]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3030] ntpq needs a general way to specify refid output format. HStenn.
authorHarlan Stenn <stenn@ntp.org>
Wed, 16 Mar 2016 08:46:16 +0000 (08:46 +0000)
committerHarlan Stenn <stenn@ntp.org>
Wed, 16 Mar 2016 08:46:16 +0000 (08:46 +0000)
bk: 56e91d58GMDIJb5QfhULjDpwf_kCbA

12 files changed:
ChangeLog
ntpq/invoke-ntpq.texi
ntpq/ntpq-opts.c
ntpq/ntpq-opts.def
ntpq/ntpq-opts.h
ntpq/ntpq-subs.c
ntpq/ntpq.1ntpqman
ntpq/ntpq.1ntpqmdoc
ntpq/ntpq.c
ntpq/ntpq.h
ntpq/ntpq.man.in
ntpq/ntpq.mdoc.in

index c70fe8fc563cf0a16def01a652b989e8bc667f06..e7f35b4e0c465ae60f9a8d8bfc0d7c578a78d79c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 * [Bug 2994] Systems with HAVE_SIGNALED_IO fail to compile. perlinger@ntp.org
 * [Bug 2995] Fixes to compile on Windows
+* [Bug 3030] ntpq needs a general way to specify refid output format.  HStenn.
 
 ---
 (4.2.8p6) 2016/01/20 Released by Harlan Stenn <stenn@ntp.org>
index bcd1df4ecf314914f4dc2eae1b5a23902c059122..697ad71d71fd3949d6e3c5f9ecb9885603447147 100644 (file)
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntpq.texi)
 #
-# It has been AutoGen-ed  January 20, 2016 at 04:19:10 AM by AutoGen 5.18.5
+# It has been AutoGen-ed  March 16, 2016 at 05:10:35 AM by AutoGen 5.18.5
 # From the definitions    ntpq-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -826,6 +826,7 @@ This software is released under the NTP license, <http://ntp.org/license>.
 * ntpq numeric::                numeric option (-n)
 * ntpq old-rv::                 old-rv option
 * ntpq peers::                  peers option (-p)
+* ntpq refid::                  refid option (-r)
 * ntpq wide::                   wide option (-w)
 * ntpq config::                 presetting/configuring ntpq
 * ntpq exit status::            exit status
@@ -868,6 +869,7 @@ Usage:  ntpq [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
       no  old-rv         Always output status line with readvar
    -p no  peers          Print a list of the peers
                                 - prohibits the option 'interactive'
+   -r KWd refid          Set default display type for S2+ refids
    -w no  wide           Display the full 'remote' value
       opt version        output version information and exit
    -? no  help           display extended usage information and exit
@@ -885,6 +887,10 @@ The following option preset mechanisms are supported:
  - reading file ./.ntprc
  - examining environment variables named NTPQ_*
 
+The valid "refid" option keywords are:
+  hash ipv4
+  or an integer from 0 through 1
+
 Please send bug reports to:  <http://bugs.ntp.org, bugs@@ntp.org>
 @end example
 @exampleindent 4
@@ -992,6 +998,27 @@ interactive.
 
 Print a list of the peers known to the server as well as a summary
 of their state. This is equivalent to the 'peers' interactive command.
+@node ntpq refid
+@subsection refid option (-r)
+@cindex ntpq-refid
+
+This is the ``set default display type for s2+ refids'' option.
+This option takes a keyword argument.
+
+@noindent
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+This option takes a keyword as its argument.
+The argument sets an enumeration value that can be tested by comparing the option value macro (OPT_VALUE_REFID).
+The available keywords are:
+@example
+    hash ipv4
+@end example
+
+or their numeric equivalent.@end itemize
+
+Set the default display format for S2+ refids.
 @node ntpq wide
 @subsection wide option (-w)
 @cindex ntpq-wide
index 42131a3390090f5760e06efa90e6f87f0e27ed0f..0ba5698f2204c6bbcff2cadac00b3485b9730996 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.c)
  *
