1 /* $NetBSD: ntp_config.h,v 1.2 2010/11/29 00:39:40 christos Exp $ */ 2 3 #ifndef NTP_CONFIG_H 4 #define NTP_CONFIG_H 5 6 #include "ntp_machine.h" 7 #include "ntp_data_structures.h" 8 #include "ntpsim.h" 9 10 11 /* 12 * Configuration file name 13 */ 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 */ 23 24 #ifdef HAVE_IPTOS_SUPPORT 25 /* 26 * "qos" modified keywords 27 */ 28 #define CONF_QOS_LOWDELAY 1 29 #define CONF_QOS_THROUGHPUT 2 30 #define CONF_QOS_RELIABILITY 3 31 #define CONF_QOS_MINCOST 4 32 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 */ 43 44 #endif /* HAVE_IPTOS_SUPPORT */ 45 46 47 /* 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. 53 */ 54 #if !defined(FREE_CFG_T) && (!defined(SAVECONFIG) || defined(DEBUG)) 55 #define FREE_CFG_T 56 #endif 57 58 /* 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. 62 */ 63 #if defined(VMS) || defined (SYS_VXWORKS) || \ 64 (!defined(HAVE_FORK) && !defined(SYS_WINNT)) 65 #define NO_INTRES 66 #endif 67 68 /* Limits */ 69 #define MAXLINE 1024 70 71 /* Configuration sources */ 72 73 #define CONF_SOURCE_FILE 0 74 #define CONF_SOURCE_NTPQ 1 75 76 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; 87 }; 88 89 /* Structure for nodes on the syntax tree */ 90 struct address_node { 91 char *address; 92 int type; 93 }; 94 95 struct restrict_node { 96 struct address_node *addr; 97 struct address_node *mask; 98 queue *flags; 99 int line_no; 100 }; 101 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; 112 }; 113 114 struct unpeer_node { 115 u_int assocID; 116 struct address_node * addr; 117 }; 118 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; 129 }; 130 131 struct filegen_node { 132 int filegen_token; 133 queue * options; 134 }; 135 136 struct setvar_node { 137 char * var; 138 char * val; 139 int isdefault; 140 }; 141 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; 147 148 struct addr_opts_node { 149 struct address_node *addr; 150 queue *options; 151 }; 152 153 struct sim_node { 154 queue *init_opts; 155 queue *servers; 156 }; 157 158 159 /* The syntax tree */ 160 struct config_tree { 161 struct config_tree *link; 162 163 struct attr_val source; 164 time_t timestamp; 165 166 queue *peers; 167 queue *unpeers; 168 169 /* Other Modes */ 170 int broadcastclient; 171 queue *manycastserver; 172 queue *multicastclient; 173 174 queue *orphan_cmds; 175 176 /* Monitoring Configuration */ 177 queue *stats_list; 178 char *stats_dir; 179 queue *filegen_opts; 180 181 /* Access Control Configuration */ 182 queue *discard_opts; 183 queue *restrict_opts; 184 185 queue *fudge; 186 queue *tinker; 187 queue *enable_opts; 188 queue *disable_opts; 189 struct auth_node auth; 190 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; 199 200 struct sim_node *sim_details; 201 202 int mdnstries; 203 }; 204 205 206 /* Structure for holding a remote configuration command */ 207 struct REMOTE_CONFIG_INFO { 208 char buffer[MAXLINE]; 209 char err_msg[MAXLINE]; 210 int pos; 211 int err_pos; 212 int no_errors; 213 }; 214 215 /* get text from T_ tokens */ 216 const char * token_name(int token); 217 218 struct peer_node *create_peer_node(int hmode, 219 struct address_node *addr, 220 queue *options); 221 struct unpeer_node *create_unpeer_node(struct address_node *addr); 222 struct address_node *create_address_node(char *addr, int type); 223 void destroy_address_node(struct address_node *my_node); 224 queue *enqueue_in_new_queue(void *my_node); 225 struct attr_val *create_attr_dval(int attr, double value); 226 struct attr_val *create_attr_ival(int attr, int value); 227 struct attr_val *create_attr_sval(int attr, char *s); 228 struct attr_val *create_attr_pval(int attr, void *s); 229 struct filegen_node *create_filegen_node(int filegen_token, queue *options); 230 void **create_pval(void *val); 231 struct restrict_node *create_restrict_node(struct address_node *addr, 232 struct address_node *mask, 233 queue *flags, int line_no); 234 int *create_ival(int val); 235 struct addr_opts_node *create_addr_opts_node(struct address_node *addr, 236 queue *options); 237 struct sim_node *create_sim_node(queue *init_opts, queue *servers); 238 struct setvar_node *create_setvar_node(char *var, char *val, 239 int isdefault); 240 nic_rule_node *create_nic_rule_node(int match_class, char *if_name, 241 int action); 242 243 script_info *create_sim_script_info(double duration, 244 queue *script_queue); 245 server_info *create_sim_server(struct address_node *addr, 246 double server_offset, queue *script); 247 248 extern struct REMOTE_CONFIG_INFO remote_config; 249 void config_remotely(sockaddr_u *); 250 251 #ifdef SAVECONFIG 252 int dump_config_tree(struct config_tree *ptree, FILE *df, int comment); 253 int dump_all_config_trees(FILE *df, int comment); 254 #endif 255 256 257 #endif /* !defined(NTP_CONFIG_H) */ 258