From: Dave Hart Date: Thu, 16 Dec 2010 04:42:37 +0000 (+0000) Subject: * [Bug 1740] ntpdc treats many counters as signed. (backport) X-Git-Tag: NTP_4_2_7P95~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca05a7c61f43fd9f7fe87b4b1c2a02f5027d06d4;p=thirdparty%2Fntp.git * [Bug 1740] ntpdc treats many counters as signed. (backport) * [Bug 1754] --version output should be more verbose. * Suppress ntp-keygen OpenSSL version display for --help, --version, display both build and runtime OpenSLL versions when they differ. bk: 4d0998bdLRw8G70uGiEyL0g1_2DChA --- diff --git a/ChangeLog b/ChangeLog index 8aa477ce0..9e7bf4d4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,11 +3,15 @@ * [Bug 1510] Add modes 20/21 for driver 8 to support RAWDCF @ 75 baud. * [Bug 1618] Unreachable code in jjy_start(). (backport from ntp-dev) * [Bug 1719] ntp-keygen -V crash. (backport) +* [Bug 1740] ntpdc treats many counters as signed. (backport) * [Bug 1741] Enable multicast reception on each address (Windows). * [Bug 1742] Fix a typo in an error message in the "build" script. * [Bug 1743] Display timezone offset when showing time for sntp in the local timezone. * [Bug 1751] Support for Atari FreeMiNT OS. +* [Bug 1754] --version output should be more verbose. +* Suppress ntp-keygen OpenSSL version display for --help, --version, + display both build and runtime OpenSLL versions when they differ. * Clean up m4 quoting in configure.ac, *.m4 files, resolving intermittent AC_LANG_PROGRAM possibly undefined errors. * Clean up the SNTP documentation. diff --git a/include/Makefile.am b/include/Makefile.am index 80113226c..88727ddaf 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -36,6 +36,7 @@ noinst_HEADERS = \ ntp_if.h \ ntp_intres.h \ ntp_io.h \ + ntp_libopts.h \ ntp_lineedit.h \ ntp_lists.h \ ntp_machine.h \ diff --git a/include/ntp_libopts.h b/include/ntp_libopts.h new file mode 100644 index 000000000..c4d6e165f --- /dev/null +++ b/include/ntp_libopts.h @@ -0,0 +1,13 @@ +/* + * ntp_libopts.h + * + * Common code interfacing with Autogen's libopts command-line option + * processing. + */ +#ifndef NTP_LIBOPTS_H +# define NTP_LIBOPTS_H +# include "autoopts/options.h" + +extern int ntpOptionProcess(tOptions *pOpts, int argc, + char ** argv); +#endif diff --git a/libntp/Makefile.am b/libntp/Makefile.am index a47972103..5d7289899 100644 --- a/libntp/Makefile.am +++ b/libntp/Makefile.am @@ -48,6 +48,7 @@ libntp_a_SRCS = \ msutotsf.c \ msyslog.c \ netof.c \ + ntp_libopts.c \ ntp_rfc2553.c \ numtoa.c \ numtohost.c \ diff --git a/libntp/ntp_libopts.c b/libntp/ntp_libopts.c new file mode 100644 index 000000000..d99b5bf6b --- /dev/null +++ b/libntp/ntp_libopts.c @@ -0,0 +1,50 @@ +/* + * ntp_libopts.c + * + * Common code interfacing with Autogen's libopts command-line option + * processing. + */ +#include +#include +#include "ntp_libopts.h" +#include "autoopts/options.h" +#include "ntp_stdlib.h" + +extern const char *Version; /* version.c for each program */ + + +/* + * ntpOptionProcess() is a clone of libopts' optionProcess which + * overrides the --version output, appending detail from version.c + * which was not available at Autogen time. + */ +int +ntpOptionProcess( + tOptions * pOpts, + int argc, + char ** argv + ) +{ + u_char Opts[sizeof(*pOpts)]; + char ** ppzFullVersion; + char * pzNewFV; + const char * pzAutogenFV; + size_t octets; + int rc; + + memcpy(Opts, pOpts, sizeof(Opts)); + ppzFullVersion = (char **)(Opts + offsetof(struct options, + pzFullVersion)); + pzAutogenFV = *ppzFullVersion; + octets = strlen(pzAutogenFV) + + 1 + /* '\n' */ + strlen(Version) + + 1; /* '\0' */ + pzNewFV = emalloc(octets); + snprintf(pzNewFV, octets, "%s\n%s", pzAutogenFV, Version); + *ppzFullVersion = pzNewFV; + rc = optionProcess((tOptions *)Opts, argc, argv); + free(pzNewFV); + + return rc; +} diff --git a/ntpd/ntp_scanner.c b/ntpd/ntp_scanner.c index 0052526f9..d3c9f826f 100644 --- a/ntpd/ntp_scanner.c +++ b/ntpd/ntp_scanner.c @@ -292,8 +292,8 @@ is_double( char *lexeme ) { - int num_digits = 0; /* Number of digits read */ - int i; + u_int num_digits = 0; /* Number of digits read */ + u_int i; i = 0; diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index a1e83b764..b2884de0f 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -22,6 +22,7 @@ # include "ntpsim.h" #endif +#include "ntp_libopts.h" #include "ntpd-opts.h" #ifdef HAVE_UNISTD_H @@ -324,7 +325,7 @@ process_commandline_opts( { int optct; - optct = optionProcess(&ntpdOptions, *pargc, *pargv); + optct = ntpOptionProcess(&ntpdOptions, *pargc, *pargv); *pargc -= optct; *pargv += optct; } diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c index 027c5f4a5..1ec269ef0 100644 --- a/ntpdc/ntpdc.c +++ b/ntpdc/ntpdc.c @@ -18,6 +18,7 @@ #include "isc/result.h" #include +#include "ntp_libopts.h" #include "ntpdc-opts.h" #ifdef SYS_WINNT @@ -290,7 +291,7 @@ ntpdcmain( progname = argv[0]; { - int optct = optionProcess(&ntpdcOptions, argc, argv); + int optct = ntpOptionProcess(&ntpdcOptions, argc, argv); argc -= optct; argv += optct; } diff --git a/ntpdc/ntpdc_ops.c b/ntpdc/ntpdc_ops.c index eac081c56..9350c8cea 100644 --- a/ntpdc/ntpdc_ops.c +++ b/ntpdc/ntpdc_ops.c @@ -520,7 +520,7 @@ again: ((pcmd->argval->ival == 6) && (plist->v6_flag != 0)) || ((pcmd->argval->ival == 4) && (plist->v6_flag == 0))) (void) fprintf(fp, - "%c%-15.15s %-15.15s %2d %4d %3o %7.7s %9.9s %7.7s\n", + "%c%-15.15s %-15.15s %2u %4d %3o %7.7s %9.9s %7.7s\n", c, nntohost(&srcadr), stoa(&dstadr), plist->stratum, ntp_poll, plist->reach, fptoa(NTOHS_FP(plist->delay), 5), @@ -844,37 +844,37 @@ again: src.sa.sa_len = SOCKLEN(&src); dst.sa.sa_len = SOCKLEN(&dst); #endif - (void) fprintf(fp, "remote host: %s\n", - nntohost(&src)); - (void) fprintf(fp, "local interface: %s\n", - stoa(&dst)); - (void) fprintf(fp, "time last received: %lds\n", - (long)ntohl(pp->timereceived)); - (void) fprintf(fp, "time until next send: %lds\n", - (long)ntohl(pp->timetosend)); - (void) fprintf(fp, "reachability change: %lds\n", - (long)ntohl(pp->timereachable)); - (void) fprintf(fp, "packets sent: %ld\n", - (long)ntohl(pp->sent)); - (void) fprintf(fp, "packets received: %ld\n", - (long)ntohl(pp->processed)); - (void) fprintf(fp, "bad authentication: %ld\n", - (long)ntohl(pp->badauth)); - (void) fprintf(fp, "bogus origin: %ld\n", - (long)ntohl(pp->bogusorg)); - (void) fprintf(fp, "duplicate: %ld\n", - (long)ntohl(pp->oldpkt)); - (void) fprintf(fp, "bad dispersion: %ld\n", - (long)ntohl(pp->seldisp)); - (void) fprintf(fp, "bad reference time: %ld\n", - (long)ntohl(pp->selbroken)); - (void) fprintf(fp, "candidate order: %d\n", - (int)pp->candidate); + fprintf(fp, "remote host: %s\n", + nntohost(&src)); + fprintf(fp, "local interface: %s\n", + stoa(&dst)); + fprintf(fp, "time last received: %lus\n", + (u_long)ntohl(pp->timereceived)); + fprintf(fp, "time until next send: %lus\n", + (u_long)ntohl(pp->timetosend)); + fprintf(fp, "reachability change: %lus\n", + (u_long)ntohl(pp->timereachable)); + fprintf(fp, "packets sent: %lu\n", + (u_long)ntohl(pp->sent)); + fprintf(fp, "packets received: %lu\n", + (u_long)ntohl(pp->processed)); + fprintf(fp, "bad authentication: %lu\n", + (u_long)ntohl(pp->badauth)); + fprintf(fp, "bogus origin: %lu\n", + (u_long)ntohl(pp->bogusorg)); + fprintf(fp, "duplicate: %lu\n", + (u_long)ntohl(pp->oldpkt)); + fprintf(fp, "bad dispersion: %lu\n", + (u_long)ntohl(pp->seldisp)); + fprintf(fp, "bad reference time: %lu\n", + (u_long)ntohl(pp->selbroken)); + fprintf(fp, "candidate order: %u\n", + pp->candidate); if (items > 0) - (void) fprintf(fp, "\n"); - (void) fprintf(fp, "flags: "); + fprintf(fp, "\n"); + fprintf(fp, "flags: "); print_pflag(fp, ntohs(pp->flags)); - pp++; + pp++; } } @@ -1079,30 +1079,30 @@ again: checkitemsize(itemsize, sizeof(struct info_sys_stats)); return; } - fprintf(fp, "time since restart: %ld\n", - (u_long)ntohl(ss->timeup)); - fprintf(fp, "time since reset: %ld\n", + fprintf(fp, "time since restart: %lu\n", + (u_long)ntohl(ss->timeup)); + fprintf(fp, "time since reset: %lu\n", (u_long)ntohl(ss->timereset)); - fprintf(fp, "packets received: %ld\n", + fprintf(fp, "packets received: %lu\n", (u_long)ntohl(ss->received)); - fprintf(fp, "packets processed: %ld\n", + fprintf(fp, "packets processed: %lu\n", (u_long)ntohl(ss->processed)); - fprintf(fp, "current version: %ld\n", - (u_long)ntohl(ss->newversionpkt)); - fprintf(fp, "previous version: %ld\n", - (u_long)ntohl(ss->oldversionpkt)); - fprintf(fp, "declined: %ld\n", - (u_long)ntohl(ss->unknownversion)); - fprintf(fp, "access denied: %ld\n", + fprintf(fp, "current version: %lu\n", + (u_long)ntohl(ss->newversionpkt)); + fprintf(fp, "previous version: %lu\n", + (u_long)ntohl(ss->oldversionpkt)); + fprintf(fp, "declined: %lu\n", + (u_long)ntohl(ss->unknownversion)); + fprintf(fp, "access denied: %lu\n", (u_long)ntohl(ss->denied)); - fprintf(fp, "bad length or format: %ld\n", - (u_long)ntohl(ss->badlength)); - fprintf(fp, "bad authentication: %ld\n", - (u_long)ntohl(ss->badauth)); + fprintf(fp, "bad length or format: %lu\n", + (u_long)ntohl(ss->badlength)); + fprintf(fp, "bad authentication: %lu\n", + (u_long)ntohl(ss->badauth)); if (itemsize != sizeof(struct info_sys_stats)) return; - fprintf(fp, "rate exceeded: %ld\n", + fprintf(fp, "rate exceeded: %lu\n", (u_long)ntohl(ss->limitrejected)); } @@ -1124,9 +1124,8 @@ iostats( int res; again: - res = doquery(impl_ver, REQ_IO_STATS, 0, 0, 0, (char *)NULL, - &items, &itemsize, (void *)&io, 0, - sizeof(struct info_io_stats)); + res = doquery(impl_ver, REQ_IO_STATS, 0, 0, 0, NULL, &items, + &itemsize, (void *)&io, 0, sizeof(*io)); if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) { impl_ver = IMPL_XNTPD_OLD; @@ -1134,38 +1133,38 @@ again: } if (res != 0) - return; + return; if (!check1item(items, fp)) - return; + return; - if (!checkitemsize(itemsize, sizeof(struct info_io_stats))) - return; + if (!checkitemsize(itemsize, sizeof(*io))) + return; - (void) fprintf(fp, "time since reset: %ld\n", - (u_long)ntohl(io->timereset)); - (void) fprintf(fp, "receive buffers: %d\n", - ntohs(io->totalrecvbufs)); - (void) fprintf(fp, "free receive buffers: %d\n", - ntohs(io->freerecvbufs)); - (void) fprintf(fp, "used receive buffers: %d\n", - ntohs(io->fullrecvbufs)); - (void) fprintf(fp, "low water refills: %d\n", - ntohs(io->lowwater)); - (void) fprintf(fp, "dropped packets: %ld\n", - (u_long)ntohl(io->dropped)); - (void) fprintf(fp, "ignored packets: %ld\n", - (u_long)ntohl(io->ignored)); - (void) fprintf(fp, "received packets: %ld\n", - (u_long)ntohl(io->received)); - (void) fprintf(fp, "packets sent: %ld\n", - (u_long)ntohl(io->sent)); - (void) fprintf(fp, "packets not sent: %ld\n", - (u_long)ntohl(io->notsent)); - (void) fprintf(fp, "interrupts handled: %ld\n", - (u_long)ntohl(io->interrupts)); - (void) fprintf(fp, "received by int: %ld\n", - (u_long)ntohl(io->int_received)); + fprintf(fp, "time since reset: %lu\n", + (u_long)ntohl(io->timereset)); + fprintf(fp, "receive buffers: %u\n", + (u_int)ntohs(io->totalrecvbufs)); + fprintf(fp, "free receive buffers: %u\n", + (u_int)ntohs(io->freerecvbufs)); + fprintf(fp, "used receive buffers: %u\n", + (u_int)ntohs(io->fullrecvbufs)); + fprintf(fp, "low water refills: %u\n", + (u_int)ntohs(io->lowwater)); + fprintf(fp, "dropped packets: %lu\n", + (u_long)ntohl(io->dropped)); + fprintf(fp, "ignored packets: %lu\n", + (u_long)ntohl(io->ignored)); + fprintf(fp, "received packets: %lu\n", + (u_long)ntohl(io->received)); + fprintf(fp, "packets sent: %lu\n", + (u_long)ntohl(io->sent)); + fprintf(fp, "packets not sent: %lu\n", + (u_long)ntohl(io->notsent)); + fprintf(fp, "interrupts handled: %lu\n", + (u_long)ntohl(io->interrupts)); + fprintf(fp, "received by int: %lu\n", + (u_long)ntohl(io->int_received)); } @@ -1186,9 +1185,8 @@ memstats( int res; again: - res = doquery(impl_ver, REQ_MEM_STATS, 0, 0, 0, (char *)NULL, - &items, &itemsize, (void *)&mem, 0, - sizeof(struct info_mem_stats)); + res = doquery(impl_ver, REQ_MEM_STATS, 0, 0, 0, NULL, &items, + &itemsize, (void *)&mem, 0, sizeof(*mem)); if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) { impl_ver = IMPL_XNTPD_OLD; @@ -1196,35 +1194,34 @@ again: } if (res != 0) - return; + return; if (!check1item(items, fp)) - return; + return; - if (!checkitemsize(itemsize, sizeof(struct info_mem_stats))) - return; + if (!checkitemsize(itemsize, sizeof(*mem))) + return; - (void) fprintf(fp, "time since reset: %ld\n", - (u_long)ntohl(mem->timereset)); - (void) fprintf(fp, "total peer memory: %d\n", - ntohs(mem->totalpeermem)); - (void) fprintf(fp, "free peer memory: %d\n", - ntohs(mem->freepeermem)); - (void) fprintf(fp, "calls to findpeer: %ld\n", - (u_long)ntohl(mem->findpeer_calls)); - (void) fprintf(fp, "new peer allocations: %ld\n", - (u_long)ntohl(mem->allocations)); - (void) fprintf(fp, "peer demobilizations: %ld\n", - (u_long)ntohl(mem->demobilizations)); - - (void) fprintf(fp, "hash table counts: "); + fprintf(fp, "time since reset: %lu\n", + (u_long)ntohl(mem->timereset)); + fprintf(fp, "total peer memory: %u\n", + (u_int)ntohs(mem->totalpeermem)); + fprintf(fp, "free peer memory: %u\n", + (u_int)ntohs(mem->freepeermem)); + fprintf(fp, "calls to findpeer: %lu\n", + (u_long)ntohl(mem->findpeer_calls)); + fprintf(fp, "new peer allocations: %lu\n", + (u_long)ntohl(mem->allocations)); + fprintf(fp, "peer demobilizations: %lu\n", + (u_long)ntohl(mem->demobilizations)); + + fprintf(fp, "hash table counts: "); for (i = 0; i < NTP_HASH_SIZE; i++) { - (void) fprintf(fp, "%4d", (int)mem->hashcount[i]); - if ((i % 8) == 7 && i != (NTP_HASH_SIZE-1)) { - (void) fprintf(fp, "\n "); - } + fprintf(fp, "%4d", (int)mem->hashcount[i]); + if ((i % 8) == 7 && i != (NTP_HASH_SIZE-1)) + fprintf(fp, "\n "); } - (void) fprintf(fp, "\n"); + fprintf(fp, "\n"); } @@ -1245,9 +1242,8 @@ timerstats( int res; again: - res = doquery(impl_ver, REQ_TIMER_STATS, 0, 0, 0, (char *)NULL, - &items, &itemsize, (void *)&tim, 0, - sizeof(struct info_timer_stats)); + res = doquery(impl_ver, REQ_TIMER_STATS, 0, 0, 0, NULL, &items, + &itemsize, (void *)&tim, 0, sizeof(*tim)); if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) { impl_ver = IMPL_XNTPD_OLD; @@ -1255,22 +1251,22 @@ again: } if (res != 0) - return; + return; if (!check1item(items, fp)) - return; + return; - if (!checkitemsize(itemsize, sizeof(struct info_timer_stats))) - return; + if (!checkitemsize(itemsize, sizeof(*tim))) + return; - (void) fprintf(fp, "time since reset: %ld\n", - (u_long)ntohl(tim->timereset)); - (void) fprintf(fp, "alarms handled: %ld\n", - (u_long)ntohl(tim->alarms)); - (void) fprintf(fp, "alarm overruns: %ld\n", - (u_long)ntohl(tim->overflows)); - (void) fprintf(fp, "calls to transmit: %ld\n", - (u_long)ntohl(tim->xmtcalls)); + fprintf(fp, "time since reset: %lu\n", + (u_long)ntohl(tim->timereset)); + fprintf(fp, "alarms handled: %lu\n", + (u_long)ntohl(tim->alarms)); + fprintf(fp, "alarm overruns: %lu\n", + (u_long)ntohl(tim->overflows)); + fprintf(fp, "calls to transmit: %lu\n", + (u_long)ntohl(tim->xmtcalls)); } @@ -1782,11 +1778,11 @@ again: } if (flagstr[0] == '\0') - (void) strcpy(flagstr, "none"); + strcpy(flagstr, "none"); if (!skip) - (void) fprintf(fp, "%-15.15s %-15.15s %9ld %s\n", - addr, mask, (u_long)count, flagstr); + fprintf(fp, "%-15.15s %-15.15s %9lu %s\n", + addr, mask, (u_long)count, flagstr); rl++; items--; } @@ -2012,8 +2008,8 @@ again: if ((pcmd->nargs == 0) || ((pcmd->argval->ival == 6) && (ml->v6_flag != 0)) || ((pcmd->argval->ival == 4) && (ml->v6_flag == 0))) - (void) fprintf(fp, - "%-22.22s %5d %-15s %8ld %1d %1d %6lx %6lu %7lu\n", + fprintf(fp, + "%-22.22s %5d %-15s %8lu %1u %1u %6lx %6lu %7lu\n", nntohost(&addr), ntohs(ml->port), stoa(&dstadr), @@ -2040,7 +2036,7 @@ again: ((pcmd->argval->ival == 6) && (ml->v6_flag != 0)) || ((pcmd->argval->ival == 4) && (ml->v6_flag == 0))) (void) fprintf(fp, - "%-25.25s %5d %9ld %4d %2d %9lx %9lu %9lu\n", + "%-25.25s %5u %9lu %4u %2u %9lx %9lu %9lu\n", nntohost(&dstadr), ntohs(ml->port), (u_long)ntohl(ml->count), @@ -2060,7 +2056,7 @@ again: "======================================================================\n"); while (items > 0) { SET_ADDR(dstadr, oml->v6_flag, oml->addr, oml->addr6); - (void) fprintf(fp, "%-20.20s %5d %9ld %4d %3d %9lu %9lu\n", + (void) fprintf(fp, "%-20.20s %5u %9lu %4u %3u %9lu %9lu\n", nntohost(&dstadr), ntohs(oml->port), (u_long)ntohl(oml->count), @@ -2320,9 +2316,8 @@ authinfo( int res; again: - res = doquery(impl_ver, REQ_AUTHINFO, 0, 0, 0, (char *)NULL, - &items, &itemsize, (void *)&ia, 0, - sizeof(struct info_auth)); + res = doquery(impl_ver, REQ_AUTHINFO, 0, 0, 0, NULL, &items, + &itemsize, (void *)&ia, 0, sizeof(*ia)); if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) { impl_ver = IMPL_XNTPD_OLD; @@ -2330,32 +2325,32 @@ again: } if (res != 0) - return; + return; if (!check1item(items, fp)) - return; + return; - if (!checkitemsize(itemsize, sizeof(struct info_auth))) - return; + if (!checkitemsize(itemsize, sizeof(*ia))) + return; - (void) fprintf(fp, "time since reset: %ld\n", - (u_long)ntohl(ia->timereset)); - (void) fprintf(fp, "stored keys: %ld\n", - (u_long)ntohl(ia->numkeys)); - (void) fprintf(fp, "free keys: %ld\n", - (u_long)ntohl(ia->numfreekeys)); - (void) fprintf(fp, "key lookups: %ld\n", - (u_long)ntohl(ia->keylookups)); - (void) fprintf(fp, "keys not found: %ld\n", - (u_long)ntohl(ia->keynotfound)); - (void) fprintf(fp, "uncached keys: %ld\n", - (u_long)ntohl(ia->keyuncached)); - (void) fprintf(fp, "encryptions: %ld\n", - (u_long)ntohl(ia->encryptions)); - (void) fprintf(fp, "decryptions: %ld\n", - (u_long)ntohl(ia->decryptions)); - (void) fprintf(fp, "expired keys: %ld\n", - (u_long)ntohl(ia->expired)); + fprintf(fp, "time since reset: %lu\n", + (u_long)ntohl(ia->timereset)); + fprintf(fp, "stored keys: %lu\n", + (u_long)ntohl(ia->numkeys)); + fprintf(fp, "free keys: %lu\n", + (u_long)ntohl(ia->numfreekeys)); + fprintf(fp, "key lookups: %lu\n", + (u_long)ntohl(ia->keylookups)); + fprintf(fp, "keys not found: %lu\n", + (u_long)ntohl(ia->keynotfound)); + fprintf(fp, "uncached keys: %lu\n", + (u_long)ntohl(ia->keyuncached)); + fprintf(fp, "encryptions: %lu\n", + (u_long)ntohl(ia->encryptions)); + fprintf(fp, "decryptions: %lu\n", + (u_long)ntohl(ia->decryptions)); + fprintf(fp, "expired keys: %lu\n", + (u_long)ntohl(ia->expired)); } @@ -2602,9 +2597,8 @@ ctlstats( int res; again: - res = doquery(impl_ver, REQ_GET_CTLSTATS, 0, 0, 0, (char *)NULL, - &items, &itemsize, (void *)&ic, 0, - sizeof(struct info_control)); + res = doquery(impl_ver, REQ_GET_CTLSTATS, 0, 0, 0, NULL, &items, + &itemsize, (void *)&ic, 0, sizeof(*ic)); if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) { impl_ver = IMPL_XNTPD_OLD; @@ -2612,44 +2606,44 @@ again: } if (res != 0) - return; + return; if (!check1item(items, fp)) - return; + return; - if (!checkitemsize(itemsize, sizeof(struct info_control))) - return; + if (!checkitemsize(itemsize, sizeof(*ic))) + return; - (void) fprintf(fp, "time since reset: %ld\n", - (u_long)ntohl(ic->ctltimereset)); - (void) fprintf(fp, "requests received: %ld\n", - (u_long)ntohl(ic->numctlreq)); - (void) fprintf(fp, "responses sent: %ld\n", - (u_long)ntohl(ic->numctlresponses)); - (void) fprintf(fp, "fragments sent: %ld\n", - (u_long)ntohl(ic->numctlfrags)); - (void) fprintf(fp, "async messages sent: %ld\n", - (u_long)ntohl(ic->numasyncmsgs)); - (void) fprintf(fp, "error msgs sent: %ld\n", - (u_long)ntohl(ic->numctlerrors)); - (void) fprintf(fp, "total bad pkts: %ld\n", - (u_long)ntohl(ic->numctlbadpkts)); - (void) fprintf(fp, "packet too short: %ld\n", - (u_long)ntohl(ic->numctltooshort)); - (void) fprintf(fp, "response on input: %ld\n", - (u_long)ntohl(ic->numctlinputresp)); - (void) fprintf(fp, "fragment on input: %ld\n", - (u_long)ntohl(ic->numctlinputfrag)); - (void) fprintf(fp, "error set on input: %ld\n", - (u_long)ntohl(ic->numctlinputerr)); - (void) fprintf(fp, "bad offset on input: %ld\n", - (u_long)ntohl(ic->numctlbadoffset)); - (void) fprintf(fp, "bad version packets: %ld\n", - (u_long)ntohl(ic->numctlbadversion)); - (void) fprintf(fp, "data in pkt too short: %ld\n", - (u_long)ntohl(ic->numctldatatooshort)); - (void) fprintf(fp, "unknown op codes: %ld\n", - (u_long)ntohl(ic->numctlbadop)); + fprintf(fp, "time since reset: %lu\n", + (u_long)ntohl(ic->ctltimereset)); + fprintf(fp, "requests received: %lu\n", + (u_long)ntohl(ic->numctlreq)); + fprintf(fp, "responses sent: %lu\n", + (u_long)ntohl(ic->numctlresponses)); + fprintf(fp, "fragments sent: %lu\n", + (u_long)ntohl(ic->numctlfrags)); + fprintf(fp, "async messages sent: %lu\n", + (u_long)ntohl(ic->numasyncmsgs)); + fprintf(fp, "error msgs sent: %lu\n", + (u_long)ntohl(ic->numctlerrors)); + fprintf(fp, "total bad pkts: %lu\n", + (u_long)ntohl(ic->numctlbadpkts)); + fprintf(fp, "packet too short: %lu\n", + (u_long)ntohl(ic->numctltooshort)); + fprintf(fp, "response on input: %lu\n", + (u_long)ntohl(ic->numctlinputresp)); + fprintf(fp, "fragment on input: %lu\n", + (u_long)ntohl(ic->numctlinputfrag)); + fprintf(fp, "error set on input: %lu\n", + (u_long)ntohl(ic->numctlinputerr)); + fprintf(fp, "bad offset on input: %lu\n", + (u_long)ntohl(ic->numctlbadoffset)); + fprintf(fp, "bad version packets: %lu\n", + (u_long)ntohl(ic->numctlbadversion)); + fprintf(fp, "data in pkt too short: %lu\n", + (u_long)ntohl(ic->numctldatatooshort)); + fprintf(fp, "unknown op codes: %lu\n", + (u_long)ntohl(ic->numctlbadop)); } @@ -3057,7 +3051,7 @@ again: (u_long)ntohl(ik->errcnt)); } -#define IF_LIST_FMT "%2d %c %48s %c %c %12.12s %03x %3d %2d %5d %5d %5d %2d %3d %7d\n" +#define IF_LIST_FMT "%2d %c %48s %c %c %12.12s %03lx %3lu %2lu %5lu %5lu %5lu %2lu %3lu %7lu\n" #define IF_LIST_FMT_STR "%2s %c %48s %c %c %12.12s %3s %3s %2s %5s %5s %5s %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", "PC", "uptime" @@ -3096,15 +3090,15 @@ iflist( stoa((&saddr)), 'A', ifs->ignore_packets ? 'D' : 'E', ifs->name, - ntohl(ifs->flags), - ntohl(ifs->last_ttl), - ntohl(ifs->num_mcast), - ntohl(ifs->received), - ntohl(ifs->sent), - ntohl(ifs->notsent), - ntohl(ifs->scopeid), - ntohl(ifs->peercnt), - ntohl(ifs->uptime)); + (u_long)ntohl(ifs->flags), + (u_long)ntohl(ifs->last_ttl), + (u_long)ntohl(ifs->num_mcast), + (u_long)ntohl(ifs->received), + (u_long)ntohl(ifs->sent), + (u_long)ntohl(ifs->notsent), + (u_long)ntohl(ifs->scopeid), + (u_long)ntohl(ifs->peercnt), + (u_long)ntohl(ifs->uptime)); SET_ADDR(saddr, ntohl(ifs->v6_flag), ifs->unmask.addr.s_addr, ifs->unmask.addr6); diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index c1b175f72..c8d26a5d4 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -23,6 +23,7 @@ #include "isc/result.h" #include +#include "ntp_libopts.h" #include "ntpq-opts.h" #ifdef SYS_WINNT @@ -515,7 +516,7 @@ ntpqmain( progname = argv[0]; { - int optct = optionProcess(&ntpqOptions, argc, argv); + int optct = ntpOptionProcess(&ntpqOptions, argc, argv); argc -= optct; argv += optct; } diff --git a/ports/winnt/vc6/libntp.dsp b/ports/winnt/vc6/libntp.dsp index 34f930f50..68e27e61b 100644 --- a/ports/winnt/vc6/libntp.dsp +++ b/ports/winnt/vc6/libntp.dsp @@ -314,6 +314,10 @@ SOURCE=..\..\..\lib\isc\netscope.c # End Source File # Begin Source File +SOURCE=..\..\..\libntp\ntp_libopts.c +# End Source File +# Begin Source File + SOURCE=..\..\..\libntp\ntp_lineedit.c # End Source File # Begin Source File diff --git a/ports/winnt/vc6/ntpkeygen.dsp b/ports/winnt/vc6/ntpkeygen.dsp index ef06b3d15..5a5067189 100644 --- a/ports/winnt/vc6/ntpkeygen.dsp +++ b/ports/winnt/vc6/ntpkeygen.dsp @@ -131,7 +131,7 @@ InputPath=..\..\..\configure "$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo Using NT Shell Script to generate version.c - ..\scripts\mkver.bat -P ntpkeygen + ..\scripts\mkver.bat -P ntp-keygen # End Custom Build @@ -143,7 +143,7 @@ InputPath=..\..\..\configure "$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo Using NT Shell Script to generate version.c - ..\scripts\mkver.bat -P ntpkeygen + ..\scripts\mkver.bat -P ntp-keygen # End Custom Build diff --git a/ports/winnt/vs2003/libntp.vcproj b/ports/winnt/vs2003/libntp.vcproj index 3243b2d05..ab70cfe7a 100644 --- a/ports/winnt/vs2003/libntp.vcproj +++ b/ports/winnt/vs2003/libntp.vcproj @@ -1244,6 +1244,9 @@ PreprocessorDefinitions=""/> + + @@ -291,7 +291,7 @@ diff --git a/ports/winnt/vs2005/libntp.vcproj b/ports/winnt/vs2005/libntp.vcproj index 28c202f69..6440137d5 100644 --- a/ports/winnt/vs2005/libntp.vcproj +++ b/ports/winnt/vs2005/libntp.vcproj @@ -1332,6 +1332,10 @@ /> + + diff --git a/ports/winnt/vs2005/ntpkeygen.vcproj b/ports/winnt/vs2005/ntpkeygen.vcproj index dea8c4094..18fb7180f 100644 --- a/ports/winnt/vs2005/ntpkeygen.vcproj +++ b/ports/winnt/vs2005/ntpkeygen.vcproj @@ -356,7 +356,7 @@ > @@ -365,7 +365,7 @@ > diff --git a/ports/winnt/vs2008/libntp/libntp.vcproj b/ports/winnt/vs2008/libntp/libntp.vcproj index 54c1c24a7..b73659cc5 100644 --- a/ports/winnt/vs2008/libntp/libntp.vcproj +++ b/ports/winnt/vs2008/libntp/libntp.vcproj @@ -411,6 +411,10 @@ RelativePath="..\..\..\..\lib\isc\netscope.c" > + + @@ -696,6 +700,10 @@ RelativePath="..\..\include\ntp_iocompletionport.h" > + + diff --git a/ports/winnt/vs2008/ntp-keygen/ntp-keygen.vcproj b/ports/winnt/vs2008/ntp-keygen/ntp-keygen.vcproj index 44bf985a7..87831a2fe 100644 --- a/ports/winnt/vs2008/ntp-keygen/ntp-keygen.vcproj +++ b/ports/winnt/vs2008/ntp-keygen/ntp-keygen.vcproj @@ -220,28 +220,6 @@ Name="Source Files" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > - - - - - - - - @@ -288,50 +266,6 @@ /> - - - - - - - - - - - - - - - - @@ -377,7 +311,7 @@ > @@ -386,7 +320,7 @@ > diff --git a/ports/winnt/vs2008/ntpd/ntpd.vcproj b/ports/winnt/vs2008/ntpd/ntpd.vcproj index a257979be..04eb8a0d1 100644 --- a/ports/winnt/vs2008/ntpd/ntpd.vcproj +++ b/ports/winnt/vs2008/ntpd/ntpd.vcproj @@ -856,6 +856,10 @@ RelativePath="..\..\..\..\ntpd\ntp_keyword.h" > + + diff --git a/util/Makefile.am b/util/Makefile.am index 94dc975e5..fff330329 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -20,13 +20,14 @@ AM_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \ # LDADD might need RESLIB and ADJLIB LDADD= ../libntp/libntp.a ntp_keygen_SOURCES = ntp-keygen.c ntp-keygen-opts.c ntp-keygen-opts.h -ntp_keygen_LDADD= $(LIBOPTS_LDADD) ../libntp/libntp.a @LCRYPTO@ +ntp_keygen_LDADD= version.o $(LIBOPTS_LDADD) ../libntp/libntp.a @LCRYPTO@ ETAGS_ARGS= Makefile.am #EXTRA_DIST= README TAGS EXTRA_DIST= ntp-keygen-opts.def ntp-keygen.1 ntp-keygen-opts.texi ntp-keygen-opts.menu BUILT_SOURCES= ntp-keygen-opts.c ntp-keygen-opts.h CLEANFILES= +DISTCLEANFILES= .version version.c noinst_DATA= $(srcdir)/ntp-keygen-opts.texi $(srcdir)/ntp-keygen-opts.menu man_MANS= $(srcdir)/ntp-keygen.1 run_ag= cd $(srcdir) && env PATH="$(abs_builddir):$(PATH)" \ @@ -62,5 +63,12 @@ jitter_LDADD= kern.o: kern.c $(COMPILE) -DHAVE_TIMEX_H -c kern.c +$(top_srcdir)/version : + cd $(top_srcdir) && $(MAKE) version + +version.o: $(ntpq_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version + env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntp-keygen + $(COMPILE) -c version.c + include $(top_srcdir)/bincheck.mf include $(top_srcdir)/depsver.mf diff --git a/util/ntp-keygen.c b/util/ntp-keygen.c index aad592a53..66d074f3f 100644 --- a/util/ntp-keygen.c +++ b/util/ntp-keygen.c @@ -93,6 +93,7 @@ #include "ntp_stdlib.h" #include "ntp_assert.h" +#include "ntp_libopts.h" #include "ntp-keygen-opts.h" #ifdef OPENSSL @@ -258,7 +259,6 @@ main( #ifdef OPENSSL ssl_check_version(); - fprintf(stderr, "Using OpenSSL version %lx\n", SSLeay()); #endif /* OPENSSL */ /* @@ -271,10 +271,21 @@ main( epoch = tv.tv_sec; { - int optct = optionProcess(&ntp_keygenOptions, argc, argv); + int optct = ntpOptionProcess(&ntp_keygenOptions, + argc, argv); argc -= optct; argv += optct; } + +#ifdef OPENSSL + if (SSLeay() == SSLEAY_VERSION_NUMBER) + fprintf(stderr, "Using OpenSSL version %s\n", + SSLeay_version(SSLEAY_VERSION)); + else + fprintf(stderr, "Built against OpenSSL %s, using version %s\n", + OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); +#endif /* OPENSSL */ + debug = DESC(DEBUG_LEVEL).optOccCt; if (HAVE_OPT( MD5KEY )) md5key++;