1 /* 2 * ntpq.h - definitions of interest to ntpq 3 */ 4 #include "ntp_fp.h" 5 #include "ntp.h" 6 #include "ntp_control.h" 7 #include "ntp_string.h" 8 #include "ntp_malloc.h" 9 10 /* 11 * Maximum number of arguments 12 */ 13 #define MAXARGS 4 14 15 /* 16 * Flags for forming descriptors. 17 */ 18 #define OPT 0x80 /* this argument is optional, or'd with type */ 19 20 #define NO 0x0 21 #define STR 0x1 /* string argument */ 22 #define UINT 0x2 /* unsigned integer */ 23 #define INT 0x3 /* signed integer */ 24 #define ADD 0x4 /* IP network address */ 25 #define IP_VERSION 0x5 /* IP address family */ 26 27 /* 28 * Arguments are returned in a union 29 */ 30 typedef union { 31 char *string; 32 long ival; 33 u_long uval; 34 struct sockaddr_storage netnum; 35 } arg_v; 36 37 /* 38 * Structure for passing parsed command line 39 */ 40 struct parse { 41 const char *keyword; 42 arg_v argval[MAXARGS]; 43 int nargs; 44 }; 45 46 /* 47 * ntpdc includes a command parser which could charitably be called 48 * crude. The following structure is used to define the command 49 * syntax. 50 */ 51 struct xcmd { 52 const char *keyword; /* command key word */ 53 void (*handler) P((struct parse *, FILE *)); /* command handler */ 54 u_char arg[MAXARGS]; /* descriptors for arguments */ 55 const char *desc[MAXARGS]; /* descriptions for arguments */ 56 const char *comment; 57 }; 58 59 /* 60 * Structure to hold association data 61 */ 62 struct association { 63 u_short assid; 64 u_short status; 65 }; 66 67 #define MAXASSOC 1024 68 69 /* 70 * Structure for translation tables between text format 71 * variable indices and text format. 72 */ 73 struct ctl_var { 74 u_short code; 75 u_short fmt; 76 const char *text; 77 }; 78 79 extern void asciize P((int, char *, FILE *)); 80 extern int getnetnum P((const char *, struct sockaddr_storage *, char *, int)); 81 extern void sortassoc P((void)); 82 extern int doquery P((int, int, int, int, char *, u_short *, int *, char **)); 83 extern char * nntohost P((struct sockaddr_storage *)); 84 extern int decodets P((char *, l_fp *)); 85 extern int decodeuint P((char *, u_long *)); 86 extern int nextvar P((int *, char **, char **, char **)); 87 extern int decodetime P((char *, l_fp *)); 88 extern void printvars P((int, char *, int, int, FILE *)); 89 extern int decodeint P((char *, long *)); 90 extern int findvar P((char *, struct ctl_var *)); 91