]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 320] restrict default should apply to both IPv4 and IPv6
authorDave Hart <hart@ntp.org>
Thu, 21 May 2009 05:30:18 +0000 (05:30 +0000)
committerDave Hart <hart@ntp.org>
Thu, 21 May 2009 05:30:18 +0000 (05:30 +0000)
[Bug 1192] restrict -4 default / restrict -6 default lost with new
ntp.conf parser.
Dynamically allocate Windows serial handles array to save 1KB static
show column of syntax errors as well as line
add erealloc(), estrdup()
save column number at start of each token for more precise syntax
error messages

bk: 4a14e6eaBIRbKEjK3wQ0h0kBeuvblw

19 files changed:
include/ntp_calendar.h
include/ntp_config.h
include/ntp_filegen.h
include/ntp_stdlib.h
include/ntp_types.h
include/ntpd.h
libntp/emalloc.c
libntp/ntp_lineedit.c
ntpd/ntp_config.c
ntpd/ntp_filegen.c
ntpd/ntp_parser.c
ntpd/ntp_parser.h
ntpd/ntp_parser.y
ntpd/ntp_scanner.c
ntpd/ntp_scanner.h
ntpd/ntp_util.c
ports/winnt/include/win32_io.h
ports/winnt/ntpd/nt_clockstuff.c
ports/winnt/ntpd/win32_io.c

index 5fc977f8152066de3ef1256dca0b4ef13e3b2e6d..fbdb27c7ab4f7e5d3c24606edd3b4b41768d93e7 100644 (file)
@@ -7,13 +7,13 @@
 #include "ntp_types.h"
 
 struct calendar {
-       u_short year;   /* year (A.D.) */
+       u_short year;           /* year (A.D.) */
        u_short yearday;        /* day of year, 1 = January 1 */
-       u_char month;   /* month, 1 = January */
+       u_char month;           /* month, 1 = January */
        u_char monthday;        /* day of month */
-       u_char hour;    /* hour of day, midnight = 0 */
-       u_char minute;  /* minute of hour */
-       u_char second;  /* second of minute */
+       u_char hour;            /* hour of day, midnight = 0 */
+       u_char minute;          /* minute of hour */
+       u_char second;          /* second of minute */
 };
 
 /*
@@ -44,7 +44,7 @@ struct calendar {
 #define        DAYSPERYEAR     (365)                   /* days per year */
 
 #define        SECSPERDAY      (SECSPERMIN*MINSPERHR*HRSPERDAY)
-#define SECSPERYEAR    (365 * SECSPERDAY)      /* regular year */
+#define        SECSPERYEAR     (365 * SECSPERDAY)      /* regular year */
 #define        SECSPERLEAPYEAR (366 * SECSPERDAY)      /* leap year */
 
 #define        MAR1900         ((JAN+FEB) * SECSPERDAY) /* no leap year in 1900 */
@@ -56,9 +56,9 @@ struct calendar {
  * Gross hacks.  I have illicit knowlege that there won't be overflows
  * here, the compiler often can't tell this.
  */
-#define TIMES60(val)   ((((val)<<4) - (val))<<2)       /* *(16 - 1) * 4 */
+#define        TIMES60(val)    ((((val)<<4) - (val))<<2)       /* *(16 - 1) * 4 */
 #define        TIMES24(val)    (((val)<<4) + ((val)<<3))       /* *16 + *8 */
-#define        TIMES7(val)     (((val)<<3) - (val))            /* *8  - *1 */
+#define        TIMES7(val)     (((val)<<3) - (val))            /* *8  - *1 */
 #define        TIMESDPERC(val) (((val)<<10) + ((val)<<8) \
                        + ((val)<<7) + ((val)<<5) \
                        + ((val)<<4) + ((val)<<2) + (val))      /* *big* hack */
@@ -89,24 +89,24 @@ extern      u_long  caltontp        (const struct calendar *);
  * Start day of NTP time as days past the imaginary date 12/1/1 BC.
  * (This is the beginning of the Christian Era, or BCE.)
  */
-#define DAY_NTP_STARTS 693596
+#define        DAY_NTP_STARTS 693596
 /*
  * The Gregorian calendar is based on a 400 year cycle.  This is the number
  * of days in each cycle.
  */
-#define GREGORIAN_CYCLE_DAYS 146097
+#define        GREGORIAN_CYCLE_DAYS 146097
 
 /*
  * Days in a normal 100 year leap year calendar.  We lose a leap year day
  * in years evenly divisible by 100 but not by 400.
  */
-#define GREGORIAN_NORMAL_CENTURY_DAYS 36524
+#define        GREGORIAN_NORMAL_CENTURY_DAYS 36524
 
 /*
  * Days in a normal 4 year leap year calendar cycle.
  */
-#define GREGORIAN_NORMAL_LEAP_CYCLE_DAYS 1461
+#define        GREGORIAN_NORMAL_LEAP_CYCLE_DAYS 1461
 
-#define is_leapyear(y) (y%4 == 0 && !(y%100 == 0 && !(y%400 == 0)))
+#define        is_leapyear(y)  (!((y) % 4) && !(!((y) % 100) && (y) % 400))
 
 #endif
index e8845616f995b3c3a4ce90a31f54217d74b55f64..ba5c2bbc2f19fbc71c141e5d0c3f0967a84f1238 100644 (file)
@@ -185,7 +185,7 @@ 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);
 void **create_pval(void *val);
-struct restrict_node *create_restrict_node(struct address_node *addr,struct address_node *mask,queue *flags, int line_no);
+struct restrict_node *create_restrict_node(struct address_node *addr, struct address_node *mask, queue *flags, int line_no);
 int *create_ival(int val);
 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);
index 90ccee1f316779e899434ff138131f894a05a2f9..8ebcd4df6c8379ef733beb0beca4dddae9823a2f 100644 (file)
@@ -50,5 +50,5 @@ extern        void    filegen_config  (FILEGEN *, char *, u_int, u_int);
 extern FILEGEN *filegen_get    (char *);
 extern void    filegen_register (char *, const char *, FILEGEN *);
 #ifdef DEBUG
-extern FILEGEN *filegen_unregister(char *);
+extern void    filegen_unregister(char *);
 #endif
index f6f26549efed5325c0164273817cda66d78bc4ef..0e8e5f6657b7385be688208832854ce27cfe670b 100644 (file)
@@ -45,10 +45,15 @@ extern      u_long  calyearstart    (u_long);
 extern const char *clockname   (int);
 extern int     clocktime       (int, int, int, int, int, u_long, u_long *, u_int32 *);
 #if !defined(_MSC_VER) || !defined(_DEBUG)
-extern void *  emalloc         (u_int);
+extern void *  emalloc         (size_t);
+extern void *  erealloc        (void *, size_t);
+extern char *  estrdup         (const char *);
 #else
-#define                emalloc(size)   debug_emalloc(size, __FILE__, __LINE__)
-extern void *  debug_emalloc   (u_int, char *, int);
+extern void *  debug_erealloc  (void *, size_t, const char *, int);
+#define                emalloc(c)      debug_erealloc(NULL, (c), __FILE__, __LINE__)
+#define                erealloc(p, c)  debug_erealloc((p), (c), __FILE__, __LINE__)
+extern char *  debug_estrdup   (const char *, const char *, int);
+#define                estrdup(s)      debug_estrdup((s), __FILE__, __LINE__)
 #endif
 extern int     ntp_getopt      (int, char **, const char *);
 extern void    init_auth       (void);
@@ -79,8 +84,8 @@ extern  const char * clockstatstr (int);
 extern struct sockaddr_storage* netof (struct sockaddr_storage*);
 extern char *  numtoa          (u_int32);
 extern char *  numtohost       (u_int32);
-extern char *  socktoa         (struct sockaddr_storage *);
-extern char *  socktohost      (struct sockaddr_storage *);
+extern char *  socktoa         (struct sockaddr_storage *);
+extern char *  socktohost      (struct sockaddr_storage *);
 extern int     octtoint        (const char *, u_long *);
 extern u_long  ranp2           (int);
 extern char *  refnumtoa       (struct sockaddr_storage *);
index 580cf23aa0a435fb45844b14d21c535827a3a579..266af57fe4c02dea57986888b89282d6955bd6a4 100644 (file)
 #define UNUSED_ARG(arg)        ((void)(arg))
 #endif
 
+/*
+ * COUNTOF(array) - size of array in elements
+ */
+#define COUNTOF(arr)   (sizeof(arr) / sizeof((arr)[0]))
+
 /*
  * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H,
  *                     and u_int isn't defined anywhere
index 45b1635f3aaa1f981745a31a15cf86bb3f0e419a..8658311616dd337765973fb02c48b3e75555c816 100644 (file)
@@ -244,7 +244,7 @@ extern      void    record_crypto_stats (struct sockaddr_storage *, const char *);
 extern void    record_timing_stats (const char *);
 #endif
 extern  int    sock_hash (struct sockaddr_storage *);
-extern char *  fstostr(time_t);
+extern char *  fstostr(time_t);        /* NTP timescale seconds */
 extern double  old_drift;
 extern int     drift_file_sw;
 extern double  wander_threshold;
index f3a0905fdc1c09e75ffb8ebf8dd876eb04b8bfb9..7a46739b150596cedcb5a3970b16bf5840e2ea9f 100644 (file)
 
 #if !defined(_MSC_VER) || !defined(_DEBUG)
 
+
 void *
