4 #ifdef HAVE_SYS_RESOURCE_H
5 # include <sys/resource.h>
6 #endif /* HAVE_SYS_RESOURCE_H */
8 #include "ntp_machine.h"
13 * Configuration file name
17 # define CONFIG_FILE "/etc/ntp.conf"
18 # else /* SYS_WINNT */
19 # define CONFIG_FILE "%windir%\\system32\\drivers\\etc\\ntp.conf"
20 # define ALT_CONFIG_FILE "%windir%\\ntp.conf"
21 # define NTP_KEYSDIR "%windir%\\system32\\drivers\\etc"
22 # endif /* SYS_WINNT */
23 #endif /* not CONFIG_FILE */
27 * We keep config trees around for possible saveconfig use. When
28 * built with configure --disable-saveconfig, and when built with
29 * debugging enabled, include the free_config_*() routines. In the
30 * DEBUG case, they are used in an atexit() cleanup routine to make
31 * postmortem leak check reports more interesting.
33 #if !defined(FREE_CFG_T) && (!defined(SAVECONFIG) || defined(DEBUG))
40 /* Configuration sources */
42 #define CONF_SOURCE_FILE 0
43 #define CONF_SOURCE_NTPQ 1
45 /* list of servers from command line for config_peers() */
46 extern int cmdline_server_count;
47 extern char ** cmdline_servers;
49 /* set to zero if we're not locking memory */
50 extern int cur_memlock;
52 typedef struct int_range_tag {
57 /* Structure for storing an attribute-value pair */
58 typedef struct attr_val_tag attr_val;
62 int type; /* T_String, T_Integer, ... */
72 typedef DECL_FIFO_ANCHOR(attr_val) attr_val_fifo;
74 /* Structure for nodes on the syntax tree */
75 typedef struct address_node_tag address_node;
76 struct address_node_tag {
79 u_short type; /* family, AF_UNSPEC (0), AF_INET[6] */
82 typedef DECL_FIFO_ANCHOR(address_node) address_fifo;
84 typedef struct int_node_tag int_node;
90 typedef DECL_FIFO_ANCHOR(int_node) int_fifo;
92 typedef struct string_node_tag string_node;
93 struct string_node_tag {
98 typedef DECL_FIFO_ANCHOR(string_node) string_fifo;
100 typedef struct restrict_node_tag restrict_node;
101 struct restrict_node_tag {
102 restrict_node * link;
109 typedef DECL_FIFO_ANCHOR(restrict_node) restrict_fifo;
111 typedef struct peer_node_tag peer_node;
112 struct peer_node_tag {
116 attr_val_fifo * peerflags;
125 typedef DECL_FIFO_ANCHOR(peer_node) peer_fifo;
127 typedef struct unpeer_node_tag unpeer_node;
128 struct unpeer_node_tag {
134 typedef DECL_FIFO_ANCHOR(unpeer_node) unpeer_fifo;
136 typedef struct auth_node_tag auth_node;
137 struct auth_node_tag {
140 attr_val_fifo * crypto_cmd_list;
145 attr_val_fifo * trusted_key_list;
146 char * ntp_signd_socket;
149 typedef struct filegen_node_tag filegen_node;
150 struct filegen_node_tag {
153 attr_val_fifo * options;
156 typedef DECL_FIFO_ANCHOR(filegen_node) filegen_fifo;
158 typedef struct setvar_node_tag setvar_node;
159 struct setvar_node_tag {
166 typedef DECL_FIFO_ANCHOR(setvar_node) setvar_fifo;
168 typedef struct nic_rule_node_tag nic_rule_node;
169 struct nic_rule_node_tag {
170 nic_rule_node * link;
172 char * if_name; /* or numeric address */
176 typedef DECL_FIFO_ANCHOR(nic_rule_node) nic_rule_fifo;
178 typedef struct addr_opts_node_tag addr_opts_node;
179 struct addr_opts_node_tag {
180 addr_opts_node *link;
182 attr_val_fifo * options;
185 typedef DECL_FIFO_ANCHOR(addr_opts_node) addr_opts_fifo;
187 typedef struct sim_node_tag sim_node;
188 struct sim_node_tag {
190 attr_val_fifo * init_opts;
191 server_info_fifo * servers;
194 typedef DECL_FIFO_ANCHOR(sim_node) sim_fifo;
196 /* The syntax tree */
197 typedef struct config_tree_tag config_tree;
198 struct config_tree_tag {
205 unpeer_fifo * unpeers;
209 address_fifo * manycastserver;
210 address_fifo * multicastclient;
212 attr_val_fifo * orphan_cmds; /* s/b renamed tos_options */
214 /* Monitoring Configuration */
215 int_fifo * stats_list;
217 filegen_fifo * filegen_opts;
219 /* Access Control Configuration */
220 attr_val_fifo * discard_opts;
221 attr_val_fifo * mru_opts;
222 restrict_fifo * restrict_opts;
224 addr_opts_fifo *fudge;
225 attr_val_fifo * rlimit;
226 attr_val_fifo * tinker;
227 attr_val_fifo * enable_opts;
228 attr_val_fifo * disable_opts;
232 attr_val_fifo * logconfig;
234 setvar_fifo * setvar;
236 addr_opts_fifo *trap;
237 attr_val_fifo * vars;
238 nic_rule_fifo * nic_rules;
239 int_fifo * reset_counters;
241 sim_fifo * sim_details;
246 /* Structure for holding a remote configuration command */
247 struct REMOTE_CONFIG_INFO {
248 char buffer[MAXLINE];
249 char err_msg[MAXLINE];
257 * context for trap_name_resolved() to call ctlsettrap() once the
258 * name->address resolution completes.
260 typedef struct settrap_parms_tag {
266 /* get text from T_ tokens */
267 const char * token_name(int token);
269 /* generic fifo routines for structs linked by 1st member */
270 void* append_gen_fifo(void *fifo, void *entry);
271 void * concat_gen_fifos(void *first, void *second);
272 #define APPEND_G_FIFO(pf, pe) \
273 ((pf) = append_gen_fifo((pf), (pe)))
274 #define CONCAT_G_FIFOS(first, second) \
275 ((first) = concat_gen_fifos((first), (second)))
276 #define HEAD_PFIFO(pf) \
281 peer_node *create_peer_node(int hmode, address_node *addr,
282 attr_val_fifo *options);
283 unpeer_node *create_unpeer_node(address_node *addr);
284 address_node *create_address_node(char *addr, int type);
285 void destroy_address_node(address_node *my_node);
286 attr_val *create_attr_dval(int attr, double value);
287 attr_val *create_attr_ival(int attr, int value);
288 attr_val *create_attr_uval(int attr, u_int value);
289 attr_val *create_attr_rangeval(int attr, int first, int last);
290 attr_val *create_attr_sval(int attr, const char *s);
291 filegen_node *create_filegen_node(int filegen_token,
292 attr_val_fifo *options);
293 string_node *create_string_node(char *str);
294 restrict_node *create_restrict_node(address_node *addr,
296 int_fifo *flags, int line_no);
297 int_node *create_int_node(int val);
298 addr_opts_node *create_addr_opts_node(address_node *addr,
299 attr_val_fifo *options);
300 sim_node *create_sim_node(attr_val_fifo *init_opts,
301 server_info_fifo *servers);
302 setvar_node *create_setvar_node(char *var, char *val, int isdefault);
303 nic_rule_node *create_nic_rule_node(int match_class, char *if_name,
306 script_info *create_sim_script_info(double duration,
307 attr_val_fifo *script_queue);
308 server_info *create_sim_server(address_node *addr, double server_offset,
309 script_info_fifo *script);
311 extern struct REMOTE_CONFIG_INFO remote_config;
312 void config_remotely(sockaddr_u *);
315 int dump_config_tree(config_tree *ptree, FILE *df, int comment);
316 int dump_all_config_trees(FILE *df, int comment);
319 #if defined(HAVE_SETRLIMIT)
320 void ntp_rlimit(int, rlim_t, int, const char *);
323 #endif /* !defined(NTP_CONFIG_H) */