File: ntp_config.h

package info (click to toggle)
ntpsec 1.2.0%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 10,044 kB
  • sloc: ansic: 60,737; python: 31,610; sh: 1,494; yacc: 1,291; makefile: 176; javascript: 138
file content (282 lines) | stat: -rw-r--r-- 6,682 bytes parent folder | download | duplicates (3)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#ifndef GUARD_NTP_CONFIG_H
#define GUARD_NTP_CONFIG_H

#include <sys/resource.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>

#include "ntp_syslog.h"
#include "ntp_fp.h"
#include "ntp.h"
#include "ntp_malloc.h"
#include "ntp_refclock.h"
#include "ntp_stdlib.h"
#include "ntp_machine.h"

/*
 * Configuration file name
 */
#ifndef CONFIG_FILE
#  define	CONFIG_FILE "/etc/ntpsec/ntp.conf"
#endif /* not CONFIG_FILE */
#define CONFIG_DIR	"ntp.d"

/* Limits */
#define MAXLINE 1024

/* Configuration sources */

#define CONF_SOURCE_FILE		0
#define CONF_SOURCE_NTPQ		1

/* count of parsing errors - for log file */
extern	int	parsing_errors;

/* list of servers from command line for config_peers() */
extern	int	cmdline_server_count;
extern	char **	cmdline_servers;

typedef struct int_range_tag {
	int	first;
	int	last;
} int_range;

/* Structure for storing an attribute-value pair  */
typedef struct attr_val_tag attr_val;
struct attr_val_tag {
	attr_val *	link;
	int		attr;
	int		type;	/* T_String, T_Integer, ... */
	union val {
		int		i;
		unsigned int	u;
		int_range	r;
		double		d;
		char *		s;
	} value;
};

typedef DECL_FIFO_ANCHOR(attr_val) attr_val_fifo;

/* Structure for nodes on the syntax tree */
typedef struct address_node_tag address_node;
struct address_node_tag {
	address_node *	link;
	char *		address;
	unsigned short	type;	/* family, AF_UNSPEC (0), AF_INET[6] */
};

typedef DECL_FIFO_ANCHOR(address_node) address_fifo;

typedef struct int_node_tag int_node;
struct int_node_tag {
	int_node *	link;
	int		i;
};

typedef DECL_FIFO_ANCHOR(int_node) int_fifo;

typedef struct string_node_tag string_node;
struct string_node_tag {
	string_node *	link;
	char *		s;
};

typedef DECL_FIFO_ANCHOR(string_node) string_fifo;

typedef struct restrict_node_tag restrict_node;
struct restrict_node_tag {
	restrict_node *	link;
	int		mode;	/* restrict or unrestrict? */
	address_node *	addr;
	address_node *	mask;
	int_fifo *	flags;
	int		line_no;
};

typedef DECL_FIFO_ANCHOR(restrict_node) restrict_fifo;

typedef struct peer_node_tag peer_node;
struct peer_node_tag {
	peer_node *	link;
	address_node *	addr;
	int		host_mode;
	struct peer_ctl	ctl;
	struct refclockstat clock_stat;
	char *		group;
};

typedef DECL_FIFO_ANCHOR(peer_node) peer_fifo;

typedef struct unpeer_node_tag unpeer_node;
struct unpeer_node_tag {
	unpeer_node *	link;
	associd_t	assocID;
	address_node *	addr;
};

typedef DECL_FIFO_ANCHOR(unpeer_node) unpeer_fifo;

typedef struct auth_node_tag auth_node;
struct auth_node_tag {
	int		control_key;
	char *		keys;
	attr_val_fifo *	trusted_key_list;
	char *		ntp_signd_socket;
};

typedef struct filegen_node_tag filegen_node;
struct filegen_node_tag {
	filegen_node *	link;
	int		filegen_token;
	attr_val_fifo *	options;
};

typedef DECL_FIFO_ANCHOR(filegen_node) filegen_fifo;

typedef struct setvar_node_tag setvar_node;
struct setvar_node_tag {
	setvar_node *	link;
	char *		var;
	char *		val;
	int		isdefault;
};

typedef DECL_FIFO_ANCHOR(setvar_node) setvar_fifo;

typedef struct nic_rule_node_tag nic_rule_node;
struct nic_rule_node_tag {
	nic_rule_node *	link;
	int		match_class;
	char *		if_name;	/* or numeric address */
	int		action;
};

