summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/ntpq/ntpq.h
blob: 8739cd4772d865db597be382006d3c2282a19eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * ntpq.h - definitions of interest to ntpq
 */
#include "ntp_fp.h"
#include "ntp.h"
#include "ntp_control.h"
#include "ntp_string.h"
#include "ntp_malloc.h"

/*
 * Maximum number of arguments
 */
#define	MAXARGS	4

/*
 * Flags for forming descriptors.
 */
#define	OPT	0x80		/* this argument is optional, or'd with type */

#define	NO	0x0
#define	STR	0x1		/* string argument */
#define	UINT	0x2		/* unsigned integer */
#define	INT	0x3		/* signed integer */
#define	ADD	0x4		/* IP network address */

/*
 * Arguments are returned in a union
 */
typedef union {
	char *string;
	long ival;
	u_long uval;
	u_int32 netnum;
} arg_v;

/*
 * Structure for passing parsed command line
 */
struct parse {
	const char *keyword;
	arg_v argval[MAXARGS];
	int nargs;
};

/*
 * ntpdc includes a command parser which could charitably be called
 * crude.  The following structure is used to define the command
 * syntax.
 */
struct xcmd {
  const char *keyword;		/* command key word */
	void (*handler)	P((struct parse *, FILE *));	/* command handler */
	u_char arg[MAXARGS];	/* descriptors for arguments */
  const char *desc[MAXARGS];	/* descriptions for arguments */
  const char *comment;
};

/*
 * Structure to hold association data
 */
struct association {
	u_short assid;
	u_short status;
};

#define	MAXASSOC	1024

/*
 * Structure for translation tables between text format
 * variable indices and text format.
 */
struct ctl_var {
	u_short code;
	u_short fmt;
	const char *text;
};

extern	void	asciize		P((int, char *, FILE *));
extern	int	getnetnum	P((const char *, u_int32 *, char *));
extern	void	sortassoc	P((void));
extern	int	doquery		P((int, int, int, int, char *, u_short *, int *, char **));
extern	char *	nntohost	P((u_int32));
extern	int	decodets	P((char *, l_fp *));
extern	int	decodeuint	P((char *, u_long *));
extern	int	nextvar		P((int *, char **, char **, char **));
extern	int	decodetime	P((char *, l_fp *));
extern	void	printvars	P((int, char *, int, int, FILE *));
extern	int	decodeint	P((char *, long *));
extern	int	findvar		P((char *, struct ctl_var *));
OpenPOWER on IntegriCloud