3 /*****************************************************************************
7 * This is the wrapper library for ntpq, the NTP query utility.
8 * This library reuses the sourcecode from ntpq and exports a number
9 * of useful functions in a library that can be linked against applications
10 * that need to query the status of a running ntpd. The whole
11 * communcation is based on mode 6 packets.
13 * This header file can be used in applications that want to link against
16 ****************************************************************************/
20 /* general purpose buffer size */
21 #define NTPQ_BUFLEN 2048
23 /* max. number of associations */
28 /* general purpose max array size definition */
34 #define LENHOSTNAME 256 /* host name is max. 256 characters long */
37 /* NTP Status codes */
38 #define NTP_STATUS_INVALID 0
39 #define NTP_STATUS_FALSETICKER 1
40 #define NTP_STATUS_EXCESS 2
41 #define NTP_STATUS_OUTLYER 3
42 #define NTP_STATUS_CANDIDATE 4
43 #define NTP_STATUS_SELECTED 5
44 #define NTP_STATUS_SYSPEER 6
45 #define NTP_STATUS_PPSPEER 7
47 /* NTP association type identifier */
48 #define NTP_CLOCKTYPE_UNKNOWN '-'
49 #define NTP_CLOCKTYPE_BROADCAST 'b'
50 #define NTP_CLOCKTYPE_LOCAL 'l'
51 #define NTP_CLOCKTYPE_UNICAST 'u'
52 #define NTP_CLOCKTYPE_MULTICAST 'm'
55 #define PEERVARS CTL_OP_READVAR
56 #define CLOCKVARS CTL_OP_CLOCKVAR
58 /* Variable list struct */
64 /* global variables used for holding snapshots of data */
66 extern char peervars
[];
67 extern int peervarlen
;
68 extern int peervar_assoc
;
69 extern char clockvars
[];
70 extern int clockvarlen
;
71 extern int clockvar_assoc
;
72 extern char sysvars
[];
74 extern char *ntpq_resultbuffer
[];
75 extern struct ntpq_varlist ntpq_varlist
[MAXLIST
];
81 * Prototypes of exported libary functions
86 extern int ntpq_openhost(char *);
87 extern int ntpq_closehost(void);
88 extern int ntpq_queryhost(unsigned short VARSET
, unsigned short association
, char *resultbuf
, int maxlen
);
89 extern int ntpq_getvar( char *resultbuf
, int datalen
, const char *varname
, char *varvalue
, int maxlen
);
90 extern int ntpq_stripquotes ( char *resultbuf
, char *srcbuf
, int datalen
, int maxlen
);
91 extern int ntpq_queryhost_peervars(unsigned short association
, char *resultbuf
, int maxlen
);
92 extern int ntpq_get_peervar( const char *varname
, char *varvalue
, int maxlen
);
93 extern int ntpq_read_sysvars( char *resultbuf
, int maxsize
);
94 extern int ntpq_get_sysvars( void );
95 extern int ntpq_read_associations ( unsigned short resultbuf
[], int max_entries
);
96 extern int ntpq_get_assocs ( void );
97 extern int ntpq_get_assoc_number ( int associd
);
98 extern int ntpq_get_assoc_peervars( int associd
);
99 extern int ntpq_get_assoc_clockvars( int associd
);
100 extern int ntpq_get_assoc_allvars( int associd
);
101 extern int ntpq_get_assoc_clocktype ( int assoc_number
);
102 extern int ntpq_read_assoc_peervars( int associd
, char *resultbuf
, int maxsize
);
103 extern int ntpq_read_assoc_clockvars( int associd
, char *resultbuf
, int maxsize
);
106 /* in libntpq_subs.c */
107 #ifndef _LIBNTPQSUBSC
108 extern int ntpq_dogetassoc(void);
109 extern char ntpq_decodeaddrtype(sockaddr_u
*sock
);
110 extern int ntpq_doquerylist(struct ntpq_varlist
*, int , int , int , u_short
*, int *, char **datap
);