- *  It has been AutoGen-ed  January 20, 2016 at 04:18:42 AM by AutoGen 5.18.5
+ *  It has been AutoGen-ed  March 16, 2016 at 05:10:15 AM by AutoGen 5.18.5
  *  From the definitions    ntpq-opts.def
  *  and the template file   options
  *
@@ -68,7 +68,7 @@ extern FILE * option_usage_fp;
 /**
  *  static const strings for ntpq options
  */
-static char const ntpq_opt_strs[1925] =
+static char const ntpq_opt_strs[1982] =
 /*     0 */ "ntpq 4.2.8p6\n"
             "Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
@@ -113,29 +113,33 @@ static char const ntpq_opt_strs[1925] =
 /*  1404 */ "Print a list of the peers\0"
 /*  1430 */ "PEERS\0"
 /*  1436 */ "peers\0"
-/*  1442 */ "Display the full 'remote' value\0"
-/*  1474 */ "WIDE\0"
-/*  1479 */ "wide\0"
-/*  1484 */ "display extended usage information and exit\0"
-/*  1528 */ "help\0"
-/*  1533 */ "extended usage information passed thru pager\0"
-/*  1578 */ "more-help\0"
-/*  1588 */ "output version information and exit\0"
-/*  1624 */ "version\0"
-/*  1632 */ "save the option state to a config file\0"
-/*  1671 */ "save-opts\0"
-/*  1681 */ "load options from a config file\0"
-/*  1713 */ "LOAD_OPTS\0"
-/*  1723 */ "no-load-opts\0"
-/*  1736 */ "no\0"
-/*  1739 */ "NTPQ\0"
-/*  1744 */ "ntpq - standard NTP query program - Ver. 4.2.8p6\n"
+/*  1442 */ "Set default display type for S2+ refids\0"
+/*  1482 */ "REFID\0"
+/*  1488 */ "refid\0"
+/*  1494 */ "Display the full 'remote' value\0"
+/*  1526 */ "WIDE\0"
+/*  1531 */ "wide\0"
+/*  1536 */ "display extended usage information and exit\0"
+/*  1580 */ "help\0"
+/*  1585 */ "extended usage information passed thru pager\0"
+/*  1630 */ "more-help\0"
+/*  1640 */ "output version information and exit\0"
+/*  1676 */ "version\0"
+/*  1684 */ "save the option state to a config file\0"
+/*  1723 */ "save-opts\0"
+/*  1733 */ "load options from a config file\0"
+/*  1765 */ "LOAD_OPTS\0"
+/*  1775 */ "no-load-opts\0"
+/*  1788 */ "no\0"
+/*  1791 */ "NTPQ\0"
+/*  1796 */ "ntpq - standard NTP query program - Ver. 4.2.8p6\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0"
-/*  1863 */ "$HOME\0"
-/*  1869 */ ".\0"
-/*  1871 */ ".ntprc\0"
-/*  1878 */ "http://bugs.ntp.org, bugs@ntp.org\0"
-/*  1912 */ "ntpq 4.2.8p6";
+/*  1915 */ "$HOME\0"
+/*  1921 */ ".\0"
+/*  1923 */ ".ntprc\0"
+/*  1930 */ "http://bugs.ntp.org, bugs@ntp.org\0"
+/*  1964 */ "ntpq 4.2.8p6\0"
+/*  1977 */ "hash";
 
 /**
  *  ipv4 option description with
@@ -264,26 +268,41 @@ static int const aPeersCantList[] = {
 /** Compiled in flag settings for the peers option */
 #define PEERS_FLAGS     (OPTST_DISABLED)
 
