Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / include / ntp_config.h
blobb2c40435e8267af1f1dca4e92a355da680a0bd2e
1 /* $NetBSD$ */
3 #ifndef NTP_CONFIG_H
4 #define NTP_CONFIG_H
6 #include "ntp_machine.h"
7 #include "ntp_data_structures.h"
8 #include "ntpsim.h"
12 * Configuration file name
14 #ifndef CONFIG_FILE
15 # ifndef SYS_WINNT
16 # define CONFIG_FILE "/etc/ntp.conf"
17 # else /* SYS_WINNT */
18 # define CONFIG_FILE "%windir%\\system32\\drivers\\etc\\ntp.conf"
19 # define ALT_CONFIG_FILE "%windir%\\ntp.conf"
20 # define NTP_KEYSDIR "%windir%\\system32\\drivers\\etc"
21 # endif /* SYS_WINNT */
22 #endif /* not CONFIG_FILE */
24 #ifdef HAVE_IPTOS_SUPPORT
25 /*
26 * "qos" modified keywords
28 #define CONF_QOS_LOWDELAY 1
29 #define CONF_QOS_THROUGHPUT 2
30 #define CONF_QOS_RELIABILITY 3
31 #define CONF_QOS_MINCOST 4
33 #ifdef IPTOS_PREC_INTERNETCONTROL
34 #define CONF_QOS_CS0 5
35 #define CONF_QOS_CS1 6
36 #define CONF_QOS_CS2 7
37 #define CONF_QOS_CS3 8
38 #define CONF_QOS_CS4 9
39 #define CONF_QOS_CS5 10
40 #define CONF_QOS_CS6 11
41 #define CONF_QOS_CS7 12
42 #endif /* IPTOS_PREC_INTERNETCONTROL */
44 #endif /* HAVE_IPTOS_SUPPORT */
48 * We keep config trees around for possible saveconfig use. When
49 * built with configure --disable-saveconfig, and when built with
50 * debugging enabled, include the free_config_*() routines. In the
51 * DEBUG case, they are used in an atexit() cleanup routine to make
52 * postmortem leak check reports more interesting.
54 #if !defined(FREE_CFG_T) && (!defined(SAVECONFIG) || defined(DEBUG))
55 #define FREE_CFG_T
56 #endif
59 * Some systems do not support fork() and don't have an alternate
60 * threads implementation of ntp_intres. Such systems are limited
61 * to using numeric IP addresses.
63 #if defined(VMS) || defined (SYS_VXWORKS) || \
64 (!defined(HAVE_FORK) && !defined(SYS_WINNT))
65 #define NO_INTRES
66 #endif
68 /* Limits */
69 #define MAXLINE 1024
71 /* Configuration sources */
73 #define CONF_SOURCE_FILE 0
74 #define CONF_SOURCE_NTPQ 1
77 /* Structure for storing an attribute-value pair */
78 struct attr_val {
79 int attr;
80 union val{
81 double d;
82 int i;
83 char *s;
84 void *p;
85 } value;
86 int type;
89 /* Structure for nodes on the syntax tree */
90 struct address_node {
91 char *address;
92 int type;
95 struct restrict_node {
96 struct address_node *addr;
97 struct address_node *mask;
98 queue *flags;
99 int line_no;
102 struct peer_node {
103 int host_mode;
104 struct address_node *addr;
105 queue *peerflags;
106 int minpoll;
107 int maxpoll;
108 int ttl;
109 int peerversion;
110 int peerkey;
111 double bias;
114 struct unpeer_node {
115 u_int assocID;
116 struct address_node * addr;
119 struct auth_node {
120 int control_key;
121 int cryptosw;
122 queue *crypto_cmd_list;
123 char *keys;
124 char *keysdir;
125 int request_key;
126 int revoke;
127 queue *trusted_key_list;
128 char *ntp_signd_socket;
131 struct filegen_node {
132 int filegen_token;
133 queue * options;
136 struct setvar_node {
137 char * var;
138 char * val;
139 int isdefault;
142 typedef struct nic_rule_node_tag {
143 int match_class;
144 char *if_name; /* interface name or numeric address */
145 int action;
146 } nic_rule_node;
148 struct addr_opts_node {
149 struct address_node *addr;
150 queue *options;
153 struct sim_node {
154 queue *init_opts;
155 queue *servers;
159 /* The syntax tree */
160 struct config_tree {
161 struct config_tree *link;
163 struct attr_val source;
164 time_t timestamp;
166 queue *peers;
167 queue *unpeers;
169 /* Other Modes */
170 int broadcastclient;
171 queue *manycastserver;
172 queue *multicastclient;
174 queue *orphan_cmds;
176 /* Monitoring Configuration */
177 queue *stats_list;
178 char *stats_dir;
179 queue *filegen_opts;
181 /* Access Control Configuration */
182 queue *discard_opts;
183 queue *restrict_opts;
185 queue *fudge;
186 queue *tinker;
187 queue *enable_opts;
188 queue *disable_opts;
189 struct auth_node auth;
191 queue *logconfig;
192 queue *qos;
193 queue *phone;
194 queue *setvar;
195 queue *ttl;
196 queue *trap;
197 queue *vars;
198 queue *nic_rules;
200 struct sim_node *sim_details;
204 /* Structure for holding a remote configuration command */
205 struct REMOTE_CONFIG_INFO {
206 char buffer[MAXLINE];
207 char err_msg[MAXLINE];
208 int pos;
209 int err_pos;
210 int no_errors;
213 /* get text from T_ tokens */
214 const char * token_name(int token);
216 struct peer_node *create_peer_node(int hmode,
217 struct address_node *addr,
218 queue *options);
219 struct unpeer_node *create_unpeer_node(struct address_node *addr);
220 struct address_node *create_address_node(char *addr, int type);
221 void destroy_address_node(struct address_node *my_node);
222 queue *enqueue_in_new_queue(void *my_node);
223 struct attr_val *create_attr_dval(int attr, double value);
224 struct attr_val *create_attr_ival(int attr, int value);
225 struct attr_val *create_attr_sval(int attr, char *s);
226 struct attr_val *create_attr_pval(int attr, void *s);
227 struct filegen_node *create_filegen_node(int filegen_token, queue *options);
228 void **create_pval(void *val);
229 struct restrict_node *create_restrict_node(struct address_node *addr,
230 struct address_node *mask,
231 queue *flags, int line_no);
232 int *create_ival(int val);
233 struct addr_opts_node *create_addr_opts_node(struct address_node *addr,
234 queue *options);
235 struct sim_node *create_sim_node(queue *init_opts, queue *servers);
236 struct setvar_node *create_setvar_node(char *var, char *val,
237 int isdefault);
238 nic_rule_node *create_nic_rule_node(int match_class, char *if_name,
239 int action);
241 script_info *create_sim_script_info(double duration,
242 queue *script_queue);
243 server_info *create_sim_server(struct address_node *addr,
244 double server_offset, queue *script);
246 extern struct REMOTE_CONFIG_INFO remote_config;
247 void config_remotely(sockaddr_u *);
249 #ifdef SAVECONFIG
250 int dump_config_tree(struct config_tree *ptree, FILE *df, int comment);
251 int dump_all_config_trees(FILE *df, int comment);
252 #endif
255 #endif /* !defined(NTP_CONFIG_H) */