NOVOLLEY
};
-/* A fix for now to prevent the configuration from being consumed before
- * it could be ever dumped
- */
-struct config_tree_list {
- s_list *peers;
- s_list *unpeers;
-
- /* Other Modes */
- int broadcastclient;
- s_list *manycastserver;
- s_list *multicastclient;
-
- s_list *orphan_cmds;
-
- /* Monitoring Configuration */
- s_list *stats_list;
- char *stats_dir;
- s_list *filegen_opts;
-
- /* Access Control Configuration */
- s_list *discard_opts;
- s_list *restrict_opts;
-
- s_list *fudge;
- s_list *tinker;
- s_list *enable_opts;
- s_list *disable_opts;
- struct auth_node auth;
-
- s_list *logconfig;
- s_list *qos;
- s_list *phone;
- s_list *setvar;
- s_list *ttl;
- s_list *trap;
- s_list *vars;
-
- struct sim_node *sim_details;
-};
-
/* The syntax tree */
struct config_tree {
+ struct config_tree *prior;
+
queue *peers;
queue *unpeers;
int no_of_elements;
} queue;
-/* Singly-linked structure to hold the same data as a priorithy queue
- * ------------------------------------------------------------------
- */
-
-typedef struct s_list {
- void *value;
- struct s_list *next;
-} s_list;
/* FUNCTION PROTOTYPES
* -------------------
if (prompt) {
if (lineedit_prompt)
free(lineedit_prompt);
- lineedit_prompt = strdup(prompt);
- success = (NULL != lineedit_prompt);
+ lineedit_prompt = estrdup(prompt);
}
#if !defined(HAVE_READLINE_HISTORY) && defined(HAVE_HISTEDIT_H)
- if (success && NULL == ntp_el) {
+ if (NULL == ntp_el) {
ntp_el = el_init(progname, stdin, stdout, stderr);
if (ntp_el) {
if (NULL != cline && *cline) {
history(ntp_hist, &hev, H_ENTER, cline);
*pcount = strlen(cline);
- line = strdup(cline);
+ line = estrdup(cline);
} else
line = NULL;
fflush(stderr);
}
- line = fgets(line_buf, sizeof line_buf, stdin);
+ line = fgets(line_buf, sizeof(line_buf), stdin);
if (NULL != line && *line) {
*pcount = strlen(line);
line = estrdup(line);
int curr_include_level; /* The current include level */
struct FILE_INFO *fp[MAXINCLUDELEVEL+1];
FILE *res_fp;
-struct config_tree my_config; /* Root of the configuration tree */
-struct config_tree_list my_config_list;
+struct config_tree cfgt; /* Parser output stored here */
+struct config_tree *cfg_tree_history; /* History of configs */
#if 0
short default_ai_family = AF_UNSPEC; /* Default either IPv4 or IPv6 */
#else
static void init_syntax_tree(struct config_tree *);
#ifdef DEBUG
static void free_auth_node(struct config_tree *);
- void free_syntax_trees(void);
+ void free_all_config_trees(void); /* atexit() */
+static void free_config_tree(struct config_tree *ptree);
#endif
double *create_dval(double val);
void destroy_restrict_node(struct restrict_node *my_node);
+static int is_sane_resolved_address(struct sockaddr_storage peeraddr, int hmode);
+static int get_correct_host_mode(int hmode);
+static void save_and_apply_config_tree(void);
+void getconfig(int argc,char *argv[]);
#if !defined(SIM)
static struct sockaddr_storage *get_next_address(struct address_node *addr);
#endif
static void config_trap(struct config_tree *);
static void config_fudge(struct config_tree *);
static void config_vars(struct config_tree *);
-static int is_sane_resolved_address(struct sockaddr_storage peeraddr, int hmode);
-static int get_correct_host_mode(int hmode);
static void config_peers(struct config_tree *);
static void config_unpeers(struct config_tree *);
+
static void config_ntpd(struct config_tree *);
#ifdef SIM
static void config_sim(struct config_tree *);
static void config_ntpdsim(struct config_tree *);
#endif
-void getconfig(int argc,char *argv[]);
-void clone_config(struct config_tree *config, struct config_tree_list *list);
enum gnn_type {
t_UNK, /* Unknown */
struct config_tree *ptree
)
{
- ptree->auth.autokey = 0;
- ptree->auth.control_key = 0;
- ptree->auth.crypto_cmd_list = NULL;
- ptree->auth.keys = NULL;
- ptree->auth.keysdir = NULL;
ptree->auth.ntp_signd_socket = default_ntp_signd_socket;
- ptree->auth.request_key = 0;
- ptree->auth.revoke = 0;
- ptree->auth.trusted_key_list = NULL;
}
#ifdef DEBUG
struct config_tree *ptree
)
{
+ memset(ptree, 0, sizeof(*ptree));
+
ptree->peers = create_queue();
ptree->unpeers = create_queue();
ptree->orphan_cmds = create_queue();
-
- ptree->broadcastclient = 0;
ptree->manycastserver = create_queue();
ptree->multicastclient = create_queue();
-
ptree->stats_list = create_queue();
- ptree->stats_dir = NULL;
ptree->filegen_opts = create_queue();
-
ptree->discard_opts = create_queue();
ptree->restrict_opts = create_queue();
-
ptree->enable_opts = create_queue();
ptree->disable_opts = create_queue();
ptree->tinker = create_queue();
ptree->fudge = create_queue();
-
ptree->logconfig = create_queue();
ptree->phone = create_queue();
ptree->qos = create_queue();
ptree->ttl = create_queue();
ptree->trap = create_queue();
ptree->vars = create_queue();
- ptree->sim_details = NULL;
init_auth_node(ptree);
#ifdef DEBUG
- atexit(free_syntax_trees);
+ atexit(free_all_config_trees);
#endif
}
+
#ifdef DEBUG
void
-free_syntax_trees(void)
+free_all_config_trees(void)
+{
+ struct config_tree *ptree;
+ struct config_tree *pprior;
+
+ ptree = cfg_tree_history;
+
+ while (ptree != NULL) {
+ pprior = ptree->prior;
+ free_config_tree(ptree);
+ ptree = pprior;
+ }
+}
+
+
+static void
+free_config_tree(struct config_tree *ptree)
{
- // !!!!
-#if 0
DESTROY_QUEUE(ptree->peers);
DESTROY_QUEUE(ptree->unpeers);
DESTROY_QUEUE(ptree->orphan_cmds);
DESTROY_QUEUE(ptree->vars);
free_auth_node(ptree);
-#endif // !!!!
+
+ free(ptree);
}
#endif /* DEBUG */
+
/* The config dumper */
int
dump_config_tree(
)
{
struct attr_val *my_val;
- int *key_val;
- while (!empty(ptree->auth.crypto_cmd_list)) {
- my_val = dequeue(ptree->auth.crypto_cmd_list);
+ while (NULL !=
+ (my_val = dequeue(ptree->auth.crypto_cmd_list))) {
+
free(my_val->value.s);
free_node(my_val);
}
DESTROY_QUEUE(ptree->auth.crypto_cmd_list);
- while (!empty(ptree->auth.trusted_key_list)) {
- key_val = dequeue(ptree->auth.trusted_key_list);
- free_node(key_val);
- }
DESTROY_QUEUE(ptree->auth.trusted_key_list);
-
}
#endif /* DEBUG */
}
#endif /* SIM */
+
+/*
+ * config_remotely() - implements ntpd side of ntpq :config
+ */
void
config_remotely(void)
{
input_from_file = 0;
key_scanner = create_keyword_scanner(keyword_list);
+ init_syntax_tree(&cfgt);
yyparse();
delete_keyword_scanner(key_scanner);
key_scanner = NULL;
DPRINTF(1, ("Finished Parsing!!\n"));
- config_ntpd(&my_config);
+ save_and_apply_config_tree();
input_from_file = 1;
}
-/* ACTUAL getconfig code */
-
+/*
+ * getconfig() - process startup configuration file e.g /etc/ntp.conf
+ */
void
getconfig(
int argc,
/*** BULK OF THE PARSER ***/
ip_file = fp[curr_include_level];
- init_syntax_tree(&my_config);
+ init_syntax_tree(&cfgt);
key_scanner = create_keyword_scanner(keyword_list);
yyparse();
DPRINTF(1, ("Finished Parsing!!\n"));
- /* The actual configuration done depends on whether we are configuring the
- * simulator or the daemon. Perform a check and call the appropriate
- * function as needed.
- */
-
-#ifndef SIM
- config_ntpd(&my_config);
-#else
- config_ntpdsim(&my_config);
-#endif
+ save_and_apply_config_tree();
while (curr_include_level != -1) {
FCLOSE(fp[curr_include_level--]);
}
+void
+save_and_apply_config_tree(void)
+{
+ struct config_tree *prior;
+
+ /*
+ * Keep all the configuration trees applied since startup in
+ * a list that can be used to dump the configuration back to
+ * a text file.
+ */
+ prior = cfg_tree_history;
+ cfg_tree_history = emalloc(sizeof(*cfg_tree_history));
+ memcpy(cfg_tree_history, &cfgt, sizeof(*cfg_tree_history));
+ cfg_tree_history->prior = prior;
+ memset(&cfgt, 0, sizeof(cfgt));
+
+ /* The actual configuration done depends on whether we are configuring the
+ * simulator or the daemon. Perform a check and call the appropriate
+ * function as needed.
+ */
+
+#ifndef SIM
+ config_ntpd(cfg_tree_history);
+#else
+ config_ntpdsim(cfg_tree_history);
+#endif
+}
+
/* FUNCTIONS COPIED FROM THE OLDER ntp_config.c
* --------------------------------------------
ni_status status;
void *domain;
ni_id config_dir;
- struct netinfo_config_state *config;
+ struct netinfo_config_state *config;
if (ni_open(NULL, ".", &domain) != NI_OK) return NULL;
return NULL;
}
- config = (struct netinfo_config_state *)malloc(sizeof(struct netinfo_config_state));
- config->domain = domain;
- config->config_dir = config_dir;
- config->prop_index = 0;
- config->val_index = 0;
- config->val_list = NULL;
+ config = emalloc(sizeof(*config));
+ config->domain = domain;
+ config->config_dir = config_dir;
+ config->prop_index = 0;
+ config->val_index = 0;
+ config->val_list = NULL;
return config;
}
*/
again:
if (!val_list) {
- for (; prop_index < (sizeof(keywords)/sizeof(keywords[0])); prop_index++)
- {
- ni_namelist namelist;
+ for (; prop_index < COUNTOF(keywords); prop_index++)
+ {
+ ni_namelist namelist;
struct keyword current_prop = keywords[prop_index];
+ ni_index index;
/*
* For each value associated in the property, we're going to return
* a separate line. We squirrel away the values in the config state
* so the next time through, we don't need to do this lookup.
*/
- NI_INIT(&namelist);
- if (ni_lookupprop(config->domain, &config->config_dir, current_prop.text, &namelist) == NI_OK) {
- ni_index index;
+ NI_INIT(&namelist);
+ if (NI_OK == ni_lookupprop(config->domain,
+ &config->config_dir, current_prop.text,
+ &namelist)) {
/* Found the property, but it has no values */
if (namelist.ni_namelist_len == 0) continue;
- if (! (val_list = config->val_list = (char**)malloc(sizeof(char*) * (namelist.ni_namelist_len + 1))))
- { msyslog(LOG_ERR, "out of memory while configuring"); break; }
-
- for (index = 0; index < namelist.ni_namelist_len; index++) {
- char *value = namelist.ni_namelist_val[index];
+ config->val_list =
+ emalloc(sizeof(char*) *
+ (namelist.ni_namelist_len + 1));
+ val_list = config->val_list;
- if (! (val_list[index] = (char*)malloc(strlen(value)+1)))
- { msyslog(LOG_ERR, "out of memory while configuring"); break; }
-
- strcpy(val_list[index], value);
+ for (index = 0;
+ index < namelist.ni_namelist_len;
+ index++) {
+ char *value;
+
+ value = namelist.ni_namelist_val[index];
+ val_list[index] = estrdup(value);
}
val_list[index] = NULL;
}
/* No list; we're done here. */
- if (!val_list) return CONFIG_UNKNOWN;
+ if (!val_list)
+ return CONFIG_UNKNOWN;
/*
* We have a list of values for the current property.
* Iterate through them and return each in order.
*/
- if (val_list[val_index])
- {
+ if (val_list[val_index]) {
int ntok = 1;
int quoted = 0;
char *tokens = val_list[val_index];
break;
} else { /* must be space */
*tokens++ = '\0';
- while (ISSPACE(*tokens)) tokens++;
- if (ISEOL(*tokens)) break;
+ while (ISSPACE(*tokens))
+ tokens++;
+ if (ISEOL(*tokens))
+ break;
}
}
/* Free val_list and reset counters. */
for (val_index = 0; val_list[val_index]; val_index++)
free(val_list[val_index]);
- free(val_list); val_list = config->val_list = NULL; val_index = config->val_index = 0;
+ free(val_list);
+ val_list = config->val_list = NULL;
+ val_index = config->val_index = 0;
goto again;
}
pn = pv;
pn--;
- return pn->node_next;
+ if (pn->node_next == NULL)
+ return NULL;
+
+ return pn->node_next + 1;
}
queue *q
)
{
- if (NULL == q->front)
+ if (NULL == q || NULL == q->front)
return NULL;
return q->front + 1;
{
struct peer_node *my_node = create_peer_node((yyvsp[(1) - (3)].Integer), (yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue));
if (my_node)
- enqueue(my_config.peers, my_node);
+ enqueue(cfgt.peers, my_node);
}
break;
{
struct peer_node *my_node = create_peer_node((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Address_node), NULL);
if (my_node)
- enqueue(my_config.peers, my_node);
+ enqueue(cfgt.peers, my_node);
}
break;
{
struct unpeer_node *my_node = create_unpeer_node((yyvsp[(2) - (2)].Address_node));
if (my_node)
- enqueue(my_config.unpeers, my_node);
+ enqueue(cfgt.unpeers, my_node);
}
break;
/* Line 1455 of yacc.c */
#line 408 "ntp_parser.y"
- { my_config.broadcastclient = SIMPLE; }
+ { cfgt.broadcastclient = SIMPLE; }
break;
case 51:
/* Line 1455 of yacc.c */
#line 410 "ntp_parser.y"
- { my_config.broadcastclient = NOVOLLEY; }
+ { cfgt.broadcastclient = NOVOLLEY; }
break;
case 52:
/* Line 1455 of yacc.c */
#line 412 "ntp_parser.y"
- { append_queue(my_config.manycastserver, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.manycastserver, (yyvsp[(2) - (2)].Queue)); }
break;
case 53:
/* Line 1455 of yacc.c */
#line 414 "ntp_parser.y"
- { append_queue(my_config.multicastclient, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.multicastclient, (yyvsp[(2) - (2)].Queue)); }
break;
case 54:
/* Line 1455 of yacc.c */
#line 425 "ntp_parser.y"
- { my_config.auth.autokey = (yyvsp[(2) - (2)].Integer); }
+ { cfgt.auth.autokey = (yyvsp[(2) - (2)].Integer); }
break;
case 55:
/* Line 1455 of yacc.c */
#line 427 "ntp_parser.y"
- { my_config.auth.control_key = (yyvsp[(2) - (2)].Integer); }
+ { cfgt.auth.control_key = (yyvsp[(2) - (2)].Integer); }
break;
case 56:
/* Line 1455 of yacc.c */
#line 429 "ntp_parser.y"
{
- if (my_config.auth.crypto_cmd_list != NULL)
- append_queue(my_config.auth.crypto_cmd_list, (yyvsp[(2) - (2)].Queue));
+ if (cfgt.auth.crypto_cmd_list != NULL)
+ append_queue(cfgt.auth.crypto_cmd_list, (yyvsp[(2) - (2)].Queue));
else
- my_config.auth.crypto_cmd_list = (yyvsp[(2) - (2)].Queue);
+ cfgt.auth.crypto_cmd_list = (yyvsp[(2) - (2)].Queue);
cryptosw++;
}
break;
/* Line 1455 of yacc.c */
#line 437 "ntp_parser.y"
- { my_config.auth.keys = (yyvsp[(2) - (2)].String); }
+ { cfgt.auth.keys = (yyvsp[(2) - (2)].String); }
break;
case 58:
/* Line 1455 of yacc.c */
#line 439 "ntp_parser.y"
- { my_config.auth.keysdir = (yyvsp[(2) - (2)].String); }
+ { cfgt.auth.keysdir = (yyvsp[(2) - (2)].String); }
break;
case 59:
/* Line 1455 of yacc.c */
#line 441 "ntp_parser.y"
- { my_config.auth.request_key = (yyvsp[(2) - (2)].Integer); }
+ { cfgt.auth.request_key = (yyvsp[(2) - (2)].Integer); }
break;
case 60:
/* Line 1455 of yacc.c */
#line 443 "ntp_parser.y"
- { my_config.auth.trusted_key_list = (yyvsp[(2) - (2)].Queue); }
+ { cfgt.auth.trusted_key_list = (yyvsp[(2) - (2)].Queue); }
break;
case 61:
/* Line 1455 of yacc.c */
#line 445 "ntp_parser.y"
- { my_config.auth.ntp_signd_socket = (yyvsp[(2) - (2)].String); }
+ { cfgt.auth.ntp_signd_socket = (yyvsp[(2) - (2)].String); }
break;
case 63:
/* Line 1455 of yacc.c */
#line 469 "ntp_parser.y"
- { my_config.auth.revoke = (yyvsp[(2) - (2)].Integer); }
+ { cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); }
break;
case 71:
/* Line 1455 of yacc.c */
#line 481 "ntp_parser.y"
- { append_queue(my_config.orphan_cmds,(yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.orphan_cmds,(yyvsp[(2) - (2)].Queue)); }
break;
case 73:
/* Line 1455 of yacc.c */
#line 521 "ntp_parser.y"
- { append_queue(my_config.stats_list, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.stats_list, (yyvsp[(2) - (2)].Queue)); }
break;
case 87:
/* Line 1455 of yacc.c */
#line 523 "ntp_parser.y"
- { my_config.stats_dir = (yyvsp[(2) - (2)].String); }
+ { cfgt.stats_dir = (yyvsp[(2) - (2)].String); }
break;
case 88:
/* Line 1455 of yacc.c */
#line 525 "ntp_parser.y"
{
- enqueue(my_config.filegen_opts,
+ enqueue(cfgt.filegen_opts,
create_filegen_node((yyvsp[(2) - (3)].VoidPtr), (yyvsp[(3) - (3)].Queue)));
}
break;
/* Line 1455 of yacc.c */
#line 588 "ntp_parser.y"
{
- append_queue(my_config.discard_opts, (yyvsp[(2) - (2)].Queue));
+ append_queue(cfgt.discard_opts, (yyvsp[(2) - (2)].Queue));
}
break;
/* Line 1455 of yacc.c */
#line 592 "ntp_parser.y"
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node((yyvsp[(2) - (3)].Address_node), NULL, (yyvsp[(3) - (3)].Queue), ip_file->line_no));
}
break;
/* Line 1455 of yacc.c */
#line 597 "ntp_parser.y"
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node(NULL, NULL, (yyvsp[(3) - (3)].Queue), ip_file->line_no));
}
break;
/* Line 1455 of yacc.c */
#line 602 "ntp_parser.y"
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node(
create_address_node(
estrdup("0.0.0.0"),
/* Line 1455 of yacc.c */
#line 615 "ntp_parser.y"
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node(
create_address_node(
estrdup("::"),
/* Line 1455 of yacc.c */
#line 628 "ntp_parser.y"
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node((yyvsp[(2) - (5)].Address_node), (yyvsp[(4) - (5)].Address_node), (yyvsp[(5) - (5)].Queue), ip_file->line_no));
}
break;
/* Line 1455 of yacc.c */
#line 672 "ntp_parser.y"
- { enqueue(my_config.fudge, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
+ { enqueue(cfgt.fudge, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
break;
case 141:
/* Line 1455 of yacc.c */
#line 705 "ntp_parser.y"
- { append_queue(my_config.enable_opts,(yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.enable_opts,(yyvsp[(2) - (2)].Queue)); }
break;
case 152:
/* Line 1455 of yacc.c */
#line 707 "ntp_parser.y"
- { append_queue(my_config.disable_opts,(yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.disable_opts,(yyvsp[(2) - (2)].Queue)); }
break;
case 153:
/* Line 1455 of yacc.c */
#line 731 "ntp_parser.y"
- { append_queue(my_config.tinker, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.tinker, (yyvsp[(2) - (2)].Queue)); }
break;
case 163:
/* Line 1455 of yacc.c */
#line 777 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_dval(T_Broadcastdelay, (yyvsp[(2) - (2)].Double))); }
+ { enqueue(cfgt.vars, create_attr_dval(T_Broadcastdelay, (yyvsp[(2) - (2)].Double))); }
break;
case 175:
/* Line 1455 of yacc.c */
#line 779 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_ival(T_Calldelay, (yyvsp[(2) - (2)].Integer))); }
+ { enqueue(cfgt.vars, create_attr_ival(T_Calldelay, (yyvsp[(2) - (2)].Integer))); }
break;
case 176:
/* Line 1455 of yacc.c */
#line 781 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_dval(T_Tick, (yyvsp[(2) - (2)].Double))); }
+ { enqueue(cfgt.vars, create_attr_dval(T_Tick, (yyvsp[(2) - (2)].Double))); }
break;
case 177:
/* Line 1455 of yacc.c */
#line 785 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_sval(T_Leapfile, (yyvsp[(2) - (2)].String))); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Leapfile, (yyvsp[(2) - (2)].String))); }
break;
case 179:
/* Line 1455 of yacc.c */
#line 788 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_sval(T_Pidfile, (yyvsp[(2) - (2)].String))); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Pidfile, (yyvsp[(2) - (2)].String))); }
break;
case 180:
/* Line 1455 of yacc.c */
#line 790 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_sval(T_Logfile, (yyvsp[(2) - (2)].String))); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Logfile, (yyvsp[(2) - (2)].String))); }
break;
case 181:
/* Line 1455 of yacc.c */
#line 792 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_ival(T_Automax, (yyvsp[(2) - (2)].Integer))); }
+ { enqueue(cfgt.vars, create_attr_ival(T_Automax, (yyvsp[(2) - (2)].Integer))); }
break;
case 182:
/* Line 1455 of yacc.c */
#line 795 "ntp_parser.y"
- { append_queue(my_config.logconfig, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.logconfig, (yyvsp[(2) - (2)].Queue)); }
break;
case 183:
/* Line 1455 of yacc.c */
#line 797 "ntp_parser.y"
- { append_queue(my_config.phone, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.phone, (yyvsp[(2) - (2)].Queue)); }
break;
case 184:
/* Line 1455 of yacc.c */
#line 799 "ntp_parser.y"
- { enqueue(my_config.setvar, (yyvsp[(2) - (2)].Set_var)); }
+ { enqueue(cfgt.setvar, (yyvsp[(2) - (2)].Set_var)); }
break;
case 185:
/* Line 1455 of yacc.c */
#line 801 "ntp_parser.y"
- { enqueue(my_config.trap, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
+ { enqueue(cfgt.trap, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
break;
case 186:
/* Line 1455 of yacc.c */
#line 803 "ntp_parser.y"
- { append_queue(my_config.ttl, (yyvsp[(2) - (2)].Queue)); }
+ { append_queue(cfgt.ttl, (yyvsp[(2) - (2)].Queue)); }
break;
case 187:
/* Line 1455 of yacc.c */
#line 805 "ntp_parser.y"
- { enqueue(my_config.qos, create_attr_sval(T_Qos, (yyvsp[(2) - (2)].String))); }
+ { enqueue(cfgt.qos, create_attr_sval(T_Qos, (yyvsp[(2) - (2)].String))); }
break;
case 188:
/* Line 1455 of yacc.c */
#line 809 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (1)].String))); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (1)].String))); }
break;
case 189:
/* Line 1455 of yacc.c */
#line 811 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_dval(T_WanderThreshold, (yyvsp[(2) - (2)].Double)));
- enqueue(my_config.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (2)].String))); }
+ { enqueue(cfgt.vars, create_attr_dval(T_WanderThreshold, (yyvsp[(2) - (2)].Double)));
+ enqueue(cfgt.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (2)].String))); }
break;
case 190:
/* Line 1455 of yacc.c */
#line 814 "ntp_parser.y"
- { enqueue(my_config.vars, create_attr_sval(T_Driftfile, "\0")); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, "\0")); }
break;
case 191:
/* Line 1455 of yacc.c */
#line 900 "ntp_parser.y"
{
- my_config.sim_details = create_sim_node((yyvsp[(3) - (5)].Queue), (yyvsp[(4) - (5)].Queue));
+ cfgt.sim_details = create_sim_node((yyvsp[(3) - (5)].Queue), (yyvsp[(4) - (5)].Queue));
/* Reset the old_config_style variable */
old_config_style = 1;
{
struct peer_node *my_node = create_peer_node($1, $2, $3);
if (my_node)
- enqueue(my_config.peers, my_node);
+ enqueue(cfgt.peers, my_node);
}
| client_type address
{
struct peer_node *my_node = create_peer_node($1, $2, NULL);
if (my_node)
- enqueue(my_config.peers, my_node);
+ enqueue(cfgt.peers, my_node);
}
;
{
struct unpeer_node *my_node = create_unpeer_node($2);
if (my_node)
- enqueue(my_config.unpeers, my_node);
+ enqueue(cfgt.unpeers, my_node);
}
;
unpeer_keyword
other_mode_command
: T_Broadcastclient
- { my_config.broadcastclient = SIMPLE; }
+ { cfgt.broadcastclient = SIMPLE; }
| T_Broadcastclient T_Novolley
- { my_config.broadcastclient = NOVOLLEY; }
+ { cfgt.broadcastclient = NOVOLLEY; }
| T_Manycastserver address_list
- { append_queue(my_config.manycastserver, $2); }
+ { append_queue(cfgt.manycastserver, $2); }
| T_Multicastclient address_list
- { append_queue(my_config.multicastclient, $2); }
+ { append_queue(cfgt.multicastclient, $2); }
;
authentication_command
: T_Autokey T_Integer
- { my_config.auth.autokey = $2; }
+ { cfgt.auth.autokey = $2; }
| T_ControlKey T_Integer
- { my_config.auth.control_key = $2; }
+ { cfgt.auth.control_key = $2; }
| T_Crypto crypto_command_line
{
- if (my_config.auth.crypto_cmd_list != NULL)
- append_queue(my_config.auth.crypto_cmd_list, $2);
+ if (cfgt.auth.crypto_cmd_list != NULL)
+ append_queue(cfgt.auth.crypto_cmd_list, $2);
else
- my_config.auth.crypto_cmd_list = $2;
+ cfgt.auth.crypto_cmd_list = $2;
cryptosw++;
}
| T_Keys T_String
- { my_config.auth.keys = $2; }
+ { cfgt.auth.keys = $2; }
| T_Keysdir T_String
- { my_config.auth.keysdir = $2; }
+ { cfgt.auth.keysdir = $2; }
| T_Requestkey T_Integer
- { my_config.auth.request_key = $2; }
+ { cfgt.auth.request_key = $2; }
| T_Trustedkey integer_list
- { my_config.auth.trusted_key_list = $2; }
+ { cfgt.auth.trusted_key_list = $2; }
| T_NtpSignDsocket T_String
- { my_config.auth.ntp_signd_socket = $2; }
+ { cfgt.auth.ntp_signd_socket = $2; }
;
crypto_command_line
| T_RandFile T_String
{ $$ = create_attr_sval(CRYPTO_CONF_RAND, $2); }
| T_Revoke T_Integer
- { my_config.auth.revoke = $2; }
+ { cfgt.auth.revoke = $2; }
| T_Sign T_String
{ $$ = create_attr_sval(CRYPTO_CONF_SIGN, $2); }
;
orphan_mode_command
: T_Tos tos_option_list
- { append_queue(my_config.orphan_cmds,$2); }
+ { append_queue(cfgt.orphan_cmds,$2); }
;
tos_option_list
monitoring_command
: T_Statistics stats_list
- { append_queue(my_config.stats_list, $2); }
+ { append_queue(cfgt.stats_list, $2); }
| T_Statsdir T_String
- { my_config.stats_dir = $2; }
+ { cfgt.stats_dir = $2; }
| T_Filegen stat filegen_option_list
{
- enqueue(my_config.filegen_opts,
+ enqueue(cfgt.filegen_opts,
create_filegen_node($2, $3));
}
;
access_control_command
: T_Discard discard_option_list
{
- append_queue(my_config.discard_opts, $2);
+ append_queue(cfgt.discard_opts, $2);
}
| T_Restrict address ac_flag_list
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node($2, NULL, $3, ip_file->line_no));
}
| T_Restrict T_Default ac_flag_list
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node(NULL, NULL, $3, ip_file->line_no));
}
| T_Restrict T_IPv4_flag T_Default ac_flag_list
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node(
create_address_node(
estrdup("0.0.0.0"),
}
| T_Restrict T_IPv6_flag T_Default ac_flag_list
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node(
create_address_node(
estrdup("::"),
}
| T_Restrict ip_address T_Mask ip_address ac_flag_list
{
- enqueue(my_config.restrict_opts,
+ enqueue(cfgt.restrict_opts,
create_restrict_node($2, $4, $5, ip_file->line_no));
}
;
fudge_command
: T_Fudge address fudge_factor_list
- { enqueue(my_config.fudge, create_addr_opts_node($2, $3)); }
+ { enqueue(cfgt.fudge, create_addr_opts_node($2, $3)); }
;
fudge_factor_list
system_option_command
: T_Enable system_option_list
- { append_queue(my_config.enable_opts,$2); }
+ { append_queue(cfgt.enable_opts,$2); }
| T_Disable system_option_list
- { append_queue(my_config.disable_opts,$2); }
+ { append_queue(cfgt.disable_opts,$2); }
;
system_option_list
*/
tinker_command
- : T_Tinker tinker_option_list { append_queue(my_config.tinker, $2); }
+ : T_Tinker tinker_option_list { append_queue(cfgt.tinker, $2); }
;
tinker_option_list
}
| T_Broadcastdelay number
- { enqueue(my_config.vars, create_attr_dval(T_Broadcastdelay, $2)); }
+ { enqueue(cfgt.vars, create_attr_dval(T_Broadcastdelay, $2)); }
| T_Calldelay T_Integer
- { enqueue(my_config.vars, create_attr_ival(T_Calldelay, $2)); }
+ { enqueue(cfgt.vars, create_attr_ival(T_Calldelay, $2)); }
| T_Tick number
- { enqueue(my_config.vars, create_attr_dval(T_Tick, $2)); }
+ { enqueue(cfgt.vars, create_attr_dval(T_Tick, $2)); }
| T_Driftfile drift_parm
{ /* Null action, possibly all null parms */ }
| T_Leapfile T_String
- { enqueue(my_config.vars, create_attr_sval(T_Leapfile, $2)); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Leapfile, $2)); }
| T_Pidfile T_String
- { enqueue(my_config.vars, create_attr_sval(T_Pidfile, $2)); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Pidfile, $2)); }
| T_Logfile T_String
- { enqueue(my_config.vars, create_attr_sval(T_Logfile, $2)); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Logfile, $2)); }
| T_Automax T_Integer
- { enqueue(my_config.vars, create_attr_ival(T_Automax, $2)); }
+ { enqueue(cfgt.vars, create_attr_ival(T_Automax, $2)); }
| T_Logconfig log_config_list
- { append_queue(my_config.logconfig, $2); }
+ { append_queue(cfgt.logconfig, $2); }
| T_Phone string_list
- { append_queue(my_config.phone, $2); }
+ { append_queue(cfgt.phone, $2); }
| T_Setvar variable_assign
- { enqueue(my_config.setvar, $2); }
+ { enqueue(cfgt.setvar, $2); }
| T_Trap ip_address trap_option_list
- { enqueue(my_config.trap, create_addr_opts_node($2, $3)); }
+ { enqueue(cfgt.trap, create_addr_opts_node($2, $3)); }
| T_Ttl integer_list
- { append_queue(my_config.ttl, $2); }
+ { append_queue(cfgt.ttl, $2); }
| T_Qos T_String
- { enqueue(my_config.qos, create_attr_sval(T_Qos, $2)); }
+ { enqueue(cfgt.qos, create_attr_sval(T_Qos, $2)); }
;
drift_parm
: T_String
- { enqueue(my_config.vars, create_attr_sval(T_Driftfile, $1)); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, $1)); }
| T_String T_Double
- { enqueue(my_config.vars, create_attr_dval(T_WanderThreshold, $2));
- enqueue(my_config.vars, create_attr_sval(T_Driftfile, $1)); }
+ { enqueue(cfgt.vars, create_attr_dval(T_WanderThreshold, $2));
+ enqueue(cfgt.vars, create_attr_sval(T_Driftfile, $1)); }
| /* Null driftfile, indicated by null string "\0" */
- { enqueue(my_config.vars, create_attr_sval(T_Driftfile, "\0")); }
+ { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, "\0")); }
;
variable_assign
simulate_command
: sim_conf_start '{' sim_init_statement_list sim_server_list '}'
{
- my_config.sim_details = create_sim_node($3, $4);
+ cfgt.sim_details = create_sim_node($3, $4);
/* Reset the old_config_style variable */
old_config_style = 1;
/* SCANNER GLOBAL VARIABLES
* ------------------------
*/
-extern struct state *key_scanner; /* A FSA for recognizing keywords */
-extern struct config_tree my_config;/* Root of the configuration tree */
-extern int curr_include_level; /* The current include level */
+extern struct state *key_scanner; /* A FSA for recognizing keywords */
+extern struct config_tree cfgt; /* Parser output stored here */
+extern int curr_include_level; /* The current include level */
-extern struct FILE_INFO *ip_file; /* Pointer to the configuration file stream */
+extern struct FILE_INFO *ip_file; /* Pointer to the configuration file stream */
/* VARIOUS EXTERNAL DECLARATIONS
* -----------------------------