diff options
Diffstat (limited to 'contrib/ntp/ntptrace/ntptrace.c')
-rw-r--r-- | contrib/ntp/ntptrace/ntptrace.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/contrib/ntp/ntptrace/ntptrace.c b/contrib/ntp/ntptrace/ntptrace.c index d69e2b0..f7106ba 100644 --- a/contrib/ntp/ntptrace/ntptrace.c +++ b/contrib/ntp/ntptrace/ntptrace.c @@ -8,18 +8,9 @@ * * Large portions stolen from ntpdate.c */ -#include <stdio.h> -#include <signal.h> -#include <ctype.h> -#include <netdb.h> -#include <sys/types.h> -#include <sys/signal.h> -#include <sys/ioctl.h> -#include <sys/time.h> -#include <sys/resource.h> -#if defined(SYS_HPUX) -#include <utmp.h> +#ifdef HAVE_CONFIG_H +# include <config.h> #endif #include "ntp_fp.h" @@ -32,6 +23,17 @@ #include "ntp_select.h" #include "ntp_stdlib.h" #include "recvbuff.h" + +#include <stdio.h> +#include <signal.h> +#include <ctype.h> +#include <netdb.h> +#include <sys/signal.h> +#ifdef HAVE_SYS_IOCTL_H +# include <sys/ioctl.h> +#endif +#include <sys/resource.h> + /* * only 16 stratums, so this is more than enough. */ @@ -59,7 +61,7 @@ int sys_retries = 5; /* # of retry attempts per server */ int sys_timeout = 2; /* timeout time, in seconds */ struct server **sys_servers; /* the server list */ int sys_numservers = 0; /* number of servers to poll */ -int sys_maxservers = NTP_MAXSTRATUM+1; /* max number of servers to deal with */ +int sys_maxservers = STRATUM_UNSPEC; /* max number of servers to deal with */ int sys_version = NTP_OLDVERSION; /* version to poll with */ @@ -242,6 +244,15 @@ DoTrace( { int retries = sys_retries; + if (!server->srcadr.sin_addr.s_addr) { + if (nonames) + printf("%s:\t*Not Synchronized*\n", ntoa(&server->srcadr)); + else + printf("%s:\t*Not Synchronized*\n", ntohost(&server->srcadr)); + fflush(stdout); + return; + } + if (!verbose) { if (nonames) printf("%s: ", ntoa(&server->srcadr)); @@ -426,7 +437,7 @@ ReceiveBuf( if ((PKT_MODE(rpkt->li_vn_mode) != MODE_SERVER && PKT_MODE(rpkt->li_vn_mode) != MODE_PASSIVE) - || rpkt->stratum > NTP_MAXSTRATUM) { + || rpkt->stratum >= STRATUM_UNSPEC) { if (debug) printf("receive: mode %d stratum %d\n", PKT_MODE(rpkt->li_vn_mode), rpkt->stratum); @@ -607,7 +618,7 @@ sendpkt( { int cc; - cc = sendto(fd, (char *)pkt, len, 0, (struct sockaddr *)dest, + cc = sendto(fd, (char *)pkt, (size_t)len, 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in)); if (cc == -1) { #ifndef SYS_WINNT |