+/**
+ *  refid option description:
+ */
+/** Descriptive text for the refid option */
+#define REFID_DESC      (ntpq_opt_strs+1442)
+/** Upper-cased name for the refid option */
+#define REFID_NAME      (ntpq_opt_strs+1482)
+/** Name string for the refid option */
+#define REFID_name      (ntpq_opt_strs+1488)
+/** The compiled in default value for the refid option argument */
+#define REFID_DFT_ARG   ((char const*)REFID_IPV4)
+/** Compiled in flag settings for the refid option */
+#define REFID_FLAGS     (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_ENUMERATION))
+
 /**
  *  wide option description:
  */
 /** Descriptive text for the wide option */
-#define WIDE_DESC      (ntpq_opt_strs+1442)
+#define WIDE_DESC      (ntpq_opt_strs+1494)
 /** Upper-cased name for the wide option */
-#define WIDE_NAME      (ntpq_opt_strs+1474)
+#define WIDE_NAME      (ntpq_opt_strs+1526)
 /** Name string for the wide option */
-#define WIDE_name      (ntpq_opt_strs+1479)
+#define WIDE_name      (ntpq_opt_strs+1531)
 /** Compiled in flag settings for the wide option */
 #define WIDE_FLAGS     (OPTST_DISABLED)
 
 /*
  *  Help/More_Help/Version option descriptions:
  */
-#define HELP_DESC       (ntpq_opt_strs+1484)
-#define HELP_name       (ntpq_opt_strs+1528)
+#define HELP_DESC       (ntpq_opt_strs+1536)
+#define HELP_name       (ntpq_opt_strs+1580)
 #ifdef HAVE_WORKING_FORK
-#define MORE_HELP_DESC  (ntpq_opt_strs+1533)
-#define MORE_HELP_name  (ntpq_opt_strs+1578)
+#define MORE_HELP_DESC  (ntpq_opt_strs+1585)
+#define MORE_HELP_name  (ntpq_opt_strs+1630)
 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
 #else
 #define MORE_HELP_DESC  HELP_DESC