-emalloc(
-       u_int size
+erealloc(
+       void *  prev,
+       size_t  size
        )
 {
-       void *mem = malloc(size);
+       void *  mem;
 
-       if (!mem) {
-               msyslog(LOG_ERR, "Exiting: No more memory!");
+       mem = realloc(prev, size);
+
+       if (NULL == mem) {
+               msyslog(LOG_ERR, "fatal out of memory (%u bytes)",
+                                (u_int)size);
                exit(1);
        }
+
        return mem;
 }
 
+
+void *
+emalloc(
+       u_int   size
+       )
+{
+       return erealloc(NULL, size);
+}
+
+
+char *
+estrdup(
+       const char *    str
+       )
+{
+       char *  copy;
+
+       copy = strdup(str);
+
+       if (NULL == copy) {
+               msyslog(LOG_ERR, 
+                       "fatal out of memory duplicating %d byte "
+                       "string '%s'",
+                       strlen(str) + 1, str);
+               exit(1);
+       }
+
+       return copy;
+}
+
 #else /* below is _MSC_VER && _DEBUG */
 
 /*
- * When using the debug MS CRT malloc, preserve the original caller's
- * line and file via the emalloc macro.
+ * When using the debug MS CRT allocator, each allocation stores the
+ * callsite __FILE__ and __LINE__, which is then displayed at process
+ * termination, to track down leaks.  We don't want all of our
+ * allocations to show up as coming from emalloc.c, so we preserve the
+ * original callsite's source file and line using macros which pass
+ * __FILE__ and __LINE__ as parameters to these routines.
  */
+
 void *
-debug_emalloc(
-       u_int size,
-       char *filename,
-       int line
+debug_erealloc(
+       void *          prev,
+       size_t          size,
+       const char *    file,           /* __FILE__ */
+       int             line            /* __LINE__ */
        )
 {
-       void *mem = _malloc_dbg(size, _NORMAL_BLOCK, filename, line);
+       void *  mem;
+
+       mem = _realloc_dbg(prev, size, _NORMAL_BLOCK, file, line);
 
-       if (!mem) {
-               msyslog(LOG_ERR, "Exiting: No more memory!");
+       if (NULL == mem) {
+               msyslog(LOG_ERR, "fatal: out of memory in %s line %d size %u", 
+                                file, line, (u_int)size);
                exit(1);
        }
+
        return mem;
 }
 
+char *
+debug_estrdup(
+       const char *    str,
+       const char *    file,           /* __FILE__ */
+       int             line            /* __LINE__ */
+       )
+{
+       char *  copy;
+
+       copy = debug_erealloc(NULL, strlen(str) + 1, file, line);
+       strcpy(copy, str);
+
+       return copy;
+}
+
 #endif /* _MSC_VER && _DEBUG */
index 724f79d056952ed1a6adb1103ef1884fb25c51ab..ca3c7c310080588c9f41071dd6897ed10a5f999e 100644 (file)
@@ -20,6 +20,7 @@
 #endif
 
 #include "ntp.h"
+#include "ntp_stdlib.h"
 #include "ntp_lineedit.h"
 
 #define MAXEDITLINE    512
@@ -212,7 +213,7 @@ ntp_readline(
        line = fgets(line_buf, sizeof line_buf, stdin);
        if (NULL != line && *line) {
                *pcount = strlen(line);
-               line = strdup(line);
+               line = estrdup(line);
        } else
                line = NULL;
 
index a2bea6717222de71dd6076c884d35cd44b543d62..8935a11c571f092e5624cfa0479d96b59a3aa4ae 100644 (file)
@@ -63,10 +63,6 @@ int resolver_pipe_fd[2];  /* used to let the resolver process alert the parent p
 #include "ntp_parser.h"
 #include "ntp_data_structures.h"
 
-void yyerror (char *msg);
-
-extern int priority_done;
-
 
 /*
  * "logconfig" building blocks
@@ -426,8 +422,7 @@ create_attr_dval(
 {
        struct attr_val *my_val;
 
-       my_val = (struct attr_val *)
-           get_node(sizeof(struct attr_val));
+       my_val = get_node(sizeof *my_val);
        my_val->attr = attr;
        my_val->value.d = value;
        my_val->type = T_Double;
@@ -442,8 +437,7 @@ create_attr_ival(
 {
        struct attr_val *my_val;
 
-       my_val = (struct attr_val *)
-           get_node(sizeof(struct attr_val));
+       my_val = get_node(sizeof *my_val);
        my_val->attr = attr;
        my_val->value.i = value;
        my_val->type = T_Integer;
@@ -458,11 +452,10 @@ create_attr_sval(
 {
        struct attr_val *my_val;
 
-       my_val = (struct attr_val *)
-           get_node(sizeof(struct attr_val));
+       my_val = get_node(sizeof *my_val);
        my_val->attr = attr;
-       if (!s)                 /* free() hates NULL */
-               s = strdup("");
+       if (NULL == s)                  /* free() hates NULL */
+               s = estrdup("");
        my_val->value.s = s;
        my_val->type = T_String;
        return my_val;
@@ -476,8 +469,7 @@ create_attr_pval(
 {
        struct attr_val *my_val;
 
-       my_val = (struct attr_val *)
-           get_node(sizeof(struct attr_val));
+       my_val = get_node(sizeof *my_val);
        my_val->attr = attr;
        my_val->value.p = p;
        my_val->type = T_Void;
@@ -489,7 +481,7 @@ create_ival(
        int val
        )
 {
-       int *p = (int *)get_node(sizeof(int));
+       int *p = get_node(sizeof *p);
 
        *p = val;
        return p;
@@ -500,7 +492,7 @@ create_dval(
        double val
        )
 {
-       double *p = (double *) get_node(sizeof(int));
+       double *p = get_node(sizeof *p);
 
        *p = val;
        return p;
@@ -511,7 +503,7 @@ create_pval(
        void *val
        )
 {
-       void **p = (void **) get_node(sizeof(void *));
+       void **p = get_node(sizeof *p);
 
        *p = val;
        return p;
@@ -523,22 +515,22 @@ create_address_node(
        int type
        )
 {
-       struct address_node *my_node = 
-               (struct address_node *) get_node(sizeof(struct address_node));
+       struct address_node *my_node;
        struct isc_netaddr temp_isc_netaddr;
 
-       NTP_REQUIRE(addr);
+       NTP_REQUIRE(NULL != addr);
+       
+       my_node = get_node(sizeof *my_node);
 
        my_node->address = addr;
-       if (type == 0) {
+       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;
-       }
-       else {
-               my_node->type = type;
-       }
+
        return my_node;
 }
 
@@ -548,8 +540,8 @@ destroy_address_node(
        struct address_node *my_node
        )
 {
-       NTP_REQUIRE(my_node);
-       NTP_REQUIRE(my_node->address);
+       NTP_REQUIRE(NULL != my_node);
+       NTP_REQUIRE(NULL != my_node->address);
 
        free(my_node->address);
        free_node(my_node);
@@ -564,10 +556,10 @@ create_peer_node(
        )
 {
        struct peer_node* my_node;
+       struct attr_val *my_val;
        int errflag = 0;
 
-       my_node = (struct peer_node *)
-           get_node(sizeof(struct peer_node));
+       my_node = get_node(sizeof *my_node);
 
        /* Initialze node values to default */
        my_node->minpoll = NTP_MINDPOLL;
@@ -582,12 +574,13 @@ create_peer_node(
        my_node->host_mode = hmode;
        my_node->addr = addr;
 
-       while (options && !empty(options)) {
-               struct attr_val *my_val = dequeue(options);
+       while (NULL != options && !empty(options)) {
+               my_val = dequeue(options);
 
                /* Check the kind of option being set */
                switch(my_val->attr) {
-                   case T_Minpoll:
+
+               case T_Minpoll:
                        if (my_val->value.i < NTP_MINPOLL) {
                                msyslog(LOG_INFO,
                                        "minpoll: provided value (%d) is below minimum (%d)",
@@ -597,7 +590,8 @@ create_peer_node(
                        else
                                my_node->minpoll = my_val->value.i;
                        break;
-                   case T_Maxpoll:
+
+               case T_Maxpoll:
                        if (my_val->value.i > NTP_MAXPOLL) {
                                msyslog(LOG_INFO,
                                        "maxpoll: provided value (%d) is above maximum (%d)",
@@ -607,7 +601,8 @@ create_peer_node(
                        else
                                my_node->maxpoll = my_val->value.i;
                        break;
-                   case T_Ttl:
+
+               case T_Ttl:
                        if (my_node->ttl >= MAX_TTL) {
                                msyslog(LOG_ERR, "ttl: invalid argument");
                                errflag = 1;
@@ -615,20 +610,32 @@ create_peer_node(
                        else
                                my_node->ttl = my_val->value.i;
                        break;
-                   case T_Mode:
+
+               case T_Mode:
                        my_node->ttl = my_val->value.i;
                        break;
-                   case T_Key:
+
+               case T_Key:
                        my_node->peerkey = my_val->value.i;
                        break;
-                   case T_Version:
+
+               case T_Version:
                        my_node->peerversion = my_val->value.i;
                        break;
-                   case T_Flag:
+
+               case T_Flag:
                        my_node->peerflags |= my_val->value.i;
                        break;
-                   case T_Bias:
+
+               case T_Bias:
                        my_node->bias = my_val->value.d;
+                       break;
+
+               default:
+                       msyslog(LOG_ERR, 
+                               "Unknown peer/server option token %d",
+                               my_val->attr);
+                       errflag = 1;
                }
                free_node(my_val);
        }
@@ -637,7 +644,7 @@ create_peer_node(
        /* Check if errors were reported. If yes, ignore the node */
        if (errflag) {
                free_node(my_node);
-               return NULL;
+               my_node = NULL;
        }
        return my_node;
 }
@@ -649,8 +656,7 @@ create_unpeer_node(
 {
        struct unpeer_node* my_node;
 
-       my_node = (struct unpeer_node *)
-           get_node(sizeof(struct unpeer_node));
+       my_node = get_node(sizeof *my_node);
 
        my_node->addr = addr;
 
@@ -663,8 +669,9 @@ create_filegen_node(
        queue *options
        )
 {
-       struct filegen_node *my_node = (struct filegen_node *)
-           get_node(sizeof(struct filegen_node));
+       struct filegen_node *my_node;
+       
+       my_node = get_node(sizeof *my_node);
 
        my_node->name = (char *) *name;
        free_node(name);
@@ -682,13 +689,15 @@ create_restrict_node(
        int line_no
        )
 {
-       struct restrict_node *my_node = (struct restrict_node *)
-           get_node(sizeof(struct restrict_node));
+       struct restrict_node *my_node;
+       
+       my_node = get_node(sizeof *my_node);
 
        my_node->addr = addr;
        my_node->mask = mask;
        my_node->flags = flags;
        my_node->line_no = line_no;
+
        return my_node;
 }
 
@@ -731,8 +740,7 @@ create_setvar_node(
        free(val);
 
        /* Now store the string and its length into a setvar_node */
-       my_node = (struct setvar_node *)
-           get_node(sizeof(struct setvar_node));
+       my_node = get_node(sizeof *my_node);
        my_node->data = s;
        my_node->len = len1 + len2 + 2;
        my_node->def = def;
@@ -745,9 +753,9 @@ create_addr_opts_node(
        queue *options
        )
 {
-       struct addr_opts_node *my_node = (struct addr_opts_node *)
-           get_node(sizeof(struct addr_opts_node));
+       struct addr_opts_node *my_node;
 
+       my_node = get_node(sizeof *my_node);
        my_node->addr = addr;
        my_node->options = options;
        return my_node;
@@ -764,8 +772,8 @@ create_sim_script_info(
 #else
        script_info *my_info;
        struct attr_val *my_attr_val;
-       my_info = (script_info *)get_node(sizeof(script_info));
-       /* XXX: check the return value... */
+
+       my_info = get_node(sizeof *my_info);
 
        /* Initialize Script Info with default values*/
        my_info->duration = duration;
@@ -777,28 +785,35 @@ create_sim_script_info(
 
        /* Traverse the script_queue and fill out non-default values */
        while (!empty(script_queue)) {
-               my_attr_val = (struct attr_val *) dequeue(script_queue);
+               my_attr_val = dequeue(script_queue);
 
                /* Set the desired value */
-               switch(my_attr_val->attr) {
-                   case T_Freq_Offset:
+               switch (my_attr_val->attr) {
+
+               case T_Freq_Offset:
                        my_info->freq_offset = my_attr_val->value.d;
                        break;
-                   case T_Wander:
+
+               case T_Wander:
                        my_info->wander = my_attr_val->value.d;
                        break;
-                   case T_Jitter:
+
+               case T_Jitter:
                        my_info->jitter = my_attr_val->value.d;
                        break;
-                   case T_Prop_Delay:
+
+               case T_Prop_Delay:
                        my_info->prop_delay = my_attr_val->value.d;
                        break;
-                   case T_Proc_Delay:
+
+               case T_Proc_Delay:
                        my_info->proc_delay = my_attr_val->value.d;
                        break;
-                   default:
-                       yyerror("ERROR!! Invalid script info in file\n");
-                       break;
+
+               default:
+                       msyslog(LOG_ERR, 
+                               "Unknown script token %d",
+                               my_attr_val->attr);
                }
                free_node(my_attr_val);
        }
@@ -817,25 +832,23 @@ get_next_address(
        struct address_node *addr
        )
 {
-       static char *addr_prefix = "192.168.0.";
+       const char addr_prefix[] = "192.168.0.";
        static int curr_addr_no = 1;
        char addr_string[ADDR_LENGTH];
-
-       struct sockaddr_storage *final_addr = (struct sockaddr_storage *)
-           malloc(sizeof(struct sockaddr_storage));
+       struct sockaddr_storage *final_addr;
        struct addrinfo *ptr;
        int retval;
+       
+       final_addr = emalloc(sizeof *final_addr);
 
        if (addr->type == T_String) {
                snprintf(addr_string, ADDR_LENGTH, "%s%d", addr_prefix, curr_addr_no++);
                printf("Selecting ip address %s for hostname %s\n", addr_string, addr->address);
                retval = getaddrinfo(addr_string, "ntp", NULL, &ptr);
-       }
-       else {
+       } else
                retval = getaddrinfo(addr->address, "ntp", NULL, &ptr);
-       }
 
-       if (retval == 0) {
+       if (!retval) {
                memcpy(final_addr, ptr->ai_addr, ptr->ai_addrlen);
                fprintf(stderr, "Successful in setting ip address of simulated server to: %s\n", stoa(final_addr));
        }
@@ -860,7 +873,8 @@ create_sim_server(
        return NULL;
 #else
        server_info *my_info;
-       my_info = (server_info *) get_node(sizeof(server_info));
+
+       my_info = get_node(sizeof *my_info);
 
        my_info->server_time = server_offset;
        my_info->addr = get_next_address(addr);
@@ -876,8 +890,9 @@ create_sim_node(
        queue *servers
        )
 {
-       struct sim_node *my_node = (struct sim_node *)
-           get_node(sizeof(struct sim_node));
+       struct sim_node *my_node;
+       
+       my_node = get_node(sizeof *my_node);
 
        my_node->init_opts = init_opts;
        my_node->servers = servers;
@@ -920,31 +935,33 @@ struct key_tok keyword_list[] = {
        { "trap",               T_Trap,            SINGLE_ARG },
        { "unconfig",           T_Unconfig,        SINGLE_ARG },
        { "unpeer",             T_Unpeer,          SINGLE_ARG },
-       { "default",            T_Default,         NO_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 },
+       { "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 },
+       { "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 },
+       { "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 */
@@ -976,7 +993,7 @@ struct key_tok keyword_list[] = {
        { "month",              T_Month,           NO_ARG },
        { "none",               T_None,            NO_ARG },
        { "pid",                T_Pid,             NO_ARG },
-       { "week",               T_Week,            NO_ARG },
+       { "week",               T_Week,            NO_ARG },
        { "year",               T_Year,            NO_ARG },
 /*** ORPHAN MODE COMMANDS ***/
 /* tos_option */
@@ -992,6 +1009,7 @@ struct key_tok keyword_list[] = {
        { "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 },
@@ -1038,18 +1056,18 @@ struct key_tok keyword_list[] = {
 /* miscellaneous_command */
        { "port",               T_Port,            NO_ARG },
        { "interface",          T_Interface,       SINGLE_ARG },
-       { "qos",                T_Qos,            NO_ARG },
+       { "qos",                T_Qos,             NO_ARG },
 /* simulaor 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 },
+       { "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 },
+       { "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}
 };
 
@@ -1112,11 +1130,12 @@ config_auth(void)
 {
        struct attr_val *my_val;
        int *key_val;
+       u_char rankey[9];
+       int i;
 
        /* Crypto Command */
        while (!empty(my_config.auth.crypto_cmd_list)) {
-               my_val = (struct attr_val *)
-                   dequeue(my_config.auth.crypto_cmd_list);
+               my_val = dequeue(my_config.auth.crypto_cmd_list);
 #ifdef OPENSSL
                crypto_config(my_val->attr, my_val->value.s);
 #endif /* OPENSSL */
@@ -1156,17 +1175,14 @@ config_auth(void)
 
        /* Requested Key Command */
        if (my_config.auth.request_key) {
-#ifdef DEBUG
-               if (debug > 3)
-                       printf("set info_auth_key to %08lx\n",
-                              (long unsigned int) my_config.auth.request_key);
-#endif
+               DPRINTF(4, ("set info_auth_key to %08lx\n",
+                           (u_long) my_config.auth.request_key));
                info_auth_keyid = (keyid_t) my_config.auth.request_key;
        }
 
        /* Trusted Key Command */
        while (!empty(my_config.auth.trusted_key_list)) {
-               key_val = (int *) dequeue(my_config.auth.trusted_key_list);
+               key_val = dequeue(my_config.auth.trusted_key_list);
                authtrust(*key_val, 1);
                free_node(key_val);
        }
@@ -1187,21 +1203,21 @@ config_auth(void)
 
        /* if doesn't exist, make up one at random */
        if (!authhavekey(req_keyid)) {
-               char rankey[9];
-               int i, j;
 
-               for (i = 0; i < 8; i++)
-                       for (j = 1; j < 100; ++j) {
-                               rankey[i] = (char) (ntp_random() & 0xff);
-                               if (rankey[i] != 0) break;
-                       }
-               rankey[8] = 0;
+               for (i = 0; i < (COUNTOF(rankey) - 1); i++)
+                       do
+                               rankey[i] = 
+                                       (u_char)(ntp_random() & 0xff);
+                       while (!rankey[i]);
+
+               rankey[COUNTOF(rankey) - 1] = 0;
 
                authusekey(req_keyid, KEY_TYPE_MD5, (u_char *)rankey);
                authtrust(req_keyid, 1);
                if (!authhavekey(req_keyid)) {
-                       msyslog(LOG_ERR, "getconfig: Couldn't generate a valid random key!");
-                       /* HMS: Should this be fatal? */
+                       msyslog(LOG_ERR, "getconfig: Couldn't generate"
+                                        " a valid random key!");
+                       exit(1);
                }
        }
 
@@ -1217,7 +1233,7 @@ config_tos(void)
        struct attr_val *tos;
 
        while (!empty(my_config.orphan_cmds)) {
-               tos = (struct attr_val *) dequeue(my_config.orphan_cmds);
+               tos = dequeue(my_config.orphan_cmds);
                proto_config(tos->attr, 0, tos->value.d, NULL);
                free_node(tos);
        }
@@ -1237,7 +1253,7 @@ config_monitor(void)
 
        /* Set the statistics directory */
        if (my_config.stats_dir) {
-               stats_config(STATS_STATSDIR,my_config.stats_dir);
+               stats_config(STATS_STATSDIR, my_config.stats_dir);
                free(my_config.stats_dir);
                my_config.stats_dir = NULL;
        }
@@ -1257,21 +1273,20 @@ config_monitor(void)
 
        /* Turn on the specified statistics */
        while (!empty(my_config.stats_list)) {
-               filegen_string = (char **) dequeue(my_config.stats_list);
+               filegen_string = dequeue(my_config.stats_list);
                filegen = filegen_get(*filegen_string);
 
-#ifdef DEBUG
-               if (debug > 3)
-                       printf("enabling filegen for %s statistics \"%s%s\"\n",
-                              *filegen_string, filegen->prefix, filegen->basename);
-#endif
+               DPRINTF(4, ("enabling filegen for %s statistics "
+                           "\"%s%s\"\n",
+                           *filegen_string, filegen->prefix, 
+                           filegen->basename));
                filegen->flag |= FGEN_FLAG_ENABLED;
                free_node(filegen_string);
        }
 
        /* Configure the statistics with the options */
        while (!empty(my_config.filegen_opts)) {
-               my_node = (struct filegen_node *) dequeue(my_config.filegen_opts);
+               my_node = dequeue(my_config.filegen_opts);
                filegen = filegen_get(my_node->name);
 
                /* Initilize the filegen variables to their pre-configurtion states */
@@ -1280,32 +1295,53 @@ config_monitor(void)
                filegen_file = my_node->name;
 
                while (!empty(my_node->options)) {
-                       my_opts = (struct attr_val *) dequeue(my_node->options);
+                       my_opts = dequeue(my_node->options);
+
                        switch (my_opts->attr) {
-                           case T_File:
-                               filegen_file = (char *) my_opts->value.p;
+
+                       case T_File:
+                               filegen_file = my_opts->value.p;
                                break;
-                           case T_Type:
+
+                       case T_Type:
                                filegen_type = my_opts->value.i;
                                break;
-                           case T_Flag:
+
+                       case T_Flag:
                                switch (my_opts->value.i) {
-                                   case T_Link:
+
+                               case T_Link:
                                        filegen_flag |= FGEN_FLAG_LINK;
                                        break;
-                                   case T_Nolink:
+
+                               case T_Nolink:
                                        filegen_flag &= ~FGEN_FLAG_LINK;
                                        break;
-                                   case T_Enable:
+
+                               case T_Enable:
                                        filegen_flag |= FGEN_FLAG_ENABLED;
                                        break;
-                                   case T_Disable:
+
+                               case T_Disable:
                                        filegen_flag &= ~FGEN_FLAG_ENABLED;
                                        break;
+
+                               default:
+                                       msyslog(LOG_ERR, 
+                                               "Unknown filegen flag "
+                                               "token %d",
+                                               my_opts->value.i);
+                                       exit(1);
                                }
                                break;
+                       default:
+                               msyslog(LOG_ERR,
+                                       "Unknown filegen option token "
+                                       "%d", my_opts->attr);
+                               exit(1);
                        }
-                       filegen_config(filegen, filegen_file, filegen_type, filegen_flag);
+                       filegen_config(filegen, filegen_file, 
+                                      filegen_type, filegen_flag);
                        free_node(my_opts);
                }
                free_node(my_node);
@@ -1316,53 +1352,64 @@ config_monitor(void)
 static void
 config_access(void)
 {
-       struct attr_val *my_opt;
-       struct restrict_node *my_node;
-
+       struct attr_val *       my_opt;
+       struct restrict_node *  my_node;
        struct sockaddr_storage addr_sock;
        struct sockaddr_storage addr_mask;
-
-       int flags;
-       int mflags;
+       int                     flags;
+       int                     mflags;
+       int                     restrict_default;
 
        /* Configure the discard options */
        while (!empty(my_config.discard_opts)) {
-               my_opt = (struct attr_val *)
-                   dequeue(my_config.discard_opts);
+               my_opt = dequeue(my_config.discard_opts);
+
                switch(my_opt->attr) {
-                   case T_Average:
+
+               case T_Average:
                        ntp_minpoll = my_opt->value.i;
                        break;
-                   case T_Minimum:
+
+               case T_Minimum:
                        ntp_minpkt = my_opt->value.i;
                        break;
-                   case T_Monitor:
+
+               case T_Monitor:
                        mon_age = my_opt->value.i;
                        break;
+
+               default:
+                       msyslog(LOG_ERR,
+                               "Unknown discard option token %d",
+                               my_opt->attr);
+                       exit(1);
                }
                free_node(my_opt);
        }
 
        /* Configure the restrict options */
        while (!empty(my_config.restrict_opts)) {
-               my_node = (struct restrict_node *)
-                   dequeue(my_config.restrict_opts);
+               my_node = dequeue(my_config.restrict_opts);
 
-               memset((char *)&addr_sock, 0, sizeof(addr_sock));
-               /* Check if the user specified a default rule */
-               if (my_node->addr) {
+               memset(&addr_sock, 0, sizeof addr_sock);
+
+               if (NULL == my_node->addr) {
+                       /*
+                        * The user specified a default rule without a
+                        * -4 / -6 qualifier, add to both lists
+                        */
+                       restrict_default = 1;
+                       ANYSOCK(&addr_mask);
+               } else {
+                       restrict_default = 0;
                        /* Resolve the specified address */
                        addr_sock.ss_family = (u_short)my_node->addr->type;
 
                        if (getnetnum(my_node->addr->address,
-                                     &addr_sock, 1,t_UNK) != 1) {
+                                     &addr_sock, 1, t_UNK) != 1) {
 
-                               /* Error in resolving name!!!
-                                * Free the node memory and move onto the next
-                                * Restrict flag
-                                */
-                               msyslog(LOG_INFO,
-                                       "restrict: error in resolving name: %s on line %d. Ignoring...",
+                               msyslog(LOG_ERR,
+                                       "restrict: error in address '%s' on line %d. Ignoring...",
                                        my_node->addr->address, my_node->line_no);
                                destroy_restrict_node(my_node);
                                continue;
@@ -1375,30 +1422,23 @@ config_access(void)
                                memset((char *)&addr_mask, 0, sizeof(addr_mask));
                                addr_mask.ss_family = (u_short)my_node->mask->type;
                                if (getnetnum(my_node->mask->address, &addr_mask, 1, t_MSK) != 1) {
-                                       /* Error in mask !!!
-                                        * Free the node memory and move onto the next
-                                        * Restrict flag
-                                        */
-                                       msyslog(LOG_INFO,
-                                               "restrict: error in resolving mask: %s on line %d. Ignoring...",
+
+                                       msyslog(LOG_ERR,
+                                               "restrict: error in mask '%s' on line %d. Ignoring...",
                                                my_node->mask->address, my_node->line_no);
                                        destroy_restrict_node(my_node);
                                        continue;
                                }
                        }
                }
-               else { /* The user specified a default rule */
-                       addr_sock.ss_family = default_ai_family;
-                       ANYSOCK(&addr_mask);
-               }
 
                /* Parse the flags */
                flags = 0;
                mflags = 0;
 
                while (!empty(my_node->flags)) {
-                       int *curr_flag = (int *) dequeue(my_node->flags);
-                       if (*curr_flag == RESM_NTPONLY)
+                       int *curr_flag = dequeue(my_node->flags);
+                       if (RESM_NTPONLY == *curr_flag)
                                mflags |= *curr_flag;
                        else
                                flags |= *curr_flag;
@@ -1406,8 +1446,17 @@ config_access(void)
                }
 
                /* Set the flags */
+               if (restrict_default) {
+                       addr_sock.ss_family = AF_INET;
+                       hack_restrict(RESTRICT_FLAGS, &addr_sock, &addr_mask,
+                                     mflags, flags);
+
+                       addr_sock.ss_family = AF_INET6;
+               }
+
                hack_restrict(RESTRICT_FLAGS, &addr_sock, &addr_mask,
                              mflags, flags);
+
                destroy_restrict_node(my_node);
        }
 }
@@ -1581,31 +1630,37 @@ config_trap(void)
        struct sockaddr_storage peeraddr;
        struct address_node *addr_node;
        struct interface *localaddr;
-       int port_no;
+       u_short port_no;
        int err_flag;
 
+       /* silence warning about addr_sock potentially uninitialized */
+       addr_sock.ss_family = AF_UNSPEC;
        port_no = 0;
-       localaddr = 0;
+       localaddr = NULL;
 
 
        while (!empty(my_config.trap)) {
                err_flag = 0;
-               curr_trap = (struct addr_opts_node *) dequeue(my_config.trap);
+               curr_trap = dequeue(my_config.trap);
 
                while (!empty(curr_trap->options)) {
-                       curr_opt = (struct attr_val *) dequeue(curr_trap->options);
-                       if (curr_opt->attr == T_Port) {
-                               port_no = curr_opt->value.i;
-                               if (port_no <= 0 || port_no > 32767) {
-                                       msyslog(LOG_ERR, "invalid port number %d, trap ignored", port_no);
+                       curr_opt = dequeue(curr_trap->options);
+                       if (T_Port == curr_opt->attr) {
+                               if (curr_opt->value.i < 1 
+                                   || curr_opt->value.i > USHRT_MAX) {
+                                       msyslog(LOG_ERR,
+                                               "invalid port number "
+                                               "%d, trap ignored", 
+                                               curr_opt->value.i);
                                        err_flag = 1;
                                }
+                               port_no = (u_short)curr_opt->value.i;
                        }
-                       else if (curr_opt->attr == T_Interface) {
-                               addr_node = (struct address_node *) curr_opt->value.p;
+                       else if (T_Interface == curr_opt->attr) {
+                               addr_node = curr_opt->value.p;
 
                                /* Resolve the interface address */
-                               memset((char *)&addr_sock, 0, sizeof(addr_sock));
+                               memset(&addr_sock, 0, sizeof(addr_sock));
                                addr_sock.ss_family = (u_short)addr_node->type;
 
                                if (getnetnum(addr_node->address,
@@ -1616,9 +1671,10 @@ config_trap(void)
 
                                localaddr = findinterface(&addr_sock);
 
-                               if (localaddr == NULL) {
+                               if (NULL == localaddr) {
                                        msyslog(LOG_ERR,
-                                               "can't find interface with address %s",
+                                               "can't find interface "
+                                               "with address %s",
                                                stoa(&addr_sock));
                                        err_flag = 1;
                                }
@@ -1633,17 +1689,17 @@ config_trap(void)
                 */
                if (!err_flag) {
                        memset((char *)&peeraddr, 0, sizeof(peeraddr));
-                       if (getnetnum(curr_trap->addr->address, &peeraddr, 1, t_UNK) != 1) {
+                       if (1 != getnetnum(curr_trap->addr->address,
+                                          &peeraddr, 1, t_UNK)) {
                                err_flag = 1;
                                break;
                        }
 
-                       if (port_no != 0)
-                               ((struct sockaddr_in6*)&peeraddr)->sin6_port = htons((u_short) port_no);
-                       else
-                               ((struct sockaddr_in6*)&peeraddr)->sin6_port = htons(TRAPPORT);
+                       /* port is at same location for v4 and v6 */
+                       ((struct sockaddr_in6*)&peeraddr)->sin6_port =
+                               htons(port_no ? port_no : TRAPPORT);
 
-                       if (localaddr == NULL) {
+                       if (NULL == localaddr) {
                                peeraddr.ss_family = default_ai_family;
                                localaddr = ANY_INTERFACE_CHOOSE(&peeraddr);
                        }
@@ -1653,7 +1709,7 @@ config_trap(void)
                        if (!ctlsettrap(&peeraddr, localaddr, 0,
                                        NTP_VERSION))
                                msyslog(LOG_ERR,
-                                       "can't set trap for %s, no resources",
+                                       "can't set trap for %s",
                                        stoa(&peeraddr));
                }
                DESTROY_QUEUE(curr_trap->options);
@@ -2097,7 +2153,7 @@ config_sim(void)
        /* Check if a simulate block was found in the configuration code.
         * If not, return an error and exit
         */
-       if (my_config.sim_details == NULL) {
+       if (NULL == my_config.sim_details) {
                fprintf(stderr, "ERROR!! I couldn't find a \"simulate\" block for configuring the simulator.\n");
                fprintf(stderr, "\tCheck your configuration file.\n");
                exit(1);
@@ -2106,20 +2162,24 @@ config_sim(void)
        /* Process the initialization statements
         * -------------------------------------
         */
-       while(!empty(my_config.sim_details->init_opts)) {
-               init_stmt = (struct attr_val *)
-                   dequeue(my_config.sim_details->init_opts);
+       while (!empty(my_config.sim_details->init_opts)) {
+               init_stmt = dequeue(my_config.sim_details->init_opts);
+
                switch(init_stmt->attr) {
-                   case T_Beep_Delay:
+
+               case T_Beep_Delay:
                        simulation.beep_delay = init_stmt->value.d;
                        break;
-                   case T_Sim_Duration:
+
+               case T_Sim_Duration:
                        simulation.end_time = init_stmt->value.d;
                        break;
-                   default:
-                       yyerror("Internal Error in parser...\n"
-                               "Invalid init statement in simulator block");
-                       break;
+
+               default:
+                       fprintf(stderr,
+                               "Unknown simulator init token %d\n",
+                               init_stmt->attr);
+                       exit(1);
                }
                free_node(init_stmt);
        }
@@ -2129,20 +2189,19 @@ config_sim(void)
        /* Process the server list
         * -----------------------
         */
-       simulation.num_of_servers = get_no_of_elements(my_config.sim_details->servers);
-       simulation.servers = (server_info *) malloc(simulation.num_of_servers *
-                                                   sizeof(server_info));
-
-       for (i = 0;i < simulation.num_of_servers;++i) {
-               serv_info = (server_info *)
-                   dequeue(my_config.sim_details->servers);
-               if (!serv_info) {
-                       yyerror("Internal Error in parser...\n"
-                               "Tried to initialize server list but no server returned\n");
-               }
-               else {
-                 memcpy(&simulation.servers[i], serv_info, sizeof(server_info));
-                 free_node(serv_info);
+       simulation.num_of_servers = 
+               get_no_of_elements(my_config.sim_details->servers);
+       simulation.servers = emalloc(simulation.num_of_servers 
+                                    * sizeof(server_info));
+
+       for (i = 0;i < simulation.num_of_servers; i++) {
+               serv_info = dequeue(my_config.sim_details->servers);
+               if (NULL == serv_info) {
+                       fprintf(stderr, "Simulator server list is corrupt\n");
+                       exit(1);
+               } else {
+                       memcpy(&simulation.servers[i], serv_info, sizeof(server_info));
+                       free_node(serv_info);
                }
        }
        DESTROY_QUEUE(my_config.sim_details->servers);
@@ -2206,9 +2265,7 @@ void
 config_remotely(void)
 {
        input_from_file = 0;
-#if 0
-       init_syntax_tree();
-#endif
+
        key_scanner = create_keyword_scanner(keyword_list);
        yyparse();
        delete_keyword_scanner(key_scanner);
@@ -2589,8 +2646,9 @@ gettokens_netinfo (
 
 /*
  * getnetnum - return a net number (this is crude, but careful)
+ *
+ * returns 1 for success, and mysteriously, 0 or -1 for failure
  */
-
 static int
 getnetnum(
        const char *num,
@@ -2611,15 +2669,18 @@ getnetnum(
        }
 
        memcpy(addr, res->ai_addr, res->ai_addrlen);
-#ifdef DEBUG
-       if (debug > 1)
-               printf("getnetnum given %s, got %s \n",
-                      num, stoa(addr));
-#endif
+
+       DPRINTF(2, ("getnetnum given %s, got %s\n", num, stoa(addr)));
+
        freeaddrinfo(res);
        return 1;
 }
 
+/*
+ * get_multiple_netnums
+ *
+ * returns 1 for success, and mysteriously, 0 or -1 for failure
+ */
 static int
 get_multiple_netnums(
        const char *num,
@@ -2647,34 +2708,29 @@ get_multiple_netnums(
                hints.ai_family = AF_INET;
 
        hints.ai_socktype = SOCK_DGRAM;
-#ifdef DEBUG
-       if (debug > 3)
-               printf("getaddrinfo %s\n", num);
-#endif
+
+       DPRINTF(4, ("getaddrinfo %s\n", num));
+
        retval = getaddrinfo(num, "ntp", &hints, &ptr);
-       if (retval != 0 ||
-           (ptr->ai_family == AF_INET6 && isc_net_probeipv6() != ISC_R_SUCCESS)) {
+
+       if (retval ||
+           (ptr->ai_family == AF_INET6 
+            && isc_net_probeipv6() != ISC_R_SUCCESS)) {
+
                if (complain)
                        msyslog(LOG_ERR,
-                               "getaddrinfo: \"%s\" invalid host address, ignored",
+                               "getaddrinfo: \"%s\" invalid host "
+                               "address, ignored",
                                num);
-#ifdef DEBUG
-               if (debug > 0)
-                       printf(
-                               "getaddrinfo: \"%s\" invalid host address%s.\n",
-                               num, (complain)
-                               ? ", ignored"
-                               : "");
-#endif
-               if (retval == 0 &&
-                   ptr->ai_family == AF_INET6 &&
-                   isc_net_probeipv6() != ISC_R_SUCCESS)
-               {
+               else
+                       DPRINTF(1, ("getaddrinfo: \"%s\" invalid host "
+                                   "address.\n",
+                                   num));
+
+               if (!retval)
                        return -1;
-               }
-               else {
+               else 
                        return 0;
-               }
        }
        *res = ptr;
 
@@ -2723,16 +2779,26 @@ save_resolve(
 #ifndef SYS_VXWORKS
        if (res_fp == NULL) {
 #ifndef SYS_WINNT
-               (void) strcpy(res_file, RES_TEMPFILE);
+               strcpy(res_file, RES_TEMPFILE);
 #else
+               int len;
+
                /* no /tmp directory under NT */
-               {
-                       if(!(GetTempPath((DWORD)MAX_PATH, (LPTSTR)res_file))) {
-                               msyslog(LOG_ERR, "cannot get pathname for temporary directory: %m");
-                               return;
-                       }
-                       (void) strcat(res_file, "ntpdXXXXXX");
+               if (!GetTempPath(sizeof res_file, res_file)) {
+                       msyslog(LOG_ERR, "can not get temp dir: %m");
+                       exit(1);
                }
+               
+               len = strlen(res_file);
+               if (sizeof res_file < len + sizeof "ntpdXXXXXX") {
+                       msyslog(LOG_ERR,
+                               "temporary directory path %s too long",
+                               res_file);
+                       exit(1);
+               }
+
+               memmove(res_file + len, "ntpdXXXXXX",
+                       sizeof "ntpdXXXXXX");
 #endif /* SYS_WINNT */
 #ifdef HAVE_MKSTEMP
                {
@@ -2743,7 +2809,7 @@ save_resolve(
                                res_fp = fdopen(fd, "r+");
                }
 #else
-               (void) mktemp(res_file);
+               mktemp(res_file);
                res_fp = fopen(res_file, "w");
 #endif
                if (res_fp == NULL) {
index 1c0c431e19c665f9f58ceeacbfcabe1a585a933d..e9fc4dc940efc428a78e8c50927b978e9c378555 100644 (file)
  */
 #define SUFFIX_SEP '.'
 
-/*
- * other constants
- */
-#define FGEN_AGE_SECS   (24*60*60) /* life time of FILEGEN_AGE in seconds */
-
 static void    filegen_open    (FILEGEN *, u_long);
 static int     valid_fileref   (char *, char *);
-#ifdef UNUSED
-static FILEGEN *filegen_unregister (char *);
-#endif /* UNUSED */
+static void    filegen_init    (char *, const char *, FILEGEN *);
+#ifdef DEBUG
+static void    filegen_uninit          (FILEGEN *);
+#endif /* DEBUG */
 
-static void    filegen_init    (char *, const char *, FILEGEN *);
 
 /*
  * filegen_init
  */
 
 static void
-filegen_init(char *prefix, const char *basename, FILEGEN *fgp)
+filegen_init(
+       char *          prefix,
+       const char *    basename,
+       FILEGEN *       fgp
+       )
 {
        fgp->fp       = NULL;
        fgp->prefix   = prefix;         /* Yes, this is TOTALLY lame! */
-       fgp->basename = (char*)emalloc(strlen(basename) + 1);
+       fgp->basename = emalloc(strlen(basename) + 1);
        strcpy(fgp->basename, basename);
        fgp->id       = 0;
        fgp->type     = FILEGEN_DAY;
@@ -74,6 +73,20 @@ filegen_init(char *prefix, const char *basename, FILEGEN *fgp)
 }
 
 
+/*
+ * filegen_uninit - free memory allocated by filegen_init
+ */
+#ifdef DEBUG
+static void
+filegen_uninit(
+       FILEGEN *       fgp
+       )
+{
+       free(fgp->basename);
+}
+#endif
+
+
 /*
  * open a file generation according to the current settings of gen
  * will also provide a link to basename if requested to do so
@@ -81,8 +94,8 @@ filegen_init(char *prefix, const char *basename, FILEGEN *fgp)
 
 static void
 filegen_open(
-       FILEGEN *gen,
-       u_long  newid
+       FILEGEN *       gen,
+       u_long          newid
        )
 {
        char *filename;
@@ -92,70 +105,83 @@ filegen_open(
        struct calendar cal;
 
        len = strlen(gen->prefix) + strlen(gen->basename) + 1;
-       basename = (char*)emalloc(len);
-       sprintf(basename, "%s%s", gen->prefix, gen->basename);
+       basename = emalloc(len);
+       snprintf(basename, len, "%s%s", gen->prefix, gen->basename);
   
        switch(gen->type) {
-           default:
-               msyslog(LOG_ERR, "unsupported file generations type %d for \"%s\" - reverting to FILEGEN_NONE",
+
+       default:
+               msyslog(LOG_ERR, 
+                       "unsupported file generations type %d for "
+                       "\"%s\" - reverting to FILEGEN_NONE",
                        gen->type, basename);
                gen->type = FILEGEN_NONE;
-      
-               /*FALLTHROUGH*/
-           case FILEGEN_NONE:
-               filename = (char*)emalloc(len);
-               sprintf(filename,"%s", basename);
+               /* fall through to FILEGEN_NONE */
+
+       case FILEGEN_NONE:
+               filename = estrdup(basename);
                break;
 
-           case FILEGEN_PID:
-               filename = (char*)emalloc(len + 1 + 1 + 10);
-               sprintf(filename,"%s%c#%ld", basename, SUFFIX_SEP, newid);
+       case FILEGEN_PID:
+               filename = emalloc(len + 1 + 1 + 10);
+               snprintf(filename, len + 1 + 1 + 10,
+                        "%s%c#%ld",
+                        basename, SUFFIX_SEP, newid);
                break;
-      
-           case FILEGEN_DAY:
-               /* You can argue here in favor of using MJD, but
-                * I would assume it to be easier for humans to interpret dates
-                * in a format they are used to in everyday life.
+
+       case FILEGEN_DAY:
+               /*
+                * You can argue here in favor of using MJD, but I
+                * would assume it to be easier for humans to interpret
+                * dates in a format they are used to in everyday life.
                 */
-               caljulian(newid,&cal);
-               filename = (char*)emalloc(len + 1 + 4 + 2 + 2);
-               sprintf(filename, "%s%c%04d%02d%02d",
-                       basename, SUFFIX_SEP, cal.year, cal.month, cal.monthday);
+               caljulian(newid, &cal);
+               filename = emalloc(len + 1 + 4 + 2 + 2);
+               snprintf(filename, len + 1 + 4 + 2 + 2,
+                        "%s%c%04d%02d%02d",
+                        basename, SUFFIX_SEP,
+                        cal.year, cal.month, cal.monthday);
                break;
-      
-           case FILEGEN_WEEK:
+
+       case FILEGEN_WEEK:
                /*
                 * This is still a hack
                 * - the term week is not correlated to week as it is used
                 *   normally - it just refers to a period of 7 days
                 *   starting at Jan 1 - 'weeks' are counted starting from zero
                 */
-               caljulian(newid,&cal);
-               filename = (char*)emalloc(len + 1 + 4 + 1 + 2);
-               sprintf(filename, "%s%c%04dw%02d",
-                       basename, SUFFIX_SEP, cal.year, cal.yearday / 7);
+               caljulian(newid, &cal);
+               filename = emalloc(len + 1 + 4 + 1 + 2);
+               snprintf(filename, len + 1 + 4 + 1 + 2,
+                        "%s%c%04dw%02d",
+                        basename, SUFFIX_SEP,
+                        cal.year, cal.yearday / 7);
                break;
 
-           case FILEGEN_MONTH:
-               caljulian(newid,&cal);
-               filename = (char*)emalloc(len + 1 + 4 + 2);
-               sprintf(filename, "%s%c%04d%02d",
-                       basename, SUFFIX_SEP, cal.year, cal.month);
+       case FILEGEN_MONTH:
+               caljulian(newid, &cal);
+               filename = emalloc(len + 1 + 4 + 2);
+               snprintf(filename, len + 1 + 4 + 2,
+                        "%s%c%04d%02d",
+                        basename, SUFFIX_SEP, cal.year, cal.month);
                break;
 
-           case FILEGEN_YEAR:
-               caljulian(newid,&cal);
-               filename = (char*)emalloc(len + 1 + 4);
-               sprintf(filename, "%s%c%04d", basename, SUFFIX_SEP, cal.year);
+       case FILEGEN_YEAR:
+               caljulian(newid, &cal);
+               filename = emalloc(len + 1 + 4);
+               snprintf(filename, len + 1 + 4,
+                        "%s%c%04d",
+                        basename, SUFFIX_SEP, cal.year);
                break;
 
-           case FILEGEN_AGE:
-               filename = (char*)emalloc(len + 1 + 2 + 10);
-               sprintf(filename, "%s%ca%08ld", basename, SUFFIX_SEP, newid);
-               break;
+       case FILEGEN_AGE:
+               filename = emalloc(len + 1 + 2 + 10);
+               snprintf(filename, len + 1 + 2 + 10,
+                        "%s%ca%08ld",
+                        basename, SUFFIX_SEP, newid);
        }
   
-       if (gen->type != FILEGEN_NONE) {
+       if (FILEGEN_NONE != gen->type) {
                /*
                 * check for existence of a file with name 'basename'
                 * as we disallow such a file
@@ -177,14 +203,18 @@ filegen_open(
                                        /*
                                         * Oh, it is not linked - try to save it
                                         */
-                                       char *savename = (char*)emalloc(len + 1 + 1 + 10 + 10);
-                                       sprintf(savename, "%s%c%dC%lu",
-                                               basename,
-                                               SUFFIX_SEP,
-                                               (int) getpid(),
-                                               (u_long)conflicts++);
+                                       char *savename;
+                                       
+                                       savename = emalloc(len + 1 + 1 + 10 + 10);
+                                       snprintf(savename, len + 1 + 1 + 10 + 10,
+                                               "%s%c%dC%lu",
+                                               basename, SUFFIX_SEP,
+                                               (int)getpid(), conflicts++);
+
                                        if (rename(basename, savename) != 0)
-                                           msyslog(LOG_ERR," couldn't save %s: %m", basename);
+                                               msyslog(LOG_ERR,
+                                                       "couldn't save %s: %m",
+                                                       basename);
                                        free(savename);
                                } else {
                                        /*
@@ -199,22 +229,28 @@ filegen_open(
                                                delete(basename) != 0
 #endif
                                                )
-                                           msyslog(LOG_ERR, "couldn't unlink %s: %m", basename);
+                                               msyslog(LOG_ERR, 
+                                                       "couldn't unlink %s: %m",
+                                                       basename);
                                }
                        } else {
                                /*
                                 * Ehh? Not a regular file ?? strange !!!!
                                 */
-                               msyslog(LOG_ERR, "expected regular file for %s (found mode 0%lo)",
-                                       basename, (unsigned long)stats.st_mode);
+                               msyslog(LOG_ERR, 
+                                       "expected regular file for %s "
+                                       "(found mode 0%lo)",
+                                       basename,
+                                       (unsigned long)stats.st_mode);
                        }
                } else {
                        /*
                         * stat(..) failed, but it is absolutely correct for
                         * 'basename' not to exist
                         */
-                       if (errno != ENOENT)
-                           msyslog(LOG_ERR,"stat(%s) failed: %m", basename);
+                       if (ENOENT != errno)
+                               msyslog(LOG_ERR, "stat(%s) failed: %m",
+                                                basename);
                }
        }
 
@@ -223,13 +259,10 @@ filegen_open(
         */
        fp = fopen(filename, "a");
   
-#ifdef DEBUG
-       if (debug > 3)
-           printf("opening filegen (type=%d/id=%lu) \"%s\"\n",
-                  gen->type, (u_long)newid, filename);
-#endif
+       DPRINTF(4, ("opening filegen (type=%d/id=%lu) \"%s\"\n",
+                   gen->type, newid, filename));
 
-       if (fp == NULL) {
+       if (NULL == fp) {
                /* open failed -- keep previous state
                 *
                 * If the file was open before keep the previous generation.
@@ -239,10 +272,10 @@ filegen_open(
                 * ignore errors due to missing directories
                 */
 
-               if (errno != ENOENT)
-                   msyslog(LOG_ERR, "can't open %s: %m", filename);
+               if (ENOENT != errno)
+                       msyslog(LOG_ERR, "can't open %s: %m", filename);
        } else {
-               if (gen->fp != NULL) {
+               if (NULL != gen->fp) {
                        fclose(gen->fp);
                        gen->fp = NULL;
                }
@@ -269,8 +302,10 @@ filegen_open(
                        errno = 0; /* On VMS, don't support FGEN_FLAG_LINK */
 #else  /* not (VMS) / VXWORKS / WINNT ; DO THE LINK) */
                        if (link(filename, basename) != 0)
-                           if (errno != EEXIST)
-                               msyslog(LOG_ERR, "can't link(%s, %s): %m", filename, basename);
+                               if (EEXIST != errno)
+                                       msyslog(LOG_ERR, 
+                                               "can't link(%s, %s): %m",
+                                               filename, basename);
 #endif /* SYS_WINNT || VXWORKS */
                }               /* flags & FGEN_FLAG_LINK */
        }                       /* else fp == NULL */
@@ -290,15 +325,15 @@ filegen_open(
 
 void
 filegen_setup(
-       FILEGEN *gen,
-       u_long   now
+       FILEGEN *       gen,
+       u_long          now
        )
 {
        u_long new_gen = ~ (u_long) 0;
        struct calendar cal;
 
        if (!(gen->flag & FGEN_FLAG_ENABLED)) {
-               if (gen->fp != NULL) {
+               if (NULL != gen->fp) {
                        fclose(gen->fp);
                        gen->fp = NULL;
                }
@@ -306,21 +341,23 @@ filegen_setup(
        }
        
        switch (gen->type) {
-           case FILEGEN_NONE:
-               if (gen->fp != NULL) return; /* file already open */
+
+       case FILEGEN_NONE:
+               if (NULL != gen->fp)
+                       return; /* file already open */
                break;
-      
-           case FILEGEN_PID:
+
+       case FILEGEN_PID:
                new_gen = getpid();
                break;
 
-           case FILEGEN_DAY:
+       case FILEGEN_DAY:
                caljulian(now, &cal);
                cal.hour = cal.minute = cal.second = 0;
                new_gen = caltontp(&cal);
                break;
-      
-           case FILEGEN_WEEK:
+
+       case FILEGEN_WEEK:
                /* Would be nice to have a calweekstart() routine */
                /* so just use a hack ... */
                /* just round time to integral 7 day period for actual year  */
@@ -336,33 +373,32 @@ filegen_setup(
                cal.hour = cal.minute = cal.second = 0;
                new_gen = caltontp(&cal);
                break;
-      
-           case FILEGEN_MONTH:
+
+       case FILEGEN_MONTH:
                caljulian(now, &cal);
                cal.yearday = (u_short) (cal.yearday - cal.monthday + 1);
                cal.monthday = 1;
                cal.hour = cal.minute = cal.second = 0;
                new_gen = caltontp(&cal);
                break;
-      
-           case FILEGEN_YEAR:
+
+       case FILEGEN_YEAR:
                new_gen = calyearstart(now);
                break;
 
-           case FILEGEN_AGE:
-               new_gen = current_time  - (current_time % FGEN_AGE_SECS);
+       case FILEGEN_AGE:
+               new_gen = current_time - (current_time % SECSPERDAY);
                break;
        }
        /*
         * try to open file if not yet open
         * reopen new file generation file on change of generation id
         */
-       if (gen->fp == NULL || gen->id != new_gen) {
-#if DEBUG
-               if (debug)
-                       printf("filegen  %0x %lu %lu %lu\n", gen->type, now,
-                           gen->id, new_gen); 
-#endif
+       if (NULL == gen->fp || gen->id != new_gen) {
+
+               DPRINTF(1, ("filegen  %0x %lu %lu %lu\n", 
+                           gen->type, now, gen->id, new_gen));
+
                filegen_open(gen, new_gen);
        }
 }
@@ -373,10 +409,10 @@ filegen_setup(
  */
 void
 filegen_config(
-       FILEGEN *gen,
-       char    *basename,
-       u_int   type,
-       u_int   flag
+       FILEGEN *       gen,
+       char *          basename,
+       u_int           type,
+       u_int           flag
        )
 {
        int file_existed = 0;
@@ -384,31 +420,35 @@ filegen_config(
        /*
         * if nothing would be changed...
         */
-       if ((basename == gen->basename || strcmp(basename,gen->basename) == 0)
+       if ((basename == gen->basename || strcmp(basename, gen->basename) == 0)
            && type == gen->type
            && flag == gen->flag)
-           return;
+               return;
   
        /*
         * validate parameters
         */
-       if (!valid_fileref(gen->prefix,basename))
-           return;
+       if (!valid_fileref(gen->prefix, basename))
+               return;
   
-       if (gen->fp != NULL) {
+       if (NULL != gen->fp) {
                fclose(gen->fp);
                gen->fp = NULL;
                file_existed = 1;
        }
 
-#ifdef DEBUG
-       if (debug > 2)
-           printf("configuring filegen:\n\tprefix:\t%s\n\tbasename:\t%s -> %s\n\ttype:\t%d -> %d\n\tflag: %x -> %x\n",
-                  gen->prefix, gen->basename, basename, gen->type, type, gen->flag, flag);
-#endif
+       DPRINTF(3, ("configuring filegen:\n"
+                   "\tprefix:\t%s\n"
+                   "\tbasename:\t%s -> %s\n"
+                   "\ttype:\t%d -> %d\n"
+                   "\tflag: %x -> %x\n",
+                   gen->prefix,
+                   gen->basename, basename,
+                   gen->type, type,
+                   gen->flag, flag));
+
        if (gen->basename != basename || strcmp(gen->basename, basename) != 0) {
-               free(gen->basename);
-               gen->basename = (char*)emalloc(strlen(basename) + 1);
+               gen->basename = erealloc(gen->basename, strlen(basename) + 1);
                strcpy(gen->basename, basename);
        }
        gen->type = (u_char) type;
@@ -435,8 +475,8 @@ filegen_config(
  */
 static int
 valid_fileref(
-       char *prefix,
-       char *basename
+       char *  prefix,
+       char *  basename
        )
 {
        /*
@@ -448,7 +488,7 @@ valid_fileref(
         *              file system parts 'below' prefix may be
         *              specified without infringement of security
         *
-        *              restricing prefix to legal values
+        *              restricting prefix to legal values
         *              has to be ensured by other means
         * (however, it would be possible to perform some checks here...)
         */
@@ -457,15 +497,16 @@ valid_fileref(
        /*
         * Just to catch, dumb errors opening up the world...
         */
-       if (prefix == NULL || *prefix == '\0')
-           return 0;
+       if (NULL == prefix || '\0' == *prefix)
+               return 0;
 
-       if (basename == NULL)
-           return 0;
+       if (NULL == basename)
+               return 0;
   
-       for (p = basename; p; p = strchr(p, '/')) {
-               if (*p == '.' && *(p+1) == '.' && (*(p+2) == '\0' || *(p+2) == '/'))
-                   return 0;
+       for (p = basename; p; p = strchr(p, DIR_SEP)) {
+               if ('.' == p[0] && '.' == p[1] 
+                   && ('\0' == p[2] || DIR_SEP == p[2]))
+                       return 0;
        }
   
        return 1;
@@ -477,78 +518,66 @@ valid_fileref(
  */
 
 static struct filegen_entry {
-       char *name;
-       FILEGEN *filegen;
-       struct filegen_entry *next;
+       char *                  name;
+       FILEGEN *               filegen;
+       struct filegen_entry *  next;
 } *filegen_registry = NULL;
 
 
 FILEGEN *
 filegen_get(
-       char *name
+       char *  name
        )
 {
        struct filegen_entry *f = filegen_registry;
 
-       while(f) {
+       while (f) {
                if (f->name == name || strcmp(name, f->name) == 0) {
-#ifdef XXX     /* this gives the Alpha compiler fits */
-                       if (debug > 3)
-                           printf("filegen_get(\"%s\") = %x\n", name,
-                                  (u_int)f->filegen);
-#endif
+                       DPRINTF(4, ("filegen_get(%s) = %p\n",
+                                   name, f->filegen));
                        return f->filegen;
                }
                f = f->next;
        }
-#ifdef DEBUG
-       if (debug > 3)
-           printf("filegen_get(\"%s\") = NULL\n", name);
-#endif
+       DPRINTF(4, ("filegen_get(%s) = NULL\n", name));
        return NULL;
 }
 
+
 void
 filegen_register(
-       char *prefix,
-       const char *name,
-       FILEGEN *filegen
+       char *          prefix,
+       const char *    name,
+       FILEGEN *       filegen
        )
 {
-       struct filegen_entry **f = &filegen_registry;
+       struct filegen_entry **ppfe;
 
-#ifdef XXX             /* this gives the Alpha compiler fits */
-       if (debug > 3)
-           printf("filegen_register(\"%s\",%x)\n", name, (u_int)filegen);
-#endif
+       DPRINTF(4, ("filegen_register(%s, %p)\n", name, filegen));
 
        filegen_init(prefix, name, filegen);
 
-       while (*f) {
-               if ((*f)->name == name || strcmp(name, (*f)->name) == 0) {
-#ifdef XXX      /* this gives the Alpha compiler fits */
-                       if (debug > 4) {
-                               printf("replacing filegen %x\n", (u_int)(*f)->filegen);
-                       }
-#endif
-                       (*f)->filegen = filegen;
+       ppfe = &filegen_registry;
+       while (NULL != *ppfe) {
+               if ((*ppfe)->name == name 
+                   || !strcmp((*ppfe)->name, name)) {
+
+                       DPRINTF(5, ("replacing filegen %p\n",
+                                   (*ppfe)->filegen));
+
+                       (*ppfe)->filegen = filegen;
                        return;
                }
-               f = &((*f)->next);
+               ppfe = &((*ppfe)->next);
        }
 
-       *f = (struct filegen_entry *) emalloc(sizeof(struct filegen_entry));
-       if (*f) {
-               (*f)->next = NULL;
-               (*f)->name = (char*)emalloc(strlen(name) + 1);
-               strcpy((*f)->name, name);
-               (*f)->filegen = filegen;
-#ifdef DEBUG
-               if (debug > 5) {
-                       printf("adding new filegen\n");
-               }
-#endif
-       }
+       *ppfe = emalloc(sizeof **ppfe);
+
+       (*ppfe)->next = NULL;
+       (*ppfe)->name = estrdup(name);
+       (*ppfe)->filegen = filegen;
+
+       DPRINTF(6, ("adding new filegen\n"));
        
        return;
 }
@@ -559,28 +588,31 @@ filegen_register(
  * name.
  */
 #ifdef DEBUG
-FILEGEN *
+void
 filegen_unregister(
        char *name
        )
 {
-       struct filegen_entry **f = &filegen_registry;
-  
-       DPRINTF(3, ("filegen_unregister(\"%s\")\n", name));
-
-       while (*f) {
-               if (strcmp((*f)->name,name) == 0) {
-                       struct filegen_entry *ff = *f;
-                       FILEGEN *fg;
+       struct filegen_entry ** ppfe;
+       struct filegen_entry *  pfe;
+       FILEGEN *               fg;
                        
-                       *f = (*f)->next;
-                       fg = ff->filegen;
-                       free(ff->name);
-                       free(ff);
-                       return fg;
+       DPRINTF(4, ("filegen_unregister(%s)\n", name));
+
+       ppfe = &filegen_registry;
+
+       while (NULL != *ppfe) {
+               if ((*ppfe)->name == name
+                   || !strcmp((*ppfe)->name, name)) {
+                       pfe = *ppfe;
+                       *ppfe = (*ppfe)->next;
+                       fg = pfe->filegen;
+                       free(pfe->name);
+                       free(pfe);
+                       filegen_uninit(fg);
+                       break;
                }
-               f = &((*f)->next);
+               ppfe = &((*ppfe)->next);
        }
-       return NULL;
 }      
-#endif /* UNUSED */
+#endif /* DEBUG */
index 13262ff1d9ec81a0995b9ec8cbe79d4dbced4d95..13cee59af93b1a32b71d6f2e1ab061799a903a68 100644 (file)
                                   for both the simulator and the daemon
                                */
 
-  /*  #include "ntp_parser.h"     SK: Arent't we generating this using bison?
-                                  This was not an issue when we were
-                                  directly including the source file. However,
-                                  we will need a seperate description of the
-                                  tokens in the scanner.
-                               */
-
 
   struct FILE_INFO *ip_file;   /* Pointer to the configuration file stream */
 
 
 
 /* Line 189 of yacc.c  */
-#line 114 "ntp_parser.c"
+#line 107 "ntp_parser.c"
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
      T_Dispersion = 283,
      T_Double = 284,
      T_Driftfile = 285,
-     T_WanderThreshold = 286,
-     T_Enable = 287,
-     T_End = 288,
-     T_False = 289,
-     T_File = 290,
-     T_Filegen = 291,
-     T_Flag1 = 292,
-     T_Flag2 = 293,
-     T_Flag3 = 294,
-     T_Flag4 = 295,
-     T_Flake = 296,
-     T_Floor = 297,
-     T_Freq = 298,
-     T_Fudge = 299,
-     T_Host = 300,
-     T_Huffpuff = 301,
-     T_IPv4_address = 302,
-     T_IPv6_address = 303,
-     T_Iburst = 304,
-     T_Ident = 305,
-     T_Ignore = 306,
-     T_Includefile = 307,
-     T_Integer = 308,
-     T_Interface = 309,
-     T_Kernel = 310,
-     T_Key = 311,
-     T_Keys = 312,
-     T_Keysdir = 313,
-     T_Kod = 314,
-     T_Leap = 315,
-     T_Leapfile = 316,
-     T_Limited = 317,
-     T_Link = 318,
-     T_Logconfig = 319,
-     T_Logfile = 320,
-     T_Loopstats = 321,
-     T_Lowpriotrap = 322,
-     T_Manycastclient = 323,
-     T_Manycastserver = 324,
-     T_Mask = 325,
-     T_Maxclock = 326,
-     T_Maxdist = 327,
-     T_Maxhop = 328,
-     T_Maxpoll = 329,
-     T_Minclock = 330,
-     T_Mindist = 331,
-     T_Minimum = 332,
-     T_Minpoll = 333,
-     T_Minsane = 334,
-     T_Mode = 335,
-     T_Monitor = 336,
-     T_Month = 337,
-     T_Multicastclient = 338,
-     T_Nolink = 339,
-     T_Nomodify = 340,
-     T_None = 341,
-     T_Nopeer = 342,
-     T_Noquery = 343,
-     T_Noselect = 344,
-     T_Noserve = 345,
-     T_Notrap = 346,
-     T_Notrust = 347,
-     T_Novolley = 348,
-     T_Ntp = 349,
-     T_Ntpport = 350,
-     T_NtpSignDsocket = 351,
-     T_Orphan = 352,
-     T_Panic = 353,
-     T_Peer = 354,
-     T_Peerstats = 355,
-     T_Phone = 356,
-     T_Pid = 357,
-     T_Pidfile = 358,
-     T_Pool = 359,
-     T_Port = 360,
-     T_Pps = 361,
-     T_Preempt = 362,
-     T_Prefer = 363,
-     T_Protostats = 364,
-     T_Pw = 365,
-     T_Qos = 366,
-     T_RandFile = 367,
-     T_Rawstats = 368,
-     T_Refid = 369,
-     T_Requestkey = 370,
-     T_Restrict = 371,
-     T_Revoke = 372,
-     T_Server = 373,
-     T_Setvar = 374,
-     T_Sign = 375,
-     T_Statistics = 376,
-     T_Stats = 377,
-     T_Statsdir = 378,
-     T_Step = 379,
-     T_Stepout = 380,
-     T_Stratum = 381,
-     T_String = 382,
-     T_Sysstats = 383,
-     T_Tick = 384,
-     T_Time1 = 385,
-     T_Time2 = 386,
-     T_Timingstats = 387,
-     T_Tinker = 388,
-     T_Tos = 389,
-     T_Trap = 390,
-     T_True = 391,
-     T_Trustedkey = 392,
-     T_Ttl = 393,
-     T_Type = 394,
-     T_Unconfig = 395,
-     T_Unpeer = 396,
-     T_Version = 397,
+     T_Enable = 286,
+     T_End = 287,
+     T_False = 288,
+     T_File = 289,
+     T_Filegen = 290,
+     T_Flag1 = 291,
+     T_Flag2 = 292,
+     T_Flag3 = 293,
+     T_Flag4 = 294,
+     T_Flake = 295,
+     T_Floor = 296,
+     T_Freq = 297,
+     T_Fudge = 298,
+     T_Host = 299,
+     T_Huffpuff = 300,
+     T_Iburst = 301,
+     T_Ident = 302,
+     T_Ignore = 303,
+     T_Includefile = 304,
+     T_Integer = 305,
+     T_Interface = 306,
+     T_IPv4_flag = 307,
+     T_IPv6_flag = 308,
+     T_Kernel = 309,
+     T_Key = 310,
+     T_Keys = 311,
+     T_Keysdir = 312,
+     T_Kod = 313,
+     T_Leap = 314,
+     T_Leapfile = 315,
+     T_Limited = 316,
+     T_Link = 317,
+     T_Logconfig = 318,
+     T_Logfile = 319,
+     T_Loopstats = 320,
+     T_Lowpriotrap = 321,
+     T_Manycastclient = 322,
+     T_Manycastserver = 323,
+     T_Mask = 324,
+     T_Maxclock = 325,
+     T_Maxdist = 326,
+     T_Maxhop = 327,
+     T_Maxpoll = 328,
+     T_Minclock = 329,
+     T_Mindist = 330,
+     T_Minimum = 331,
+     T_Minpoll = 332,
+     T_Minsane = 333,
+     T_Mode = 334,
+     T_Monitor = 335,
+     T_Month = 336,
+     T_Multicastclient = 337,
+     T_Nolink = 338,
+     T_Nomodify = 339,
+     T_None = 340,
+     T_Nopeer = 341,
+     T_Noquery = 342,
+     T_Noselect = 343,
+     T_Noserve = 344,
+     T_Notrap = 345,
+     T_Notrust = 346,
+     T_Novolley = 347,
+     T_Ntp = 348,
+     T_Ntpport = 349,
+     T_NtpSignDsocket = 350,
+     T_Orphan = 351,
+     T_Panic = 352,
+     T_Peer = 353,
+     T_Peerstats = 354,
+     T_Phone = 355,
+     T_Pid = 356,
+     T_Pidfile = 357,
+     T_Pool = 358,
+     T_Port = 359,
+     T_Pps = 360,
+     T_Preempt = 361,
+     T_Prefer = 362,
+     T_Protostats = 363,
+     T_Pw = 364,
+     T_Qos = 365,
+     T_RandFile = 366,
+     T_Rawstats = 367,
+     T_Refid = 368,
+     T_Requestkey = 369,
+     T_Restrict = 370,
+     T_Revoke = 371,
+     T_Server = 372,
+     T_Setvar = 373,
+     T_Sign = 374,
+     T_Statistics = 375,
+     T_Stats = 376,
+     T_Statsdir = 377,
+     T_Step = 378,
+     T_Stepout = 379,
+     T_Stratum = 380,
+     T_String = 381,
+     T_Sysstats = 382,
+     T_Tick = 383,
+     T_Time1 = 384,
+     T_Time2 = 385,
+     T_Timingstats = 386,
+     T_Tinker = 387,
+     T_Tos = 388,
+     T_Trap = 389,
+     T_True = 390,
+     T_Trustedkey = 391,
+     T_Ttl = 392,
+     T_Type = 393,
+     T_Unconfig = 394,
+     T_Unpeer = 395,
+     T_Version = 396,
+     T_WanderThreshold = 397,
      T_Week = 398,
      T_Xleave = 399,
      T_Year = 400,
 #define T_Dispersion 283
 #define T_Double 284
 #define T_Driftfile 285
-#define T_WanderThreshold 286
-#define T_Enable 287
-#define T_End 288
-#define T_False 289
-#define T_File 290
-#define T_Filegen 291
-#define T_Flag1 292
-#define T_Flag2 293
-#define T_Flag3 294
-#define T_Flag4 295
-#define T_Flake 296
-#define T_Floor 297
-#define T_Freq 298
-#define T_Fudge 299
-#define T_Host 300
-#define T_Huffpuff 301
-#define T_IPv4_address 302
-#define T_IPv6_address 303
-#define T_Iburst 304
-#define T_Ident 305
-#define T_Ignore 306
-#define T_Includefile 307
-#define T_Integer 308
-#define T_Interface 309
-#define T_Kernel 310
-#define T_Key 311
-#define T_Keys 312
-#define T_Keysdir 313
-#define T_Kod 314
-#define T_Leap 315
-#define T_Leapfile 316
-#define T_Limited 317
-#define T_Link 318
-#define T_Logconfig 319
-#define T_Logfile 320
-#define T_Loopstats 321
-#define T_Lowpriotrap 322
-#define T_Manycastclient 323
-#define T_Manycastserver 324
-#define T_Mask 325
-#define T_Maxclock 326
-#define T_Maxdist 327
-#define T_Maxhop 328
-#define T_Maxpoll 329
-#define T_Minclock 330
-#define T_Mindist 331
-#define T_Minimum 332
-#define T_Minpoll 333
-#define T_Minsane 334
-#define T_Mode 335
-#define T_Monitor 336
-#define T_Month 337
-#define T_Multicastclient 338
-#define T_Nolink 339
-#define T_Nomodify 340
-#define T_None 341
-#define T_Nopeer 342
-#define T_Noquery 343
-#define T_Noselect 344
-#define T_Noserve 345
-#define T_Notrap 346
-#define T_Notrust 347
-#define T_Novolley 348
-#define T_Ntp 349
-#define T_Ntpport 350
-#define T_NtpSignDsocket 351
-#define T_Orphan 352
-#define T_Panic 353
-#define T_Peer 354
-#define T_Peerstats 355
-#define T_Phone 356
-#define T_Pid 357
-#define T_Pidfile 358
-#define T_Pool 359
-#define T_Port 360
-#define T_Pps 361
-#define T_Preempt 362
-#define T_Prefer 363
-#define T_Protostats 364
-#define T_Pw 365
-#define T_Qos 366
-#define T_RandFile 367
-#define T_Rawstats 368
-#define T_Refid 369
-#define T_Requestkey 370
-#define T_Restrict 371
-#define T_Revoke 372
-#define T_Server 373
-#define T_Setvar 374
-#define T_Sign 375
-#define T_Statistics 376
-#define T_Stats 377
-#define T_Statsdir 378
-#define T_Step 379
-#define T_Stepout 380
-#define T_Stratum 381
-#define T_String 382
-#define T_Sysstats 383
-#define T_Tick 384
-#define T_Time1 385
-#define T_Time2 386
-#define T_Timingstats 387
-#define T_Tinker 388
-#define T_Tos 389
-#define T_Trap 390
-#define T_True 391
-#define T_Trustedkey 392
-#define T_Ttl 393
-#define T_Type 394
-#define T_Unconfig 395
-#define T_Unpeer 396
-#define T_Version 397
+#define T_Enable 286
+#define T_End 287
+#define T_False 288
+#define T_File 289
+#define T_Filegen 290
+#define T_Flag1 291
+#define T_Flag2 292
+#define T_Flag3 293
+#define T_Flag4 294
+#define T_Flake 295
+#define T_Floor 296
+#define T_Freq 297
+#define T_Fudge 298
+#define T_Host 299
+#define T_Huffpuff 300
+#define T_Iburst 301
+#define T_Ident 302
+#define T_Ignore 303
+#define T_Includefile 304
+#define T_Integer 305
+#define T_Interface 306
+#define T_IPv4_flag 307
+#define T_IPv6_flag 308
+#define T_Kernel 309
+#define T_Key 310
+#define T_Keys 311
+#define T_Keysdir 312
+#define T_Kod 313
+#define T_Leap 314
+#define T_Leapfile 315
+#define T_Limited 316
+#define T_Link 317
+#define T_Logconfig 318
+#define T_Logfile 319
+#define T_Loopstats 320
+#define T_Lowpriotrap 321
+#define T_Manycastclient 322
+#define T_Manycastserver 323
+#define T_Mask 324
+#define T_Maxclock 325
+#define T_Maxdist 326
+#define T_Maxhop 327
+#define T_Maxpoll 328
+#define T_Minclock 329
+#define T_Mindist 330
+#define T_Minimum 331
+#define T_Minpoll 332
+#define T_Minsane 333
+#define T_Mode 334
+#define T_Monitor 335
+#define T_Month 336
+#define T_Multicastclient 337
+#define T_Nolink 338
+#define T_Nomodify 339
+#define T_None 340
+#define T_Nopeer 341
+#define T_Noquery 342
+#define T_Noselect 343
+#define T_Noserve 344
+#define T_Notrap 345
+#define T_Notrust 346
+#define T_Novolley 347
+#define T_Ntp 348
+#define T_Ntpport 349
+#define T_NtpSignDsocket 350
+#define T_Orphan 351
+#define T_Panic 352
+#define T_Peer 353
+#define T_Peerstats 354
+#define T_Phone 355
+#define T_Pid 356
+#define T_Pidfile 357
+#define T_Pool 358
+#define T_Port 359
+#define T_Pps 360
+#define T_Preempt 361
+#define T_Prefer 362
+#define T_Protostats 363
+#define T_Pw 364
+#define T_Qos 365
+#define T_RandFile 366
+#define T_Rawstats 367
+#define T_Refid 368
+#define T_Requestkey 369
+#define T_Restrict 370
+#define T_Revoke 371
+#define T_Server 372
+#define T_Setvar 373
+#define T_Sign 374
+#define T_Statistics 375
+#define T_Stats 376
+#define T_Statsdir 377
+#define T_Step 378
+#define T_Stepout 379
+#define T_Stratum 380
+#define T_String 381
+#define T_Sysstats 382
+#define T_Tick 383
+#define T_Time1 384
+#define T_Time2 385
+#define T_Timingstats 386
+#define T_Tinker 387
+#define T_Tos 388
+#define T_Trap 389
+#define T_True 390
+#define T_Trustedkey 391
+#define T_Ttl 392
+#define T_Type 393
+#define T_Unconfig 394
+#define T_Unpeer 395
+#define T_Version 396
+#define T_WanderThreshold 397
 #define T_Week 398
 #define T_Xleave 399
 #define T_Year 400
@@ -461,7 +454,7 @@ typedef union YYSTYPE
 {
 
 /* Line 214 of yacc.c  */
-#line 51 "ntp_parser.y"
+#line 44 "ntp_parser.y"
 
     char   *String;
     double  Double;
@@ -479,7 +472,7 @@ typedef union YYSTYPE
 
 
 /* Line 214 of yacc.c  */
-#line 483 "ntp_parser.c"
+#line 476 "ntp_parser.c"
 } YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -491,7 +484,7 @@ typedef union YYSTYPE
 
 
 /* Line 264 of yacc.c  */
-#line 495 "ntp_parser.c"
+#line 488 "ntp_parser.c"
 
 #ifdef short
 # undef short
@@ -704,18 +697,18 @@ union yyalloc
 #endif
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  166
+#define YYFINAL  168
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   631
+#define YYLAST   638
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  162
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  64
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  229
+#define YYNRULES  231
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  362
+#define YYNSTATES  368
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
@@ -787,18 +780,19 @@ static const yytype_uint16 yyprhs[] =
      200,   203,   206,   209,   212,   215,   218,   221,   224,   228,
      231,   233,   235,   237,   239,   241,   243,   245,   247,   249,
      252,   254,   257,   260,   262,   264,   266,   268,   270,   272,
-     274,   276,   278,   280,   282,   285,   289,   293,   299,   300,
-     303,   305,   307,   309,   311,   313,   315,   317,   319,   321,
-     323,   325,   327,   329,   332,   334,   337,   340,   343,   347,
-     350,   352,   355,   358,   361,   364,   367,   370,   373,   376,
-     379,   382,   385,   387,   389,   391,   393,   395,   397,   399,
-     401,   404,   407,   409,   412,   415,   418,   421,   424,   427,
-     430,   434,   436,   439,   442,   445,   448,   451,   454,   457,
-     460,   463,   466,   469,   473,   476,   479,   481,   484,   485,
-     490,   494,   497,   499,   502,   505,   508,   510,   512,   515,
-     517,   520,   522,   525,   527,   529,   531,   533,   535,   537,
-     543,   545,   549,   552,   556,   560,   563,   565,   571,   576,
-     580,   583,   585,   592,   596,   599,   603,   607,   611,   615
+     274,   276,   278,   280,   282,   285,   289,   293,   298,   303,
+     309,   310,   313,   315,   317,   319,   321,   323,   325,   327,
+     329,   331,   333,   335,   337,   339,   342,   344,   347,   350,
+     353,   357,   360,   362,   365,   368,   371,   374,   377,   380,
+     383,   386,   389,   392,   395,   397,   399,   401,   403,   405,
+     407,   409,   411,   414,   417,   419,   422,   425,   428,   431,
+     434,   437,   440,   444,   446,   449,   452,   455,   458,   461,
+     464,   467,   470,   473,   476,   479,   483,   486,   489,   491,
+     494,   495,   500,   504,   507,   509,   512,   515,   518,   520,
+     522,   525,   527,   530,   532,   535,   537,   539,   541,   543,
+     545,   547,   553,   555,   559,   562,   566,   570,   573,   575,
+     581,   586,   590,   593,   595,   602,   606,   609,   613,   617,
+     621,   625
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
@@ -808,60 +802,61 @@ static const yytype_int16 yyrhs[] =
      148,    -1,     1,   148,    -1,    -1,   166,    -1,   172,    -1,
      174,    -1,   175,    -1,   182,    -1,   188,    -1,   179,    -1,
      193,    -1,   196,    -1,   199,    -1,   202,    -1,   214,    -1,
-     167,   168,   170,    -1,   167,   168,    -1,   118,    -1,   104,
-      -1,    99,    -1,    12,    -1,    68,    -1,   169,    -1,    47,
-     127,    -1,    48,   127,    -1,   127,    -1,   170,   171,    -1,
-     171,    -1,     6,    -1,    11,   213,    -1,    15,    -1,    49,
-      -1,    56,    53,    -1,    78,    53,    -1,    74,    53,    -1,
-      89,    -1,   107,    -1,   108,    -1,   136,    -1,   144,    -1,
-     138,    53,    -1,    80,    53,    -1,   142,    53,    -1,   173,
-     168,    -1,   140,    -1,   141,    -1,    13,    -1,    13,    93,
-      -1,    69,   211,    -1,    83,   211,    -1,     6,    53,    -1,
-      21,    53,    -1,    22,   176,    -1,    57,   127,    -1,    58,
-     127,    -1,   115,    53,    -1,   137,   209,    -1,    96,   127,
-      -1,   177,    -1,    -1,   177,   178,    -1,   178,    -1,    45,
-     127,    -1,    50,   127,    -1,   110,   127,    -1,   112,   127,
-      -1,   117,    53,    -1,   120,   127,    -1,   134,   180,    -1,
-     180,   181,    -1,   181,    -1,    18,    53,    -1,    42,    53,
-      -1,    20,   212,    -1,    97,    53,    -1,    76,   213,    -1,
-      72,   213,    -1,    75,   213,    -1,    71,   213,    -1,    79,
-      53,    -1,    10,    53,    -1,    73,    53,    -1,   121,   183,
-      -1,   123,   127,    -1,    36,   184,   185,    -1,   183,   184,
-      -1,   184,    -1,    19,    -1,    23,    -1,    66,    -1,   100,
-      -1,   113,    -1,   128,    -1,   132,    -1,   109,    -1,   185,
-     186,    -1,   186,    -1,    35,   127,    -1,   139,   187,    -1,
-      63,    -1,    84,    -1,    32,    -1,    26,    -1,    86,    -1,
-     102,    -1,    24,    -1,   143,    -1,    82,    -1,   145,    -1,
-       3,    -1,    27,   191,    -1,   116,   168,   189,    -1,   116,
-      25,   189,    -1,   116,   169,    70,   169,   189,    -1,    -1,
-     189,   190,    -1,    41,    -1,    51,    -1,    59,    -1,    62,
-      -1,    67,    -1,    85,    -1,    87,    -1,    88,    -1,    90,
-      -1,    91,    -1,    92,    -1,    95,    -1,   142,    -1,   191,
-     192,    -1,   192,    -1,     8,    53,    -1,    77,    53,    -1,
-      81,    53,    -1,    44,   168,   194,    -1,   194,   195,    -1,
-     195,    -1,   130,   213,    -1,   131,   213,    -1,   126,    53,
-      -1,   114,   127,    -1,    37,   212,    -1,    38,   212,    -1,
-      39,   212,    -1,    40,   212,    -1,    32,   197,    -1,    26,
+     167,   168,   170,    -1,   167,   168,    -1,   117,    -1,   103,
+      -1,    98,    -1,    12,    -1,    67,    -1,   169,    -1,    52,
+     126,    -1,    53,   126,    -1,   126,    -1,   170,   171,    -1,
+     171,    -1,     6,    -1,    11,   213,    -1,    15,    -1,    46,
+      -1,    55,    50,    -1,    77,    50,    -1,    73,    50,    -1,
+      88,    -1,   106,    -1,   107,    -1,   135,    -1,   144,    -1,
+     137,    50,    -1,    79,    50,    -1,   141,    50,    -1,   173,
+     168,    -1,   139,    -1,   140,    -1,    13,    -1,    13,    92,
+      -1,    68,   211,    -1,    82,   211,    -1,     6,    50,    -1,
+      21,    50,    -1,    22,   176,    -1,    56,   126,    -1,    57,
+     126,    -1,   114,    50,    -1,   136,   209,    -1,    95,   126,
+      -1,   177,    -1,    -1,   177,   178,    -1,   178,    -1,    44,
+     126,    -1,    47,   126,    -1,   109,   126,    -1,   111,   126,
+      -1,   116,    50,    -1,   119,   126,    -1,   133,   180,    -1,
+     180,   181,    -1,   181,    -1,    18,    50,    -1,    41,    50,
+      -1,    20,   212,    -1,    96,    50,    -1,    75,   213,    -1,
+      71,   213,    -1,    74,   213,    -1,    70,   213,    -1,    78,
+      50,    -1,    10,    50,    -1,    72,    50,    -1,   120,   183,
+      -1,   122,   126,    -1,    35,   184,   185,    -1,   183,   184,
+      -1,   184,    -1,    19,    -1,    23,    -1,    65,    -1,    99,
+      -1,   112,    -1,   127,    -1,   131,    -1,   108,    -1,   185,
+     186,    -1,   186,    -1,    34,   126,    -1,   138,   187,    -1,
+      62,    -1,    83,    -1,    31,    -1,    26,    -1,    85,    -1,
+     101,    -1,    24,    -1,   143,    -1,    81,    -1,   145,    -1,
+       3,    -1,    27,   191,    -1,   115,   168,   189,    -1,   115,
+      25,   189,    -1,   115,    52,    25,   189,    -1,   115,    53,
+      25,   189,    -1,   115,   169,    69,   169,   189,    -1,    -1,
+     189,   190,    -1,    40,    -1,    48,    -1,    58,    -1,    61,
+      -1,    66,    -1,    84,    -1,    86,    -1,    87,    -1,    89,
+      -1,    90,    -1,    91,    -1,    94,    -1,   141,    -1,   191,
+     192,    -1,   192,    -1,     8,    50,    -1,    76,    50,    -1,
+      80,    50,    -1,    43,   168,   194,    -1,   194,   195,    -1,
+     195,    -1,   129,   213,    -1,   130,   213,    -1,   125,    50,
+      -1,   113,   126,    -1,    36,   212,    -1,    37,   212,    -1,
+      38,   212,    -1,    39,   212,    -1,    31,   197,    -1,    26,
      197,    -1,   197,   198,    -1,   198,    -1,     5,    -1,     9,
-      -1,    16,    -1,    55,    -1,    81,    -1,    94,    -1,   122,
-      -1,   133,   200,    -1,   200,   201,    -1,   201,    -1,     4,
-     213,    -1,    28,   213,    -1,    43,   213,    -1,    46,   213,
-      -1,    98,   213,    -1,   124,   213,    -1,   125,   213,    -1,
-      52,   127,   165,    -1,    33,    -1,    14,   213,    -1,    17,
-      53,    -1,   129,   213,    -1,    30,   203,    -1,    61,   127,
-      -1,   103,   127,    -1,    65,   127,    -1,     7,    53,    -1,
-      64,   207,    -1,   101,   210,    -1,   119,   204,    -1,   135,
-     169,   205,    -1,   138,   209,    -1,   111,   127,    -1,   127,
-      -1,   127,    29,    -1,    -1,   127,   159,   127,    25,    -1,
-     127,   159,   127,    -1,   205,   206,    -1,   206,    -1,   105,
-      53,    -1,    54,   169,    -1,   207,   208,    -1,   208,    -1,
-     127,    -1,   209,    53,    -1,    53,    -1,   210,   127,    -1,
-     127,    -1,   211,   168,    -1,   168,    -1,    53,    -1,   136,
-      -1,    34,    -1,    53,    -1,    29,    -1,   215,   160,   216,
+      -1,    16,    -1,    54,    -1,    80,    -1,    93,    -1,   121,
+      -1,   132,   200,    -1,   200,   201,    -1,   201,    -1,     4,
+     213,    -1,    28,   213,    -1,    42,   213,    -1,    45,   213,
+      -1,    97,   213,    -1,   123,   213,    -1,   124,   213,    -1,
+      49,   126,   165,    -1,    32,    -1,    14,   213,    -1,    17,
+      50,    -1,   128,   213,    -1,    30,   203,    -1,    60,   126,
+      -1,   102,   126,    -1,    64,   126,    -1,     7,    50,    -1,
+      63,   207,    -1,   100,   210,    -1,   118,   204,    -1,   134,
+     169,   205,    -1,   137,   209,    -1,   110,   126,    -1,   126,
+      -1,   126,    29,    -1,    -1,   126,   159,   126,    25,    -1,
+     126,   159,   126,    -1,   205,   206,    -1,   206,    -1,   104,
+      50,    -1,    51,   169,    -1,   207,   208,    -1,   208,    -1,
+     126,    -1,   209,    50,    -1,    50,    -1,   210,   126,    -1,
+     126,    -1,   211,   168,    -1,   168,    -1,    50,    -1,   135,
+      -1,    33,    -1,    50,    -1,    29,    -1,   215,   160,   216,
      218,   161,    -1,   149,    -1,   216,   217,   148,    -1,   217,
      148,    -1,   150,   159,   213,    -1,   151,   159,   213,    -1,
      218,   219,    -1,   219,    -1,   221,   160,   220,   222,   161,
-      -1,   152,   159,   213,   148,    -1,   118,   159,   168,    -1,
+      -1,   152,   159,   213,   148,    -1,   117,   159,   168,    -1,
      222,   223,    -1,   223,    -1,   153,   159,   213,   160,   224,
      161,    -1,   224,   225,   148,    -1,   225,   148,    -1,   154,
      159,   213,    -1,   155,   159,   213,    -1,   156,   159,   213,
@@ -871,29 +866,30 @@ static const yytype_int16 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   287,   287,   291,   292,   293,   308,   309,   310,   311,
-     312,   313,   314,   315,   316,   317,   318,   319,   320,   328,
-     334,   343,   344,   345,   346,   347,   351,   352,   353,   357,
-     361,   362,   367,   368,   369,   370,   371,   372,   373,   374,
-     375,   376,   377,   378,   379,   380,   381,   390,   398,   399,
-     409,   411,   413,   415,   426,   428,   430,   438,   440,   442,
-     444,   446,   451,   453,   457,   458,   462,   464,   466,   468,
-     470,   472,   482,   487,   488,   492,   494,   496,   498,   500,
-     502,   504,   506,   508,   510,   512,   522,   524,   526,   534,
-     535,   539,   541,   543,   545,   547,   549,   551,   553,   558,
-     559,   563,   565,   567,   568,   569,   570,   574,   575,   576,
-     577,   578,   579,   580,   589,   593,   598,   603,   611,   612,
-     616,   617,   618,   619,   620,   621,   622,   623,   624,   625,
-     626,   627,   628,   632,   633,   637,   638,   639,   647,   652,
-     653,   657,   659,   661,   663,   665,   667,   669,   671,   680,
-     682,   687,   688,   692,   693,   694,   695,   696,   697,   699,
-     707,   711,   712,   716,   717,   718,   719,   720,   721,   722,
-     730,   746,   752,   754,   756,   758,   760,   763,   765,   767,
-     770,   772,   774,   776,   778,   780,   784,   786,   790,   794,
-     796,   802,   803,   807,   808,   813,   814,   818,   837,   838,
-     842,   843,   847,   848,   852,   861,   862,   866,   867,   875,
-     890,   894,   895,   899,   900,   904,   905,   909,   914,   918,
-     922,   923,   927,   932,   933,   937,   939,   941,   943,   945
+       0,   280,   280,   284,   285,   286,   307,   308,   309,   310,
+     311,   312,   313,   314,   315,   316,   317,   318,   319,   327,
+     333,   342,   343,   344,   345,   346,   350,   351,   352,   356,
+     360,   361,   365,   366,   367,   368,   369,   370,   371,   372,
+     373,   374,   375,   376,   377,   378,   379,   388,   396,   397,
+     407,   409,   411,   413,   424,   426,   428,   436,   438,   440,
+     442,   444,   449,   451,   455,   456,   460,   462,   464,   466,
+     468,   470,   480,   485,   486,   490,   492,   494,   496,   498,
+     500,   502,   504,   506,   508,   510,   520,   522,   524,   532,
+     533,   537,   539,   541,   543,   545,   547,   549,   551,   556,
+     557,   561,   563,   565,   566,   567,   568,   572,   573,   574,
+     575,   576,   577,   578,   587,   591,   596,   601,   614,   627,
+     635,   636,   640,   641,   642,   643,   644,   645,   646,   647,
+     648,   649,   650,   651,   652,   656,   657,   661,   662,   663,
+     671,   676,   677,   681,   683,   685,   687,   689,   691,   693,
+     695,   704,   706,   711,   712,   716,   717,   718,   719,   720,
+     721,   723,   731,   735,   736,   740,   741,   742,   743,   744,
+     745,   746,   754,   770,   776,   778,   780,   782,   784,   787,
+     789,   791,   794,   796,   798,   800,   802,   804,   808,   810,
+     814,   818,   820,   826,   827,   831,   832,   837,   838,   842,
+     861,   862,   866,   867,   871,   872,   876,   885,   886,   890,
+     891,   899,   914,   918,   919,   923,   924,   928,   929,   933,
+     938,   942,   946,   947,   951,   956,   957,   961,   963,   965,
+     967,   969
 };
 #endif
 
@@ -908,12 +904,12 @@ static const char *const yytname[] =
   "T_Calibrate", "T_Calldelay", "T_Ceiling", "T_Clockstats", "T_Cohort",
   "T_ControlKey", "T_Crypto", "T_Cryptostats", "T_Day", "T_Default",
   "T_Disable", "T_Discard", "T_Dispersion", "T_Double", "T_Driftfile",
-  "T_WanderThreshold", "T_Enable", "T_End", "T_False", "T_File",
-  "T_Filegen", "T_Flag1", "T_Flag2", "T_Flag3", "T_Flag4", "T_Flake",
-  "T_Floor", "T_Freq", "T_Fudge", "T_Host", "T_Huffpuff", "T_IPv4_address",
-  "T_IPv6_address", "T_Iburst", "T_Ident", "T_Ignore", "T_Includefile",
-  "T_Integer", "T_Interface", "T_Kernel", "T_Key", "T_Keys", "T_Keysdir",
-  "T_Kod", "T_Leap", "T_Leapfile", "T_Limited", "T_Link", "T_Logconfig",
+  "T_Enable", "T_End", "T_False", "T_File", "T_Filegen", "T_Flag1",
+  "T_Flag2", "T_Flag3", "T_Flag4", "T_Flake", "T_Floor", "T_Freq",
+  "T_Fudge", "T_Host", "T_Huffpuff", "T_Iburst", "T_Ident", "T_Ignore",
+  "T_Includefile", "T_Integer", "T_Interface", "T_IPv4_flag",
+  "T_IPv6_flag", "T_Kernel", "T_Key", "T_Keys", "T_Keysdir", "T_Kod",
+  "T_Leap", "T_Leapfile", "T_Limited", "T_Link", "T_Logconfig",
   "T_Logfile", "T_Loopstats", "T_Lowpriotrap", "T_Manycastclient",
   "T_Manycastserver", "T_Mask", "T_Maxclock", "T_Maxdist", "T_Maxhop",
   "T_Maxpoll", "T_Minclock", "T_Mindist", "T_Minimum", "T_Minpoll",
@@ -928,28 +924,29 @@ static const char *const yytname[] =
   "T_Statistics", "T_Stats", "T_Statsdir", "T_Step", "T_Stepout",
   "T_Stratum", "T_String", "T_Sysstats", "T_Tick", "T_Time1", "T_Time2",
   "T_Timingstats", "T_Tinker", "T_Tos", "T_Trap", "T_True", "T_Trustedkey",
-  "T_Ttl", "T_Type", "T_Unconfig", "T_Unpeer", "T_Version", "T_Week",
-  "T_Xleave", "T_Year", "T_Flag", "T_Void", "T_EOC", "T_Simulate",
-  "T_Beep_Delay", "T_Sim_Duration", "T_Server_Offset", "T_Duration",
-  "T_Freq_Offset", "T_Wander", "T_Jitter", "T_Prop_Delay", "T_Proc_Delay",
-  "'='", "'{'", "'}'", "$accept", "configuration", "command_list",
-  "command", "server_command", "client_type", "address", "ip_address",
-  "option_list", "option", "unpeer_command", "unpeer_keyword",
-  "other_mode_command", "authentication_command", "crypto_command_line",
-  "crypto_command_list", "crypto_command", "orphan_mode_command",
-  "tos_option_list", "tos_option", "monitoring_command", "stats_list",
-  "stat", "filegen_option_list", "filegen_option", "filegen_type",
-  "access_control_command", "ac_flag_list", "access_control_flag",
-  "discard_option_list", "discard_option", "fudge_command",
-  "fudge_factor_list", "fudge_factor", "system_option_command",
-  "system_option_list", "system_option", "tinker_command",
-  "tinker_option_list", "tinker_option", "miscellaneous_command",
-  "drift_parm", "variable_assign", "trap_option_list", "trap_option",
-  "log_config_list", "log_config_command", "integer_list", "string_list",
-  "address_list", "boolean", "number", "simulate_command",
-  "sim_conf_start", "sim_init_statement_list", "sim_init_statement",
-  "sim_server_list", "sim_server", "sim_server_offset", "sim_server_name",
-  "sim_act_list", "sim_act", "sim_act_stmt_list", "sim_act_stmt", 0
+  "T_Ttl", "T_Type", "T_Unconfig", "T_Unpeer", "T_Version",
+  "T_WanderThreshold", "T_Week", "T_Xleave", "T_Year", "T_Flag", "T_Void",
+  "T_EOC", "T_Simulate", "T_Beep_Delay", "T_Sim_Duration",
+  "T_Server_Offset", "T_Duration", "T_Freq_Offset", "T_Wander", "T_Jitter",
+  "T_Prop_Delay", "T_Proc_Delay", "'='", "'{'", "'}'", "$accept",
+  "configuration", "command_list", "command", "server_command",
+  "client_type", "address", "ip_address", "option_list", "option",
+  "unpeer_command", "unpeer_keyword", "other_mode_command",
+  "authentication_command", "crypto_command_line", "crypto_command_list",
+  "crypto_command", "orphan_mode_command", "tos_option_list", "tos_option",
+  "monitoring_command", "stats_list", "stat", "filegen_option_list",
+  "filegen_option", "filegen_type", "access_control_command",
+  "ac_flag_list", "access_control_flag", "discard_option_list",
+  "discard_option", "fudge_command", "fudge_factor_list", "fudge_factor",
+  "system_option_command", "system_option_list", "system_option",
+  "tinker_command", "tinker_option_list", "tinker_option",
+  "miscellaneous_command", "drift_parm", "variable_assign",
+  "trap_option_list", "trap_option", "log_config_list",
+  "log_config_command", "integer_list", "string_list", "address_list",
+  "boolean", "number", "simulate_command", "sim_conf_start",
+  "sim_init_statement_list", "sim_init_statement", "sim_server_list",
+  "sim_server", "sim_server_offset", "sim_server_name", "sim_act_list",
+  "sim_act", "sim_act_stmt_list", "sim_act_stmt", 0
 };
 #endif
 
@@ -992,18 +989,19 @@ static const yytype_uint8 yyr1[] =
      181,   181,   181,   181,   181,   181,   182,   182,   182,   183,
      183,   184,   184,   184,   184,   184,   184,   184,   184,   185,
      185,   186,   186,   186,   186,   186,   186,   187,   187,   187,
-     187,   187,   187,   187,   188,   188,   188,   188,   189,   189,
-     190,   190,   190,   190,   190,   190,   190,   190,   190,   190,
-     190,   190,   190,   191,   191,   192,   192,   192,   193,   194,
-     194,   195,   195,   195,   195,   195,   195,   195,   195,   196,
-     196,   197,   197,   198,   198,   198,   198,   198,   198,   198,
-     199,   200,   200,   201,   201,   201,   201,   201,   201,   201,
-     202,   202,   202,   202,   202,   202,   202,   202,   202,   202,
-     202,   202,   202,   202,   202,   202,   203,   203,   203,   204,
-     204,   205,   205,   206,   206,   207,   207,   208,   209,   209,
-     210,   210,   211,   211,   212,   212,   212,   213,   213,   214,
-     215,   216,   216,   217,   217,   218,   218,   219,   220,   221,
-     222,   222,   223,   224,   224,   225,   225,   225,   225,   225
+     187,   187,   187,   187,   188,   188,   188,   188,   188,   188,
+     189,   189,   190,   190,   190,   190,   190,   190,   190,   190,
+     190,   190,   190,   190,   190,   191,   191,   192,   192,   192,
+     193,   194,   194,   195,   195,   195,   195,   195,   195,   195,
+     195,   196,   196,   197,   197,   198,   198,   198,   198,   198,
+     198,   198,   199,   200,   200,   201,   201,   201,   201,   201,
+     201,   201,   202,   202,   202,   202,   202,   202,   202,   202,
+     202,   202,   202,   202,   202,   202,   202,   202,   203,   203,
+     203,   204,   204,   205,   205,   206,   206,   207,   207,   208,
+     209,   209,   210,   210,   211,   211,   212,   212,   212,   213,
+     213,   214,   215,   216,   216,   217,   217,   218,   218,   219,
+     220,   221,   222,   222,   223,   224,   224,   225,   225,   225,
+     225,   225
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
@@ -1020,18 +1018,19 @@ static const yytype_uint8 yyr2[] =
        2,     2,     2,     2,     2,     2,     2,     2,     3,     2,
        1,     1,     1,     1,     1,     1,     1,     1,     1,     2,
        1,     2,     2,     1,     1,     1,     1,     1,     1,     1,
-       1,     1,     1,     1,     2,     3,     3,     5,     0,     2,
-       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       1,     1,     1,     2,     1,     2,     2,     2,     3,     2,
-       1,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     1,     1,     1,     1,     1,     1,     1,     1,
-       2,     2,     1,     2,     2,     2,     2,     2,     2,     2,
-       3,     1,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     3,     2,     2,     1,     2,     0,     4,
-       3,     2,     1,     2,     2,     2,     1,     1,     2,     1,
-       2,     1,     2,     1,     1,     1,     1,     1,     1,     5,
-       1,     3,     2,     3,     3,     2,     1,     5,     4,     3,
-       2,     1,     6,     3,     2,     3,     3,     3,     3,     3
+       1,     1,     1,     1,     2,     3,     3,     4,     4,     5,
+       0,     2,     1,     1,     1,     1,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     2,     1,     2,     2,     2,
+       3,     2,     1,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     1,     1,     1,     1,     1,     1,
+       1,     1,     2,     2,     1,     2,     2,     2,     2,     2,
+       2,     2,     3,     1,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     3,     2,     2,     1,     2,
+       0,     4,     3,     2,     1,     2,     2,     2,     1,     1,
+       2,     1,     2,     1,     2,     1,     1,     1,     1,     1,
+       1,     5,     1,     3,     2,     3,     3,     2,     1,     5,
+       4,     3,     2,     1,     6,     3,     2,     3,     3,     3,
+       3,     3
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -1040,110 +1039,110 @@ static const yytype_uint8 yyr2[] =
 static const yytype_uint8 yydefact[] =
 {
        0,     0,     0,     0,    24,    50,     0,     0,     0,    63,
-       0,     0,   188,     0,   171,     0,     0,     0,     0,     0,
+       0,     0,   190,     0,   173,     0,     0,     0,     0,     0,
        0,     0,     0,    25,     0,     0,     0,    23,     0,     0,
       22,     0,     0,     0,    21,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    48,    49,   210,     0,     2,     0,
+       0,     0,     0,     0,    48,    49,   212,     0,     2,     0,
        7,     0,     8,     0,     9,    10,    13,    11,    12,    14,
-      15,    16,    17,    18,     0,     5,    54,   179,    51,   208,
-     207,   172,   173,    55,     0,     0,     0,     0,     0,     0,
-      56,    62,    65,   153,   154,   155,   156,   157,   158,   159,
-     150,   152,     0,     0,     0,   114,   134,   186,   175,   149,
+      15,    16,    17,    18,     0,     5,    54,   181,    51,   210,
+     209,   174,   175,    55,     0,     0,     0,     0,     0,     0,
+      56,    62,    65,   155,   156,   157,   158,   159,   160,   161,
+     152,   154,     0,     0,     0,   114,   136,   188,   177,   151,
       91,    92,    93,    94,    98,    95,    96,    97,     0,     0,
-       0,    29,     0,    26,     6,    57,    58,   176,   197,   180,
-     196,   178,   203,    52,    53,    61,   201,   181,   177,   185,
-      59,   118,   118,    26,     0,   182,    86,    90,    87,   174,
-       0,     0,     0,     0,     0,     0,     0,   160,   162,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-      72,    74,     0,   199,    60,   184,     1,     0,     4,    20,
-      47,     0,    66,    67,    68,    69,    70,    71,    64,   151,
-     135,   136,   137,   133,   187,   106,   105,     0,   103,   104,
-       0,    88,   100,    27,    28,     0,     0,     0,     0,     0,
-       0,     0,     0,   138,   140,   170,   195,   202,   200,   116,
-     115,     0,     0,    89,   163,   164,   165,   166,   167,   168,
-     169,   161,    84,    75,   206,   204,   205,    77,    76,    82,
-      80,    85,    81,    79,    83,    78,    73,     0,     0,   183,
-     192,   198,     3,    32,     0,    34,    35,     0,     0,     0,
-       0,    39,    40,    41,    42,     0,     0,    43,    19,    31,
-       0,     0,     0,     0,   101,   113,   109,   111,   107,   108,
-     110,   112,   102,    99,   145,   146,   147,   148,   144,   143,
-     141,   142,   139,   120,   121,   122,   123,   124,   125,   126,
-     127,   128,   129,   130,   131,   132,   119,   118,   190,   194,
-     193,   191,    33,    36,    38,    37,    45,    44,    46,    30,
-       0,     0,     0,     0,     0,   216,     0,   212,   117,   189,
-     213,   214,     0,   211,   209,   215,     0,   219,     0,     0,
-       0,     0,     0,   221,     0,     0,   217,   220,   218,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   222,     0,   224,   225,   226,   227,   228,
-     229,   223
+       0,    29,     0,    26,     6,    57,    58,   178,   199,   182,
+     198,   180,   205,    52,    53,    61,   203,   183,   179,   187,
+      59,   120,     0,     0,   120,    26,     0,   184,    86,    90,
+      87,   176,     0,     0,     0,     0,     0,     0,     0,   162,
+     164,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,    72,    74,     0,   201,    60,   186,     1,     0,
+       4,    20,    47,     0,    66,    67,    68,    69,    70,    71,
+      64,   153,   137,   138,   139,   135,   189,   106,   105,     0,
+     103,   104,     0,    88,   100,    27,    28,     0,     0,     0,
+       0,     0,     0,     0,     0,   140,   142,   172,   197,   204,
+     202,   116,   120,   120,   115,     0,     0,    89,   165,   166,
+     167,   168,   169,   170,   171,   163,    84,    75,   208,   206,
+     207,    77,    76,    82,    80,    85,    81,    79,    83,    78,
+      73,     0,     0,   185,   194,   200,     3,    32,     0,    34,
+      35,     0,     0,     0,     0,    39,    40,    41,    42,     0,
+       0,    43,    19,    31,     0,     0,     0,     0,   101,   113,
+     109,   111,   107,   108,   110,   112,   102,    99,   147,   148,
+     149,   150,   146,   145,   143,   144,   141,   122,   123,   124,
+     125,   126,   127,   128,   129,   130,   131,   132,   133,   134,
+     121,   117,   118,   120,   192,   196,   195,   193,    33,    36,
+      38,    37,    45,    44,    46,    30,     0,     0,     0,     0,
+       0,   218,     0,   214,   119,   191,   215,   216,     0,   213,
+     211,   217,     0,   221,     0,     0,     0,     0,     0,   223,
+       0,     0,   219,   222,   220,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,   224,
+       0,   226,   227,   228,   229,   230,   231,   225
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
-      -1,    47,    48,    49,    50,    51,   122,   113,   258,   259,
-      52,    53,    54,    55,    80,    81,    82,    56,   160,   161,
-      57,   136,   108,   191,   192,   272,    58,   209,   296,    95,
-      96,    59,   203,   204,    60,    90,    91,    61,   147,   148,
-      62,    98,   135,   239,   240,   119,   120,   164,   127,   123,
-     227,    71,    63,    64,   262,   263,   314,   315,   329,   316,
-     332,   333,   346,   347
+      -1,    47,    48,    49,    50,    51,   122,   113,   262,   263,
+      52,    53,    54,    55,    80,    81,    82,    56,   162,   163,
+      57,   138,   108,   193,   194,   276,    58,   211,   300,    95,
+      96,    59,   205,   206,    60,    90,    91,    61,   149,   150,
+      62,    98,   137,   243,   244,   119,   120,   166,   127,   123,
+     231,    71,    63,    64,   266,   267,   320,   321,   335,   322,
+     338,   339,   352,   353
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -135
+#define YYPACT_NINF -133
 static const yytype_int16 yypact[] =
 {
-     126,  -134,   -26,   -22,  -135,   -73,    -1,   -19,    -7,   -33,
-       2,    16,   -79,     2,  -135,    22,     3,   -69,   -62,   -61,
-     -59,   -58,   -56,  -135,     3,     3,   -55,  -135,   -54,   -52,
-    -135,   -51,    25,   -15,  -135,   -47,    22,   -45,    -1,     1,
-     278,   -42,    28,    28,  -135,  -135,  -135,    54,   273,   -53,
-    -135,     3,  -135,     3,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,   -74,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,   -27,   -16,    -6,     7,    48,     9,
-    -135,   -33,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-       2,  -135,    64,    67,    75,    16,  -135,   108,  -135,     2,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,   -10,    14,
-      15,  -135,   213,  -135,   411,  -135,  -135,  -135,  -135,   -58,
-    -135,  -135,  -135,     3,     3,  -135,  -135,    18,  -135,  -135,
-    -135,  -135,  -135,    74,    -8,  -135,    22,  -135,  -135,  -135,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,     1,  -135,    93,
-      96,   -13,   107,    -1,    -1,   112,    -1,    -1,   113,   114,
-     278,  -135,   -46,  -135,   116,   116,  -135,    13,  -135,   487,
-    -135,  -108,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,    49,  -135,  -135,
-      12,   -10,  -135,  -135,  -135,   -13,   -13,   -13,   -13,    50,
-     127,    -1,    -1,   213,  -135,  -135,  -135,  -135,  -135,   433,
-     433,   -42,    55,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,   -42,   128,   -46,
-    -135,  -135,  -135,  -135,    -1,  -135,  -135,   132,   133,   135,
-     136,  -135,  -135,  -135,  -135,   139,   140,  -135,   487,  -135,
-      37,    38,   -95,    51,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,   173,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-      -1,    -1,    41,    53,  -112,  -135,    42,  -135,   433,  -135,
-    -135,  -135,     3,  -135,  -135,  -135,    52,  -135,    44,    57,
-      -1,    56,  -123,  -135,    59,    -1,  -135,  -135,  -135,    58,
-      17,    60,    61,    62,    65,    69,   -94,    63,    -1,    -1,
-      -1,    -1,    -1,  -135,    66,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135
+     118,  -118,    -8,    -7,  -133,   -46,    -6,    -3,     1,   -26,
+       8,    19,   -77,     8,  -133,   157,   -48,   -73,   -72,   -69,
+     -68,   -67,   -65,  -133,   -48,   -48,   -62,  -133,   -61,   -56,
+    -133,   -55,    29,   -15,  -133,   -44,   157,   -40,    -6,     3,
+     542,   -39,    34,    34,  -133,  -133,  -133,    89,   279,   -57,
+    -133,   -48,  -133,   -48,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,   -66,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,   -29,   -28,   -24,   -13,    53,     7,
+    -133,   -26,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,
+       8,  -133,    66,    84,    86,    19,  -133,   108,  -133,     8,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,   -23,    12,
+      20,  -133,    30,  -133,   417,  -133,  -133,  -133,  -133,   -67,
+    -133,  -133,  -133,   -48,   -48,  -133,  -133,    21,  -133,  -133,
+    -133,  -133,    15,    16,  -133,    82,    -2,  -133,   157,  -133,
+    -133,  -133,    -6,    -6,    -6,    -6,    -6,    -6,    -6,     3,
+    -133,   102,   112,   -21,   113,    -6,    -6,   114,    -6,    -6,
+     119,   120,   542,  -133,   -31,  -133,   122,   122,  -133,    10,
+    -133,   492,  -133,  -117,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,    42,
+    -133,  -133,    11,   -23,  -133,  -133,  -133,   -21,   -21,   -21,
+     -21,    47,   127,    -6,    -6,    30,  -133,  -133,  -133,  -133,
+    -133,   301,  -133,  -133,   301,   -39,    58,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,   -39,   129,   -31,  -133,  -133,  -133,  -133,    -6,  -133,
+    -133,   142,   143,   151,   152,  -133,  -133,  -133,  -133,   153,
+     154,  -133,   492,  -133,    46,    48,   -95,    60,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,  -133,
+    -133,   301,   301,  -133,   181,  -133,  -133,  -133,  -133,  -133,
+    -133,  -133,  -133,  -133,  -133,  -133,    -6,    -6,    52,    64,
+     -98,  -133,    54,  -133,   301,  -133,  -133,  -133,   -48,  -133,
+    -133,  -133,    63,  -133,    65,    70,    -6,    67,  -125,  -133,
+      69,    -6,  -133,  -133,  -133,    59,    41,    68,    71,    72,
+      75,    78,    33,    77,    -6,    -6,    -6,    -6,    -6,  -133,
+      81,  -133,  -133,  -133,  -133,  -133,  -133,  -133
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -135,  -135,  -135,   -44,  -135,  -135,   -14,   -32,  -135,   -50,
-    -135,  -135,  -135,  -135,  -135,  -135,   131,  -135,  -135,    71,
-    -135,  -135,   -23,  -135,    26,  -135,  -135,  -129,  -135,  -135,
-     118,  -135,  -135,    20,  -135,   203,   -64,  -135,  -135,    79,
-    -135,  -135,  -135,  -135,    -5,  -135,   117,   189,  -135,   208,
-    -106,   -38,  -135,  -135,  -135,   -24,  -135,   -75,  -135,  -135,
-    -135,   -97,  -135,  -103
+    -133,  -133,  -133,   -42,  -133,  -133,    -1,   -32,  -133,   -20,
+    -133,  -133,  -133,  -133,  -133,  -133,   158,  -133,  -133,    79,
+    -133,  -133,   -10,  -133,    50,  -133,  -133,  -132,  -133,  -133,
+     149,  -133,  -133,    40,  -133,   234,   -74,  -133,  -133,    99,
+    -133,  -133,  -133,  -133,     6,  -133,   134,   216,  -133,   235,
+    -123,   -38,  -133,  -133,  -133,    -5,  -133,   -58,  -133,  -133,
+    -133,   -75,  -133,   -88
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -1153,138 +1152,138 @@ static const yytype_int16 yypgoto[] =
 #define YYTABLE_NINF -7
 static const yytype_int16 yytable[] =
 {
-     139,   133,   112,   210,   167,   140,   312,    83,   237,   162,
-     131,    84,    74,   137,    65,   265,   185,    75,    85,   132,
-      68,   224,   186,   312,    92,   187,   179,    66,    69,   141,
-     331,    67,   109,   110,    72,   179,   266,   169,   336,   170,
-     225,   100,   260,   261,   142,   101,    73,   143,    97,   324,
-     109,   110,    70,   188,   166,   260,   261,    86,   114,   238,
-     341,   342,   343,   344,   345,   115,   116,   353,   117,   118,
-     205,   121,   125,   126,   189,   128,   129,    76,   130,    77,
-     134,   163,   138,    87,    78,   111,   171,    79,   102,   274,
-     275,   276,   277,    93,   267,   168,    88,    94,   268,   144,
-     172,   176,   214,   215,   216,   217,   218,   219,   220,   207,
-     207,   173,   111,   213,   269,   229,   230,   180,   232,   233,
-     181,   174,   103,   226,    89,   145,   146,     1,   182,   190,
-     111,   104,     2,     3,   175,   105,   177,   184,     4,     5,
-       6,   193,   194,     7,   211,   208,   222,     8,     9,   223,
-     106,   212,    10,    11,   107,   270,    12,   271,    13,    14,
-     228,   242,    15,   280,   281,   231,   234,   235,   318,   241,
-      16,   341,   342,   343,   344,   345,   264,   278,    17,   297,
-     279,   300,   298,    18,    19,   303,   304,    20,   305,   306,
-      21,    22,   307,   308,    23,    24,   310,   311,   319,   317,
-     322,   323,   326,   330,   328,   299,   302,   338,   309,    25,
-     331,   355,   178,   183,   361,   335,    99,   273,   340,   348,
-     349,   350,    26,   282,   351,    27,   221,    28,   352,    29,
-      30,   236,   165,   124,   301,   337,   206,    31,   313,   325,
-       0,    32,    33,   354,    34,    35,     0,    36,     0,    37,
-     195,   196,   197,   198,     0,    38,     0,     0,     0,    39,
-      40,    41,     0,    42,    43,     0,    44,    45,     0,     0,
-       0,     0,   320,   321,    -6,    46,     0,     0,     0,     2,
-       3,     0,     0,     0,     0,     4,     5,     6,   149,     0,
-       7,     0,   334,     0,     8,     9,   150,   339,   151,    10,
-      11,     0,     0,    12,     0,    13,    14,     0,   327,    15,
-     356,   357,   358,   359,   360,     0,     0,    16,     0,     0,
-     152,     0,     0,     0,     0,    17,     0,   199,     0,     0,
-      18,    19,     0,     0,    20,     0,     0,    21,    22,   200,
-       0,    23,    24,   201,   202,     0,     0,     0,     0,   153,
-     154,   155,     0,   156,   157,     0,    25,   158,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    26,
-       0,     0,    27,     0,    28,   159,    29,    30,     0,     0,
-       0,     0,     0,     0,    31,     0,     0,     0,    32,    33,
-       0,    34,    35,     0,    36,     0,    37,     0,     0,     0,
-       0,     0,    38,     0,     0,     0,    39,    40,    41,     0,
-      42,    43,     0,    44,    45,     0,     0,     2,     3,     0,
-       0,    -6,    46,     4,     5,     6,     0,     0,     7,     0,
-       0,     0,     8,     9,     0,     0,     0,    10,    11,     0,
-       0,    12,     0,    13,    14,     0,     0,    15,     0,     0,
-       0,     0,     0,     0,     0,    16,     0,     0,     0,     0,
-       0,     0,     0,    17,     0,     0,     0,     0,    18,    19,
-       0,     0,    20,     0,   283,    21,    22,     0,     0,    23,
-      24,     0,     0,     0,   284,     0,     0,     0,     0,     0,
-       0,     0,   285,   243,    25,   286,     0,     0,   244,     0,
-     287,     0,   245,     0,     0,     0,     0,    26,     0,     0,
-      27,     0,    28,     0,    29,    30,     0,     0,   288,     0,
-     289,   290,    31,   291,   292,   293,    32,    33,   294,    34,
-      35,     0,    36,     0,    37,     0,   246,     0,     0,     0,
-      38,     0,     0,   247,    39,    40,    41,     0,    42,    43,
-       0,    44,    45,     0,     0,     0,     0,     0,     0,     0,
-      46,   248,     0,     0,     0,   249,     0,   250,     0,     0,
-       0,     0,     0,     0,     0,   295,   251,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,   252,   253,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     141,   135,   214,   187,   109,   110,   169,   142,   188,   164,
+     131,   189,   228,    83,   269,   112,   181,    84,    74,   318,
+     241,    75,   318,    69,    85,   181,   139,    92,   337,   229,
+      65,   143,   134,   264,   265,   270,   342,   132,   133,   190,
+     212,   213,    66,    67,    70,   144,    68,    72,   145,    97,
+     171,    73,   172,   114,   115,   264,   265,   116,   117,   118,
+     191,   121,    86,   330,   125,   126,   197,   198,   199,   200,
+     128,   129,   207,   242,   278,   279,   280,   281,   111,   130,
+     301,   302,   136,    76,   165,    77,   140,   111,    87,   168,
+      78,   170,   271,    79,   173,    93,   272,   174,   175,    94,
+     146,    88,   176,   178,   218,   219,   220,   221,   222,   223,
+     224,   111,   273,   177,   230,   192,   182,   233,   234,     1,
+     236,   237,   209,   209,     2,     3,   147,   148,   217,    89,
+       4,     5,     6,   179,   183,     7,   184,   186,   195,     8,
+       9,   195,   196,   201,    10,    11,   196,   210,    12,    13,
+      14,   215,   226,    15,   274,   202,   275,   216,   246,   203,
+     204,    16,   227,   232,   235,   284,   285,    17,   268,   238,
+     239,   324,   245,   282,    18,    19,   100,   283,    20,   306,
+     101,    21,    22,   303,   304,    23,    24,   347,   348,   349,
+     350,   351,   309,   310,   359,   347,   348,   349,   350,   351,
+      25,   311,   312,   313,   314,   316,   325,   317,   323,   305,
+     308,   328,   329,    26,   332,   334,    27,   344,    28,   346,
+      29,    30,   102,   337,   336,   361,   341,   354,    31,   367,
+     355,   356,    32,    33,   357,    34,    35,   358,    36,   180,
+      37,   240,   315,   277,   185,   286,    38,    99,   225,   307,
+      39,    40,    41,   208,    42,    43,   103,    44,    45,   167,
+     124,   319,   331,   343,   360,   104,    -6,    46,     0,   105,
+       0,     0,     0,     0,     0,     0,     0,     0,   326,   327,
+       0,     0,     0,     0,   106,     2,     3,     0,   107,     0,
+       0,     4,     5,     6,     0,     0,     7,     0,   340,     0,
+       8,     9,     0,   345,     0,    10,    11,     0,     0,    12,
+      13,    14,     0,     0,    15,     0,   362,   363,   364,   365,
+     366,     0,    16,     0,     0,     0,     0,   333,    17,     0,
+       0,     0,     0,     0,     0,    18,    19,     0,     0,    20,
+       0,   287,    21,    22,     0,     0,    23,    24,     0,   288,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,   289,
+       0,    25,   290,     0,     0,     0,     0,   291,     0,     0,
+       0,     0,     0,     0,    26,     0,     0,    27,     0,    28,
+       0,    29,    30,     0,     0,   292,     0,   293,   294,    31,
+     295,   296,   297,    32,    33,   298,    34,    35,     0,    36,
+       0,    37,     0,     0,     0,     0,     0,    38,     0,     0,
+       0,    39,    40,    41,     0,    42,    43,     0,    44,    45,
+       0,     0,     0,     2,     3,     0,     0,    -6,    46,     4,
+       5,     6,     0,     0,     7,     0,     0,     0,     8,     9,
+       0,     0,   299,    10,    11,     0,     0,    12,    13,    14,
+       0,     0,    15,     0,     0,     0,     0,     0,     0,     0,
+      16,     0,     0,     0,     0,     0,    17,     0,     0,     0,
+       0,     0,     0,    18,    19,     0,     0,    20,     0,     0,
+      21,    22,     0,     0,    23,    24,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   247,    25,
+       0,     0,     0,   248,     0,     0,     0,   249,     0,     0,
+       0,     0,    26,     0,     0,    27,     0,    28,     0,    29,
+      30,     0,     0,     0,     0,     0,     0,    31,     0,     0,
+       0,    32,    33,     0,    34,    35,     0,    36,   250,    37,
+       0,     0,     0,     0,     0,    38,     0,   251,     0,    39,
+      40,    41,   151,    42,    43,     0,    44,    45,     0,     0,
+     152,     0,   153,     0,     0,   252,    46,     0,     0,   253,
+       0,   254,     0,     0,     0,     0,     0,     0,     0,     0,
+     255,     0,     0,   154,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   256,   257,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   254,     0,   255,     0,     0,     0,   256,
-       0,   257
+       0,     0,   155,   156,   157,     0,   158,   159,     0,     0,
+     160,     0,     0,     0,     0,     0,     0,   258,     0,   259,
+       0,     0,     0,   260,     0,     0,   261,     0,   161
 };
 
 static const yytype_int16 yycheck[] =
 {
-      38,    33,    16,   132,    48,     4,   118,     5,    54,    41,
-      25,     9,    45,    36,   148,     3,    26,    50,    16,    33,
-      93,    34,    32,   118,     8,    35,    90,    53,    29,    28,
-     153,    53,    47,    48,    53,    99,    24,    51,   161,    53,
-      53,    19,   150,   151,    43,    23,    53,    46,   127,   161,
-      47,    48,    53,    63,     0,   150,   151,    55,   127,   105,
-     154,   155,   156,   157,   158,   127,   127,   161,   127,   127,
-     114,   127,   127,   127,    84,   127,   127,   110,    53,   112,
-     127,    53,   127,    81,   117,   127,   160,   120,    66,   195,
-     196,   197,   198,    77,    82,   148,    94,    81,    86,    98,
-     127,    53,   140,   141,   142,   143,   144,   145,   146,   123,
-     124,   127,   127,   136,   102,   153,   154,    53,   156,   157,
-      53,   127,   100,   136,   122,   124,   125,     1,    53,   139,
-     127,   109,     6,     7,   127,   113,   127,    29,    12,    13,
-      14,   127,   127,    17,    70,   127,    53,    21,    22,    53,
-     128,   159,    26,    27,   132,   143,    30,   145,    32,    33,
-      53,   148,    36,   201,   202,    53,    53,    53,   297,    53,
-      44,   154,   155,   156,   157,   158,   127,   127,    52,   211,
-      53,    53,   127,    57,    58,    53,    53,    61,    53,    53,
-      64,    65,    53,    53,    68,    69,   159,   159,    25,   148,
-     159,   148,   160,   159,   152,   237,   244,   148,   258,    83,
-     153,   148,    81,    95,   148,   159,    13,   191,   160,   159,
-     159,   159,    96,   203,   159,    99,   147,   101,   159,   103,
-     104,   160,    43,    25,   239,   332,   119,   111,   262,   314,
-      -1,   115,   116,   346,   118,   119,    -1,   121,    -1,   123,
-      37,    38,    39,    40,    -1,   129,    -1,    -1,    -1,   133,
-     134,   135,    -1,   137,   138,    -1,   140,   141,    -1,    -1,
-      -1,    -1,   310,   311,   148,   149,    -1,    -1,    -1,     6,
-       7,    -1,    -1,    -1,    -1,    12,    13,    14,    10,    -1,
-      17,    -1,   330,    -1,    21,    22,    18,   335,    20,    26,
-      27,    -1,    -1,    30,    -1,    32,    33,    -1,   322,    36,
-     348,   349,   350,   351,   352,    -1,    -1,    44,    -1,    -1,
-      42,    -1,    -1,    -1,    -1,    52,    -1,   114,    -1,    -1,
-      57,    58,    -1,    -1,    61,    -1,    -1,    64,    65,   126,
-      -1,    68,    69,   130,   131,    -1,    -1,    -1,    -1,    71,
-      72,    73,    -1,    75,    76,    -1,    83,    79,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,
-      -1,    -1,    99,    -1,   101,    97,   103,   104,    -1,    -1,
-      -1,    -1,    -1,    -1,   111,    -1,    -1,    -1,   115,   116,
-      -1,   118,   119,    -1,   121,    -1,   123,    -1,    -1,    -1,
-      -1,    -1,   129,    -1,    -1,    -1,   133,   134,   135,    -1,
-     137,   138,    -1,   140,   141,    -1,    -1,     6,     7,    -1,
-      -1,   148,   149,    12,    13,    14,    -1,    -1,    17,    -1,
-      -1,    -1,    21,    22,    -1,    -1,    -1,    26,    27,    -1,
-      -1,    30,    -1,    32,    33,    -1,    -1,    36,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    44,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    52,    -1,    -1,    -1,    -1,    57,    58,
-      -1,    -1,    61,    -1,    41,    64,    65,    -1,    -1,    68,
-      69,    -1,    -1,    -1,    51,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    59,     6,    83,    62,    -1,    -1,    11,    -1,
-      67,    -1,    15,    -1,    -1,    -1,    -1,    96,    -1,    -1,
-      99,    -1,   101,    -1,   103,   104,    -1,    -1,    85,    -1,
-      87,    88,   111,    90,    91,    92,   115,   116,    95,   118,
-     119,    -1,   121,    -1,   123,    -1,    49,    -1,    -1,    -1,
-     129,    -1,    -1,    56,   133,   134,   135,    -1,   137,   138,
-      -1,   140,   141,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-     149,    74,    -1,    -1,    -1,    78,    -1,    80,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   142,    89,    -1,    -1,    -1,
+      38,    33,   134,    26,    52,    53,    48,     4,    31,    41,
+      25,    34,    33,     5,     3,    16,    90,     9,    44,   117,
+      51,    47,   117,    29,    16,    99,    36,     8,   153,    50,
+     148,    28,    33,   150,   151,    24,   161,    52,    53,    62,
+      25,    25,    50,    50,    50,    42,    92,    50,    45,   126,
+      51,    50,    53,   126,   126,   150,   151,   126,   126,   126,
+      83,   126,    54,   161,   126,   126,    36,    37,    38,    39,
+     126,   126,   114,   104,   197,   198,   199,   200,   126,    50,
+     212,   213,   126,   109,    50,   111,   126,   126,    80,     0,
+     116,   148,    81,   119,   160,    76,    85,   126,   126,    80,
+      97,    93,   126,    50,   142,   143,   144,   145,   146,   147,
+     148,   126,   101,   126,   135,   138,    50,   155,   156,     1,
+     158,   159,   123,   124,     6,     7,   123,   124,   138,   121,
+      12,    13,    14,   126,    50,    17,    50,    29,   126,    21,
+      22,   126,   126,   113,    26,    27,   126,   126,    30,    31,
+      32,    69,    50,    35,   143,   125,   145,   159,   148,   129,
+     130,    43,    50,    50,    50,   203,   204,    49,   126,    50,
+      50,   303,    50,   126,    56,    57,    19,    50,    60,    50,
+      23,    63,    64,   215,   126,    67,    68,   154,   155,   156,
+     157,   158,    50,    50,   161,   154,   155,   156,   157,   158,
+      82,    50,    50,    50,    50,   159,    25,   159,   148,   241,
+     248,   159,   148,    95,   160,   152,    98,   148,   100,   160,
+     102,   103,    65,   153,   159,   148,   159,   159,   110,   148,
+     159,   159,   114,   115,   159,   117,   118,   159,   120,    81,
+     122,   162,   262,   193,    95,   205,   128,    13,   149,   243,
+     132,   133,   134,   119,   136,   137,    99,   139,   140,    43,
+      25,   266,   320,   338,   352,   108,   148,   149,    -1,   112,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   316,   317,
+      -1,    -1,    -1,    -1,   127,     6,     7,    -1,   131,    -1,
+      -1,    12,    13,    14,    -1,    -1,    17,    -1,   336,    -1,
+      21,    22,    -1,   341,    -1,    26,    27,    -1,    -1,    30,
+      31,    32,    -1,    -1,    35,    -1,   354,   355,   356,   357,
+     358,    -1,    43,    -1,    -1,    -1,    -1,   328,    49,    -1,
+      -1,    -1,    -1,    -1,    -1,    56,    57,    -1,    -1,    60,
+      -1,    40,    63,    64,    -1,    -1,    67,    68,    -1,    48,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    58,
+      -1,    82,    61,    -1,    -1,    -1,    -1,    66,    -1,    -1,
+      -1,    -1,    -1,    -1,    95,    -1,    -1,    98,    -1,   100,
+      -1,   102,   103,    -1,    -1,    84,    -1,    86,    87,   110,
+      89,    90,    91,   114,   115,    94,   117,   118,    -1,   120,
+      -1,   122,    -1,    -1,    -1,    -1,    -1,   128,    -1,    -1,
+      -1,   132,   133,   134,    -1,   136,   137,    -1,   139,   140,
+      -1,    -1,    -1,     6,     7,    -1,    -1,   148,   149,    12,
+      13,    14,    -1,    -1,    17,    -1,    -1,    -1,    21,    22,
+      -1,    -1,   141,    26,    27,    -1,    -1,    30,    31,    32,
+      -1,    -1,    35,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      43,    -1,    -1,    -1,    -1,    -1,    49,    -1,    -1,    -1,
+      -1,    -1,    -1,    56,    57,    -1,    -1,    60,    -1,    -1,
+      63,    64,    -1,    -1,    67,    68,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     6,    82,
+      -1,    -1,    -1,    11,    -1,    -1,    -1,    15,    -1,    -1,
+      -1,    -1,    95,    -1,    -1,    98,    -1,   100,    -1,   102,
+     103,    -1,    -1,    -1,    -1,    -1,    -1,   110,    -1,    -1,
+      -1,   114,   115,    -1,   117,   118,    -1,   120,    46,   122,
+      -1,    -1,    -1,    -1,    -1,   128,    -1,    55,    -1,   132,
+     133,   134,    10,   136,   137,    -1,   139,   140,    -1,    -1,
+      18,    -1,    20,    -1,    -1,    73,   149,    -1,    -1,    77,
+      -1,    79,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      88,    -1,    -1,    41,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   106,   107,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   107,   108,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,   136,    -1,   138,    -1,    -1,    -1,   142,
-      -1,   144
+      -1,    -1,    70,    71,    72,    -1,    74,    75,    -1,    -1,
+      78,    -1,    -1,    -1,    -1,    -1,    -1,   135,    -1,   137,
+      -1,    -1,    -1,   141,    -1,    -1,   144,    -1,    96
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1292,42 +1291,42 @@ static const yytype_int16 yycheck[] =
 static const yytype_uint8 yystos[] =
 {
        0,     1,     6,     7,    12,    13,    14,    17,    21,    22,
-      26,    27,    30,    32,    33,    36,    44,    52,    57,    58,
-      61,    64,    65,    68,    69,    83,    96,    99,   101,   103,
-     104,   111,   115,   116,   118,   119,   121,   123,   129,   133,
-     134,   135,   137,   138,   140,   141,   149,   163,   164,   165,
+      26,    27,    30,    31,    32,    35,    43,    49,    56,    57,
+      60,    63,    64,    67,    68,    82,    95,    98,   100,   102,
+     103,   110,   114,   115,   117,   118,   120,   122,   128,   132,
+     133,   134,   136,   137,   139,   140,   149,   163,   164,   165,
      166,   167,   172,   173,   174,   175,   179,   182,   188,   193,
-     196,   199,   202,   214,   215,   148,    53,    53,    93,    29,
-      53,   213,    53,    53,    45,    50,   110,   112,   117,   120,
-     176,   177,   178,     5,     9,    16,    55,    81,    94,   122,
-     197,   198,     8,    77,    81,   191,   192,   127,   203,   197,
-      19,    23,    66,   100,   109,   113,   128,   132,   184,    47,
-      48,   127,   168,   169,   127,   127,   127,   127,   127,   207,
-     208,   127,   168,   211,   211,   127,   127,   210,   127,   127,
-      53,    25,   168,   169,   127,   204,   183,   184,   127,   213,
-       4,    28,    43,    46,    98,   124,   125,   200,   201,    10,
-      18,    20,    42,    71,    72,    73,    75,    76,    79,    97,
-     180,   181,   169,    53,   209,   209,     0,   165,   148,   168,
-     168,   160,   127,   127,   127,   127,    53,   127,   178,   198,
-      53,    53,    53,   192,    29,    26,    32,    35,    63,    84,
-     139,   185,   186,   127,   127,    37,    38,    39,    40,   114,
-     126,   130,   131,   194,   195,   165,   208,   168,   127,   189,
-     189,    70,   159,   184,   213,   213,   213,   213,   213,   213,
-     213,   201,    53,    53,    34,    53,   136,   212,    53,   213,
-     213,    53,   213,   213,    53,    53,   181,    54,   105,   205,
-     206,    53,   148,     6,    11,    15,    49,    56,    74,    78,
-      80,    89,   107,   108,   136,   138,   142,   144,   170,   171,
-     150,   151,   216,   217,   127,     3,    24,    82,    86,   102,
-     143,   145,   187,   186,   212,   212,   212,   212,   127,    53,
-     213,   213,   195,    41,    51,    59,    62,    67,    85,    87,
-      88,    90,    91,    92,    95,   142,   190,   169,   127,   169,
-      53,   206,   213,    53,    53,    53,    53,    53,    53,   171,
-     159,   159,   118,   217,   218,   219,   221,   148,   189,    25,
-     213,   213,   159,   148,   161,   219,   160,   168,   152,   220,
-     159,   153,   222,   223,   213,   159,   161,   223,   148,   213,
-     160,   154,   155,   156,   157,   158,   224,   225,   159,   159,
-     159,   159,   159,   161,   225,   148,   213,   213,   213,   213,
-     213,   148
+     196,   199,   202,   214,   215,   148,    50,    50,    92,    29,
+      50,   213,    50,    50,    44,    47,   109,   111,   116,   119,
+     176,   177,   178,     5,     9,    16,    54,    80,    93,   121,
+     197,   198,     8,    76,    80,   191,   192,   126,   203,   197,
+      19,    23,    65,    99,   108,   112,   127,   131,   184,    52,
+      53,   126,   168,   169,   126,   126,   126,   126,   126,   207,
+     208,   126,   168,   211,   211,   126,   126,   210,   126,   126,
+      50,    25,    52,    53,   168,   169,   126,   204,   183,   184,
+     126,   213,     4,    28,    42,    45,    97,   123,   124,   200,
+     201,    10,    18,    20,    41,    70,    71,    72,    74,    75,
+      78,    96,   180,   181,   169,    50,   209,   209,     0,   165,
+     148,   168,   168,   160,   126,   126,   126,   126,    50,   126,
+     178,   198,    50,    50,    50,   192,    29,    26,    31,    34,
+      62,    83,   138,   185,   186,   126,   126,    36,    37,    38,
+      39,   113,   125,   129,   130,   194,   195,   165,   208,   168,
+     126,   189,    25,    25,   189,    69,   159,   184,   213,   213,
+     213,   213,   213,   213,   213,   201,    50,    50,    33,    50,
+     135,   212,    50,   213,   213,    50,   213,   213,    50,    50,
+     181,    51,   104,   205,   206,    50,   148,     6,    11,    15,
+      46,    55,    73,    77,    79,    88,   106,   107,   135,   137,
+     141,   144,   170,   171,   150,   151,   216,   217,   126,     3,
+      24,    81,    85,   101,   143,   145,   187,   186,   212,   212,
+     212,   212,   126,    50,   213,   213,   195,    40,    48,    58,
+      61,    66,    84,    86,    87,    89,    90,    91,    94,   141,
+     190,   189,   189,   169,   126,   169,    50,   206,   213,    50,
+      50,    50,    50,    50,    50,   171,   159,   159,   117,   217,
+     218,   219,   221,   148,   189,    25,   213,   213,   159,   148,
+     161,   219,   160,   168,   152,   220,   159,   153,   222,   223,
+     213,   159,   161,   223,   148,   213,   160,   154,   155,   156,
+     157,   158,   224,   225,   159,   159,   159,   159,   159,   161,
+     225,   148,   213,   213,   213,   213,   213,   148
 };
 
 #define yyerrok                (yyerrstatus = 0)
@@ -2141,25 +2140,31 @@ yyreduce:
         case 5:
 
 /* Line 1455 of yacc.c  */
-#line 294 "ntp_parser.y"
+#line 287 "ntp_parser.y"
     {
                        /* I will need to incorporate much more fine grained
                         * error messages. The following should suffice for
-                        * the time being.
+                        * the time being.  ip_file->col_no is always 1 here,
+                        * and ip_file->line_no is one higher than the
+                        * problem line.  In other words, the scanner has
+                        * moved on to the start of the next line.
                         */
                        if (input_from_file == 1) {
-                               msyslog(LOG_ERR, "parse error %s line %d ignored\n",
-                                       ip_file->fname, ip_file->line_no);
+                               msyslog(LOG_ERR, 
+                                       "syntax error in %s line %d, "
+                                       "ignored",
+                                       ip_file->fname,
+                                       ip_file->line_no - 1);
                        } else if (input_from_file != 0)
                                msyslog(LOG_ERR,
-                                       "parse: bad boolean input flag\n");
+                                       "parse: bad boolean input flag");
        }
     break;
 
   case 19:
 
 /* Line 1455 of yacc.c  */
-#line 329 "ntp_parser.y"
+#line 328 "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)
@@ -2170,7 +2175,7 @@ yyreduce:
   case 20:
 
 /* Line 1455 of yacc.c  */
-#line 335 "ntp_parser.y"
+#line 334 "ntp_parser.y"
     {
                        struct peer_node *my_node = create_peer_node((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Address_node), NULL);
                        if (my_node)
@@ -2181,189 +2186,189 @@ yyreduce:
   case 21:
 
 /* Line 1455 of yacc.c  */
-#line 343 "ntp_parser.y"
+#line 342 "ntp_parser.y"
     { (yyval.Integer) = T_Server; }
     break;
 
   case 22:
 
 /* Line 1455 of yacc.c  */
-#line 344 "ntp_parser.y"
+#line 343 "ntp_parser.y"
     { (yyval.Integer) = T_Pool; }
     break;
 
   case 23:
 
 /* Line 1455 of yacc.c  */
-#line 345 "ntp_parser.y"
+#line 344 "ntp_parser.y"
     { (yyval.Integer) = T_Peer; }
     break;
 
   case 24:
 
 /* Line 1455 of yacc.c  */
-#line 346 "ntp_parser.y"
+#line 345 "ntp_parser.y"
     { (yyval.Integer) = T_Broadcast; }
     break;
 
   case 25:
 
 /* Line 1455 of yacc.c  */
-#line 347 "ntp_parser.y"
+#line 346 "ntp_parser.y"
     { (yyval.Integer) = T_Manycastclient; }
     break;
 
   case 26:
 
 /* Line 1455 of yacc.c  */
-#line 351 "ntp_parser.y"
+#line 350 "ntp_parser.y"
     { (yyval.Address_node) = (yyvsp[(1) - (1)].Address_node); }
     break;
 
   case 27:
 
 /* Line 1455 of yacc.c  */
-#line 352 "ntp_parser.y"
+#line 351 "ntp_parser.y"
     { (yyval.Address_node) = create_address_node((yyvsp[(2) - (2)].String), AF_INET); }
     break;
 
   case 28:
 
 /* Line 1455 of yacc.c  */
-#line 353 "ntp_parser.y"
+#line 352 "ntp_parser.y"
     { (yyval.Address_node) = create_address_node((yyvsp[(2) - (2)].String), AF_INET6); }
     break;
 
   case 29:
 
 /* Line 1455 of yacc.c  */
-#line 357 "ntp_parser.y"
+#line 356 "ntp_parser.y"
     { (yyval.Address_node) = create_address_node((yyvsp[(1) - (1)].String), 0); }
     break;
 
   case 30:
 
 /* Line 1455 of yacc.c  */
-#line 361 "ntp_parser.y"
+#line 360 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 31:
 
 /* Line 1455 of yacc.c  */
-#line 362 "ntp_parser.y"
+#line 361 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 32:
 
 /* Line 1455 of yacc.c  */
-#line 367 "ntp_parser.y"
+#line 365 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_SKEY); }
     break;
 
   case 33:
 
 /* Line 1455 of yacc.c  */
-#line 368 "ntp_parser.y"
+#line 366 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Bias, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 34:
 
 /* Line 1455 of yacc.c  */
-#line 369 "ntp_parser.y"
+#line 367 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_BURST); }
     break;
 
   case 35:
 
 /* Line 1455 of yacc.c  */
-#line 370 "ntp_parser.y"
+#line 368 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_IBURST); }
     break;
 
   case 36:
 
 /* Line 1455 of yacc.c  */
-#line 371 "ntp_parser.y"
+#line 369 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Key, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 37:
 
 /* Line 1455 of yacc.c  */
-#line 372 "ntp_parser.y"
+#line 370 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Minpoll, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 38:
 
 /* Line 1455 of yacc.c  */
-#line 373 "ntp_parser.y"
+#line 371 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Maxpoll, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 39:
 
 /* Line 1455 of yacc.c  */
-#line 374 "ntp_parser.y"
+#line 372 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_NOSELECT); }
     break;
 
   case 40:
 
 /* Line 1455 of yacc.c  */
-#line 375 "ntp_parser.y"
+#line 373 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_PREEMPT); }
     break;
 
   case 41:
 
 /* Line 1455 of yacc.c  */
-#line 376 "ntp_parser.y"
+#line 374 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_PREFER); }
     break;
 
   case 42:
 
 /* Line 1455 of yacc.c  */
-#line 377 "ntp_parser.y"
+#line 375 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_TRUE); }
     break;
 
   case 43:
 
 /* Line 1455 of yacc.c  */
-#line 378 "ntp_parser.y"
+#line 376 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, FLAG_XLEAVE); }
     break;
 
   case 44:
 
 /* Line 1455 of yacc.c  */
-#line 379 "ntp_parser.y"
+#line 377 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Ttl, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 45:
 
 /* Line 1455 of yacc.c  */
-#line 380 "ntp_parser.y"
+#line 378 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Mode, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 46:
 
 /* Line 1455 of yacc.c  */
-#line 381 "ntp_parser.y"
+#line 379 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Version, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 47:
 
 /* Line 1455 of yacc.c  */
-#line 391 "ntp_parser.y"
+#line 389 "ntp_parser.y"
     {
                        struct unpeer_node *my_node = create_unpeer_node((yyvsp[(2) - (2)].Address_node));
                        if (my_node)
@@ -2374,63 +2379,63 @@ yyreduce:
   case 48:
 
 /* Line 1455 of yacc.c  */
-#line 398 "ntp_parser.y"
+#line 396 "ntp_parser.y"
     { (yyval.Integer) = T_Unconfig; }
     break;
 
   case 49:
 
 /* Line 1455 of yacc.c  */
-#line 399 "ntp_parser.y"
+#line 397 "ntp_parser.y"
     { (yyval.Integer) = T_Unpeer; }
     break;
 
   case 50:
 
 /* Line 1455 of yacc.c  */
-#line 410 "ntp_parser.y"
+#line 408 "ntp_parser.y"
     { my_config.broadcastclient = SIMPLE; }
     break;
 
   case 51:
 
 /* Line 1455 of yacc.c  */
-#line 412 "ntp_parser.y"
+#line 410 "ntp_parser.y"
     { my_config.broadcastclient = NOVOLLEY; }
     break;
 
   case 52:
 
 /* Line 1455 of yacc.c  */
-#line 414 "ntp_parser.y"
+#line 412 "ntp_parser.y"
     { append_queue(my_config.manycastserver, (yyvsp[(2) - (2)].Queue)); }
     break;
 
   case 53:
 
 /* Line 1455 of yacc.c  */
-#line 416 "ntp_parser.y"
+#line 414 "ntp_parser.y"
     { append_queue(my_config.multicastclient, (yyvsp[(2) - (2)].Queue)); }
     break;
 
   case 54:
 
 /* Line 1455 of yacc.c  */
-#line 427 "ntp_parser.y"
+#line 425 "ntp_parser.y"
     { my_config.auth.autokey = (yyvsp[(2) - (2)].Integer); }
     break;
 
   case 55:
 
 /* Line 1455 of yacc.c  */
-#line 429 "ntp_parser.y"
+#line 427 "ntp_parser.y"
     { my_config.auth.control_key = (yyvsp[(2) - (2)].Integer); }
     break;
 
   case 56:
 
 /* Line 1455 of yacc.c  */
-#line 431 "ntp_parser.y"
+#line 429 "ntp_parser.y"
     { 
                        if (my_config.auth.crypto_cmd_list != NULL)
                                append_queue(my_config.auth.crypto_cmd_list, (yyvsp[(2) - (2)].Queue));
@@ -2443,217 +2448,217 @@ yyreduce:
   case 57:
 
 /* Line 1455 of yacc.c  */
-#line 439 "ntp_parser.y"
+#line 437 "ntp_parser.y"
     { my_config.auth.keys = (yyvsp[(2) - (2)].String); }
     break;
 
   case 58:
 
 /* Line 1455 of yacc.c  */
-#line 441 "ntp_parser.y"
+#line 439 "ntp_parser.y"
     { my_config.auth.keysdir = (yyvsp[(2) - (2)].String); }
     break;
 
   case 59:
 
 /* Line 1455 of yacc.c  */
-#line 443 "ntp_parser.y"
+#line 441 "ntp_parser.y"
     { my_config.auth.request_key = (yyvsp[(2) - (2)].Integer); }
     break;
 
   case 60:
 
 /* Line 1455 of yacc.c  */
-#line 445 "ntp_parser.y"
+#line 443 "ntp_parser.y"
     { my_config.auth.trusted_key_list = (yyvsp[(2) - (2)].Queue); }
     break;
 
   case 61:
 
 /* Line 1455 of yacc.c  */
-#line 447 "ntp_parser.y"
+#line 445 "ntp_parser.y"
     { my_config.auth.ntp_signd_socket = (yyvsp[(2) - (2)].String); }
     break;
 
   case 63:
 
 /* Line 1455 of yacc.c  */
-#line 453 "ntp_parser.y"
+#line 451 "ntp_parser.y"
     { (yyval.Queue) = NULL; }
     break;
 
   case 64:
 
 /* Line 1455 of yacc.c  */
-#line 457 "ntp_parser.y"
+#line 455 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 65:
 
 /* Line 1455 of yacc.c  */
-#line 458 "ntp_parser.y"
+#line 456 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 66:
 
 /* Line 1455 of yacc.c  */
-#line 463 "ntp_parser.y"
+#line 461 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_PRIV, (yyvsp[(2) - (2)].String)); }
     break;
 
   case 67:
 
 /* Line 1455 of yacc.c  */
-#line 465 "ntp_parser.y"
+#line 463 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_IDENT, (yyvsp[(2) - (2)].String)); }
     break;
 
   case 68:
 
 /* Line 1455 of yacc.c  */
-#line 467 "ntp_parser.y"
+#line 465 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_PW, (yyvsp[(2) - (2)].String)); }
     break;
 
   case 69:
 
 /* Line 1455 of yacc.c  */
-#line 469 "ntp_parser.y"
+#line 467 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_RAND, (yyvsp[(2) - (2)].String)); }
     break;
 
   case 70:
 
 /* Line 1455 of yacc.c  */
-#line 471 "ntp_parser.y"
+#line 469 "ntp_parser.y"
     { my_config.auth.revoke = (yyvsp[(2) - (2)].Integer); }
     break;
 
   case 71:
 
 /* Line 1455 of yacc.c  */
-#line 473 "ntp_parser.y"
+#line 471 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_sval(CRYPTO_CONF_SIGN, (yyvsp[(2) - (2)].String)); }
     break;
 
   case 72:
 
 /* Line 1455 of yacc.c  */
-#line 483 "ntp_parser.y"
+#line 481 "ntp_parser.y"
     { append_queue(my_config.orphan_cmds,(yyvsp[(2) - (2)].Queue)); }
     break;
 
   case 73:
 
 /* Line 1455 of yacc.c  */
-#line 487 "ntp_parser.y"
+#line 485 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 74:
 
 /* Line 1455 of yacc.c  */
-#line 488 "ntp_parser.y"
+#line 486 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 75:
 
 /* Line 1455 of yacc.c  */
-#line 493 "ntp_parser.y"
+#line 491 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_CEILING, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 76:
 
 /* Line 1455 of yacc.c  */
-#line 495 "ntp_parser.y"
+#line 493 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_FLOOR, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 77:
 
 /* Line 1455 of yacc.c  */
-#line 497 "ntp_parser.y"
+#line 495 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_COHORT, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 78:
 
 /* Line 1455 of yacc.c  */
-#line 499 "ntp_parser.y"
+#line 497 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_ORPHAN, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 79:
 
 /* Line 1455 of yacc.c  */
-#line 501 "ntp_parser.y"
+#line 499 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_MINDISP, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 80:
 
 /* Line 1455 of yacc.c  */
-#line 503 "ntp_parser.y"
+#line 501 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_MAXDIST, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 81:
 
 /* Line 1455 of yacc.c  */
-#line 505 "ntp_parser.y"
+#line 503 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_MINCLOCK, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 82:
 
 /* Line 1455 of yacc.c  */
-#line 507 "ntp_parser.y"
+#line 505 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_MAXCLOCK, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 83:
 
 /* Line 1455 of yacc.c  */
-#line 509 "ntp_parser.y"
+#line 507 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_MINSANE, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 84:
 
 /* Line 1455 of yacc.c  */
-#line 511 "ntp_parser.y"
+#line 509 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_BEACON, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 85:
 
 /* Line 1455 of yacc.c  */
-#line 513 "ntp_parser.y"
+#line 511 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(PROTO_MAXHOP, (double)(yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 86:
 
 /* Line 1455 of yacc.c  */
-#line 523 "ntp_parser.y"
+#line 521 "ntp_parser.y"
     { append_queue(my_config.stats_list, (yyvsp[(2) - (2)].Queue)); }
     break;
 
   case 87:
 
 /* Line 1455 of yacc.c  */
-#line 525 "ntp_parser.y"
+#line 523 "ntp_parser.y"
     { my_config.stats_dir = (yyvsp[(2) - (2)].String); }
     break;
 
   case 88:
 
 /* Line 1455 of yacc.c  */
-#line 527 "ntp_parser.y"
+#line 525 "ntp_parser.y"
     {
                        enqueue(my_config.filegen_opts,
                                create_filegen_node((yyvsp[(2) - (3)].VoidPtr), (yyvsp[(3) - (3)].Queue)));
@@ -2663,182 +2668,182 @@ yyreduce:
   case 89:
 
 /* Line 1455 of yacc.c  */
-#line 534 "ntp_parser.y"
+#line 532 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].VoidPtr)); }
     break;
 
   case 90:
 
 /* Line 1455 of yacc.c  */
-#line 535 "ntp_parser.y"
+#line 533 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].VoidPtr)); }
     break;
 
   case 91:
 
 /* Line 1455 of yacc.c  */
-#line 540 "ntp_parser.y"
+#line 538 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("clockstats"); }
     break;
 
   case 92:
 
 /* Line 1455 of yacc.c  */
-#line 542 "ntp_parser.y"
+#line 540 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("cryptostats"); }
     break;
 
   case 93:
 
 /* Line 1455 of yacc.c  */
-#line 544 "ntp_parser.y"
+#line 542 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("loopstats"); }
     break;
 
   case 94:
 
 /* Line 1455 of yacc.c  */
-#line 546 "ntp_parser.y"
+#line 544 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("peerstats"); }
     break;
 
   case 95:
 
 /* Line 1455 of yacc.c  */
-#line 548 "ntp_parser.y"
+#line 546 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("rawstats"); }
     break;
 
   case 96:
 
 /* Line 1455 of yacc.c  */
-#line 550 "ntp_parser.y"
+#line 548 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("sysstats"); }
     break;
 
   case 97:
 
 /* Line 1455 of yacc.c  */
-#line 552 "ntp_parser.y"
+#line 550 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("timingstats"); }
     break;
 
   case 98:
 
 /* Line 1455 of yacc.c  */
-#line 554 "ntp_parser.y"
+#line 552 "ntp_parser.y"
     { (yyval.VoidPtr) = create_pval("protostats"); }
     break;
 
   case 99:
 
 /* Line 1455 of yacc.c  */
-#line 558 "ntp_parser.y"
+#line 556 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 100:
 
 /* Line 1455 of yacc.c  */
-#line 559 "ntp_parser.y"
+#line 557 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 101:
 
 /* Line 1455 of yacc.c  */
-#line 564 "ntp_parser.y"
+#line 562 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_sval(T_File, (yyvsp[(2) - (2)].String)); }
     break;
 
   case 102:
 
 /* Line 1455 of yacc.c  */
-#line 566 "ntp_parser.y"
+#line 564 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Type, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 103:
 
 /* Line 1455 of yacc.c  */
-#line 567 "ntp_parser.y"
+#line 565 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, T_Link); }
     break;
 
   case 104:
 
 /* Line 1455 of yacc.c  */
-#line 568 "ntp_parser.y"
+#line 566 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, T_Nolink); }
     break;
 
   case 105:
 
 /* Line 1455 of yacc.c  */
-#line 569 "ntp_parser.y"
+#line 567 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, T_Enable); }
     break;
 
   case 106:
 
 /* Line 1455 of yacc.c  */
-#line 570 "ntp_parser.y"
+#line 568 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Flag, T_Disable); }
     break;
 
   case 107:
 
 /* Line 1455 of yacc.c  */
-#line 574 "ntp_parser.y"
+#line 572 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_NONE; }
     break;
 
   case 108:
 
 /* Line 1455 of yacc.c  */
-#line 575 "ntp_parser.y"
+#line 573 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_PID; }
     break;
 
   case 109:
 
 /* Line 1455 of yacc.c  */
-#line 576 "ntp_parser.y"
+#line 574 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_DAY; }
     break;
 
   case 110:
 
 /* Line 1455 of yacc.c  */
-#line 577 "ntp_parser.y"
+#line 575 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_WEEK; }
     break;
 
   case 111:
 
 /* Line 1455 of yacc.c  */
-#line 578 "ntp_parser.y"
+#line 576 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_MONTH; }
     break;
 
   case 112:
 
 /* Line 1455 of yacc.c  */
-#line 579 "ntp_parser.y"
+#line 577 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_YEAR; }
     break;
 
   case 113:
 
 /* Line 1455 of yacc.c  */
-#line 580 "ntp_parser.y"
+#line 578 "ntp_parser.y"
     { (yyval.Integer) = FILEGEN_AGE; }
     break;
 
   case 114:
 
 /* Line 1455 of yacc.c  */
-#line 590 "ntp_parser.y"
+#line 588 "ntp_parser.y"
     {   
                        append_queue(my_config.discard_opts, (yyvsp[(2) - (2)].Queue));
                }
@@ -2847,7 +2852,7 @@ yyreduce:
   case 115:
 
 /* Line 1455 of yacc.c  */
-#line 594 "ntp_parser.y"
+#line 592 "ntp_parser.y"
     {
                        enqueue(my_config.restrict_opts,
                                create_restrict_node((yyvsp[(2) - (3)].Address_node), NULL, (yyvsp[(3) - (3)].Queue), ip_file->line_no));
@@ -2857,7 +2862,7 @@ yyreduce:
   case 116:
 
 /* Line 1455 of yacc.c  */
-#line 599 "ntp_parser.y"
+#line 597 "ntp_parser.y"
     {
                        enqueue(my_config.restrict_opts,
                                create_restrict_node(NULL, NULL, (yyvsp[(3) - (3)].Queue), ip_file->line_no));
@@ -2867,381 +2872,417 @@ yyreduce:
   case 117:
 
 /* Line 1455 of yacc.c  */
-#line 604 "ntp_parser.y"
+#line 602 "ntp_parser.y"
     {
                        enqueue(my_config.restrict_opts,
-                               create_restrict_node((yyvsp[(2) - (5)].Address_node), (yyvsp[(4) - (5)].Address_node), (yyvsp[(5) - (5)].Queue), ip_file->line_no));
+                               create_restrict_node(
+                                       create_address_node(
+                                               estrdup("0.0.0.0"), 
+                                               AF_INET),
+                                       create_address_node(
+                                               estrdup("255.255.255.255"), 
+                                               AF_INET),
+                                       (yyvsp[(4) - (4)].Queue), 
+                                       ip_file->line_no));
                }
     break;
 
   case 118:
 
 /* Line 1455 of yacc.c  */
-#line 611 "ntp_parser.y"
-    { (yyval.Queue) = create_queue(); }
+#line 615 "ntp_parser.y"
+    {
+                       enqueue(my_config.restrict_opts,
+                               create_restrict_node(
+                                       create_address_node(
+                                               estrdup("::"), 
+                                               AF_INET6),
+                                       create_address_node(
+                                               estrdup("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),
+                                               AF_INET6),
+                                       (yyvsp[(4) - (4)].Queue), 
+                                       ip_file->line_no));
+               }
     break;
 
   case 119:
 
 /* Line 1455 of yacc.c  */
-#line 612 "ntp_parser.y"
-    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].VoidPtr)); }
+#line 628 "ntp_parser.y"
+    {
+                       enqueue(my_config.restrict_opts,
+                               create_restrict_node((yyvsp[(2) - (5)].Address_node), (yyvsp[(4) - (5)].Address_node), (yyvsp[(5) - (5)].Queue), ip_file->line_no));
+               }
     break;
 
   case 120:
 
 /* Line 1455 of yacc.c  */
-#line 616 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_TIMEOUT); }
+#line 635 "ntp_parser.y"
+    { (yyval.Queue) = create_queue(); }
     break;
 
   case 121:
 
 /* Line 1455 of yacc.c  */
-#line 617 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_IGNORE); }
+#line 636 "ntp_parser.y"
+    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].VoidPtr)); }
     break;
 
   case 122:
 
 /* Line 1455 of yacc.c  */
-#line 618 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_KOD); }
+#line 640 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_TIMEOUT); }
     break;
 
   case 123:
 
 /* Line 1455 of yacc.c  */
-#line 619 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_LIMITED); }
+#line 641 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_IGNORE); }
     break;
 
   case 124:
 
 /* Line 1455 of yacc.c  */
-#line 620 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_LPTRAP); }
+#line 642 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_KOD); }
     break;
 
   case 125:
 
 /* Line 1455 of yacc.c  */
-#line 621 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_NOMODIFY); }
+#line 643 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_LIMITED); }
     break;
 
   case 126:
 
 /* Line 1455 of yacc.c  */
-#line 622 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_NOPEER); }
+#line 644 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_LPTRAP); }
     break;
 
   case 127:
 
 /* Line 1455 of yacc.c  */
-#line 623 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_NOQUERY); }
+#line 645 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_NOMODIFY); }
     break;
 
   case 128:
 
 /* Line 1455 of yacc.c  */
-#line 624 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_DONTSERVE); }
+#line 646 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_NOPEER); }
     break;
 
   case 129:
 
 /* Line 1455 of yacc.c  */
-#line 625 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_NOTRAP); }
+#line 647 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_NOQUERY); }
     break;
 
   case 130:
 
 /* Line 1455 of yacc.c  */
-#line 626 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_DONTTRUST); }
+#line 648 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_DONTSERVE); }
     break;
 
   case 131:
 
 /* Line 1455 of yacc.c  */
-#line 627 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RESM_NTPONLY); }
+#line 649 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_NOTRAP); }
     break;
 
   case 132:
 
 /* Line 1455 of yacc.c  */
-#line 628 "ntp_parser.y"
-    { (yyval.VoidPtr) = create_ival(RES_VERSION); }
+#line 650 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_DONTTRUST); }
     break;
 
   case 133:
 
 /* Line 1455 of yacc.c  */
-#line 632 "ntp_parser.y"
-    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
+#line 651 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RESM_NTPONLY); }
     break;
 
   case 134:
 
 /* Line 1455 of yacc.c  */
-#line 633 "ntp_parser.y"
-    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
+#line 652 "ntp_parser.y"
+    { (yyval.VoidPtr) = create_ival(RES_VERSION); }
     break;
 
   case 135:
 
 /* Line 1455 of yacc.c  */
-#line 637 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Average, (yyvsp[(2) - (2)].Integer)); }
+#line 656 "ntp_parser.y"
+    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 136:
 
 /* Line 1455 of yacc.c  */
-#line 638 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Minimum, (yyvsp[(2) - (2)].Integer)); }
+#line 657 "ntp_parser.y"
+    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 137:
 
 /* Line 1455 of yacc.c  */
-#line 639 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Monitor, (yyvsp[(2) - (2)].Integer)); }
+#line 661 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Average, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 138:
 
 /* Line 1455 of yacc.c  */
-#line 648 "ntp_parser.y"
-    { enqueue(my_config.fudge, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
+#line 662 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Minimum, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 139:
 
 /* Line 1455 of yacc.c  */
-#line 652 "ntp_parser.y"
-    { enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
+#line 663 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Monitor, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 140:
 
 /* Line 1455 of yacc.c  */
-#line 653 "ntp_parser.y"
-    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
+#line 672 "ntp_parser.y"
+    { enqueue(my_config.fudge, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
     break;
 
   case 141:
 
 /* Line 1455 of yacc.c  */
-#line 658 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(CLK_HAVETIME1, (yyvsp[(2) - (2)].Double)); }
+#line 676 "ntp_parser.y"
+    { enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 142:
 
 /* Line 1455 of yacc.c  */
-#line 660 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(CLK_HAVETIME2, (yyvsp[(2) - (2)].Double)); }
+#line 677 "ntp_parser.y"
+    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 143:
 
 /* Line 1455 of yacc.c  */
-#line 662 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEVAL1,  (yyvsp[(2) - (2)].Integer)); }
+#line 682 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(CLK_HAVETIME1, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 144:
 
 /* Line 1455 of yacc.c  */
-#line 664 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_sval(CLK_HAVEVAL2,  (yyvsp[(2) - (2)].String)); }
+#line 684 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(CLK_HAVETIME2, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 145:
 
 /* Line 1455 of yacc.c  */
-#line 666 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG1, (yyvsp[(2) - (2)].Integer)); }
+#line 686 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEVAL1,  (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 146:
 
 /* Line 1455 of yacc.c  */
-#line 668 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG2, (yyvsp[(2) - (2)].Integer)); }
+#line 688 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_sval(CLK_HAVEVAL2,  (yyvsp[(2) - (2)].String)); }
     break;
 
   case 147:
 
 /* Line 1455 of yacc.c  */
-#line 670 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG3, (yyvsp[(2) - (2)].Integer)); }
+#line 690 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG1, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 148:
 
 /* Line 1455 of yacc.c  */
-#line 672 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG4, (yyvsp[(2) - (2)].Integer)); }
+#line 692 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG2, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 149:
 
 /* Line 1455 of yacc.c  */
-#line 681 "ntp_parser.y"
-    { append_queue(my_config.enable_opts,(yyvsp[(2) - (2)].Queue));  }
+#line 694 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG3, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 150:
 
 /* Line 1455 of yacc.c  */
-#line 683 "ntp_parser.y"
-    { append_queue(my_config.disable_opts,(yyvsp[(2) - (2)].Queue));  }
+#line 696 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(CLK_HAVEFLAG4, (yyvsp[(2) - (2)].Integer)); }
     break;
 
   case 151:
 
 /* Line 1455 of yacc.c  */
-#line 687 "ntp_parser.y"
-    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
+#line 705 "ntp_parser.y"
+    { append_queue(my_config.enable_opts,(yyvsp[(2) - (2)].Queue));  }
     break;
 
   case 152:
 
 /* Line 1455 of yacc.c  */
-#line 688 "ntp_parser.y"
-    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
+#line 707 "ntp_parser.y"
+    { append_queue(my_config.disable_opts,(yyvsp[(2) - (2)].Queue));  }
     break;
 
   case 153:
 
 /* Line 1455 of yacc.c  */
-#line 692 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_AUTHENTICATE); }
+#line 711 "ntp_parser.y"
+    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 154:
 
 /* Line 1455 of yacc.c  */
-#line 693 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_BROADCLIENT); }
+#line 712 "ntp_parser.y"
+    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 155:
 
 /* Line 1455 of yacc.c  */
-#line 694 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_CAL); }
+#line 716 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_AUTHENTICATE); }
     break;
 
   case 156:
 
 /* Line 1455 of yacc.c  */
-#line 695 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_KERNEL); }
+#line 717 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_BROADCLIENT); }
     break;
 
   case 157:
 
 /* Line 1455 of yacc.c  */
-#line 696 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_MONITOR); }
+#line 718 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_CAL); }
     break;
 
   case 158:
 
 /* Line 1455 of yacc.c  */
-#line 697 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_NTP); }
+#line 719 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_KERNEL); }
     break;
 
   case 159:
 
 /* Line 1455 of yacc.c  */
-#line 699 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_FILEGEN); }
+#line 720 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_MONITOR); }
     break;
 
   case 160:
 
 /* Line 1455 of yacc.c  */
-#line 707 "ntp_parser.y"
-    { append_queue(my_config.tinker, (yyvsp[(2) - (2)].Queue)); }
+#line 721 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_NTP); }
     break;
 
   case 161:
 
 /* Line 1455 of yacc.c  */
-#line 711 "ntp_parser.y"
-    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
+#line 723 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_ival(T_Flag, PROTO_FILEGEN); }
     break;
 
   case 162:
 
 /* Line 1455 of yacc.c  */
-#line 712 "ntp_parser.y"
-    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
+#line 731 "ntp_parser.y"
+    { append_queue(my_config.tinker, (yyvsp[(2) - (2)].Queue)); }
     break;
 
   case 163:
 
 /* Line 1455 of yacc.c  */
-#line 716 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_ALLAN, (yyvsp[(2) - (2)].Double)); }
+#line 735 "ntp_parser.y"
+    { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
   case 164:
 
 /* Line 1455 of yacc.c  */
-#line 717 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_PHI, (yyvsp[(2) - (2)].Double)); }
+#line 736 "ntp_parser.y"
+    { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
   case 165:
 
 /* Line 1455 of yacc.c  */
-#line 718 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_FREQ, (yyvsp[(2) - (2)].Double)); }
+#line 740 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_ALLAN, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 166:
 
 /* Line 1455 of yacc.c  */
-#line 719 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_HUFFPUFF, (yyvsp[(2) - (2)].Double)); }
+#line 741 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_PHI, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 167:
 
 /* Line 1455 of yacc.c  */
-#line 720 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_PANIC, (yyvsp[(2) - (2)].Double)); }
+#line 742 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_FREQ, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 168:
 
 /* Line 1455 of yacc.c  */
-#line 721 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_MAX, (yyvsp[(2) - (2)].Double)); }
+#line 743 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_HUFFPUFF, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 169:
 
 /* Line 1455 of yacc.c  */
-#line 722 "ntp_parser.y"
-    { (yyval.Attr_val) = create_attr_dval(LOOP_MINSTEP, (yyvsp[(2) - (2)].Double)); }
+#line 744 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_PANIC, (yyvsp[(2) - (2)].Double)); }
     break;
 
   case 170:
 
 /* Line 1455 of yacc.c  */
-#line 731 "ntp_parser.y"
+#line 745 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_MAX, (yyvsp[(2) - (2)].Double)); }
+    break;
+
+  case 171:
+
+/* Line 1455 of yacc.c  */
+#line 746 "ntp_parser.y"
+    { (yyval.Attr_val) = create_attr_dval(LOOP_MINSTEP, (yyvsp[(2) - (2)].Double)); }
+    break;
+
+  case 172:
+
+/* Line 1455 of yacc.c  */
+#line 755 "ntp_parser.y"
     {
                        if (curr_include_level >= MAXINCLUDELEVEL) {
                                fprintf(stderr, "getconfig: Maximum include file level exceeded.\n");
@@ -3252,203 +3293,203 @@ yyreduce:
                                if (fp[curr_include_level + 1] == NULL) {
                                        fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig((yyvsp[(2) - (3)].String)));
                                        msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", FindConfig((yyvsp[(2) - (3)].String)));
-                       }
-                       else
-                               ip_file = fp[++curr_include_level];
+                               }
+                               else
+                                       ip_file = fp[++curr_include_level];
                        }
                }
     break;
 
-  case 171:
+  case 173:
 
 /* Line 1455 of yacc.c  */
-#line 747 "ntp_parser.y"
+#line 771 "ntp_parser.y"
     {
                        while (curr_include_level != -1)
                                FCLOSE(fp[curr_include_level--]);
                }
     break;
 
-  case 172:
+  case 174:
 
 /* Line 1455 of yacc.c  */
-#line 753 "ntp_parser.y"
+#line 777 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_dval(T_Broadcastdelay, (yyvsp[(2) - (2)].Double))); }
     break;
 
-  case 173:
+  case 175:
 
 /* Line 1455 of yacc.c  */
-#line 755 "ntp_parser.y"
+#line 779 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_ival(T_Calldelay, (yyvsp[(2) - (2)].Integer))); }
     break;
 
-  case 174:
+  case 176:
 
 /* Line 1455 of yacc.c  */
-#line 757 "ntp_parser.y"
+#line 781 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_dval(T_Tick, (yyvsp[(2) - (2)].Double))); }
     break;
 
-  case 175:
+  case 177:
 
 /* Line 1455 of yacc.c  */
-#line 759 "ntp_parser.y"
+#line 783 "ntp_parser.y"
     { /* Null action, possibly all null parms */ }
     break;
 
-  case 176:
+  case 178:
 
 /* Line 1455 of yacc.c  */
-#line 761 "ntp_parser.y"
+#line 785 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_sval(T_Leapfile, (yyvsp[(2) - (2)].String))); }
     break;
 
-  case 177:
+  case 179:
 
 /* Line 1455 of yacc.c  */
-#line 764 "ntp_parser.y"
+#line 788 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_sval(T_Pidfile, (yyvsp[(2) - (2)].String))); }
     break;
 
-  case 178:
+  case 180:
 
 /* Line 1455 of yacc.c  */
-#line 766 "ntp_parser.y"
+#line 790 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_sval(T_Logfile, (yyvsp[(2) - (2)].String))); }
     break;
 
-  case 179:
+  case 181:
 
 /* Line 1455 of yacc.c  */
-#line 768 "ntp_parser.y"
+#line 792 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_ival(T_Automax, (yyvsp[(2) - (2)].Integer))); }
     break;
 
-  case 180:
+  case 182:
 
 /* Line 1455 of yacc.c  */
-#line 771 "ntp_parser.y"
+#line 795 "ntp_parser.y"
     { append_queue(my_config.logconfig, (yyvsp[(2) - (2)].Queue)); }
     break;
 
-  case 181:
+  case 183:
 
 /* Line 1455 of yacc.c  */
-#line 773 "ntp_parser.y"
+#line 797 "ntp_parser.y"
     { append_queue(my_config.phone, (yyvsp[(2) - (2)].Queue)); }
     break;
 
-  case 182:
+  case 184:
 
 /* Line 1455 of yacc.c  */
-#line 775 "ntp_parser.y"
+#line 799 "ntp_parser.y"
     { enqueue(my_config.setvar, (yyvsp[(2) - (2)].Set_var)); }
     break;
 
-  case 183:
+  case 185:
 
 /* Line 1455 of yacc.c  */
-#line 777 "ntp_parser.y"
+#line 801 "ntp_parser.y"
     { enqueue(my_config.trap, create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Queue))); }
     break;
 
-  case 184:
+  case 186:
 
 /* Line 1455 of yacc.c  */
-#line 779 "ntp_parser.y"
+#line 803 "ntp_parser.y"
     { append_queue(my_config.ttl, (yyvsp[(2) - (2)].Queue)); }
     break;
 
-  case 185:
+  case 187:
 
 /* Line 1455 of yacc.c  */
-#line 781 "ntp_parser.y"
+#line 805 "ntp_parser.y"
     { enqueue(my_config.qos, create_attr_sval(T_Qos, (yyvsp[(2) - (2)].String))); }
     break;
 
-  case 186:
+  case 188:
 
 /* Line 1455 of yacc.c  */
-#line 785 "ntp_parser.y"
+#line 809 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (1)].String))); }
     break;
 
-  case 187:
+  case 189:
 
 /* Line 1455 of yacc.c  */
-#line 787 "ntp_parser.y"
+#line 811 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_dval(T_WanderThreshold, (yyvsp[(2) - (2)].Double)));
                          enqueue(my_config.vars, create_attr_sval(T_Driftfile, (yyvsp[(1) - (2)].String))); }
     break;
 
-  case 188:
+  case 190:
 
 /* Line 1455 of yacc.c  */
-#line 790 "ntp_parser.y"
+#line 814 "ntp_parser.y"
     { enqueue(my_config.vars, create_attr_sval(T_Driftfile, "\0")); }
     break;
 
-  case 189:
+  case 191:
 
 /* Line 1455 of yacc.c  */
-#line 795 "ntp_parser.y"
+#line 819 "ntp_parser.y"
     { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (4)].String), (yyvsp[(3) - (4)].String), DEF); }
     break;
 
-  case 190:
+  case 192:
 
 /* Line 1455 of yacc.c  */
-#line 797 "ntp_parser.y"
+#line 821 "ntp_parser.y"
     { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (3)].String), (yyvsp[(3) - (3)].String), 0); }
     break;
 
-  case 191:
+  case 193:
 
 /* Line 1455 of yacc.c  */
-#line 802 "ntp_parser.y"
+#line 826 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
-  case 192:
+  case 194:
 
 /* Line 1455 of yacc.c  */
-#line 803 "ntp_parser.y"
+#line 827 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
-  case 193:
+  case 195:
 
 /* Line 1455 of yacc.c  */
-#line 807 "ntp_parser.y"
+#line 831 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival(T_Port, (yyvsp[(2) - (2)].Integer)); }
     break;
 
-  case 194:
+  case 196:
 
 /* Line 1455 of yacc.c  */
-#line 808 "ntp_parser.y"
+#line 832 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_pval(T_Interface, (yyvsp[(2) - (2)].Address_node)); }
     break;
 
-  case 195:
+  case 197:
 
 /* Line 1455 of yacc.c  */
-#line 813 "ntp_parser.y"
+#line 837 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Attr_val)); }
     break;
 
-  case 196:
+  case 198:
 
 /* Line 1455 of yacc.c  */
-#line 814 "ntp_parser.y"
+#line 838 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Attr_val)); }
     break;
 
-  case 197:
+  case 199:
 
 /* Line 1455 of yacc.c  */
-#line 819 "ntp_parser.y"
+#line 843 "ntp_parser.y"
     {
                        char prefix = (yyvsp[(1) - (1)].String)[0];
                        char *type = (yyvsp[(1) - (1)].String) + 1;
@@ -3457,57 +3498,57 @@ yyreduce:
                                yyerror("Logconfig prefix is not '+', '-' or '='\n");
                        }
                        else
-                               (yyval.Attr_val) = create_attr_sval(prefix, strdup(type));
+                               (yyval.Attr_val) = create_attr_sval(prefix, estrdup(type));
                        YYFREE((yyvsp[(1) - (1)].String));
                }
     break;
 
-  case 198:
+  case 200:
 
 /* Line 1455 of yacc.c  */
-#line 837 "ntp_parser.y"
+#line 861 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), create_ival((yyvsp[(2) - (2)].Integer))); }
     break;
 
-  case 199:
+  case 201:
 
 /* Line 1455 of yacc.c  */
-#line 838 "ntp_parser.y"
+#line 862 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue(create_ival((yyvsp[(1) - (1)].Integer))); }
     break;
 
-  case 200:
+  case 202:
 
 /* Line 1455 of yacc.c  */
-#line 842 "ntp_parser.y"
+#line 866 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), create_pval((yyvsp[(2) - (2)].String))); }
     break;
 
-  case 201:
+  case 203:
 
 /* Line 1455 of yacc.c  */
-#line 843 "ntp_parser.y"
+#line 867 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue(create_pval((yyvsp[(1) - (1)].String))); }
     break;
 
-  case 202:
+  case 204:
 
 /* Line 1455 of yacc.c  */
-#line 847 "ntp_parser.y"
+#line 871 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Address_node)); }
     break;
 
-  case 203:
+  case 205:
 
 /* Line 1455 of yacc.c  */
-#line 848 "ntp_parser.y"
+#line 872 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Address_node)); }
     break;
 
-  case 204:
+  case 206:
 
 /* Line 1455 of yacc.c  */
-#line 853 "ntp_parser.y"
+#line 877 "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");
@@ -3518,38 +3559,38 @@ yyreduce:
                }
     break;
 
-  case 205:
+  case 207:
 
 /* Line 1455 of yacc.c  */
-#line 861 "ntp_parser.y"
+#line 885 "ntp_parser.y"
     { (yyval.Integer) = 1; }
     break;
 
-  case 206:
+  case 208:
 
 /* Line 1455 of yacc.c  */
-#line 862 "ntp_parser.y"
+#line 886 "ntp_parser.y"
     { (yyval.Integer) = 0; }
     break;
 
-  case 207:
+  case 209:
 
 /* Line 1455 of yacc.c  */
-#line 866 "ntp_parser.y"
+#line 890 "ntp_parser.y"
     { (yyval.Double) = (double)(yyvsp[(1) - (1)].Integer); }
     break;
 
-  case 208:
+  case 210:
 
 /* Line 1455 of yacc.c  */
-#line 867 "ntp_parser.y"
+#line 891 "ntp_parser.y"
     { (yyval.Double) = (yyvsp[(1) - (1)].Double); }
     break;
 
-  case 209:
+  case 211:
 
 /* Line 1455 of yacc.c  */
-#line 876 "ntp_parser.y"
+#line 900 "ntp_parser.y"
     {
                        my_config.sim_details = create_sim_node((yyvsp[(3) - (5)].Queue), (yyvsp[(4) - (5)].Queue));
 
@@ -3558,150 +3599,150 @@ yyreduce:
                }
     break;
 
-  case 210:
+  case 212:
 
 /* Line 1455 of yacc.c  */
-#line 890 "ntp_parser.y"
+#line 914 "ntp_parser.y"
     { old_config_style = 0; }
     break;
 
-  case 211:
+  case 213:
 
 /* Line 1455 of yacc.c  */
-#line 894 "ntp_parser.y"
+#line 918 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (3)].Queue), (yyvsp[(2) - (3)].Attr_val)); }
     break;
 
-  case 212:
+  case 214:
 
 /* Line 1455 of yacc.c  */
-#line 895 "ntp_parser.y"
+#line 919 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (2)].Attr_val)); }
     break;
 
-  case 213:
+  case 215:
 
 /* Line 1455 of yacc.c  */
-#line 899 "ntp_parser.y"
+#line 923 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Beep_Delay, (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 214:
+  case 216:
 
 /* Line 1455 of yacc.c  */
-#line 900 "ntp_parser.y"
+#line 924 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Sim_Duration, (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 215:
+  case 217:
 
 /* Line 1455 of yacc.c  */
-#line 904 "ntp_parser.y"
+#line 928 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Sim_server)); }
     break;
 
-  case 216:
+  case 218:
 
 /* Line 1455 of yacc.c  */
-#line 905 "ntp_parser.y"
+#line 929 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Sim_server)); }
     break;
 
-  case 217:
+  case 219:
 
 /* Line 1455 of yacc.c  */
-#line 910 "ntp_parser.y"
+#line 934 "ntp_parser.y"
     { (yyval.Sim_server) = create_sim_server((yyvsp[(1) - (5)].Address_node), (yyvsp[(3) - (5)].Double), (yyvsp[(4) - (5)].Queue)); }
     break;
 
-  case 218:
+  case 220:
 
 /* Line 1455 of yacc.c  */
-#line 914 "ntp_parser.y"
+#line 938 "ntp_parser.y"
     { (yyval.Double) = (yyvsp[(3) - (4)].Double); }
     break;
 
-  case 219:
+  case 221:
 
 /* Line 1455 of yacc.c  */
-#line 918 "ntp_parser.y"
+#line 942 "ntp_parser.y"
     { (yyval.Address_node) = (yyvsp[(3) - (3)].Address_node); }
     break;
 
-  case 220:
+  case 222:
 
 /* Line 1455 of yacc.c  */
-#line 922 "ntp_parser.y"
+#line 946 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (2)].Queue), (yyvsp[(2) - (2)].Sim_script)); }
     break;
 
-  case 221:
+  case 223:
 
 /* Line 1455 of yacc.c  */
-#line 923 "ntp_parser.y"
+#line 947 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (1)].Sim_script)); }
     break;
 
-  case 222:
+  case 224:
 
 /* Line 1455 of yacc.c  */
-#line 928 "ntp_parser.y"
+#line 952 "ntp_parser.y"
     { (yyval.Sim_script) = create_sim_script_info((yyvsp[(3) - (6)].Double), (yyvsp[(5) - (6)].Queue)); }
     break;
 
-  case 223:
+  case 225:
 
 /* Line 1455 of yacc.c  */
-#line 932 "ntp_parser.y"
+#line 956 "ntp_parser.y"
     { (yyval.Queue) = enqueue((yyvsp[(1) - (3)].Queue), (yyvsp[(2) - (3)].Attr_val)); }
     break;
 
-  case 224:
+  case 226:
 
 /* Line 1455 of yacc.c  */
-#line 933 "ntp_parser.y"
+#line 957 "ntp_parser.y"
     { (yyval.Queue) = enqueue_in_new_queue((yyvsp[(1) - (2)].Attr_val)); }
     break;
 
-  case 225:
+  case 227:
 
 /* Line 1455 of yacc.c  */
-#line 938 "ntp_parser.y"
+#line 962 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Freq_Offset, (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 226:
+  case 228:
 
 /* Line 1455 of yacc.c  */
-#line 940 "ntp_parser.y"
+#line 964 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Wander, (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 227:
+  case 229:
 
 /* Line 1455 of yacc.c  */
-#line 942 "ntp_parser.y"
+#line 966 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Jitter, (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 228:
+  case 230:
 
 /* Line 1455 of yacc.c  */
-#line 944 "ntp_parser.y"
+#line 968 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Prop_Delay, (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 229:
+  case 231:
 
 /* Line 1455 of yacc.c  */
-#line 946 "ntp_parser.y"
+#line 970 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval(T_Proc_Delay, (yyvsp[(3) - (3)].Double)); }
     break;
 
 
 
 /* Line 1455 of yacc.c  */
-#line 3705 "ntp_parser.c"
+#line 3746 "ntp_parser.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3913,7 +3954,7 @@ yyreturn:
 
 
 /* Line 1675 of yacc.c  */
-#line 950 "ntp_parser.y"
+#line 974 "ntp_parser.y"
 
 
 /* KEYWORDS
@@ -3925,7 +3966,11 @@ void yyerror (char *msg)
        int retval;
        
        if (input_from_file)
-               msyslog(LOG_ERR, "%s\n", msg);
+               msyslog(LOG_ERR, 
+                       "line %d column %d %s", 
+                       ip_file->line_no,
+                       ip_file->prev_token_col_no,
+                       msg);
        else {
                /* Save the error message in the correct buffer */
                retval = snprintf(remote_config.err_msg + remote_config.err_pos,
index 0e8305d72aca9b36abf5c710f95f9354a734d9b7..90f6e291d58cd486fbba0280acd96d0b2a7ba989 100644 (file)
      T_Dispersion = 283,
      T_Double = 284,
      T_Driftfile = 285,
-     T_WanderThreshold = 286,
-     T_Enable = 287,
-     T_End = 288,
-     T_False = 289,
-     T_File = 290,
-     T_Filegen = 291,
-     T_Flag1 = 292,
-     T_Flag2 = 293,
-     T_Flag3 = 294,
-     T_Flag4 = 295,
-     T_Flake = 296,
-     T_Floor = 297,
-     T_Freq = 298,
-     T_Fudge = 299,
-     T_Host = 300,
-     T_Huffpuff = 301,
-     T_IPv4_address = 302,
-     T_IPv6_address = 303,
-     T_Iburst = 304,
-     T_Ident = 305,
-     T_Ignore = 306,
-     T_Includefile = 307,
-     T_Integer = 308,
-     T_Interface = 309,
-     T_Kernel = 310,
-     T_Key = 311,
-     T_Keys = 312,
-     T_Keysdir = 313,
-     T_Kod = 314,
-     T_Leap = 315,
-     T_Leapfile = 316,
-     T_Limited = 317,
-     T_Link = 318,
-     T_Logconfig = 319,
-     T_Logfile = 320,
-     T_Loopstats = 321,
-     T_Lowpriotrap = 322,
-     T_Manycastclient = 323,
-     T_Manycastserver = 324,
-     T_Mask = 325,
-     T_Maxclock = 326,
-     T_Maxdist = 327,
-     T_Maxhop = 328,
-     T_Maxpoll = 329,
-     T_Minclock = 330,
-     T_Mindist = 331,
-     T_Minimum = 332,
-     T_Minpoll = 333,
-     T_Minsane = 334,
-     T_Mode = 335,
-     T_Monitor = 336,
-     T_Month = 337,
-     T_Multicastclient = 338,
-     T_Nolink = 339,
-     T_Nomodify = 340,
-     T_None = 341,
-     T_Nopeer = 342,
-     T_Noquery = 343,
-     T_Noselect = 344,
-     T_Noserve = 345,
-     T_Notrap = 346,
-     T_Notrust = 347,
-     T_Novolley = 348,
-     T_Ntp = 349,
-     T_Ntpport = 350,
-     T_NtpSignDsocket = 351,
-     T_Orphan = 352,
-     T_Panic = 353,
-     T_Peer = 354,
-     T_Peerstats = 355,
-     T_Phone = 356,
-     T_Pid = 357,
-     T_Pidfile = 358,
-     T_Pool = 359,
-     T_Port = 360,
-     T_Pps = 361,
-     T_Preempt = 362,
-     T_Prefer = 363,
-     T_Protostats = 364,
-     T_Pw = 365,
-     T_Qos = 366,
-     T_RandFile = 367,
-     T_Rawstats = 368,
-     T_Refid = 369,
-     T_Requestkey = 370,
-     T_Restrict = 371,
-     T_Revoke = 372,
-     T_Server = 373,
-     T_Setvar = 374,
-     T_Sign = 375,
-     T_Statistics = 376,
-     T_Stats = 377,
-     T_Statsdir = 378,
-     T_Step = 379,
-     T_Stepout = 380,
-     T_Stratum = 381,
-     T_String = 382,
-     T_Sysstats = 383,
-     T_Tick = 384,
-     T_Time1 = 385,
-     T_Time2 = 386,
-     T_Timingstats = 387,
-     T_Tinker = 388,
-     T_Tos = 389,
-     T_Trap = 390,
-     T_True = 391,
-     T_Trustedkey = 392,
-     T_Ttl = 393,
-     T_Type = 394,
-     T_Unconfig = 395,
-     T_Unpeer = 396,
-     T_Version = 397,
+     T_Enable = 286,
+     T_End = 287,
+     T_False = 288,
+     T_File = 289,
+     T_Filegen = 290,
+     T_Flag1 = 291,
+     T_Flag2 = 292,
+     T_Flag3 = 293,
+     T_Flag4 = 294,
+     T_Flake = 295,
+     T_Floor = 296,
+     T_Freq = 297,
+     T_Fudge = 298,
+     T_Host = 299,
+     T_Huffpuff = 300,
+     T_Iburst = 301,
+     T_Ident = 302,
+     T_Ignore = 303,
+     T_Includefile = 304,
+     T_Integer = 305,
+     T_Interface = 306,
+     T_IPv4_flag = 307,
+     T_IPv6_flag = 308,
+     T_Kernel = 309,
+     T_Key = 310,
+     T_Keys = 311,
+     T_Keysdir = 312,
+     T_Kod = 313,
+     T_Leap = 314,
+     T_Leapfile = 315,
+     T_Limited = 316,
+     T_Link = 317,
+     T_Logconfig = 318,
+     T_Logfile = 319,
+     T_Loopstats = 320,
+     T_Lowpriotrap = 321,
+     T_Manycastclient = 322,
+     T_Manycastserver = 323,
+     T_Mask = 324,
+     T_Maxclock = 325,
+     T_Maxdist = 326,
+     T_Maxhop = 327,
+     T_Maxpoll = 328,
+     T_Minclock = 329,
+     T_Mindist = 330,
+     T_Minimum = 331,
+     T_Minpoll = 332,
+     T_Minsane = 333,
+     T_Mode = 334,
+     T_Monitor = 335,
+     T_Month = 336,
+     T_Multicastclient = 337,
+     T_Nolink = 338,
+     T_Nomodify = 339,
+     T_None = 340,
+     T_Nopeer = 341,
+     T_Noquery = 342,
+     T_Noselect = 343,
+     T_Noserve = 344,
+     T_Notrap = 345,
+     T_Notrust = 346,
+     T_Novolley = 347,
+     T_Ntp = 348,
+     T_Ntpport = 349,
+     T_NtpSignDsocket = 350,
+     T_Orphan = 351,
+     T_Panic = 352,
+     T_Peer = 353,
+     T_Peerstats = 354,
+     T_Phone = 355,
+     T_Pid = 356,
+     T_Pidfile = 357,
+     T_Pool = 358,
+     T_Port = 359,
+     T_Pps = 360,
+     T_Preempt = 361,
+     T_Prefer = 362,
+     T_Protostats = 363,
+     T_Pw = 364,
+     T_Qos = 365,
+     T_RandFile = 366,
+     T_Rawstats = 367,
+     T_Refid = 368,
+     T_Requestkey = 369,
+     T_Restrict = 370,
+     T_Revoke = 371,
+     T_Server = 372,
+     T_Setvar = 373,
+     T_Sign = 374,
+     T_Statistics = 375,
+     T_Stats = 376,
+     T_Statsdir = 377,
+     T_Step = 378,
+     T_Stepout = 379,
+     T_Stratum = 380,
+     T_String = 381,
+     T_Sysstats = 382,
+     T_Tick = 383,
+     T_Time1 = 384,
+     T_Time2 = 385,
+     T_Timingstats = 386,
+     T_Tinker = 387,
+     T_Tos = 388,
+     T_Trap = 389,
+     T_True = 390,
+     T_Trustedkey = 391,
+     T_Ttl = 392,
+     T_Type = 393,
+     T_Unconfig = 394,
+     T_Unpeer = 395,
+     T_Version = 396,
+     T_WanderThreshold = 397,
      T_Week = 398,
      T_Xleave = 399,
      T_Year = 400,
 #define T_Dispersion 283
 #define T_Double 284
 #define T_Driftfile 285
-#define T_WanderThreshold 286
-#define T_Enable 287
-#define T_End 288
-#define T_False 289
-#define T_File 290
-#define T_Filegen 291
-#define T_Flag1 292
-#define T_Flag2 293
-#define T_Flag3 294
-#define T_Flag4 295
-#define T_Flake 296
-#define T_Floor 297
-#define T_Freq 298
-#define T_Fudge 299
-#define T_Host 300
-#define T_Huffpuff 301
-#define T_IPv4_address 302
-#define T_IPv6_address 303
-#define T_Iburst 304
-#define T_Ident 305
-#define T_Ignore 306
-#define T_Includefile 307
-#define T_Integer 308
-#define T_Interface 309
-#define T_Kernel 310
-#define T_Key 311
-#define T_Keys 312
-#define T_Keysdir 313
-#define T_Kod 314
-#define T_Leap 315
-#define T_Leapfile 316
-#define T_Limited 317
-#define T_Link 318
-#define T_Logconfig 319
-#define T_Logfile 320
-#define T_Loopstats 321
-#define T_Lowpriotrap 322
-#define T_Manycastclient 323
-#define T_Manycastserver 324
-#define T_Mask 325
-#define T_Maxclock 326
-#define T_Maxdist 327
-#define T_Maxhop 328
-#define T_Maxpoll 329
-#define T_Minclock 330
-#define T_Mindist 331
-#define T_Minimum 332
-#define T_Minpoll 333
-#define T_Minsane 334
-#define T_Mode 335
-#define T_Monitor 336
-#define T_Month 337
-#define T_Multicastclient 338
-#define T_Nolink 339
-#define T_Nomodify 340
-#define T_None 341
-#define T_Nopeer 342
-#define T_Noquery 343
-#define T_Noselect 344
-#define T_Noserve 345
-#define T_Notrap 346
-#define T_Notrust 347
-#define T_Novolley 348
-#define T_Ntp 349
-#define T_Ntpport 350
-#define T_NtpSignDsocket 351
-#define T_Orphan 352
-#define T_Panic 353
-#define T_Peer 354
-#define T_Peerstats 355
-#define T_Phone 356
-#define T_Pid 357
-#define T_Pidfile 358
-#define T_Pool 359
-#define T_Port 360
-#define T_Pps 361
-#define T_Preempt 362
-#define T_Prefer 363
-#define T_Protostats 364
-#define T_Pw 365
-#define T_Qos 366
-#define T_RandFile 367
-#define T_Rawstats 368
-#define T_Refid 369
-#define T_Requestkey 370
-#define T_Restrict 371
-#define T_Revoke 372
-#define T_Server 373
-#define T_Setvar 374
-#define T_Sign 375
-#define T_Statistics 376
-#define T_Stats 377
-#define T_Statsdir 378
-#define T_Step 379
-#define T_Stepout 380
-#define T_Stratum 381
-#define T_String 382
-#define T_Sysstats 383
-#define T_Tick 384
-#define T_Time1 385
-#define T_Time2 386
-#define T_Timingstats 387
-#define T_Tinker 388
-#define T_Tos 389
-#define T_Trap 390
-#define T_True 391
-#define T_Trustedkey 392
-#define T_Ttl 393
-#define T_Type 394
-#define T_Unconfig 395
-#define T_Unpeer 396
-#define T_Version 397
+#define T_Enable 286
+#define T_End 287
+#define T_False 288
+#define T_File 289
+#define T_Filegen 290
+#define T_Flag1 291
+#define T_Flag2 292
+#define T_Flag3 293
+#define T_Flag4 294
+#define T_Flake 295
+#define T_Floor 296
+#define T_Freq 297
+#define T_Fudge 298
+#define T_Host 299
+#define T_Huffpuff 300
+#define T_Iburst 301
+#define T_Ident 302
+#define T_Ignore 303
+#define T_Includefile 304
+#define T_Integer 305
+#define T_Interface 306
+#define T_IPv4_flag 307
+#define T_IPv6_flag 308
+#define T_Kernel 309
+#define T_Key 310
+#define T_Keys 311
+#define T_Keysdir 312
+#define T_Kod 313
+#define T_Leap 314
+#define T_Leapfile 315
+#define T_Limited 316
+#define T_Link 317
+#define T_Logconfig 318
+#define T_Logfile 319
+#define T_Loopstats 320
+#define T_Lowpriotrap 321
+#define T_Manycastclient 322
+#define T_Manycastserver 323
+#define T_Mask 324
+#define T_Maxclock 325
+#define T_Maxdist 326
+#define T_Maxhop 327
+#define T_Maxpoll 328
+#define T_Minclock 329
+#define T_Mindist 330
+#define T_Minimum 331
+#define T_Minpoll 332
+#define T_Minsane 333
+#define T_Mode 334
+#define T_Monitor 335
+#define T_Month 336
+#define T_Multicastclient 337
+#define T_Nolink 338
+#define T_Nomodify 339
+#define T_None 340
+#define T_Nopeer 341
+#define T_Noquery 342
+#define T_Noselect 343
+#define T_Noserve 344
+#define T_Notrap 345
+#define T_Notrust 346
+#define T_Novolley 347
+#define T_Ntp 348
+#define T_Ntpport 349
+#define T_NtpSignDsocket 350
+#define T_Orphan 351
+#define T_Panic 352
+#define T_Peer 353
+#define T_Peerstats 354
+#define T_Phone 355
+#define T_Pid 356
+#define T_Pidfile 357
+#define T_Pool 358
+#define T_Port 359
+#define T_Pps 360
+#define T_Preempt 361
+#define T_Prefer 362
+#define T_Protostats 363
+#define T_Pw 364
+#define T_Qos 365
+#define T_RandFile 366
+#define T_Rawstats 367
+#define T_Refid 368
+#define T_Requestkey 369
+#define T_Restrict 370
+#define T_Revoke 371
+#define T_Server 372
+#define T_Setvar 373
+#define T_Sign 374
+#define T_Statistics 375
+#define T_Stats 376
+#define T_Statsdir 377
+#define T_Step 378
+#define T_Stepout 379
+#define T_Stratum 380
+#define T_String 381
+#define T_Sysstats 382
+#define T_Tick 383
+#define T_Time1 384
+#define T_Time2 385
+#define T_Timingstats 386
+#define T_Tinker 387
+#define T_Tos 388
+#define T_Trap 389
+#define T_True 390
+#define T_Trustedkey 391
+#define T_Ttl 392
+#define T_Type 393
+#define T_Unconfig 394
+#define T_Unpeer 395
+#define T_Version 396
+#define T_WanderThreshold 397
 #define T_Week 398
 #define T_Xleave 399
 #define T_Year 400
@@ -363,7 +363,7 @@ typedef union YYSTYPE
 {
 
 /* Line 1676 of yacc.c  */
-#line 51 "ntp_parser.y"
+#line 44 "ntp_parser.y"
 
     char   *String;
     double  Double;
index 1822e88062eac419049d132b709616b924688eb8..e181c855fa035d24c75f4795c2c8b25d7898737e 100644 (file)
                                   for both the simulator and the daemon
                                */
 
-  /*  #include "ntp_parser.h"     SK: Arent't we generating this using bison?
-                                  This was not an issue when we were
-                                  directly including the source file. However,
-                                  we will need a seperate description of the
-                                  tokens in the scanner.
-                               */
-
 
   struct FILE_INFO *ip_file;   /* Pointer to the configuration file stream */
 
@@ -92,7 +85,6 @@
 %token                 T_Dispersion
 %token <Double>        T_Double
 %token                 T_Driftfile
-%token <Double>        T_WanderThreshold
 %token                 T_Enable
 %token                 T_End
 %token                 T_False
 %token                 T_Fudge
 %token                 T_Host
 %token                 T_Huffpuff
-%token                 T_IPv4_address
-%token                 T_IPv6_address
 %token                 T_Iburst
 %token                 T_Ident
 %token                 T_Ignore
 %token                 T_Includefile
 %token <Integer>       T_Integer
 %token                 T_Interface
+%token                 T_IPv4_flag
+%token                 T_IPv6_flag
 %token                 T_Kernel
 %token                 T_Key
 %token                 T_Keys
 %token                 T_Unconfig
 %token                 T_Unpeer
 %token                 T_Version
+%token <Double>        T_WanderThreshold
 %token                 T_Week
 %token                 T_Xleave
 %token                 T_Year
@@ -294,14 +287,20 @@ command_list
                {
                        /* I will need to incorporate much more fine grained
                         * error messages. The following should suffice for
-                        * the time being.
+                        * the time being.  ip_file->col_no is always 1 here,
+                        * and ip_file->line_no is one higher than the
+                        * problem line.  In other words, the scanner has
+                        * moved on to the start of the next line.
                         */
                        if (input_from_file == 1) {
-                               msyslog(LOG_ERR, "parse error %s line %d ignored\n",
-                                       ip_file->fname, ip_file->line_no);
+                               msyslog(LOG_ERR, 
+                                       "syntax error in %s line %d, "
+                                       "ignored",
+                                       ip_file->fname,
+                                       ip_file->line_no - 1);
                        } else if (input_from_file != 0)
                                msyslog(LOG_ERR,
-                                       "parse: bad boolean input flag\n");
+                                       "parse: bad boolean input flag");
        }
        ;
 
@@ -349,8 +348,8 @@ client_type
 
 address
        :       ip_address              { $$ = $1; }
-       |       T_IPv4_address T_String { $$ = create_address_node($2, AF_INET); }
-       |       T_IPv6_address T_String { $$ = create_address_node($2, AF_INET6); }
+       |       T_IPv4_flag T_String    { $$ = create_address_node($2, AF_INET); }
+       |       T_IPv6_flag T_String    { $$ = create_address_node($2, AF_INET6); }
        ;
 
 ip_address
@@ -363,7 +362,6 @@ option_list
        ;
 
 option
-/*     :       /* Null Statement       { $$ = NULL; } */
        :       T_Autokey               { $$ = create_attr_ival(T_Flag, FLAG_SKEY); }
        |       T_Bias number           { $$ = create_attr_dval(T_Bias, $2); }
        |       T_Burst                 { $$ = create_attr_ival(T_Flag, FLAG_BURST); }
@@ -600,6 +598,32 @@ access_control_command
                        enqueue(my_config.restrict_opts,
                                create_restrict_node(NULL, NULL, $3, ip_file->line_no));
                }
+       |       T_Restrict T_IPv4_flag T_Default ac_flag_list
+               {
+                       enqueue(my_config.restrict_opts,
+                               create_restrict_node(
+                                       create_address_node(
+                                               estrdup("0.0.0.0"), 
+                                               AF_INET),
+                                       create_address_node(
+                                               estrdup("255.255.255.255"), 
+                                               AF_INET),
+                                       $4, 
+                                       ip_file->line_no));
+               }
+       |       T_Restrict T_IPv6_flag T_Default ac_flag_list
+               {
+                       enqueue(my_config.restrict_opts,
+                               create_restrict_node(
+                                       create_address_node(
+                                               estrdup("::"), 
+                                               AF_INET6),
+                                       create_address_node(
+                                               estrdup("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),
+                                               AF_INET6),
+                                       $4, 
+                                       ip_file->line_no));
+               }
        |       T_Restrict ip_address T_Mask ip_address ac_flag_list
                {
                        enqueue(my_config.restrict_opts,
@@ -738,9 +762,9 @@ miscellaneous_command
                                if (fp[curr_include_level + 1] == NULL) {
                                        fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig($2));
                                        msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", FindConfig($2));
-                       }
-                       else
-                               ip_file = fp[++curr_include_level];
+                               }
+                               else
+                                       ip_file = fp[++curr_include_level];
                        }
                }
        |       T_End
@@ -824,7 +848,7 @@ log_config_command
                                yyerror("Logconfig prefix is not '+', '-' or '='\n");
                        }
                        else
-                               $$ = create_attr_sval(prefix, strdup(type));
+                               $$ = create_attr_sval(prefix, estrdup(type));
                        YYFREE($1);
                }
        ;
@@ -958,7 +982,11 @@ void yyerror (char *msg)
        int retval;
        
        if (input_from_file)
-               msyslog(LOG_ERR, "%s\n", msg);
+               msyslog(LOG_ERR, 
+                       "line %d column %d %s", 
+                       ip_file->line_no,
+                       ip_file->prev_token_col_no,
+                       msg);
        else {
                /* Save the error message in the correct buffer */
                retval = snprintf(remote_config.err_msg + remote_config.err_pos,
index 24add2bdadb02857cc220224783b3509a9edcadc..5799f7a379b8a02fc2e9f3a0304e7c2430937c37 100644 (file)
@@ -23,6 +23,7 @@
 #include "ntpsim.h"
 #include "ntp_scanner.h"
 #include "ntp_parser.h"
+#include "ntp_debug.h"
 
 
 /* Define a structure to hold the FSA for the keywords.
@@ -49,19 +50,18 @@ 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;
 
+
 /* CONSTANTS 
  * ---------
  */
 #define NON_ACCEPTING 0                /* A constant that depicts a non-accepting state */
-#define NO_OF_SPECIAL_CHARS 8
 
 
 /* SCANNER GLOBAL VARIABLES 
  * ------------------------
  */
-char special_char[] =          /* This list of special characters */
-{ '{', '}', '(', ')', ',', ';','|','=' };
+const char special_chars[] = "{}(),;|=";
+
 
 /* FUNCTIONS
  * ---------
@@ -194,7 +194,7 @@ print_keyword_scanner(
                lexeme[pos] = curr_state->ch;
                if (curr_state->token != NON_ACCEPTING) {
                        lexeme[pos + 1] = '\0';
-                       printf("%s\n",lexeme);
+                       printf("%s\n", lexeme);
                }
                if (curr_state->next_state != NULL)
                        print_keyword_scanner(curr_state->next_state, pos + 1);
@@ -214,16 +214,18 @@ F_OPEN(
        const char *mode
        )
 {
-       struct FILE_INFO *my_info = (struct FILE_INFO *)
-               malloc(sizeof(struct FILE_INFO));
+       struct FILE_INFO *my_info;
 
-       if (my_info == NULL)
-               return NULL;
-       my_info->line_no = 0;
+       my_info = emalloc(sizeof *my_info);
+
+       my_info->line_no = 1;
        my_info->col_no = 0;
+       my_info->prev_line_col_no = 0;
+       my_info->prev_token_col_no = 0;
        my_info->fname = path;
 
-       if ((my_info->fd = fopen(path,mode)) == NULL) {
+       my_info->fd = fopen(path, mode);
+       if (NULL == my_info->fd) {
                free(my_info);
                return NULL;
        }
@@ -372,103 +374,79 @@ is_integer(
        return 1;
 }
 
+
 /* Double */
 static int
 is_double(
        char *lexeme
        )
 {
+       int num_digits = 0;  /* Number of digits read */
        int i;
 
-       /* Initialize the state machine
-          int int_part = 1;
-          int frac_part = 0; 
-       */
-       int no_digits = 0;  /* Number of digits read */
-
        i = 0;
+
        /* Check for an optional '+' or '-' */
-       if (lexeme[i] == '+' || lexeme[i] == '-')
-               ++i;
+       if ('+' == lexeme[i] || '-' == lexeme[i])
+               i++;
 
        /* Read the integer part */
-       for (; lexeme[i] && isdigit(lexeme[i]); ++i)
-               ++no_digits;
+       for (; lexeme[i] && isdigit(lexeme[i]); i++)
+               num_digits++;
 
        /* Check for the required decimal point */
-       if (lexeme[i] == '.')
-               ++i;
+       if ('.' == lexeme[i])
+               i++;
        else
                return 0;
 
        /* Check for any digits after the decimal point */
-       for (; lexeme[i] && isdigit(lexeme[i]); ++i)
-               ++no_digits;
+       for (; lexeme[i] && isdigit(lexeme[i]); i++)
+               num_digits++;
 
-       /* The number of digits in both the decimal part and the fraction part
-          must not be zero at this point */
-       if (no_digits == 0)
+       /*
+        * The number of digits in both the decimal part and the
+        * fraction part must not be zero at this point 
+        */
+       if (!num_digits)
                return 0;
 
        /* Check if we are done */
-       if (lexeme[i] == '\0')
+       if (!lexeme[i])
                return 1;
 
-       /* There is still more output, read the Exponent Part */
-       if (lexeme[i] == 'e' || lexeme[i] == 'E') {
-               ++i;
-       }
+       /* There is still more input, read the exponent */
+       if ('e' == tolower(lexeme[i]))
+               i++;
        else
                return 0;
 
        /* Read an optional Sign */
-       if (lexeme[i] == '+' || lexeme[i] == '-')
-               ++i;
+       if ('+' == lexeme[i] || '-' == lexeme[i])
+               i++;
 
        /* Now read the exponent part */
-       for (; lexeme[i] && isdigit(lexeme[i]); ++i)
-               ++no_digits;
+       while (lexeme[i] && isdigit(lexeme[i]))
+               i++;
 
        /* Check if we are done */
-       if (lexeme[i] == '\0')
+       if (!lexeme[i])
                return 1;
        else
                return 0;
 }
 
 
-
-/* Host Name */
-/* static int is_host_name (char *lexeme) */
-/* { */
-/*     int i; */
-/*     for (i = 0;lexeme[i];++i) */
-/*     if (!isalnum(lexeme[i])) { */
-               /* Check for two consequtive periods which are not allowed */
-/*             if (lexeme[i] == '.' && lexeme[i + 1] != '.') */
-/*                     ; */
-/*             else */
-/*                     return 0; */
-/*     } */
-/*     return 1; */
-/* } */
-
-
-/* Define a function to test whether a character is a special character */
-
-static int
+/* is_special() - Test whether a character is a token */
+static inline int
 is_special(
        int ch
        )
 {
-       int i;
-
-       for (i = 0; i < NO_OF_SPECIAL_CHARS; ++i)
-               if (ch == special_char[i])
-                       return 1;
-       return 0;
+       return (int)strchr(special_chars, ch);
 }
 
+
 static int
 is_EOC(
        int ch
@@ -480,6 +458,7 @@ is_EOC(
        return 0;
 }
 
+
 static int
 create_string_token(
        char *lexeme
@@ -497,24 +476,21 @@ create_string_token(
        if (!*pch)
                return T_EOC;
 
-       yylval.String = strdup(lexeme);
-       if (!yylval.String) {
-               fprintf(stderr, "Could not allocate memory for: %s\n",
-                       lexeme);
-               exit(1);
-       }
-       else
-               return T_String;
+       yylval.String = estrdup(lexeme);
+
+       return T_String;
 }
 
 
-/* Define a function that does the actual scanning 
+/*
+ * Define a 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
  */
-
 int
-yylex()
+yylex(
+       void
+       )
 {
        int i, instring = 0;
        int token;              /* The return value/the recognized token */
@@ -523,40 +499,42 @@ yylex()
 
        do {
                /* Ignore whitespace at the beginning */
-               while ((ch = get_next_char()) != EOF &&
+               while (EOF != (ch = get_next_char()) &&
                       isspace(ch) &&
                       !is_EOC(ch))
                        ; /* Null Statement */
 
-               if (ch == EOF) {
-                       if (input_from_file == 0)
-                               return 0;
-                       if (!(curr_include_level > 0)) 
+               if (EOF == ch) {
+
+                       if (!input_from_file || !curr_include_level) 
                                return 0;
-                       else { 
-                               FCLOSE(fp[curr_include_level]);
-                               ip_file = fp[--curr_include_level]; 
-                               return T_EOC;
-                       }
+
+                       FCLOSE(fp[curr_include_level]);
+                       ip_file = fp[--curr_include_level]; 
+                       return T_EOC;
+
                } else if (is_EOC(ch)) {
+
                        expect_string = NO_ARG;   /* Reset expect_string */
                        return T_EOC;
-               }
-               /* Check if the next character is a special character.
-                * If yes, return the special character.
-                */
-               else if ((expect_string == NO_ARG) && is_special(ch))
+
+               } else if (is_special(ch) && NO_ARG == expect_string)
+                       /* special chars are their own token values */
                        return ch;
                else
                        push_back_char(ch);
 
+               /* save the column of start of the token */
+               ip_file->prev_token_col_no = ip_file->col_no;
+
                /* Read in the lexeme */
-               for (i = 0;(i < MAX_LEXEME) && 
-                        (yytext[i] = get_next_char()) != EOF; ++i) {
+               for (i = 0;
+                    (i < MAX_LEXEME) && EOF != (yytext[i] = get_next_char());
+                    i++) {
 
                        /* Break on whitespace or a special character */
                        if (isspace(yytext[i]) 
-                           || ((expect_string == NO_ARG) && is_special(yytext[i]))
+                           || (is_special(yytext[i]) && NO_ARG == expect_string)
                            || is_EOC(ch) || yytext[i] == '"')
                                break;
 
@@ -597,10 +575,7 @@ yylex()
                yytext[i] = '\0';
        } while (i == 0);
 
-#ifdef DEBUG
-       if (debug >= 3)
-               printf ("yylex: Just Read: %s\n", yytext);
-#endif
+       DPRINTF(4, ("yylex: lexeme '%s'\n", yytext));
 
        /* Now return the desired token */
        
@@ -615,9 +590,10 @@ yylex()
                        return token;
                else if (is_integer(yytext)) {
                        errno = 0;
-                       if ((yylval.Integer = strtol(yytext,(char **) NULL, 10)) == 0
+                       if ((yylval.Integer = strtol(yytext, NULL, 10)) == 0
                            && ((errno == EINVAL) || (errno == ERANGE))) {
-                               fprintf(stderr,"Integer cannot be represented: %s\n",
+                               msyslog(LOG_ERR, 
+                                       "Integer cannot be represented: %s",
                                        yytext);
                                exit(1);
                        }
@@ -627,7 +603,8 @@ yylex()
                else if (is_double(yytext)) {
                        errno = 0;
                        if ((yylval.Double = atof(yytext)) == 0 && errno == ERANGE) {
-                               fprintf(stderr, "Double too large to represent: %s\n",
+                               msyslog(LOG_ERR,
+                                       "Double too large to represent: %s",
                                        yytext);
                                exit(1);
                        }
@@ -637,23 +614,38 @@ yylex()
                else /* Default: Everything is a string */
                        return create_string_token(yytext);
        }
-       else { 
-               /* Either expect_string is 1 or this lexeme is part of a string.
-                  Hence, we need to return T_String.
-                  
-                  ONLY EXCEPTION (sic), we might have a -4 or -6 flag.
-                  This is a terrible hack, but the grammar is ambiguous so
-                  we don't have a choice.
-               */
-               if (strcmp(yytext, "-4") == 0)
-                       return T_IPv4_address;
-               else if (strcmp(yytext, "-6") == 0)
-                       return T_IPv6_address;
-               else {
-                       instring = 0;
-                       if (expect_string == SINGLE_ARG)
-                               expect_string = NO_ARG;
-                       return create_string_token(yytext);
-               }
+
+       /*
+        * Either expect_string is 1 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.).
+        *
+        * This is a terrible hack, but the grammar is ambiguous so we
+        * don't have a choice.  [SK]
+        *
+        * The ambiguity is in the keyword scanner, not ntp_parser.y.
+        * 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.
+        * restrict -4 and restrict -6 parsing works correctly without
+        * this hack, as restrict uses NO_ARG.  [DH]
+        */
+       if ('-' == yytext[0]) {
+               if ('4' == yytext[1])
+                       return T_IPv4_flag;
+               else if ('6' == yytext[1])
+                       return T_IPv6_flag;
        }
+
+       instring = 0;
+       if (SINGLE_ARG == expect_string)
+               expect_string = NO_ARG;
+
+       return create_string_token(yytext);
 }
index 0269402925b138e60b24229078bfba30aaec191a..31c16a76b3f3d295ecf373c3c8aa9b4f878d52cd 100644 (file)
@@ -2,9 +2,9 @@
  *
  * The header file for a simple lexical analyzer. 
  *
- * Written By: Sachin Kamboj
- *             University of Delaware
- *             Newark, DE 19711
+ * Written By: Sachin Kamboj
+ *             University of Delaware
+ *             Newark, DE 19711
  * Copyright (c) 2006
  */
 
 
 /* Define a structure to hold a (keyword, token) pair */
 struct key_tok {
-    char *keyword;             /* Keyword */
-    int token;                 /* Associated Token */
-    int expect_string;         /* A boolean flag, which when set, indicates
-                                  that the next token should be a string */
+       char *  keyword;        /* Keyword */
+       int     token;          /* Associated Token */
+       int     expect_string;  /* nonzero indicates the next token
+                                  should be a string */
 };
 
 /* Structure to hold a filename, file pointer and positional info */
 struct FILE_INFO {
-    const char *fname;        /* Path to the file */
-    FILE *fd;                  /* File Descriptor */
-    int line_no;               /* Line Number in the file being scanned */
-    int col_no;                /* Column Number in the file being scanned */
-    int prev_line_col_no;      /* Col No on the previous line when a '\n' is
-                                  seen */
+       const char *    fname;                  /* Path to the file */
+       FILE *          fd;                     /* File Descriptor */
+       int             line_no;                /* Line Number */
+       int             col_no;                 /* Column Number */
+       int             prev_line_col_no;       /* Col No on the 
+                                                  previous line when a
+                                                  '\n' was seen */
+       int             prev_token_col_no;      /* Col No at start of
+                                                  token */
 };
 
 
index 9109b3ce7f2b3381131f85045cd10c3984954348..01e837451816780be54626a0c452e7f5db5cf17a 100644 (file)
@@ -391,32 +391,20 @@ stats_config(
         * Open and read frequency file.
         */
        case STATS_FREQ_FILE:
-               if (stats_drift_file) {
-                       free(stats_drift_file);
-                       free(stats_temp_file);
-                       stats_drift_file = NULL;
-                       stats_temp_file = NULL;
-               }
+               if (!value || (len = strlen(value)) == 0)
+                       break;
 
-               if (value == 0 || (len = strlen(value)) == 0)
-                   break;
+               stats_drift_file = erealloc(stats_drift_file, len + 1);
+               stats_temp_file = erealloc(stats_temp_file, 
+                                          len + sizeof(".TEMP"));
 
-               stats_drift_file = (char*)emalloc((u_int)(len + 1));
-#if !defined(VMS)
-               stats_temp_file = (char*)emalloc((u_int)(len +
-                   sizeof(".TEMP")));
-#else
-               stats_temp_file = (char*)emalloc((u_int)(len +
-                   sizeof("-TEMP")));
-#endif /* VMS */
                memmove(stats_drift_file, value, (unsigned)(len+1));
                memmove(stats_temp_file, value, (unsigned)len);
+               memmove(stats_temp_file + len,
 #if !defined(VMS)
-               memmove(stats_temp_file + len, ".TEMP",
-                   sizeof(".TEMP"));
+                       ".TEMP", sizeof(".TEMP"));
 #else
-               memmove(stats_temp_file + len, "-TEMP",
-                   sizeof("-TEMP"));
+                       "-TEMP", sizeof("-TEMP"));
 #endif /* VMS */
 
                /*
@@ -428,8 +416,8 @@ stats_config(
 
                if (fscanf(fp, "%lf", &old_drift) != 1) {
                        msyslog(LOG_ERR,
-                           "format error frequency file %s", 
-                           stats_drift_file);
+                               "format error frequency file %s", 
+                               stats_drift_file);
                        fclose(fp);
                        break;
 
@@ -1015,29 +1003,24 @@ getauthkeys(
        int len;
 
        len = strlen(keyfile);
-       if (len == 0)
+       if (!len)
                return;
        
-       if (key_file_name != NULL) {
-               free(key_file_name);
-               key_file_name = NULL;
-       }
-       if (key_file_name == NULL) {
 #ifndef SYS_WINNT
-               key_file_name = emalloc(len + 1);
-#else
-               key_file_name = emalloc(MAXPATHLEN);
-#endif
-       }
-#ifndef SYS_WINNT
-       memmove(key_file_name, keyfile, len + 1);
+       key_file_name = erealloc(key_file_name, len + 1);
+       memmove(key_file_name, keyfile, len + 1);
 #else
+       key_file_name = erealloc(key_file_name, _MAX_PATH);
+       if (len + 1 > _MAX_PATH)
+               return;
        if (!ExpandEnvironmentStrings(keyfile, key_file_name,
-           MAXPATHLEN)) {
+                                     _MAX_PATH)) {
                msyslog(LOG_ERR,
-                   "ExpandEnvironmentStrings(KEY_FILE) failed: %m\n");
+                       "ExpandEnvironmentStrings(KEY_FILE) failed: %m");
+               strncpy(key_file_name, keyfile, _MAX_PATH);
        }
 #endif /* SYS_WINNT */
+
        authreadkeys(key_file_name);
 }
 
@@ -1048,7 +1031,7 @@ getauthkeys(
 void
 rereadkeys(void)
 {
-       if (key_file_name != NULL)
+       if (NULL != key_file_name)
                authreadkeys(key_file_name);
 }
 
@@ -1093,9 +1076,12 @@ sock_hash(
 
        for (i = 0; i < len ; i++)
                hashVal = 37 * hashVal + (int)*(ch + i);
-       hashVal = hashVal % 128;  /* % MON_HASH_SIZE hardcoded */
+
+#define        MON_HASH_SIZE   128     /* duplicated from ntp_monitor.c */
+
+       hashVal = hashVal % MON_HASH_SIZE;
        if (hashVal < 0)
-               hashVal += 128;
+               hashVal += MON_HASH_SIZE;
        return hashVal;
 }
 
@@ -1116,18 +1102,22 @@ ntp_exit(int retval)
  * fstostr - prettyprint NTP seconds
  */
 char * fstostr(
-       time_t  fstamp
+       time_t  ntp_stamp
        )
 {
-       struct tm *tm = NULL;
-       static char str[20] = { '\0' };
-       time_t  ustamp;
-
-       ustamp = fstamp - JAN_1970;
-       tm = gmtime(&ustamp);
-       if (tm != NULL)
-               snprintf(str, sizeof(str), "%04d%02d%02d%02d%02d",
-                   tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
-                   tm->tm_hour, tm->tm_min);
-       return (str);
+       static char     str[20];
+       struct tm *     tm;
+       time_t          unix_stamp;
+
+       unix_stamp = ntp_stamp - JAN_1970;
+       tm = gmtime(&unix_stamp);
+       if (NULL != tm)
+               snprintf(str, sizeof(str),
+                        "%04d%02d%02d%02d%02d",
+                        tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+                        tm->tm_hour, tm->tm_min);
+       else
+               strcpy(str, "gmtime() error");
+
+       return str;
 }
index db29283f6e92b4ec62759cdbd26e0caec6f3935c..b1249dd4ebdaac6b96411018fb643dd74b74c782 100644 (file)
@@ -1,5 +1,5 @@
-#if !defined(_WIN32_IO_)
-#define _WIN32_IO_
+#ifndef WIN32_IO_H
+#define WIN32_IO_H
 
 /*  Flag definitions for compatibility
  *  ==================================
@@ -7,23 +7,23 @@
 
 #include <fcntl.h>
 
-#define NCCS 4
-#define VEOL 3
+#define NCCS   4
+#define VEOL   3
 typedef unsigned char  cc_t;
 typedef unsigned int   speed_t;
 typedef unsigned int   tcflag_t;
 
 struct termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_line;                       /* line discipline */
-    cc_t c_cc[NCCS];           /* control characters */ 
-    speed_t c_ispeed;          /* input speed */
-    speed_t c_ospeed;          /* output speed */
-  };
+{
+       tcflag_t        c_iflag;        /* input mode flags */
+       tcflag_t        c_oflag;        /* output mode flags */
+       tcflag_t        c_cflag;        /* control mode flags */
+       tcflag_t        c_lflag;        /* local mode flags */
+       cc_t            c_line;         /* line discipline */
+       cc_t            c_cc[NCCS];     /* control characters */ 
+       speed_t         c_ispeed;       /* input speed */
+       speed_t         c_ospeed;       /* output speed */
+};
 
 /* c_cc characters 
 #define VINTR 0
@@ -70,68 +70,79 @@ struct termios
 #define ONLRET 0000040
 #define OFILL  0000100
 #define OFDEL  0000200
+
 #define NLDLY  0000400
-#define   NL0  0000000
-#define   NL1  0000400
+#define NL0    0000000
+#define NL1    0000400
+
 #define CRDLY  0003000
-#define   CR0  0000000
-#define   CR1  0001000
-#define   CR2  0002000
-#define   CR3  0003000
+#define CR0    0000000
+#define CR1    0001000
+#define CR2    0002000
+#define CR3    0003000
+
 #define TABDLY 0014000
-#define   TAB0 0000000
-#define   TAB1 0004000
-#define   TAB2 0010000
-#define   TAB3 0014000
-#define   XTABS        0014000
+#define TAB0   0000000
+#define TAB1   0004000
+#define TAB2   0010000
+#define TAB3   0014000
+#define XTABS  0014000
+
 #define BSDLY  0020000
-#define   BS0  0000000
-#define   BS1  0020000
+#define BS0    0000000
+#define BS1    0020000
+
 #define VTDLY  0040000
-#define   VT0  0000000
-#define   VT1  0040000
+#define VT0    0000000
+#define VT1    0040000
+
 #define FFDLY  0100000
-#define   FF0  0000000
-#define   FF1  0100000
+#define FF0    0000000
+#define FF1    0100000
 
 /* c_cflag bit meaning */
 #define CBAUD  0010017
-#define  B0    0000000         /* hang up */
-#define  B50   0000001
-#define  B75   0000002
-#define  B110  0000003
-#define  B134  0000004
-#define  B150  0000005
-#define  B200  0000006
-#define  B300  0000007
-#define  B600  0000010
-#define  B1200 0000011
-#define  B1800 0000012
-#define  B2400 0000013
-#define  B4800 0000014
-#define  B9600 0000015
-#define  B19200        0000016
-#define  B38400        0000017
-#define EXTA B19200
-#define EXTB B38400
+#define B0     0000000         /* hang up */
+#define B50    0000001
+#define B75    0000002
+#define B110   0000003
+#define B134   0000004
+#define B150   0000005
+#define B200   0000006
+#define B300   0000007
+#define B600   0000010
+#define B1200  0000011
+#define B1800  0000012
+#define B2400  0000013
+#define B4800  0000014
+#define B9600  0000015
+#define B19200 0000016
+#define B38400 0000017
+
+#define EXTA   B19200
+#define EXTB   B38400
+
 #define CSIZE  0000060
-#define   CS5  0000000
-#define   CS6  0000020
-#define   CS7  0000040
-#define   CS8  0000060
+#define CS5    0000000
+#define CS6    0000020
+#define CS7    0000040
+#define CS8    0000060
+
 #define CSTOPB 0000100
 #define CREAD  0000200
 #define PARENB 0000400
 #define PARODD 0001000
 #define HUPCL  0002000
 #define CLOCAL 0004000
+
 #define CBAUDEX 0010000
-#define  B57600  0010001
-#define  B115200 0010002
-#define  B230400 0010003
-#define  B460800 0010004
-#define CIBAUD   002003600000  /* input baud rate (not used) */
-#define CRTSCTS          020000000000          /* flow control */
+#define B57600  0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+
+#define CIBAUD 002003600000    /* input baud rate (not used) */
+#define CRTSCTS        020000000000    /* flow control */
 
 /* c_lflag bits */
 #define ISIG   0000001
@@ -167,38 +178,37 @@ struct termios
 #define        TCSAFLUSH       2
 
 /* modem lines */
-#define TIOCM_LE        0x001
-#define TIOCM_DTR       0x002
-#define TIOCM_RTS       0x004
-#define TIOCM_ST        0x008
-#define TIOCM_SR        0x010
-#define TIOCM_CTS       0x020
-#define TIOCM_CAR       0x040
-#define TIOCM_RNG       0x080
-#define TIOCM_DSR       0x100
-#define TIOCM_CD        TIOCM_CAR
-#define TIOCM_RI        TIOCM_RNG
-#define TIOCM_OUT1      0x2000
-#define TIOCM_OUT2      0x4000
+#define TIOCM_LE       0x001
+#define TIOCM_DTR      0x002
+#define TIOCM_RTS      0x004
+#define TIOCM_ST       0x008
+#define TIOCM_SR       0x010
+#define TIOCM_CTS      0x020
+#define TIOCM_CAR      0x040
+#define TIOCM_RNG      0x080
+#define TIOCM_DSR      0x100
+#define TIOCM_CD       TIOCM_CAR
+#define TIOCM_RI       TIOCM_RNG
+#define TIOCM_OUT1     0x2000
+#define TIOCM_OUT2     0x4000
 
 /* ioctl */
-#define TIOCMGET        0x5415
-#define TIOCMSET        0x5418       
-/*
-#define cfgetospeed(dcb) dcb->BaudRate
-#define cfgetispeed(dcb) dcb->BaudRate
-#define cfsetospeed(dcb,speed) (dcb->BaudRate = (speed), 0)
-#define cfsetispeed(dcb,speed) (dcb->BaudRate = (speed), 0)
+#define TIOCMGET       0x5415
+#define TIOCMSET       0x5418
 
+/* NOP cfsetospeed() and cfsetispeed() for now */
+#define cfsetospeed(dcb, spd)  (0)
+#define cfsetispeed(dcb, spd)  (0)
 
 
+
+#if 0
 extern BOOL    TTY_GETATTR (int fd, DCB *tio);
 extern BOOL    TTY_SETATTR (int fd, const DCB *tio);
+#endif
 
-*/
-
-extern int ioctl               (int, int, int *);
-extern int     tcsetattr       (int fd, int optional_actions, const struct termios *);
-extern int     tcgetattr       (int fd, struct termios *);
-#endif /* defined _WIN32_IO_ */
+extern int     ioctl           (int, int, int *);
+extern int     tcsetattr       (int, int, const struct termios *);
+extern int     tcgetattr       (int, struct termios *);
 
+#endif /* defined WIN32_IO_H */
index 07ba3bfe7b3e2e7e4710cce354b0877461e21dbe..920acc2020ce56c074da77f452268d88b8998e92 100644 (file)
@@ -193,9 +193,6 @@ do {        \
        (t) -= HECTONANOSECONDS / 2;    \
 } while (0)
 
-/* there must be a better place for this */
-#define COUNTOF(arr) (sizeof(arr) / sizeof((arr)[0]))
-
 /*
  * workaround for VC6 inability to convert unsigned __int64 to double
  */
index b255b79ace60c3e9c2a2a6eda60136053e79d57a..d39cba5982ca575cca35faef3db7046cf2e444dd 100644 (file)
  * common_serial_open ensures duplicate opens of the same port
  * work by duplicating the handle for the 2nd open, allowing
  * refclock_atom to share a GPS refclock's comm port.
- *
  */
 
 HANDLE common_serial_open(
        char *dev
        )
 {
-       /* SerialHandles[0] is unused, hence MAX_SERIAL + 1 */
-       static HANDLE SerialHandles[MAX_SERIAL + 1] = {0};
-       HANDLE RetHandle;
-       int unit;
+       static HANDLE * hnds = NULL;    /* handle array */
+       static int      c_hnd = 0;      /* current array size */
+       HANDLE          handle;
+       int             unit;
+       int             prev_c_hnd;
 
        if (1 != sscanf(dev, "COM%d:", &unit) || unit > MAX_SERIAL)
                return INVALID_HANDLE_VALUE;
 
-       if (!SerialHandles[unit])
-               SerialHandles[unit] = CreateFile(
-                                       dev,
-                                       GENERIC_READ | GENERIC_WRITE,
-                                       0, /* sharing prohibited */
-                                       NULL, /* default security */
-                                       OPEN_EXISTING,
-                                       FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
-                                       NULL);
-
-       if (INVALID_HANDLE_VALUE == SerialHandles[unit]) {
-               SerialHandles[unit] = 0;
-               return INVALID_HANDLE_VALUE;
+       if (c_hnd < unit + 1) {
+               prev_c_hnd = c_hnd;
+               c_hnd = unit + 1;
+               /* round up to closest multiple of 4 to avoid churn */
+               c_hnd = (c_hnd + 3) & ~3;
+               hnds = erealloc(hnds, c_hnd * sizeof hnds[0]);
+               memset(&hnds[prev_c_hnd], 0, 
+                      (c_hnd - prev_c_hnd) * sizeof hnds[0]);
        }
 
-       DuplicateHandle(
-               GetCurrentProcess(),
-               SerialHandles[unit],
-               GetCurrentProcess(),
-               &RetHandle,
-               0,
-               FALSE,
-               DUPLICATE_SAME_ACCESS
-               );
-
-       return RetHandle;
+       if (NULL == hnds[unit])
+               hnds[unit] = 
+                       CreateFile(
+                               dev,
+                               GENERIC_READ | GENERIC_WRITE,
+                               0, /* sharing prohibited */
+                               NULL, /* default security */
+                               OPEN_EXISTING,
+                               FILE_ATTRIBUTE_NORMAL
+                                   | FILE_FLAG_OVERLAPPED,
+                               NULL);
+
+       if (INVALID_HANDLE_VALUE == hnds[unit]) {
+               hnds[unit] = NULL;
+               handle = INVALID_HANDLE_VALUE;
+       } else
+               DuplicateHandle(
+                       GetCurrentProcess(),
+                       hnds[unit],
+                       GetCurrentProcess(),
+                       &handle,
+                       0,
+                       FALSE,
+                       DUPLICATE_SAME_ACCESS
+                       );
+
+       return handle;
 }
 
 /*
@@ -74,10 +85,12 @@ int pps_open(
        )
 {
        HANDLE Handle;
-       char windev[3 + 20 + 1 + 1];
+       char windev[3 + 3 + 1 + 1];     /* COM255:\0 */
        int unit;
 
-       if (1 != sscanf(dev, "/dev/pps%d", &unit)) {
+       if (1 != sscanf(dev, "/dev/pps%d", &unit)
+           || unit > MAX_SERIAL) {
+
                errno = ENOENT;
                return -1;
        }
@@ -106,55 +119,83 @@ int pps_open(
  * refclock_open - open serial port for reference clock
  *
  * This routine opens a serial port for I/O and sets default options. It
- * returns the file descriptor if success and zero if failure.
+ * returns the file descriptor or -1 indicating failure.
  */
 int refclock_open(
-       char *dev,              /* device name pointer */
-       u_int speed,            /* serial port speed (code) */
-       u_int flags             /* line discipline flags */
+       char *  dev,            /* device name pointer */
+       u_int   speed,          /* serial port speed (code) */
+       u_int   flags           /* line discipline flags */
        )
 {
-       HANDLE Handle = INVALID_HANDLE_VALUE;
-       COMMTIMEOUTS timeouts;
-       DCB dcb;
+       HANDLE          h;
+       COMMTIMEOUTS    timeouts;
+       DCB             dcb;
 
        /*
         * open communication port handle
         */
-       Handle = common_serial_open(dev);
+       h = common_serial_open(dev);
 
-       if (Handle == INVALID_HANDLE_VALUE) {  
-                
-               msyslog(LOG_ERR, "NT_COM: Device %s CreateFile error: %m", dev);
+       if (INVALID_HANDLE_VALUE == h) {  
+               msyslog(LOG_ERR, "Device %s CreateFile error: %m", dev);
                return -1;
        }
 
-       /*  Change the input/output buffers to be large.
-       */
-       if (!SetupComm( Handle, 1024, 1024)) {
-               msyslog(LOG_ERR, "NT_COM: Device %s SetupComm error: %m", dev);
+       /* Change the input/output buffers to be large. */
+       if (!SetupComm(h, 1024, 1024)) {
+               msyslog(LOG_ERR, "Device %s SetupComm error: %m", dev);
                return -1;
        }
 
        dcb.DCBlength = sizeof(dcb);
-       if (!GetCommState(Handle, &dcb)) {
-               // Error getting current DCB settings
-               msyslog(LOG_ERR, "NT_COM: Device %s GetCommState error: %m", dev);
+
+       if (!GetCommState(h, &dcb)) {
+               msyslog(LOG_ERR, "Device %s GetCommState error: %m",
+                                dev);
                return -1;
        }
 
        switch (speed) {
-         case B300 :   dcb.BaudRate = 300; break;
-         case B1200 :  dcb.BaudRate = 1200; break;
-         case B2400 :  dcb.BaudRate = 2400; break;
-         case B4800 :  dcb.BaudRate = 4800; break;
-         case B9600 :  dcb.BaudRate = 9600; break;
-         case B19200 : dcb.BaudRate = 19200; break;
-         case B38400 : dcb.BaudRate = 38400; break;
-         case B57600 : dcb.BaudRate = 57600; break;
-         case B115200 : dcb.BaudRate = 115200; break;
-         default :
-               msyslog(LOG_ERR, "NT_COM: Device %s unsupported baud rate", dev);
+
+       case B300:
+               dcb.BaudRate = 300;
+               break;
+
+       case B1200:  
+               dcb.BaudRate = 1200;
+               break;
+
+       case B2400:
+               dcb.BaudRate = 2400;
+               break;
+
+       case B4800:
+               dcb.BaudRate = 4800;
+               break;
+
+       case B9600:
+               dcb.BaudRate = 9600;
+               break;
+
+       case B19200:
+               dcb.BaudRate = 19200;
+               break;
+
+       case B38400:
+               dcb.BaudRate = 38400;
+               break;
+
+       case B57600:
+               dcb.BaudRate = 57600;
+               break;
+
+       case B115200:
+               dcb.BaudRate = 115200;
+               break;
+
+       default:
+               msyslog(LOG_ERR, "Device %s unsupported baud rate "
+                                "code %u", dev, speed);
                return -1;
        }
 
@@ -170,7 +211,7 @@ int refclock_open(
        dcb.fInX = 0;
        dcb.fErrorChar = 0;
        dcb.fNull = 0;
-       dcb.fRtsControl = RTS_CONTROL_DISABLE; // RTS_CONTROL_DISABLE;
+       dcb.fRtsControl = RTS_CONTROL_DISABLE;
        dcb.fAbortOnError = 0;
        dcb.ByteSize = 8;
        dcb.StopBits = ONESTOPBIT;
@@ -179,14 +220,14 @@ int refclock_open(
        dcb.EvtChar = 13; /* CR */
        dcb.EofChar = 0;
 
-       if (!SetCommState(Handle, &dcb)) {
-               msyslog(LOG_ERR, "NT_COM: Device %s SetCommState error: %m", dev);
+       if (!SetCommState(h, &dcb)) {
+               msyslog(LOG_ERR, "Device %s SetCommState error: %m", dev);
                return -1;
        }
 
        /* watch out for CR (dcb.EvtChar) as well as the CD line */
-       if (!SetCommMask(Handle, EV_RXFLAG | EV_RLSD)) {
-               msyslog(LOG_ERR, "NT_COM: Device %s SetCommMask error: %m", dev);
+       if (!SetCommMask(h, EV_RXFLAG | EV_RLSD)) {
+               msyslog(LOG_ERR, "Device %s SetCommMask error: %m", dev);
                return -1;
        }
 
@@ -197,197 +238,374 @@ int refclock_open(
        timeouts.WriteTotalTimeoutMultiplier = 0;
        timeouts.WriteTotalTimeoutConstant = 0;
 
-       if (!SetCommTimeouts(Handle, &timeouts)) {
-               msyslog(LOG_ERR, "NT_COM: Device %s SetCommTimeouts error: %m", dev);
+       if (!SetCommTimeouts(h, &timeouts)) {
+               msyslog(LOG_ERR, "Device %s SetCommTimeouts error: %m", dev);
                return -1;
        }
 
-       return (int) _open_osfhandle((int)Handle, _O_TEXT);
+       return (int)_open_osfhandle((int)h, _O_TEXT);
 }
 
-int 
-ioctl(int fd,
-       int cmd,
-       int *x)
+
+int
+ioctl_tiocmget(
+       HANDLE h,
+       int *pi
+       )
 {
-       HANDLE h = (HANDLE) _get_osfhandle(fd);
+       DWORD   dw;
 
-       if ((cmd == TIOCMSET) && (*x & TIOCM_RTS)) {
-               if (!EscapeCommFunction(h, SETRTS)) 
-                       return -1;
-       }
-       else if ((cmd == TIOCMSET) && !(*x & TIOCM_RTS)){
-               if (!EscapeCommFunction(h, CLRRTS)) 
-                       return -1;
+       if (!GetCommModemStatus(h, &dw)) {
+               errno = ENOTTY;
+               return -1;
        }
-       if ((cmd == TIOCMSET) && (*x & TIOCM_DTR)) {
-               if (!EscapeCommFunction(h, SETDTR)) 
-                       return -1;
+
+       *pi = ((dw & MS_CTS_ON)  ? TIOCM_CTS : 0)
+           | ((dw & MS_DSR_ON)  ? TIOCM_DSR : 0)
+           | ((dw & MS_RLSD_ON) ? TIOCM_CAR : 0)
+           | ((dw & MS_RING_ON) ? TIOCM_RI  : 0);
+
+       return 0;
+}
+
+
+int
+ioctl_tiocmset(
+       HANDLE h,
+       int *pi
+       )
+{
+       BOOL    failed;
+       int     result;
+       
+       failed = EscapeCommFunction(
+                       h, 
+                       (*pi & TIOCM_RTS) 
+                           ? SETRTS
+                           : CLRRTS
+                       );
+
+       if (!failed)
+               failed = EscapeCommFunction(
+                               h, 
+                               (*pi & TIOCM_DTR) 
+                                   ? SETDTR
+                                   : CLRDTR
+                               );
+
+       if (failed) {
+               errno = ENOTTY;
+               result = -1;
+       } else
+               result = 0;
+
+       return result;
+}
+
+
+int 
+ioctl(
+       int fd,
+       int op,
+       int *pi
+       )
+{
+       HANDLE  h;
+       int     result;
+       
+       h = (HANDLE)_get_osfhandle(fd);
+
+       if (INVALID_HANDLE_VALUE == h) {
+               /* errno already set */
+               return -1;
        }
-       else if ((cmd == TIOCMSET) && !(*x & TIOCM_DTR)){
-               if (!EscapeCommFunction(h, CLRDTR)) 
-                       return -1;
+
+       switch (op) {
+
+       case TIOCMGET:
+               result = ioctl_tiocmget(h, pi);
+               break;
+
+       case TIOCMSET:
+               result = ioctl_tiocmset(h, pi);
+               break;
+
+       default:
+               errno = EINVAL;
+               result = -1;
        }
 
-       return 0;
+       return result;
 }
 
 
 int    
 tcsetattr(
-       int fd, 
-       int optional_actions, 
-       const struct termios * s)
+       int                     fd, 
+       int                     optional_actions, 
+       const struct termios *  tios
+       )
 {
-       DCB dcb = { 0 };
-       HANDLE Handle = (HANDLE) _get_osfhandle(fd);
+       DCB dcb;
+       HANDLE h;
+
+       UNUSED_ARG(optional_actions);
+
+       h = (HANDLE)_get_osfhandle(fd);
+
+       if (INVALID_HANDLE_VALUE == h) {
+               /* errno already set */
+               return -1;
+       }
+
        dcb.DCBlength = sizeof(dcb);
-       if (!GetCommState(Handle, &dcb)) {
-               // Error getting current DCB settings
-               msyslog(LOG_ERR, "NT_COM: GetCommState error: %m");
-               return FALSE;
+       if (!GetCommState(h, &dcb)) {
+               errno = ENOTTY;
+               return -1;
        }
 
-       switch (max(s->c_ospeed, s->c_ispeed)) {
-               case B300 :   dcb.BaudRate = 300; break;
-               case B1200 :  dcb.BaudRate = 1200; break;
-               case B2400 :  dcb.BaudRate = 2400; break;
-               case B4800 :  dcb.BaudRate = 4800; break;
-               case B9600 :  dcb.BaudRate = 9600; break;
-               case B19200 : dcb.BaudRate = 19200; break;
-               case B38400 : dcb.BaudRate = 38400; break;
-               case B57600 : dcb.BaudRate = 57600; break;
-               case B115200 : dcb.BaudRate = 115200; break;
-               default :
-                       msyslog(LOG_ERR, "NT_COM: unsupported baud rate");
-                       return FALSE;
+       switch (max(tios->c_ospeed, tios->c_ispeed)) {
+
+       case B300:
+               dcb.BaudRate = 300;
+               break;
+
+       case B1200:
+               dcb.BaudRate = 1200;
+               break;
+
+       case B2400:
+               dcb.BaudRate = 2400;
+               break;
+
+       case B4800:
+               dcb.BaudRate = 4800;
+               break;
+
+       case B9600:
+               dcb.BaudRate = 9600;
+               break;
+
+       case B19200:
+               dcb.BaudRate = 19200;
+               break;
+
+       case B38400:
+               dcb.BaudRate = 38400;
+               break;
+
+       case B57600:
+               dcb.BaudRate = 57600;
+               break;
+
+       case B115200:
+               dcb.BaudRate = 115200;
+               break;
+
+       default:
+               msyslog(LOG_ERR, "unsupported serial baud rate");
+               errno = EINVAL;
+               return -1;
        }
 
-       switch (s->c_cflag & CSIZE) {
-               case CS5 : dcb.ByteSize = 5; break;
-               case CS6 : dcb.ByteSize = 6; break;
-               case CS7 : dcb.ByteSize = 7; break;
-               case CS8 : dcb.ByteSize = 8; break;
-               default :
-                       msyslog(LOG_ERR, "NT_COM: unsupported word size");
-                       return FALSE;
+       switch (tios->c_cflag & CSIZE) {
+
+       case CS5:
+               dcb.ByteSize = 5;
+               break;
+
+       case CS6:
+               dcb.ByteSize = 6;
+               break;
+
+       case CS7:
+               dcb.ByteSize = 7;
+               break;
+
+       case CS8:
+               dcb.ByteSize = 8;
+               break;
+
+       default:
+               msyslog(LOG_ERR, "unsupported serial word size");
+               errno = EINVAL;
+               return FALSE;
        }
 
-       if (s->c_cflag & PARENB) {
+       if (PARENB & tios->c_cflag) {
                dcb.fParity = TRUE;
-               if (s->c_cflag & PARODD) {
-                       dcb.Parity = ODDPARITY;
-               }
-               else {
-                       dcb.Parity = EVENPARITY;
-               }
-       }
-       else {
+               dcb.Parity = (tios->c_cflag & PARODD)
+                               ? ODDPARITY
+                               : EVENPARITY;
+       } else {
                dcb.fParity = FALSE;
                dcb.Parity = NOPARITY;
        }
-       if (s->c_cflag & CSTOPB ) {
-               dcb.StopBits = TWOSTOPBITS;
-       }
-       else {
-               dcb.StopBits = ONESTOPBIT;
-       }
 
-       if (!SetCommState(Handle, &dcb)) {
-               msyslog(LOG_ERR, "NT_COM: SetCommState error 2: %m");
-               return FALSE;
+       dcb.StopBits = (CSTOPB & tios->c_cflag)
+                       ? TWOSTOPBITS
+                       : ONESTOPBIT;
+
+       if (!SetCommState(h, &dcb)) {
+               errno = ENOTTY;
+               return -1;
        }
-       return TRUE;
+
+       return 0;
 }
 
-extern int     
+
+int
 tcgetattr(
-       int fd, struct termios *s)
+       int             fd,
+       struct termios *tios
+       )
 {
-       DCB dcb;
-       HANDLE Handle = (HANDLE) _get_osfhandle(fd);
+       DCB     dcb;
+       HANDLE  h;
+
+       h = (HANDLE)_get_osfhandle(fd);
+
+       if (INVALID_HANDLE_VALUE == h) {
+               /* errno already set */
+               return -1;
+       }
 
        dcb.DCBlength = sizeof(dcb);
-       if (!GetCommState(Handle, &dcb)) {
-               msyslog(LOG_ERR, "NT_COM: GetCommState error: %m");
-               return FALSE;
+
+       if (!GetCommState(h, &dcb)) {
+               errno = ENOTTY;
+               return -1;
        }
 
-       /*  Set c_ispeed & c_ospeed
-       */
+       /*  Set c_ispeed & c_ospeed */
+
        switch (dcb.BaudRate) {
-               case 300 : s->c_ispeed = s->c_ospeed = B300; break;
-               case 1200 : s->c_ispeed = s->c_ospeed = B1200; break;
-               case 2400 : s->c_ispeed = s->c_ospeed = B2400; break;
-               case 4800 : s->c_ispeed = s->c_ospeed = B4800; break;
-               case 9600 : s->c_ispeed = s->c_ospeed = B9600; break;
-               case 19200 : s->c_ispeed = s->c_ospeed = B19200; break;
-               case 38400 : s->c_ispeed = s->c_ospeed = B38400; break;
-               case 57600 : s->c_ispeed = s->c_ospeed = B57600; break;
-               case 115200 : s->c_ispeed = s->c_ospeed = B115200; break;
-               default : s->c_ispeed = s->c_ospeed = B9600;
+
+       case 300:
+               tios->c_ispeed = tios->c_ospeed = B300;
+               break;
+
+       case 1200: 
+               tios->c_ispeed = tios->c_ospeed = B1200;
+               break;
+
+       case 2400:
+               tios->c_ispeed = tios->c_ospeed = B2400;
+               break;
+
+       case 4800: 
+               tios->c_ispeed = tios->c_ospeed = B4800;
+               break;
+
+       case 9600:
+               tios->c_ispeed = tios->c_ospeed = B9600;
+               break;
+
+       case 19200:
+               tios->c_ispeed = tios->c_ospeed = B19200;
+               break;
+
+       case 38400:
+               tios->c_ispeed = tios->c_ospeed = B38400;
+               break;
+
+       case 57600:
+               tios->c_ispeed = tios->c_ospeed = B57600;
+               break;
+
+       case 115200:
+               tios->c_ispeed = tios->c_ospeed = B115200;
+               break;
+
+       default:
+               tios->c_ispeed = tios->c_ospeed = B9600;
        }
        
 
-       s->c_cflag = 0;
        switch (dcb.ByteSize) {
-               case 5 : s->c_cflag |= CS5; break;
-               case 6 : s->c_cflag |= CS6; break;
-               case 7 : s->c_cflag |= CS7; break;
-               case 8 : s->c_cflag |= CS8; break;
+               case 5:
+                       tios->c_cflag = CS5;
+                       break;
+
+               case 6:
+                       tios->c_cflag = CS6;
+                       break;
+
+               case 7: 
+                       tios->c_cflag = CS7; 
+                       break;
+
+               case 8:
+               default:
+                       tios->c_cflag = CS8;
        }
+
        if (dcb.fParity) {
-                 s->c_cflag |= PARENB;
-       }
-       switch (dcb.Parity) {
-               case EVENPARITY : break;
-               case MARKPARITY : break;
-               case NOPARITY : break;
-               case ODDPARITY : s->c_cflag |= PARODD; break;
-               case SPACEPARITY : break;
-       }
-       switch (dcb.StopBits) {
-               case ONESTOPBIT : break;
-               case ONE5STOPBITS : break;
-               case TWOSTOPBITS : s->c_cflag |= CSTOPB; break;
+               tios->c_cflag |= PARENB;
+
+               if (ODDPARITY == dcb.Parity)
+                       tios->c_cflag |= PARODD;
        }
 
-       s->c_iflag = 0;
-       s->c_lflag = 0;
-       s->c_line = 0;
-       s->c_oflag = 0;
+       if (TWOSTOPBITS == dcb.StopBits)
+               tios->c_cflag |= CSTOPB;
+
+       tios->c_iflag = 0;
+       tios->c_lflag = 0;
+       tios->c_line = 0;
+       tios->c_oflag = 0;
 
-       return TRUE; /* ok */
+       return 0;
 }
 
 
-extern int tcflush(int fd, int mode) {
-       int Result = 0;
-       HANDLE h = (HANDLE) _get_osfhandle(fd);
-       switch ( mode ) {
+int
+tcflush(
+       int fd,
+       int mode
+       )
+{
+       HANDLE  h;
+       BOOL    success;
+       DWORD   flags;
+       int     result;
+
+       h = (HANDLE)_get_osfhandle(fd);
+
+       if (INVALID_HANDLE_VALUE == h) {
+               /* errno already set */
+               return -1;
+       }
+
+       switch (mode) {
+
        case TCIFLUSH:
-               Result = PurgeComm(h, PURGE_RXCLEAR);
+               flags = PURGE_RXCLEAR;
                break;
+
        case TCOFLUSH:
-               Result = PurgeComm(h, PURGE_TXABORT);
+               flags = PURGE_TXABORT;
                break;
+
        case TCIOFLUSH:
-               Result = PurgeComm(h, PURGE_RXCLEAR | PURGE_TXABORT);
+               flags = PURGE_RXCLEAR | PURGE_TXABORT;
                break;
-       }
-       if ( Result == 0 ) return -1;   /* failed */
-       else return 0;                                  /* successful */
-}
-
-
-extern int cfsetispeed(struct termios *tio, int speed) {
 
-return 0;              
-};     
+       default:
+               errno = EINVAL;
+               return -1;
+       }
 
+       success = PurgeComm(h, flags);
 
-extern int cfsetospeed(struct termios *tio, int speed) {
+       if (success)
+               result = 0;
+       else {
+               errno = ENOTTY;
+               result = -1;
+       }
 
-return 0;              
-};     
+       return result;
+}