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/* 57 * Some systems do not support fork() and don't have an alternate 58 * threads implementation of ntp_intres. Such systems are limited 59 * to using numeric IP addresses. 60 */ 61#if defined(VMS) || defined (SYS_VXWORKS) || \ 62 (!defined(HAVE_FORK) && !defined(SYS_WINNT)) 63#define NO_INTRES 64#endif 65 66/* Limits */ 67#define MAXLINE 1024 68 69/* Configuration sources */ 70 71#define CONF_SOURCE_FILE 0 72#define CONF_SOURCE_NTPQ 1 73 74 75/* Structure for storing an attribute-value pair */ 76struct attr_val { 77 int attr; 78 union val{ 79 double d; 80 int i; 81 char *s; 82 void *p; 83 } value; 84 int type; 85}; 86 87/* Structure for nodes on the syntax tree */ 88struct address_node { 89 char *address; 90 int type; 91}; 92 93struct restrict_node { 94 struct address_node *addr; 95 struct address_node *mask; 96 queue *flags; 97 int line_no; 98}; 99 100struct peer_node { 101 int host_mode; 102 struct address_node *addr; 103 queue *peerflags; 104 int minpoll; 105 int maxpoll; 106 int ttl; 107 int peerversion; 108 int peerkey; 109 double bias; 110}; 111 112struct unpeer_node { 113 u_int assocID; 114 struct address_node * addr; 115}; 116 117struct auth_node { 118 int control_key; 119 int cryptosw; 120 queue *crypto_cmd_list; 121 char *keys; 122 char *keysdir; 123 int request_key; 124 int revoke; 125 queue *trusted_key_list; 126 char *ntp_signd_socket; 127}; 128 129struct filegen_node { 130 int filegen_token; 131 queue * options; 132}; 133 134struct setvar_node { 135 char * var; 136 char * val; 137 int isdefault; 138}; 139 140typedef struct nic_rule_node_tag { 141 int match_class; 142 char *if_name; /* interface name or numeric address */ 143 int action; 144} nic_rule_node; 145 146struct addr_opts_node { 147 struct address_node *addr; 148 queue *options; 149}; 150 151struct sim_node { 152 queue *init_opts; 153 queue *servers; 154}; 155 156 157/* The syntax tree */ 158struct config_tree { 159 struct config_tree *link; 160 161 struct attr_val source; 162 time_t timestamp; 163 164 queue *peers; 165 queue *unpeers; 166 167 /* Other Modes */ 168 int broadcastclient; 169 queue *manycastserver; 170 queue *multicastclient; 171 172 queue *orphan_cmds; 173 174 /* Monitoring Configuration */ 175 queue *stats_list; 176 char *stats_dir; 177 queue *filegen_opts; 178 179 /* Access Control Configuration */ 180 queue *discard_opts; 181 queue *restrict_opts; 182 183 queue *fudge; 184 queue *tinker; 185 queue *enable_opts; 186 queue *disable_opts; 187 struct auth_node auth; 188 189 queue *logconfig; 190 queue *qos; 191 queue *phone; 192 queue *setvar; 193 queue *ttl; 194 queue *trap; 195 queue *vars; 196 queue *nic_rules; 197 198 struct sim_node *sim_details; 199}; 200 201 202/* Structure for holding a remote configuration command */ 203struct REMOTE_CONFIG_INFO { 204 char buffer[MAXLINE]; 205 char err_msg[MAXLINE]; 206 int pos; 207 int err_pos; 208 int no_errors; 209}; 210 211/* get text from T_ tokens */ 212const char * token_name(int token); 213 214struct peer_node *create_peer_node(int hmode, 215 struct address_node *addr, 216 queue *options); 217struct unpeer_node *create_unpeer_node(struct address_node *addr); 218struct address_node *create_address_node(char *addr, int type); 219void destroy_address_node(struct address_node *my_node); 220queue *enqueue_in_new_queue(void *my_node); 221struct attr_val *create_attr_dval(int attr, double value); 222struct attr_val *create_attr_ival(int attr, int value); 223struct attr_val *create_attr_sval(int attr, char *s); 224struct attr_val *create_attr_pval(int attr, void *s); 225struct filegen_node *create_filegen_node(int filegen_token, queue *options); 226void **create_pval(void *val); 227struct restrict_node *create_restrict_node(struct address_node *addr, 228 struct address_node *mask, 229 queue *flags, int line_no); 230int *create_ival(int val); 231struct addr_opts_node *create_addr_opts_node(struct address_node *addr, 232 queue *options); 233struct sim_node *create_sim_node(queue *init_opts, queue *servers); 234struct setvar_node *create_setvar_node(char *var, char *val, 235 int isdefault); 236nic_rule_node *create_nic_rule_node(int match_class, char *if_name, 237 int action); 238 239script_info *create_sim_script_info(double duration, 240 queue *script_queue); 241server_info *create_sim_server(struct address_node *addr, 242 double server_offset, queue *script); 243 244extern struct REMOTE_CONFIG_INFO remote_config; 245void config_remotely(sockaddr_u *); 246 247#ifdef SAVECONFIG 248int dump_config_tree(struct config_tree *ptree, FILE *df, int comment); 249int dump_all_config_trees(FILE *df, int comment); 250#endif 251 252 253#endif /* !defined(NTP_CONFIG_H) */ 254