@@ -296,14 +315,14 @@ static int const aPeersCantList[] = {
 #  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
                          OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
 #endif
-#define VER_DESC        (ntpq_opt_strs+1588)
-#define VER_name        (ntpq_opt_strs+1624)
-#define SAVE_OPTS_DESC  (ntpq_opt_strs+1632)
-#define SAVE_OPTS_name  (ntpq_opt_strs+1671)
-#define LOAD_OPTS_DESC     (ntpq_opt_strs+1681)
-#define LOAD_OPTS_NAME     (ntpq_opt_strs+1713)
-#define NO_LOAD_OPTS_name  (ntpq_opt_strs+1723)
-#define LOAD_OPTS_pfx      (ntpq_opt_strs+1736)
+#define VER_DESC        (ntpq_opt_strs+1640)
+#define VER_name        (ntpq_opt_strs+1676)
+#define SAVE_OPTS_DESC  (ntpq_opt_strs+1684)
+#define SAVE_OPTS_name  (ntpq_opt_strs+1723)
+#define LOAD_OPTS_DESC     (ntpq_opt_strs+1733)
+#define LOAD_OPTS_NAME     (ntpq_opt_strs+1765)
+#define NO_LOAD_OPTS_name  (ntpq_opt_strs+1775)
+#define LOAD_OPTS_pfx      (ntpq_opt_strs+1788)
 #define LOAD_OPTS_name     (NO_LOAD_OPTS_name + 3)
 /**
  *  Declare option callback procedures
@@ -314,7 +333,7 @@ extern tOptProc
     optionResetOpt,          optionStackArg,          optionTimeDate,
     optionTimeVal,           optionUnstackArg,        optionVendorOption;
 static tOptProc
-    doOptDebug_Level, doUsageOpt;
+    doOptDebug_Level, doOptRefid, doUsageOpt;
 #define VER_PROC        ntpOptionPrintVersion
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -432,8 +451,20 @@ static tOptDesc optDesc[OPTION_CT] = {
      /* desc, NAME, name */ PEERS_DESC, PEERS_NAME, PEERS_name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 9, VALUE_OPT_WIDE,
-     /* equiv idx, value */ 9, VALUE_OPT_WIDE,
+  {  /* entry idx, value */ 9, VALUE_OPT_REFID,
+     /* equiv idx, value */ 9, VALUE_OPT_REFID,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ REFID_FLAGS, 0,
+     /* last opt argumnt */ { REFID_DFT_ARG },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doOptRefid,
+     /* desc, NAME, name */ REFID_DESC, REFID_NAME, REFID_name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 10, VALUE_OPT_WIDE,
+     /* equiv idx, value */ 10, VALUE_OPT_WIDE,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ WIDE_FLAGS, 0,
@@ -512,24 +543,24 @@ static tOptDesc optDesc[OPTION_CT] = {
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 /** Reference to the upper cased version of ntpq. */
-#define zPROGNAME       (ntpq_opt_strs+1739)
+#define zPROGNAME       (ntpq_opt_strs+1791)
 /** Reference to the title line for ntpq usage. */
-#define zUsageTitle     (ntpq_opt_strs+1744)
+#define zUsageTitle     (ntpq_opt_strs+1796)
 /** ntpq configuration file name. */
-#define zRcName         (ntpq_opt_strs+1871)
+#define zRcName         (ntpq_opt_strs+1923)
 /** Directories to search for ntpq config files. */
 static char const * const apzHomeList[3] = {
-    ntpq_opt_strs+1863,
-    ntpq_opt_strs+1869,
+    ntpq_opt_strs+1915,
+    ntpq_opt_strs+1921,
     NULL };
 /** The ntpq program bug email address. */
-#define zBugsAddr       (ntpq_opt_strs+1878)
+#define zBugsAddr       (ntpq_opt_strs+1930)
 /** Clarification/explanation of what ntpq does. */
 #define zExplain        (NULL)
 /** Extra detail explaining what ntpq does. */
 #define zDetail         (NULL)
 /** The full version string for ntpq. */
-#define zFullVersion    (ntpq_opt_strs+1912)
+#define zFullVersion    (ntpq_opt_strs+1964)
 /* extracted from optcode.tlib near line 364 */
 
 #if defined(ENABLE_NLS)
@@ -588,6 +619,30 @@ OPT_VALUE_SET_DEBUG_LEVEL++;
     (void)pOptDesc;
     (void)pOptions;
 }
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/**
+ * Code to handle the refid option.
+ * Set the default display format for S2+ refids.
+ * @param[in] pOptions the ntpq options data structure
+ * @param[in,out] pOptDesc the option descriptor for this option.
+ */
+static void
+doOptRefid(tOptions* pOptions, tOptDesc* pOptDesc)
+{
+
+/* extracted from optmain.tlib near line 945 */
+    static char const * const names[2] = {
+        ntpq_opt_strs+1977, ntpq_opt_strs+1044 };
+
+    if (pOptions <= OPTPROC_EMIT_LIMIT) {
+        (void) optionEnumerationVal(pOptions, pOptDesc, names, 2);
+        return; /* protect AutoOpts client code from internal callbacks */
+    }
+
+    pOptDesc->optArg.argEnum =
+        optionEnumerationVal(pOptions, pOptDesc, names, 2);
+}
 /* extracted from optmain.tlib near line 1250 */
 
 /**
@@ -651,7 +706,7 @@ tOptions ntpqOptions = {
       NO_EQUIVALENT, /* '-#' option index */
       NO_EQUIVALENT /* index of default opt */
     },
-    15 /* full option count */, 10 /* user option count */,
+    16 /* full option count */, 11 /* user option count */,
     ntpq_full_usage, ntpq_short_usage,
     NULL, NULL,
     PKGDATADIR, ntpq_packager_info
@@ -833,6 +888,9 @@ implied warranty.\n"));
   /* referenced via ntpqOptions.pOptDesc->pzText */
   puts(_("Print a list of the peers"));
 
+  /* referenced via ntpqOptions.pOptDesc->pzText */
+  puts(_("Set default display type for S2+ refids"));
+
   /* referenced via ntpqOptions.pOptDesc->pzText */
   puts(_("Display the full 'remote' value"));
 
index bac20d79af9379c80080a794c472ae6cca7d5bc0..9232268f297b06d2714805ae8fd3847fe01fdd19 100644 (file)
@@ -99,6 +99,18 @@ flag = {
        _EndOfDoc_;
 };
 
+flag = {
+    name      = refid;
+    value     = r;
+    descrip   = "Set default display type for S2+ refids";
+    arg-type  = keyword;
+    keyword   = hash, ipv4;
+    arg-default = ipv4;
+    doc = <<-  _EndOfDoc_
+       Set the default display format for S2+ refids.
+       _EndOfDoc_;
+};
+
 flag = {
     name      = wide;
     value     = w;
index af7a4c2c6e8265c037d047c12afde1984bd79c09..1092f312c4f86f13b98ccbeb45c1ba481d5ac214 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
  *
- *  It has been AutoGen-ed  January 20, 2016 at 04:18:42 AM by AutoGen 5.18.5
+ *  It has been AutoGen-ed  March 16, 2016 at 05:10:15 AM by AutoGen 5.18.5
  *  From the definitions    ntpq-opts.def
  *  and the template file   options
  *
@@ -73,15 +73,16 @@ typedef enum {
     INDEX_OPT_NUMERIC          =  6,
     INDEX_OPT_OLD_RV           =  7,
     INDEX_OPT_PEERS            =  8,
-    INDEX_OPT_WIDE             =  9,
-    INDEX_OPT_VERSION          = 10,
-    INDEX_OPT_HELP             = 11,
-    INDEX_OPT_MORE_HELP        = 12,
-    INDEX_OPT_SAVE_OPTS        = 13,
-    INDEX_OPT_LOAD_OPTS        = 14
+    INDEX_OPT_REFID            =  9,
+    INDEX_OPT_WIDE             = 10,
+    INDEX_OPT_VERSION          = 11,
+    INDEX_OPT_HELP             = 12,
+    INDEX_OPT_MORE_HELP        = 13,
+    INDEX_OPT_SAVE_OPTS        = 14,
+    INDEX_OPT_LOAD_OPTS        = 15
 } teOptIndex;
 /** count of all options for ntpq */
-#define OPTION_CT    15
+#define OPTION_CT    16
 /** ntpq version */
 #define NTPQ_VERSION       "4.2.8p6"
 /** Full ntpq version text */
@@ -174,6 +175,10 @@ typedef enum {
 #  warning undefining PEERS due to option name conflict
 #  undef   PEERS
 # endif
+# ifdef    REFID
+#  warning undefining REFID due to option name conflict
+#  undef   REFID
+# endif
 # ifdef    WIDE
 #  warning undefining WIDE due to option name conflict
 #  undef   WIDE
@@ -188,6 +193,7 @@ typedef enum {
 # undef NUMERIC
 # undef OLD_RV
 # undef PEERS
+# undef REFID
 # undef WIDE
 #endif  /*  NO_OPTION_NAME_WARNINGS */
 
@@ -206,6 +212,13 @@ typedef enum {
 #define VALUE_OPT_NUMERIC        'n'
 #define VALUE_OPT_OLD_RV         0x1001
 #define VALUE_OPT_PEERS          'p'
+#define VALUE_OPT_REFID          'r'
+
+typedef enum {
+    REFID_HASH, REFID_IPV4
+} te_Refid;
+#define OPT_REFID_VAL2STR(_v)    optionKeywordName(&DESC(REFID), (_v))
+#define OPT_VALUE_REFID          (DESC(REFID).optArg.argEnum)
 #define VALUE_OPT_WIDE           'w'
 /** option flag (value) for help-value option */
 #define VALUE_OPT_HELP          '?'
index 8e7047776cf8bd9675ae6ab0b31ee13a2822975e..f6bbf212814cbd1a03e7a26758545edd84886072 100644 (file)
@@ -1679,7 +1679,8 @@ doprintpeers(
                } else if (!strcmp("hmode", name)) {
                        decodeint(value, &hmode);
                } else if (!strcmp("refid", name)) {
-                       if (pvl == peervarlist) {
+                       if (   (pvl == peervarlist)
+                           && (drefid == REFID_IPV4)) {
                                have_da_rid = TRUE;
                                drlen = strlen(value);
                                if (0 == drlen) {
@@ -1700,7 +1701,9 @@ doprintpeers(
                                } else {
                                        have_da_rid = FALSE;
                                }
-                       } else if (pvl == apeervarlist) {
+                       } else if (   (pvl == apeervarlist)
+                                  || (pvl == peervarlist)) {
+                               /* no need to check drefid == REFID_HASH */
                                have_da_rid = TRUE;
                                drlen = strlen(value);
                                if (0 == drlen) {
@@ -2030,15 +2033,19 @@ peers(
        FILE *fp
        )
 {
-       int af = 0;
+       if (drefid == REFID_HASH) {
+               apeers(pcmd, fp);
+       } else {
+               int af = 0;
 
-       if (pcmd->nargs == 1) {
-               if (pcmd->argval->ival == 6)
-                       af = AF_INET6;
-               else
-                       af = AF_INET;
+               if (pcmd->nargs == 1) {
+                       if (pcmd->argval->ival == 6)
+                               af = AF_INET6;
+                       else
+                               af = AF_INET;
+               }
+               dopeers(0, fp, af);
        }
-       dopeers(0, fp, af);
 }
 
 
index b96d1068b010005e663bacdb37b43e2d59b1b6c2..5425a2104bcaca7b823e2e5e91d95f06663c144f 100644 (file)
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpq 1ntpqman "20 Jan 2016" "4.2.8p6" "User Commands"
+.TH ntpq 1ntpqman "16 Mar 2016" "4.2.8p6" "User Commands"
 .\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Z7aWRV/ag-_7aOQV)
+.\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed January 20, 2016 at 04:19:06 AM by AutoGen 5.18.5
+.\" It has been AutoGen-ed March 16, 2016 at 05:10:36 AM by AutoGen 5.18.5
 .\" From the definitions ntpq-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -1347,6 +1347,27 @@ interactive.
 Print a list of the peers known to the server as well as a summary
 of their state. This is equivalent to the 'peers' interactive command.
 .TP
+.NOP \f\*[B-Font]\-r\f[] \f\*[I-Font]keyword\f[], \f\*[B-Font]\-\-refid\f[]=\f\*[I-Font]keyword\f[]
+Set default display type for S2+ refids.
+This option takes a keyword as its argument.  The argument sets an enumeration value that can
+be tested by comparing them against the option value macro.
+The available keywords are:
+.in +4
+.nf
+.na
+hash ipv4
+.fi
+or their numeric equivalent.
+.in -4
+.sp
+The default
+\f\*[I-Font]keyword\f[]
+for this option is:
+.ti +4
+ ipv4
+.sp
+Set the default display format for S2+ refids.
+.TP
 .NOP \f\*[B-Font]\-w\f[], \f\*[B-Font]\-\-wide\f[]
 Display the full 'remote' value.
 .sp
index d4da8d761d1f84dfe530548dcebc074ce32d8c2a..968dbfa19547657b8ef508096497fe22ed7443e9 100644 (file)
@@ -1,9 +1,9 @@
-.Dd January 20 2016
+.Dd March 16 2016
 .Dt NTPQ 1ntpqmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpq-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  January 20, 2016 at 04:19:12 AM by AutoGen 5.18.5
+.\"  It has been AutoGen-ed  March 16, 2016 at 05:10:32 AM by AutoGen 5.18.5
 .\"  From the definitions    ntpq-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -898,6 +898,26 @@ interactive.
 .sp
 Print a list of the peers known to the server as well as a summary
 of their state. This is equivalent to the 'peers' interactive command.
+.It  Fl r Ar keyword , Fl \-refid Ns = Ns Ar keyword 
+Set default display type for S2+ refids.
+This option takes a keyword as its argument.  The argument sets an enumeration value that can
+be tested by comparing them against the option value macro.
+The available keywords are:
+.in +4
+.nf
+.na
+hash ipv4
+.fi
+or their numeric equivalent.
+.in -4
+.sp
+The default
+.Ar keyword
+for this option is:
+.ti +4
+ ipv4
+.sp
+Set the default display format for S2+ refids.
 .It  Fl w , Fl \-wide 
 Display the full 'remote' value.
 .sp
index 1dcaeb794822e2987a42d73856d198ed10253913..37103752e6f68102f5b872743385d85385e2e4ea 100644 (file)
@@ -38,7 +38,6 @@
 #include <ssl_applink.c>
 
 #include "ntp_libopts.h"
-#include "ntpq-opts.h"
 #include "safecast.h"
 
 #ifdef SYS_VXWORKS             /* vxWorks needs mode flag -casey*/
@@ -67,6 +66,11 @@ const char *prompt = "ntpq> ";       /* prompt to ask him about */
  */
 int    old_rv = 1;
 
+/*
+ * How should we display the refid?
+ * REFID_HASH, REFID_IPV4
+ */
+te_Refid drefid = -1;
 
 /*
  * for get_systime()
@@ -198,6 +202,7 @@ static      void    passwd          (struct parse *, FILE *);
 static void    hostnames       (struct parse *, FILE *);
 static void    setdebug        (struct parse *, FILE *);
 static void    quit            (struct parse *, FILE *);
+static void    showdrefid      (struct parse *, FILE *);
 static void    version         (struct parse *, FILE *);
 static void    raw             (struct parse *, FILE *);
 static void    cooked          (struct parse *, FILE *);
@@ -269,6 +274,9 @@ struct xcmd builtins[] = {
        { "keyid",      keyid,          { OPT|NTP_UINT, NO, NO, NO },
          { "key#", "", "", "" },
          "set keyid to use for authenticated requests" },
+       { "drefid",     showdrefid,     { OPT|NTP_STR, NO, NO, NO },
+         { "hash|ipv4", "", "", "" },
+         "display refid's as IPv4 or hash" },
        { "version",    version,        { NO, NO, NO, NO },
          { "", "", "", "" },
          "print version number" },
@@ -532,6 +540,8 @@ ntpqmain(
 
        old_rv = HAVE_OPT(OLD_RV);
 
+       drefid = OPT_VALUE_REFID;
+
        if (0 == argc) {
                ADDHOST(DEFHOST);
        } else {
@@ -1327,7 +1337,7 @@ show_error_msg(
        if (numhosts > 1)
                fprintf(stderr, "server=%s ", currenthost);
 
-       switch(m6resp) {
+       switch (m6resp) {
 
        case CERR_BADFMT:
                fprintf(stderr,
@@ -2440,6 +2450,47 @@ ntp_poll(
 }
 
 
+/*
+ * showdrefid2str - return a string explanation of the value of drefid
+ */
+static char *
+showdrefid2str(void)
+{
+       switch (drefid) {
+           case REFID_HASH:
+               return "hash";
+           case REFID_IPV4:
+               return "ipv4";
+           default:
+               return "Unknown";
+       }
+}
+
+
+/*
+ * drefid - display/change "display hash" 
+ */
+static void
+showdrefid(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               (void) fprintf(fp, "drefid value is %s\n", showdrefid2str());
+               return;
+       } else if (STREQ(pcmd->argval[0].string, "hash")) {
+               drefid = REFID_HASH;
+       } else if (STREQ(pcmd->argval[0].string, "ipv4")) {
+               drefid = REFID_IPV4;
+       } else {
+               (void) fprintf(fp, "What?\n");
+               return;
+       }
+       (void) fprintf(fp, "drefid value set to %s\n", showdrefid2str());
+}
+
+
 /*
  * keyid - get a keyid to use for authenticating requests
  */
index 55ea0fb5c3622a1464efc2c6139f913889309114..1f0291531d9902a880150978d1ace5e4c402de33 100644 (file)
@@ -13,6 +13,8 @@
 #include "ntp_control.h"
 #include "lib_strbuf.h"
 
+#include "ntpq-opts.h"
+
 /*
  * Maximum number of arguments
  */
@@ -126,6 +128,7 @@ extern chost        chosts[];
 
 extern int     interactive;    /* are we prompting? */
 extern int     old_rv;         /* use old rv behavior? --old-rv */
+extern te_Refid        drefid;         /* How should we display a refid? */
 extern u_int   assoc_cache_slots;/* count of allocated array entries */
 extern u_int   numassoc;       /* number of cached associations */
 extern u_int   numhosts;
index abe26085e190e2ccfd043bbc8e2cdc743dd21cba..363f1815da8de909ae0fab72669029dace586cc3 100644 (file)
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpq @NTPQ_MS@ "20 Jan 2016" "4.2.8p6" "User Commands"
+.TH ntpq @NTPQ_MS@ "16 Mar 2016" "4.2.8p6" "User Commands"
 .\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Z7aWRV/ag-_7aOQV)
+.\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed January 20, 2016 at 04:19:06 AM by AutoGen 5.18.5
+.\" It has been AutoGen-ed March 16, 2016 at 05:10:36 AM by AutoGen 5.18.5
 .\" From the definitions ntpq-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -1347,6 +1347,27 @@ interactive.
 Print a list of the peers known to the server as well as a summary
 of their state. This is equivalent to the 'peers' interactive command.
 .TP
+.NOP \f\*[B-Font]\-r\f[] \f\*[I-Font]keyword\f[], \f\*[B-Font]\-\-refid\f[]=\f\*[I-Font]keyword\f[]
+Set default display type for S2+ refids.
+This option takes a keyword as its argument.  The argument sets an enumeration value that can
+be tested by comparing them against the option value macro.
+The available keywords are:
+.in +4
+.nf
+.na
+hash ipv4
+.fi
+or their numeric equivalent.
+.in -4
+.sp
+The default
+\f\*[I-Font]keyword\f[]
+for this option is:
+.ti +4
+ ipv4
+.sp
+Set the default display format for S2+ refids.
+.TP
 .NOP \f\*[B-Font]\-w\f[], \f\*[B-Font]\-\-wide\f[]
 Display the full 'remote' value.
 .sp
index d71c508ae1e8b8a5629f127f7b32563e01518e71..cb1408b7c6f87d9f3c6e627c551d9048c361f7e8 100644 (file)
@@ -1,9 +1,9 @@
-.Dd January 20 2016
+.Dd March 16 2016
 .Dt NTPQ @NTPQ_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpq-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  January 20, 2016 at 04:19:12 AM by AutoGen 5.18.5
+.\"  It has been AutoGen-ed  March 16, 2016 at 05:10:32 AM by AutoGen 5.18.5
 .\"  From the definitions    ntpq-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -898,6 +898,26 @@ interactive.
 .sp
 Print a list of the peers known to the server as well as a summary
 of their state. This is equivalent to the 'peers' interactive command.
+.It  Fl r Ar keyword , Fl \-refid Ns = Ns Ar keyword 
+Set default display type for S2+ refids.
+This option takes a keyword as its argument.  The argument sets an enumeration value that can
+be tested by comparing them against the option value macro.
+The available keywords are:
+.in +4
+.nf
+.na
+hash ipv4
+.fi
+or their numeric equivalent.
+.in -4
+.sp
+The default
+.Ar keyword
+for this option is:
+.ti +4
+ ipv4
+.sp
+Set the default display format for S2+ refids.
 .It  Fl w , Fl \-wide 
 Display the full 'remote' value.
 .sp