#include "isc/result.h"
#ifdef SYS_WINNT
+#include <Mswsock.h>
# include <io.h>
#else
# define closesocket close
{ "help", help, { OPT|NTP_STR, NO, NO, NO },
{ "command", "", "", "" },
"tell the use and syntax of commands" },
- { "timeout", timeout, { OPT|UINT, NO, NO, NO },
+ { "timeout", timeout, { OPT|NTP_UINT, NO, NO, NO },
{ "msec", "", "", "" },
"set the primary receive time out" },
- { "delay", my_delay, { OPT|INT, NO, NO, NO },
+ { "delay", my_delay, { OPT|NTP_INT, NO, NO, NO },
{ "msec", "", "", "" },
"set the delay added to encryption time stamps" },
{ "host", host, { OPT|NTP_STR, OPT|NTP_STR, NO, NO },
{ "exit", quit, { NO, NO, NO, NO },
{ "", "", "", "" },
"exit ntpdc" },
- { "keyid", keyid, { OPT|UINT, NO, NO, NO },
+ { "keyid", keyid, { OPT|NTP_UINT, NO, NO, NO },
{ "key#", "", "", "" },
"set/show keyid to use for authenticated requests" },
{ "keytype", keytype, { OPT|NTP_STR, NO, NO, NO },
case NTP_STR:
argp->string = str;
break;
- case ADD:
+ case NTP_ADD:
if (!strcmp("-6", str)) {
ai_fam_templ = AF_INET6;
return -1;
return 0;
}
break;
- case INT:
- case UINT:
+ case NTP_INT:
+ case NTP_UINT:
isneg = 0;
np = str;
if (*np == '-') {
} while (*(++np) != '\0');
if (isneg) {
- if ((code & ~OPT) == UINT) {
+ if ((code & ~OPT) == NTP_UINT) {
(void) fprintf(stderr,
"***Value %s should be unsigned\n", str);
return 0;
opt46 = 0;
(void) fprintf(fp, "usage: %s", xcp->keyword);
for (i = 0; i < MAXARGS && xcp->arg[i] != NO; i++) {
- if (opt46 == 0 && (xcp->arg[i] & ~OPT) == ADD) {
+ if (opt46 == 0 && (xcp->arg[i] & ~OPT) == NTP_ADD) {
(void) fprintf(fp, " [ -4|-6 ]");
opt46 = 1;
}
/*
* Flags for forming descriptors.
*/
-#define OPT 0x80 /* this argument is optional, or'd with type */
+#define OPT 0x80 /* this argument is optional, or'd with type */
-#define NO 0x0
-#define NTP_STR 0x1 /* string argument */
-#define UINT 0x2 /* unsigned integer */
-#define INT 0x3 /* signed integer */
-#define ADD 0x4 /* IP network address */
-#define IP_VERSION 0x5 /* IP version */
+#define NO 0x0
+#define NTP_STR 0x1 /* string argument */
+#define NTP_UINT 0x2 /* unsigned integer */
+#define NTP_INT 0x3 /* signed integer */
+#define NTP_ADD 0x4 /* IP network address */
+#define IP_VERSION 0x5 /* IP version */
/*
* Arguments are returned in a union
{ "dmpeers", dmpeers, { OPT|IP_VERSION, NO, NO, NO },
{ "-4|-6", "", "", "" },
"display peer summary info the way Dave Mills likes it (IP Version)" },
- { "showpeer", showpeer, { ADD, OPT|ADD, OPT|ADD, OPT|ADD},
+ { "showpeer", showpeer, { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD},
{ "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
"display detailed information for one or more peers" },
- { "pstats", peerstats, { ADD, OPT|ADD, OPT|ADD, OPT|ADD },
+ { "pstats", peerstats, { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
{ "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
"display statistical information for one or more peers" },
{ "loopinfo", loopinfo, { OPT|NTP_STR, NO, NO, NO },
{ "timerstats", timerstats, { NO, NO, NO, NO },
{ "", "", "", "" },
"display event timer subsystem statistics" },
- { "addpeer", addpeer, { ADD, OPT|UINT, OPT|UINT, OPT|NTP_STR },
+ { "addpeer", addpeer, { NTP_ADD, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_STR },
{ "addr", "keyid", "version", "minpoll|prefer" },
"configure a new peer association" },
- { "addserver", addserver, { ADD, OPT|UINT, OPT|UINT, OPT|NTP_STR },
+ { "addserver", addserver, { NTP_ADD, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_STR },
{ "addr", "keyid", "version", "minpoll|prefer" },
"configure a new server" },
- { "addrefclock",addrefclock, { ADD, OPT|UINT, OPT|NTP_STR, OPT|NTP_STR },
+ { "addrefclock",addrefclock, { NTP_ADD, OPT|NTP_UINT, OPT|NTP_STR, OPT|NTP_STR },
{ "addr", "mode", "minpoll|prefer", "minpoll|prefer" },
"configure a new server" },
- { "broadcast", broadcast, { ADD, OPT|UINT, OPT|UINT, OPT|NTP_STR },
+ { "broadcast", broadcast, { NTP_ADD, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_STR },
{ "addr", "keyid", "version", "minpoll" },
"configure broadcasting time service" },
- { "unconfig", unconfig, { ADD, OPT|ADD, OPT|ADD, OPT|ADD },
+ { "unconfig", unconfig, { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
{ "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
"unconfigure existing peer assocations" },
{ "enable", set, { NTP_STR, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
{ "reslist", reslist, {OPT|IP_VERSION, NO, NO, NO },
{ "-4|-6", "", "", "" },
"display the server's restrict list" },
- { "restrict", new_restrict, { ADD, ADD, NTP_STR, OPT|NTP_STR },
+ { "restrict", new_restrict, { NTP_ADD, NTP_ADD, NTP_STR, OPT|NTP_STR },
{ "address", "mask",
"ntpport|ignore|noserve|notrust|noquery|nomodify|nopeer|version|kod",
"..." },
"create restrict entry/add flags to entry" },
- { "unrestrict", unrestrict, { ADD, ADD, NTP_STR, OPT|NTP_STR },
+ { "unrestrict", unrestrict, { NTP_ADD, NTP_ADD, NTP_STR, OPT|NTP_STR },
{ "address", "mask",
"ntpport|ignore|noserve|notrust|noquery|nomodify|nopeer|version|kod",
"..." },
"remove flags from a restrict entry" },
- { "delrestrict", delrestrict, { ADD, ADD, OPT|NTP_STR, NO },
+ { "delrestrict", delrestrict, { NTP_ADD, NTP_ADD, OPT|NTP_STR, NO },
{ "address", "mask", "ntpport", "" },
"delete a restrict entry" },
- { "monlist", monlist, { OPT|INT, NO, NO, NO },
+ { "monlist", monlist, { OPT|NTP_INT, NO, NO, NO },
{ "version", "", "", "" },
"display data the server's monitor routines have collected" },
{ "reset", reset, { NTP_STR, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
{ "io|sys|mem|timer|auth|allpeers", "...", "...", "..." },
"reset various subsystem statistics counters" },
- { "preset", preset, { ADD, OPT|ADD, OPT|ADD, OPT|ADD },
+ { "preset", preset, { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
{ "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
"reset stat counters associated with particular peer(s)" },
{ "readkeys", readkeys, { NO, NO, NO, NO },
{ "", "", "", "" },
"request a reread of the keys file and re-init of system keys" },
- { "trustedkey", trustkey, { UINT, OPT|UINT, OPT|UINT, OPT|UINT },
+ { "trustedkey", trustkey, { NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT },
{ "keyid", "keyid", "keyid", "keyid" },
"add one or more key ID's to the trusted list" },
- { "untrustedkey", untrustkey, { UINT, OPT|UINT, OPT|UINT, OPT|UINT },
+ { "untrustedkey", untrustkey, { NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT },
{ "keyid", "keyid", "keyid", "keyid" },
"remove one or more key ID's from the trusted list" },
{ "authinfo", authinfo, { NO, NO, NO, NO },
{ "traps", traps, { NO, NO, NO, NO },
{ "", "", "", "" },
"display the traps set in the server" },
- { "addtrap", addtrap, { ADD, OPT|UINT, OPT|ADD, NO },
+ { "addtrap", addtrap, { NTP_ADD, OPT|NTP_UINT, OPT|NTP_ADD, NO },
{ "address", "port", "interface", "" },
"configure a trap in the server" },
- { "clrtrap", clrtrap, { ADD, OPT|UINT, OPT|ADD, NO },
+ { "clrtrap", clrtrap, { NTP_ADD, OPT|NTP_UINT, OPT|NTP_ADD, NO },
{ "address", "port", "interface", "" },
"remove a trap (configured or otherwise) from the server" },
- { "requestkey", requestkey, { UINT, NO, NO, NO },
+ { "requestkey", requestkey, { NTP_UINT, NO, NO, NO },
{ "keyid", "", "", "" },
"change the keyid the server uses to authenticate requests" },
- { "controlkey", controlkey, { UINT, NO, NO, NO },
+ { "controlkey", controlkey, { NTP_UINT, NO, NO, NO },
{ "keyid", "", "", "" },
"change the keyid the server uses to authenticate control messages" },
{ "ctlstats", ctlstats, { NO, NO, NO, NO },
{ "", "", "", "" },
"display packet count statistics from the control module" },
- { "clockstat", clockstat, { ADD, OPT|ADD, OPT|ADD, OPT|ADD },
+ { "clockstat", clockstat, { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
{ "address", "address", "address", "address" },
"display clock status information" },
- { "fudge", fudge, { ADD, NTP_STR, NTP_STR, NO },
+ { "fudge", fudge, { NTP_ADD, NTP_STR, NTP_STR, NO },
{ "address", "time1|time2|val1|val2|flags", "value", "" },
"set/change one of a clock's fudge factors" },
- { "clkbug", clkbug, { ADD, OPT|ADD, OPT|ADD, OPT|ADD },
+ { "clkbug", clkbug, { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
{ "address", "address", "address", "address" },
"display clock debugging information" },
{ "kerninfo", kerninfo, { NO, NO, NO, NO },
#include "isc/result.h"
#ifdef SYS_WINNT
+#include <Mswsock.h>
# include <io.h>
#else
#define closesocket close
* Built-in commands we understand
*/
struct xcmd builtins[] = {
- { "?", help, { OPT|STR, NO, NO, NO },
+ { "?", help, { OPT|NTP_STR, NO, NO, NO },
{ "command", "", "", "" },
"tell the use and syntax of commands" },
- { "help", help, { OPT|STR, NO, NO, NO },
+ { "help", help, { OPT|NTP_STR, NO, NO, NO },
{ "command", "", "", "" },
"tell the use and syntax of commands" },
- { "timeout", timeout, { OPT|UINT, NO, NO, NO },
+ { "timeout", timeout, { OPT|NTP_UINT, NO, NO, NO },
{ "msec", "", "", "" },
"set the primary receive time out" },
- { "delay", auth_delay, { OPT|INT, NO, NO, NO },
+ { "delay", auth_delay, { OPT|NTP_INT, NO, NO, NO },
{ "msec", "", "", "" },
"set the delay added to encryption time stamps" },
- { "host", host, { OPT|STR, OPT|STR, NO, NO },
+ { "host", host, { OPT|NTP_STR, OPT|NTP_STR, NO, NO },
{ "-4|-6", "hostname", "", "" },
"specify the host whose NTP server we talk to" },
- { "poll", ntp_poll, { OPT|UINT, OPT|STR, NO, NO },
+ { "poll", ntp_poll, { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
{ "n", "verbose", "", "" },
"poll an NTP server in client mode `n' times" },
{ "passwd", passwd, { NO, NO, NO, NO },
{ "", "", "", "" },
"specify a password to use for authenticated requests"},
- { "hostnames", hostnames, { OPT|STR, NO, NO, NO },
+ { "hostnames", hostnames, { OPT|NTP_STR, NO, NO, NO },
{ "yes|no", "", "", "" },
"specify whether hostnames or net numbers are printed"},
- { "debug", setdebug, { OPT|STR, NO, NO, NO },
+ { "debug", setdebug, { OPT|NTP_STR, NO, NO, NO },
{ "no|more|less", "", "", "" },
"set/change debugging level" },
{ "quit", quit, { NO, NO, NO, NO },
{ "exit", quit, { NO, NO, NO, NO },
{ "", "", "", "" },
"exit ntpq" },
- { "keyid", keyid, { OPT|UINT, NO, NO, NO },
+ { "keyid", keyid, { OPT|NTP_UINT, NO, NO, NO },
{ "key#", "", "", "" },
"set keyid to use for authenticated requests" },
{ "version", version, { NO, NO, NO, NO },
{ "cooked", cooked, { NO, NO, NO, NO },
{ "", "", "", "" },
"do cooked mode variable output" },
- { "authenticate", authenticate, { OPT|STR, NO, NO, NO },
+ { "authenticate", authenticate, { OPT|NTP_STR, NO, NO, NO },
{ "yes|no", "", "", "" },
"always authenticate requests to this server" },
- { "ntpversion", ntpversion, { OPT|UINT, NO, NO, NO },
+ { "ntpversion", ntpversion, { OPT|NTP_UINT, NO, NO, NO },
{ "version number", "", "", "" },
"set the NTP version number to use for requests" },
- { "keytype", keytype, { OPT|STR, NO, NO, NO },
+ { "keytype", keytype, { OPT|NTP_STR, NO, NO, NO },
{ "key type (md5|des)", "", "", "" },
"set key type to use for authenticated requests (des|md5)" },
{ 0, 0, { NO, NO, NO, NO },
static const char *digits = "0123456789";
switch (code & ~OPT) {
- case STR:
+ case NTP_STR:
argp->string = str;
break;
- case ADD:
+ case NTP_ADD:
if (!getnetnum(str, &(argp->netnum), (char *)0, 0)) {
return 0;
}
break;
- case INT:
- case UINT:
+ case NTP_INT:
+ case NTP_UINT:
isneg = 0;
np = str;
if (*np == '&') {
} while (*(++np) != '\0');
if (isneg) {
- if ((code & ~OPT) == UINT) {
+ if ((code & ~OPT) == NTP_UINT) {
(void) fprintf(stderr,
"***Value %s should be unsigned\n", str);
return 0;
/*
* Flags for forming descriptors.
*/
-#define OPT 0x80 /* this argument is optional, or'd with type */
+/*
+ * Flags for forming descriptors.
+ */
+#define OPT 0x80 /* this argument is optional, or'd with type */
-#define NO 0x0
-#define STR 0x1 /* string argument */
-#define UINT 0x2 /* unsigned integer */
-#define INT 0x3 /* signed integer */
-#define ADD 0x4 /* IP network address */
-#define IP_VERSION 0x5 /* IP address family */
+#define NO 0x0
+#define NTP_STR 0x1 /* string argument */
+#define NTP_UINT 0x2 /* unsigned integer */
+#define NTP_INT 0x3 /* signed integer */
+#define NTP_ADD 0x4 /* IP network address */
+#define IP_VERSION 0x5 /* IP version */
/*
* Arguments are returned in a union
{ "lpassociations", lpassociations, { NO, NO, NO, NO },
{ "", "", "", "" },
"print last obtained list of associations, including client information" },
- { "addvars", addvars, { STR, NO, NO, NO },
+ { "addvars", addvars, { NTP_STR, NO, NO, NO },
{ "name[=value][,...]", "", "", "" },
"add variables to the variable list or change their values" },
- { "rmvars", rmvars, { STR, NO, NO, NO },
+ { "rmvars", rmvars, { NTP_STR, NO, NO, NO },
{ "name[,...]", "", "", "" },
"remove variables from the variable list" },
{ "clearvars", clearvars, { NO, NO, NO, NO },
{ "showvars", showvars, { NO, NO, NO, NO },
{ "", "", "", "" },
"print variables on the variable list" },
- { "readlist", readlist, { OPT|UINT, NO, NO, NO },
+ { "readlist", readlist, { OPT|NTP_UINT, NO, NO, NO },
{ "assocID", "", "", "" },
"read the system or peer variables included in the variable list" },
- { "rl", readlist, { OPT|UINT, NO, NO, NO },
+ { "rl", readlist, { OPT|NTP_UINT, NO, NO, NO },
{ "assocID", "", "", "" },
"read the system or peer variables included in the variable list" },
- { "writelist", writelist, { OPT|UINT, NO, NO, NO },
+ { "writelist", writelist, { OPT|NTP_UINT, NO, NO, NO },
{ "assocID", "", "", "" },
"write the system or peer variables included in the variable list" },
- { "readvar", readvar, { OPT|UINT, OPT|STR, NO, NO },
+ { "readvar", readvar, { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
{ "assocID", "name=value[,...]", "", "" },
"read system or peer variables" },
- { "rv", readvar, { OPT|UINT, OPT|STR, NO, NO },
+ { "rv", readvar, { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
{ "assocID", "name=value[,...]", "", "" },
"read system or peer variables" },
- { "writevar", writevar, { UINT, STR, NO, NO },
+ { "writevar", writevar, { NTP_UINT, NTP_STR, NO, NO },
{ "assocID", "name=value,[...]", "", "" },
"write system or peer variables" },
- { "mreadlist", mreadlist, { UINT, UINT, NO, NO },
+ { "mreadlist", mreadlist, { NTP_UINT, NTP_UINT, NO, NO },
{ "assocID", "assocID", "", "" },
"read the peer variables in the variable list for multiple peers" },
- { "mrl", mreadlist, { UINT, UINT, NO, NO },
+ { "mrl", mreadlist, { NTP_UINT, NTP_UINT, NO, NO },
{ "assocID", "assocID", "", "" },
"read the peer variables in the variable list for multiple peers" },
- { "mreadvar", mreadvar, { UINT, UINT, OPT|STR, NO },
+ { "mreadvar", mreadvar, { NTP_UINT, NTP_UINT, OPT|NTP_STR, NO },
{ "assocID", "assocID", "name=value[,...]", "" },
"read peer variables from multiple peers" },
- { "mrv", mreadvar, { UINT, UINT, OPT|STR, NO },
+ { "mrv", mreadvar, { NTP_UINT, NTP_UINT, OPT|NTP_STR, NO },
{ "assocID", "assocID", "name=value[,...]", "" },
"read peer variables from multiple peers" },
- { "clocklist", clocklist, { OPT|UINT, NO, NO, NO },
+ { "clocklist", clocklist, { OPT|NTP_UINT, NO, NO, NO },
{ "assocID", "", "", "" },
"read the clock variables included in the variable list" },
- { "cl", clocklist, { OPT|UINT, NO, NO, NO },
+ { "cl", clocklist, { OPT|NTP_UINT, NO, NO, NO },
{ "assocID", "", "", "" },
"read the clock variables included in the variable list" },
- { "clockvar", clockvar, { OPT|UINT, OPT|STR, NO, NO },
+ { "clockvar", clockvar, { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
{ "assocID", "name=value[,...]", "", "" },
"read clock variables" },
- { "cv", clockvar, { OPT|UINT, OPT|STR, NO, NO },
+ { "cv", clockvar, { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
{ "assocID", "name=value[,...]", "", "" },
"read clock variables" },
- { "pstatus", pstatus, { UINT, NO, NO, NO },
+ { "pstatus", pstatus, { NTP_UINT, NO, NO, NO },
{ "assocID", "", "", "" },
"print status information returned for a peer" },
{ "peers", peers, { OPT|IP_VERSION, NO, NO, NO },