typedef DECL_FIFO_ANCHOR(nic_rule_node) nic_rule_fifo;

typedef struct addr_opts_node_tag addr_opts_node;
struct addr_opts_node_tag {
	addr_opts_node *link;
	address_node *	addr;
	attr_val_fifo *	options;
};

typedef DECL_FIFO_ANCHOR(addr_opts_node) addr_opts_fifo;

typedef struct sim_node_tag sim_node;
struct sim_node_tag {
	sim_node *		link;
	attr_val_fifo *		init_opts;
};

typedef DECL_FIFO_ANCHOR(sim_node) sim_fifo;

/* The syntax tree */
typedef struct config_tree_tag config_tree;
struct config_tree_tag {
	config_tree *	link;

	attr_val	source;
	time_t		timestamp;

	peer_fifo *	peers;
	unpeer_fifo *	unpeers;

	/* Other Modes */
	attr_val_fifo *	orphan_cmds;	/* s/b renamed tos_options */

	/* Monitoring Configuration */
	int_fifo *	stats_list;
	char *		stats_dir;
	filegen_fifo *	filegen_opts;

	/* Access Control Configuration */
	attr_val_fifo *	limit_opts;
	attr_val_fifo *	mru_opts;
	restrict_fifo *	restrict_opts;

	addr_opts_fifo *fudge;
	attr_val_fifo *	rlimit;
	attr_val_fifo *	tinker;
	attr_val_fifo *	nts;
	attr_val_fifo *	enable_opts;
	attr_val_fifo *	disable_opts;

	auth_node	auth;

	attr_val_fifo *	logconfig;
	string_fifo *	phone;
	setvar_fifo *	setvar;
	attr_val_fifo *	vars;
	nic_rule_fifo *	nic_rules;
	int_fifo *	reset_counters;

	sim_fifo *	sim_details;
	int		mdnstries;
};
extern void init_readconfig(void);
extern void set_keys_file(char*);
extern void set_trustedkey(keyid_t);
extern int mdnstries;


/* Structure for holding a remote configuration command */
struct REMOTE_CONFIG_INFO {
	char buffer[MAXLINE];
	char err_msg[MAXLINE];
	int pos;
	int err_pos;
	int no_errors;
};


/* get text from T_ tokens */
const char * token_name(int token);

/* generic fifo routines for structs linked by 1st member */
void*	append_gen_fifo(void *fifo, void *entry);
void *	concat_gen_fifos(void *first, void *second);
#define APPEND_G_FIFO(pf, pe)		\
	((pf) = append_gen_fifo((pf), (pe)))
#define CONCAT_G_FIFOS(first, second)	\
	((first) = concat_gen_fifos((first), (second)))
#define HEAD_PFIFO(pf)			\
	(((pf) != NULL)			\
	      ? HEAD_FIFO(*(pf))	\
	      : NULL)

address_node *addr_from_typeunit(char *type, int unit);
peer_node *create_peer_node(int hmode, address_node *addr,
			    attr_val_fifo *options);
unpeer_node *create_unpeer_node(address_node *addr);
address_node *create_address_node(char *addr, int type);
void destroy_address_node(address_node *my_node);
attr_val *create_attr_dval(int attr, double value);
attr_val *create_attr_ival(int attr, int value);
attr_val *create_attr_uval(int attr, unsigned int value);
attr_val *create_attr_rangeval(int attr, int first, int last);
attr_val *create_attr_sval(int attr, const char *s);
filegen_node *create_filegen_node(int filegen_token,
				  attr_val_fifo *options);
string_node *create_string_node(char *str);
restrict_node *create_restrict_node(int mode, address_node *addr,
				    address_node *mask,
				    int_fifo *flags, int line_no);
int_node *create_int_node(int val);
addr_opts_node *create_addr_opts_node(address_node *addr,
				      attr_val_fifo *options);
setvar_node *create_setvar_node(char *var, char *val, int isdefault);
nic_rule_node *create_nic_rule_node(int match_class, char *if_name,
				    int action);

extern struct REMOTE_CONFIG_INFO remote_config;
void config_remotely(sockaddr_u *);

extern bool have_interface_option;
extern char *stats_drift_file;	/* name of the driftfile */


void ntp_rlimit(int, rlim_t, int, const char *);

#endif	/* GUARD_NTP_CONFIG_H */