4 #ifdef HAVE_SYS_RESOURCE_H
5 # include <sys/resource.h>
6 #endif /* HAVE_SYS_RESOURCE_H */
8 #include "ntp_machine.h"
14 * Configuration file name
18 # define CONFIG_FILE "/etc/ntp.conf"
19 # else /* SYS_WINNT */
20 # define CONFIG_FILE "%windir%\\system32\\drivers\\etc\\ntp.conf"
21 # define ALT_CONFIG_FILE "%windir%\\ntp.conf"
22 # define NTP_KEYSDIR "%windir%\\system32\\drivers\\etc"
23 # endif /* SYS_WINNT */
24 #endif /* not CONFIG_FILE */
28 * We keep config trees around for possible saveconfig use. When
29 * built with configure --disable-saveconfig, and when built with
30 * debugging enabled, include the free_config_*() routines. In the
31 * DEBUG case, they are used in an atexit() cleanup routine to make
32 * postmortem leak check reports more interesting.
34 #if !defined(FREE_CFG_T) && (!defined(SAVECONFIG) || defined(DEBUG))
41 /* Configuration sources */
43 #define CONF_SOURCE_FILE 0
44 #define CONF_SOURCE_NTPQ 1
46 /* list of servers from command line for config_peers() */
47 extern int cmdline_server_count;
48 extern char ** cmdline_servers;
50 /* set to zero if we're not locking memory */
51 extern int cur_memlock;
53 typedef struct int_range_tag {
58 /* generic list node */
59 typedef struct any_node_tag any_node;
64 typedef DECL_FIFO_ANCHOR(any_node) any_node_fifo;
66 /* Structure for storing an attribute-value pair */
67 typedef struct attr_val_tag attr_val;
71 int type; /* T_String, T_Integer, ... */
72 int flag; /* auxiliary flags */
74 double d; /* T_Double */
75 int i; /* T_Integer */
76 int_range r; /* T_Intrange */
77 char * s; /* T_String */
78 u_int u; /* T_U_int */
82 typedef DECL_FIFO_ANCHOR(attr_val) attr_val_fifo;
84 /* Structure for nodes on the syntax tree */
85 typedef struct address_node_tag address_node;
86 struct address_node_tag {
89 u_short type; /* family, AF_UNSPEC (0), AF_INET[6] */
92 typedef DECL_FIFO_ANCHOR(address_node) address_fifo;
94 typedef struct int_node_tag int_node;
100 typedef DECL_FIFO_ANCHOR(int_node) int_fifo;
102 typedef struct string_node_tag string_node;
103 struct string_node_tag {
108 typedef DECL_FIFO_ANCHOR(string_node) string_fifo;
110 typedef struct restrict_node_tag restrict_node;
111 struct restrict_node_tag {
112 restrict_node * link;
115 attr_val_fifo * flag_tok_fifo;
121 typedef DECL_FIFO_ANCHOR(restrict_node) restrict_fifo;
123 typedef struct peer_node_tag peer_node;
124 struct peer_node_tag {
128 attr_val_fifo * peerflags;
137 typedef DECL_FIFO_ANCHOR(peer_node) peer_fifo;
139 typedef struct unpeer_node_tag unpeer_node;
140 struct unpeer_node_tag {
146 typedef DECL_FIFO_ANCHOR(unpeer_node) unpeer_fifo;
148 typedef struct auth_node_tag auth_node;
149 struct auth_node_tag {
152 attr_val_fifo * crypto_cmd_list;
157 attr_val_fifo * trusted_key_list;
158 char * ntp_signd_socket;
161 typedef struct filegen_node_tag filegen_node;
162 struct filegen_node_tag {
165 attr_val_fifo * options;
168 typedef DECL_FIFO_ANCHOR(filegen_node) filegen_fifo;
170 typedef struct setvar_node_tag setvar_node;
171 struct setvar_node_tag {
178 typedef DECL_FIFO_ANCHOR(setvar_node) setvar_fifo;
180 typedef struct nic_rule_node_tag nic_rule_node;
181 struct nic_rule_node_tag {
182 nic_rule_node * link;
184 char * if_name; /* or numeric address */
188 typedef DECL_FIFO_ANCHOR(nic_rule_node) nic_rule_fifo;
190 typedef struct addr_opts_node_tag addr_opts_node;
191 struct addr_opts_node_tag {
192 addr_opts_node *link;
194 attr_val_fifo * options;
197 typedef DECL_FIFO_ANCHOR(addr_opts_node) addr_opts_fifo;
199 typedef struct sim_node_tag sim_node;
200 struct sim_node_tag {
202 attr_val_fifo * init_opts;
203 server_info_fifo * servers;
206 typedef DECL_FIFO_ANCHOR(sim_node) sim_fifo;
208 /* The syntax tree */
209 typedef struct config_tree_tag config_tree;
210 struct config_tree_tag {
217 unpeer_fifo * unpeers;
221 address_fifo * manycastserver;
222 address_fifo * multicastclient;
224 attr_val_fifo * orphan_cmds; /* s/b renamed tos_options */
226 /* Monitoring Configuration */
227 int_fifo * stats_list;
229 filegen_fifo * filegen_opts;
231 /* Access Control Configuration */
232 attr_val_fifo * discard_opts;
233 attr_val_fifo * mru_opts;
234 restrict_fifo * restrict_opts;
236 addr_opts_fifo *fudge;
237 attr_val_fifo * rlimit;
238 attr_val_fifo * tinker;
239 attr_val_fifo * enable_opts;
240 attr_val_fifo * disable_opts;
244 attr_val_fifo * logconfig;
246 setvar_fifo * setvar;
248 addr_opts_fifo *trap;
249 attr_val_fifo * vars;
250 nic_rule_fifo * nic_rules;
251 int_fifo * reset_counters;
252 attr_val_fifo * pollskewlist;
254 sim_fifo * sim_details;
259 /* Structure for holding a remote configuration command */
260 struct REMOTE_CONFIG_INFO {
261 char buffer[MAXLINE];
262 char err_msg[MAXLINE];
270 * context for trap_name_resolved() to call ctlsettrap() once the
271 * name->address resolution completes.
273 typedef struct settrap_parms_tag {
280 ** Data Minimization Items
283 /* Serverresponse fuzz reftime: stored in 'restrict' fifos */
286 /* get text from T_ tokens */
287 const char * token_name(int token);
289 /* generic fifo routines for structs linked by 1st member */
290 typedef void (*fifo_deleter)(void*);
291 void * destroy_gen_fifo(void *fifo, fifo_deleter func);
292 void * append_gen_fifo(void *fifo, void *entry);
293 void * concat_gen_fifos(void *first, void *second);
294 #define DESTROY_G_FIFO(pf, func) \
295 ((pf) = destroy_gen_fifo((pf), (fifo_deleter)(func)))
296 #define APPEND_G_FIFO(pf, pe) \
297 ((pf) = append_gen_fifo((pf), (pe)))
298 #define CONCAT_G_FIFOS(first, second) \
299 ((first) = concat_gen_fifos((first), (second)))
300 #define HEAD_PFIFO(pf) \
305 peer_node *create_peer_node(int hmode, address_node *addr,
306 attr_val_fifo *options);
307 unpeer_node *create_unpeer_node(address_node *addr);
308 address_node *create_address_node(char *addr, int type);
309 void destroy_address_node(address_node *my_node);
310 attr_val *create_attr_dval(int attr, double value);
311 attr_val *create_attr_ival(int attr, int value);
312 attr_val *create_attr_rval(int attr, int first, int last);
313 attr_val *create_attr_sval(int attr, const char *s);
314 attr_val *create_attr_uval(int attr, u_int value);
315 void destroy_attr_val(attr_val *node);
316 filegen_node *create_filegen_node(int filegen_token,
317 attr_val_fifo *options);
318 string_node *create_string_node(char *str);
319 restrict_node *create_restrict_node(address_node *addr,
322 attr_val_fifo *flags, int line_no);
323 int_node *create_int_node(int val);
324 addr_opts_node *create_addr_opts_node(address_node *addr,
325 attr_val_fifo *options);
326 sim_node *create_sim_node(attr_val_fifo *init_opts,
327 server_info_fifo *servers);
328 setvar_node *create_setvar_node(char *var, char *val, int isdefault);
329 nic_rule_node *create_nic_rule_node(int match_class, char *if_name,
332 script_info *create_sim_script_info(double duration,
333 attr_val_fifo *script_queue);
334 server_info *create_sim_server(address_node *addr, double server_offset,
335 script_info_fifo *script);
337 extern struct REMOTE_CONFIG_INFO remote_config;
338 void config_remotely(sockaddr_u *);
341 int dump_config_tree(config_tree *ptree, FILE *df, int comment);
342 int dump_all_config_trees(FILE *df, int comment);
345 #if defined(HAVE_SETRLIMIT)
346 void ntp_rlimit(int, rlim_t, int, const char *);
349 #endif /* !defined(NTP_CONFIG_H) */