aboutsummaryrefslogtreecommitdiff
path: root/ntpq/ntpq.h
diff options
context:
space:
mode:
Diffstat (limited to 'ntpq/ntpq.h')
-rw-r--r--ntpq/ntpq.h83
1 files changed, 66 insertions, 17 deletions
diff --git a/ntpq/ntpq.h b/ntpq/ntpq.h
index 77d5ce7f9afb..ec2bcb98d3bb 100644
--- a/ntpq/ntpq.h
+++ b/ntpq/ntpq.h
@@ -1,11 +1,16 @@
/*
* ntpq.h - definitions of interest to ntpq
*/
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "ntp_fp.h"
#include "ntp.h"
-#include "ntp_control.h"
+#include "ntp_stdlib.h"
#include "ntp_string.h"
#include "ntp_malloc.h"
+#include "ntp_assert.h"
+#include "ntp_control.h"
#include "lib_strbuf.h"
/*
@@ -14,8 +19,34 @@
#define MAXARGS 4
/*
- * Flags for forming descriptors.
+ * Limit on packets in a single response. Increasing this value to
+ * 96 will marginally speed "mrulist" operation on lossless networks
+ * but it has been observed to cause loss on WiFi networks and with
+ * an IPv6 go6.net tunnel over UDP. That loss causes the request
+ * row limit to be cut in half, and it grows back very slowly to
+ * ensure forward progress is made and loss isn't triggered too quickly
+ * afterward. While the lossless case gains only marginally with
+ * MAXFRAGS == 96, the lossy case is a lot slower due to the repeated
+ * timeouts. Empirally, MAXFRAGS == 32 avoids most of the routine loss
+ * on both the WiFi and UDP v6 tunnel tests and seems a good compromise.
+ * This suggests some device in the path has a limit of 32 ~512 byte UDP
+ * packets in queue.
+ * Lowering MAXFRAGS may help with particularly lossy networks, but some
+ * ntpq commands may rely on the longtime value of 24 implicitly,
+ * assuming a single multipacket response will be large enough for any
+ * needs. In contrast, the "mrulist" command is implemented as a series
+ * of requests and multipacket responses to each.
*/
+#define MAXFRAGS 32
+
+/*
+ * Error codes for internal use
+ */
+#define ERR_UNSPEC 256
+#define ERR_INCOMPLETE 257
+#define ERR_TIMEOUT 258
+#define ERR_TOOMUCH 259
+
/*
* Flags for forming descriptors.
*/
@@ -27,12 +58,16 @@
#define NTP_INT 0x3 /* signed integer */
#define NTP_ADD 0x4 /* IP network address */
#define IP_VERSION 0x5 /* IP version */
+#define NTP_ADP 0x6 /* IP address and port */
+#define NTP_LFP 0x7 /* NTP timestamp */
+#define NTP_MODE 0x8 /* peer mode */
+#define NTP_2BIT 0x9 /* leap bits */
/*
* Arguments are returned in a union
*/
typedef union {
- char *string;
+ const char *string;
long ival;
u_long uval;
sockaddr_u netnum;
@@ -68,38 +103,52 @@ struct association {
u_short status;
};
-#define MAXASSOC 1024
+/*
+ * mrulist terminal status interval
+ */
+#define MRU_REPORT_SECS 5
/*
- * Structure for translation tables between text format
- * variable indices and text format.
+ * var_format is used to override cooked formatting for selected vars.
*/
-struct ctl_var {
- u_short code;
- u_short fmt;
- const char *text;
+typedef struct var_format_tag {
+ const char * varname;
+ u_short fmt;
+} var_format;
+
+typedef struct chost_tag chost;
+struct chost_tag {
+ const char *name;
+ int fam;
};
+extern chost chosts[];
+
extern int interactive; /* are we prompting? */
extern int old_rv; /* use old rv behavior? --old-rv */
+extern u_int assoc_cache_slots;/* count of allocated array entries */
+extern u_int numassoc; /* number of cached associations */
+extern u_int numhosts;
+extern void grow_assoc_cache(void);
extern void asciize (int, char *, FILE *);
extern int getnetnum (const char *, sockaddr_u *, char *, int);
extern void sortassoc (void);
extern void show_error_msg (int, associd_t);
-extern int doquery (int, associd_t, int, int, char *,
+extern int dogetassoc (FILE *);
+extern int doquery (int, associd_t, int, int, const char *,
u_short *, int *, const char **);
-extern int doqueryex (int, associd_t, int, int, char *,
+extern int doqueryex (int, associd_t, int, int, const char *,
u_short *, int *, const char **, int);
-extern char * nntohost (sockaddr_u *);
-extern char * nntohost_col (sockaddr_u *, size_t, int);
+extern const char * nntohost (sockaddr_u *);
+extern const char * nntohost_col (sockaddr_u *, size_t, int);
+extern const char * nntohostp (sockaddr_u *);
extern int decodets (char *, l_fp *);
extern int decodeuint (char *, u_long *);
extern int nextvar (int *, const char **, char **, char **);
extern int decodetime (char *, l_fp *);
extern void printvars (int, const char *, int, int, int, FILE *);
extern int decodeint (char *, long *);
-extern int findvar (char *, struct ctl_var *, int code);
extern void makeascii (int, const char *, FILE *);
-extern char * trunc_left (const char *, size_t);
-extern char * trunc_right (const char *, size_t);
+extern const char * trunc_left (const char *, size_t);
+extern const char * trunc_right(const char *, size_t);