]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
* [Bug 1740] ntpdc treats many counters as signed. (backport)
authorDave Hart <hart@ntp.org>
Thu, 16 Dec 2010 04:42:37 +0000 (04:42 +0000)
committerDave Hart <hart@ntp.org>
Thu, 16 Dec 2010 04:42:37 +0000 (04:42 +0000)
* [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

21 files changed:
ChangeLog
include/Makefile.am
include/ntp_libopts.h [new file with mode: 0644]
libntp/Makefile.am
libntp/ntp_libopts.c [new file with mode: 0644]
ntpd/ntp_scanner.c
ntpd/ntpd.c
ntpdc/ntpdc.c
ntpdc/ntpdc_ops.c
ntpq/ntpq.c
ports/winnt/vc6/libntp.dsp
ports/winnt/vc6/ntpkeygen.dsp
ports/winnt/vs2003/libntp.vcproj
ports/winnt/vs2003/ntpkeygen.vcproj
ports/winnt/vs2005/libntp.vcproj
ports/winnt/vs2005/ntpkeygen.vcproj
ports/winnt/vs2008/libntp/libntp.vcproj
ports/winnt/vs2008/ntp-keygen/ntp-keygen.vcproj
ports/winnt/vs2008/ntpd/ntpd.vcproj
util/Makefile.am
util/ntp-keygen.c

index 8aa477ce056db22e21a6105514189476286c0a9f..9e7bf4d4d7dbe127f86861962704275154247869 100644 (file)
--- 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.
index 80113226c07a8be667251863f5e645e8e22913a3..88727ddaf4e51c7e5a3867b4f861e755d83b5481 100644 (file)
@@ -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 (file)
index 0000000..c4d6e16
--- /dev/null
@@ -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
index a47972103d598fbfbedd63ea25aa916907503c05..5d728989939ad392ad51b8207ec991053e8d3770 100644 (file)
@@ -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 (file)
index 0000000..d99b5bf
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ntp_libopts.c
+ *
+ * Common code interfacing with Autogen's libopts command-line option
+ * processing.
+ */
+#include <stdio.h>
+#include <stddef.h>
+#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;
+}
index 0052526f9cbf87a7c1e82e331a16e04d48ff44f5..d3c9f826f8f9dade26bc2ff9d66909d527f67d01 100644 (file)
@@ -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;
 
index a1e83b764ed4e115a65c9c91421315e0f8fc42df..b2884de0fe6c67525cf6b9df4e4739a9e8cc7497 100644 (file)
@@ -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;
 }
index 027c5f4a5eae1044c69373e7da6460e6bb3f5df6..1ec269ef0ac4b67cb9190cc0ff9e450e9827bfd4 100644 (file)
@@ -18,6 +18,7 @@
 #include "isc/result.h"
 #include <ssl_applink.c>
 
+#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;
        }
index eac081c56e616fd48c8744d0e386c61145a024cb..9350c8ceaa86d270677ff36999a988a9de0c56ce 100644 (file)
@@ -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);
index c1b175f727db9abd79fd35fafbc046aec186cf3b..c8d26a5d4ddb3ff7e8a86d4ce901f004e286336d 100644 (file)
@@ -23,6 +23,7 @@
 #include "isc/result.h"
 #include <ssl_applink.c>
 
+#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;
        }
index 34f930f501ad327d6df8a3ccbe7f86435e7e7d8b..68e27e61be368015b426975eedf479fe62fddb94 100644 (file)
@@ -314,6 +314,10 @@ SOURCE=..\..\..\lib\isc\netscope.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\..\libntp\ntp_libopts.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\..\libntp\ntp_lineedit.c\r
 # End Source File\r
 # Begin Source File\r
index ef06b3d15a77ccfb45c8c3f8554691d8cdc28a12..5a506718927ddcb0f229c9b18ca698964c49fe07 100644 (file)
@@ -131,7 +131,7 @@ InputPath=..\..\..\configure
 \r
 "$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
        echo Using NT Shell Script to generate version.c \r
-       ..\scripts\mkver.bat -P ntpkeygen \r
+       ..\scripts\mkver.bat -P ntp-keygen \r
        \r
 # End Custom Build\r
 \r
@@ -143,7 +143,7 @@ InputPath=..\..\..\configure
 \r
 "$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
        echo Using NT Shell Script to generate version.c \r
-       ..\scripts\mkver.bat -P ntpkeygen \r
+       ..\scripts\mkver.bat -P ntp-keygen \r
        \r
 # End Custom Build\r
 \r
