From: Dave Hart Date: Mon, 21 Sep 2009 00:10:58 +0000 (+0000) Subject: [Bug 1314] saveconfig emits -4 and -6 on when not given. X-Git-Tag: NTP_4_2_5P218~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd8ad85c50684ab1deed6c8d8d50323c34650e40;p=thirdparty%2Fntp.git [Bug 1314] saveconfig emits -4 and -6 on when not given. clarify (former) NO_ARG, SINGLE_ARG, MULTIPLE_ARG renaming to FOLLBY_TOKEN, FOLLBY_STRING, FOLLBY_STRINGS_TO_EOC. parser, saveconfig cleanup to store T_ identifiers in syntax tree. bk: 4ab6c492W-FT2qIfUxuIbg--lBR78A --- diff --git a/ChangeLog b/ChangeLog index 00b02f458..5b7603fb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +* [Bug 1314] saveconfig emits -4 and -6 on when not given. +* clarify (former) NO_ARG, SINGLE_ARG, MULTIPLE_ARG renaming to + FOLLBY_TOKEN, FOLLBY_STRING, FOLLBY_STRINGS_TO_EOC. +* parser, saveconfig cleanup to store T_ identifiers in syntax tree. * [Bug 1300] reject remote configuration of dangerous items. (4.2.5p216) 2009/09/19 Released by Harlan Stenn * [Bug 1312] ntpq/ntpdc MD5 passwords truncated to 8 chars on Suns. diff --git a/include/ntp_config.h b/include/ntp_config.h index 27860a781..d54ecde04 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -79,13 +79,12 @@ struct restrict_node { struct peer_node { int host_mode; struct address_node *addr; - queue *options; + queue *peerflags; int minpoll; int maxpoll; int ttl; int peerversion; int peerkey; - int peerflags; double bias; }; @@ -96,6 +95,7 @@ struct unpeer_node { struct auth_node { int control_key; + int cryptosw; queue *crypto_cmd_list; char *keys; char *keysdir; @@ -106,14 +106,13 @@ struct auth_node { }; struct filegen_node { - char *name; - queue *options; + int filegen_token; + queue * options; }; struct setvar_node { - char *data; - u_long len; - u_short def; + char * data; + int isdefault; }; typedef struct nic_rule_node_tag { @@ -201,7 +200,7 @@ struct attr_val *create_attr_dval(int attr, double value); struct attr_val *create_attr_ival(int attr, int value); struct attr_val *create_attr_sval(int attr, char *s); struct attr_val *create_attr_pval(int attr, void *s); -struct filegen_node *create_filegen_node(void **name, queue *options); +struct filegen_node *create_filegen_node(int filegen_token, queue *options); void **create_pval(void *val); struct restrict_node *create_restrict_node(struct address_node *addr, struct address_node *mask, @@ -211,7 +210,7 @@ struct addr_opts_node *create_addr_opts_node(struct address_node *addr, queue *options); struct sim_node *create_sim_node(queue *init_opts, queue *servers); struct setvar_node *create_setvar_node(char *var, char *val, - u_short def); + int isdefault); nic_rule_node *create_nic_rule_node(int match_class, char *if_name, int action); diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 2334e1e88..b49a7c480 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -491,7 +491,7 @@ dump_config_tree( FILE *df ) { - struct peer_node *peers = NULL; + struct peer_node *peer = NULL; struct unpeer_node *unpeers = NULL; struct attr_val *atrv = NULL; struct address_node *addr = NULL; @@ -503,18 +503,17 @@ dump_config_tree( struct setvar_node *setv_node = NULL; nic_rule_node *rule_node; - char **string = NULL; + char **pstr = NULL; char *s1; char *s2; - int *integer = NULL; + int *intp = NULL; int *key_val; void *fudge_ptr; void *list_ptr = NULL; void *options = NULL; void *opt_ptr = NULL; - void *flags = NULL; + int *flags = NULL; void *opts = NULL; - char refid[5]; char timestamp[80]; int enable; @@ -533,62 +532,48 @@ dump_config_tree( /* For options I didn't find documentation I'll just output its name and the cor. value */ list_ptr = queue_head(ptree->vars); - if (list_ptr != NULL) { - - for(; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - - atrv = (struct attr_val *) list_ptr; + for(; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - switch (atrv->attr) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown vars token %d\n", - atrv->attr); - break; + atrv = (struct attr_val *) list_ptr; - case T_Broadcastdelay: - fprintf(df, "broadcastdelay %g\n", atrv->value.d); - break; - - case T_Calldelay: - fprintf(df, "calldelay %i\n", atrv->value.i); - break; + switch (atrv->attr) { - case T_Tick: - fprintf(df, "tick %g\n", atrv->value.d); - break; + default: + fprintf(df, "\n# dump error:\n" + "# unknown vars token %s\n", + token_name(atrv->attr)); + break; - case T_Driftfile: - fprintf(df, "driftfile \"%s\"\n", atrv->value.s); - break; + /* doubles */ + case T_Broadcastdelay: + case T_Tick: + case T_WanderThreshold: + fprintf(df, "%s %g\n", + keyword(atrv->attr), + atrv->value.d); + break; - case T_WanderThreshold: - fprintf(df, "wander_threshold %g\n", atrv->value.d); - break; - - case T_Leapfile: - fprintf(df, "leapfile \"%s\"\n", atrv->value.s); - break; - - case T_Pidfile: - fprintf(df, "pidfile \"%s\"\n", atrv->value.s); - break; - - case T_Logfile: - fprintf(df, "logfile \"%s\"\n", atrv->value.s); - break; - - case T_Saveconfigdir: - fprintf(df, "saveconfigdir \"%s\"\n", - atrv->value.s); - break; + /* ints */ + case T_Calldelay: #ifdef OPENSSL - case T_Automax: - fprintf(df, "automax %i\n", atrv->value.i); - break; + case T_Automax: #endif - } + fprintf(df, "%s %d\n", + keyword(atrv->attr), + atrv->value.i); + break; + + /* strings */ + case T_Driftfile: + case T_Leapfile: + case T_Logfile: + case T_Pidfile: + case T_Saveconfigdir: + fprintf(df, "%s \"%s\"\n", + keyword(atrv->attr), + atrv->value.s); + break; } } @@ -599,8 +584,8 @@ dump_config_tree( for(; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - atrv = (struct attr_val *) list_ptr; + atrv = list_ptr; fprintf(df, " %c%s", atrv->attr, atrv->value.s); } fprintf(df, "\n"); @@ -616,11 +601,9 @@ dump_config_tree( for(; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - string = (char **) list_ptr; - - /* FIXME Find keyword and type of information */ + intp = list_ptr; - fprintf(df, " %s", *string); + fprintf(df, " %s", keyword(*intp)); } fprintf(df, "\n"); @@ -636,7 +619,8 @@ dump_config_tree( opt_ptr = queue_head(fgen_node->options); if (opt_ptr != NULL) - fprintf(df, "filegen %s", fgen_node->name); + fprintf(df, "filegen %s", + keyword(fgen_node->filegen_token)); for(; opt_ptr != NULL; opt_ptr = next_node(opt_ptr)) { @@ -650,78 +634,22 @@ dump_config_tree( "# unknown filegen option token %d\n" "filegen %s", atrv->type, - fgen_node->name); + keyword(fgen_node->filegen_token)); break; case T_File: - fprintf(df, " file %s", atrv->value.s); + fprintf(df, " file %s", + atrv->value.s); break; case T_Type: - fprintf(df, " type "); - - switch (atrv->value.i) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown filegen type %d\n" - "filegen %s type ", - atrv->value.i, - fgen_node->name); - break; - - case FILEGEN_NONE: - fprintf(df, "none"); - break; - - case FILEGEN_DAY: - fprintf(df, "day"); - break; - - case FILEGEN_MONTH: - fprintf(df, "month"); - break; - - case FILEGEN_PID: - fprintf(df, "pid"); - break; - - case FILEGEN_WEEK: - fprintf(df, "week"); - break; - - case FILEGEN_YEAR: - fprintf(df, "year"); - break; - } + fprintf(df, " type %s", + keyword(atrv->value.i)); break; - case T_Flag: - switch (atrv->value.i) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown filegen flag token %d\n" - "filegen %s", - atrv->value.i, - fgen_node->name); - break; - - case T_Link: - fprintf(df, " link"); - break; - - case T_Nolink: - fprintf(df, " nolink"); - break; - - case T_Enable: - fprintf(df, " enable"); - break; - - case T_Disable: - fprintf(df, " disable"); - break; - } + case T_Flag: + fprintf(df, " %s", + keyword(atrv->value.i)); break; } @@ -731,6 +659,23 @@ dump_config_tree( } } + list_ptr = queue_head(ptree->auth.crypto_cmd_list); + if (ptree->auth.revoke != 0 || list_ptr != NULL) { + fprintf(df, "crypto"); + + if (ptree->auth.revoke != 0) + fprintf(df, " revoke %d", ptree->auth.revoke); + + for (; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { + + atrv = list_ptr; + fprintf(df, " %s %s", keyword(atrv->attr), + atrv->value.s); + } + fprintf(df, "\n"); + } + if (NULL != ptree->auth.keysdir) fprintf(df, "keysdir \"%s\"\n", ptree->auth.keysdir); @@ -759,125 +704,64 @@ dump_config_tree( ? queue_head(ptree->enable_opts) : queue_head(ptree->disable_opts); - if (list_ptr != NULL) + if (list_ptr != NULL) { fprintf(df, (enable) ? "enable" : "disable"); - for(; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - - atrv = (struct attr_val *) list_ptr; - - switch (atrv->value.i) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown enable/disable token %d\n" - "%s", atrv->value.i, - (enable) - ? "enable" - : "disable"); - break; - - case T_Auth: - fprintf(df, " auth"); - break; - - case T_Bclient: - fprintf(df, " bclient"); - break; - - case T_Calibrate: - fprintf(df, " calibrate"); - break; - - case T_Kernel: - fprintf(df, " kernel"); - break; - - case T_Monitor: - fprintf(df, " monitor"); - break; + for(; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - case T_Ntp: - fprintf(df, " ntp"); - break; + atrv = (struct attr_val *) list_ptr; - case T_Stats: - fprintf(df, " stats"); - break; + fprintf(df, " %s", + keyword(atrv->value.i)); } + fprintf(df, "\n"); } - fprintf(df, "\n"); } - list_ptr = queue_head(ptree->orphan_cmds); - if (list_ptr != NULL) { - + if (list_ptr != NULL) fprintf(df, "tos"); - for(; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - - atrv = (struct attr_val *) list_ptr; - - switch (atrv->attr) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown tos token %d\n" - "tos", atrv->attr); - break; - - case PROTO_CEILING: - fprintf(df, " ceiling %d", (int)atrv->value.d); - break; - - case PROTO_FLOOR: - fprintf(df, " floor %d", (int)atrv->value.d); - break; - - case PROTO_COHORT: - fprintf(df, " cohort %d", !!(atrv->value.d)); - break; - - case PROTO_ORPHAN: - fprintf(df, " orphan %d", (int)atrv->value.d); - break; - - case PROTO_MINDISP: - fprintf(df, " mindist %g", atrv->value.d); - break; - - case PROTO_MAXDIST: - fprintf(df, " maxdist %g", atrv->value.d); - break; + for(; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - case PROTO_MINCLOCK: - fprintf(df, " minclock %d", (int)atrv->value.d); - break; + atrv = list_ptr; - case PROTO_MAXCLOCK: - fprintf(df, " maxclock %d", (int)atrv->value.d); - break; + switch (atrv->attr) { - case PROTO_MINSANE: - fprintf(df, " minsane %d", (int)atrv->value.d); - break; + default: + fprintf(df, "\n# dump error:\n" + "# unknown tos token %s\n" + "tos", token_name(atrv->attr)); + break; - case PROTO_BEACON: - fprintf(df, " beacon %d", (int)atrv->value.d); - break; + /* ints */ + case T_Ceiling: + case T_Floor: + case T_Cohort: + case T_Orphan: + case T_Minclock: + case T_Maxclock: + case T_Minsane: + case T_Beacon: + case T_Maxhop: + fprintf(df, " %s %d", keyword(atrv->attr), + (int)atrv->value.d); + break; - case PROTO_MAXHOP: - fprintf(df, " maxhop %d", (int)atrv->value.d); - break; - } + /* doubles */ + case T_Mindist: + case T_Maxdist: + fprintf(df, " %s %g", keyword(atrv->attr), + atrv->value.d); + break; } - - fprintf(df, "\n"); } + if (queue_head(ptree->orphan_cmds) != NULL) + fprintf(df, "\n"); list_ptr = queue_head(ptree->tinker); if (list_ptr != NULL) { @@ -887,45 +771,9 @@ dump_config_tree( for(; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - atrv = (struct attr_val *) list_ptr; - - switch (atrv->attr) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown tinker token %d\n" - "tinker", atrv->attr); - break; - - case LOOP_MAX: - fprintf(df, " step"); - break; - - case LOOP_PANIC: - fprintf(df, " panic"); - break; - - case LOOP_PHI: - fprintf(df, " dispersion"); - break; - - case LOOP_MINSTEP: - fprintf(df, " stepout"); - break; - - case LOOP_ALLAN: - fprintf(df, " allan"); - break; - - case LOOP_HUFFPUFF: - fprintf(df, " huffpuff"); - break; - - case LOOP_FREQ: - fprintf(df, " freq"); - break; - } - - fprintf(df, " %g", atrv->value.d); + atrv = list_ptr; + fprintf(df, " %s %g", keyword(atrv->attr), + atrv->value.d); } fprintf(df, "\n"); @@ -938,227 +786,120 @@ dump_config_tree( for (; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - peers = (struct peer_node *) list_ptr; - addr = peers->addr; - - switch (peers->host_mode) { + peer = list_ptr; + addr = peer->addr; + fprintf(df, "%s", keyword(peer->host_mode)); + + switch (addr->type) { default: fprintf(df, "# dump error:\n" - "# unknown peer token %d for:\n" - "peer ", peers->host_mode); + "# unknown peer family %d for:\n" + "peer", addr->type); break; - case T_Peer: - fprintf(df, "peer"); + case AF_UNSPEC: break; - case T_Server: - fprintf(df, "server"); + case AF_INET: + fprintf(df, " -4"); break; - case T_Broadcast: - fprintf(df, "broadcast"); + case AF_INET6: + fprintf(df, " -6"); break; - - case T_Manycastclient: - fprintf(df, "manycastclient"); - break; - } - - if (addr->type != AF_UNSPEC) { - switch (addr->type) { - - default: - fprintf(df, "# dump error:\n" - "# unknown peer family %d for:\n" - "peer", addr->type); - break; - - case AF_INET: - fprintf(df, " -4"); - break; - - case AF_INET6: - fprintf(df, " -6"); - break; - } } fprintf(df, " %s", addr->address); - for (atrv = queue_head(peers->options); - atrv != NULL; - atrv = next_node(atrv)) { - - switch (atrv->attr) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown peer option token %d\n" - "# remaining options:", - atrv->attr); - break; + if (peer->minpoll != 0) + fprintf(df, " minpoll %d", peer->minpoll); - case T_Flag: - switch (atrv->type) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown peer flag type %d\n" - "# remaining options:", - atrv->type); - break; - - case T_Integer: - switch (atrv->value.i) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown peer flag 0x%x\n" - "# remaining options:", - (unsigned)atrv->value.i); - break; + if (peer->maxpoll != 0) + fprintf(df, " maxpoll %d", peer->maxpoll); - case FLAG_SKEY: - fprintf(df, " autokey"); - break; - - case FLAG_BURST: - fprintf(df, " burst"); - break; - - case FLAG_IBURST: - fprintf(df, " iburst"); - break; + if (peer->ttl != 0) + fprintf(df, " ttl %d", peer->ttl); - case FLAG_NOSELECT: - fprintf(df, " noselect"); - break; + if (peer->peerversion != NTP_VERSION) + fprintf(df, " version %d", peer->peerversion); - case FLAG_PREEMPT: - fprintf(df, " preempt"); - break; + if (peer->peerkey != 0) + fprintf(df, " key %d", peer->peerkey); - case FLAG_PREFER: - fprintf(df, " prefer"); - break; - - case FLAG_TRUE: - fprintf(df, " true"); - break; + if (peer->bias != 0.) + fprintf(df, " bias %g", peer->bias); - case FLAG_XLEAVE: - fprintf(df, " xleave"); - break; - } - break; - } - break; - - case T_Bias: - fprintf(df, " bias %g", atrv->value.d); - break; - - case T_Key: - fprintf(df, " key %d", atrv->value.i); - break; - - case T_Minpoll: - fprintf(df, " minpoll %d", atrv->value.i); - break; - - case T_Maxpoll: - fprintf(df, " maxpoll %d", atrv->value.i); - break; - - case T_Ttl: - fprintf(df, " ttl %d", atrv->value.i); - break; + for (atrv = queue_head(peer->peerflags); + atrv != NULL; + atrv = next_node(atrv)) { - case T_Mode: - fprintf(df, " mode %d", atrv->value.i); - break; - - case T_Version: - fprintf(df, " version %d", atrv->value.i); - break; - } + NTP_INSIST(T_Flag == atrv->attr); + NTP_INSIST(T_Integer == atrv->type); + fprintf(df, " %s", keyword(atrv->value.i)); } fprintf(df, "\n"); fudge_ptr = queue_head(ptree->fudge); - if (fudge_ptr != NULL) { + for(; fudge_ptr != NULL; + fudge_ptr = next_node(fudge_ptr)) { + - for(; fudge_ptr != NULL; - fudge_ptr = next_node(fudge_ptr)) { + addr_opts = (struct addr_opts_node *) fudge_ptr; + peer_addr = peer->addr; + fudge_addr = addr_opts->addr; + s1 = peer_addr->address; + s2 = fudge_addr->address; - addr_opts = (struct addr_opts_node *) fudge_ptr; - peer_addr = peers->addr; - fudge_addr = addr_opts->addr; + if (!strcmp(s1, s2)) { + + fprintf(df, "fudge %s", addr_opts->addr->address); + + opts = queue_head(addr_opts->options); - s1 = peer_addr->address; - s2 = fudge_addr->address; + for(; opts != NULL; opts = next_node(opts)) { + atrv = (struct attr_val *) opts; + + switch (atrv->attr) { - if (!strcmp(s1, s2)) { + default: + fprintf(df, "\n# dump error:\n" + "# unknown fudge option %s\n" + "fudge %s", + token_name(atrv->attr), + addr_opts->addr->address); + break; - fprintf(df, "fudge %s", addr_opts->addr->address); + /* doubles */ + case T_Time1: + case T_Time2: + fprintf(df, " %s %g", + keyword(atrv->attr), + atrv->value.d); + break; - opts = queue_head(addr_opts->options); + /* ints */ + case T_Stratum: + case T_Flag1: + case T_Flag2: + case T_Flag3: + case T_Flag4: + fprintf(df, " %s %d", + keyword(atrv->attr), + atrv->value.i); + break; - for(; opts != NULL; opts = next_node(opts)) { - atrv = (struct attr_val *) opts; - - switch (atrv->attr) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown fudge CLK_ value %d\n" - "fudge %s", atrv->attr, - addr_opts->addr->address); - break; - - case CLK_HAVETIME1: - fprintf(df, " time1 %g", atrv->value.d); - break; - - case CLK_HAVETIME2: - fprintf(df, " time2 %g", atrv->value.d); - break; - - case CLK_HAVEVAL1: - fprintf(df, " stratum %i", atrv->value.i); - break; - - case CLK_HAVEVAL2: - memset(refid, 0, sizeof(refid)); - memcpy(refid, atrv->value.s, - min(strlen(atrv->value.s), 4)); - - fprintf(df, " refid %s", refid); - break; - - case CLK_HAVEFLAG1: - fprintf(df, " flag1 %d", !!atrv->value.i); - break; - - case CLK_HAVEFLAG2: - fprintf(df, " flag2 %d", !!atrv->value.i); - break; - - case CLK_HAVEFLAG3: - fprintf(df, " flag3 %d", !!atrv->value.i); - break; - - case CLK_HAVEFLAG4: - fprintf(df, " flag4 %d", !!atrv->value.i); - break; - } + /* strings */ + case T_Refid: + fprintf(df, " %s %s", + keyword(atrv->attr), + atrv->value.s); + break; } - fprintf(df, "\n"); } + fprintf(df, "\n"); } } } @@ -1185,201 +926,71 @@ dump_config_tree( list_ptr != NULL; list_ptr = next_node(list_ptr)) { - addr = (struct address_node *) list_ptr; - fprintf(df, " %s", addr->address); - } - fprintf(df, "\n"); - } - - list_ptr = queue_head(ptree->unpeers); - for (; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - - unpeers = (struct unpeer_node *) list_ptr; - - fprintf(df, "unpeer %s\n", (unpeers->addr)->address); - } - - list_ptr = queue_head(ptree->discard_opts); - if (list_ptr != NULL) { - - fprintf(df, "discard"); - - for(; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - - atrv = (struct attr_val *) list_ptr; - - switch (atrv->attr) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown discard token %d\n" - "discard ", atrv->attr); - break; - - case T_Average: - fprintf(df, " average %i", atrv->value.i); - break; - - case T_Minimum: - fprintf(df, " minimum %i", atrv->value.i); - break; - - case T_Monitor: - fprintf(df, " monitor %i", atrv->value.i); - } - - } - fprintf(df, "\n"); - } - - list_ptr = queue_head(ptree->restrict_opts); - if (list_ptr != NULL) { - - for (; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - - rest_node = (struct restrict_node *) list_ptr; - - if (NULL == rest_node->addr) - s1 = "default"; - else - s1 = rest_node->addr->address; - - fprintf(df, "restrict %s", s1); - - if (rest_node->mask != NULL) - fprintf(df, " %s", rest_node->mask->address); - - flags = queue_head(rest_node->flags); - - for (; flags != NULL; flags = next_node(flags)) { - int *curr_flag = flags; - - switch (*curr_flag) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown restrict token %d\n" - "restrict %s", - *curr_flag, - s1); - if (rest_node->mask != NULL) - fprintf(df, " %s", rest_node->mask->address); - break; - - case RES_TIMEOUT: - fprintf(df, " flake"); - break; - - case RES_IGNORE: - fprintf(df, " ignore"); - break; - - case RES_LIMITED: - fprintf(df, " limited"); - break; - - case RES_KOD: - fprintf(df, " kod"); - break; - - case RES_LPTRAP: - fprintf(df, " lowpriotrap"); - break; - - case RES_NOMODIFY: - fprintf(df, " nomodify"); - break; - - case RES_NOQUERY: - fprintf(df, " noquery"); - break; - - case RES_NOPEER: - fprintf(df, " nopeer"); - break; - - case RES_DONTSERVE: - fprintf(df, " noserve"); - break; - - case RES_NOTRAP: - fprintf(df, " notrap"); - break; - - case RES_DONTTRUST: - fprintf(df, " notrust"); - break; - - case RESM_NTPONLY: - fprintf(df, " ntpport"); - break; - - case RES_VERSION: - fprintf(df, " version"); - break; - } - } - fprintf(df, "\n"); + addr = (struct address_node *) list_ptr; + fprintf(df, " %s", addr->address); } + fprintf(df, "\n"); } - list_ptr = queue_head(ptree->nic_rules); - for (; list_ptr != NULL; + list_ptr = queue_head(ptree->unpeers); + for (; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - rule_node = list_ptr; - - fprintf(df, "interface "); - - switch (rule_node->action) { + + unpeers = (struct unpeer_node *) list_ptr; + + fprintf(df, "unpeer %s\n", (unpeers->addr)->address); + } - default: - fprintf(df, "\n# dump error:\n" - "# unknown nic action %d\n", - rule_node->action); - break; + list_ptr = queue_head(ptree->discard_opts); + if (list_ptr != NULL) { - case T_Listen: - fprintf(df, "listen "); - break; + fprintf(df, "discard"); - case T_Ignore: - fprintf(df, "ignore "); - break; + for(; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - case T_Drop: - fprintf(df, "drop "); - break; + atrv = list_ptr; + fprintf(df, " %s %d", keyword(atrv->attr), + atrv->value.i); } + fprintf(df, "\n"); + } - switch (rule_node->match_class) { - - default: - fprintf(df, "\n# dump error:\n" - "# unknown nic match class %d\n", - rule_node->match_class); - break; + list_ptr = queue_head(ptree->restrict_opts); + for (; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - case 0: /* interface name or address */ - fprintf(df, "%s", rule_node->if_name); - break; + rest_node = list_ptr; + if (NULL == rest_node->addr) + s1 = "default"; + else + s1 = rest_node->addr->address; - case T_All: - fprintf(df, "all"); - break; + fprintf(df, "restrict %s", s1); - case T_Ipv4: - fprintf(df, "ipv4"); - break; + if (rest_node->mask != NULL) + fprintf(df, " mask %s", + rest_node->mask->address); - case T_Ipv6: - fprintf(df, "ipv6"); - break; - } + flags = queue_head(rest_node->flags); + for (; flags != NULL; flags = next_node(flags)) + fprintf(df, " %s", keyword(*flags)); fprintf(df, "\n"); } + list_ptr = queue_head(ptree->nic_rules); + for (; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { + + rule_node = list_ptr; + fprintf(df, "interface %s %s\n", + keyword(rule_node->action), + (rule_node->match_class) + ? keyword(rule_node->match_class) + : rule_node->if_name); + } + list_ptr = queue_head(ptree->phone); if (list_ptr != NULL) { @@ -1387,9 +998,9 @@ dump_config_tree( for(; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - string = list_ptr; - fprintf(df, " %s", *string); + pstr = list_ptr; + fprintf(df, " %s", *pstr); } fprintf(df, "\n"); @@ -1402,8 +1013,8 @@ dump_config_tree( for(; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - atrv = (struct attr_val *) list_ptr; + atrv = list_ptr; fprintf(df, " %s", atrv->value.s); } @@ -1411,31 +1022,19 @@ dump_config_tree( } list_ptr = queue_head(ptree->setvar); - if (list_ptr != NULL) { - - fprintf(df, "setvar"); - - for(; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { - u_long a = 0; - char *data = NULL; - - setv_node = (struct setvar_node *) list_ptr; - data = setv_node->data; + for(; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - fprintf(df, " "); + setv_node = list_ptr; + fprintf(df, "setvar %s", setv_node->data); - for(a=0; alen; a++) - if(data[a] == '=') - fprintf(df, " "); - else - fprintf(df, "%c", data[a]); + if (setv_node->isdefault) + fprintf(df, " default"); - if(setv_node->def) - fprintf(df, " default"); - } + fprintf(df, "\n"); } + list_ptr = queue_head(ptree->ttl); if (list_ptr != NULL) { @@ -1443,53 +1042,51 @@ dump_config_tree( for(; list_ptr != NULL; list_ptr = next_node(list_ptr)) { - integer = (int *) list_ptr; - fprintf(df, " %i", *integer); + intp = list_ptr; + fprintf(df, " %d", *intp); } fprintf(df, "\n"); } list_ptr = queue_head(ptree->trap); - if (list_ptr != NULL) { + for(; list_ptr != NULL; + list_ptr = next_node(list_ptr)) { - for(; list_ptr != NULL; - list_ptr = next_node(list_ptr)) { + addr_opts = list_ptr; + addr = addr_opts->addr; - addr_opts = (struct addr_opts_node *) list_ptr; - addr = addr_opts->addr; + fprintf(df, "trap %s", addr->address); - fprintf(df, "trap %s", addr->address); + options = queue_head(addr_opts->options); - options = queue_head(addr_opts->options); + for(; options != NULL; + options = next_node(options)) { - for(; options != NULL; - options = next_node(options)) { + atrv = options; - atrv = (struct attr_val *) options; + switch (atrv->attr) { - switch (atrv->attr) { - default: - fprintf(df, "\n# dump error:\n" - "# unknown trap token %d\n" - "trap %s", atrv->attr, - addr->address); - break; + default: + fprintf(df, "\n# dump error:\n" + "# unknown trap token %d\n" + "trap %s", atrv->attr, + addr->address); + break; - case T_Port: - fprintf(df, " port %d", atrv->value.i); - break; + case T_Port: + fprintf(df, " port %d", atrv->value.i); + break; - case T_Interface: - addr = (struct address_node *) atrv->value.p; - fprintf(df, " interface %s", addr->address); - break; - } + case T_Interface: + addr = (struct address_node *) atrv->value.p; + fprintf(df, " interface %s", addr->address); + break; } - - fprintf(df, "\n"); } + + fprintf(df, "\n"); } return 0; @@ -1614,20 +1211,13 @@ create_address_node( ) { struct address_node *my_node; - struct isc_netaddr temp_isc_netaddr; NTP_REQUIRE(NULL != addr); my_node = get_node(sizeof *my_node); my_node->address = addr; - if (type) - my_node->type = type; - else - if (is_ip_address(addr, &temp_isc_netaddr)) - my_node->type = temp_isc_netaddr.family; - else - my_node->type = default_ai_family; + my_node->type = type; return my_node; } @@ -1654,7 +1244,8 @@ create_peer_node( ) { struct peer_node *my_node; - struct attr_val *my_val; + struct attr_val *option; + int freenode; int errflag = 0; my_node = get_node(sizeof(*my_node)); @@ -1665,40 +1256,52 @@ create_peer_node( my_node->ttl = 0; my_node->peerversion = NTP_VERSION; my_node->peerkey = 0; - my_node->peerflags = 0; my_node->bias = 0; + my_node->peerflags = create_queue(); /* Now set the node to the read values */ my_node->host_mode = hmode; my_node->addr = addr; - my_node->options = options; - my_val = queue_head(options); - while (my_val != NULL) { + /* + * the options list mixes items that will be saved in the + * peer_node as explicit members, such as minpoll, and + * those that are moved from the options queue intact + * to the peer_node's peerflags queue. The options + * queue is consumed and destroyed here. + */ + while (options && NULL != (option = dequeue(options))) { + + freenode = 1; /* Check the kind of option being set */ - switch (my_val->attr) { + switch (option->attr) { + + case T_Flag: + enqueue(my_node->peerflags, option); + freenode = 0; + break; case T_Minpoll: - if (my_val->value.i < NTP_MINPOLL) { + if (option->value.i < NTP_MINPOLL) { msyslog(LOG_INFO, "minpoll: provided value (%d) is below minimum (%d)", - my_val->value.i, NTP_MINPOLL); + option->value.i, NTP_MINPOLL); my_node->minpoll = NTP_MINPOLL; } else - my_node->minpoll = my_val->value.i; + my_node->minpoll = option->value.i; break; case T_Maxpoll: - if (my_val->value.i > NTP_MAXPOLL) { + if (option->value.i > NTP_MAXPOLL) { msyslog(LOG_INFO, "maxpoll: provided value (%d) is above maximum (%d)", - my_val->value.i, NTP_MAXPOLL); + option->value.i, NTP_MAXPOLL); my_node->maxpoll = NTP_MAXPOLL; } else - my_node->maxpoll = my_val->value.i; + my_node->maxpoll = option->value.i; break; case T_Ttl: @@ -1707,38 +1310,35 @@ create_peer_node( errflag = 1; } else - my_node->ttl = my_val->value.i; + my_node->ttl = option->value.i; break; case T_Mode: - my_node->ttl = my_val->value.i; + my_node->ttl = option->value.i; break; case T_Key: - my_node->peerkey = my_val->value.i; + my_node->peerkey = option->value.i; break; case T_Version: - my_node->peerversion = my_val->value.i; - break; - - case T_Flag: - my_node->peerflags |= my_val->value.i; + my_node->peerversion = option->value.i; break; case T_Bias: - my_node->bias = my_val->value.d; + my_node->bias = option->value.d; break; default: msyslog(LOG_ERR, - "Unknown peer/server option token %d", - my_val->attr); + "Unknown peer/server option token %s", + token_name(option->attr)); errflag = 1; } - - my_val = next_node(my_val); + if (freenode) + free_node(option); } + DESTROY_QUEUE(options); /* Check if errors were reported. If yes, ignore the node */ if (errflag) { @@ -1748,6 +1348,7 @@ create_peer_node( return my_node; } + struct unpeer_node * create_unpeer_node( struct address_node *addr @@ -1783,18 +1384,16 @@ create_unpeer_node( struct filegen_node * create_filegen_node( - void **name, - queue *options + int filegen_token, + queue * options ) { struct filegen_node *my_node; my_node = get_node(sizeof *my_node); - - my_node->name = (char *) *name; - free_node(name); - + my_node->filegen_token = filegen_token; my_node->options = options; + return my_node; } @@ -1838,30 +1437,25 @@ destroy_restrict_node( struct setvar_node * create_setvar_node( - char *var, - char *val, - u_short def + char * var, + char * val, + int isdefault ) { - int len1 = strlen(var); - int len2 = strlen(val); - char *s = (char *) emalloc(len1 + len2 + 2); + int octets; + char *s; struct setvar_node *my_node; - /* Copy the var = val to s */ - strcpy(s, var); - s[len1] = '='; - strcpy(&s[len1 + 1], val); - s[len1+len2+1] = '\0'; - + octets = strlen(var) + strlen(val) + 4; /* " = " + NUL */ + s = emalloc(octets); + snprintf(s, octets, "%s = %s", var, val); free(var); free(val); - /* Now store the string and its length into a setvar_node */ + /* Now store the string into a setvar_node */ my_node = get_node(sizeof *my_node); my_node->data = s; - my_node->len = len1 + len2 + 2; - my_node->def = def; + my_node->isdefault = isdefault; return my_node; } @@ -2036,202 +1630,6 @@ create_sim_node( } -/* Lookup the keyword associated with token */ -/* -char * -token_to_str ( - int token - ) -{ - register int a = 0; - - for(; atoken == token) - return keyword_list[a]->keyword; - - return NULL; -}*/ - - -struct key_tok keyword_list[] = { - { "automax", T_Automax, NO_ARG }, - { "broadcast", T_Broadcast, SINGLE_ARG }, - { "broadcastclient", T_Broadcastclient, NO_ARG }, - { "broadcastdelay", T_Broadcastdelay, NO_ARG }, - { "calldelay", T_Calldelay, NO_ARG }, - { "disable", T_Disable, NO_ARG }, - { "driftfile", T_Driftfile, SINGLE_ARG }, - { "enable", T_Enable, NO_ARG }, - { "end", T_End, NO_ARG }, - { "filegen", T_Filegen, NO_ARG }, - { "fudge", T_Fudge, SINGLE_ARG }, - { "includefile", T_Includefile, SINGLE_ARG }, - { "leapfile", T_Leapfile, SINGLE_ARG }, - { "logconfig", T_Logconfig, MULTIPLE_ARG }, - { "logfile", T_Logfile, SINGLE_ARG }, - { "manycastclient", T_Manycastclient, SINGLE_ARG }, - { "manycastserver", T_Manycastserver, MULTIPLE_ARG }, - { "multicastclient", T_Multicastclient, MULTIPLE_ARG }, - { "peer", T_Peer, SINGLE_ARG }, - { "phone", T_Phone, MULTIPLE_ARG }, - { "pidfile", T_Pidfile, SINGLE_ARG }, - { "pool", T_Pool, SINGLE_ARG }, - { "discard", T_Discard, NO_ARG }, - { "restrict", T_Restrict, NO_ARG }, - { "server", T_Server, SINGLE_ARG }, - { "setvar", T_Setvar, NO_ARG }, - { "statistics", T_Statistics, NO_ARG }, - { "statsdir", T_Statsdir, SINGLE_ARG }, - { "tick", T_Tick, NO_ARG }, - { "tinker", T_Tinker, NO_ARG }, - { "tos", T_Tos, NO_ARG }, - { "trap", T_Trap, SINGLE_ARG }, - { "unconfig", T_Unconfig, SINGLE_ARG }, - { "unpeer", T_Unpeer, SINGLE_ARG }, - -/* authentication_command */ - { "controlkey", T_ControlKey, NO_ARG }, - { "crypto", T_Crypto, NO_ARG }, - { "keys", T_Keys, SINGLE_ARG }, - { "keysdir", T_Keysdir, SINGLE_ARG }, - { "ntpsigndsocket", T_NtpSignDsocket, SINGLE_ARG }, - { "requestkey", T_Requestkey, NO_ARG }, - { "revoke", T_Revoke, NO_ARG }, - { "trustedkey", T_Trustedkey, NO_ARG }, -/* IPv4/IPv6 protocol override flag */ - { "-4", T_Ipv4_flag, NO_ARG }, - { "-6", T_Ipv6_flag, NO_ARG }, -/* option */ - { "autokey", T_Autokey, NO_ARG }, - { "bias", T_Bias, NO_ARG }, - { "burst", T_Burst, NO_ARG }, - { "iburst", T_Iburst, NO_ARG }, - { "key", T_Key, NO_ARG }, - { "maxpoll", T_Maxpoll, NO_ARG }, - { "minpoll", T_Minpoll, NO_ARG }, - { "mode", T_Mode, NO_ARG }, - { "noselect", T_Noselect, NO_ARG }, - { "preempt", T_Preempt, NO_ARG }, - { "true", T_True, NO_ARG }, - { "prefer", T_Prefer, NO_ARG }, - { "ttl", T_Ttl, NO_ARG }, - { "version", T_Version, NO_ARG }, - { "xleave", T_Xleave, NO_ARG }, -/* crypto_command */ - { "host", T_Host, SINGLE_ARG }, - { "ident", T_Ident, SINGLE_ARG }, - { "pw", T_Pw, SINGLE_ARG }, - { "randfile", T_RandFile, SINGLE_ARG }, - { "sign", T_Sign, SINGLE_ARG }, -/*** MONITORING COMMANDS ***/ -/* stat */ - { "clockstats", T_Clockstats, NO_ARG }, - { "cryptostats", T_Cryptostats, NO_ARG }, - { "loopstats", T_Loopstats, NO_ARG }, - { "peerstats", T_Peerstats, NO_ARG }, - { "rawstats", T_Rawstats, NO_ARG }, - { "sysstats", T_Sysstats, NO_ARG }, - { "protostats", T_Protostats, NO_ARG }, - { "timingstats", T_Timingstats, NO_ARG }, -/* filegen_option */ - { "disable", T_Disable, NO_ARG }, - { "enable", T_Enable, NO_ARG }, - { "file", T_File, SINGLE_ARG }, - { "link", T_Link, NO_ARG }, - { "nolink", T_Nolink, NO_ARG }, - { "type", T_Type, NO_ARG }, -/* filegen_type */ - { "age", T_Age, NO_ARG }, - { "day", T_Day, NO_ARG }, - { "month", T_Month, NO_ARG }, - { "none", T_None, NO_ARG }, - { "pid", T_Pid, NO_ARG }, - { "week", T_Week, NO_ARG }, - { "year", T_Year, NO_ARG }, -/*** ORPHAN MODE COMMANDS ***/ -/* tos_option */ - { "minclock", T_Minclock, NO_ARG }, - { "maxclock", T_Maxclock, NO_ARG }, - { "minsane", T_Minsane, NO_ARG }, - { "floor", T_Floor, NO_ARG }, - { "ceiling", T_Ceiling, NO_ARG }, - { "cohort", T_Cohort, NO_ARG }, - { "mindist", T_Mindist, NO_ARG }, - { "maxdist", T_Maxdist, NO_ARG }, - { "maxhop", T_Maxhop, NO_ARG }, - { "beacon", T_Beacon, NO_ARG }, - { "orphan", T_Orphan, NO_ARG }, -/* access_control_flag */ - { "default", T_Default, NO_ARG }, - { "flake", T_Flake, NO_ARG }, - { "ignore", T_Ignore, NO_ARG }, - { "limited", T_Limited, NO_ARG }, - { "mssntp", T_Mssntp, NO_ARG }, - { "kod", T_Kod, NO_ARG }, - { "lowpriotrap", T_Lowpriotrap, NO_ARG }, - { "mask", T_Mask, NO_ARG }, - { "nomodify", T_Nomodify, NO_ARG }, - { "nopeer", T_Nopeer, NO_ARG }, - { "noquery", T_Noquery, NO_ARG }, - { "noserve", T_Noserve, NO_ARG }, - { "notrap", T_Notrap, NO_ARG }, - { "notrust", T_Notrust, NO_ARG }, - { "ntpport", T_Ntpport, NO_ARG }, - { "version", T_Version, NO_ARG }, -/* discard_option */ - { "average", T_Average, NO_ARG }, - { "minimum", T_Minimum, NO_ARG }, - { "monitor", T_Monitor, NO_ARG }, -/* fudge_factor */ - { "flag1", T_Flag1, NO_ARG }, - { "flag2", T_Flag2, NO_ARG }, - { "flag3", T_Flag3, NO_ARG }, - { "flag4", T_Flag4, NO_ARG }, - { "refid", T_Refid, SINGLE_ARG }, - { "stratum", T_Stratum, NO_ARG }, - { "time1", T_Time1, NO_ARG }, - { "time2", T_Time2, NO_ARG }, -/* system_option */ - { "auth", T_Auth, NO_ARG }, - { "bclient", T_Bclient, NO_ARG }, - { "calibrate", T_Calibrate, NO_ARG }, - { "kernel", T_Kernel, NO_ARG }, - { "monitor", T_Monitor, NO_ARG }, - { "ntp", T_Ntp, NO_ARG }, - { "stats", T_Stats, NO_ARG }, -/* tinker_option */ - { "step", T_Step, NO_ARG }, - { "panic", T_Panic, NO_ARG }, - { "dispersion", T_Dispersion, NO_ARG }, - { "stepout", T_Stepout, NO_ARG }, - { "allan", T_Allan, NO_ARG }, - { "huffpuff", T_Huffpuff, NO_ARG }, - { "freq", T_Freq, NO_ARG }, -/* miscellaneous_command */ - { "port", T_Port, NO_ARG }, - { "interface", T_Interface, NO_ARG }, - { "qos", T_Qos, NO_ARG }, - { "saveconfigdir", T_Saveconfigdir, SINGLE_ARG }, -/* interface_command (ignore and interface already defined) */ - { "nic", T_Nic, NO_ARG }, - { "all", T_All, NO_ARG }, - { "ipv4", T_Ipv4, NO_ARG }, - { "ipv6", T_Ipv6, NO_ARG }, - { "listen", T_Listen, NO_ARG }, - { "drop", T_Drop, NO_ARG }, -/* simulator commands */ - { "simulate", T_Simulate, NO_ARG }, - { "simulation_duration",T_Sim_Duration, NO_ARG }, - { "beep_delay", T_Beep_Delay, NO_ARG }, - { "duration", T_Duration, NO_ARG }, - { "server_offset", T_Server_Offset, NO_ARG }, - { "freq_offset", T_Freq_Offset, NO_ARG }, - { "wander", T_Wander, NO_ARG }, - { "jitter", T_Jitter, NO_ARG }, - { "prop_delay", T_Prop_Delay, NO_ARG }, - { "proc_delay", T_Proc_Delay, NO_ARG }, - { NULL, 0, 0} -}; /* FUNCTIONS FOR PERFORMING THE CONFIGURATION @@ -2304,16 +1702,46 @@ config_auth( struct config_tree *ptree ) { - u_char rankey[9]; +#ifdef OPENSSL struct attr_val *my_val; + int item; +#endif int *key_val; int i; + u_char rankey[9]; /* Crypto Command */ - my_val = queue_head(ptree->auth.crypto_cmd_list); #ifdef OPENSSL + item = -1; /* quiet warning */ + my_val = queue_head(ptree->auth.crypto_cmd_list); while (my_val != NULL) { - crypto_config(my_val->attr, my_val->value.s); + switch (my_val->attr) { + + default: + NTP_INSIST(0); + break; + + case T_Host: + item = CRYPTO_CONF_PRIV; + break; + + case T_Ident: + item = CRYPTO_CONF_IDENT; + break; + + case T_Pw: + item = CRYPTO_CONF_PW; + break; + + case T_Randfile: + item = CRYPTO_CONF_RAND; + break; + + case T_Sign: + item = CRYPTO_CONF_SIGN; + break; + } + crypto_config(item, my_val->value.s); my_val = next_node(my_val); } #endif /* OPENSSL */ @@ -2334,9 +1762,9 @@ config_auth( } #ifdef OPENSSL - if (cryptosw) { + if (ptree->auth.cryptosw && !cryptosw) { crypto_setup(); - cryptosw = 0; + cryptosw = 1; } #endif /* OPENSSL */ @@ -2363,7 +1791,7 @@ config_auth( } #ifdef OPENSSL - /* Revoke Command */ + /* crypto revoke command */ if (ptree->auth.revoke) sys_revoke = ptree->auth.revoke; #endif /* OPENSSL */ @@ -2429,10 +1857,62 @@ config_tos( ) { struct attr_val *tos; + int item; + item = -1; /* quiet warning */ tos = queue_head(ptree->orphan_cmds); while (tos != NULL) { - proto_config(tos->attr, 0, tos->value.d, NULL); + switch(tos->attr) { + + default: + NTP_INSIST(0); + break; + + case T_Ceiling: + item = PROTO_CEILING; + break; + + case T_Floor: + item = PROTO_FLOOR; + break; + + case T_Cohort: + item = PROTO_COHORT; + break; + + case T_Orphan: + item = PROTO_ORPHAN; + break; + + case T_Mindist: + item = PROTO_MINDISP; + break; + + case T_Maxdist: + item = PROTO_MAXDIST; + break; + + case T_Minclock: + item = PROTO_MINCLOCK; + break; + + case T_Maxclock: + item = PROTO_MAXCLOCK; + break; + + case T_Minsane: + item = PROTO_MINSANE; + break; + + case T_Beacon: + item = PROTO_BEACON; + break; + + case T_Maxhop: + item = PROTO_MAXHOP; + break; + } + proto_config(item, 0, tos->value.d, NULL); tos = next_node(tos); } } @@ -2459,7 +1939,8 @@ config_monitor( struct config_tree *ptree ) { - char **filegen_string; + int *pfilegen_token; + char *filegen_string; FILEGEN *filegen; struct filegen_node *my_node; struct attr_val *my_opts; @@ -2486,27 +1967,27 @@ config_monitor( */ /* Turn on the specified statistics */ - filegen_string = queue_head(ptree->stats_list); - while (filegen_string != NULL) { - filegen = filegen_get(*filegen_string); + pfilegen_token = queue_head(ptree->stats_list); + while (pfilegen_token != NULL) { + filegen_string = keyword(*pfilegen_token); + filegen = filegen_get(filegen_string); - DPRINTF(4, ("enabling filegen for %s statistics " - "\"%s%s\"\n", - *filegen_string, filegen->prefix, + DPRINTF(4, ("enabling filegen for %s statistics '%s%s'\n", + filegen_string, filegen->prefix, filegen->basename)); filegen->flag |= FGEN_FLAG_ENABLED; - filegen_string = next_node(filegen_string); + pfilegen_token = next_node(pfilegen_token); } /* Configure the statistics with the options */ my_node = queue_head(ptree->filegen_opts); while (my_node != NULL) { - filegen = filegen_get(my_node->name); + filegen_file = keyword(my_node->filegen_token); + filegen = filegen_get(filegen_file); /* Initialize the filegen variables to their pre-configurtion states */ filegen_flag = filegen->flag; filegen_type = filegen->type; - filegen_file = my_node->name; my_opts = queue_head(my_node->options); while (my_opts != NULL) { @@ -2518,7 +1999,40 @@ config_monitor( break; case T_Type: - filegen_type = my_opts->value.i; + switch (my_opts->value.i) { + + default: + NTP_INSIST(0); + break; + + case T_None: + filegen_type = FILEGEN_NONE; + break; + + case T_Pid: + filegen_type = FILEGEN_PID; + break; + + case T_Day: + filegen_type = FILEGEN_DAY; + break; + + case T_Week: + filegen_type = FILEGEN_WEEK; + break; + + case T_Month: + filegen_type = FILEGEN_MONTH; + break; + + case T_Year: + filegen_type = FILEGEN_YEAR; + break; + + case T_Age: + filegen_type = FILEGEN_AGE; + break; + } break; case T_Flag: @@ -2542,16 +2056,15 @@ config_monitor( default: msyslog(LOG_ERR, - "Unknown filegen flag " - "token %d", + "Unknown filegen flag token %d", my_opts->value.i); exit(1); } break; default: msyslog(LOG_ERR, - "Unknown filegen option token " - "%d", my_opts->attr); + "Unknown filegen option token %d", + my_opts->attr); exit(1); } filegen_config(filegen, filegen_file, @@ -2689,10 +2202,68 @@ config_access( curr_flag = queue_head(my_node->flags); while (curr_flag != NULL) { - if (RESM_NTPONLY == *curr_flag) - mflags |= *curr_flag; - else - flags |= *curr_flag; + switch (*curr_flag) { + + default: + NTP_INSIST(0); + break; + + case T_Ntpport: + mflags |= RESM_NTPONLY; + break; + + case T_Flake: + flags |= RES_TIMEOUT; + break; + + case T_Ignore: + flags |= RES_IGNORE; + break; + + case T_Kod: + flags |= RES_KOD; + break; + + case T_Mssntp: + flags |= RES_MSSNTP; + break; + + case T_Limited: + flags |= RES_LIMITED; + break; + + case T_Lowpriotrap: + flags |= RES_LPTRAP; + break; + + case T_Nomodify: + flags |= RES_NOMODIFY; + break; + + case T_Nopeer: + flags |= RES_NOPEER; + break; + + case T_Noquery: + flags |= RES_NOQUERY; + break; + + case T_Noserve: + flags |= RES_DONTSERVE; + break; + + case T_Notrap: + flags |= RES_NOTRAP; + break; + + case T_Notrust: + flags |= RES_DONTTRUST; + break; + + case T_Version: + flags |= RES_VERSION; + break; + } curr_flag = next_node(curr_flag); } @@ -2748,10 +2319,46 @@ config_tinker( ) { struct attr_val *tinker; + int item; + item = -1; /* quiet warning */ tinker = queue_head(ptree->tinker); while (tinker != NULL) { - loop_config(tinker->attr, tinker->value.d); + switch (tinker->attr) { + + default: + NTP_INSIST(0); + break; + + case T_Allan: + item = LOOP_ALLAN; + break; + + case T_Dispersion: + item = LOOP_PHI; + break; + + case T_Freq: + item = LOOP_FREQ; + break; + + case T_Huffpuff: + item = LOOP_HUFFPUFF; + break; + + case T_Panic: + item = LOOP_PANIC; + break; + + case T_Step: + item = LOOP_MAX; + break; + + case T_Stepout: + item = LOOP_MINSTEP; + break; + } + loop_config(item, tinker->value.d); tinker = next_node(tinker); } } @@ -3155,7 +2762,10 @@ config_setvar( my_node = queue_head(ptree->setvar); while (my_node != NULL) { - set_sys_var(my_node->data, my_node->len, my_node->def); + set_sys_var(my_node->data, strlen(my_node->data) + 1, + (my_node->isdefault) + ? DEF + : 0); my_node = next_node(my_node); } } @@ -3371,39 +2981,48 @@ config_fudge( */ clock_stat.haveflags |= curr_opt->attr; switch (curr_opt->attr) { - case CLK_HAVETIME1: + case T_Time1: + clock_stat.haveflags |= CLK_HAVETIME1; clock_stat.fudgetime1 = curr_opt->value.d; break; - case CLK_HAVETIME2: + case T_Time2: + clock_stat.haveflags |= CLK_HAVETIME2; clock_stat.fudgetime2 = curr_opt->value.d; break; - case CLK_HAVEVAL1: + case T_Stratum: + clock_stat.haveflags |= CLK_HAVEVAL1; clock_stat.fudgeval1 = curr_opt->value.i; break; - case CLK_HAVEVAL2: + case T_Refid: + clock_stat.haveflags |= CLK_HAVEVAL2; + clock_stat.fudgeval2 = 0; memcpy(&clock_stat.fudgeval2, curr_opt->value.s, min(strlen(curr_opt->value.s), 4)); break; - case CLK_HAVEFLAG1: + case T_Flag1: + clock_stat.haveflags |= CLK_HAVEFLAG1; if (curr_opt->value.i) clock_stat.flags |= CLK_FLAG1; else clock_stat.flags &= ~CLK_FLAG1; break; - case CLK_HAVEFLAG2: + case T_Flag2: + clock_stat.haveflags |= CLK_HAVEFLAG2; if (curr_opt->value.i) clock_stat.flags |= CLK_FLAG2; else clock_stat.flags &= ~CLK_FLAG2; break; - case CLK_HAVEFLAG3: + case T_Flag3: + clock_stat.haveflags |= CLK_HAVEFLAG3; if (curr_opt->value.i) clock_stat.flags |= CLK_FLAG3; else clock_stat.flags &= ~CLK_FLAG3; break; - case CLK_HAVEFLAG4: + case T_Flag4: + clock_stat.haveflags |= CLK_HAVEFLAG4; if (curr_opt->value.i) clock_stat.flags |= CLK_FLAG4; else @@ -3645,7 +3264,9 @@ config_peers( struct addrinfo *res, *res_bak; sockaddr_u peeraddr; struct peer_node *curr_peer; + struct attr_val *option; int hmode; + int peerflags; int status; int no_needed; int i; @@ -3664,11 +3285,55 @@ config_peers( hmode = get_correct_host_mode(curr_peer->host_mode); NTP_INSIST(hmode != -1); + /* translate peerflags options to bits */ + peerflags = 0; + option = queue_head(curr_peer->peerflags); + for (; option != NULL; option = next_node(option)) + switch (option->value.i) { + + default: + NTP_INSIST(0); + break; + + case T_Autokey: + peerflags |= FLAG_SKEY; + break; + + case T_Burst: + peerflags |= FLAG_BURST; + break; + + case T_Iburst: + peerflags |= FLAG_IBURST; + break; + + case T_Noselect: + peerflags |= FLAG_NOSELECT; + break; + + case T_Preempt: + peerflags |= FLAG_PREEMPT; + break; + + case T_Prefer: + peerflags |= FLAG_PREFER; + break; + + case T_True: + peerflags |= FLAG_TRUE; + break; + + case T_Xleave: + peerflags |= FLAG_XLEAVE; + break; + } + /* Attempt to resolve the address */ ZERO_SOCK(&peeraddr); AF(&peeraddr) = (u_short)curr_peer->addr->type; - status = get_multiple_netnums(curr_peer->addr->address, &peeraddr, &res, 0, t_UNK); + status = get_multiple_netnums(curr_peer->addr->address, + &peeraddr, &res, 0, t_UNK); /* I don't know why getnetnum would return -1. * The old code had this test, so I guess it must be @@ -3688,7 +3353,7 @@ config_peers( curr_peer->peerversion, curr_peer->minpoll, curr_peer->maxpoll, - curr_peer->peerflags, + peerflags, curr_peer->ttl, curr_peer->peerkey, (u_char *)"*"); @@ -3720,7 +3385,7 @@ config_peers( curr_peer->peerversion, curr_peer->minpoll, curr_peer->maxpoll, - curr_peer->peerflags, + peerflags, curr_peer->ttl, curr_peer->peerkey, (u_char *)"*"); @@ -3742,7 +3407,7 @@ free_config_peers( while (NULL != (curr_peer = dequeue(ptree->peers))) { destroy_address_node(curr_peer->addr); - DESTROY_QUEUE(curr_peer->options); + DESTROY_QUEUE(curr_peer->peerflags); free_node(curr_peer); } } @@ -4025,7 +3690,7 @@ config_remotely( input_from_file = 0; init_syntax_tree(&cfgt); - key_scanner = create_keyword_scanner(keyword_list); + key_scanner = create_keyword_scanner(); yyparse(); delete_keyword_scanner(key_scanner); key_scanner = NULL; @@ -4136,7 +3801,7 @@ getconfig( yydebug = !!(debug >= 5); #endif ip_file = fp[curr_include_level]; - key_scanner = create_keyword_scanner(keyword_list); + key_scanner = create_keyword_scanner(); yyparse(); delete_keyword_scanner(key_scanner); diff --git a/ntpd/ntp_parser.c b/ntpd/ntp_parser.c index 79cf99d73..03d286f69 100644 --- a/ntpd/ntp_parser.c +++ b/ntpd/ntp_parser.c @@ -100,11 +100,10 @@ #define YYMAXDEPTH 1000 /* stop the madness sooner */ void yyerror (char *msg); extern int input_from_file; /* 0=input from ntpq :config */ - extern int cryptosw; /* Line 189 of yacc.c */ -#line 108 "ntp_parser.c" +#line 107 "ntp_parser.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -243,7 +242,7 @@ T_Protostats = 367, T_Pw = 368, T_Qos = 369, - T_RandFile = 370, + T_Randfile = 370, T_Rawstats = 371, T_Refid = 372, T_Requestkey = 373, @@ -407,7 +406,7 @@ #define T_Protostats 367 #define T_Pw 368 #define T_Qos 369 -#define T_RandFile 370 +#define T_Randfile 370 #define T_Rawstats 371 #define T_Refid 372 #define T_Requestkey 373 @@ -465,7 +464,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 51 "ntp_parser.y" +#line 50 "ntp_parser.y" char *String; double Double; @@ -483,7 +482,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 487 "ntp_parser.c" +#line 486 "ntp_parser.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -495,7 +494,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 499 "ntp_parser.c" +#line 498 "ntp_parser.c" #ifdef short # undef short @@ -826,8 +825,8 @@ static const yytype_int16 yyrhs[] = 23, 181, -1, 60, 131, -1, 61, 131, -1, 118, 52, -1, 141, 218, -1, 100, 131, -1, 182, -1, -1, 182, 183, -1, 183, -1, 46, 131, -1, 49, - 131, -1, 113, 131, -1, 115, 131, -1, 120, 52, - -1, 124, 131, -1, 138, 185, -1, 185, 186, -1, + 131, -1, 113, 131, -1, 115, 131, -1, 124, 131, + -1, 120, 52, -1, 138, 185, -1, 185, 186, -1, 186, -1, 19, 52, -1, 43, 52, -1, 21, 221, -1, 101, 52, -1, 80, 222, -1, 76, 222, -1, 79, 222, -1, 75, 222, -1, 83, 52, -1, 11, @@ -881,31 +880,31 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 296, 296, 300, 301, 302, 316, 317, 318, 319, - 320, 321, 322, 323, 324, 325, 326, 327, 328, 336, - 342, 351, 352, 353, 354, 355, 359, 360, 361, 365, - 369, 370, 374, 375, 376, 377, 378, 379, 380, 381, - 382, 383, 384, 385, 386, 387, 388, 397, 405, 406, - 416, 418, 420, 431, 433, 435, 440, 442, 444, 446, - 448, 453, 455, 459, 460, 464, 466, 468, 470, 472, - 474, 484, 489, 490, 494, 496, 498, 500, 502, 504, - 506, 508, 510, 512, 514, 524, 526, 535, 543, 544, - 548, 550, 552, 554, 556, 558, 560, 562, 567, 574, - 584, 594, 603, 612, 621, 622, 626, 627, 628, 629, - 630, 631, 632, 641, 645, 650, 655, 668, 681, 689, - 690, 694, 695, 696, 697, 698, 699, 700, 701, 702, - 703, 704, 705, 706, 707, 711, 712, 716, 717, 718, - 726, 731, 732, 736, 738, 740, 742, 744, 746, 748, - 750, 759, 761, 766, 773, 783, 784, 785, 786, 787, - 788, 789, 805, 809, 810, 814, 815, 816, 817, 818, - 819, 820, 829, 830, 846, 852, 854, 856, 858, 860, - 863, 865, 876, 878, 880, 890, 892, 894, 896, 898, - 903, 905, 909, 913, 915, 920, 922, 926, 927, 931, - 932, 936, 951, 956, 964, 965, 969, 970, 971, 975, - 976, 977, 987, 988, 992, 993, 997, 998, 1002, 1011, - 1012, 1016, 1017, 1026, 1041, 1045, 1046, 1050, 1051, 1055, - 1056, 1060, 1065, 1069, 1073, 1074, 1078, 1083, 1084, 1088, - 1090, 1092, 1094, 1096 + 0, 295, 295, 299, 300, 301, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 324, 325, 326, 327, 335, + 341, 350, 351, 352, 353, 354, 358, 359, 360, 364, + 368, 369, 373, 374, 375, 376, 377, 378, 379, 380, + 381, 382, 383, 384, 385, 386, 387, 396, 404, 405, + 415, 417, 419, 430, 432, 434, 439, 441, 443, 445, + 447, 452, 454, 458, 465, 475, 477, 479, 481, 483, + 485, 498, 503, 504, 508, 510, 512, 514, 516, 518, + 520, 522, 524, 526, 528, 538, 540, 549, 557, 558, + 562, 563, 564, 565, 566, 567, 568, 569, 573, 580, + 590, 600, 609, 618, 627, 628, 632, 633, 634, 635, + 636, 637, 638, 647, 651, 656, 661, 674, 687, 696, + 697, 702, 703, 704, 705, 706, 707, 708, 709, 710, + 711, 712, 713, 714, 715, 719, 721, 726, 727, 728, + 736, 741, 743, 748, 749, 750, 751, 752, 753, 754, + 755, 763, 765, 770, 777, 787, 788, 789, 790, 791, + 792, 793, 809, 813, 814, 818, 819, 820, 821, 822, + 823, 824, 833, 834, 850, 856, 858, 860, 862, 864, + 867, 869, 880, 882, 884, 894, 896, 898, 900, 902, + 907, 909, 913, 917, 919, 924, 926, 930, 931, 935, + 936, 940, 955, 960, 968, 969, 973, 974, 975, 979, + 980, 981, 991, 992, 996, 997, 1001, 1002, 1006, 1015, + 1016, 1020, 1021, 1030, 1045, 1049, 1050, 1054, 1055, 1059, + 1060, 1064, 1069, 1073, 1077, 1078, 1082, 1087, 1088, 1092, + 1094, 1096, 1098, 1100 }; #endif @@ -935,7 +934,7 @@ static const char *const yytname[] = "T_Notrust", "T_Ntp", "T_Ntpport", "T_NtpSignDsocket", "T_Orphan", "T_Panic", "T_Peer", "T_Peerstats", "T_Phone", "T_Pid", "T_Pidfile", "T_Pool", "T_Port", "T_Preempt", "T_Prefer", "T_Protostats", "T_Pw", - "T_Qos", "T_RandFile", "T_Rawstats", "T_Refid", "T_Requestkey", + "T_Qos", "T_Randfile", "T_Rawstats", "T_Refid", "T_Requestkey", "T_Restrict", "T_Revoke", "T_Saveconfigdir", "T_Server", "T_Setvar", "T_Sign", "T_Statistics", "T_Stats", "T_Statsdir", "T_Step", "T_Stepout", "T_Stratum", "T_String", "T_Sysstats", "T_Tick", "T_Time1", "T_Time2", @@ -1075,7 +1074,7 @@ static const yytype_uint8 yydefact[] = 0, 0, 162, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 73, 186, 213, 59, 188, 1, 0, 4, 20, 47, 211, 210, 209, 0, - 0, 65, 66, 67, 68, 69, 70, 63, 153, 137, + 0, 65, 66, 67, 68, 70, 69, 63, 153, 137, 138, 139, 135, 191, 105, 104, 0, 102, 103, 0, 87, 99, 27, 28, 0, 0, 0, 0, 0, 0, 0, 0, 140, 142, 173, 199, 216, 214, 115, 119, @@ -2171,7 +2170,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 303 "ntp_parser.y" +#line 302 "ntp_parser.y" { /* I will need to incorporate much more fine grained * error messages. The following should suffice for @@ -2188,7 +2187,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 337 "ntp_parser.y" +#line 336 "ntp_parser.y" { struct peer_node *my_node = create_peer_node((yyvsp[(1) - (3)].Integer), (yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue)); if (my_node) @@ -2199,7 +2198,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 343 "ntp_parser.y" +#line 342 "ntp_parser.y" { struct peer_node *my_node = create_peer_node((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Address_node), NULL); if (my_node) @@ -2210,147 +2209,147 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 360 "ntp_parser.y" +#line 359 "ntp_parser.y" { (yyval.Address_node) = create_address_node((yyvsp[(2) - (2)].String), AF_INET); } break; case 28: /* Line 1455 of yacc.c */ -#line 361 "ntp_parser.y" +#line 360 "ntp_parser.y" { (yyval.Address_node) = create_address_node((yyvsp[(2) - (2)].String), AF_INET6); } break; case 29: /* Line 1455 of yacc.c */ -#line 365 "ntp_parser.y" +#line 364 "ntp_parser.y" { (yyval.Address_node) = create_address_node((yyvsp[(1) - (1)].String), 0); } break; case 30: /* Line 1455 of yacc.c */ -#line 369 "ntp_parser.y" +#line 368 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 31: /* Line 1455 of yacc.c */ -#line 370 "ntp_parser.y" +#line 369 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 32: /* Line 1455 of yacc.c */ -#line 374 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_SKEY); } +#line 373 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 33: /* Line 1455 of yacc.c */ -#line 375 "ntp_parser.y" +#line 374 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 34: /* Line 1455 of yacc.c */ -#line 376 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_BURST); } +#line 375 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 35: /* Line 1455 of yacc.c */ -#line 377 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_IBURST); } +#line 376 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 36: /* Line 1455 of yacc.c */ -#line 378 "ntp_parser.y" +#line 377 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 37: /* Line 1455 of yacc.c */ -#line 379 "ntp_parser.y" +#line 378 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 38: /* Line 1455 of yacc.c */ -#line 380 "ntp_parser.y" +#line 379 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 39: /* Line 1455 of yacc.c */ -#line 381 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_NOSELECT); } +#line 380 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 40: /* Line 1455 of yacc.c */ -#line 382 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_PREEMPT); } +#line 381 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 41: /* Line 1455 of yacc.c */ -#line 383 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_PREFER); } +#line 382 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 42: /* Line 1455 of yacc.c */ -#line 384 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_TRUE); } +#line 383 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 43: /* Line 1455 of yacc.c */ -#line 385 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_XLEAVE); } +#line 384 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 44: /* Line 1455 of yacc.c */ -#line 386 "ntp_parser.y" +#line 385 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 45: /* Line 1455 of yacc.c */ -#line 387 "ntp_parser.y" +#line 386 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 46: /* Line 1455 of yacc.c */ -#line 388 "ntp_parser.y" +#line 387 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 47: /* Line 1455 of yacc.c */ -#line 398 "ntp_parser.y" +#line 397 "ntp_parser.y" { struct unpeer_node *my_node = create_unpeer_node((yyvsp[(2) - (2)].Address_node)); if (my_node) @@ -2361,44 +2360,44 @@ yyreduce: case 50: /* Line 1455 of yacc.c */ -#line 417 "ntp_parser.y" +#line 416 "ntp_parser.y" { cfgt.broadcastclient = 1; } break; case 51: /* Line 1455 of yacc.c */ -#line 419 "ntp_parser.y" +#line 418 "ntp_parser.y" { append_queue(cfgt.manycastserver, (yyvsp[(2) - (2)].Queue)); } break; case 52: /* Line 1455 of yacc.c */ -#line 421 "ntp_parser.y" +#line 420 "ntp_parser.y" { append_queue(cfgt.multicastclient, (yyvsp[(2) - (2)].Queue)); } break; case 53: /* Line 1455 of yacc.c */ -#line 432 "ntp_parser.y" +#line 431 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer))); } break; case 54: /* Line 1455 of yacc.c */ -#line 434 "ntp_parser.y" +#line 433 "ntp_parser.y" { cfgt.auth.control_key = (yyvsp[(2) - (2)].Integer); } break; case 55: /* Line 1455 of yacc.c */ -#line 436 "ntp_parser.y" +#line 435 "ntp_parser.y" { - cryptosw++; + cfgt.auth.cryptosw++; append_queue(cfgt.auth.crypto_cmd_list, (yyvsp[(2) - (2)].Queue)); } break; @@ -2406,42 +2405,42 @@ yyreduce: case 56: /* Line 1455 of yacc.c */ -#line 441 "ntp_parser.y" +#line 440 "ntp_parser.y" { cfgt.auth.keys = (yyvsp[(2) - (2)].String); } break; case 57: /* Line 1455 of yacc.c */ -#line 443 "ntp_parser.y" +#line 442 "ntp_parser.y" { cfgt.auth.keysdir = (yyvsp[(2) - (2)].String); } break; case 58: /* Line 1455 of yacc.c */ -#line 445 "ntp_parser.y" +#line 444 "ntp_parser.y" { cfgt.auth.request_key = (yyvsp[(2) - (2)].Integer); } break; case 59: /* Line 1455 of yacc.c */ -#line 447 "ntp_parser.y" +#line 446 "ntp_parser.y" { cfgt.auth.trusted_key_list = (yyvsp[(2) - (2)].Queue); } break; case 60: /* Line 1455 of yacc.c */ -#line 449 "ntp_parser.y" +#line 448 "ntp_parser.y" { cfgt.auth.ntp_signd_socket = (yyvsp[(2) - (2)].String); } break; case 62: /* Line 1455 of yacc.c */ -#line 455 "ntp_parser.y" +#line 454 "ntp_parser.y" { (yyval.Queue) = create_queue(); } break; @@ -2449,167 +2448,180 @@ yyreduce: /* Line 1455 of yacc.c */ #line 459 "ntp_parser.y" - { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } + { + if ((yyvsp[(2) - (2)].Attr_val) != NULL) + (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); + else + (yyval.Queue) = (yyvsp[(1) - (2)].Queue); + } break; case 64: /* Line 1455 of yacc.c */ -#line 460 "ntp_parser.y" - { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } +#line 466 "ntp_parser.y" + { + if ((yyvsp[(1) - (1)].Attr_val) != NULL) + (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); + else + (yyval.Queue) = create_queue(); + } break; case 65: /* Line 1455 of yacc.c */ -#line 465 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_PRIV, (yyvsp[(2) - (2)].String)); } +#line 476 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 66: /* Line 1455 of yacc.c */ -#line 467 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_IDENT, (yyvsp[(2) - (2)].String)); } +#line 478 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 67: /* Line 1455 of yacc.c */ -#line 469 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_PW, (yyvsp[(2) - (2)].String)); } +#line 480 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 68: /* Line 1455 of yacc.c */ -#line 471 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_RAND, (yyvsp[(2) - (2)].String)); } +#line 482 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 69: /* Line 1455 of yacc.c */ -#line 473 "ntp_parser.y" - { cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); } +#line 484 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 70: /* Line 1455 of yacc.c */ -#line 475 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_SIGN, (yyvsp[(2) - (2)].String)); } +#line 486 "ntp_parser.y" + { + (yyval.Attr_val) = NULL; + cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); + } break; case 71: /* Line 1455 of yacc.c */ -#line 485 "ntp_parser.y" +#line 499 "ntp_parser.y" { append_queue(cfgt.orphan_cmds,(yyvsp[(2) - (2)].Queue)); } break; case 72: /* Line 1455 of yacc.c */ -#line 489 "ntp_parser.y" +#line 503 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 73: /* Line 1455 of yacc.c */ -#line 490 "ntp_parser.y" +#line 504 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 74: /* Line 1455 of yacc.c */ -#line 495 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_CEILING, (double)(yyvsp[(2) - (2)].Integer)); } +#line 509 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 75: /* Line 1455 of yacc.c */ -#line 497 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_FLOOR, (double)(yyvsp[(2) - (2)].Integer)); } +#line 511 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 76: /* Line 1455 of yacc.c */ -#line 499 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_COHORT, (double)(yyvsp[(2) - (2)].Integer)); } +#line 513 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 77: /* Line 1455 of yacc.c */ -#line 501 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_ORPHAN, (double)(yyvsp[(2) - (2)].Integer)); } +#line 515 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 78: /* Line 1455 of yacc.c */ -#line 503 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_MINDISP, (yyvsp[(2) - (2)].Double)); } +#line 517 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 79: /* Line 1455 of yacc.c */ -#line 505 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_MAXDIST, (yyvsp[(2) - (2)].Double)); } +#line 519 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 80: /* Line 1455 of yacc.c */ -#line 507 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_MINCLOCK, (yyvsp[(2) - (2)].Double)); } +#line 521 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 81: /* Line 1455 of yacc.c */ -#line 509 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_MAXCLOCK, (yyvsp[(2) - (2)].Double)); } +#line 523 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 82: /* Line 1455 of yacc.c */ -#line 511 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_MINSANE, (double)(yyvsp[(2) - (2)].Integer)); } +#line 525 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 83: /* Line 1455 of yacc.c */ -#line 513 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_BEACON, (double)(yyvsp[(2) - (2)].Integer)); } +#line 527 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 84: /* Line 1455 of yacc.c */ -#line 515 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(PROTO_MAXHOP, (double)(yyvsp[(2) - (2)].Integer)); } +#line 529 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 85: /* Line 1455 of yacc.c */ -#line 525 "ntp_parser.y" +#line 539 "ntp_parser.y" { append_queue(cfgt.stats_list, (yyvsp[(2) - (2)].Queue)); } break; case 86: /* Line 1455 of yacc.c */ -#line 527 "ntp_parser.y" +#line 541 "ntp_parser.y" { if (input_from_file) cfgt.stats_dir = (yyvsp[(2) - (2)].String); @@ -2623,87 +2635,31 @@ yyreduce: case 87: /* Line 1455 of yacc.c */ -#line 536 "ntp_parser.y" +#line 550 "ntp_parser.y" { enqueue(cfgt.filegen_opts, - create_filegen_node((yyvsp[(2) - (3)].VoidPtr), (yyvsp[(3) - (3)].Queue))); + create_filegen_node((yyvsp[(2) - (3)].Integer), (yyvsp[(3) - (3)].Queue))); } break; case 88: -/* Line 1455 of yacc.c */ -#line 543 "ntp_parser.y" - { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].VoidPtr)); } - break; - - case 89: - -/* Line 1455 of yacc.c */ -#line 544 "ntp_parser.y" - { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].VoidPtr)); } - break; - - case 90: - -/* Line 1455 of yacc.c */ -#line 549 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("clockstats"); } - break; - - case 91: - -/* Line 1455 of yacc.c */ -#line 551 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("cryptostats"); } - break; - - case 92: - -/* Line 1455 of yacc.c */ -#line 553 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("loopstats"); } - break; - - case 93: - -/* Line 1455 of yacc.c */ -#line 555 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("peerstats"); } - break; - - case 94: - /* Line 1455 of yacc.c */ #line 557 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("rawstats"); } - break; - - case 95: - -/* Line 1455 of yacc.c */ -#line 559 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("sysstats"); } - break; - - case 96: - -/* Line 1455 of yacc.c */ -#line 561 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("timingstats"); } + { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), create_ival((yyvsp[(2) - (2)].Integer))); } break; - case 97: + case 89: /* Line 1455 of yacc.c */ -#line 563 "ntp_parser.y" - { (yyval.VoidPtr) = create_pval("protostats"); } +#line 558 "ntp_parser.y" + { (yyval.Queue) = enqueue_in_new_queue(create_ival((yyvsp[(1) - (1)].Integer))); } break; case 98: /* Line 1455 of yacc.c */ -#line 568 "ntp_parser.y" +#line 574 "ntp_parser.y" { if ((yyvsp[(2) - (2)].Attr_val) != NULL) (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); @@ -2715,7 +2671,7 @@ yyreduce: case 99: /* Line 1455 of yacc.c */ -#line 575 "ntp_parser.y" +#line 581 "ntp_parser.y" { if ((yyvsp[(1) - (1)].Attr_val) != NULL) (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); @@ -2727,7 +2683,7 @@ yyreduce: case 100: /* Line 1455 of yacc.c */ -#line 585 "ntp_parser.y" +#line 591 "ntp_parser.y" { if (input_from_file) (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); @@ -2742,7 +2698,7 @@ yyreduce: case 101: /* Line 1455 of yacc.c */ -#line 595 "ntp_parser.y" +#line 601 "ntp_parser.y" { if (input_from_file) (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); @@ -2756,7 +2712,7 @@ yyreduce: case 102: /* Line 1455 of yacc.c */ -#line 604 "ntp_parser.y" +#line 610 "ntp_parser.y" { if (input_from_file) (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); @@ -2770,7 +2726,7 @@ yyreduce: case 103: /* Line 1455 of yacc.c */ -#line 613 "ntp_parser.y" +#line 619 "ntp_parser.y" { if (input_from_file) (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); @@ -2784,71 +2740,22 @@ yyreduce: case 104: /* Line 1455 of yacc.c */ -#line 621 "ntp_parser.y" +#line 627 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 105: -/* Line 1455 of yacc.c */ -#line 622 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } - break; - - case 106: - -/* Line 1455 of yacc.c */ -#line 626 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_NONE; } - break; - - case 107: - -/* Line 1455 of yacc.c */ -#line 627 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_PID; } - break; - - case 108: - /* Line 1455 of yacc.c */ #line 628 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_DAY; } - break; - - case 109: - -/* Line 1455 of yacc.c */ -#line 629 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_WEEK; } - break; - - case 110: - -/* Line 1455 of yacc.c */ -#line 630 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_MONTH; } - break; - - case 111: - -/* Line 1455 of yacc.c */ -#line 631 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_YEAR; } - break; - - case 112: - -/* Line 1455 of yacc.c */ -#line 632 "ntp_parser.y" - { (yyval.Integer) = FILEGEN_AGE; } + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 113: /* Line 1455 of yacc.c */ -#line 642 "ntp_parser.y" - { +#line 648 "ntp_parser.y" + { append_queue(cfgt.discard_opts, (yyvsp[(2) - (2)].Queue)); } break; @@ -2856,7 +2763,7 @@ yyreduce: case 114: /* Line 1455 of yacc.c */ -#line 646 "ntp_parser.y" +#line 652 "ntp_parser.y" { enqueue(cfgt.restrict_opts, create_restrict_node((yyvsp[(2) - (3)].Address_node), NULL, (yyvsp[(3) - (3)].Queue), ip_file->line_no)); @@ -2866,7 +2773,7 @@ yyreduce: case 115: /* Line 1455 of yacc.c */ -#line 651 "ntp_parser.y" +#line 657 "ntp_parser.y" { enqueue(cfgt.restrict_opts, create_restrict_node(NULL, NULL, (yyvsp[(3) - (3)].Queue), ip_file->line_no)); @@ -2876,7 +2783,7 @@ yyreduce: case 116: /* Line 1455 of yacc.c */ -#line 656 "ntp_parser.y" +#line 662 "ntp_parser.y" { enqueue(cfgt.restrict_opts, create_restrict_node( @@ -2894,7 +2801,7 @@ yyreduce: case 117: /* Line 1455 of yacc.c */ -#line 669 "ntp_parser.y" +#line 675 "ntp_parser.y" { enqueue(cfgt.restrict_opts, create_restrict_node( @@ -2912,7 +2819,7 @@ yyreduce: case 118: /* Line 1455 of yacc.c */ -#line 682 "ntp_parser.y" +#line 688 "ntp_parser.y" { 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)); @@ -2922,245 +2829,147 @@ yyreduce: case 119: /* Line 1455 of yacc.c */ -#line 689 "ntp_parser.y" +#line 696 "ntp_parser.y" { (yyval.Queue) = create_queue(); } break; case 120: -/* Line 1455 of yacc.c */ -#line 690 "ntp_parser.y" - { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].VoidPtr)); } - break; - - case 121: - -/* Line 1455 of yacc.c */ -#line 694 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_TIMEOUT); } - break; - - case 122: - -/* Line 1455 of yacc.c */ -#line 695 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_IGNORE); } - break; - - case 123: - -/* Line 1455 of yacc.c */ -#line 696 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_KOD); } - break; - - case 124: - -/* Line 1455 of yacc.c */ -#line 697 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_MSSNTP); } - break; - - case 125: - /* Line 1455 of yacc.c */ #line 698 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_LIMITED); } - break; - - case 126: - -/* Line 1455 of yacc.c */ -#line 699 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_LPTRAP); } - break; - - case 127: - -/* Line 1455 of yacc.c */ -#line 700 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_NOMODIFY); } - break; - - case 128: - -/* Line 1455 of yacc.c */ -#line 701 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_NOPEER); } - break; - - case 129: - -/* Line 1455 of yacc.c */ -#line 702 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_NOQUERY); } - break; - - case 130: - -/* Line 1455 of yacc.c */ -#line 703 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_DONTSERVE); } - break; - - case 131: - -/* Line 1455 of yacc.c */ -#line 704 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_NOTRAP); } - break; - - case 132: - -/* Line 1455 of yacc.c */ -#line 705 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_DONTTRUST); } - break; - - case 133: - -/* Line 1455 of yacc.c */ -#line 706 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RESM_NTPONLY); } - break; - - case 134: - -/* Line 1455 of yacc.c */ -#line 707 "ntp_parser.y" - { (yyval.VoidPtr) = create_ival(RES_VERSION); } + { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), create_ival((yyvsp[(2) - (2)].Integer))); } break; case 135: /* Line 1455 of yacc.c */ -#line 711 "ntp_parser.y" +#line 720 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 136: /* Line 1455 of yacc.c */ -#line 712 "ntp_parser.y" +#line 722 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 137: /* Line 1455 of yacc.c */ -#line 716 "ntp_parser.y" +#line 726 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 138: /* Line 1455 of yacc.c */ -#line 717 "ntp_parser.y" +#line 727 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 139: /* Line 1455 of yacc.c */ -#line 718 "ntp_parser.y" +#line 728 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 140: /* Line 1455 of yacc.c */ -#line 727 "ntp_parser.y" +#line 737 "ntp_parser.y" { 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 731 "ntp_parser.y" +#line 742 "ntp_parser.y" { enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 142: /* Line 1455 of yacc.c */ -#line 732 "ntp_parser.y" +#line 744 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 143: /* Line 1455 of yacc.c */ -#line 737 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(CLK_HAVETIME1, (yyvsp[(2) - (2)].Double)); } +#line 748 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 144: /* Line 1455 of yacc.c */ -#line 739 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(CLK_HAVETIME2, (yyvsp[(2) - (2)].Double)); } +#line 749 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 145: /* Line 1455 of yacc.c */ -#line 741 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(CLK_HAVEVAL1, (yyvsp[(2) - (2)].Integer)); } +#line 750 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 146: /* Line 1455 of yacc.c */ -#line 743 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval(CLK_HAVEVAL2, (yyvsp[(2) - (2)].String)); } +#line 751 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 147: /* Line 1455 of yacc.c */ -#line 745 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG1, (yyvsp[(2) - (2)].Integer)); } +#line 752 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 148: /* Line 1455 of yacc.c */ -#line 747 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG2, (yyvsp[(2) - (2)].Integer)); } +#line 753 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 149: /* Line 1455 of yacc.c */ -#line 749 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG3, (yyvsp[(2) - (2)].Integer)); } +#line 754 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 150: /* Line 1455 of yacc.c */ -#line 751 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG4, (yyvsp[(2) - (2)].Integer)); } +#line 755 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 151: /* Line 1455 of yacc.c */ -#line 760 "ntp_parser.y" +#line 764 "ntp_parser.y" { append_queue(cfgt.enable_opts, (yyvsp[(2) - (2)].Queue)); } break; case 152: /* Line 1455 of yacc.c */ -#line 762 "ntp_parser.y" +#line 766 "ntp_parser.y" { append_queue(cfgt.disable_opts, (yyvsp[(2) - (2)].Queue)); } break; case 153: /* Line 1455 of yacc.c */ -#line 767 "ntp_parser.y" +#line 771 "ntp_parser.y" { if ((yyvsp[(2) - (2)].Attr_val) != NULL) (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); @@ -3172,7 +2981,7 @@ yyreduce: case 154: /* Line 1455 of yacc.c */ -#line 774 "ntp_parser.y" +#line 778 "ntp_parser.y" { if ((yyvsp[(1) - (1)].Attr_val) != NULL) (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); @@ -3184,49 +2993,49 @@ yyreduce: case 155: /* Line 1455 of yacc.c */ -#line 783 "ntp_parser.y" +#line 787 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 156: /* Line 1455 of yacc.c */ -#line 784 "ntp_parser.y" +#line 788 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 157: /* Line 1455 of yacc.c */ -#line 785 "ntp_parser.y" +#line 789 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 158: /* Line 1455 of yacc.c */ -#line 786 "ntp_parser.y" +#line 790 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 159: /* Line 1455 of yacc.c */ -#line 787 "ntp_parser.y" +#line 791 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 160: /* Line 1455 of yacc.c */ -#line 788 "ntp_parser.y" +#line 792 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 161: /* Line 1455 of yacc.c */ -#line 790 "ntp_parser.y" +#line 794 "ntp_parser.y" { if (input_from_file) (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); @@ -3240,77 +3049,77 @@ yyreduce: case 162: /* Line 1455 of yacc.c */ -#line 805 "ntp_parser.y" +#line 809 "ntp_parser.y" { append_queue(cfgt.tinker, (yyvsp[(2) - (2)].Queue)); } break; case 163: /* Line 1455 of yacc.c */ -#line 809 "ntp_parser.y" +#line 813 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 164: /* Line 1455 of yacc.c */ -#line 810 "ntp_parser.y" +#line 814 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 165: /* Line 1455 of yacc.c */ -#line 814 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_ALLAN, (yyvsp[(2) - (2)].Double)); } +#line 818 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 166: /* Line 1455 of yacc.c */ -#line 815 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_PHI, (yyvsp[(2) - (2)].Double)); } +#line 819 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 167: /* Line 1455 of yacc.c */ -#line 816 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_FREQ, (yyvsp[(2) - (2)].Double)); } +#line 820 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 168: /* Line 1455 of yacc.c */ -#line 817 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_HUFFPUFF, (yyvsp[(2) - (2)].Double)); } +#line 821 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 169: /* Line 1455 of yacc.c */ -#line 818 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_PANIC, (yyvsp[(2) - (2)].Double)); } +#line 822 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 170: /* Line 1455 of yacc.c */ -#line 819 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_MAX, (yyvsp[(2) - (2)].Double)); } +#line 823 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 171: /* Line 1455 of yacc.c */ -#line 820 "ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval(LOOP_MINSTEP, (yyvsp[(2) - (2)].Double)); } +#line 824 "ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 173: /* Line 1455 of yacc.c */ -#line 831 "ntp_parser.y" +#line 835 "ntp_parser.y" { if (curr_include_level >= MAXINCLUDELEVEL) { fprintf(stderr, "getconfig: Maximum include file level exceeded.\n"); @@ -3331,7 +3140,7 @@ yyreduce: case 174: /* Line 1455 of yacc.c */ -#line 847 "ntp_parser.y" +#line 851 "ntp_parser.y" { while (curr_include_level != -1) FCLOSE(fp[curr_include_level--]); @@ -3341,49 +3150,49 @@ yyreduce: case 175: /* Line 1455 of yacc.c */ -#line 853 "ntp_parser.y" +#line 857 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double))); } break; case 176: /* Line 1455 of yacc.c */ -#line 855 "ntp_parser.y" +#line 859 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer))); } break; case 177: /* Line 1455 of yacc.c */ -#line 857 "ntp_parser.y" +#line 861 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double))); } break; case 178: /* Line 1455 of yacc.c */ -#line 859 "ntp_parser.y" +#line 863 "ntp_parser.y" { /* Null action, possibly all null parms */ } break; case 179: /* Line 1455 of yacc.c */ -#line 861 "ntp_parser.y" +#line 865 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String))); } break; case 180: /* Line 1455 of yacc.c */ -#line 864 "ntp_parser.y" +#line 868 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String))); } break; case 181: /* Line 1455 of yacc.c */ -#line 866 "ntp_parser.y" +#line 870 "ntp_parser.y" { if (input_from_file) enqueue(cfgt.vars, @@ -3398,21 +3207,21 @@ yyreduce: case 182: /* Line 1455 of yacc.c */ -#line 877 "ntp_parser.y" +#line 881 "ntp_parser.y" { append_queue(cfgt.logconfig, (yyvsp[(2) - (2)].Queue)); } break; case 183: /* Line 1455 of yacc.c */ -#line 879 "ntp_parser.y" +#line 883 "ntp_parser.y" { append_queue(cfgt.phone, (yyvsp[(2) - (2)].Queue)); } break; case 184: /* Line 1455 of yacc.c */ -#line 881 "ntp_parser.y" +#line 885 "ntp_parser.y" { if (input_from_file) enqueue(cfgt.vars, @@ -3427,49 +3236,49 @@ yyreduce: case 185: /* Line 1455 of yacc.c */ -#line 891 "ntp_parser.y" +#line 895 "ntp_parser.y" { enqueue(cfgt.setvar, (yyvsp[(2) - (2)].Set_var)); } break; case 186: /* Line 1455 of yacc.c */ -#line 893 "ntp_parser.y" +#line 897 "ntp_parser.y" { enqueue(cfgt.trap, create_addr_opts_node((yyvsp[(2) - (2)].Address_node), NULL)); } break; case 187: /* Line 1455 of yacc.c */ -#line 895 "ntp_parser.y" +#line 899 "ntp_parser.y" { enqueue(cfgt.trap, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); } break; case 188: /* Line 1455 of yacc.c */ -#line 897 "ntp_parser.y" +#line 901 "ntp_parser.y" { append_queue(cfgt.ttl, (yyvsp[(2) - (2)].Queue)); } break; case 189: /* Line 1455 of yacc.c */ -#line 899 "ntp_parser.y" +#line 903 "ntp_parser.y" { enqueue(cfgt.qos, create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String))); } break; case 190: /* Line 1455 of yacc.c */ -#line 904 "ntp_parser.y" +#line 908 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (1)].String))); } break; case 191: /* Line 1455 of yacc.c */ -#line 906 "ntp_parser.y" +#line 910 "ntp_parser.y" { 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; @@ -3477,70 +3286,70 @@ yyreduce: case 192: /* Line 1455 of yacc.c */ -#line 909 "ntp_parser.y" +#line 913 "ntp_parser.y" { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, "\0")); } break; case 193: /* Line 1455 of yacc.c */ -#line 914 "ntp_parser.y" - { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (4)].String), (yyvsp[(3) - (4)].String), DEF); } +#line 918 "ntp_parser.y" + { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (4)].String), (yyvsp[(3) - (4)].String), (yyvsp[(4) - (4)].Integer)); } break; case 194: /* Line 1455 of yacc.c */ -#line 916 "ntp_parser.y" +#line 920 "ntp_parser.y" { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (3)].String), (yyvsp[(3) - (3)].String), 0); } break; case 195: /* Line 1455 of yacc.c */ -#line 921 "ntp_parser.y" +#line 925 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 196: /* Line 1455 of yacc.c */ -#line 922 "ntp_parser.y" +#line 926 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 197: /* Line 1455 of yacc.c */ -#line 926 "ntp_parser.y" +#line 930 "ntp_parser.y" { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 198: /* Line 1455 of yacc.c */ -#line 927 "ntp_parser.y" +#line 931 "ntp_parser.y" { (yyval.Attr_val) = create_attr_pval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Address_node)); } break; case 199: /* Line 1455 of yacc.c */ -#line 931 "ntp_parser.y" +#line 935 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); } break; case 200: /* Line 1455 of yacc.c */ -#line 932 "ntp_parser.y" +#line 936 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); } break; case 201: /* Line 1455 of yacc.c */ -#line 937 "ntp_parser.y" +#line 941 "ntp_parser.y" { char prefix = (yyvsp[(1) - (1)].String)[0]; char *type = (yyvsp[(1) - (1)].String) + 1; @@ -3557,7 +3366,7 @@ yyreduce: case 202: /* Line 1455 of yacc.c */ -#line 952 "ntp_parser.y" +#line 956 "ntp_parser.y" { enqueue(cfgt.nic_rules, create_nic_rule_node((yyvsp[(3) - (3)].Integer), NULL, (yyvsp[(2) - (3)].Integer))); @@ -3567,7 +3376,7 @@ yyreduce: case 203: /* Line 1455 of yacc.c */ -#line 957 "ntp_parser.y" +#line 961 "ntp_parser.y" { enqueue(cfgt.nic_rules, create_nic_rule_node(0, (yyvsp[(3) - (3)].String), (yyvsp[(2) - (3)].Integer))); @@ -3577,49 +3386,49 @@ yyreduce: case 212: /* Line 1455 of yacc.c */ -#line 987 "ntp_parser.y" +#line 991 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), create_ival((yyvsp[(2) - (2)].Integer))); } break; case 213: /* Line 1455 of yacc.c */ -#line 988 "ntp_parser.y" +#line 992 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue(create_ival((yyvsp[(1) - (1)].Integer))); } break; case 214: /* Line 1455 of yacc.c */ -#line 992 "ntp_parser.y" +#line 996 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), create_pval((yyvsp[(2) - (2)].String))); } break; case 215: /* Line 1455 of yacc.c */ -#line 993 "ntp_parser.y" +#line 997 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue(create_pval((yyvsp[(1) - (1)].String))); } break; case 216: /* Line 1455 of yacc.c */ -#line 997 "ntp_parser.y" +#line 1001 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Address_node)); } break; case 217: /* Line 1455 of yacc.c */ -#line 998 "ntp_parser.y" +#line 1002 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Address_node)); } break; case 218: /* Line 1455 of yacc.c */ -#line 1003 "ntp_parser.y" +#line 1007 "ntp_parser.y" { if ((yyvsp[(1) - (1)].Integer) != 0 && (yyvsp[(1) - (1)].Integer) != 1) { yyerror("Integer value is not boolean (0 or 1). Assuming 1"); @@ -3633,28 +3442,28 @@ yyreduce: case 219: /* Line 1455 of yacc.c */ -#line 1011 "ntp_parser.y" +#line 1015 "ntp_parser.y" { (yyval.Integer) = 1; } break; case 220: /* Line 1455 of yacc.c */ -#line 1012 "ntp_parser.y" +#line 1016 "ntp_parser.y" { (yyval.Integer) = 0; } break; case 221: /* Line 1455 of yacc.c */ -#line 1016 "ntp_parser.y" +#line 1020 "ntp_parser.y" { (yyval.Double) = (double)(yyvsp[(1) - (1)].Integer); } break; case 223: /* Line 1455 of yacc.c */ -#line 1027 "ntp_parser.y" +#line 1031 "ntp_parser.y" { cfgt.sim_details = create_sim_node((yyvsp[(3) - (5)].Queue), (yyvsp[(4) - (5)].Queue)); @@ -3666,147 +3475,147 @@ yyreduce: case 224: /* Line 1455 of yacc.c */ -#line 1041 "ntp_parser.y" +#line 1045 "ntp_parser.y" { old_config_style = 0; } break; case 225: /* Line 1455 of yacc.c */ -#line 1045 "ntp_parser.y" +#line 1049 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (3)].Queue), (yyvsp[(2) - (3)].Attr_val)); } break; case 226: /* Line 1455 of yacc.c */ -#line 1046 "ntp_parser.y" +#line 1050 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (2)].Attr_val)); } break; case 227: /* Line 1455 of yacc.c */ -#line 1050 "ntp_parser.y" +#line 1054 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; case 228: /* Line 1455 of yacc.c */ -#line 1051 "ntp_parser.y" +#line 1055 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; case 229: /* Line 1455 of yacc.c */ -#line 1055 "ntp_parser.y" +#line 1059 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Sim_server)); } break; case 230: /* Line 1455 of yacc.c */ -#line 1056 "ntp_parser.y" +#line 1060 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Sim_server)); } break; case 231: /* Line 1455 of yacc.c */ -#line 1061 "ntp_parser.y" +#line 1065 "ntp_parser.y" { (yyval.Sim_server) = create_sim_server((yyvsp[(1) - (5)].Address_node), (yyvsp[(3) - (5)].Double), (yyvsp[(4) - (5)].Queue)); } break; case 232: /* Line 1455 of yacc.c */ -#line 1065 "ntp_parser.y" +#line 1069 "ntp_parser.y" { (yyval.Double) = (yyvsp[(3) - (4)].Double); } break; case 233: /* Line 1455 of yacc.c */ -#line 1069 "ntp_parser.y" +#line 1073 "ntp_parser.y" { (yyval.Address_node) = (yyvsp[(3) - (3)].Address_node); } break; case 234: /* Line 1455 of yacc.c */ -#line 1073 "ntp_parser.y" +#line 1077 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Sim_script)); } break; case 235: /* Line 1455 of yacc.c */ -#line 1074 "ntp_parser.y" +#line 1078 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Sim_script)); } break; case 236: /* Line 1455 of yacc.c */ -#line 1079 "ntp_parser.y" +#line 1083 "ntp_parser.y" { (yyval.Sim_script) = create_sim_script_info((yyvsp[(3) - (6)].Double), (yyvsp[(5) - (6)].Queue)); } break; case 237: /* Line 1455 of yacc.c */ -#line 1083 "ntp_parser.y" +#line 1087 "ntp_parser.y" { (yyval.Queue) = enqueue((yyvsp[(1) - (3)].Queue), (yyvsp[(2) - (3)].Attr_val)); } break; case 238: /* Line 1455 of yacc.c */ -#line 1084 "ntp_parser.y" +#line 1088 "ntp_parser.y" { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (2)].Attr_val)); } break; case 239: /* Line 1455 of yacc.c */ -#line 1089 "ntp_parser.y" +#line 1093 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; case 240: /* Line 1455 of yacc.c */ -#line 1091 "ntp_parser.y" +#line 1095 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; case 241: /* Line 1455 of yacc.c */ -#line 1093 "ntp_parser.y" +#line 1097 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; case 242: /* Line 1455 of yacc.c */ -#line 1095 "ntp_parser.y" +#line 1099 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; case 243: /* Line 1455 of yacc.c */ -#line 1097 "ntp_parser.y" +#line 1101 "ntp_parser.y" { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; /* Line 1455 of yacc.c */ -#line 3810 "ntp_parser.c" +#line 3619 "ntp_parser.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -4018,7 +3827,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 1101 "ntp_parser.y" +#line 1105 "ntp_parser.y" void yyerror (char *msg) diff --git a/ntpd/ntp_parser.h b/ntpd/ntp_parser.h index 2e6cc0aa2..5ac2ed52f 100644 --- a/ntpd/ntp_parser.h +++ b/ntpd/ntp_parser.h @@ -151,7 +151,7 @@ T_Protostats = 367, T_Pw = 368, T_Qos = 369, - T_RandFile = 370, + T_Randfile = 370, T_Rawstats = 371, T_Refid = 372, T_Requestkey = 373, @@ -315,7 +315,7 @@ #define T_Protostats 367 #define T_Pw 368 #define T_Qos 369 -#define T_RandFile 370 +#define T_Randfile 370 #define T_Rawstats 371 #define T_Refid 372 #define T_Requestkey 373 @@ -373,7 +373,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 51 "ntp_parser.y" +#line 50 "ntp_parser.y" char *String; double Double; diff --git a/ntpd/ntp_parser.y b/ntpd/ntp_parser.y index ff7a3d9a0..91398b8fd 100644 --- a/ntpd/ntp_parser.y +++ b/ntpd/ntp_parser.y @@ -39,7 +39,6 @@ #define YYMAXDEPTH 1000 /* stop the madness sooner */ void yyerror (char *msg); extern int input_from_file; /* 0=input from ntpq :config */ - extern int cryptosw; %} /* @@ -176,7 +175,7 @@ %token T_Protostats %token T_Pw %token T_Qos -%token T_RandFile +%token T_Randfile %token T_Rawstats %token T_Refid %token T_Requestkey @@ -232,7 +231,7 @@ /*** NON-TERMINALS ***/ -%type access_control_flag +%type access_control_flag %type ac_flag_list %type address %type address_list @@ -259,7 +258,7 @@ %type number %type option %type option_list -%type stat +%type stat %type stats_list %type string_list %type system_option @@ -371,18 +370,18 @@ option_list ; option - : T_Autokey { $$ = create_attr_ival(T_Flag, FLAG_SKEY); } + : T_Autokey { $$ = create_attr_ival(T_Flag, $1); } | T_Bias number { $$ = create_attr_dval($1, $2); } - | T_Burst { $$ = create_attr_ival(T_Flag, FLAG_BURST); } - | T_Iburst { $$ = create_attr_ival(T_Flag, FLAG_IBURST); } + | T_Burst { $$ = create_attr_ival(T_Flag, $1); } + | T_Iburst { $$ = create_attr_ival(T_Flag, $1); } | T_Key T_Integer { $$ = create_attr_ival($1, $2); } | T_Minpoll T_Integer { $$ = create_attr_ival($1, $2); } | T_Maxpoll T_Integer { $$ = create_attr_ival($1, $2); } - | T_Noselect { $$ = create_attr_ival(T_Flag, FLAG_NOSELECT); } - | T_Preempt { $$ = create_attr_ival(T_Flag, FLAG_PREEMPT); } - | T_Prefer { $$ = create_attr_ival(T_Flag, FLAG_PREFER); } - | T_True { $$ = create_attr_ival(T_Flag, FLAG_TRUE); } - | T_Xleave { $$ = create_attr_ival(T_Flag, FLAG_XLEAVE); } + | T_Noselect { $$ = create_attr_ival(T_Flag, $1); } + | T_Preempt { $$ = create_attr_ival(T_Flag, $1); } + | T_Prefer { $$ = create_attr_ival(T_Flag, $1); } + | T_True { $$ = create_attr_ival(T_Flag, $1); } + | T_Xleave { $$ = create_attr_ival(T_Flag, $1); } | T_Ttl T_Integer { $$ = create_attr_ival($1, $2); } | T_Mode T_Integer { $$ = create_attr_ival($1, $2); } | T_Version T_Integer { $$ = create_attr_ival($1, $2); } @@ -434,7 +433,7 @@ authentication_command { cfgt.auth.control_key = $2; } | T_Crypto crypto_command_line { - cryptosw++; + cfgt.auth.cryptosw++; append_queue(cfgt.auth.crypto_cmd_list, $2); } | T_Keys T_String @@ -456,23 +455,38 @@ crypto_command_line ; crypto_command_list - : crypto_command_list crypto_command { $$ = enqueue($1, $2); } - | crypto_command { $$ = enqueue_in_new_queue($1); } + : crypto_command_list crypto_command + { + if ($2 != NULL) + $$ = enqueue($1, $2); + else + $$ = $1; + } + | crypto_command + { + if ($1 != NULL) + $$ = enqueue_in_new_queue($1); + else + $$ = create_queue(); + } ; crypto_command : T_Host T_String - { $$ = create_attr_sval(CRYPTO_CONF_PRIV, $2); } + { $$ = create_attr_sval($1, $2); } | T_Ident T_String - { $$ = create_attr_sval(CRYPTO_CONF_IDENT, $2); } + { $$ = create_attr_sval($1, $2); } | T_Pw T_String - { $$ = create_attr_sval(CRYPTO_CONF_PW, $2); } - | T_RandFile T_String - { $$ = create_attr_sval(CRYPTO_CONF_RAND, $2); } - | T_Revoke T_Integer - { cfgt.auth.revoke = $2; } + { $$ = create_attr_sval($1, $2); } + | T_Randfile T_String + { $$ = create_attr_sval($1, $2); } | T_Sign T_String - { $$ = create_attr_sval(CRYPTO_CONF_SIGN, $2); } + { $$ = create_attr_sval($1, $2); } + | T_Revoke T_Integer + { + $$ = NULL; + cfgt.auth.revoke = $2; + } ; @@ -492,27 +506,27 @@ tos_option_list tos_option : T_Ceiling T_Integer - { $$ = create_attr_dval(PROTO_CEILING, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } | T_Floor T_Integer - { $$ = create_attr_dval(PROTO_FLOOR, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } | T_Cohort boolean - { $$ = create_attr_dval(PROTO_COHORT, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } | T_Orphan T_Integer - { $$ = create_attr_dval(PROTO_ORPHAN, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } | T_Mindist number - { $$ = create_attr_dval(PROTO_MINDISP, $2); } + { $$ = create_attr_dval($1, $2); } | T_Maxdist number - { $$ = create_attr_dval(PROTO_MAXDIST, $2); } + { $$ = create_attr_dval($1, $2); } | T_Minclock number - { $$ = create_attr_dval(PROTO_MINCLOCK, $2); } + { $$ = create_attr_dval($1, $2); } | T_Maxclock number - { $$ = create_attr_dval(PROTO_MAXCLOCK, $2); } + { $$ = create_attr_dval($1, $2); } | T_Minsane T_Integer - { $$ = create_attr_dval(PROTO_MINSANE, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } | T_Beacon T_Integer - { $$ = create_attr_dval(PROTO_BEACON, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } | T_Maxhop T_Integer - { $$ = create_attr_dval(PROTO_MAXHOP, (double)$2); } + { $$ = create_attr_dval($1, (double)$2); } ; @@ -540,27 +554,19 @@ monitoring_command ; stats_list - : stats_list stat { $$ = enqueue($1, $2); } - | stat { $$ = enqueue_in_new_queue($1); } + : stats_list stat { $$ = enqueue($1, create_ival($2)); } + | stat { $$ = enqueue_in_new_queue(create_ival($1)); } ; stat : T_Clockstats - { $$ = create_pval("clockstats"); } | T_Cryptostats - { $$ = create_pval("cryptostats"); } | T_Loopstats - { $$ = create_pval("loopstats"); } | T_Peerstats - { $$ = create_pval("peerstats"); } | T_Rawstats - { $$ = create_pval("rawstats"); } | T_Sysstats - { $$ = create_pval("sysstats"); } | T_Timingstats - { $$ = create_pval("timingstats"); } | T_Protostats - { $$ = create_pval("protostats"); } ; filegen_option_list @@ -623,13 +629,13 @@ filegen_option ; filegen_type - : T_None { $$ = FILEGEN_NONE; } - | T_Pid { $$ = FILEGEN_PID; } - | T_Day { $$ = FILEGEN_DAY; } - | T_Week { $$ = FILEGEN_WEEK; } - | T_Month { $$ = FILEGEN_MONTH; } - | T_Year { $$ = FILEGEN_YEAR; } - | T_Age { $$ = FILEGEN_AGE; } + : T_None + | T_Pid + | T_Day + | T_Week + | T_Month + | T_Year + | T_Age ; @@ -639,7 +645,7 @@ filegen_type access_control_command : T_Discard discard_option_list - { + { append_queue(cfgt.discard_opts, $2); } | T_Restrict address ac_flag_list @@ -686,30 +692,34 @@ access_control_command ; ac_flag_list - : /* Null statement */ { $$ = create_queue(); } - | ac_flag_list access_control_flag { $$ = enqueue($1, $2); } + : /* Null statement */ + { $$ = create_queue(); } + | ac_flag_list access_control_flag + { $$ = enqueue($1, create_ival($2)); } ; access_control_flag - : T_Flake { $$ = create_ival(RES_TIMEOUT); } - | T_Ignore { $$ = create_ival(RES_IGNORE); } - | T_Kod { $$ = create_ival(RES_KOD); } - | T_Mssntp { $$ = create_ival(RES_MSSNTP); } - | T_Limited { $$ = create_ival(RES_LIMITED); } - | T_Lowpriotrap { $$ = create_ival(RES_LPTRAP); } - | T_Nomodify { $$ = create_ival(RES_NOMODIFY); } - | T_Nopeer { $$ = create_ival(RES_NOPEER); } - | T_Noquery { $$ = create_ival(RES_NOQUERY); } - | T_Noserve { $$ = create_ival(RES_DONTSERVE); } - | T_Notrap { $$ = create_ival(RES_NOTRAP); } - | T_Notrust { $$ = create_ival(RES_DONTTRUST); } - | T_Ntpport { $$ = create_ival(RESM_NTPONLY); } - | T_Version { $$ = create_ival(RES_VERSION); } + : T_Flake + | T_Ignore + | T_Kod + | T_Mssntp + | T_Limited + | T_Lowpriotrap + | T_Nomodify + | T_Nopeer + | T_Noquery + | T_Noserve + | T_Notrap + | T_Notrust + | T_Ntpport + | T_Version ; discard_option_list - : discard_option_list discard_option { $$ = enqueue($1, $2); } - | discard_option { $$ = enqueue_in_new_queue($1); } + : discard_option_list discard_option + { $$ = enqueue($1, $2); } + | discard_option + { $$ = enqueue_in_new_queue($1); } ; discard_option @@ -728,27 +738,21 @@ fudge_command ; fudge_factor_list - : fudge_factor_list fudge_factor { enqueue($1, $2); } - | fudge_factor { $$ = enqueue_in_new_queue($1); } + : fudge_factor_list fudge_factor + { enqueue($1, $2); } + | fudge_factor + { $$ = enqueue_in_new_queue($1); } ; fudge_factor - : T_Time1 number - { $$ = create_attr_dval(CLK_HAVETIME1, $2); } - | T_Time2 number - { $$ = create_attr_dval(CLK_HAVETIME2, $2); } - | T_Stratum T_Integer - { $$ = create_attr_ival(CLK_HAVEVAL1, $2); } - | T_Refid T_String - { $$ = create_attr_sval(CLK_HAVEVAL2, $2); } - | T_Flag1 boolean - { $$ = create_attr_ival(CLK_HAVEFLAG1, $2); } - | T_Flag2 boolean - { $$ = create_attr_ival(CLK_HAVEFLAG2, $2); } - | T_Flag3 boolean - { $$ = create_attr_ival(CLK_HAVEFLAG3, $2); } - | T_Flag4 boolean - { $$ = create_attr_ival(CLK_HAVEFLAG4, $2); } + : T_Time1 number { $$ = create_attr_dval($1, $2); } + | T_Time2 number { $$ = create_attr_dval($1, $2); } + | T_Stratum T_Integer { $$ = create_attr_ival($1, $2); } + | T_Refid T_String { $$ = create_attr_sval($1, $2); } + | T_Flag1 boolean { $$ = create_attr_ival($1, $2); } + | T_Flag2 boolean { $$ = create_attr_ival($1, $2); } + | T_Flag3 boolean { $$ = create_attr_ival($1, $2); } + | T_Flag4 boolean { $$ = create_attr_ival($1, $2); } ; /* Command for System Options @@ -811,13 +815,13 @@ tinker_option_list ; tinker_option - : T_Allan number { $$ = create_attr_dval(LOOP_ALLAN, $2); } - | T_Dispersion number { $$ = create_attr_dval(LOOP_PHI, $2); } - | T_Freq number { $$ = create_attr_dval(LOOP_FREQ, $2); } - | T_Huffpuff number { $$ = create_attr_dval(LOOP_HUFFPUFF, $2); } - | T_Panic number { $$ = create_attr_dval(LOOP_PANIC, $2); } - | T_Step number { $$ = create_attr_dval(LOOP_MAX, $2); } - | T_Stepout number { $$ = create_attr_dval(LOOP_MINSTEP, $2); } + : T_Allan number { $$ = create_attr_dval($1, $2); } + | T_Dispersion number { $$ = create_attr_dval($1, $2); } + | T_Freq number { $$ = create_attr_dval($1, $2); } + | T_Huffpuff number { $$ = create_attr_dval($1, $2); } + | T_Panic number { $$ = create_attr_dval($1, $2); } + | T_Step number { $$ = create_attr_dval($1, $2); } + | T_Stepout number { $$ = create_attr_dval($1, $2); } ; @@ -911,7 +915,7 @@ drift_parm variable_assign : T_String '=' T_String T_Default - { $$ = create_setvar_node($1, $3, DEF); } + { $$ = create_setvar_node($1, $3, $4); } | T_String '=' T_String { $$ = create_setvar_node($1, $3, 0); } ; diff --git a/ntpd/ntp_scanner.c b/ntpd/ntp_scanner.c index b277ad26a..21c6fcd59 100644 --- a/ntpd/ntp_scanner.c +++ b/ntpd/ntp_scanner.c @@ -33,11 +33,9 @@ struct state { char ch; /* Input character associated with the state */ struct state *next_state; /* Next state to advance to on reading ch */ - struct state *next_char; /* Pointer to next character associated with - the state */ + struct state *next_char_s;/* State to check having read any other */ int token; /* Token to be returned on successful parse */ - int expect_string; /* A boolean flag, which when set, indicates - that the next token should be a string */ + follby followedby; /* Forces the next token(s) to T_String */ }; @@ -45,12 +43,191 @@ struct state { * ------------------------ */ -#define MAX_LEXEME 1024+1 /* The maximum size of a lexeme */ +#define MAX_LEXEME (1024 + 1) /* The maximum size of a lexeme */ char yytext[MAX_LEXEME]; /* Buffer for storing the input text/lexeme */ struct state *key_scanner; /* A FSA for recognizing keywords */ extern int input_from_file; +struct key_tok ntp_keyword_list[] = { +{ "automax", T_Automax, FOLLBY_TOKEN }, +{ "broadcast", T_Broadcast, FOLLBY_STRING }, +{ "broadcastclient", T_Broadcastclient, FOLLBY_TOKEN }, +{ "broadcastdelay", T_Broadcastdelay, FOLLBY_TOKEN }, +{ "calldelay", T_Calldelay, FOLLBY_TOKEN }, +{ "disable", T_Disable, FOLLBY_TOKEN }, +{ "driftfile", T_Driftfile, FOLLBY_STRING }, +{ "enable", T_Enable, FOLLBY_TOKEN }, +{ "end", T_End, FOLLBY_TOKEN }, +{ "filegen", T_Filegen, FOLLBY_TOKEN }, +{ "fudge", T_Fudge, FOLLBY_STRING }, +{ "includefile", T_Includefile, FOLLBY_STRING }, +{ "leapfile", T_Leapfile, FOLLBY_STRING }, +{ "logconfig", T_Logconfig, FOLLBY_STRINGS_TO_EOC }, +{ "logfile", T_Logfile, FOLLBY_STRING }, +{ "manycastclient", T_Manycastclient, FOLLBY_STRING }, +{ "manycastserver", T_Manycastserver, FOLLBY_STRINGS_TO_EOC }, +{ "multicastclient", T_Multicastclient, FOLLBY_STRINGS_TO_EOC }, +{ "peer", T_Peer, FOLLBY_STRING }, +{ "phone", T_Phone, FOLLBY_STRINGS_TO_EOC }, +{ "pidfile", T_Pidfile, FOLLBY_STRING }, +{ "pool", T_Pool, FOLLBY_STRING }, +{ "discard", T_Discard, FOLLBY_TOKEN }, +{ "restrict", T_Restrict, FOLLBY_TOKEN }, +{ "server", T_Server, FOLLBY_STRING }, +{ "setvar", T_Setvar, FOLLBY_TOKEN }, +{ "statistics", T_Statistics, FOLLBY_TOKEN }, +{ "statsdir", T_Statsdir, FOLLBY_STRING }, +{ "tick", T_Tick, FOLLBY_TOKEN }, +{ "tinker", T_Tinker, FOLLBY_TOKEN }, +{ "tos", T_Tos, FOLLBY_TOKEN }, +{ "trap", T_Trap, FOLLBY_STRING }, +{ "unconfig", T_Unconfig, FOLLBY_STRING }, +{ "unpeer", T_Unpeer, FOLLBY_STRING }, +/* authentication_command */ +{ "controlkey", T_ControlKey, FOLLBY_TOKEN }, +{ "crypto", T_Crypto, FOLLBY_TOKEN }, +{ "keys", T_Keys, FOLLBY_STRING }, +{ "keysdir", T_Keysdir, FOLLBY_STRING }, +{ "ntpsigndsocket", T_NtpSignDsocket, FOLLBY_STRING }, +{ "requestkey", T_Requestkey, FOLLBY_TOKEN }, +{ "revoke", T_Revoke, FOLLBY_TOKEN }, +{ "trustedkey", T_Trustedkey, FOLLBY_TOKEN }, +/* IPv4/IPv6 protocol override flag */ +{ "-4", T_Ipv4_flag, FOLLBY_TOKEN }, +{ "-6", T_Ipv6_flag, FOLLBY_TOKEN }, +/* option */ +{ "autokey", T_Autokey, FOLLBY_TOKEN }, +{ "bias", T_Bias, FOLLBY_TOKEN }, +{ "burst", T_Burst, FOLLBY_TOKEN }, +{ "iburst", T_Iburst, FOLLBY_TOKEN }, +{ "key", T_Key, FOLLBY_TOKEN }, +{ "maxpoll", T_Maxpoll, FOLLBY_TOKEN }, +{ "minpoll", T_Minpoll, FOLLBY_TOKEN }, +{ "mode", T_Mode, FOLLBY_TOKEN }, +{ "noselect", T_Noselect, FOLLBY_TOKEN }, +{ "preempt", T_Preempt, FOLLBY_TOKEN }, +{ "true", T_True, FOLLBY_TOKEN }, +{ "prefer", T_Prefer, FOLLBY_TOKEN }, +{ "ttl", T_Ttl, FOLLBY_TOKEN }, +{ "version", T_Version, FOLLBY_TOKEN }, +{ "xleave", T_Xleave, FOLLBY_TOKEN }, +/* crypto_command */ +{ "host", T_Host, FOLLBY_STRING }, +{ "ident", T_Ident, FOLLBY_STRING }, +{ "pw", T_Pw, FOLLBY_STRING }, +{ "randfile", T_Randfile, FOLLBY_STRING }, +{ "sign", T_Sign, FOLLBY_STRING }, +/*** MONITORING COMMANDS ***/ +/* stat */ +{ "clockstats", T_Clockstats, FOLLBY_TOKEN }, +{ "cryptostats", T_Cryptostats, FOLLBY_TOKEN }, +{ "loopstats", T_Loopstats, FOLLBY_TOKEN }, +{ "peerstats", T_Peerstats, FOLLBY_TOKEN }, +{ "rawstats", T_Rawstats, FOLLBY_TOKEN }, +{ "sysstats", T_Sysstats, FOLLBY_TOKEN }, +{ "protostats", T_Protostats, FOLLBY_TOKEN }, +{ "timingstats", T_Timingstats, FOLLBY_TOKEN }, +/* filegen_option */ +{ "disable", T_Disable, FOLLBY_TOKEN }, +{ "enable", T_Enable, FOLLBY_TOKEN }, +{ "file", T_File, FOLLBY_STRING }, +{ "link", T_Link, FOLLBY_TOKEN }, +{ "nolink", T_Nolink, FOLLBY_TOKEN }, +{ "type", T_Type, FOLLBY_TOKEN }, +/* filegen_type */ +{ "age", T_Age, FOLLBY_TOKEN }, +{ "day", T_Day, FOLLBY_TOKEN }, +{ "month", T_Month, FOLLBY_TOKEN }, +{ "none", T_None, FOLLBY_TOKEN }, +{ "pid", T_Pid, FOLLBY_TOKEN }, +{ "week", T_Week, FOLLBY_TOKEN }, +{ "year", T_Year, FOLLBY_TOKEN }, +/*** ORPHAN MODE COMMANDS ***/ +/* tos_option */ +{ "minclock", T_Minclock, FOLLBY_TOKEN }, +{ "maxclock", T_Maxclock, FOLLBY_TOKEN }, +{ "minsane", T_Minsane, FOLLBY_TOKEN }, +{ "floor", T_Floor, FOLLBY_TOKEN }, +{ "ceiling", T_Ceiling, FOLLBY_TOKEN }, +{ "cohort", T_Cohort, FOLLBY_TOKEN }, +{ "mindist", T_Mindist, FOLLBY_TOKEN }, +{ "maxdist", T_Maxdist, FOLLBY_TOKEN }, +{ "maxhop", T_Maxhop, FOLLBY_TOKEN }, +{ "beacon", T_Beacon, FOLLBY_TOKEN }, +{ "orphan", T_Orphan, FOLLBY_TOKEN }, +/* access_control_flag */ +{ "default", T_Default, FOLLBY_TOKEN }, +{ "flake", T_Flake, FOLLBY_TOKEN }, +{ "ignore", T_Ignore, FOLLBY_TOKEN }, +{ "limited", T_Limited, FOLLBY_TOKEN }, +{ "mssntp", T_Mssntp, FOLLBY_TOKEN }, +{ "kod", T_Kod, FOLLBY_TOKEN }, +{ "lowpriotrap", T_Lowpriotrap, FOLLBY_TOKEN }, +{ "mask", T_Mask, FOLLBY_TOKEN }, +{ "nomodify", T_Nomodify, FOLLBY_TOKEN }, +{ "nopeer", T_Nopeer, FOLLBY_TOKEN }, +{ "noquery", T_Noquery, FOLLBY_TOKEN }, +{ "noserve", T_Noserve, FOLLBY_TOKEN }, +{ "notrap", T_Notrap, FOLLBY_TOKEN }, +{ "notrust", T_Notrust, FOLLBY_TOKEN }, +{ "ntpport", T_Ntpport, FOLLBY_TOKEN }, +{ "version", T_Version, FOLLBY_TOKEN }, +/* discard_option */ +{ "average", T_Average, FOLLBY_TOKEN }, +{ "minimum", T_Minimum, FOLLBY_TOKEN }, +{ "monitor", T_Monitor, FOLLBY_TOKEN }, +/* fudge_factor */ +{ "flag1", T_Flag1, FOLLBY_TOKEN }, +{ "flag2", T_Flag2, FOLLBY_TOKEN }, +{ "flag3", T_Flag3, FOLLBY_TOKEN }, +{ "flag4", T_Flag4, FOLLBY_TOKEN }, +{ "refid", T_Refid, FOLLBY_STRING }, +{ "stratum", T_Stratum, FOLLBY_TOKEN }, +{ "time1", T_Time1, FOLLBY_TOKEN }, +{ "time2", T_Time2, FOLLBY_TOKEN }, +/* system_option */ +{ "auth", T_Auth, FOLLBY_TOKEN }, +{ "bclient", T_Bclient, FOLLBY_TOKEN }, +{ "calibrate", T_Calibrate, FOLLBY_TOKEN }, +{ "kernel", T_Kernel, FOLLBY_TOKEN }, +{ "monitor", T_Monitor, FOLLBY_TOKEN }, +{ "ntp", T_Ntp, FOLLBY_TOKEN }, +{ "stats", T_Stats, FOLLBY_TOKEN }, +/* tinker_option */ +{ "step", T_Step, FOLLBY_TOKEN }, +{ "panic", T_Panic, FOLLBY_TOKEN }, +{ "dispersion", T_Dispersion, FOLLBY_TOKEN }, +{ "stepout", T_Stepout, FOLLBY_TOKEN }, +{ "allan", T_Allan, FOLLBY_TOKEN }, +{ "huffpuff", T_Huffpuff, FOLLBY_TOKEN }, +{ "freq", T_Freq, FOLLBY_TOKEN }, +/* miscellaneous_command */ +{ "port", T_Port, FOLLBY_TOKEN }, +{ "interface", T_Interface, FOLLBY_TOKEN }, +{ "qos", T_Qos, FOLLBY_TOKEN }, +{ "saveconfigdir", T_Saveconfigdir, FOLLBY_STRING }, +/* interface_command (ignore and interface already defined) */ +{ "nic", T_Nic, FOLLBY_TOKEN }, +{ "all", T_All, FOLLBY_TOKEN }, +{ "ipv4", T_Ipv4, FOLLBY_TOKEN }, +{ "ipv6", T_Ipv6, FOLLBY_TOKEN }, +{ "listen", T_Listen, FOLLBY_TOKEN }, +{ "drop", T_Drop, FOLLBY_TOKEN }, +/* simulator commands */ +{ "simulate", T_Simulate, FOLLBY_TOKEN }, +{ "simulation_duration",T_Sim_Duration, FOLLBY_TOKEN }, +{ "beep_delay", T_Beep_Delay, FOLLBY_TOKEN }, +{ "duration", T_Duration, FOLLBY_TOKEN }, +{ "server_offset", T_Server_Offset, FOLLBY_TOKEN }, +{ "freq_offset", T_Freq_Offset, FOLLBY_TOKEN }, +{ "wander", T_Wander, FOLLBY_TOKEN }, +{ "jitter", T_Jitter, FOLLBY_TOKEN }, +{ "prop_delay", T_Prop_Delay, FOLLBY_TOKEN }, +{ "proc_delay", T_Proc_Delay, FOLLBY_TOKEN }, +{ NULL, 0, 0 } }; + + /* CONSTANTS * --------- */ @@ -68,6 +245,8 @@ const char special_chars[] = "{}(),;|="; */ char get_next_char(void); +static int is_keyword(char *lexeme, follby *pfollowedby); + /* Define a function to create the states of the scanner. This function * is used by the create_keyword_scanner function below. @@ -76,46 +255,49 @@ char get_next_char(void); * recognizing the complete keyword, and any pre-existing state that exists * for some other keyword that has the same prefix as the current one. */ - struct state * create_states( - char *keyword, - int token, - int expect_string, + char * text, + int token, + follby followedby, struct state *pre_state ) { struct state *my_state; - struct state *return_state = pre_state; + struct state *return_state; + struct state *prev_char_s; + struct state *curr_char_s; - struct state *prev_char = NULL; - struct state *curr_char = pre_state; + return_state = pre_state; + curr_char_s = pre_state; + prev_char_s = NULL; /* Find the correct position to insert the state. * All states should be in alphabetical order */ - while (curr_char && (keyword[0] < curr_char->ch)) { - prev_char = curr_char; - curr_char = curr_char->next_char; + while (curr_char_s != NULL && (text[0] < curr_char_s->ch)) { + prev_char_s = curr_char_s; + curr_char_s = curr_char_s->next_char_s; } /* Check if a previously seen keyword has the same prefix as the * current keyword. If yes, simply use the state for that keyword * as my_state */ - if (curr_char && (keyword[0] == curr_char->ch)) - my_state = curr_char; + if (curr_char_s && (text[0] == curr_char_s->ch)) + my_state = curr_char_s; else { my_state = emalloc(sizeof(*my_state)); - my_state->ch = keyword[0]; /* Store the first character - of the keyword */ + /* Store the first character of the keyword */ + my_state->ch = text[0]; my_state->next_state = NULL; - my_state->next_char = curr_char; - my_state->token = NON_ACCEPTING; /* Not an accepting state */ - my_state->expect_string = NO_ARG; + my_state->next_char_s = curr_char_s; + /* Not an accepting state */ + my_state->token = NON_ACCEPTING; + my_state->followedby = FOLLBY_TOKEN; - if (prev_char) - prev_char->next_char = my_state; + if (prev_char_s) + prev_char_s->next_char_s = my_state; else return_state = my_state; } @@ -125,36 +307,34 @@ create_states( * state. * If not, we need to continue scanning */ - if (keyword[1] == '\0') { + if ('\0' == text[1]) { my_state->token = token; - my_state->expect_string = expect_string; - } - else { - my_state->next_state = create_states(&keyword[1], - token, - expect_string, - my_state->next_state); - } + my_state->followedby = followedby; + } else + my_state->next_state = + create_states(&text[1], token, followedby, + my_state->next_state); return return_state; } - /* Define a function that takes a list of (keyword, token) values and * creates a keywords scanner out of it. */ struct state * -create_keyword_scanner( - struct key_tok *keyword_list - ) +create_keyword_scanner(void) { - struct state *scanner = NULL; - while (keyword_list->keyword != NULL) { - scanner = create_states(keyword_list->keyword, + struct state *scanner; + struct key_tok *keyword_list; + + keyword_list = ntp_keyword_list; + scanner = NULL; + while (keyword_list->key != NULL) { + scanner = create_states(keyword_list->key, keyword_list->token, - keyword_list->expect_string, + keyword_list->followedby, scanner); ++keyword_list; } @@ -171,7 +351,7 @@ delete_keyword_scanner( ) { if (my_key_scanner) { - delete_keyword_scanner(my_key_scanner->next_char); + delete_keyword_scanner(my_key_scanner->next_char_s); delete_keyword_scanner(my_key_scanner->next_state); free(my_key_scanner); } @@ -198,10 +378,33 @@ print_keyword_scanner( } if (curr_state->next_state != NULL) print_keyword_scanner(curr_state->next_state, pos + 1); - curr_state = curr_state->next_char; + curr_state = curr_state->next_char_s; } } + +/* + * keyword() - Return the keyword associated with token T_ identifier + */ +char * +keyword( + int token + ) +{ + struct key_tok *keyword_list; + + + + for (keyword_list = ntp_keyword_list; + keyword_list->key != NULL; + keyword_list++) + if (keyword_list->token == token) + return keyword_list->key; + + return "(keyword not found)"; +} + + /* FILE INTERFACE * -------------- * We define a couple of wrapper functions around the standard C fgetc @@ -346,7 +549,7 @@ push_back_char( static int is_keyword( char *lexeme, - int *expect_string + follby *pfollowedby ) { struct state *curr_state = key_scanner; @@ -355,15 +558,15 @@ is_keyword( for (i = 0; lexeme[i]; ++i) { while (curr_state && (lexeme[i] != curr_state->ch)) - curr_state = curr_state->next_char; + curr_state = curr_state->next_char_s; if (curr_state && (lexeme[i] == curr_state->ch)) { - *expect_string = curr_state->expect_string; + *pfollowedby = curr_state->followedby; token = curr_state->token; curr_state = curr_state->next_state; } else { - *expect_string = NO_ARG; + *pfollowedby = FOLLBY_TOKEN; token = NON_ACCEPTING; break; } @@ -502,7 +705,7 @@ create_string_token( /* - * Define a function that does the actual scanning. + * yylex() - function that does the actual scanning. * Bison expects this function to be called yylex and for it to take no * input and return an int. * Conceptually yylex "returns" yylval as well as the actual return @@ -517,7 +720,7 @@ yylex( int yylval_was_set = 0; int token; /* The return value/the recognized token */ int ch; - static int expect_string = NO_ARG; + static follby followedby = FOLLBY_TOKEN; do { /* Ignore whitespace at the beginning */ @@ -538,11 +741,12 @@ yylex( } else if (is_EOC(ch)) { - expect_string = NO_ARG; /* Reset expect_string */ + /* end FOLLBY_STRINGS_TO_EOC effect */ + followedby = FOLLBY_TOKEN; token = T_EOC; goto normal_return; - } else if (is_special(ch) && NO_ARG == expect_string) { + } else if (is_special(ch) && FOLLBY_TOKEN == followedby) { /* special chars are their own token values */ token = ch; goto normal_return; @@ -559,7 +763,7 @@ yylex( /* Break on whitespace or a special character */ if (isspace(yytext[i]) - || (is_special(yytext[i]) && NO_ARG == expect_string) + || (is_special(yytext[i]) && FOLLBY_TOKEN == followedby) || is_EOC(ch) || yytext[i] == '"') break; @@ -613,8 +817,8 @@ yylex( * returned) and that we haven't read a string. */ - if (expect_string == NO_ARG && !instring) { - token = is_keyword(yytext, &expect_string); + if (followedby == FOLLBY_TOKEN && !instring) { + token = is_keyword(yytext, &followedby); if (token) goto normal_return; else if (is_integer(yytext)) { @@ -652,8 +856,8 @@ yylex( } /* - * Either expect_string is 1 or this lexeme is part of a - * string. Hence, we need to return T_String. + * Either followedby is not FOLLBY_TOKEN or this lexeme is part + * of a string. Hence, we need to return T_String. * * _Except_ we might have a -4 or -6 flag on a an association * configuration line (server, peer, pool, etc.). @@ -665,12 +869,13 @@ yylex( * We do not require server addresses be quoted in ntp.conf, * complicating the scanner's job. To avoid trying (and * failing) to match an IP address or DNS name to a keyword, - * the association keywords use SINGLE_ARG in the keyword - * table, which tells the scanner to "expect_string", so it - * does not try to match a keyword but rather expects a string - * when -4/-6 modifiers to server, peer, etc. are encountered. + * the association keywords use FOLLBY_STRING in the keyword + * table, which tells the scanner to force the next token to be + * a T_String, so it does not try to match a keyword but rather + * expects a string when -4/-6 modifiers to server, peer, etc. + * are encountered. * restrict -4 and restrict -6 parsing works correctly without - * this hack, as restrict uses NO_ARG. [DH] + * this hack, as restrict uses FOLLBY_TOKEN. [DH] */ if ('-' == yytext[0]) { if ('4' == yytext[1]) { @@ -683,8 +888,8 @@ yylex( } instring = 0; - if (SINGLE_ARG == expect_string) - expect_string = NO_ARG; + if (FOLLBY_STRING == followedby) + followedby = FOLLBY_TOKEN; yylval_was_set = 1; token = create_string_token(yytext); diff --git a/ntpd/ntp_scanner.h b/ntpd/ntp_scanner.h index 71aa4ed12..9b0c13b5c 100644 --- a/ntpd/ntp_scanner.h +++ b/ntpd/ntp_scanner.h @@ -8,10 +8,25 @@ * Copyright (c) 2006 */ - -#define NO_ARG 0 -#define SINGLE_ARG 1 -#define MULTIPLE_ARG 2 +/* + * ntp.conf syntax is slightly irregular in that some tokens such as + * hostnames do not require quoting even if they might otherwise be + * recognized as T_ terminal tokens. This hand-crafted lexical scanner + * uses a "followed by" value associated with each keyword to indicate + * normal scanning of the next token, forced scanning of the next token + * alone as a T_String, or forced scanning of all tokens to the end of + * the command as T_String. + * In the past the identifiers for this functionality ended in _ARG: + * + * NO_ARG -> FOLLBY_TOKEN + * SINGLE_ARG -> FOLLBY_STRING + * MULTIPLE_ARG -> FOLLBY_STRINGS_TO_EOC + */ +typedef enum { + FOLLBY_TOKEN = 0, + FOLLBY_STRING, + FOLLBY_STRINGS_TO_EOC +} follby; #define MAXLINE 1024 /* maximum length of line */ #define MAXINCLUDELEVEL 5 /* maximum include file levels */ @@ -22,9 +37,9 @@ /* Define a structure to hold a (keyword, token) pair */ struct key_tok { - char * keyword; /* Keyword */ + char * key; /* Keyword */ int token; /* Associated Token */ - int expect_string; /* nonzero indicates the next token + follby followedby; /* nonzero indicates the next token should be a string */ }; @@ -66,11 +81,12 @@ extern struct FILE_INFO *fp[]; /* VARIOUS SUBROUTINE DECLARATIONS * ------------------------------- */ -struct state *create_states(char *keyword, +extern char * keyword(int token); +struct state *create_states(char *text, int token, - int expect_string, + follby followedby, struct state *pre_state); -struct state *create_keyword_scanner(struct key_tok *keyword_list); +struct state *create_keyword_scanner(void); void delete_keyword_scanner(struct state *my_key_scanner); int yylex(void);