12b15cb3dSCy Schubert /*****************************************************************************
22b15cb3dSCy Schubert *
32b15cb3dSCy Schubert * libntpq_subs.c
42b15cb3dSCy Schubert *
52b15cb3dSCy Schubert * This is the second part of the wrapper library for ntpq, the NTP query utility.
62b15cb3dSCy Schubert * This library reuses the sourcecode from ntpq and exports a number
72b15cb3dSCy Schubert * of useful functions in a library that can be linked against applications
82b15cb3dSCy Schubert * that need to query the status of a running ntpd. The whole
92b15cb3dSCy Schubert * communcation is based on mode 6 packets.
102b15cb3dSCy Schubert *
112b15cb3dSCy Schubert * This source file exports the (private) functions from ntpq-subs.c
122b15cb3dSCy Schubert *
132b15cb3dSCy Schubert ****************************************************************************/
142b15cb3dSCy Schubert
152b15cb3dSCy Schubert
162b15cb3dSCy Schubert #include "ntpq-subs.c"
172b15cb3dSCy Schubert #include "libntpq.h"
182b15cb3dSCy Schubert
192b15cb3dSCy Schubert
ntpq_dogetassoc(void)202b15cb3dSCy Schubert int ntpq_dogetassoc(void)
212b15cb3dSCy Schubert {
222b15cb3dSCy Schubert
232b15cb3dSCy Schubert if (dogetassoc(NULL))
242b15cb3dSCy Schubert return numassoc;
252b15cb3dSCy Schubert else
262b15cb3dSCy Schubert return 0;
272b15cb3dSCy Schubert }
282b15cb3dSCy Schubert
292b15cb3dSCy Schubert /* the following functions are required internally by a number of libntpq functions
302b15cb3dSCy Schubert * and since they are defined as static in ntpq-subs.c, they need to be exported here
312b15cb3dSCy Schubert */
322b15cb3dSCy Schubert
ntpq_decodeaddrtype(sockaddr_u * sock)332b15cb3dSCy Schubert char ntpq_decodeaddrtype(sockaddr_u *sock)
342b15cb3dSCy Schubert {
352b15cb3dSCy Schubert return decodeaddrtype(sock);
362b15cb3dSCy Schubert }
372b15cb3dSCy Schubert
382b15cb3dSCy Schubert int
ntpq_doquerylist(struct ntpq_varlist * vlist,int op,associd_t associd,int auth,u_short * rstatus,size_t * dsize,const char ** datap)392b15cb3dSCy Schubert ntpq_doquerylist(
402b15cb3dSCy Schubert struct ntpq_varlist *vlist,
412b15cb3dSCy Schubert int op,
422b15cb3dSCy Schubert associd_t associd,
432b15cb3dSCy Schubert int auth,
442b15cb3dSCy Schubert u_short *rstatus,
45*3311ff84SXin LI size_t *dsize,
462b15cb3dSCy Schubert const char **datap
472b15cb3dSCy Schubert )
482b15cb3dSCy Schubert {
492b15cb3dSCy Schubert return doquerylist((struct varlist *)vlist, op, associd, auth,
502b15cb3dSCy Schubert rstatus, dsize, datap);
512b15cb3dSCy Schubert }
522b15cb3dSCy Schubert
53