* [Bug 1330] disallow interface/nic rules when --novirtualips or
--interface are used.
+* [Bug 1332] ntpq -c 'rv 0 variablename' returns extra stuff.
* Add test of ntpd --saveconfigquit fidelity using new complete.conf.
* Documentation updates from Dave Hart/Dave Mills.
(4.2.5p226) 2009/10/04 Released by Harlan Stenn <stenn@ntp.org>
/*
* EDIT THIS FILE WITH CAUTION (ntpq-opts.c)
*
- * It has been AutoGen-ed October 4, 2009 at 07:42:10 AM by AutoGen 5.9.9pre5
+ * It has been AutoGen-ed Monday October 5, 2009 at 06:18:35 AM UTC
* From the definitions ntpq-opts.def
* and the template file options
*
*
* This source file is copyrighted and licensed under the following terms:
*
- * ntpq copyright (c) 1970-2009 David L. Mills and/or others - all rights reserved
+ * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
*
* see html/copyright.html
*/
# define EXIT_FAILURE 1
#endif
/*
- * Ipv4 option description:
+ * Ipv4 option description with
+ * "Must also have options" and "Incompatible options":
*/
tSCC zIpv4Text[] =
"Force IPv4 DNS name resolution";
tSCC zIpv4_NAME[] = "IPV4";
tSCC zIpv4_Name[] = "ipv4";
+static const int
+ aIpv4CantList[] = {
+ INDEX_OPT_IPV6, NO_EQUIVALENT };
#define IPV4_FLAGS (OPTST_DISABLED)
/*
- * Ipv6 option description:
+ * Ipv6 option description with
+ * "Must also have options" and "Incompatible options":
*/
tSCC zIpv6Text[] =
"Force IPv6 DNS name resolution";
tSCC zIpv6_NAME[] = "IPV6";
tSCC zIpv6_Name[] = "ipv6";
+static const int
+ aIpv6CantList[] = {
+ INDEX_OPT_IPV4, NO_EQUIVALENT };
#define IPV6_FLAGS (OPTST_DISABLED)
/*
tSCC zNumeric_Name[] = "numeric";
#define NUMERIC_FLAGS (OPTST_DISABLED)
+/*
+ * Old_Rv option description:
+ */
+tSCC zOld_RvText[] =
+ "Always output status line with readvar";
+tSCC zOld_Rv_NAME[] = "OLD_RV";
+tSCC zOld_Rv_Name[] = "old-rv";
+#define OLD_RV_FLAGS (OPTST_DISABLED)
+
/*
* Help/More_Help/Version option descriptions:
*/
*/
static tOptDesc optDesc[ OPTION_CT ] = {
{ /* entry idx, value */ 0, VALUE_OPT_IPV4,
- /* equiv idx, value */ NO_EQUIVALENT, 0,
+ /* equiv idx, value */ 0, VALUE_OPT_IPV4,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ IPV4_FLAGS, 0,
/* last opt argumnt */ { NULL },
/* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
+ /* must/cannot opts */ NULL, aIpv4CantList,
/* option proc */ NULL,
/* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
/* disablement strs */ NULL, NULL },
{ /* entry idx, value */ 1, VALUE_OPT_IPV6,
- /* equiv idx, value */ NOLIMIT, NOLIMIT,
- /* equivalenced to */ INDEX_OPT_IPV4,
+ /* equiv idx, value */ 1, VALUE_OPT_IPV6,
+ /* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ IPV6_FLAGS, 0,
/* last opt argumnt */ { NULL },
/* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
+ /* must/cannot opts */ NULL, aIpv6CantList,
/* option proc */ NULL,
/* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
/* disablement strs */ NULL, NULL },
/* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
/* disablement strs */ NULL, NULL },
+ { /* entry idx, value */ 8, VALUE_OPT_OLD_RV,
+ /* equiv idx, value */ 8, VALUE_OPT_OLD_RV,
+ /* equivalenced to */ NO_EQUIVALENT,
+ /* min, max, act ct */ 0, 1, 0,
+ /* opt state flags */ OLD_RV_FLAGS, 0,
+ /* last opt argumnt */ { NULL },
+ /* arg list/cookie */ NULL,
+ /* must/cannot opts */ NULL, NULL,
+ /* option proc */ NULL,
+ /* desc, NAME, name */ zOld_RvText, zOld_Rv_NAME, zOld_Rv_Name,
+ /* disablement strs */ NULL, NULL },
+
#ifdef NO_OPTIONAL_OPT_ARGS
# define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT
#else
NO_EQUIVALENT, /* '-#' option index */
NO_EQUIVALENT /* index of default opt */
},
- 13 /* full option count */, 8 /* user option count */,
+ 14 /* full option count */, 9 /* user option count */,
ntpq_full_usage, ntpq_short_usage,
NULL, NULL
};
flag = {
name = ipv4;
+ flags-cant = ipv6;
value = 4;
- equivalence = ipv4;
descrip = "Force IPv4 DNS name resolution";
doc = <<- _EndOfDoc_
Force DNS resolution of following host names on the command line
flag = {
name = ipv6;
+ flags-cant = ipv4;
value = 6;
- equivalence = ipv4;
descrip = "Force IPv6 DNS name resolution";
doc = <<- _EndOfDoc_
Force DNS resolution of following host names on the command line
_EndOfDoc_;
};
+flag = {
+ name = old-rv;
+ descrip = "Always output status line with readvar";
+ doc = <<- _EndOfDoc_
+ By default, ntpq now suppresses the associd=... line that
+ precedes the output of "readvar" (alias "rv") when a single
+ variable is requested, such as ntpq -c "rv 0 offset". This
+ option causes ntpq to include both lines of output for a
+ single-variable readvar. Using an environment variable to
+ preset this option in a script will enable both older and
+ newer ntpq to behave identically in this regard.
+ _EndOfDoc_;
+};
+
detail = <<- _END_DETAIL
The
[= prog-name =]
/*
* EDIT THIS FILE WITH CAUTION (ntpq-opts.h)
*
- * It has been AutoGen-ed October 4, 2009 at 07:42:09 AM by AutoGen 5.9.9pre5
+ * It has been AutoGen-ed Monday October 5, 2009 at 06:18:35 AM UTC
* From the definitions ntpq-opts.def
* and the template file options
*
*
* This source file is copyrighted and licensed under the following terms:
*
- * ntpq copyright (c) 1970-2009 David L. Mills and/or others - all rights reserved
+ * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
*
* see html/copyright.html
*/
INDEX_OPT_PEERS = 5,
INDEX_OPT_INTERACTIVE = 6,
INDEX_OPT_NUMERIC = 7,
- INDEX_OPT_VERSION = 8,
- INDEX_OPT_HELP = 9,
- INDEX_OPT_MORE_HELP = 10,
- INDEX_OPT_SAVE_OPTS = 11,
- INDEX_OPT_LOAD_OPTS = 12
+ INDEX_OPT_OLD_RV = 8,
+ INDEX_OPT_VERSION = 9,
+ INDEX_OPT_HELP = 10,
+ INDEX_OPT_MORE_HELP = 11,
+ INDEX_OPT_SAVE_OPTS = 12,
+ INDEX_OPT_LOAD_OPTS = 13
} teOptIndex;
-#define OPTION_CT 13
+#define OPTION_CT 14
#define NTPQ_VERSION "4.2.5p226"
#define NTPQ_FULL_VERSION "ntpq - standard NTP query program - Ver. 4.2.5p226"
# warning undefining NUMERIC due to option name conflict
# undef NUMERIC
# endif
+# ifdef OLD_RV
+# warning undefining OLD_RV due to option name conflict
+# undef OLD_RV
+# endif
#else /* NO_OPTION_NAME_WARNINGS */
# undef IPV4
# undef IPV6
# undef PEERS
# undef INTERACTIVE
# undef NUMERIC
+# undef OLD_RV
#endif /* NO_OPTION_NAME_WARNINGS */
/* * * * * *
* Interface defines for specific options.
*/
#define VALUE_OPT_IPV4 '4'
-#define WHICH_OPT_IPV4 (DESC(IPV4).optActualValue)
-#define WHICH_IDX_IPV4 (DESC(IPV4).optActualIndex)
#define VALUE_OPT_IPV6 '6'
#define VALUE_OPT_COMMAND 'c'
#define VALUE_OPT_DEBUG_LEVEL 'd'
#define VALUE_OPT_PEERS 'p'
#define VALUE_OPT_INTERACTIVE 'i'
#define VALUE_OPT_NUMERIC 'n'
+#define VALUE_OPT_OLD_RV 8
#define VALUE_OPT_HELP '?'
#define VALUE_OPT_MORE_HELP '!'
#define VALUE_OPT_VERSION INDEX_OPT_VERSION
#
# EDIT THIS FILE WITH CAUTION (ntpq-opts.texi)
#
-# It has been AutoGen-ed October 4, 2009 at 07:42:13 AM by AutoGen 5.9.9pre5
+# It has been AutoGen-ed Monday October 5, 2009 at 06:18:38 AM UTC
# From the definitions ntpq-opts.def
# and the template file aginfo.tpl
@end ignore
* ntpq ipv4:: ipv4 option (-4)
* ntpq ipv6:: ipv6 option (-6)
* ntpq numeric:: numeric option (-n)
+* ntpq old-rv:: old-rv option
* ntpq peers:: peers option (-p)
* ntpq set-debug-level:: set-debug-level option (-D)
@end menu
or by a single hyphen and the flag character.
The following option preset mechanisms are supported:
- - reading file /users/stenn/.ntprc
- - reading file /deacon/backroom/snaps/ntp-dev/ntpq/.ntprc
+ - reading file /m/pogo/users/hart/.ntprc
+ - reading file /m/pogo/users/hart/ntp-dev-1332/ntpq/.ntprc
- examining environment variables named NTPQ_*
The
This option has some usage constraints. It:
@itemize @bullet
@item
-is a member of the ipv4 class of options.
+must not appear in combination with any of the following options:
+ipv6.
@end itemize
Force DNS resolution of following host names on the command line
This option has some usage constraints. It:
@itemize @bullet
@item
-is a member of the ipv4 class of options.
+must not appear in combination with any of the following options:
+ipv4.
@end itemize
Force DNS resolution of following host names on the command line
This is the ``numeric host addresses'' option.
Output all host addresses in dotted-quad numeric format rather than
converting to the canonical host names.
+
+@node ntpq old-rv
+@subsection old-rv option
+@cindex ntpq-old-rv
+
+This is the ``always output status line with readvar'' option.
+By default, ntpq now suppresses the associd=... line that
+precedes the output of "readvar" (alias "rv") when a single
+variable is requested, such as ntpq -c "rv 0 offset". This
+option causes ntpq to include both lines of output for a
+single-variable readvar. Using an environment variable to
+preset this option in a script will enable both older and
+newer ntpq to behave identically in this regard.
#include <sys/types.h>
#include <sys/time.h>
-#include "ntpq.h"
#include "ntp_stdlib.h"
+#include "ntpq.h"
+#include "ntpq-opts.h"
extern char * chosts[];
extern char currenthost[];
static void dormvlist (struct varlist *, char *);
static void doclearvlist (struct varlist *);
static void makequerydata (struct varlist *, int *, char *);
-static int doquerylist (struct varlist *, int, int, int, u_short *, int *, char **);
+static int doquerylist (struct varlist *, int, int, int,
+ u_short *, int *, char **);
static void doprintvlist (struct varlist *, FILE *);
static void addvars (struct parse *, FILE *);
static void rmvars (struct parse *, FILE *);
static void clearvars (struct parse *, FILE *);
static void showvars (struct parse *, FILE *);
-static int dolist (struct varlist *, int, int, int, FILE *);
+static int dolist (struct varlist *, int, int, int,
+ FILE *);
static void readlist (struct parse *, FILE *);
static void writelist (struct parse *, FILE *);
static void readvar (struct parse *, FILE *);
static void writevar (struct parse *, FILE *);
static void clocklist (struct parse *, FILE *);
static void clockvar (struct parse *, FILE *);
-static int findassidrange (u_int32, u_int32, int *, int *);
+static int findassidrange (u_int32, u_int32, int *, int *);
static void mreadlist (struct parse *, FILE *);
static void mreadvar (struct parse *, FILE *);
-static int dogetassoc (FILE *);
+static int dogetassoc (FILE *);
static void printassoc (int, FILE *);
static void associations (struct parse *, FILE *);
static void lassociations (struct parse *, FILE *);
struct varlist {
char *name;
char *value;
-} varlist[MAXLIST] = { { 0, 0 } };
+} g_varlist[MAXLIST] = { { 0, 0 } };
/*
* Imported from ntpq.c
free((void *)vl->name);
if (vl->value != 0)
free(vl->value);
- for ( ; (vl+1) < (varlist+MAXLIST)
+ for ( ; (vl+1) < (g_varlist + MAXLIST)
&& (vl+1)->name != 0; vl++) {
vl->name = (vl+1)->name;
vl->value = (vl+1)->value;
FILE *fp
)
{
- doaddvlist(varlist, pcmd->argval[0].string);
+ doaddvlist(g_varlist, pcmd->argval[0].string);
}
FILE *fp
)
{
- dormvlist(varlist, pcmd->argval[0].string);
+ dormvlist(g_varlist, pcmd->argval[0].string);
}
FILE *fp
)
{
- doclearvlist(varlist);
+ doclearvlist(g_varlist);
}
FILE *fp
)
{
- doprintvlist(varlist, fp);
+ doprintvlist(g_varlist, fp);
}
int res;
int dsize;
u_short rstatus;
+ int quiet;
+
+ /*
+ * if we're asking for specific variables don't include the
+ * status header line in the output.
+ */
+ if (HAVE_OPT( OLD_RV ))
+ quiet = 0;
+ else
+ quiet = (vlist->name != NULL);
res = doquerylist(vlist, op, associd, 0, &rstatus, &dsize, &datap);
return 1;
}
- (void) fprintf(fp,"associd=%d ",associd);
- printvars(dsize, datap, (int)rstatus, type, fp);
+ if (!quiet)
+ fprintf(fp,"associd=%d ",associd);
+ printvars(dsize, datap, (int)rstatus, type, quiet, fp);
return 1;
}
return;
}
- (void) dolist(varlist, associd, CTL_OP_READVAR,
+ (void) dolist(g_varlist, associd, CTL_OP_READVAR,
(associd == 0) ? TYPE_SYS : TYPE_PEER, fp);
}
return;
}
- res = doquerylist(varlist, CTL_OP_WRITEVAR, associd, 1, &rstatus,
+ res = doquerylist(g_varlist, CTL_OP_WRITEVAR, associd, 1, &rstatus,
&dsize, &datap);
if (res != 0)
else {
(void) fprintf(fp,"associd=%d ",associd);
printvars(dsize, datap, (int)rstatus,
- (associd != 0) ? TYPE_PEER : TYPE_SYS, fp);
+ (associd != 0) ? TYPE_PEER : TYPE_SYS, 0, fp);
}
return;
}
else {
(void) fprintf(fp,"associd=%d ",associd);
printvars(dsize, datap, (int)rstatus,
- (associd != 0) ? TYPE_PEER : TYPE_SYS, fp);
+ (associd != 0)
+ ? TYPE_PEER
+ : TYPE_SYS,
+ 0, fp);
}
return;
}
return;
}
- (void) dolist(varlist, associd, CTL_OP_READCLOCK, TYPE_CLOCK, fp);
+ (void) dolist(g_varlist, associd, CTL_OP_READCLOCK, TYPE_CLOCK, fp);
}
for (i = from; i <= to; i++) {
if (i != from)
(void) fprintf(fp, "\n");
- if (!dolist(varlist, (int)assoc_cache[i].assid,
+ if (!dolist(g_varlist, (int)assoc_cache[i].assid,
CTL_OP_READVAR, TYPE_PEER, fp))
return;
}
for (i = from; i <= to; i++) {
if (i != from)
(void) fprintf(fp, "\n");
- if (!dolist(varlist, (int)assoc_cache[i].assid,
+ if (!dolist(g_varlist, (int)assoc_cache[i].assid,
CTL_OP_READVAR, TYPE_PEER, fp))
break;
}
}
(void) fprintf(fp,"associd=%d ",associd);
- printvars(dsize, datap, (int)rstatus, TYPE_PEER, fp);
+ printvars(dsize, datap, (int)rstatus, TYPE_PEER, 0, fp);
}
-.TH NTPQ 1 2009-10-04 "( 4.2.5p226)" "Programmer's Manual"
+.TH NTPQ 1 2009-10-05 "( 4.2.5p226)" "Programmer's Manual"
.\" EDIT THIS FILE WITH CAUTION (ntpq.1)
.\"
-.\" It has been AutoGen-ed October 4, 2009 at 07:42:11 AM by AutoGen 5.9.9pre5
+.\" It has been AutoGen-ed Monday October 5, 2009 at 06:18:37 AM UTC
.\" From the definitions ntpq-opts.def
.\" and the template file agman1.tpl
.\"
.TP
.BR \-4 ", " \--ipv4
Force IPv4 DNS name resolution.
-This option is a member of the ipv4 class of options.
+This option must not appear in combination with any of the following options:
+ipv6.
.sp
Force DNS resolution of following host names on the command line
to the IPv4 namespace.
.TP
.BR \-6 ", " \--ipv6
Force IPv6 DNS name resolution.
-This option is a member of the ipv4 class of options.
+This option must not appear in combination with any of the following options:
+ipv4.
.sp
Force DNS resolution of following host names on the command line
to the IPv6 namespace.
Output all host addresses in dotted-quad numeric format rather than
converting to the canonical host names.
.TP
+.BR \--old-rv
+Always output status line with readvar.
+.sp
+By default, ntpq now suppresses the associd=... line that
+precedes the output of "readvar" (alias "rv") when a single
+variable is requested, such as ntpq \-c "rv 0 offset". This
+option causes ntpq to include both lines of output for a
+single-variable readvar. Using an environment variable to
+preset this option in a script will enable both older and
+newer ntpq to behave identically in this regard.
+.TP
.BR \-? , " \--help"
Display usage information and exit.
.TP
static u_long getkeyid (const char *);
static void atoascii (int, char *, char *);
static void makeascii (int, char *, FILE *);
-static void rawprint (int, int, char *, int, FILE *);
+static void cookedprint (int, int, char *, int, int, FILE *);
+static void rawprint (int, int, char *, int, int, FILE *);
static void startoutput (void);
static void output (FILE *, char *, char *);
static void endoutput (FILE *);
static void outputarr (FILE *, char *, int, l_fp *);
-static void cookedprint (int, int, char *, int, FILE *);
#ifdef QSORT_USES_VOID_P
static int assoccmp (const void *, const void *);
#else
* handled by ntpq_custom_opt_handler().
*/
- switch (WHICH_IDX_IPV4) {
- case INDEX_OPT_IPV4:
+ debug = DESC(DEBUG_LEVEL).optOccCt;
+
+ if (HAVE_OPT(IPV4))
ai_fam_templ = AF_INET;
- break;
- case INDEX_OPT_IPV6:
+ else if (HAVE_OPT(IPV6))
ai_fam_templ = AF_INET6;
- break;
- default:
+ else
ai_fam_templ = ai_fam_default;
- break;
- }
- debug = DESC(DEBUG_LEVEL).optOccCt;
-
- if (HAVE_OPT(INTERACTIVE)) {
+ if (HAVE_OPT(INTERACTIVE))
interactive = 1;
- }
- if (HAVE_OPT(NUMERIC)) {
+ if (HAVE_OPT(NUMERIC))
showhostnames = 0;
- }
#if 0
while ((c = ntp_getopt(argc, argv, "46c:dinp")) != EOF)
char *data,
int status,
int sttype,
+ int quiet,
FILE *fp
)
{
if (rawmode)
- rawprint(sttype, length, data, status, fp);
+ rawprint(sttype, length, data, status, quiet, fp);
else
- cookedprint(sttype, length, data, status, fp);
+ cookedprint(sttype, length, data, status, quiet, fp);
}
int length,
char *data,
int status,
+ int quiet,
FILE *fp
)
{
cp = data;
cpend = data + length;
- (void) fprintf(fp, "status=0x%04x,\n", status);
+ if (!quiet)
+ (void) fprintf(fp, "status=0x%04x,\n", status);
while (cp < cpend) {
if (*cp == '\r') {
* \n, supress this, else pretty print it. Otherwise
* just output the character.
*/
- if (cp == (cpend-1) || *(cp+1) != '\n')
+ if (cp == (cpend - 1) || *(cp + 1) != '\n')
makeascii(1, cp, fp);
- } else if (isspace((int)*cp) || isprint((int)*cp)) {
+ } else if (isspace(*cp) || isprint(*cp))
putc(*cp, fp);
- } else {
+ else
makeascii(1, cp, fp);
- }
cp++;
}
}
int length,
char *data,
int status,
+ int quiet,
FILE *fp
)
{
return;
}
- (void) fprintf(fp, "status=%04x %s,\n", status,
- statustoa(datatype, status));
+ if (!quiet)
+ (void) fprintf(fp, "status=%04x %s,\n", status,
+ statustoa(datatype, status));
startoutput();
while (nextvar(&length, &data, &name, &value)) {
extern int decodeuint (char *, u_long *);
extern int nextvar (int *, char **, char **, char **);
extern int decodetime (char *, l_fp *);
-extern void printvars (int, char *, int, int, FILE *);
+extern void printvars (int, char *, int, int, int, FILE *);
extern int decodeint (char *, long *);
extern int findvar (char *, struct ctl_var *, int code);