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