From: Frank Kardel Date: Wed, 31 Aug 2005 08:05:42 +0000 (+0000) Subject: ntpdc_ops.c, layout.std, ntp_request.c, ntp_io.c, ntp_request.h, ntp.h: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cc62ef0b2d4fd1d03a5b59af95ce88cf96d093e;p=thirdparty%2Fntp.git ntpdc_ops.c, layout.std, ntp_request.c, ntp_io.c, ntp_request.h, ntp.h: output interface life time in log and via ntpdc bk: 431564d6PnEuo466Mbk_1jyVgKEEXg --- diff --git a/include/ntp.h b/include/ntp.h index c73badaf1c..f2455eb836 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -184,6 +184,7 @@ struct interface { int last_ttl; /* last TTL specified */ u_int32 addr_refid; /* IPv4 addr or IPv6 hash */ int num_mcast; /* No. of IP addresses in multicast socket */ + u_long starttime; /* current_time as of creation of interface structure */ volatile long received; /* number of incoming packets */ long sent; /* number of outgoing packets */ long notsent; /* number of send failures */ diff --git a/include/ntp_request.h b/include/ntp_request.h index ab12c60866..8662308589 100644 --- a/include/ntp_request.h +++ b/include/ntp_request.h @@ -899,6 +899,7 @@ struct info_if_stats { int32 received; /* number of incoming packets */ int32 sent; /* number of outgoing packets */ int32 notsent; /* number of send failures */ + int32 uptime; /* number of seconds this interface was active */ u_int32 scopeid; /* Scope used for Multicasting */ u_int32 ifindex; /* interface index - from system */ u_int32 ifnum; /* sequential interface number */ diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 9ee139e9b2..df06d8d87d 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -607,11 +607,16 @@ remove_interface(struct interface *interface) if (interface->fd != INVALID_SOCKET) { - msyslog(LOG_INFO, "Deleting interface #%d %s, %s#%d", + msyslog(LOG_INFO, "Deleting interface #%d %s, %s#%d, interface stats: received=%ld, sent=%ld, dropped=%ld, active_time=%ld secs", interface->ifnum, interface->name, stoa((&interface->sin)), - NTP_PORT); /* XXX should extract port from sin structure */ + NTP_PORT, /* XXX should extract port from sin structure */ + interface->received, + interface->sent, + interface->notsent, + current_time - interface->starttime); + close_and_delete_fd_from_list(interface->fd); } diff --git a/ntpd/ntp_request.c b/ntpd/ntp_request.c index d754f39810..2887812527 100644 --- a/ntpd/ntp_request.c +++ b/ntpd/ntp_request.c @@ -2806,6 +2806,7 @@ fill_info_if_stats(void *data, interface_info_t *interface_info) ifs->scopeid = htonl(interface->scopeid); ifs->ifindex = htonl(interface->ifindex); ifs->ifnum = htonl(interface->ifnum); + ifs->uptime = htonl(current_time - interface->starttime); ifs->ignore_packets = interface->ignore_packets; ifs->peercnt = htonl(interface->peercnt); ifs->action = interface_info->action; diff --git a/ntpdc/layout.std b/ntpdc/layout.std index f7e3589ca4..a244bf7cd2 100644 --- a/ntpdc/layout.std +++ b/ntpdc/layout.std @@ -410,7 +410,7 @@ offsetof(calcnt) = 48 offsetof(errcnt) = 52 offsetof(stbcnt) = 56 -sizeof(struct info_if_stats) = 136 +sizeof(struct info_if_stats) = 140 offsetof(unaddr) = 0 offsetof(unbcast) = 16 offsetof(unmask) = 32 @@ -423,12 +423,13 @@ offsetof(num_mcast) = 96 offsetof(received) = 100 offsetof(sent) = 104 offsetof(notsent) = 108 -offsetof(scopeid) = 112 -offsetof(ifindex) = 116 -offsetof(ifnum) = 120 -offsetof(ignore_packets) = 124 -offsetof(peercnt) = 128 -offsetof(action) = 132 +offsetof(uptime) = 112 +offsetof(scopeid) = 116 +offsetof(ifindex) = 120 +offsetof(ifnum) = 124 +offsetof(ignore_packets) = 128 +offsetof(peercnt) = 132 +offsetof(action) = 136 sizeof(struct info_dns_assoc) = 32 offsetof(peeraddr) = 0 diff --git a/ntpdc/ntpdc_ops.c b/ntpdc/ntpdc_ops.c index 8c7007a3f0..51fae2c1f5 100644 --- a/ntpdc/ntpdc_ops.c +++ b/ntpdc/ntpdc_ops.c @@ -3037,11 +3037,11 @@ again: (u_long)ntohl(ik->errcnt)); } -#define IF_LIST_FMT "%2d %c %48s %c %c %12.12s %03x %3d %2d %5d %5d %5d %2d %2d %3d\n" -#define IF_LIST_FMT_STR "%2s %c %48s %c %c %12.12s %3s %3s %2s %5s %5s %5s %2s %2s %3s\n" +#define IF_LIST_FMT "%2d %c %48s %c %c %12.12s %03x %3d %2d %5d %5d %5d %2d %2d %3d %7d\n" +#define IF_LIST_FMT_STR "%2s %c %48s %c %c %12.12s %3s %3s %2s %5s %5s %5s %2s %2s %3s %7s\n" #define IF_LIST_AFMT_STR " %48s %c\n" -#define IF_LIST_LABELS "#", 'A', "Address/Mask/Broadcast", 'T', 'E', "IF name", "Flg", "TL", "#M", "recv", "sent", "drop", "S", "IX", "PC" -#define IF_LIST_LINE "=============================================================================================================\n" +#define IF_LIST_LABELS "#", 'A', "Address/Mask/Broadcast", 'T', 'E', "IF name", "Flg", "TL", "#M", "recv", "sent", "drop", "S", "IX", "PC", "uptime" +#define IF_LIST_LINE "=====================================================================================================================\n" static void iflist( @@ -3092,7 +3092,8 @@ iflist( ntohl(ifs->notsent), ntohl(ifs->scopeid), ntohl(ifs->ifindex), - ntohl(ifs->peercnt)); + ntohl(ifs->peercnt), + ntohl(ifs->uptime)); if (!ntohl(ifs->v6_flag)) { memcpy((char *)&GET_INADDR(saddr), (char *)&ifs->unbcast.addr, sizeof(ifs->unbcast.addr));