154359Sroberto/*
254359Sroberto * ntpq.h - definitions of interest to ntpq
354359Sroberto */
454359Sroberto#include "ntp_fp.h"
554359Sroberto#include "ntp.h"
654359Sroberto#include "ntp_control.h"
754359Sroberto#include "ntp_string.h"
854359Sroberto#include "ntp_malloc.h"
954359Sroberto
1054359Sroberto/*
1154359Sroberto * Maximum number of arguments
1254359Sroberto */
1354359Sroberto#define	MAXARGS	4
1454359Sroberto
1554359Sroberto/*
1654359Sroberto * Flags for forming descriptors.
1754359Sroberto */
18182007Sroberto/*
19182007Sroberto * Flags for forming descriptors.
20182007Sroberto */
21182007Sroberto#define	OPT		0x80	/* this argument is optional, or'd with type */
2254359Sroberto
23182007Sroberto#define	NO		0x0
24182007Sroberto#define	NTP_STR		0x1	/* string argument */
25182007Sroberto#define	NTP_UINT	0x2	/* unsigned integer */
26182007Sroberto#define	NTP_INT		0x3	/* signed integer */
27182007Sroberto#define	NTP_ADD		0x4	/* IP network address */
28182007Sroberto#define IP_VERSION	0x5	/* IP version */
2954359Sroberto
3054359Sroberto/*
3154359Sroberto * Arguments are returned in a union
3254359Sroberto */
3354359Srobertotypedef union {
3454359Sroberto	char *string;
3554359Sroberto	long ival;
3654359Sroberto	u_long uval;
37132451Sroberto	struct sockaddr_storage netnum;
3854359Sroberto} arg_v;
3954359Sroberto
4054359Sroberto/*
4154359Sroberto * Structure for passing parsed command line
4254359Sroberto */
4354359Srobertostruct parse {
4454359Sroberto	const char *keyword;
4554359Sroberto	arg_v argval[MAXARGS];
4654359Sroberto	int nargs;
4754359Sroberto};
4854359Sroberto
4954359Sroberto/*
5054359Sroberto * ntpdc includes a command parser which could charitably be called
5154359Sroberto * crude.  The following structure is used to define the command
5254359Sroberto * syntax.
5354359Sroberto */
5454359Srobertostruct xcmd {
5554359Sroberto  const char *keyword;		/* command key word */
5654359Sroberto	void (*handler)	P((struct parse *, FILE *));	/* command handler */
5754359Sroberto	u_char arg[MAXARGS];	/* descriptors for arguments */
5854359Sroberto  const char *desc[MAXARGS];	/* descriptions for arguments */
5954359Sroberto  const char *comment;
6054359Sroberto};
6154359Sroberto
6254359Sroberto/*
6354359Sroberto * Structure to hold association data
6454359Sroberto */
6554359Srobertostruct association {
6654359Sroberto	u_short assid;
6754359Sroberto	u_short status;
6854359Sroberto};
6954359Sroberto
7054359Sroberto#define	MAXASSOC	1024
7154359Sroberto
7254359Sroberto/*
7354359Sroberto * Structure for translation tables between text format
7454359Sroberto * variable indices and text format.
7554359Sroberto */
7654359Srobertostruct ctl_var {
7754359Sroberto	u_short code;
7854359Sroberto	u_short fmt;
7954359Sroberto	const char *text;
8054359Sroberto};
8154359Sroberto
8254359Srobertoextern	void	asciize		P((int, char *, FILE *));
83132451Srobertoextern	int	getnetnum	P((const char *, struct sockaddr_storage *, char *, int));
8454359Srobertoextern	void	sortassoc	P((void));
8554359Srobertoextern	int	doquery		P((int, int, int, int, char *, u_short *, int *, char **));
86132451Srobertoextern	char *	nntohost	P((struct sockaddr_storage *));
8754359Srobertoextern	int	decodets	P((char *, l_fp *));
8854359Srobertoextern	int	decodeuint	P((char *, u_long *));
8954359Srobertoextern	int	nextvar		P((int *, char **, char **, char **));
9054359Srobertoextern	int	decodetime	P((char *, l_fp *));
9154359Srobertoextern	void	printvars	P((int, char *, int, int, FILE *));
9254359Srobertoextern	int	decodeint	P((char *, long *));
93182007Srobertoextern	int	findvar		P((char *, struct ctl_var *, int code));
94