]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
maintain history of config trees
authorDave Hart <hart@ntp.org>
Thu, 6 Aug 2009 12:04:59 +0000 (12:04 +0000)
committerDave Hart <hart@ntp.org>
Thu, 6 Aug 2009 12:04:59 +0000 (12:04 +0000)
bk: 4a7ac6eb0Zf6-tWp7vG8nfBZN05zWg

include/ntp_config.h
include/ntp_data_structures.h
libntp/ntp_lineedit.c
ntpd/ntp_config.c
ntpd/ntp_data_structures.c
ntpd/ntp_parser.c
ntpd/ntp_parser.y
ntpd/ntp_scanner.h

index b28dc08ead290a671dc738724800e5ac7ec9311f..a2e2e031ddfcfa967ff550ebd4214f27e9661a2d 100644 (file)
@@ -125,49 +125,11 @@ enum broadcastclienttype {
     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;
 
index 21f28c8f92258725073587dde8089ee4bf17e8f0..363e0b47a4e9b3987bc9eb43a98fa51f3e4e67e5 100644 (file)
@@ -32,14 +32,6 @@ typedef struct Queue {
     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
  * -------------------
index ca3c7c310080588c9f41071dd6897ed10a5f999e..9a74c5697cda7a98c378d11528054a01c937b609 100644 (file)
@@ -65,13 +65,12 @@ ntp_readline_init(
        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) {
@@ -189,7 +188,7 @@ ntp_readline(
        if (NULL != cline && *cline) {
                history(ntp_hist, &hev, H_ENTER, cline);
                *pcount = strlen(cline);
-               line = strdup(cline);
+               line = estrdup(cline);
        } else
                line = NULL;
 
@@ -210,7 +209,7 @@ ntp_readline(
                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);
index 0a5bac5f9926f4e5d640ee8cb843a254669da953..ea0f82b4a4a7151a4d90d0eadf42debb6029efa7 100644 (file)
@@ -130,8 +130,8 @@ static char res_file[MAX_PATH];
 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
@@ -208,10 +208,15 @@ static void init_auth_node(struct config_tree *);
 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
@@ -231,17 +236,14 @@ static void config_ttl(struct config_tree *);
 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 */
@@ -295,15 +297,7 @@ init_auth_node(
        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
@@ -338,26 +332,21 @@ init_syntax_tree(
        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();
@@ -365,21 +354,35 @@ init_syntax_tree(
        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);
@@ -407,10 +410,12 @@ free_syntax_trees(void)
        DESTROY_QUEUE(ptree->vars);
 
        free_auth_node(ptree);
-#endif // !!!!
+
+       free(ptree);
 }
 #endif /* DEBUG */
 
+
 /* The config dumper */
 int
 dump_config_tree(
@@ -2055,21 +2060,16 @@ free_config_auth(
        )
 {
        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 */
 
@@ -3444,26 +3444,32 @@ config_ntpdsim(
 }
 #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,
@@ -3543,7 +3549,7 @@ getconfig(
 
        /*** 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();
        
@@ -3552,16 +3558,7 @@ getconfig(
 
        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--]);
@@ -3587,6 +3584,34 @@ getconfig(
 }
 
 
+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
  * --------------------------------------------
@@ -3670,7 +3695,7 @@ get_netinfo_config(void)
        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;
 
@@ -3688,12 +3713,12 @@ get_netinfo_config(void)
                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;
 }
@@ -3733,33 +3758,37 @@ gettokens_netinfo (
         */
   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;
 
@@ -3771,14 +3800,14 @@ gettokens_netinfo (
        }
 
        /* 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];
@@ -3796,8 +3825,10 @@ gettokens_netinfo (
                                break;
                        } else {                /* must be space */
                                *tokens++ = '\0';
-                               while (ISSPACE(*tokens)) tokens++;
-                               if (ISEOL(*tokens)) break;
+                               while (ISSPACE(*tokens))
+                                       tokens++;
+                               if (ISEOL(*tokens))
+                                       break;
                        }
                }
 
@@ -3821,7 +3852,9 @@ gettokens_netinfo (
        /* 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;
 }
index b48c518d5c9a7c13c416e542a494c21125f6b02a..fb21529be56b0f74427d82f9718a7cc857688ed7 100644 (file)
@@ -82,7 +82,10 @@ next_node(
        pn = pv;
        pn--;
 
-       return pn->node_next;
+       if (pn->node_next == NULL)
+               return NULL;
+
+       return pn->node_next + 1;
 }
 
 
@@ -98,7 +101,7 @@ queue_head(
        queue *q
        )
 {
-       if (NULL == q->front)
+       if (NULL == q || NULL == q->front)
                return NULL;
                
        return q->front + 1;
index 13cee59af93b1a32b71d6f2e1ab061799a903a68..23cefeb24809baeef5ac045f215f8e61a23eff37 100644 (file)
@@ -2168,7 +2168,7 @@ yyreduce:
     {
                        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;
 
@@ -2179,7 +2179,7 @@ yyreduce:
     {
                        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;
 
@@ -2372,7 +2372,7 @@ yyreduce:
     {
                        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;
 
@@ -2394,42 +2394,42 @@ yyreduce:
 
 /* 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:
@@ -2437,10 +2437,10 @@ yyreduce:
 /* 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;
@@ -2449,35 +2449,35 @@ yyreduce:
 
 /* 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:
@@ -2533,7 +2533,7 @@ yyreduce:
 
 /* 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:
@@ -2547,7 +2547,7 @@ yyreduce:
 
 /* 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:
@@ -2645,14 +2645,14 @@ yyreduce:
 
 /* 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:
@@ -2660,7 +2660,7 @@ yyreduce:
 /* 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;
@@ -2845,7 +2845,7 @@ yyreduce:
 /* 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;
 
@@ -2854,7 +2854,7 @@ yyreduce:
 /* 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;
@@ -2864,7 +2864,7 @@ yyreduce:
 /* 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;
@@ -2874,7 +2874,7 @@ yyreduce:
 /* 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"), 
@@ -2892,7 +2892,7 @@ yyreduce:
 /* 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("::"), 
@@ -2910,7 +2910,7 @@ yyreduce:
 /* 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;
@@ -3059,7 +3059,7 @@ yyreduce:
 
 /* 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:
@@ -3136,14 +3136,14 @@ yyreduce:
 
 /* 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:
@@ -3213,7 +3213,7 @@ yyreduce:
 
 /* 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:
@@ -3314,21 +3314,21 @@ yyreduce:
 
 /* 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:
@@ -3342,92 +3342,92 @@ yyreduce:
 
 /* 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:
@@ -3592,7 +3592,7 @@ yyreduce:
 /* 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;
index e181c855fa035d24c75f4795c2c8b25d7898737e..9ebc8638ef3e89999b98058801fb505699c47349 100644 (file)
@@ -328,13 +328,13 @@ server_command
                {
                        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);
                }
        ;
 
@@ -389,7 +389,7 @@ unpeer_command
                {
                        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 
@@ -405,13 +405,13 @@ 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); }
        ;
 
 
@@ -422,27 +422,27 @@ other_mode_command
 
 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
@@ -466,7 +466,7 @@ crypto_command
        |       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); }
        ;
@@ -478,7 +478,7 @@ crypto_command
 
 orphan_mode_command
        :       T_Tos tos_option_list
-                       { append_queue(my_config.orphan_cmds,$2); }
+                       { append_queue(cfgt.orphan_cmds,$2); }
        ;
 
 tos_option_list
@@ -518,12 +518,12 @@ tos_option
 
 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));
                }
        ;
@@ -586,21 +586,21 @@ filegen_type
 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"), 
@@ -613,7 +613,7 @@ access_control_command
                }
        |       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("::"), 
@@ -626,7 +626,7 @@ access_control_command
                }
        |       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));
                }
        ;
@@ -669,7 +669,7 @@ discard_option
 
 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
@@ -702,9 +702,9 @@ fudge_factor
 
 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
@@ -728,7 +728,7 @@ system_option
  */
 
 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
@@ -774,44 +774,44 @@ miscellaneous_command
                }
 
        |       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
@@ -898,7 +898,7 @@ number
 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;
index 31c16a76b3f3d295ecf373c3c8aa9b4f878d52cd..f1f4d372597e8af9f93f6689e30290d73ad0bdbe 100644 (file)
@@ -45,11 +45,11 @@ struct FILE_INFO {
 /* 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
  * -----------------------------