index 3243b2d056b7a41136e961b4b485b4863d3e914a..ab70cfe7a474be1b13bda9485db536ef97992c8b 100644 (file)
                                                PreprocessorDefinitions=""/>
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath="..\..\..\libntp\ntp_libopts.c">
+                       </File>
                        <File
                                RelativePath="..\..\..\libntp\ntp_random.c">
                                <FileConfiguration
index 5f5f6a05e4f99e4d246fb4216d7fecc29632d386..4aa966fa72151aaf1bafe573dc96282df9566cc2 100644 (file)
                                <Tool
                                        Name="VCCustomBuildTool"
                                        CommandLine="echo Using NT Shell Script to generate version.c
-..\scripts\mkver.bat -P ntpkeygen
+..\scripts\mkver.bat -P ntp-keygen
 "
                                        Outputs="$(ProjectDir)version.c"/>
                        </FileConfiguration>
                                <Tool
                                        Name="VCCustomBuildTool"
                                        CommandLine="echo Using NT Shell Script to generate version.c
-..\scripts\mkver.bat -P ntpkeygen
+..\scripts\mkver.bat -P ntp-keygen
 "
                                        Outputs="$(ProjectDir)version.c"/>
                        </FileConfiguration>
index 28c202f695253d32cd7c52ad9df1ac8e4e6610fa..6440137d5beadc534bac0c1c6d292d0b5bac5924 100644 (file)
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath="..\..\..\libntp\ntp_libopts.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\libntp\ntp_lineedit.c"
                                >
index dea8c409424ae3159ad0e0c6b6a7bc3a361b91d4..18fb7180f0137683850ee00e802b19430d0b6117 100644 (file)
                                >
                                <Tool
                                        Name="VCCustomBuildTool"
-                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpkeygen&#x0D;&#x0A;"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntp-keygen&#x0D;&#x0A;"
                                        Outputs="$(ProjectDir)version.c"
                                />
                        </FileConfiguration>
                                >
                                <Tool
                                        Name="VCCustomBuildTool"
-                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpkeygen&#x0D;&#x0A;"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntp-keygen&#x0D;&#x0A;"
                                        Outputs="$(ProjectDir)version.c"
                                />
                        </FileConfiguration>
index 54c1c24a7a70c8a5d2c872cf4f82715214fbb522..b73659cc5475d0774cf9b314d309f8e50d479cae 100644 (file)
                                RelativePath="..\..\..\..\lib\isc\netscope.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\libntp\ntp_libopts.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\..\libntp\ntp_lineedit.c"
                                >
                                RelativePath="..\..\include\ntp_iocompletionport.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\include\ntp_libopts.h"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\..\include\ntp_lineedit.h"
                                >
index 44bf985a750c6f0469bf97d68e39be400f2f9864..87831a2fe3ad16a5d01fd75fe7ce6e108f434832 100644 (file)
                        Name="Source Files"
                        Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
                        >
-                       <File
-                               RelativePath="..\..\..\..\libntp\getopt.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
                        <File
                                RelativePath="..\..\..\..\util\ntp-keygen-opts.c"
                                >
                                        />
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath="..\..\..\..\libntp\ntp_random.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\libntp\randfile.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
                        <File
                                RelativePath=".\version.c"
                                >
                                >
                                <Tool
                                        Name="VCCustomBuildTool"
-                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\..\scripts\mkver.bat -P ntpkeygen&#x0D;&#x0A;"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\..\scripts\mkver.bat -P ntp-keygen&#x0D;&#x0A;"
                                        Outputs="$(ProjectDir)version.c"
                                />
                        </FileConfiguration>
                                >
                                <Tool
                                        Name="VCCustomBuildTool"
-                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\..\scripts\mkver.bat -P ntpkeygen&#x0D;&#x0A;"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\..\scripts\mkver.bat -P ntp-keygen&#x0D;&#x0A;"
                                        Outputs="$(ProjectDir)version.c"
                                />
                        </FileConfiguration>
index a257979be14c30b3f38b91a96f024172ea460884..04eb8a0d17247d91ea0e4dc114af16b1c36646bf 100644 (file)
                                RelativePath="..\..\..\..\ntpd\ntp_keyword.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\include\ntp_libopts.h"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\..\include\ntp_lists.h"
                                >
index 94dc975e5369b426b923fc7c1e9cc011fdaf3f9e..fff3303298fff148e019ed29719c3d780b7b1d13 100644 (file)
@@ -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
index aad592a53c8313670a744ca3a76d1fcbbb6633e1..66d074f3fcfaf5baffcee721f5ec2d13bc410327 100644 (file)
@@ -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++;