summaryrefslogtreecommitdiffstats
path: root/usr.sbin/xntpd/ntpq
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1994-09-29 23:04:24 +0000
committerwollman <wollman@FreeBSD.org>1994-09-29 23:04:24 +0000
commit96f7e86b724c797f2b44beaaf956cf14550e57df (patch)
tree65fc9d6eb6e84f9e629426ab09186ab1373f9bcb /usr.sbin/xntpd/ntpq
parent1185c9048d38483a3f99f3065590713d8bcda610 (diff)
downloadFreeBSD-src-96f7e86b724c797f2b44beaaf956cf14550e57df.zip
FreeBSD-src-96f7e86b724c797f2b44beaaf956cf14550e57df.tar.gz
xntp 3.4e from Dave Mills @ UDel
Diffstat (limited to 'usr.sbin/xntpd/ntpq')
-rw-r--r--usr.sbin/xntpd/ntpq/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq.c154
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq.h16
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq_ops.c87
4 files changed, 118 insertions, 141 deletions
diff --git a/usr.sbin/xntpd/ntpq/Makefile.tmpl b/usr.sbin/xntpd/ntpq/Makefile.tmpl
index e802861..76a09ad 100644
--- a/usr.sbin/xntpd/ntpq/Makefile.tmpl
+++ b/usr.sbin/xntpd/ntpq/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# Makefile.tmpl,v 3.1 1993/07/06 01:09:28 jbj Exp
+# Makefile.tmpl
#
PROGRAM= ntpq
#
diff --git a/usr.sbin/xntpd/ntpq/ntpq.c b/usr.sbin/xntpd/ntpq/ntpq.c
index 73c2a35..441b283 100644
--- a/usr.sbin/xntpd/ntpq/ntpq.c
+++ b/usr.sbin/xntpd/ntpq/ntpq.c
@@ -1,4 +1,4 @@
-/* ntpq.c,v 3.1 1993/07/06 01:09:29 jbj Exp
+/*
* ntpq - query an NTP server using mode 6 commands
*/
#include <stdio.h>
@@ -27,7 +27,7 @@ char *prompt = "ntpq> "; /* prompt to ask him about */
/*
* Keyid used for authenticated requests. Obtained on the fly.
*/
-U_LONG info_auth_keyid = -1;
+u_long info_auth_keyid = -1;
/*
* Type of key md5 or des
@@ -88,7 +88,7 @@ struct ctl_var sys_var[] = {
{ CS_LEAP, LP, "leap" }, /* 1 */
{ CS_STRATUM, UI, "stratum" }, /* 2 */
{ CS_PRECISION, IN, "precision" }, /* 3 */
- { CS_ROOTDELAY, FU, "rootdelay" }, /* 4 */
+ { CS_ROOTDELAY, FS, "rootdelay" }, /* 4 */
{ CS_ROOTDISPERSION, FU, "rootdispersion" }, /* 5 */
{ CS_REFID, RF, "refid" }, /* 6 */
{ CS_REFTIME, TS, "reftime" }, /* 7 */
@@ -96,7 +96,7 @@ struct ctl_var sys_var[] = {
{ CS_PEERID, UI, "peer" }, /* 9 */
{ CS_OFFSET, FL, "phase" }, /* 10 */
{ CS_DRIFT, FS, "freq" }, /* 11 */
- { CS_COMPLIANCE, UI, "compliance" }, /* 12 */
+ { CS_COMPLIANCE, FU, "error" }, /* 12 */
{ CS_CLOCK, TS, "clock" }, /* 13 */
{ CS_LEAPIND, LP, "leapindicator" }, /* 14 */
{ CS_LEAPWARNING, LP, "leapwarning" }, /* 15 */
@@ -149,7 +149,7 @@ struct ctl_var peer_var[] = {
{ CP_FLASH, TST, "flash"}, /* 34 */
{ CP_DISP, AR, "disp" }, /* 35 */
/*
- * These are duplicate entires so that we can
+ * These are duplicate entries so that we can
* process deviant version of the xntp protocal.
*/
{ CP_SRCADR, HA, "peeraddr" }, /* 4 */
@@ -173,8 +173,8 @@ struct ctl_var clock_var[] = {
{ CC_BADDATA, UI, "baddata" }, /* 6 */
{ CC_FUDGETIME1, FL, "fudgetime1" }, /* 7 */
{ CC_FUDGETIME2, FL, "fudgetime2" }, /* 8 */
- { CC_FUDGEVAL1, IN, "fudgeval1" }, /* 9 */
- { CC_FUDGEVAL2, IN, "fudgeval2" }, /* 10 */
+ { CC_FUDGEVAL1, UI, "stratum" }, /* 9 */
+ { CC_FUDGEVAL2, RF, "refid" }, /* 10 */
{ CC_FLAGS, UI, "flags" }, /* 11 */
{ CC_DEVICE, ST, "device" }, /* 12 */
{ 0, EOV, "" }
@@ -308,11 +308,6 @@ static void tokenize P((char *, char **, int *));
static int findcmd P((char *, struct xcmd *, struct xcmd *, struct xcmd **));
static int getarg P((char *, int, arg_v *));
static int rtdatetolfp P((char *, l_fp *));
-
-#ifdef UNUSED
-static int decodereach P((char *, U_LONG *));
-#endif /* UNUSED */
-
static int decodearr P((char *, int *, l_fp *));
static char * getcode P((int, struct codestring *));
static void help P((struct parse *, FILE *));
@@ -339,7 +334,7 @@ static void authenticate P((struct parse *, FILE *));
static void ntpversion P((struct parse *, FILE *));
static void warning P((char *, char *, char *));
static void error P((char *, char *, char *));
-static U_LONG getkeyid P((char *));
+static u_long getkeyid P((char *));
static void atoascii P((int, char *, char *));
static void makeascii P((int, char *, FILE *));
static char * getevents P((int));
@@ -424,7 +419,7 @@ struct xcmd builtins[] = {
#define DEFSTIMEOUT (2) /* 2 second time out after first */
#define DEFDELAY 0x51EB852 /* 20 milliseconds, l_fp fraction */
#define DEFHOST "localhost" /* default host name */
-#define LENHOSTNAME 256 /* host name is 256 characters LONG */
+#define LENHOSTNAME 256 /* host name is 256 characters long */
#define MAXCMDS 100 /* maximum commands on cmd line */
#define MAXHOSTS 100 /* maximum hosts on cmd line */
#define MAXLINE 512 /* maximum line length */
@@ -454,12 +449,12 @@ struct servent *server_entry = NULL; /* server entry for ntp */
u_short sequence;
/*
- * Holds data returned from queries. Declare buffer LONG to be sure of
+ * Holds data returned from queries. Declare buffer long to be sure of
* alignment.
*/
#define MAXFRAGS 24 /* maximum number of fragments */
#define DATASIZE (MAXFRAGS*480) /* maximum amount of data */
-LONG pktdata[DATASIZE/sizeof(LONG)];
+long pktdata[DATASIZE/sizeof(long)];
/*
* Holds association data for use with the &n operator.
@@ -597,7 +592,7 @@ static int
openhost(hname)
char *hname;
{
- U_LONG netnum;
+ u_long netnum;
char temphost[LENHOSTNAME];
if (server_entry == NULL) {
@@ -712,9 +707,9 @@ getresponse(opcode, associd, rstatus, rsize, rdata, timeo)
/*
* This is pretty tricky. We may get between 1 and MAXFRAG packets
* back in response to the request. We peel the data out of
- * each packet and collect it in one LONG block. When the last
+ * each packet and collect it in one long block. When the last
* packet in the sequence is received we'll know how much data we
- * should have had. Note we use one LONG time out, should reconsider.
+ * should have had. Note we use one long time out, should reconsider.
*/
*rsize = 0;
if (rstatus)
@@ -879,8 +874,8 @@ again:
if (debug >= 3) {
int shouldbesize;
- U_LONG key;
- U_LONG *lpkt;
+ u_long key;
+ u_long *lpkt;
int maclen;
/*
@@ -898,15 +893,15 @@ again:
printf(
"Packet shows signs of authentication (total %d, data %d, mac %d)\n",
n, shouldbesize, maclen);
- lpkt = (U_LONG *)&rpkt;
+ lpkt = (u_long *)&rpkt;
printf("%08lx %08lx %08lx %08lx %08lx %08lx\n",
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) - 3]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) - 2]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) - 1]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG)]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) + 1]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) + 2]));
- key = ntohl(lpkt[(n - maclen) / sizeof(U_LONG)]);
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 3]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 2]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 1]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long)]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) + 1]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) + 2]));
+ key = ntohl(lpkt[(n - maclen) / sizeof(u_long)]);
printf("Authenticated with keyid %lu\n", key);
if (key != 0 && key != info_auth_keyid) {
printf("We don't know that key\n");
@@ -1067,7 +1062,7 @@ sendrequest(opcode, associd, auth, qsize, qdata)
if (qsize > 0) {
memmove((char *)qpkt.data, qdata, qsize);
pktsize = qsize + CTL_HEADER_LEN;
- while (pktsize & (sizeof(U_LONG)-1)) {
+ while (pktsize & (sizeof(u_long) - 1)) {
qpkt.data[qsize++] = 0;
pktsize++;
}
@@ -1118,7 +1113,7 @@ sendrequest(opcode, associd, auth, qsize, qdata)
* cp currently points. Cp should be aligned
* properly. Then do the encryptions.
*/
- *(U_LONG *)(&qpkt.data[qsize]) = htonl(info_auth_keyid);
+ *(u_long *)(&qpkt.data[qsize]) = htonl(info_auth_keyid);
maclen = authencrypt(info_auth_keyid, (U_LONG *)&qpkt,
pktsize);
return sendpkt((char *)&qpkt, pktsize + maclen);
@@ -1542,21 +1537,22 @@ getarg(str, code, argp)
int
getnetnum(host, num, fullhost)
char *host;
- U_LONG *num;
+ u_long *num;
char *fullhost;
{
struct hostent *hp;
if (decodenetnum(host, num)) {
if (fullhost != 0) {
- (void) sprintf(fullhost,
- "%d.%d.%d.%d", ((htonl(*num)>>24)&0xff),
- ((htonl(*num)>>16)&0xff), ((htonl(*num)>>8)&0xff),
- (htonl(*num)&0xff));
+ (void) sprintf(fullhost, "%lu.%lu.%lu.%lu",
+ (u_long)((htonl(*num) >> 24) & 0xff),
+ (u_long)((htonl(*num) >> 16) & 0xff),
+ (u_long)((htonl(*num) >> 8) & 0xff),
+ (u_long)(htonl(*num) & 0xff));
}
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- memmove((char *)num, hp->h_addr, sizeof(U_LONG));
+ memmove((char *)num, hp->h_addr, sizeof(u_long));
if (fullhost != 0)
(void) strcpy(fullhost, hp->h_name);
return 1;
@@ -1573,7 +1569,7 @@ getnetnum(host, num, fullhost)
*/
char *
nntohost(netnum)
- U_LONG netnum;
+ u_long netnum;
{
if (!showhostnames)
return numtoa(netnum);
@@ -1613,7 +1609,7 @@ rtdatetolfp(str, lfp)
/*
* Catch special case
*/
- lfp->l_ui = lfp->l_uf = 0;
+ L_CLR(lfp);
return 1;
}
return 0;
@@ -1654,7 +1650,7 @@ rtdatetolfp(str, lfp)
* Catch special case. If cal.year == 0 this is a zero timestamp.
*/
if (cal.year == 0) {
- lfp->l_ui = lfp->l_uf = 0;
+ L_CLR(lfp);
return 1;
}
@@ -1748,49 +1744,18 @@ decodetime(str, lfp)
}
-#ifdef UNUSED
-/*
- * decodereach - decode a (possibly octal or hex, damn fuzzballs) reachability
- */
-static int
-decodereach(str, uval)
- char *str;
- U_LONG *uval;
-{
- U_LONG u;
-
- if (*str == '0') {
- /*
- * Could be octal or hex
- */
- if (*(str+1) == 'x' || *(str+1) == 'X')
- return hextoint(str+2, uval);
- return octtoint(str, uval);
- }
-
- if (!atouint(str, &u))
- return 0;
-
- if (u > 255)
- return octtoint(str, uval);
- *uval = u;
- return 1;
-}
-#endif /* UNUSED */
-
-
/*
* decodeint - decode an integer
*/
int
decodeint(str, val)
char *str;
- LONG *val;
+ long *val;
{
if (*str == '0') {
if (*(str+1) == 'x' || *(str+1) == 'X')
- return hextoint(str+2, (U_LONG *)val);
- return octtoint(str, (U_LONG *)val);
+ return hextoint(str+2, (u_long *)&val);
+ return octtoint(str, (u_long *)&val);
}
return atoint(str, val);
}
@@ -1802,7 +1767,7 @@ decodeint(str, val)
int
decodeuint(str, val)
char *str;
- U_LONG *val;
+ u_long *val;
{
if (*str == '0') {
if (*(str+1) == 'x' || *(str+1) == 'X')
@@ -2017,18 +1982,18 @@ delay(pcmd, fp)
FILE *fp;
{
int isneg;
- U_LONG val;
+ u_long val;
if (pcmd->nargs == 0) {
val = delay_time.l_ui * 1000 + delay_time.l_uf / 4294967;
- (void) fprintf(fp, "delay %d ms\n", val);
+ (void) fprintf(fp, "delay %lu ms\n", val);
} else {
if (pcmd->argval[0].ival < 0) {
isneg = 1;
- val = (U_LONG)(-pcmd->argval[0].ival);
+ val = (u_long)(-pcmd->argval[0].ival);
} else {
isneg = 0;
- val = (U_LONG)pcmd->argval[0].ival;
+ val = (u_long)pcmd->argval[0].ival;
}
delay_time.l_ui = val / 1000;
@@ -2092,7 +2057,7 @@ keyid(pcmd, fp)
if (info_auth_keyid == -1)
(void) fprintf(fp, "no keyid defined\n");
else
- (void) fprintf(fp, "keyid is %u\n", info_auth_keyid);
+ (void) fprintf(fp, "keyid is %lu\n", info_auth_keyid);
} else {
info_auth_keyid = pcmd->argval[0].uval;
}
@@ -2344,7 +2309,7 @@ error(fmt, st1, st2)
/*
* getkeyid - prompt the user for a keyid to use
*/
-static U_LONG
+static u_long
getkeyid(prompt)
char *prompt;
{
@@ -2368,7 +2333,7 @@ char *prompt;
if (strcmp(pbuf, "0") == 0)
return 0;
- return (U_LONG) atoi(pbuf);
+ return (u_long) atoi(pbuf);
}
@@ -2515,7 +2480,9 @@ statustoa(type, st)
case TYPE_SYS:
(void)strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes));
(void)strcat(cb, ", ");
- (void)strcat(cb, getcode(CTL_SYS_SOURCE(st), sync_codes));
+ (void)strcat(cb, getcode(CTL_SYS_SOURCE(st) & ~CTL_SST_TS_PPS, sync_codes));
+ if (CTL_SYS_SOURCE(st) & CTL_SST_TS_PPS)
+ (void)strcat(cb, "/PPS");
(void)strcat(cb, ", ");
(void)strcat(cb, getevents(CTL_SYS_NEVNT(st)));
(void)strcat(cb, ", ");
@@ -2853,7 +2820,7 @@ outputarr(fp, name, narr, lfp)
static char *
tstflags(val)
- U_LONG val;
+ u_long val;
{
register char *cb, *s;
register int i;
@@ -2865,7 +2832,7 @@ tstflags(val)
if (++nextcb >= NUMCB)
nextcb = 0;
- sprintf(cb, "0x%x", val);
+ sprintf(cb, "0x%lx", val);
cb += strlen(cb);
if (val <= ((1<<8)-1)) {
if (!val) {
@@ -2909,8 +2876,9 @@ cookedprint(datatype, length, data, status, fp)
int fmt;
struct ctl_var *varlist;
l_fp lfp;
- LONG ival;
- U_LONG uval;
+ long ival;
+ u_long hval;
+ u_long uval;
l_fp lfparr[8];
int narr;
@@ -2986,12 +2954,12 @@ cookedprint(datatype, length, data, status, fp)
case HA:
case NA:
- if (!decodenetnum(value, &uval))
+ if (!decodenetnum(value, &hval))
output_raw = '?';
else if (fmt == HA)
- output(fp, name, nntohost(uval));
+ output(fp, name, nntohost(hval));
else
- output(fp, name, numtoa(uval));
+ output(fp, name, numtoa(hval));
break;
case ST:
@@ -2999,8 +2967,8 @@ cookedprint(datatype, length, data, status, fp)
break;
case RF:
- if (decodenetnum(value, &uval))
- output(fp, name, nntohost(uval));
+ if (decodenetnum(value, &hval))
+ output(fp, name, nntohost(hval));
else if ((int)strlen(value) <= 4)
output(fp, name, value);
else
@@ -3028,7 +2996,7 @@ cookedprint(datatype, length, data, status, fp)
else {
char b[10];
- (void) sprintf(b, "%03o", uval);
+ (void) sprintf(b, "%03lo", uval);
output(fp, name, b);
}
break;
diff --git a/usr.sbin/xntpd/ntpq/ntpq.h b/usr.sbin/xntpd/ntpq/ntpq.h
index edfc9b5..c233b24 100644
--- a/usr.sbin/xntpd/ntpq/ntpq.h
+++ b/usr.sbin/xntpd/ntpq/ntpq.h
@@ -1,4 +1,4 @@
-/* ntpq.h,v 3.1 1993/07/06 01:09:30 jbj Exp
+/*
* ntpq.h - definitions of interest to ntpq
*/
#include "ntp_fp.h"
@@ -28,9 +28,9 @@
*/
typedef union {
char *string;
- LONG ival;
- U_LONG uval;
- U_LONG netnum;
+ long ival;
+ u_long uval;
+ u_long netnum;
} arg_v;
/*
@@ -84,14 +84,14 @@ struct ctl_var {
};
extern void asciize P((int, char *, FILE *));
-extern int getnetnum P((char *, U_LONG *, char *));
+extern int getnetnum P((char *, u_long *, char *));
extern void sortassoc P((void));
extern int doquery P((int, int, int, int, char *, u_short *, int *, char **));
-extern char * nntohost P((U_LONG));
+extern char * nntohost P((u_long));
extern int decodets P((char *, l_fp *));
-extern int decodeuint P((char *, U_LONG *));
+extern int decodeuint P((char *, u_long *));
extern int nextvar P((int *, char **, char **, char **));
extern int decodetime P((char *, l_fp *));
extern void printvars P((int, char *, int, int, FILE *));
-extern int decodeint P((char *, LONG *));
+extern int decodeint P((char *, long *));
extern int findvar P((char *, struct ctl_var *));
diff --git a/usr.sbin/xntpd/ntpq/ntpq_ops.c b/usr.sbin/xntpd/ntpq/ntpq_ops.c
index 395a9ec..8bab73d 100644
--- a/usr.sbin/xntpd/ntpq/ntpq_ops.c
+++ b/usr.sbin/xntpd/ntpq/ntpq_ops.c
@@ -1,4 +1,4 @@
-/* ntpq_ops.c,v 3.1 1993/07/06 01:09:32 jbj Exp
+/*
* ntpdc_ops.c - subroutines which are called to perform operations by xntpdc
*/
#include <stdio.h>
@@ -18,7 +18,7 @@ int maxhostlen;
/*
* Declarations for command handlers in here
*/
-static int checkassocid P((U_LONG));
+static int checkassocid P((u_long));
static char * strsave P((char *));
static struct varlist *findlistvar P((struct varlist *, char *));
static void doaddvlist P((struct varlist *, char *));
@@ -38,7 +38,7 @@ static void readvar P((struct parse *, FILE *));
static void writevar P((struct parse *, FILE *));
static void clocklist P((struct parse *, FILE *));
static void clockvar P((struct parse *, FILE *));
-static int findassidrange P((U_LONG, U_LONG, int *, int *));
+static int findassidrange P((u_long, u_long, int *, int *));
static void mreadlist P((struct parse *, FILE *));
static void mreadvar P((struct parse *, FILE *));
static int dogetassoc P((FILE *));
@@ -159,7 +159,7 @@ struct xcmd opcmds[] = {
* Variable list data space
*/
#define MAXLIST 64 /* maximum number of variables in list */
-#define LENHOSTNAME 256 /* host name is 256 characters LONG */
+#define LENHOSTNAME 256 /* host name is 256 characters long */
/*
* Old CTL_PST defines for version 2.
*/
@@ -205,7 +205,7 @@ extern u_char pktversion;
*/
static int
checkassocid(value)
- U_LONG value;
+ u_long value;
{
if (value == 0 || value >= 65536) {
(void) fprintf(stderr, "***Invalid association ID specified\n");
@@ -706,8 +706,8 @@ clockvar(pcmd, fp)
*/
static int
findassidrange(assid1, assid2, from, to)
- U_LONG assid1;
- U_LONG assid2;
+ u_long assid1;
+ u_long assid2;
int *from;
int *to;
{
@@ -716,13 +716,13 @@ findassidrange(assid1, assid2, from, to)
if (assid1 == 0 || assid1 > 65535) {
(void) fprintf(stderr,
- "***Invalid association ID %lu specified\n", assid1);
+ "***Invalid association ID %lu specified\n", (u_long)assid1);
return 0;
}
if (assid2 == 0 || assid2 > 65535) {
(void) fprintf(stderr,
- "***Invalid association ID %lu specified\n", assid2);
+ "***Invalid association ID %lu specified\n", (u_long)assid2);
return 0;
}
@@ -743,7 +743,7 @@ findassidrange(assid1, assid2, from, to)
if (f == -1 || t == -1) {
(void) fprintf(stderr,
"***Association ID %lu not found in list\n",
- (f == -1) ? assid1 : assid2);
+ (f == -1) ? (u_long)assid1 : (u_long)assid2);
return 0;
}
@@ -876,7 +876,7 @@ printassoc(showall, fp)
int i;
u_char statval;
int event;
- U_LONG event_count;
+ u_long event_count;
char *conf;
char *reach;
char *auth;
@@ -1028,7 +1028,7 @@ associations(pcmd, fp)
/*
- * lassociations - get, record and print a LONG list of associations
+ * lassociations - get, record and print a long list of associations
*/
/*ARGSUSED*/
static void
@@ -1055,7 +1055,7 @@ passociations(pcmd, fp)
/*
- * lpassociations - print the LONG association list
+ * lpassociations - print the long association list
*/
/*ARGSUSED*/
static void
@@ -1146,7 +1146,7 @@ fixup(width, str)
/*
- * when - print how LONG its been since his last packet arrived
+ * when - print how long its been since his last packet arrived
*/
static char *
when(ts, rec, reftime)
@@ -1154,7 +1154,7 @@ when(ts, rec, reftime)
l_fp *rec;
l_fp *reftime;
{
- LONG diff;
+ long diff;
l_fp *lasttime;
static char buf[20];
@@ -1165,7 +1165,7 @@ when(ts, rec, reftime)
else
return "-";
- diff = (LONG)(ts->l_ui - lasttime->l_ui);
+ diff = (long)(ts->l_ui - lasttime->l_ui);
if (diff <= 0) {
/*
* Time warp?
@@ -1174,24 +1174,24 @@ when(ts, rec, reftime)
}
if (diff <= 2048) {
- (void) sprintf(buf, "%d", diff);
+ (void) sprintf(buf, "%ld", (long int)diff);
return buf;
}
diff = (diff + 29) / 60;
if (diff <= 300) {
- (void) sprintf(buf, "%dm", diff);
+ (void) sprintf(buf, "%ldm", (long int)diff);
return buf;
}
diff = (diff + 29) / 60;
if (diff <= 96) {
- (void) sprintf(buf, "%dh", diff);
+ (void) sprintf(buf, "%ldh", (long int)diff);
return buf;
}
diff = (diff + 11) / 24;
- (void) sprintf(buf, "%dd", diff);
+ (void) sprintf(buf, "%ldd", (long int)diff);
return buf;
}
@@ -1264,14 +1264,14 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
int i;
int c;
- U_LONG srcadr;
- U_LONG dstadr;
- U_LONG srcport;
+ u_long srcadr;
+ u_long dstadr;
+ u_long srcport;
char *dstadr_refid = "0.0.0.0";
- U_LONG stratum;
- LONG ppoll;
- LONG hpoll;
- U_LONG reach;
+ u_long stratum;
+ long ppoll;
+ long hpoll;
+ u_long reach;
l_fp estdelay;
l_fp estoffset;
l_fp estdisp;
@@ -1279,7 +1279,8 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
l_fp reftime;
l_fp ts;
u_char havevar[MAXHAVE];
- U_LONG poll;
+ u_long poll;
+ char type = '?';
char refid_string[10];
extern struct ctl_var peer_var[];
@@ -1287,6 +1288,7 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
gettstamp(&ts);
while (nextvar(&datalen, &data, &name, &value)) {
+ u_long dummy;
i = findvar(name, peer_var);
if (i == 0)
continue; /* don't know this one */
@@ -1296,6 +1298,14 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
havevar[HAVE_SRCADR] = 1;
break;
case CP_DSTADR:
+ if (decodenetnum(value, &dummy)) {
+ dummy = ntohl(dummy);
+ type = ((dummy&0xf0000000)==0xe0000000) ? 'm' :
+ ((dummy&0x000000ff)==0x000000ff) ? 'b' :
+ ((dummy&0xffffffff)==0x7f000001) ? 'l' :
+ ((dummy&0xffffffe0)==0x00000000) ? '-' :
+ 'u';
+ }
if (pvl == opeervarlist) {
if (decodenetnum(value, &dstadr)) {
havevar[HAVE_DSTADR] = 1;
@@ -1370,7 +1380,7 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
case CP_REFTIME:
havevar[HAVE_REFTIME] = 1;
if (!decodets(value, &reftime))
- reftime.l_ui = reftime.l_uf = 0;
+ L_CLR(&reftime);
break;
default:
break;
@@ -1408,11 +1418,10 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
if (numhosts > 1)
(void) fprintf(fp, "%-*s ", maxhostlen, currenthost);
(void) fprintf(fp,
- "%c%-15.15s %-15.15s %2d %4.4s %4d %3o %7.7s %7.7s %7.7s\n",
- c, nntohost(srcadr), dstadr_refid, stratum,
- when(&ts, &rec, &reftime),
- poll, reach, fixup(7, lfptoms(&estdelay, 2)),
- fixup(7, lfptoms(&estoffset, 2)),
+ "%c%-15.15s %-15.15s %2ld %c %4.4s %4ld %3lo %7.7s %8.7s %7.7s\n",
+ c, nntohost(srcadr), dstadr_refid, stratum, type,
+ when(&ts, &rec, &reftime), poll, reach,
+ fixup(7, lfptoms(&estdelay, 2)), fixup(8, lfptoms(&estoffset, 3)),
fixup(7, lfptoms(&estdisp, 2)));
return 1;
}
@@ -1484,7 +1493,7 @@ dopeers(showall, fp)
{
register int i;
char fullname[LENHOSTNAME];
- U_LONG netnum;
+ u_long netnum;
if (!dogetassoc(fp))
@@ -1498,12 +1507,12 @@ dopeers(showall, fp)
if (numhosts > 1)
(void) fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "host");
(void) fprintf(fp,
-" remote refid st when poll reach delay offset disp\n");
+" remote refid st t when poll reach delay offset disp\n");
if (numhosts > 1)
for (i = 0; i <= maxhostlen; ++i)
(void) fprintf(fp, "=");
(void) fprintf(fp,
-"===========================================================================\n");
+"==============================================================================\n");
for (i = 0; i < numassoc; i++) {
if (!showall &&
@@ -1558,9 +1567,9 @@ doopeers(showall, fp)
return;
(void) fprintf(fp,
-" remote local st when poll reach delay offset disp\n");
+" remote local st t when poll reach delay offset disp\n");
(void) fprintf(fp,
-"=========================================================================\n");
+"===========================================================================\n");
for (i = 0; i < numassoc; i++) {
if (!showall &&
OpenPOWER on IntegriCloud