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