]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
sntp option cleanup
authorHarlan Stenn <stenn@ntp.org>
Sun, 16 Jan 2011 10:49:33 +0000 (10:49 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 16 Jan 2011 10:49:33 +0000 (10:49 +0000)
bk: 4d32cd3dylRwI9Gkez8IT5r8cThLtg

sntp/main.c
sntp/sntp-opts.c
sntp/sntp-opts.def
sntp/sntp-opts.h
sntp/sntp-opts.texi
sntp/sntp.1
sntp/sntp.html
sntp/sntp.texi

index f8a749b5894e836d8d33e53cf02d11f1c2af75a5..8e4a2277f87cba08456c8cf3357d5241b4f4cfb3 100644 (file)
@@ -14,6 +14,8 @@
 int n_pending_dns = 0;
 int n_pending_ntp = 0;
 int ai_fam_pref = AF_UNSPEC;
+int ntpver = 4;
+double steplimit = -1;
 int xmt_delay;
 SOCKET sock4 = -1;             /* Socket for IPv4 */
 SOCKET sock6 = -1;             /* Socket for IPv6 */
@@ -106,6 +108,12 @@ sntp_main (
        DPRINTF(1, ("%s\n", Version));
 #endif
 
+       if (atoint(OPT_ARG(NTPVERSION), &l))
+               ntpver = l;
+
+       if (atoint(OPT_ARG(STEPLIMIT), &l))
+               steplimit = (double)l / 1000;
+
        /* Initialize logging system */
        init_logging();
        if (HAVE_OPT(FILELOG))
@@ -121,7 +129,7 @@ sntp_main (
        ** - separate bcst and ucst timeouts
        ** - multiple --timeout values in the commandline
        */
-       if (ENABLED_OPT(TIMEOUT) && atoint(OPT_ARG(TIMEOUT), &l))
+       if (atoint(OPT_ARG(BCTIMEOUT), &l))
                timeout_tv.tv_sec = l;
        else 
                timeout_tv.tv_sec = 68; /* ntpd broadcasts every 64s */
@@ -230,7 +238,7 @@ open_sockets(
                ZERO(name);
                AF(&name) = AF_INET;
                SET_ADDR4N(&name, INADDR_ANY);
-               SET_PORT(&name, (HAVE_OPT(UNPRIV_PORT) ? 0 : 123));
+               SET_PORT(&name, (HAVE_OPT(USERESERVEDPORT) ? 123 : 0));
 
                if (-1 == bind(sock4, &name.sa,
                               SOCKLEN(&name))) {
@@ -254,7 +262,7 @@ open_sockets(
                ZERO(name);
                AF(&name) = AF_INET6;
                SET_ADDR6N(&name, in6addr_any);
-               SET_PORT(&name, 0);
+               SET_PORT(&name, (HAVE_OPT(USERESERVEDPORT) ? 123 : 0));
 
                if (-1 == bind(sock6, &name.sa,
                               SOCKLEN(&name))) {
@@ -613,7 +621,7 @@ generate_pkt (
        x_pkt->stratum = STRATUM_TO_PKT(STRATUM_UNSPEC);
        x_pkt->ppoll = 8;
        /* FIXME! Modus broadcast + adr. check -> bdr. pkt */
-       set_li_vn_mode(x_pkt, LEAP_NOTINSYNC, 4, 3);
+       set_li_vn_mode(x_pkt, LEAP_NOTINSYNC, ntpver, 3);
        if (pkt_key != NULL) {
                int mac_size = 20; /* max room for MAC */
 
@@ -679,7 +687,12 @@ handle_pkt (
                break;
 
            case KOD_RATE:
-               /* Hmm... probably we should sleep a bit here */
+               /*
+               ** Hmm...
+               ** We should probably call add_entry() with an
+               ** expiration timestamp of several seconds in the future,
+               ** and back-off even more if we get more RATE responses.
+               */
                break;
 
            case 1:
@@ -729,7 +742,7 @@ handle_pkt (
                if (p_SNTP_PRETEND_TIME)
                        return 0;
 
-               if (ENABLED_OPT(SETTOD) || ENABLED_OPT(ADJTIME))
+               if (ENABLED_OPT(STEP) || ENABLED_OPT(SLEW))
                        return set_time(offset);
 
                return 0;
@@ -815,10 +828,15 @@ set_li_vn_mode (
        )
 {
        if (leap > 3) {
-               msyslog(LOG_DEBUG, "set_li_vn_mode: leap > 3 using max. 3");
+               msyslog(LOG_DEBUG, "set_li_vn_mode: leap > 3, using max. 3");
                leap = 3;
        }
 
+       if (version < 0 || version > 7) {
+               msyslog(LOG_DEBUG, "set_li_vn_mode: version < 0 or > 7, using 4");
+               version = 4;
+       }
+
        if (mode > 7) {
                msyslog(LOG_DEBUG, "set_li_vn_mode: mode > 7, using client mode 3");
                mode = 3;
@@ -831,8 +849,8 @@ set_li_vn_mode (
 
 
 /*
-** set_time corrects the local clock by offset with either settimeofday() or
-** by default with adjtime()/adjusttimeofday().
+** set_time corrects the local clock by offset with either
+** settimeofday() oradjtime()/adjusttimeofday().
 */
 int
 set_time(
@@ -841,27 +859,34 @@ set_time(
 {
        struct timeval tp;
 
-       if (ENABLED_OPT(SETTOD)) {
-               GETTIMEOFDAY(&tp, NULL);
+       /* check offset against steplimit */
+       if (fabs(offset) > steplimit || !ENABLED_OPT(SLEW)) {
+               if (ENABLED_OPT(STEP)) {
+                       GETTIMEOFDAY(&tp, NULL);
+
+                       tp.tv_sec += (long)offset;
+                       tp.tv_usec += 1e6 * (offset - (long)offset);
+                       NORMALIZE_TIMEVAL(tp);
+
+                       if (SETTIMEOFDAY(&tp, NULL) < 0) {
+                               msyslog(LOG_ERR, "Time not set: settimeofday(): %m");
+                               return -1;
+                       }
+                       return 0;
+               }
+       }
 
-               tp.tv_sec += (long)offset;
-               tp.tv_usec += 1e6 * (offset - (long)offset);
+       if (ENABLED_OPT(SLEW)) {
+               tp.tv_sec = (long)offset;
+               tp.tv_usec = 1e6 * (offset - (long)offset);
                NORMALIZE_TIMEVAL(tp);
 
-               if (SETTIMEOFDAY(&tp, NULL) < 0) {
-                       msyslog(LOG_ERR, "Time not set: settimeofday(): %m");
+               if (ADJTIMEOFDAY(&tp, NULL) < 0) {
+                       msyslog(LOG_ERR, "Time not set: adjtime(): %m");
                        return -1;
                }
                return 0;
        }
 
-       tp.tv_sec = (long)offset;
-       tp.tv_usec = 1e6 * (offset - (long)offset);
-       NORMALIZE_TIMEVAL(tp);
-
-       if (ADJTIMEOFDAY(&tp, NULL) < 0) {
-               msyslog(LOG_ERR, "Time not set: adjtime(): %m");
-               return -1;
-       }
-       return 0;
+       return -1;
 }
index 9c7d4785dcdb12df8e4911c1bef14bd588ed3854..d7c8b334db29ee3acd2d090aa24fc45a0f651575 100644 (file)
@@ -1,7 +1,7 @@
 /*  
  *  EDIT THIS FILE WITH CAUTION  (sntp-opts.c)
  *  
- *  It has been AutoGen-ed  January 15, 2011 at 10:39:47 AM by AutoGen 5.11.6pre7
+ *  It has been AutoGen-ed  January 16, 2011 at 10:45:30 AM by AutoGen 5.11.6pre7
  *  From the definitions    sntp-opts.def
  *  and the template file   options
  *
@@ -26,7 +26,8 @@
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
-
+#include <errno.h>
+extern FILE * option_usage_fp;
 #define OPTION_CODE_COMPILE 1
 #include "sntp-opts.h"
 
@@ -110,126 +111,66 @@ static const int
 #define IPV6_FLAGS       (OPTST_DISABLED)
 
 /*
- *  Kod option description:
- */
-static char const zKodText[] =
-        "KoD history filename";
-static char const zKod_NAME[]                = "KOD";
-static char const zKod_Name[]                = "kod";
-static char const zKodDefaultArg[]             = "/var/db/ntp-kod";
-#define KOD_FLAGS       (OPTST_DISABLED \
-        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
-
-/*
- *  Syslog option description with
- *  "Must also have options" and "Incompatible options":
- */
-static char const zSyslogText[] =
-        "Logging with syslog";
-static char const zSyslog_NAME[]             = "SYSLOG";
-static char const zSyslog_Name[]             = "syslog";
-static const int
-    aSyslogCantList[] = {
-    INDEX_OPT_FILELOG, NO_EQUIVALENT };
-#define SYSLOG_FLAGS       (OPTST_DISABLED)
-
-/*
- *  Filelog option description with
- *  "Must also have options" and "Incompatible options":
- */
-static char const zFilelogText[] =
-        "Log to specified logfile";
-static char const zFilelog_NAME[]            = "FILELOG";
-static char const zFilelog_Name[]            = "filelog";
-static const int
-    aFilelogCantList[] = {
-    INDEX_OPT_SYSLOG, NO_EQUIVALENT };
-#define FILELOG_FLAGS       (OPTST_DISABLED \
-        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
-
-/*
- *  Steplimit option description with
- *  "Must also have options" and "Incompatible options":
+ *  Authentication option description:
  */
-static char const zSteplimitText[] =
-        "Adjustments less than steplimit msec will be slewed.";
-static char const zSteplimit_NAME[]          = "STEPLIMIT";
-static char const zSteplimit_Name[]          = "steplimit";
-static const int
-    aSteplimitCantList[] = {
-    INDEX_OPT_ADJTIME,
-    INDEX_OPT_SETTOD, NO_EQUIVALENT };
-#define STEPLIMIT_FLAGS       (OPTST_DISABLED \
+static char const zAuthenticationText[] =
+        "Enable authentication with the key auth-keynumber";
+static char const zAuthentication_NAME[]     = "AUTHENTICATION";
+static char const zAuthentication_Name[]     = "authentication";
+#define AUTHENTICATION_FLAGS       (OPTST_DISABLED \
         | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
 
 /*
- *  Settod option description with
- *  "Must also have options" and "Incompatible options":
+ *  Bctimeout option description:
  */
-static char const zSettodText[] =
-        "Set (step) the time with settimeofday()";
-static char const zSettod_NAME[]             = "SETTOD";
-static char const zSettod_Name[]             = "settod";
-static const int
-    aSettodCantList[] = {
-    INDEX_OPT_ADJTIME,
-    INDEX_OPT_STEPLIMIT, NO_EQUIVALENT };
-#define SETTOD_FLAGS       (OPTST_DISABLED)
+static char const zBctimeoutText[] =
+        "Specify the number of seconds to wait for broadcasts";
+static char const zBctimeout_NAME[]          = "BCTIMEOUT";
+static char const zBctimeout_Name[]          = "bctimeout";
+#define zBctimeoutDefaultArg         ((char const*)68)
+#define BCTIMEOUT_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
 
 /*
- *  Adjtime option description with
- *  "Must also have options" and "Incompatible options":
+ *  Broadcast option description:
  */
-static char const zAdjtimeText[] =
-        "Set (slew) the time with adjtime()";
-static char const zAdjtime_NAME[]            = "ADJTIME";
-static char const zAdjtime_Name[]            = "adjtime";
-static const int
-    aAdjtimeCantList[] = {
-    INDEX_OPT_SETTOD,
-    INDEX_OPT_STEPLIMIT, NO_EQUIVALENT };
-#define ADJTIME_FLAGS       (OPTST_DISABLED)
+static char const zBroadcastText[] =
+        "Listen to the address specified for broadcast time sync";
+static char const zBroadcast_NAME[]          = "BROADCAST";
+static char const zBroadcast_Name[]          = "broadcast";
+#define BROADCAST_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
 
 /*
  *  Concurrent option description:
  */
 static char const zConcurrentText[] =
-        "Send concurrent queries to all IPs returned for host-name";
+        "Concurrent query all IPs returned for host-name";
 static char const zConcurrent_NAME[]         = "CONCURRENT";
 static char const zConcurrent_Name[]         = "concurrent";
 #define CONCURRENT_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
 
 /*
- *  Broadcast option description:
+ *  Filelog option description:
  */
-static char const zBroadcastText[] =
-        "Use broadcasts to the address specified for synchronisation";
-static char const zBroadcast_NAME[]          = "BROADCAST";
-static char const zBroadcast_Name[]          = "broadcast";
-#define BROADCAST_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
-        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
-
-/*
- *  Timeout option description:
- */
-static char const zTimeoutText[] =
-        "Specify the number of seconds to wait for broadcasts";
-static char const zTimeout_NAME[]            = "TIMEOUT";
-static char const zTimeout_Name[]            = "timeout";
-#define zTimeoutDefaultArg           ((char const*)68)
-#define TIMEOUT_FLAGS       (OPTST_DISABLED \
-        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+static char const zFilelogText[] =
+        "Log to specified logfile";
+static char const zFilelog_NAME[]            = "FILELOG";
+static char const zFilelog_Name[]            = "filelog";
+#define FILELOG_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
 
 /*
- *  Authentication option description:
+ *  Kod option description:
  */
-static char const zAuthenticationText[] =
-        "Enable authentication with the key auth-keynumber";
-static char const zAuthentication_NAME[]     = "AUTHENTICATION";
-static char const zAuthentication_Name[]     = "authentication";
-#define AUTHENTICATION_FLAGS       (OPTST_DISABLED \
-        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+static char const zKodText[] =
+        "KoD history filename";
+static char const zKod_NAME[]                = "KOD";
+static char const zKod_Name[]                = "kod";
+static char const zKodDefaultArg[]             = "/var/db/ntp-kod";
+#define KOD_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
 
 /*
  *  Keyfile option description:
@@ -242,13 +183,52 @@ static char const zKeyfile_Name[]            = "keyfile";
         | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
 
 /*
- *  Unpriv_Port option description:
+ *  Steplimit option description:
  */
-static char const zUnpriv_PortText[] =
-        "Use an unprivileged port for communicating";
-static char const zUnpriv_Port_NAME[]        = "UNPRIV_PORT";
-static char const zUnpriv_Port_Name[]        = "unpriv-port";
-#define UNPRIV_PORT_FLAGS       (OPTST_DISABLED)
+static char const zSteplimitText[] =
+        "Adjustments less than steplimit msec will be slewed.";
+static char const zSteplimit_NAME[]          = "STEPLIMIT";
+static char const zSteplimit_Name[]          = "steplimit";
+#define STEPLIMIT_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+/*
+ *  Ntpversion option description:
+ */
+static char const zNtpversionText[] =
+        "Send <int> as our NTP version";
+static char const zNtpversion_NAME[]         = "NTPVERSION";
+static char const zNtpversion_Name[]         = "ntpversion";
+#define zNtpversionDefaultArg        ((char const*)4)
+#define NTPVERSION_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+/*
+ *  Usereservedport option description:
+ */
+static char const zUsereservedportText[] =
+        "Use the NTP Reserved Port (port 123)";
+static char const zUsereservedport_NAME[]    = "USERESERVEDPORT";
+static char const zUsereservedport_Name[]    = "usereservedport";
+#define USERESERVEDPORT_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Step option description:
+ */
+static char const zStepText[] =
+        "OK to 'step' the time with settimeofday()";
+static char const zStep_NAME[]               = "STEP";
+static char const zStep_Name[]               = "step";
+#define STEP_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Slew option description:
+ */
+static char const zSlewText[] =
+        "OK to 'slew' the time with adjtime()";
+static char const zSlew_NAME[]               = "SLEW";
+static char const zSlew_Name[]               = "slew";
+#define SLEW_FLAGS       (OPTST_DISABLED)
 
 /*
  *  Help/More_Help/Version option descriptions:
@@ -289,7 +269,8 @@ static char const zNotLoad_Opts_Pfx[]  = "no";
  *  if multiple copies are allowed.
  */
 static tOptProc
-    doOptFilelog, doOptKeyfile, doOptKod, doUsageOpt;
+    doOptFilelog,    doOptKeyfile,    doOptKod,        doOptNtpversion,
+    doOptSteplimit,  doUsageOpt;
 
 /*
  *  #define map the "normal" callout procs to the test ones...
@@ -307,7 +288,9 @@ extern tOptProc
     optionStackArg,      optionTimeVal,       optionUnstackArg,
     optionVersionStderr;
 static tOptProc
-    doOptFilelog, doOptKeyfile, doOptKod, doOptSet_Debug_Level, doUsageOpt;
+    doOptFilelog,         doOptKeyfile,         doOptKod,
+    doOptNtpversion,      doOptSet_Debug_Level, doOptSteplimit,
+    doUsageOpt;
 
 /*
  *  #define map the "normal" callout procs
@@ -375,148 +358,148 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 4, VALUE_OPT_KOD,
-     /* equiv idx, value */ 4, VALUE_OPT_KOD,
+  {  /* entry idx, value */ 4, VALUE_OPT_AUTHENTICATION,
+     /* equiv idx, value */ 4, VALUE_OPT_AUTHENTICATION,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ KOD_FLAGS, 0,
-     /* last opt argumnt */ { zKodDefaultArg },
+     /* opt state flags  */ AUTHENTICATION_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
-     /* option proc      */ doOptKod,
-     /* desc, NAME, name */ zKodText, zKod_NAME, zKod_Name,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zAuthenticationText, zAuthentication_NAME, zAuthentication_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 5, VALUE_OPT_SYSLOG,
-     /* equiv idx, value */ 5, VALUE_OPT_SYSLOG,
+  {  /* entry idx, value */ 5, VALUE_OPT_BCTIMEOUT,
+     /* equiv idx, value */ 5, VALUE_OPT_BCTIMEOUT,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ SYSLOG_FLAGS, 0,
-     /* last opt argumnt */ { NULL },
+     /* opt state flags  */ BCTIMEOUT_FLAGS, 0,
+     /* last opt argumnt */ { zBctimeoutDefaultArg },
      /* arg list/cookie  */ NULL,
-     /* must/cannot opts */ NULL, aSyslogCantList,
-     /* option proc      */ NULL,
-     /* desc, NAME, name */ zSyslogText, zSyslog_NAME, zSyslog_Name,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zBctimeoutText, zBctimeout_NAME, zBctimeout_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 6, VALUE_OPT_FILELOG,
-     /* equiv idx, value */ 6, VALUE_OPT_FILELOG,
+  {  /* entry idx, value */ 6, VALUE_OPT_BROADCAST,
+     /* equiv idx, value */ 6, VALUE_OPT_BROADCAST,
      /* equivalenced to  */ NO_EQUIVALENT,
-     /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ FILELOG_FLAGS, 0,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ BROADCAST_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
-     /* must/cannot opts */ NULL, aFilelogCantList,
-     /* option proc      */ doOptFilelog,
-     /* desc, NAME, name */ zFilelogText, zFilelog_NAME, zFilelog_Name,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zBroadcastText, zBroadcast_NAME, zBroadcast_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 7, VALUE_OPT_STEPLIMIT,
-     /* equiv idx, value */ 7, VALUE_OPT_STEPLIMIT,
+  {  /* entry idx, value */ 7, VALUE_OPT_CONCURRENT,
+     /* equiv idx, value */ 7, VALUE_OPT_CONCURRENT,
      /* equivalenced to  */ NO_EQUIVALENT,
-     /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ STEPLIMIT_FLAGS, 0,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ CONCURRENT_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
-     /* must/cannot opts */ NULL, aSteplimitCantList,
-     /* option proc      */ optionNumericVal,
-     /* desc, NAME, name */ zSteplimitText, zSteplimit_NAME, zSteplimit_Name,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zConcurrentText, zConcurrent_NAME, zConcurrent_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 8, VALUE_OPT_SETTOD,
-     /* equiv idx, value */ 8, VALUE_OPT_SETTOD,
+  {  /* entry idx, value */ 8, VALUE_OPT_FILELOG,
+     /* equiv idx, value */ 8, VALUE_OPT_FILELOG,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ SETTOD_FLAGS, 0,
+     /* opt state flags  */ FILELOG_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
-     /* must/cannot opts */ NULL, aSettodCantList,
-     /* option proc      */ NULL,
-     /* desc, NAME, name */ zSettodText, zSettod_NAME, zSettod_Name,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doOptFilelog,
+     /* desc, NAME, name */ zFilelogText, zFilelog_NAME, zFilelog_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 9, VALUE_OPT_ADJTIME,
-     /* equiv idx, value */ 9, VALUE_OPT_ADJTIME,
+  {  /* entry idx, value */ 9, VALUE_OPT_KOD,
+     /* equiv idx, value */ 9, VALUE_OPT_KOD,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ ADJTIME_FLAGS, 0,
-     /* last opt argumnt */ { NULL },
+     /* opt state flags  */ KOD_FLAGS, 0,
+     /* last opt argumnt */ { zKodDefaultArg },
      /* arg list/cookie  */ NULL,
-     /* must/cannot opts */ NULL, aAdjtimeCantList,
-     /* option proc      */ NULL,
-     /* desc, NAME, name */ zAdjtimeText, zAdjtime_NAME, zAdjtime_Name,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doOptKod,
+     /* desc, NAME, name */ zKodText, zKod_NAME, zKod_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 10, VALUE_OPT_CONCURRENT,
-     /* equiv idx, value */ 10, VALUE_OPT_CONCURRENT,
+  {  /* entry idx, value */ 10, VALUE_OPT_KEYFILE,
+     /* equiv idx, value */ 10, VALUE_OPT_KEYFILE,
      /* equivalenced to  */ NO_EQUIVALENT,
-     /* min, max, act ct */ 0, NOLIMIT, 0,
-     /* opt state flags  */ CONCURRENT_FLAGS, 0,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ KEYFILE_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
-     /* option proc      */ optionStackArg,
-     /* desc, NAME, name */ zConcurrentText, zConcurrent_NAME, zConcurrent_Name,
+     /* option proc      */ doOptKeyfile,
+     /* desc, NAME, name */ zKeyfileText, zKeyfile_NAME, zKeyfile_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 11, VALUE_OPT_BROADCAST,
-     /* equiv idx, value */ 11, VALUE_OPT_BROADCAST,
+  {  /* entry idx, value */ 11, VALUE_OPT_STEPLIMIT,
+     /* equiv idx, value */ 11, VALUE_OPT_STEPLIMIT,
      /* equivalenced to  */ NO_EQUIVALENT,
-     /* min, max, act ct */ 0, NOLIMIT, 0,
-     /* opt state flags  */ BROADCAST_FLAGS, 0,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ STEPLIMIT_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
-     /* option proc      */ optionStackArg,
-     /* desc, NAME, name */ zBroadcastText, zBroadcast_NAME, zBroadcast_Name,
+     /* option proc      */ doOptSteplimit,
+     /* desc, NAME, name */ zSteplimitText, zSteplimit_NAME, zSteplimit_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 12, VALUE_OPT_TIMEOUT,
-     /* equiv idx, value */ 12, VALUE_OPT_TIMEOUT,
+  {  /* entry idx, value */ 12, VALUE_OPT_NTPVERSION,
+     /* equiv idx, value */ 12, VALUE_OPT_NTPVERSION,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ TIMEOUT_FLAGS, 0,
-     /* last opt argumnt */ { zTimeoutDefaultArg },
+     /* opt state flags  */ NTPVERSION_FLAGS, 0,
+     /* last opt argumnt */ { zNtpversionDefaultArg },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
-     /* option proc      */ optionNumericVal,
-     /* desc, NAME, name */ zTimeoutText, zTimeout_NAME, zTimeout_Name,
+     /* option proc      */ doOptNtpversion,
+     /* desc, NAME, name */ zNtpversionText, zNtpversion_NAME, zNtpversion_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 13, VALUE_OPT_AUTHENTICATION,
-     /* equiv idx, value */ 13, VALUE_OPT_AUTHENTICATION,
+  {  /* entry idx, value */ 13, VALUE_OPT_USERESERVEDPORT,
+     /* equiv idx, value */ 13, VALUE_OPT_USERESERVEDPORT,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ AUTHENTICATION_FLAGS, 0,
+     /* opt state flags  */ USERESERVEDPORT_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
-     /* option proc      */ optionNumericVal,
-     /* desc, NAME, name */ zAuthenticationText, zAuthentication_NAME, zAuthentication_Name,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zUsereservedportText, zUsereservedport_NAME, zUsereservedport_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 14, VALUE_OPT_KEYFILE,
-     /* equiv idx, value */ 14, VALUE_OPT_KEYFILE,
+  {  /* entry idx, value */ 14, VALUE_OPT_STEP,
+     /* equiv idx, value */ 14, VALUE_OPT_STEP,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ KEYFILE_FLAGS, 0,
+     /* opt state flags  */ STEP_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
-     /* option proc      */ doOptKeyfile,
-     /* desc, NAME, name */ zKeyfileText, zKeyfile_NAME, zKeyfile_Name,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zStepText, zStep_NAME, zStep_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 15, VALUE_OPT_UNPRIV_PORT,
-     /* equiv idx, value */ 15, VALUE_OPT_UNPRIV_PORT,
+  {  /* entry idx, value */ 15, VALUE_OPT_SLEW,
+     /* equiv idx, value */ 15, VALUE_OPT_SLEW,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ UNPRIV_PORT_FLAGS, 0,
+     /* opt state flags  */ SLEW_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
      /* option proc      */ NULL,
-     /* desc, NAME, name */ zUnpriv_PortText, zUnpriv_Port_NAME, zUnpriv_Port_Name,
+     /* desc, NAME, name */ zSlewText, zSlew_NAME, zSlew_Name,
      /* disablement strs */ NULL, NULL },
 
   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
@@ -680,17 +663,17 @@ doUsageOpt(
 static void
 doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
 {
-    /* extracted from ../include/debug-opt.def, line 27 */
+    /* extracted from include/debug-opt.def, line 27 */
 DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
 }
 #endif /* defined(TEST_SNTP_OPTS) */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
- *   For the kod option.
+ *   For the filelog option.
  */
 static void
-doOptKod(tOptions* pOptions, tOptDesc* pOptDesc)
+doOptFilelog(tOptions* pOptions, tOptDesc* pOptDesc)
 {
     static teOptFileType const  type =
         FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
@@ -705,10 +688,10 @@ doOptKod(tOptions* pOptions, tOptDesc* pOptDesc)
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
- *   For the filelog option.
+ *   For the kod option.
  */
 static void
-doOptFilelog(tOptions* pOptions, tOptDesc* pOptDesc)
+doOptKod(tOptions* pOptions, tOptDesc* pOptDesc)
 {
     static teOptFileType const  type =
         FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
@@ -738,6 +721,106 @@ doOptKeyfile(tOptions* pOptions, tOptDesc* pOptDesc)
 
     optionFileCheck(pOptions, pOptDesc, type, mode);
 }
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   For the steplimit option.
+ */
+static void
+doOptSteplimit(tOptions* pOptions, tOptDesc* pOptDesc)
+{
+    static const struct {long const rmin, rmax;} rng[1] = {
+        { 0, LONG_MAX } };
+    long val;
+    int  ix;
+    char * pzEnd;
+
+    if (pOptions <= OPTPROC_EMIT_LIMIT)
+        goto emit_ranges;
+
+    errno = 0;
+    val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
+    if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
+        goto bad_value;
+
+    if (*pzEnd != '\0')
+        goto bad_value;
+    for (ix = 0; ix < 1; ix++) {
+        if (val < rng[ix].rmin)
+            continue;  /* ranges need not be ordered. */
+        if (val == rng[ix].rmin)
+            goto valid_return;
+        if (rng[ix].rmax == LONG_MIN)
+            continue;
+        if (val <= rng[ix].rmax)
+            goto valid_return;
+    }
+
+  bad_value:
+
+    option_usage_fp = stderr;
+
+  emit_ranges:
+    optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
+    return;
+
+  valid_return:
+    if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
+        free((void *)pOptDesc->optArg.argString);
+        pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+    pOptDesc->optArg.argInt = val;
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   For the ntpversion option.
+ */
+static void
+doOptNtpversion(tOptions* pOptions, tOptDesc* pOptDesc)
+{
+    static const struct {long const rmin, rmax;} rng[1] = {
+        { 0, 7 } };
+    long val;
+    int  ix;
+    char * pzEnd;
+
+    if (pOptions <= OPTPROC_EMIT_LIMIT)
+        goto emit_ranges;
+
+    errno = 0;
+    val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
+    if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
+        goto bad_value;
+
+    if (*pzEnd != '\0')
+        goto bad_value;
+    for (ix = 0; ix < 1; ix++) {
+        if (val < rng[ix].rmin)
+            continue;  /* ranges need not be ordered. */
+        if (val == rng[ix].rmin)
+            goto valid_return;
+        if (rng[ix].rmax == LONG_MIN)
+            continue;
+        if (val <= rng[ix].rmax)
+            goto valid_return;
+    }
+
+  bad_value:
+
+    option_usage_fp = stderr;
+
+  emit_ranges:
+    optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
+    return;
+
+  valid_return:
+    if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
+        free((void *)pOptDesc->optArg.argString);
+        pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+    pOptDesc->optArg.argInt = val;
+}
 /* extracted from /usr/local/share/autogen/optmain.tpl near line 107 */
 
 #if defined(TEST_SNTP_OPTS) /* TEST MAIN PROCEDURE: */
index ea7bd5de49152d4a10c6ea672488b01ab2fc3cca..64bbb6c0392432342630d85944204f148cfa78be 100644 (file)
@@ -49,78 +49,51 @@ flag = {
        _EndOfDoc_;
 };
 
-
-flag = {
-    name      = kod;
-    value     = K;
-    arg-type  = file;
-    arg-name  = "file-name";
-    arg-default = "/var/db/ntp-kod";
-    descrip   = "KoD history filename";
-    doc = <<-  _EndOfDoc_
-       Specifies the filename to be used for the  persistent history of KoD
-       responses received from servers.  The default is
-       /var/db/ntp-kod.
-       _EndOfDoc_;
-};
-
-
-flag = {
-       name    = syslog;
-       value   = p;
-       flags-cant = filelog;
-       descrip = "Logging with syslog";
-       doc = <<-  _EndOfDoc_
-       When this option is set all logging will be done using syslog.
-       _EndOfDoc_;
-};
-
 flag = {
-       name       = filelog;
-       value      = l;
-       arg-type   = file;
-       arg-name   = "file-name";
-       flags-cant = syslog;
-       descrip = "Log to specified logfile";
-       doc = <<-  _EndOfDoc_
-       This option causes the client to write log messages to the specified
-       logfile.
+       name    = authentication;
+       value   = a;
+       descrip = "Enable authentication with the key auth-keynumber";
+       arg-type = number;
+       arg-name = "auth-keynumber";
+       doc     = <<- _EndOfDoc_
+       This option enables authentication using the key specified in this option's argument.
+       The argument of this option is the keyid, a number specified in the keyfile as this
+       key's identifier. See the keyfile option (-k) for more details.
        _EndOfDoc_;
 };
 
 flag = {
-       name       = steplimit;
-       value      = S;
-       arg-type   = number;
-       flags-cant = adjtime, settod;
-       descrip    = "Adjustments less than steplimit msec will be slewed.";
-       doc = <<-  _EndOfDoc_
-       If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
-       _EndOfDoc_;
-       };
-
-flag = {
-       name       = settod;
-       value      = s;
-       flags-cant = adjtime, steplimit;
-       descrip    = "Set (step) the time with settimeofday()";
-       doc = <<-  _EndOfDoc_
+       name    = bctimeout;
+       value   = B;
+       descrip = "Specify the number of seconds to wait for broadcasts";
+       arg-type = number;
+       arg-name = "seconds";
+       arg-default = 68;
+       doc     = <<-  _EndOfDoc_
+       When waiting for a broadcast packet SNTP will wait the number
+       of seconds specified before giving up.  Default 68 seconds.
        _EndOfDoc_;
 };
 
 flag = {
-       name       = adjtime;
-       value      = j;
-       flags-cant = settod, steplimit;
-       descrip    = "Set (slew) the time with adjtime()";
-       doc = <<-  _EndOfDoc_
+       name    = broadcast;
+       value   = b;
+       descrip = "Listen to the address specified for broadcast time sync";
+       arg-type = string;
+       arg-name = "broadcast-address";
+       max      = NOLIMIT;
+       stack-arg;
+       doc     = <<-  _EndOfDoc_
+       If specified SNTP will listen to the specified address
+       for NTP broadcasts.  The default maximum wait time,
+       68 seconds, can be modified with -B.
        _EndOfDoc_;
 };
 
 flag = {
        name     = concurrent;
        value    = c;
-       descrip  = "Send concurrent queries to all IPs returned for host-name";
+       descrip  = "Concurrent query all IPs returned for host-name";
        arg-type = string;
        arg-name = "host-name";
        max      = NOLIMIT;
@@ -139,43 +112,28 @@ flag = {
 };
 
 flag = {
-       name    = broadcast;
-       value   = b;
-       descrip = "Use broadcasts to the address specified for synchronisation";
-       arg-type = string;
-       arg-name = "broadcast-address";
-       max      = NOLIMIT;
-       stack-arg;
-       doc     = <<-  _EndOfDoc_
-       If specified SNTP will listen to the specified broadcast address
-       for NTP broadcasts.  The default maximum wait time,
-       68 seconds, can be modified with -t.
-       _EndOfDoc_;
-};
-
-flag = {
-       name    = timeout;
-       value   = t;
-       descrip = "Specify the number of seconds to wait for broadcasts";
-       arg-type = number;
-       arg-name = "seconds";
-       arg-default = 68;
-       doc     = <<-  _EndOfDoc_
-       When waiting for a broadcast packet SNTP will wait the number
-       of seconds specified before giving up.  Default 68 seconds.
+       name       = filelog;
+       value      = l;
+       arg-type   = file;
+       arg-name   = "file-name";
+       descrip = "Log to specified logfile";
+       doc = <<-  _EndOfDoc_
+       This option causes the client to write log messages to the specified
+       logfile.
        _EndOfDoc_;
 };
 
 flag = {
-       name    = authentication;
-       value   = a;
-       descrip = "Enable authentication with the key auth-keynumber";
-       arg-type = number;
-       arg-name = "auth-keynumber";
-       doc     = <<- _EndOfDoc_
-       This option enables authentication using the key specified in this option's argument.
-       The argument of this option is the keyid, a number specified in the keyfile as this
-       key's identifier. See the keyfile option (-k) for more details.
+    name      = kod;
+    value     = K;
+    arg-type  = file;
+    arg-name  = "file-name";
+    arg-default = "/var/db/ntp-kod";
+    descrip   = "KoD history filename";
+    doc = <<-  _EndOfDoc_
+       Specifies the filename to be used for the  persistent history of KoD
+       responses received from servers.  The default is
+       /var/db/ntp-kod.
        _EndOfDoc_;
 };
 
@@ -203,10 +161,51 @@ flag = {
 };
 
 flag = {
-    name      = unpriv-port;
-    value     = u;
-    descrip   = "Use an unprivileged port for communicating";
-    doc = <<-  _EndOfDoc_
+       name       = steplimit;
+       value      = M;
+       arg-type   = number;
+       arg-range  = "0->";
+       descrip    = "Adjustments less than steplimit msec will be slewed.";
+       doc = <<-  _EndOfDoc_
+       If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
+       _EndOfDoc_;
+       };
+
+flag = {
+       name    = ntpversion;
+       value   = o;
+       descrip = "Send <int> as our NTP version";
+       arg-type = number;
+       arg-default = 4;
+       arg-range   = "0->7";
+       doc = <<-  _EndOfDoc_
+       When sending requests to a remote server, tell them we are running
+       NTP protocol version <ntpversion> .
+       _EndOfDoc_;
+};
+
+flag = {
+       name    = usereservedport;
+       value   = r;
+       descrip = "Use the NTP Reserved Port (port 123)";
+       doc = <<-  _EndOfDoc_
+       Use port 123, which is reserved for NTP, for our network communications.
+       _EndOfDoc_;
+};
+
+flag = {
+       name       = step;
+       value      = S;
+       descrip    = "OK to 'step' the time with settimeofday()";
+       doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+flag = {
+       name       = slew;
+       value      = s;
+       descrip    = "OK to 'slew' the time with adjtime()";
+       doc = <<-  _EndOfDoc_
        _EndOfDoc_;
 };
 
index 0b7a4744817107b320792dbe867f5645178d56da..4aaf3ae63fcd97e8e54ce521cdf685811dc62a85 100644 (file)
@@ -1,7 +1,7 @@
 /*  
  *  EDIT THIS FILE WITH CAUTION  (sntp-opts.h)
  *  
- *  It has been AutoGen-ed  January 15, 2011 at 10:39:47 AM by AutoGen 5.11.6pre7
+ *  It has been AutoGen-ed  January 16, 2011 at 10:45:30 AM by AutoGen 5.11.6pre7
  *  From the definitions    sntp-opts.def
  *  and the template file   options
  *
@@ -54,18 +54,18 @@ typedef enum {
     INDEX_OPT_SET_DEBUG_LEVEL  =  1,
     INDEX_OPT_IPV4             =  2,
     INDEX_OPT_IPV6             =  3,
-    INDEX_OPT_KOD              =  4,
-    INDEX_OPT_SYSLOG           =  5,
-    INDEX_OPT_FILELOG          =  6,
-    INDEX_OPT_STEPLIMIT        =  7,
-    INDEX_OPT_SETTOD           =  8,
-    INDEX_OPT_ADJTIME          =  9,
-    INDEX_OPT_CONCURRENT       = 10,
-    INDEX_OPT_BROADCAST        = 11,
-    INDEX_OPT_TIMEOUT          = 12,
-    INDEX_OPT_AUTHENTICATION   = 13,
-    INDEX_OPT_KEYFILE          = 14,
-    INDEX_OPT_UNPRIV_PORT      = 15,
+    INDEX_OPT_AUTHENTICATION   =  4,
+    INDEX_OPT_BCTIMEOUT        =  5,
+    INDEX_OPT_BROADCAST        =  6,
+    INDEX_OPT_CONCURRENT       =  7,
+    INDEX_OPT_FILELOG          =  8,
+    INDEX_OPT_KOD              =  9,
+    INDEX_OPT_KEYFILE          = 10,
+    INDEX_OPT_STEPLIMIT        = 11,
+    INDEX_OPT_NTPVERSION       = 12,
+    INDEX_OPT_USERESERVEDPORT  = 13,
+    INDEX_OPT_STEP             = 14,
+    INDEX_OPT_SLEW             = 15,
     INDEX_OPT_VERSION          = 16,
     INDEX_OPT_HELP             = 17,
     INDEX_OPT_MORE_HELP        = 18,
@@ -127,71 +127,71 @@ typedef enum {
 #  warning undefining IPV6 due to option name conflict
 #  undef   IPV6
 # endif
-# ifdef    KOD
-#  warning undefining KOD due to option name conflict
-#  undef   KOD
-# endif
-# ifdef    SYSLOG
-#  warning undefining SYSLOG due to option name conflict
-#  undef   SYSLOG
-# endif
-# ifdef    FILELOG
-#  warning undefining FILELOG due to option name conflict
-#  undef   FILELOG
-# endif
-# ifdef    STEPLIMIT
-#  warning undefining STEPLIMIT due to option name conflict
-#  undef   STEPLIMIT
+# ifdef    AUTHENTICATION
+#  warning undefining AUTHENTICATION due to option name conflict
+#  undef   AUTHENTICATION
 # endif
-# ifdef    SETTOD
-#  warning undefining SETTOD due to option name conflict
-#  undef   SETTOD
+# ifdef    BCTIMEOUT
+#  warning undefining BCTIMEOUT due to option name conflict
+#  undef   BCTIMEOUT
 # endif
-# ifdef    ADJTIME
-#  warning undefining ADJTIME due to option name conflict
-#  undef   ADJTIME
+# ifdef    BROADCAST
+#  warning undefining BROADCAST due to option name conflict
+#  undef   BROADCAST
 # endif
 # ifdef    CONCURRENT
 #  warning undefining CONCURRENT due to option name conflict
 #  undef   CONCURRENT
 # endif
-# ifdef    BROADCAST
-#  warning undefining BROADCAST due to option name conflict
-#  undef   BROADCAST
-# endif
-# ifdef    TIMEOUT
-#  warning undefining TIMEOUT due to option name conflict
-#  undef   TIMEOUT
+# ifdef    FILELOG
+#  warning undefining FILELOG due to option name conflict
+#  undef   FILELOG
 # endif
-# ifdef    AUTHENTICATION
-#  warning undefining AUTHENTICATION due to option name conflict
-#  undef   AUTHENTICATION
+# ifdef    KOD
+#  warning undefining KOD due to option name conflict
+#  undef   KOD
 # endif
 # ifdef    KEYFILE
 #  warning undefining KEYFILE due to option name conflict
 #  undef   KEYFILE
 # endif
-# ifdef    UNPRIV_PORT
-#  warning undefining UNPRIV_PORT due to option name conflict
-#  undef   UNPRIV_PORT
+# ifdef    STEPLIMIT
+#  warning undefining STEPLIMIT due to option name conflict
+#  undef   STEPLIMIT
+# endif
+# ifdef    NTPVERSION
+#  warning undefining NTPVERSION due to option name conflict
+#  undef   NTPVERSION
+# endif
+# ifdef    USERESERVEDPORT
+#  warning undefining USERESERVEDPORT due to option name conflict
+#  undef   USERESERVEDPORT
+# endif
+# ifdef    STEP
+#  warning undefining STEP due to option name conflict
+#  undef   STEP
+# endif
+# ifdef    SLEW
+#  warning undefining SLEW due to option name conflict
+#  undef   SLEW
 # endif
 #else  /* NO_OPTION_NAME_WARNINGS */
 # undef DEBUG_LEVEL
 # undef SET_DEBUG_LEVEL
 # undef IPV4
 # undef IPV6
-# undef KOD
-# undef SYSLOG
-# undef FILELOG
-# undef STEPLIMIT
-# undef SETTOD
-# undef ADJTIME
-# undef CONCURRENT
-# undef BROADCAST
-# undef TIMEOUT
 # undef AUTHENTICATION
+# undef BCTIMEOUT
+# undef BROADCAST
+# undef CONCURRENT
+# undef FILELOG
+# undef KOD
 # undef KEYFILE
-# undef UNPRIV_PORT
+# undef STEPLIMIT
+# undef NTPVERSION
+# undef USERESERVEDPORT
+# undef STEP
+# undef SLEW
 #endif  /*  NO_OPTION_NAME_WARNINGS */
 
 /* * * * * *
@@ -202,24 +202,26 @@ typedef enum {
 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
 #define VALUE_OPT_IPV4           '4'
 #define VALUE_OPT_IPV6           '6'
-#define VALUE_OPT_KOD            'K'
-#define VALUE_OPT_SYSLOG         'p'
-#define VALUE_OPT_FILELOG        'l'
-#define VALUE_OPT_STEPLIMIT      'S'
-
-#define OPT_VALUE_STEPLIMIT      (DESC(STEPLIMIT).optArg.argInt)
-#define VALUE_OPT_SETTOD         's'
-#define VALUE_OPT_ADJTIME        'j'
-#define VALUE_OPT_CONCURRENT     'c'
-#define VALUE_OPT_BROADCAST      'b'
-#define VALUE_OPT_TIMEOUT        't'
-
-#define OPT_VALUE_TIMEOUT        (DESC(TIMEOUT).optArg.argInt)
 #define VALUE_OPT_AUTHENTICATION 'a'
 
 #define OPT_VALUE_AUTHENTICATION (DESC(AUTHENTICATION).optArg.argInt)
+#define VALUE_OPT_BCTIMEOUT      'B'
+
+#define OPT_VALUE_BCTIMEOUT      (DESC(BCTIMEOUT).optArg.argInt)
+#define VALUE_OPT_BROADCAST      'b'
+#define VALUE_OPT_CONCURRENT     'c'
+#define VALUE_OPT_FILELOG        'l'
+#define VALUE_OPT_KOD            'K'
 #define VALUE_OPT_KEYFILE        'k'
-#define VALUE_OPT_UNPRIV_PORT    'u'
+#define VALUE_OPT_STEPLIMIT      'M'
+
+#define OPT_VALUE_STEPLIMIT      (DESC(STEPLIMIT).optArg.argInt)
+#define VALUE_OPT_NTPVERSION     'o'
+
+#define OPT_VALUE_NTPVERSION     (DESC(NTPVERSION).optArg.argInt)
+#define VALUE_OPT_USERESERVEDPORT 'r'
+#define VALUE_OPT_STEP           'S'
+#define VALUE_OPT_SLEW           's'
 #define VALUE_OPT_HELP          '?'
 #define VALUE_OPT_MORE_HELP     '!'
 #define VALUE_OPT_VERSION       INDEX_OPT_VERSION
index 7339a6aabf68e2f2c0584cced57bdbba30001867..ea59d2434beedaa4140b83be17d0207b31c696b8 100644 (file)
@@ -6,7 +6,7 @@
 # 
 # EDIT THIS FILE WITH CAUTION  (sntp-opts.texi)
 # 
-# It has been AutoGen-ed  January 15, 2011 at 10:40:30 AM by AutoGen 5.11.6pre7
+# It has been AutoGen-ed  January 16, 2011 at 10:46:01 AM by AutoGen 5.11.6pre7
 # From the definitions    sntp-opts.def
 # and the template file   aginfo.tpl
 @end ignore
@@ -47,8 +47,8 @@ This software is released under a specialized copyright license.
 
 @menu
 * sntp usage::                  sntp usage help (-?)
-* sntp adjtime::               adjtime option (-j)
 * sntp authentication::        authentication option (-a)
+* sntp bctimeout::             bctimeout option (-B)
 * sntp broadcast::             broadcast option (-b)
 * sntp concurrent::            concurrent option (-c)
 * sntp debug-level::           debug-level option (-d)
@@ -57,12 +57,12 @@ This software is released under a specialized copyright license.
 * sntp ipv6::                  ipv6 option (-6)
 * sntp keyfile::               keyfile option (-k)
 * sntp kod::                   kod option (-K)
+* sntp ntpversion::            ntpversion option (-o)
 * sntp set-debug-level::       set-debug-level option (-D)
-* sntp settod::                settod option (-s)
-* sntp steplimit::             steplimit option (-S)
-* sntp syslog::                syslog option (-p)
-* sntp timeout::               timeout option (-t)
-* sntp unpriv-port::           unpriv-port option (-u)
+* sntp slew::                  slew option (-s)
+* sntp step::                  step option (-S)
+* sntp steplimit::             steplimit option (-M)
+* sntp usereservedport::       usereservedport option (-r)
 @end menu
 
 @node sntp usage
@@ -87,33 +87,22 @@ USAGE:  sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
    -6 no  ipv6           Force IPv6 DNS name resolution
                                 - prohibits these options:
                                 ipv4
-   -K Fil kod            KoD history filename
-   -p no  syslog         Logging with syslog
-                                - prohibits these options:
-                                filelog
-   -l Fil filelog        Log to specified logfile
-                                - prohibits these options:
-                                syslog
-   -S Num steplimit      Adjustments less than steplimit msec will be slewed.
-                                - prohibits these options:
-                                adjtime
-                                settod
-   -s no  settod         Set (step) the time with settimeofday()
-                                - prohibits these options:
-                                adjtime
-                                steplimit
-   -j no  adjtime        Set (slew) the time with adjtime()
-                                - prohibits these options:
-                                settod
-                                steplimit
-   -c Str concurrent     Send concurrent queries to all IPs returned for host-name
+   -a Num authentication Enable authentication with the key auth-keynumber
+   -B Num bctimeout      Specify the number of seconds to wait for broadcasts
+   -b Str broadcast      Listen to the address specified for broadcast time sync
                                 - may appear multiple times
-   -b Str broadcast      Use broadcasts to the address specified for synchronisation
+   -c Str concurrent     Concurrent query all IPs returned for host-name
                                 - may appear multiple times
-   -t Num timeout        Specify the number of seconds to wait for broadcasts
-   -a Num authentication Enable authentication with the key auth-keynumber
+   -l Fil filelog        Log to specified logfile
+   -K Fil kod            KoD history filename
    -k Fil keyfile        Specify a keyfile. SNTP will look in this file for the key specified with -a
-   -u no  unpriv-port    Use an unprivileged port for communicating
+   -M Num steplimit      Adjustments less than steplimit msec will be slewed.
+                                - it must be:  greater than or equal to 0
+   -o Num ntpversion     Send <int> as our NTP version
+                                - it must be:  0 to 7
+   -r no  usereservedport Use the NTP Reserved Port (port 123)
+   -S no  step           OK to 'step' the time with settimeofday()
+   -s no  slew           OK to 'slew' the time with adjtime()
       opt version        Output version information and exit
    -? no  help           Display extended usage information and exit
    -! no  more-help      Extended usage information passed thru pager
@@ -145,21 +134,6 @@ please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
 @end example
 @exampleindent 4
 
-@node sntp adjtime
-@subsection adjtime option (-j)
-@cindex sntp-adjtime
-
-This is the ``set (slew) the time with adjtime()'' option.
-
-This option has some usage constraints.  It:
-@itemize @bullet
-@item
-must not appear in combination with any of the following options:
-settod, steplimit.
-@end itemize
-
-
-
 @node sntp authentication
 @subsection authentication option (-a)
 @cindex sntp-authentication
@@ -169,11 +143,19 @@ This option enables authentication using the key specified in this option's argu
 The argument of this option is the keyid, a number specified in the keyfile as this
 key's identifier. See the keyfile option (-k) for more details.
 
+@node sntp bctimeout
+@subsection bctimeout option (-B)
+@cindex sntp-bctimeout
+
+This is the ``specify the number of seconds to wait for broadcasts'' option.
+When waiting for a broadcast packet SNTP will wait the number
+of seconds specified before giving up.  Default 68 seconds.
+
 @node sntp broadcast
 @subsection broadcast option (-b)
 @cindex sntp-broadcast
 
-This is the ``use broadcasts to the address specified for synchronisation'' option.
+This is the ``listen to the address specified for broadcast time sync'' option.
 
 This option has some usage constraints.  It:
 @itemize @bullet
@@ -181,15 +163,15 @@ This option has some usage constraints.  It:
 may appear an unlimited number of times.
 @end itemize
 
-If specified SNTP will listen to the specified broadcast address
+If specified SNTP will listen to the specified address
 for NTP broadcasts.  The default maximum wait time,
-68 seconds, can be modified with -t.
+68 seconds, can be modified with -B.
 
 @node sntp concurrent
 @subsection concurrent option (-c)
 @cindex sntp-concurrent
 
-This is the ``send concurrent queries to all ips returned for host-name'' option.
+This is the ``concurrent query all ips returned for host-name'' option.
 
 This option has some usage constraints.  It:
 @itemize @bullet
@@ -226,14 +208,6 @@ Increase the debugging message output level.
 @cindex sntp-filelog
 
 This is the ``log to specified logfile'' option.
-
-This option has some usage constraints.  It:
-@itemize @bullet
-@item
-must not appear in combination with any of the following options:
-syslog.
-@end itemize
-
 This option causes the client to write log messages to the specified
 logfile.
 
@@ -297,6 +271,14 @@ Specifies the filename to be used for the  persistent history of KoD
 responses received from servers.  The default is
 /var/db/ntp-kod.
 
+@node sntp ntpversion
+@subsection ntpversion option (-o)
+@cindex sntp-ntpversion
+
+This is the ``send <int> as our ntp version'' option.
+When sending requests to a remote server, tell them we are running
+NTP protocol version <ntpversion> .
+
 @node sntp set-debug-level
 @subsection set-debug-level option (-D)
 @cindex sntp-set-debug-level
@@ -312,61 +294,30 @@ may appear an unlimited number of times.
 Set the output debugging level.  Can be supplied multiple times,
 but each overrides the previous value(s).
 
-@node sntp settod
-@subsection settod option (-s)
-@cindex sntp-settod
+@node sntp slew
+@subsection slew option (-s)
+@cindex sntp-slew
 
-This is the ``set (step) the time with settimeofday()'' option.
+This is the ``ok to 'slew' the time with adjtime()'' option.
 
-This option has some usage constraints.  It:
-@itemize @bullet
-@item
-must not appear in combination with any of the following options:
-adjtime, steplimit.
-@end itemize
 
+@node sntp step
+@subsection step option (-S)
+@cindex sntp-step
+
+This is the ``ok to 'step' the time with settimeofday()'' option.
 
 
 @node sntp steplimit
-@subsection steplimit option (-S)
+@subsection steplimit option (-M)
 @cindex sntp-steplimit
 
 This is the ``adjustments less than steplimit msec will be slewed.'' option.
-
-This option has some usage constraints.  It:
-@itemize @bullet
-@item
-must not appear in combination with any of the following options:
-adjtime, settod.
-@end itemize
-
 If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
 
-@node sntp syslog
-@subsection syslog option (-p)
-@cindex sntp-syslog
-
-This is the ``logging with syslog'' option.
-
-This option has some usage constraints.  It:
-@itemize @bullet
-@item
-must not appear in combination with any of the following options:
-filelog.
-@end itemize
-
-When this option is set all logging will be done using syslog.
-
-@node sntp timeout
-@subsection timeout option (-t)
-@cindex sntp-timeout
-
-This is the ``specify the number of seconds to wait for broadcasts'' option.
-When waiting for a broadcast packet SNTP will wait the number
-of seconds specified before giving up.  Default 68 seconds.
-
-@node sntp unpriv-port
-@subsection unpriv-port option (-u)
-@cindex sntp-unpriv-port
+@node sntp usereservedport
+@subsection usereservedport option (-r)
+@cindex sntp-usereservedport
 
-This is the ``use an unprivileged port for communicating'' option.
+This is the ``use the ntp reserved port (port 123)'' option.
+Use port 123, which is reserved for NTP, for our network communications.
index d4ddacf56a2d0eb9ebf32ca677a1ac774f45a130..6a13bd891fa36cef3e4f5900cdc108c0bdccbf0b 100644 (file)
@@ -1,7 +1,7 @@
-.TH SNTP 1 2011-01-15 "( 4.2.7p118)" "Programmer's Manual"
+.TH SNTP 1 2011-01-16 "( 4.2.7p118)" "Programmer's Manual"
 .\"  EDIT THIS FILE WITH CAUTION  (sntp.1)
 .\"  
-.\"  It has been AutoGen-ed  January 15, 2011 at 10:40:27 AM by AutoGen 5.11.6pre7
+.\"  It has been AutoGen-ed  January 16, 2011 at 10:46:00 AM by AutoGen 5.11.6pre7
 .\"  From the definitions    sntp-opts.def
 .\"  and the template file   agman1.tpl
 .\"
@@ -76,55 +76,34 @@ ipv4.
 Force DNS resolution of following host names on the command line
 to the IPv6 namespace.
 .TP
-.BR \-K " \fIfile-name\fP, " \--kod "=" \fIfile-name\fP
-KoD history filename.
-The default \fIfile-name\fP for this option is:
-.ti +4
- /var/db/ntp-kod
-.sp
-Specifies the filename to be used for the  persistent history of KoD
-responses received from servers.  The default is
-/var/db/ntp-kod.
-.TP
-.BR \-p ", " \--syslog
-Logging with syslog.
-This option must not appear in combination with any of the following options:
-filelog.
-.sp
-When this option is set all logging will be done using syslog.
-.TP
-.BR \-l " \fIfile-name\fP, " \--filelog "=" \fIfile-name\fP
-Log to specified logfile.
-This option must not appear in combination with any of the following options:
-syslog.
-.sp
-This option causes the client to write log messages to the specified
-logfile.
-.TP
-.BR \-S " \fInumber\fP, " \--steplimit "=" \fInumber\fP
-Adjustments less than steplimit msec will be slewed..
-This option must not appear in combination with any of the following options:
-adjtime, settod.
+.BR \-a " \fIauth-keynumber\fP, " \--authentication "=" \fIauth-keynumber\fP
+Enable authentication with the key auth-keynumber.
 This option takes an integer number as its argument.
 .sp
-If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
+This option enables authentication using the key specified in this option's argument.
+The argument of this option is the keyid, a number specified in the keyfile as this
+key's identifier. See the keyfile option (-k) for more details.
 .TP
-.BR \-s ", " \--settod
-Set (step) the time with settimeofday().
-This option must not appear in combination with any of the following options:
-adjtime, steplimit.
+.BR \-B " \fIseconds\fP, " \--bctimeout "=" \fIseconds\fP
+Specify the number of seconds to wait for broadcasts.
+This option takes an integer number as its argument.
+The default \fIseconds\fP for this option is:
+.ti +4
+ 68
 .sp
-
+When waiting for a broadcast packet SNTP will wait the number
+of seconds specified before giving up.  Default 68 seconds.
 .TP
-.BR \-j ", " \--adjtime
-Set (slew) the time with adjtime().
-This option must not appear in combination with any of the following options:
-settod, steplimit.
+.BR \-b " \fIbroadcast-address\fP, " \--broadcast "=" \fIbroadcast-address\fP
+Listen to the address specified for broadcast time sync.
+This option may appear an unlimited number of times.
 .sp
-
+If specified SNTP will listen to the specified address
+for NTP broadcasts.  The default maximum wait time,
+68 seconds, can be modified with \-B.
 .TP
 .BR \-c " \fIhost-name\fP, " \--concurrent "=" \fIhost-name\fP
-Send concurrent queries to all IPs returned for host-name.
+Concurrent query all IPs returned for host-name.
 This option may appear an unlimited number of times.
 .sp
 Requests from an NTP "client" to a "server" should never be sent
@@ -137,31 +116,21 @@ The \-c or \--concurrent flag says that any IPs returned for the
 DNS lookup of the supplied host-name are on different machines,
 so we can send concurrent queries.
 .TP
-.BR \-b " \fIbroadcast-address\fP, " \--broadcast "=" \fIbroadcast-address\fP
-Use broadcasts to the address specified for synchronisation.
-This option may appear an unlimited number of times.
+.BR \-l " \fIfile-name\fP, " \--filelog "=" \fIfile-name\fP
+Log to specified logfile.
 .sp
-If specified SNTP will listen to the specified broadcast address
-for NTP broadcasts.  The default maximum wait time,
-68 seconds, can be modified with \-t.
+This option causes the client to write log messages to the specified
+logfile.
 .TP
-.BR \-t " \fIseconds\fP, " \--timeout "=" \fIseconds\fP
-Specify the number of seconds to wait for broadcasts.
-This option takes an integer number as its argument.
-The default \fIseconds\fP for this option is:
+.BR \-K " \fIfile-name\fP, " \--kod "=" \fIfile-name\fP
+KoD history filename.
+The default \fIfile-name\fP for this option is:
 .ti +4
- 68
-.sp
-When waiting for a broadcast packet SNTP will wait the number
-of seconds specified before giving up.  Default 68 seconds.
-.TP
-.BR \-a " \fIauth-keynumber\fP, " \--authentication "=" \fIauth-keynumber\fP
-Enable authentication with the key auth-keynumber.
-This option takes an integer number as its argument.
+ /var/db/ntp-kod
 .sp
-This option enables authentication using the key specified in this option's argument.
-The argument of this option is the keyid, a number specified in the keyfile as this
-key's identifier. See the keyfile option (-k) for more details.
+Specifies the filename to be used for the  persistent history of KoD
+responses received from servers.  The default is
+/var/db/ntp-kod.
 .TP
 .BR \-k " \fIfile-name\fP, " \--keyfile "=" \fIfile-name\fP
 Specify a keyfile. SNTP will look in this file for the key specified with \-a.
@@ -180,8 +149,48 @@ M  Key in a 1-to-8 character ASCII string using the MD5 authentication scheme.
 
 For more information see ntp.keys(5).
 .TP
-.BR \-u ", " \--unpriv-port
-Use an unprivileged port for communicating.
+.BR \-M " \fInumber\fP, " \--steplimit "=" \fInumber\fP
+Adjustments less than steplimit msec will be slewed..
+This option takes an integer number as its argument.
+The value of \fInumber\fP is constrained to being:
+.in +4
+.nf
+.na
+greater than or equal to 0
+.fi
+.in -4
+.sp
+If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
+.TP
+.BR \-o " \fInumber\fP, " \--ntpversion "=" \fInumber\fP
+Send <int> as our NTP version.
+This option takes an integer number as its argument.
+The value of \fInumber\fP is constrained to being:
+.in +4
+.nf
+.na
+in the range  0 through 7
+.fi
+.in -4
+The default \fInumber\fP for this option is:
+.ti +4
+ 4
+.sp
+When sending requests to a remote server, tell them we are running
+NTP protocol version <ntpversion> .
+.TP
+.BR \-r ", " \--usereservedport
+Use the NTP Reserved Port (port 123).
+.sp
+Use port 123, which is reserved for NTP, for our network communications.
+.TP
+.BR \-S ", " \--step
+OK to 'step' the time with settimeofday().
+.sp
+
+.TP
+.BR \-s ", " \--slew
+OK to 'slew' the time with adjtime().
 .sp
 
 .TP
index acacc37eac12d6ec9a28338599dcffda0f924c0a..912fb5479cc06d67e5dbcfcde7e923e330549927 100644 (file)
@@ -38,7 +38,7 @@ display the time offset of the system clock relative to the server
 clock.  Run as root, it can correct the system clock to this offset as
 well.  It can be run as an interactive command or from a cron job.
 
-  <p>This document applies to version 4.2.7p116 of <code>sntp</code>.
+  <p>This document applies to version 4.2.7p114 of <code>sntp</code>.
 
   <p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
 IETF specification.
@@ -69,9 +69,13 @@ IETF specification.
 <p>By default, <code>sntp</code> writes the local data and time (i.e., not UTC) to the
 standard output in the format:
 
-<pre class="example">     1996 Oct 15 20:17:25.123 +4.567 +/- 0.089 secs
+<pre class="example">     1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 secs
 </pre>
-  <p>where the +4.567 +/- 0.089 secs indicates the time offset and
+  <p>where
+YYYY-MM-DD HH:MM:SS.SUBSEC is the local date and time,
+(+0800) is the local timezone adjustment (so we would add 8 hours and 0 minutes to convert the reported local time to UTC),
+and
+the +4.567 +/- 0.089 secs indicates the time offset and
 error bound of the system clock relative to the server clock.
 
 <div class="node">
@@ -117,8 +121,8 @@ the aginfo template and the option descriptions for the <samp><span class="comma
 
 <ul class="menu">
 <li><a accesskey="1" href="#sntp-usage">sntp usage</a>:                   sntp usage help (-?) 
-<li><a accesskey="2" href="#sntp-adjtime">sntp adjtime</a>:                adjtime option (-j)
-<li><a accesskey="3" href="#sntp-authentication">sntp authentication</a>:         authentication option (-a)
+<li><a accesskey="2" href="#sntp-authentication">sntp authentication</a>:         authentication option (-a)
+<li><a accesskey="3" href="#sntp-bctimeout">sntp bctimeout</a>:              bctimeout option (-B)
 <li><a accesskey="4" href="#sntp-broadcast">sntp broadcast</a>:              broadcast option (-b)
 <li><a accesskey="5" href="#sntp-concurrent">sntp concurrent</a>:             concurrent option (-c)
 <li><a accesskey="6" href="#sntp-debug_002dlevel">sntp debug-level</a>:            debug-level option (-d)
@@ -127,18 +131,18 @@ the aginfo template and the option descriptions for the <samp><span class="comma
 <li><a accesskey="9" href="#sntp-ipv6">sntp ipv6</a>:                   ipv6 option (-6)
 <li><a href="#sntp-keyfile">sntp keyfile</a>:                keyfile option (-k)
 <li><a href="#sntp-kod">sntp kod</a>:                    kod option (-K)
+<li><a href="#sntp-ntpversion">sntp ntpversion</a>:             ntpversion option (-o)
 <li><a href="#sntp-set_002ddebug_002dlevel">sntp set-debug-level</a>:        set-debug-level option (-D)
-<li><a href="#sntp-settod">sntp settod</a>:                 settod option (-s)
-<li><a href="#sntp-steplimit">sntp steplimit</a>:              steplimit option (-S)
-<li><a href="#sntp-syslog">sntp syslog</a>:                 syslog option (-p)
-<li><a href="#sntp-timeout">sntp timeout</a>:                timeout option (-t)
-<li><a href="#sntp-unpriv_002dport">sntp unpriv-port</a>:            unpriv-port option (-u)
+<li><a href="#sntp-slew">sntp slew</a>:                   slew option (-s)
+<li><a href="#sntp-step">sntp step</a>:                   step option (-S)
+<li><a href="#sntp-steplimit">sntp steplimit</a>:              steplimit option (-M)
+<li><a href="#sntp-usereservedport">sntp usereservedport</a>:        usereservedport option (-r)
 </ul>
 
 <div class="node">
 <p><hr>
 <a name="sntp-usage"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-adjtime">sntp adjtime</a>,
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-authentication">sntp authentication</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
@@ -162,33 +166,22 @@ USAGE:  sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ].
    -6 no  ipv6           Force IPv6 DNS name resolution
                                 - prohibits these options:
                                 ipv4
-   -K Fil kod            KoD history filename
-   -p no  syslog         Logging with syslog
-                                - prohibits these options:
-                                filelog
-   -l Fil filelog        Log to specified logfile
-                                - prohibits these options:
-                                syslog
-   -S Num steplimit      Adjustments less than steplimit msec will be slewed.
-                                - prohibits these options:
-                                adjtime
-                                settod
-   -s no  settod         Set (step) the time with settimeofday()
-                                - prohibits these options:
-                                adjtime
-                                steplimit
-   -j no  adjtime        Set (slew) the time with adjtime()
-                                - prohibits these options:
-                                settod
-                                steplimit
-   -c Str concurrent     Send concurrent queries to all IPs returned for host-name
+   -a Num authentication Enable authentication with the key auth-keynumber
+   -B Num bctimeout      Specify the number of seconds to wait for broadcasts
+   -b Str broadcast      Listen to the address specified for broadcast time sync
                                 - may appear multiple times
-   -b Str broadcast      Use broadcasts to the address specified for synchronisation
+   -c Str concurrent     Concurrent query all IPs returned for host-name
                                 - may appear multiple times
-   -t Num timeout        Specify the number of seconds to wait for broadcasts
-   -a Num authentication Enable authentication with the key auth-keynumber
+   -l Fil filelog        Log to specified logfile
+   -K Fil kod            KoD history filename
    -k Fil keyfile        Specify a keyfile. SNTP will look in this file for the key specified with -a
-   -u no  unpriv-port    Use an unprivileged port for communicating
+   -M Num steplimit      Adjustments less than steplimit msec will be slewed.
+                                - it must be:  greater than or equal to 0
+   -o Num ntpversion     Send &lt;int&gt; as our NTP version
+                                - it must be:  0 to 7
+   -r no  usereservedport Use the NTP Reserved Port (port 123)
+   -S no  step           OK to 'step' the time with settimeofday()
+   -s no  slew           OK to 'slew' the time with adjtime()
       opt version        Output version information and exit
    -? no  help           Display extended usage information and exit
    -! no  more-help      Extended usage information passed thru pager
@@ -220,46 +213,42 @@ please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
 </pre>
   <div class="node">
 <p><hr>
-<a name="sntp-adjtime"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-authentication">sntp authentication</a>,
+<a name="sntp-authentication"></a>
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-bctimeout">sntp bctimeout</a>,
 Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-usage">sntp usage</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">adjtime option (-j)</h4>
-
-<p><a name="index-sntp_002dadjtime-4"></a>
-This is the &ldquo;set (slew) the time with adjtime()&rdquo; option.
+<h4 class="subsection">authentication option (-a)</h4>
 
-  <p>This option has some usage constraints.  It:
-     <ul>
-<li>must not appear in combination with any of the following options:
-settod, steplimit. 
-</ul>
+<p><a name="index-sntp_002dauthentication-4"></a>
+This is the &ldquo;enable authentication with the key auth-keynumber&rdquo; option. 
+This option enables authentication using the key specified in this option's argument. 
+The argument of this option is the keyid, a number specified in the keyfile as this
+key's identifier. See the keyfile option (-k) for more details.
 
 <div class="node">
 <p><hr>
-<a name="sntp-authentication"></a>
+<a name="sntp-bctimeout"></a>
 Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-broadcast">sntp broadcast</a>,
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-adjtime">sntp adjtime</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-authentication">sntp authentication</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">authentication option (-a)</h4>
+<h4 class="subsection">bctimeout option (-B)</h4>
 
-<p><a name="index-sntp_002dauthentication-5"></a>
-This is the &ldquo;enable authentication with the key auth-keynumber&rdquo; option. 
-This option enables authentication using the key specified in this option's argument. 
-The argument of this option is the keyid, a number specified in the keyfile as this
-key's identifier. See the keyfile option (-k) for more details.
+<p><a name="index-sntp_002dbctimeout-5"></a>
+This is the &ldquo;specify the number of seconds to wait for broadcasts&rdquo; option. 
+When waiting for a broadcast packet SNTP will wait the number
+of seconds specified before giving up.  Default 68 seconds.
 
 <div class="node">
 <p><hr>
 <a name="sntp-broadcast"></a>
 Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-concurrent">sntp concurrent</a>,
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-authentication">sntp authentication</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-bctimeout">sntp bctimeout</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
@@ -267,16 +256,16 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 <h4 class="subsection">broadcast option (-b)</h4>
 
 <p><a name="index-sntp_002dbroadcast-6"></a>
-This is the &ldquo;use broadcasts to the address specified for synchronisation&rdquo; option.
+This is the &ldquo;listen to the address specified for broadcast time sync&rdquo; option.
 
   <p>This option has some usage constraints.  It:
      <ul>
 <li>may appear an unlimited number of times. 
 </ul>
 
-  <p>If specified SNTP will listen to the specified broadcast address
+  <p>If specified SNTP will listen to the specified address
 for NTP broadcasts.  The default maximum wait time,
-68 seconds, can be modified with -t.
+68 seconds, can be modified with -B.
 
 <div class="node">
 <p><hr>
@@ -290,7 +279,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 <h4 class="subsection">concurrent option (-c)</h4>
 
 <p><a name="index-sntp_002dconcurrent-7"></a>
-This is the &ldquo;send concurrent queries to all ips returned for host-name&rdquo; option.
+This is the &ldquo;concurrent query all ips returned for host-name&rdquo; option.
 
   <p>This option has some usage constraints.  It:
      <ul>
@@ -341,15 +330,8 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 <h4 class="subsection">filelog option (-l)</h4>
 
 <p><a name="index-sntp_002dfilelog-9"></a>
-This is the &ldquo;log to specified logfile&rdquo; option.
-
-  <p>This option has some usage constraints.  It:
-     <ul>
-<li>must not appear in combination with any of the following options:
-syslog. 
-</ul>
-
-  <p>This option causes the client to write log messages to the specified
+This is the &ldquo;log to specified logfile&rdquo; option. 
+This option causes the client to write log messages to the specified
 logfile.
 
 <div class="node">
@@ -428,7 +410,7 @@ M  Key in a 1-to-8 character ASCII string using the MD5 authentication scheme.
 <div class="node">
 <p><hr>
 <a name="sntp-kod"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-set_002ddebug_002dlevel">sntp set-debug-level</a>,
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-ntpversion">sntp ntpversion</a>,
 Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-keyfile">sntp keyfile</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
@@ -444,120 +426,99 @@ responses received from servers.  The default is
 
 <div class="node">
 <p><hr>
-<a name="sntp-set-debug-level"></a>
-<a name="sntp-set_002ddebug_002dlevel"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-settod">sntp settod</a>,
+<a name="sntp-ntpversion"></a>
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-set_002ddebug_002dlevel">sntp set-debug-level</a>,
 Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-kod">sntp kod</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">set-debug-level option (-D)</h4>
-
-<p><a name="index-sntp_002dset_002ddebug_002dlevel-14"></a>
-This is the &ldquo;set the output debug message level&rdquo; option.
+<h4 class="subsection">ntpversion option (-o)</h4>
 
-  <p>This option has some usage constraints.  It:
-     <ul>
-<li>may appear an unlimited number of times. 
-</ul>
-
-  <p>Set the output debugging level.  Can be supplied multiple times,
-but each overrides the previous value(s).
+<p><a name="index-sntp_002dntpversion-14"></a>
+This is the &ldquo;send &lt;int&gt; as our ntp version&rdquo; option. 
+When sending requests to a remote server, tell them we are running
+NTP protocol version &lt;ntpversion&gt; .
 
 <div class="node">
 <p><hr>
-<a name="sntp-settod"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-steplimit">sntp steplimit</a>,
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-set_002ddebug_002dlevel">sntp set-debug-level</a>,
+<a name="sntp-set-debug-level"></a>
+<a name="sntp-set_002ddebug_002dlevel"></a>
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-slew">sntp slew</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-ntpversion">sntp ntpversion</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">settod option (-s)</h4>
+<h4 class="subsection">set-debug-level option (-D)</h4>
 
-<p><a name="index-sntp_002dsettod-15"></a>
-This is the &ldquo;set (step) the time with settimeofday()&rdquo; option.
+<p><a name="index-sntp_002dset_002ddebug_002dlevel-15"></a>
+This is the &ldquo;set the output debug message level&rdquo; option.
 
   <p>This option has some usage constraints.  It:
      <ul>
-<li>must not appear in combination with any of the following options:
-adjtime, steplimit. 
+<li>may appear an unlimited number of times. 
 </ul>
 
+  <p>Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+
 <div class="node">
 <p><hr>
-<a name="sntp-steplimit"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-syslog">sntp syslog</a>,
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-settod">sntp settod</a>,
+<a name="sntp-slew"></a>
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-step">sntp step</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-set_002ddebug_002dlevel">sntp set-debug-level</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">steplimit option (-S)</h4>
+<h4 class="subsection">slew option (-s)</h4>
 
-<p><a name="index-sntp_002dsteplimit-16"></a>
-This is the &ldquo;adjustments less than steplimit msec will be slewed.&rdquo; option.
-
-  <p>This option has some usage constraints.  It:
-     <ul>
-<li>must not appear in combination with any of the following options:
-adjtime, settod. 
-</ul>
-
-  <p>If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
+<p><a name="index-sntp_002dslew-16"></a>
+This is the &ldquo;ok to 'slew' the time with adjtime()&rdquo; option.
 
 <div class="node">
 <p><hr>
-<a name="sntp-syslog"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-timeout">sntp timeout</a>,
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-steplimit">sntp steplimit</a>,
+<a name="sntp-step"></a>
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-steplimit">sntp steplimit</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-slew">sntp slew</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">syslog option (-p)</h4>
+<h4 class="subsection">step option (-S)</h4>
 
-<p><a name="index-sntp_002dsyslog-17"></a>
-This is the &ldquo;logging with syslog&rdquo; option.
-
-  <p>This option has some usage constraints.  It:
-     <ul>
-<li>must not appear in combination with any of the following options:
-filelog. 
-</ul>
-
-  <p>When this option is set all logging will be done using syslog.
+<p><a name="index-sntp_002dstep-17"></a>
+This is the &ldquo;ok to 'step' the time with settimeofday()&rdquo; option.
 
 <div class="node">
 <p><hr>
-<a name="sntp-timeout"></a>
-Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-unpriv_002dport">sntp unpriv-port</a>,
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-syslog">sntp syslog</a>,
+<a name="sntp-steplimit"></a>
+Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-usereservedport">sntp usereservedport</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-step">sntp step</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">timeout option (-t)</h4>
+<h4 class="subsection">steplimit option (-M)</h4>
 
-<p><a name="index-sntp_002dtimeout-18"></a>
-This is the &ldquo;specify the number of seconds to wait for broadcasts&rdquo; option. 
-When waiting for a broadcast packet SNTP will wait the number
-of seconds specified before giving up.  Default 68 seconds.
+<p><a name="index-sntp_002dsteplimit-18"></a>
+This is the &ldquo;adjustments less than steplimit msec will be slewed.&rdquo; option. 
+If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime().  Otherwise, step the correction using settimeofday().
 
 <div class="node">
 <p><hr>
-<a name="sntp-unpriv-port"></a>
-<a name="sntp-unpriv_002dport"></a>
-Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-timeout">sntp timeout</a>,
+<a name="sntp-usereservedport"></a>
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-steplimit">sntp steplimit</a>,
 Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
 
 </div>
 
-<h4 class="subsection">unpriv-port option (-u)</h4>
+<h4 class="subsection">usereservedport option (-r)</h4>
 
-<p><a name="index-sntp_002dunpriv_002dport-19"></a>
-This is the &ldquo;use an unprivileged port for communicating&rdquo; option.
+<p><a name="index-sntp_002dusereservedport-19"></a>
+This is the &ldquo;use the ntp reserved port (port 123)&rdquo; option. 
+Use port 123, which is reserved for NTP, for our network communications.
 
 <div class="node">
 <p><hr>
index 482cf1eb065d80294cac7af3bc77430e0a0948bb..2c8de936c8aa8254b1eab04e3642802cbee82a72 100644 (file)
@@ -54,10 +54,14 @@ By default, @code{sntp} writes the local data and time (i.e., not UTC) to the
 standard output in the format:
 
 @example
-1996 Oct 15 20:17:25.123 +4.567 +/- 0.089 secs
+1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 secs
 @end example
 
-where the +4.567 +/- 0.089 secs indicates the time offset and
+where
+YYYY-MM-DD HH:MM:SS.SUBSEC is the local date and time,
+(+0800) is the local timezone adjustment (so we would add 8 hours and 0 minutes to convert the reported local time to UTC),
+and
+the +4.567 +/- 0.089 secs indicates the time offset and
 error bound of the system clock relative to the server clock.
 
 @include sntp-opts.texi