Update CommitLog build rule for bk 7.x repo format.
Provide ntpd thread names to debugger on Windows.
Remove dead code libntp/numtohost.c and its unit tests.
Remove class A, B, C IPv4 distinctions in netof().
bk: 64ecf42cHmsQzFVMjeGB_YW-iP22Pg
---
+* [Bug 3859] Use NotifyIpInterfaceChange on Windows ntpd. <hart@ntp.org>
* [Bug 3851] Drop pool server when no local address can reach it.
<hart@ntp.org>
* [Bug 3850] ntpq -c apeers breaks column formatting s2 w/refclock refid.
Fix the script checkHtmlFileDates. <burnicki@ntp.org>
* html/clockopt.html cleanup. <stenn@ntp.org>
* Add DSA, DSA-SHA, and SHA to tests/libntp/digests.c. <hart@ntp.org>
+* Provide ntpd thread names to debugger on Windows. <hart@ntp.org>
+* Remove dead code libntp/numtohost.c and its unit tests. <hart@ntp.org>
+* Remove class A, B, C IPv4 distinctions in netof(). <hart@ntp.org>
---
(4.2.8p17) 2023/06/06 Released by Harlan Stenn <stenn@ntp.org>
CommitLog: FRC.CommitLog
cd $(srcdir) \
&& $(PATH_TEST) -e CommitLog \
- -a SCCS/s.ChangeSet -ot CommitLog \
+ -a .bk/SCCS/ChangeSet,s -ot CommitLog \
|| scripts/build/genCommitLog
# HMS: The following seems to be a work-in-progress...
};
/*
- * Flags for interfaces
+ * Flags for network endpoints (interfaces or really addresses)
*/
#define INT_UP 0x001 /* Interface is up */
#define INT_PPP 0x002 /* Point-to-point interface */
-#define INT_LOOPBACK 0x004 /* the loopback interface */
+#define INT_LOOPBACK 0x004 /* ::1 or 127.0.0.1 */
#define INT_BROADCAST 0x008 /* can broadcast out this interface */
#define INT_MULTICAST 0x010 /* can multicast out this interface */
#define INT_BCASTOPEN 0x020 /* broadcast receive socket is open */
u_char status; /* peer status */
u_char new_status; /* under-construction status */
u_char reach; /* reachability register */
+ u_char filter_nextpt; /* index into filter shift register */
int flash; /* protocol error test tally bits */
u_long epoch; /* reference epoch */
int burst; /* packets remaining in burst */
int retry; /* retry counter */
int flip; /* interleave mode control */
- int filter_nextpt; /* index into filter shift register */
double filter_delay[NTP_SHIFT]; /* delay shift register */
double filter_offset[NTP_SHIFT]; /* offset shift register */
double filter_disp[NTP_SHIFT]; /* dispersion shift register */
u_int32 count; /* number of packets matched */
u_short rflags; /* restrict (accesslist) flags */
u_short mflags; /* match flags */
- short ippeerlimit; /* IP peer limit */
- int srvfuzrftpoll; /* server response: fuzz reftime */
+ short ippeerlimit; /* limit of associations matching */
u_long expire; /* valid until time */
union { /* variant starting here */
res_addr4 v4;
#define V6_SIZEOF_RESTRICT_U (offsetof(restrict_u, u) \
+ sizeof(res_addr6))
+/* restrictions for (4) a given address */
typedef struct r4addr_tag r4addr;
struct r4addr_tag {
u_short rflags; /* match flags */
short ippeerlimit; /* IP peer limit */
};
-char *build_iflags(u_int32 flags);
-char *build_mflags(u_short mflags);
-char *build_rflags(u_short rflags);
-
/*
* Restrict (Access) flags (rflags)
*/
#define MRU_ROW_LIMIT 256
/* similar datagrams per response limit for ntpd */
#define MRU_FRAGS_LIMIT 128
+
+/* found on POSIX systems in sysexit.h */
+#ifndef EX_SOFTWARE
+# define EX_SOFTWARE 70 /* internal software error */
+#endif
+
+
#endif /* NTP_H */
== (LOOPBACKADR & LOOPNETMASK)) \
&& SRCADR(srcadr) != LOOPBACKADR)
+#define IS_LOOPBACK_ADDR(psau) \
+ (IS_IPV4(psau) \
+ ? LOOPBACKADR == SRCADR(psau) \
+ : IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(psau)) \
+ )
#endif /* NTP_NET_H */
/*
* Poll Skew List Item
+ * u_in32 is large enough for sub and qty so long as NTP_MAXPOLL < 31
*/
-
+#if NTP_MAXPOLL >= 31
+#include "psl_item structure needs larger type"
+#endif
typedef struct psl_item_tag {
- int sub; /* int or short? unsigned is OK, but why? */
- int qty; /* int or short? unsigned is OK, but why? */
- int msk; /* int or short? unsigned is OK */
+ u_int32 sub;
+ u_int32 qty;
+ u_int32 msk;
} psl_item;
int get_pollskew(int, psl_item *);
#include "declcond.h" /* ntpd uses ntpd/declcond.h, others include/ */
#include "l_stdlib.h"
+#include "lib_strbuf.h"
#include "ntp_md5.h"
#include "ntp_net.h"
#include "ntp_debug.h"
extern int MD5authdecrypt (int type, const u_char *key, size_t klen,
u_int32 *pkt, size_t length, size_t size,
keyid_t keyno);
-extern u_int32 addr2refid(sockaddr_u *);
+extern u_int32 addr2refid (sockaddr_u *);
/* authkeys.c */
extern void MD5auth_setkey (keyid_t, int, const u_char *, size_t,
extern char * statustoa (int, int);
extern sockaddr_u * netof (sockaddr_u *);
extern char * numtoa (u_int32);
-extern char * numtohost (u_int32);
extern const char * socktoa (const sockaddr_u *);
extern const char * sockporttoa(const sockaddr_u *);
extern u_short sock_hash (const sockaddr_u *);
# define DPRINTF(lvl, arg) do {} while (0)
#endif
+/* clear bitflag only on DEBUG builds */
+#ifdef DEBUG
+# define CLEAR_BIT_IF_DEBUG(bit, flags) \
+ do { \
+ (flags) &= ~(bit); \
+ } while (FALSE)
+#else
+# define CLEAR_BIT_IF_DEBUG(bit, flags) \
+ do {} while (FALSE)
+#endif
+
/* nt_clockstuff.c */
#ifdef SYS_WINNT
extern void init_control (void);
extern void process_control (struct recvbuf *, int);
extern void report_event (int, struct peer *, const char *);
-extern int mprintf_event (int, struct peer *, const char *, ...)
- NTP_PRINTF(3, 4);
+extern int mprintf_event (int evcode, struct peer *p,
+ const char *fmt, ...) NTP_PRINTF(3, 4);
/* ntp_control.c */
/*
extern void enable_multicast_if (endpt *, sockaddr_u *);
extern void interface_update (interface_receiver_t, void *);
#ifndef HAVE_IO_COMPLETION_PORT
-extern void io_handler (void);
+extern void io_handler (void);
+#else
+extern void WINAPI ip_interface_changed(ULONG_PTR ctx);
#endif
extern void init_io (void);
extern void io_open_sockets (void);
extern void io_unsetbclient (void);
extern void io_multicast_add(sockaddr_u *);
extern void io_multicast_del(sockaddr_u *);
-extern void sendpkt (sockaddr_u *, struct interface *, int, struct pkt *, int);
+extern void sendpkt (sockaddr_u *dest, endpt * ep, int ttl,
+ struct pkt *pkt, int len);
extern isc_boolean_t is_linklocal(sockaddr_u *psau);
#ifdef DEBUG_TIMING
extern void collect_timing (struct recvbuf *, const char *, int, l_fp *);
#endif
#define latoa(pif) localaddrtoa(pif)
extern const char * localaddrtoa(endpt *);
+#ifdef DEBUG
+extern const char * iflags_str(u_int32 iflags);
+#endif
+
/* ntp_loopfilter.c */
extern void init_loopfilter(void);
extern void set_sys_leap (u_char);
extern u_long leapsec; /* seconds to next leap (proximity class) */
-extern int leapdif; /* TAI difference step at next leap second*/
+extern int leapdif; /* TAI difference step at next leap second */
extern int sys_orphan;
extern double sys_mindisp;
extern double sys_maxdist;
/* ntp_restrict.c */
extern void init_restrict (void);
extern void restrictions (sockaddr_u *, r4addr *);
-extern void hack_restrict (restrict_op, sockaddr_u *, sockaddr_u *,
- short, u_short, u_short, u_long);
+extern void hack_restrict (restrict_op op, sockaddr_u *resaddr,
+ sockaddr_u* resmask, short ippeerlimit,
+ u_short mflags, u_short rflags,
+ u_long expire);
extern void restrict_source (sockaddr_u *, int, u_long);
extern void dump_restricts (void);
+#ifdef DEBUG
+extern const char *resop_str (restrict_op op);
+extern const char *rflags_str (u_short rflags);
+extern const char *mflags_str (u_short mflags);
+#endif
+
/* ntp_timer.c */
extern void init_timer (void);
extern void reinit_timer (void);
extern void timer (void);
extern void timer_clr_stats (void);
-extern void timer_interfacetimeout (u_long);
-extern volatile int interface_interval;
+extern int endpt_scan_period; /* -U option default 301s */
+extern u_long endpt_scan_timer; /* next scan current_time */
extern u_long orphwait; /* orphan wait time */
#ifdef AUTOKEY
extern char *sys_hostname; /* host name */
extern void record_loop_stats (double, double, double, double, int);
extern void record_clock_stats (sockaddr_u *, const char *);
extern int mprintf_clock_stats(sockaddr_u *, const char *, ...)
- NTP_PRINTF(2, 3);
-extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid, int len, u_char *extra);
+ NTP_PRINTF(2, 3);
+extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr,
+ l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4,
+ int leap, int version, int mode,
+ int stratum, int ppoll, int precision,
+ double root_delay, double root_dispersion,
+ u_int32 refid, int len, u_char *extra);
extern void check_leap_file (int is_daily_check, u_int32 ntptime, const time_t * systime);
extern void record_crypto_stats (sockaddr_u *, const char *);
#ifdef DEBUG
extern void record_timing_stats (const char *);
+extern void append_flagstr(char *flagstr, size_t sz, const char *text);
#endif
extern char * fstostr(time_t); /* NTP timescale seconds */
/* ntpd.c */
extern void parse_cmdline_opts(int *, char ***);
+
+/* ntservice.c */
+#ifndef SYS_WINNT
+# define ntservice_isup() do {} while (FALSE)
+#endif
+
/*
* Signals we catch for debugging.
*/
extern u_long io_timereset; /* time counters were reset */
/* ntp_io.c */
-extern int disable_dynamic_updates;/* scan interfaces once only */
+extern int no_periodic_scan; /* no periodic net addr scans */
+extern int scan_addrs_once; /* no net addr rescans */
extern int nonlocal_v4_addr_up; /* should we try IPv4 pool? */
extern int nonlocal_v6_addr_up; /* should we try IPv6 pool? */
extern u_int sys_ifnum; /* next .ifnum to assign */
ntp_rfc2553.c \
ntp_worker.c \
numtoa.c \
- numtohost.c \
octtoint.c \
prettydate.c \
refidsmear.c \
#include "ntp_fp.h"
#include "ntp.h"
-#include "lib_strbuf.h"
#include "ntp_refclock.h"
#include "ntp_stdlib.h"
#include <stdio.h>
#include "ntp_fp.h"
-#include "lib_strbuf.h"
-#include "ntp_string.h"
#include "ntp_stdlib.h"
char *
#include <stdio.h>
#include "ntp_fp.h"
-#include "lib_strbuf.h"
-#include "ntp_string.h"
#include "ntp_stdlib.h"
char *
#include "ntp_fp.h"
#include "ntp_unixtime.h" /* includes <sys/time.h> and <time.h> */
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp_fp.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
/*
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
#include "ntp_unixtime.h"
-#include "lib_strbuf.h"
#include "ntp_debug.h"
#ifdef HAVE_UNISTD_H
#include <config.h>
#include <stdio.h>
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
const char *
/*
- * netof - return the net address part of an ip address in a sockaddr_storage structure
+ * netof - return the net address part of an ip address in a sockaddr_u structure
* (zero out host part)
*/
#include <config.h>
#include "ntp_stdlib.h"
#include "ntp.h"
+/*
+ * Return the network portion of a host address. Used by ntp_io.c
+ * findbcastinter() to find a multicast/broadcast interface for
+ * a given remote address. Note static storage is used, with room
+ * for only two addresses, which is all that is needed at present.
+ *
+ */
sockaddr_u *
netof(
sockaddr_u *hostaddr
)
{
- static sockaddr_u netofbuf[8];
+ static sockaddr_u netofbuf[2];
static int next_netofbuf;
u_int32 netnum;
sockaddr_u * netaddr;
memcpy(netaddr, hostaddr, sizeof(*netaddr));
if (IS_IPV4(netaddr)) {
- netnum = SRCADR(netaddr);
-
/*
- * We live in a modern CIDR world where the basement nets, which
- * used to be class A, are now probably associated with each
- * host address. So, for class-A nets, all bits are significant.
+ * We live in a modern classless IPv4 world. Assume /24.
*/
- if (IN_CLASSC(netnum))
- netnum &= IN_CLASSC_NET;
- else if (IN_CLASSB(netnum))
- netnum &= IN_CLASSB_NET;
-
+ netnum = SRCADR(netaddr) & IN_CLASSC_NET;
SET_ADDR4(netaddr, netnum);
-
} else if (IS_IPV6(netaddr))
/* assume the typical /64 subnet size */
zero_mem(&NSRCADR6(netaddr)[8], 8);
#include "ntp_unixtime.h"
#include "ntpd.h"
-#include "lib_strbuf.h"
/* For now, let's take the conservative approach: if the target property
* macros are not defined, check a few well-known compiler/architecture
#include <ctype.h>
#include "ntp_fp.h"
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
char *
+++ /dev/null
-/*
- * numtohost - convert network number to host name.
- */
-#include <config.h>
-
-#include <sys/types.h>
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h> /* ntohl */
-#endif
-
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
-
-#define LOOPBACKNET 0x7f000000
-#define LOOPBACKHOST 0x7f000001
-#define LOOPBACKNETMASK 0xff000000
-
-char *
-numtohost(
- u_int32 netnum
- )
-{
- char *bp;
- struct hostent *hp;
-
- /*
- * This is really gross, but saves lots of hanging looking for
- * hostnames for the radio clocks. Don't bother looking up
- * addresses on the loopback network except for the loopback
- * host itself.
- */
- if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET)
- && (ntohl(netnum) != LOOPBACKHOST))
- || ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET))
- == 0))
- return numtoa(netnum);
-
- LIB_GETBUF(bp);
- strlcpy(bp, hp->h_name, LIB_BUFLENGTH);
-
- return bp;
-}
#include "ntp_fp.h"
#include "ntp_unixtime.h" /* includes <sys/time.h> */
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp_assert.h"
#include "ntp_calendar.h"
#include <stdio.h>
#include "ntp_net.h"
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
const char *
#include <isc/sockaddr.h>
#include "ntp_fp.h"
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"
#include <stdio.h>
#include "ntp_fp.h"
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"
#include "ntp_debug.h"
#include "ntp_stdlib.h"
#include "ntp_fp.h"
#include "ntp.h"
-#include "lib_strbuf.h"
#include "ntp_refclock.h"
#include "ntp_control.h"
#include "ntp_string.h"
#include "timevalops.h"
#include "timespecops.h"
#include "ntp_calendar.h"
-#include "lib_strbuf.h"
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#include "ntp_fp.h"
#include "ntp_unixtime.h"
-#include "lib_strbuf.h"
#include "ntp_stdlib.h"
/* --------------------------------------------------------------------
* Create a worker thread. There are several differences between POSIX
- * and Windows, of course -- most notably the Windows thread is no
+ * and Windows, of course -- most notably the Windows thread is a
* detached thread, and we keep the handle around until we want to get
* rid of the thread. The notification scheme also differs: Windows
* makes use of semaphores in both directions, POSIX uses a pipe for
}
/* remember the thread priority is only within the process class */
if (!SetThreadPriority(c->thr_table[0].thnd,
- THREAD_PRIORITY_BELOW_NORMAL))
+ THREAD_PRIORITY_BELOW_NORMAL)) {
msyslog(LOG_ERR, "Error lowering blocking thread priority: %m");
-
+ }
+ if (NULL != pSetThreadDescription) {
+ (*pSetThreadDescription)(c->thr_table[0].thnd, L"ntp_worker");
+ }
resumed = ResumeThread(c->thr_table[0].thnd);
DEBUG_INSIST(resumed);
c->thread_ref = &c->thr_table[0];
#ifdef LIBDEBUG
-#include "lib_strbuf.h"
-
static char *
fmt_blong(
unsigned long val,
if (HAVE_OPT( UPDATEINTERVAL )) {
long val = OPT_VALUE_UPDATEINTERVAL;
-
- if (val >= 0)
- interface_interval = val;
- else {
- fprintf(stderr,
- "command line interface update interval %ld must not be negative\n",
- val);
- msyslog(LOG_ERR,
- "command line interface update interval %ld must not be negative",
- val);
+ const char errfmt[] =
+ "-U/--updateinterval %ld must be >= 0\n";
+
+ if (val >= 0) {
+ endpt_scan_period = val;
+ } else {
+ fprintf(stderr, errfmt, val);
+ msyslog(LOG_ERR, errfmt, val);
errflg++;
}
}
#include <ntp_stdlib.h>
#include <ntp_config.h>
-#include <lib_strbuf.h>
#include "ntp_scanner.h"
#include "ntp_parser.h"
#include "ntp_clockdev.h"
#include "ntp_filegen.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
#include "ntp_assert.h"
#include "ntp_random.h"
/*
/*
* Poll Skew List array has an entry for each supported poll
- * interval, plus one for the default.
+ * interval.
*/
#define PSL_ENTRIES (NTP_MAXPOLL - NTP_MINPOLL + 1)
static psl_item psl[PSL_ENTRIES];
static void config_ntpd(config_tree *, int/*BOOL*/ input_from_file);
static void config_other_modes(config_tree *);
static void config_auth(config_tree *);
-static void attrtopsl(int poll, attr_val *avp);
+static void attrtopsl(u_char poll, attr_val *avp);
static void config_access(config_tree *);
static void config_mdnstries(config_tree *);
static void config_phone(config_tree *);
static u_int32 get_logmask(const char *);
static int/*BOOL*/ is_refclk_addr(const address_node * addr);
-static void appendstr(char *, size_t, const char *);
-
-
#ifndef SIM
static int getnetnum(const char *num, sockaddr_u *addr, int complain,
enum gnn_type a_type);
static void
config_monitor(
- config_tree *ptree
- )
+ config_tree* ptree
+)
{
- int_node *pfilegen_token;
- const char *filegen_string;
- const char *filegen_file;
- FILEGEN *filegen;
- filegen_node *my_node;
- attr_val *my_opts;
- int filegen_type;
- int filegen_flag;
+ int_node * pfilegen_token;
+ const char * filegen_string;
+ const char * filegen_file;
+ FILEGEN * filegen;
+ filegen_node * my_node;
+ attr_val* my_opts;
+ int filegen_type;
+ int filegen_flag;
/* Set the statistics directory */
- if (ptree->stats_dir)
- stats_config(STATS_STATSDIR, ptree->stats_dir, 0);
+ if (ptree->stats_dir) {
+ stats_config(STATS_STATSDIR, ptree->stats_dir, 0);
+ }
/* NOTE:
* Calling filegen_get is brain dead. Doing a string
/*
* pollskewlist
- *
- * First, find the last default pollskewlist item.
- * There should only be one of these with the current grammar,
- * but better safe than sorry.
*/
- dflt_psl_atr = NULL;
atrv = HEAD_PFIFO(ptree->pollskewlist);
- if (NULL != atrv) {
- ZERO(psl);
+ if (NULL == atrv) {
+ /* don't touch the poll skew list */
+ return;
}
+ ZERO(psl);
+ /*
+ * First, find the last default pollskewlist item.
+ */
+ dflt_psl_atr = NULL;
for ( ; atrv != NULL; atrv = atrv->link) {
- switch (atrv->attr) {
- case -1: /* default */
+ if (-1 == atrv->attr) { /* default */
dflt_psl_atr = atrv;
- break;
-
- case 3: /* Fall through */
- case 4: /* Fall through */
- case 5: /* Fall through */
- case 6: /* Fall through */
- case 7: /* Fall through */
- case 8: /* Fall through */
- case 9: /* Fall through */
- case 10: /* Fall through */
- case 11: /* Fall through */
- case 12: /* Fall through */
- case 13: /* Fall through */
- case 14: /* Fall through */
- case 15: /* Fall through */
- case 16: /* Fall through */
- case 17:
- /* ignore */
- break;
-
- default:
+ } else if ( atrv->attr < NTP_MINPOLL
+ || atrv->attr > NTP_MAXPOLL) {
msyslog(LOG_ERR,
- "config_access: default PSL scan: ignoring unexpected poll value %d",
- atrv->attr);
- break;
+ "Poll %d out of bounds for pollskewlist, (%d-%d)",
+ atrv->attr, NTP_MINPOLL, NTP_MAXPOLL);
}
}
- /* If we have a nonzero default, initialize the PSL */
+ /* If we have a nonzero default, put it in all entries */
if ( dflt_psl_atr
&& ( 0 != dflt_psl_atr->value.r.first
|| 0 != dflt_psl_atr->value.r.last)) {
/* Finally, update the PSL with any explicit entries */
atrv = HEAD_PFIFO(ptree->pollskewlist);
for ( ; atrv != NULL; atrv = atrv->link) {
- switch (atrv->attr) {
- case -1: /* default */
- /* Ignore */
- break;
-
- case 3: /* Fall through */
- case 4: /* Fall through */
- case 5: /* Fall through */
- case 6: /* Fall through */
- case 7: /* Fall through */
- case 8: /* Fall through */
- case 9: /* Fall through */
- case 10: /* Fall through */
- case 11: /* Fall through */
- case 12: /* Fall through */
- case 13: /* Fall through */
- case 14: /* Fall through */
- case 15: /* Fall through */
- case 16: /* Fall through */
- case 17:
+ if (atrv->attr >= NTP_MINPOLL && atrv->attr <= NTP_MAXPOLL) {
attrtopsl(atrv->attr, atrv);
- break;
-
- default:
- break; /* Ignore - we reported this above */
}
}
#if 0
int p;
msyslog(LOG_INFO, "Dumping PSL:");
- for (p = 3; p <= 17; ++p) {
+ for (p = NTP_MINPOLL; p <= NTP_MAXPOLL; ++p) {
psl_item psi;
if (0 == get_pollskew(p, &psi)) {
}
-void
-attrtopsl(int poll, attr_val *avp)
+static void
+attrtopsl(
+ u_char poll,
+ attr_val * avp
+ )
{
- if (poll < NTP_MINPOLL || poll > NTP_MAXPOLL) {
- msyslog(LOG_ERR, "Poll %d value unsupported for pollskewlist",
- poll);
- } else {
- int pao = poll - NTP_MINPOLL; /* poll array offset */
- int lower = avp->value.r.first; /* a positive number */
- int upper = avp->value.r.last;
- int psmax = 1 << (poll - 1);
- int qmsk;
-
- DEBUG_INSIST(pao < COUNTOF(psl));
-
- if (lower > psmax) {
- msyslog(LOG_WARNING, "pollskewlist %d lower bound reduced from %d to %d",
- poll, lower, psmax);
- lower = psmax;
- }
- if (upper > psmax) {
- msyslog(LOG_WARNING, "pollskewlist %d upper bound reduced from %d to %d",
- poll, upper, psmax);
- upper = psmax;
- }
- psl[pao].sub = lower;
- psl[pao].qty = lower + upper;
-
- qmsk = 1;
- while (qmsk < (lower + upper)) {
- qmsk <<= 1;
- qmsk |= 1;
- };
- psl[pao].msk = qmsk;
+ int pao = poll - NTP_MINPOLL; /* poll array offset */
+ u_int32 lower = (u_short)avp->value.r.first; /* ntp_parser.y ensures */
+ u_int32 upper = (u_short)avp->value.r.last; /* non-neg. first/last */
+ u_int psmax = 1 << (poll - 1);
+ u_int32 qmsk;
+
+ DEBUG_INSIST(pao >= 0 && pao < COUNTOF(psl));
+
+ if (lower > psmax) {
+ msyslog(LOG_WARNING, "pollskewlist %d lower bound reduced from %d to %d",
+ poll, lower, psmax);
+ lower = psmax;
+ }
+ if (upper > psmax) {
+ msyslog(LOG_WARNING, "pollskewlist %d upper bound reduced from %d to %d",
+ poll, upper, psmax);
+ upper = psmax;
+ }
+ psl[pao].sub = lower;
+ psl[pao].qty = lower + upper;
+
+ qmsk = 1;
+ while (qmsk < (lower + upper)) {
+ qmsk <<= 1;
+ qmsk |= 1;
}
-}
+ psl[pao].msk = qmsk;
+}
#endif /* !SIM */
if_name = estrdup(if_name);
switch (curr_node->match_class) {
-
+#ifdef DEBUG
default:
fatal_error("config_nic_rules: match-class-token=%d", curr_node->match_class);
+#endif
case 0:
/*
}
switch (curr_node->action) {
-
+#ifdef DEBUG
default:
fatal_error("config_nic_rules: action-token=%d", curr_node->action);
-
+#endif
case T_Listen:
action = ACTION_LISTEN;
break;
add_nic_rule(match_type, if_name, prefixlen,
action);
- timer_interfacetimeout(current_time + 2);
+ if (!initializing && !scan_addrs_once) {
+ endpt_scan_timer = 1 + current_time;
+ }
if (if_name != NULL)
free(if_name);
}
case T_Driftfile:
if ('\0' == curr_var->value.s[0])
msyslog(LOG_INFO, "config: driftfile disabled");
- stats_config(STATS_FREQ_FILE, curr_var->value.s, 0);
+ stats_config(STATS_FREQ_FILE, curr_var->value.s, TRUE);
break;
case T_Dscp:
break;
case T_Leapfile:
- stats_config(STATS_LEAP_FILE, curr_var->value.s, curr_var->flag);
+ stats_config(STATS_LEAP_FILE, curr_var->value.s, curr_var->flag);
break;
#ifdef LEAP_SMEAR
}
}
#endif /* HAVE_SETRLIMIT */
-
-
-char *
-build_iflags(
- u_int32 iflags
- )
-{
- static char ifs[1024];
-
- ifs[0] = '\0';
-
- if (iflags & INT_UP) {
- iflags &= ~INT_UP;
- appendstr(ifs, sizeof ifs, "up");
- }
-
- if (iflags & INT_PPP) {
- iflags &= ~INT_PPP;
- appendstr(ifs, sizeof ifs, "ppp");
- }
-
- if (iflags & INT_LOOPBACK) {
- iflags &= ~INT_LOOPBACK;
- appendstr(ifs, sizeof ifs, "loopback");
- }
-
- if (iflags & INT_BROADCAST) {
- iflags &= ~INT_BROADCAST;
- appendstr(ifs, sizeof ifs, "broadcast");
- }
-
- if (iflags & INT_MULTICAST) {
- iflags &= ~INT_MULTICAST;
- appendstr(ifs, sizeof ifs, "multicast");
- }
-
- if (iflags & INT_BCASTOPEN) {
- iflags &= ~INT_BCASTOPEN;
- appendstr(ifs, sizeof ifs, "bcastopen");
- }
-
- if (iflags & INT_MCASTOPEN) {
- iflags &= ~INT_MCASTOPEN;
- appendstr(ifs, sizeof ifs, "mcastopen");
- }
-
- if (iflags & INT_WILDCARD) {
- iflags &= ~INT_WILDCARD;
- appendstr(ifs, sizeof ifs, "wildcard");
- }
-
- if (iflags & INT_MCASTIF) {
- iflags &= ~INT_MCASTIF;
- appendstr(ifs, sizeof ifs, "MCASTif");
- }
-
- if (iflags & INT_PRIVACY) {
- iflags &= ~INT_PRIVACY;
- appendstr(ifs, sizeof ifs, "IPv6privacy");
- }
-
- if (iflags & INT_BCASTXMIT) {
- iflags &= ~INT_BCASTXMIT;
- appendstr(ifs, sizeof ifs, "bcastxmit");
- }
-
- if (iflags) {
- char string[10];
-
- snprintf(string, sizeof string, "%0x", iflags);
- appendstr(ifs, sizeof ifs, string);
- }
-
- return ifs;
-}
-
-
-char *
-build_mflags(
- u_short mflags
- )
-{
- static char mfs[1024];
-
- mfs[0] = '\0';
-
- if (mflags & RESM_NTPONLY) {
- mflags &= ~RESM_NTPONLY;
- appendstr(mfs, sizeof mfs, "ntponly");
- }
-
- if (mflags & RESM_SOURCE) {
- mflags &= ~RESM_SOURCE;
- appendstr(mfs, sizeof mfs, "source");
- }
-
- if (mflags) {
- char string[10];
-
- snprintf(string, sizeof string, "%0x", mflags);
- appendstr(mfs, sizeof mfs, string);
- }
-
- return mfs;
-}
-
-
-char *
-build_rflags(
- u_short rflags
- )
-{
- static char rfs[1024];
-
- rfs[0] = '\0';
-
- if (rflags & RES_FLAKE) {
- rflags &= ~RES_FLAKE;
- appendstr(rfs, sizeof rfs, "flake");
- }
-
- if (rflags & RES_IGNORE) {
- rflags &= ~RES_IGNORE;
- appendstr(rfs, sizeof rfs, "ignore");
- }
-
- if (rflags & RES_KOD) {
- rflags &= ~RES_KOD;
- appendstr(rfs, sizeof rfs, "kod");
- }
-
- if (rflags & RES_MSSNTP) {
- rflags &= ~RES_MSSNTP;
- appendstr(rfs, sizeof rfs, "mssntp");
- }
-
- if (rflags & RES_LIMITED) {
- rflags &= ~RES_LIMITED;
- appendstr(rfs, sizeof rfs, "limited");
- }
-
- if (rflags & RES_LPTRAP) {
- rflags &= ~RES_LPTRAP;
- appendstr(rfs, sizeof rfs, "lptrap");
- }
-
- if (rflags & RES_NOMODIFY) {
- rflags &= ~RES_NOMODIFY;
- appendstr(rfs, sizeof rfs, "nomodify");
- }
-
- if (rflags & RES_NOMRULIST) {
- rflags &= ~RES_NOMRULIST;
- appendstr(rfs, sizeof rfs, "nomrulist");
- }
-
- if (rflags & RES_NOEPEER) {
- rflags &= ~RES_NOEPEER;
- appendstr(rfs, sizeof rfs, "noepeer");
- }
-
- if (rflags & RES_NOPEER) {
- rflags &= ~RES_NOPEER;
- appendstr(rfs, sizeof rfs, "nopeer");
- }
-
- if (rflags & RES_NOQUERY) {
- rflags &= ~RES_NOQUERY;
- appendstr(rfs, sizeof rfs, "noquery");
- }
-
- if (rflags & RES_DONTSERVE) {
- rflags &= ~RES_DONTSERVE;
- appendstr(rfs, sizeof rfs, "dontserve");
- }
-
- if (rflags & RES_NOTRAP) {
- rflags &= ~RES_NOTRAP;
- appendstr(rfs, sizeof rfs, "notrap");
- }
-
- if (rflags & RES_DONTTRUST) {
- rflags &= ~RES_DONTTRUST;
- appendstr(rfs, sizeof rfs, "notrust");
- }
-
- if (rflags & RES_SRVRSPFUZ) {
- rflags &= ~RES_SRVRSPFUZ;
- appendstr(rfs, sizeof rfs, "srvrspfuz");
- }
-
- if (rflags & RES_VERSION) {
- rflags &= ~RES_VERSION;
- appendstr(rfs, sizeof rfs, "version");
- }
-
- if (rflags) {
- char string[10];
-
- snprintf(string, sizeof string, "%0x", rflags);
- appendstr(rfs, sizeof rfs, string);
- }
-
- if ('\0' == rfs[0]) {
- appendstr(rfs, sizeof rfs, "(none)");
- }
-
- return rfs;
-}
-
-
-static void
-appendstr(
- char *string,
- size_t s,
- const char *new
- )
-{
- if (*string != '\0') {
- (void)strlcat(string, ",", s);
- }
- (void)strlcat(string, new, s);
-
- return;
-}
#include "ntp_crypto.h"
#include "ntp_assert.h"
#include "ntp_leapsec.h"
-#include "lib_strbuf.h"
#include "timexsup.h"
#include <rc_cmdlength.h>
endpt * any6_interface; /* wildcard ipv6 interface */
endpt * loopback_interface; /* loopback ipv4 interface */
-static isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
+static isc_boolean_t broadcast_client_enabled;
u_int sys_ifnum; /* next .ifnum to assign */
int ninterfaces; /* Total number of interfaces */
-int disable_dynamic_updates; /* scan interfaces once only */
-int nonlocal_v4_addr_up; /* should we try IPv4 pool? */
-int nonlocal_v6_addr_up; /* should we try IPv6 pool? */
+int no_periodic_scan; /* network endpoint scans */
+int scan_addrs_once; /* because dropped privs */
+int nonlocal_v4_addr_up; /* should we try IPv4 pool? */
+int nonlocal_v6_addr_up; /* should we try IPv6 pool? */
#ifdef REFCLOCK
/*
int accept_wildcard_if_for_winnt;
#else
const int accept_wildcard_if_for_winnt = FALSE;
+#define init_io_completion_port() do {} while (FALSE)
#endif
static void add_fd_to_list (SOCKET, enum desc_type);
/* Init buffer free list and stat counters */
init_recvbuff(RECV_INIT);
/* update interface every 5 minutes as default */
- interface_interval = 300;
+ endpt_scan_period = 301;
#ifdef WORK_PIPE
addremove_io_fd = &ntpd_addremove_io_fd;
#endif
-#if defined(SYS_WINNT)
init_io_completion_port();
-#elif defined(HAVE_SIGNALED_IO)
+#if defined(HAVE_SIGNALED_IO)
(void) set_signal(input_handler);
#endif
}
endpt * scan;
endpt * scan_next;
endpt * unlinked;
- sockaddr_u * addr;
int ep_local;
int scan_local;
int same_subnet;
? &mc4_list
: &mc6_list;
+ ep_local = is_linklocal(&ep->sin);
if (AF_INET6 == ep->family) {
- ep_local =
- IN6_IS_ADDR_LINKLOCAL(PSOCK_ADDR6(&ep->sin)) ||
- IN6_IS_ADDR_SITELOCAL(PSOCK_ADDR6(&ep->sin));
ep_univ_iid = IS_IID_UNIV(&ep->sin);
ep_privacy = !!(INT_PRIVACY & ep->flags);
} else {
- ep_local = FALSE;
ep_univ_iid = FALSE;
ep_privacy = FALSE;
}
continue;
same_subnet = addr_samesubnet(&ep->sin, &ep->mask,
&scan->sin, &scan->mask);
+ scan_local = is_linklocal(&scan->sin);
if (AF_INET6 == ep->family) {
- addr = &scan->sin;
- scan_local =
- IN6_IS_ADDR_LINKLOCAL(PSOCK_ADDR6(addr)) ||
- IN6_IS_ADDR_SITELOCAL(PSOCK_ADDR6(addr));
- scan_univ_iid = IS_IID_UNIV(addr);
+ scan_univ_iid = IS_IID_UNIV(&scan->sin);
scan_privacy = !!(INT_PRIVACY & scan->flags);
} else {
- scan_local = FALSE;
scan_univ_iid = FALSE;
scan_privacy = FALSE;
}
/* remove restrict interface entry */
SET_HOSTMASK(&resmask, AF(&ep->sin));
- hack_restrict(RESTRICT_REMOVEIF, &ep->sin, &resmask,
- -3, RESM_NTPONLY | RESM_INTERFACE, RES_IGNORE, 0);
+ hack_restrict(RESTRICT_REMOVEIF, &ep->sin, &resmask, 0,
+ RESM_NTPONLY | RESM_INTERFACE, 0, 0);
}
u_short port
)
{
- const u_char v6loop[16] = {0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 1};
-
strlcpy(itf->name, isc_if->name, sizeof(itf->name));
itf->ifindex = isc_if->ifindex;
itf->family = (u_short)isc_if->af;
* Clear the loopback flag if the address is not localhost.
* http://bugs.ntp.org/1683
*/
- if (INT_LOOPBACK & itf->flags) {
- if (AF_INET == itf->family) {
- if (127 != (SRCADR(&itf->sin) >> 24))
- itf->flags &= ~INT_LOOPBACK;
- } else {
- if (memcmp(v6loop, NSRCADR6(&itf->sin),
- sizeof(NSRCADR6(&itf->sin))))
- itf->flags &= ~INT_LOOPBACK;
- }
+ if ((INT_LOOPBACK & itf->flags) && !IS_LOOPBACK_ADDR(&itf->sin)) {
+ itf->flags &= ~INT_LOOPBACK;
}
}
{
int new_interface_found;
- if (disable_dynamic_updates)
+ if (scan_addrs_once) {
return;
-
+ }
BLOCKIO();
new_interface_found = update_interfaces(NTP_PORT, receiver, data);
UNBLOCKIO();
}
+#ifdef DEBUG
+const char *
+iflags_str(
+ u_int32 iflags
+)
+{
+ const size_t sz = LIB_BUFLENGTH;
+ char * ifs;
+
+ LIB_GETBUF(ifs);
+ ifs[0] = '\0';
+
+ if (iflags & INT_UP) {
+ CLEAR_BIT_IF_DEBUG(INT_UP, iflags);
+ append_flagstr(ifs, sz, "up");
+ }
+
+ if (iflags & INT_PPP) {
+ CLEAR_BIT_IF_DEBUG(INT_PPP, iflags);
+ append_flagstr(ifs, sz, "ppp");
+ }
+
+ if (iflags & INT_LOOPBACK) {
+ CLEAR_BIT_IF_DEBUG(INT_LOOPBACK, iflags);
+ append_flagstr(ifs, sz, "loopback");
+ }
+
+ if (iflags & INT_BROADCAST) {
+ CLEAR_BIT_IF_DEBUG(INT_BROADCAST, iflags);
+ append_flagstr(ifs, sz, "broadcast");
+ }
+
+ if (iflags & INT_MULTICAST) {
+ CLEAR_BIT_IF_DEBUG(INT_MULTICAST, iflags);
+ append_flagstr(ifs, sz, "multicast");
+ }
+
+ if (iflags & INT_BCASTOPEN) {
+ CLEAR_BIT_IF_DEBUG(INT_BCASTOPEN, iflags);
+ append_flagstr(ifs, sz, "bcastopen");
+ }
+
+ if (iflags & INT_MCASTOPEN) {
+ CLEAR_BIT_IF_DEBUG(INT_MCASTOPEN, iflags);
+ append_flagstr(ifs, sz, "mcastopen");
+ }
+
+ if (iflags & INT_WILDCARD) {
+ CLEAR_BIT_IF_DEBUG(INT_WILDCARD, iflags);
+ append_flagstr(ifs, sz, "wildcard");
+ }
+
+ if (iflags & INT_MCASTIF) {
+ CLEAR_BIT_IF_DEBUG(INT_MCASTIF, iflags);
+ append_flagstr(ifs, sz, "mcastif");
+ }
+
+ if (iflags & INT_PRIVACY) {
+ CLEAR_BIT_IF_DEBUG(INT_PRIVACY, iflags);
+ append_flagstr(ifs, sz, "IPv6privacy");
+ }
+
+ if (iflags & INT_BCASTXMIT) {
+ CLEAR_BIT_IF_DEBUG(INT_BCASTXMIT, iflags);
+ append_flagstr(ifs, sz, "bcastxmit");
+ }
+
+ DEBUG_INVARIANT(!iflags);
+
+ return ifs;
+}
+#endif /* DEBUG */
+
+
#ifdef SO_EXCLUSIVEADDRUSE
static void
set_excladdruse(
#endif /* OPEN_BCAST_SOCKET */
-/*
- * return the broadcast client flag value
- */
-/*isc_boolean_t
-get_broadcastclient_flag(void)
-{
- return (broadcast_client_enabled);
-}
-*/
/*
* Check to see if the address is a multicast address
}
#endif /* MCAST */
+
/*
* io_setbclient - open the broadcast client sockets
*/
#endif /* OPEN_BCAST_SOCKET */
}
+
/*
* io_unsetbclient - close the broadcast client sockets
*/
broadcast_client_enabled = ISC_FALSE;
}
+
/*
* io_multicast_add() - add multicast group address
*/
/* XXX ELIMINATE sendpkt similar in ntpq.c, ntpdc.c, ntp_io.c, ntptrace.c */
/*
- * sendpkt - send a packet to the specified destination. Maintain a
- * send error cache so that only the first consecutive error for a
- * destination is logged.
+ * sendpkt - send a packet to the specified destination from the given endpt
+ * except for multicast, which may be sent from several addresses.
*/
void
sendpkt(
- sockaddr_u * dest,
- struct interface * ep,
- int ttl,
- struct pkt * pkt,
- int len
+ sockaddr_u * dest,
+ endpt * ep,
+ int ttl,
+ struct pkt * pkt,
+ int len
)
{
endpt * src;
ismcast ? "\tMCAST\t***** " : "", src->fd,
stoa(dest), stoa(&src->sin), ttl, len));
#ifdef MCAST
- /*
- * for the moment we use the bcast option to set multicast ttl
- */
if (ismcast && ttl > 0 && ttl != src->last_ttl) {
/*
* set the multicast ttl for outgoing packets
static char buffer[256];
char * buf = buffer;
- count = min(count, 255);
+ count = min(count, sizeof(buffer) - 1);
while (count >= 0) {
*buf++ = FD_ISSET(count, set) ? '#' : '-';
*/
rb->recv_length = buflen;
rb->recv_peer = rp->srcclock;
- rb->dstadr = 0;
+ rb->dstadr = NULL;
rb->fd = fd;
rb->recv_time = ts;
rb->receiver = rp->clock_recv;
*/
static inline int
read_network_packet(
- SOCKET fd,
- struct interface * itf,
- l_fp ts
+ SOCKET fd,
+ endpt * itf,
+ l_fp ts
)
{
GETSOCKNAME_SOCKLEN_TYPE fromlen;
** Bug 2672: Some OSes (MacOSX and Linux) don't block spoofed ::1
*/
- if (AF_INET6 == itf->family) {
- DPRINTF(2, ("Got an IPv6 packet, from <%s> (%d) to <%s> (%d)\n",
- stoa(&rb->recv_srcadr),
- IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr)),
- stoa(&itf->sin),
- !IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&itf->sin))
- ));
-
- if ( IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr))
- && !IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&itf->sin))
- ) {
- packets_dropped++;
- DPRINTF(2, ("DROPPING that packet\n"));
- freerecvbuf(rb);
- return buflen;
- }
- DPRINTF(2, ("processing that packet\n"));
+ if ( IS_IPV6(&rb->recv_srcadr)
+ && IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr))
+ && !(INT_LOOPBACK & itf->flags)) {
+
+ packets_dropped++;
+ DPRINTF(2, ("DROPPING pkt with spoofed ::1 source on %s\n", latoa(itf)));
+ freerecvbuf(rb);
+ return -1;
}
/*
char *p;
#endif
- if (disable_dynamic_updates) {
+ if (scan_addrs_once) {
/*
* discard ourselves if we are not needed any more
* usually happens when running unprivileged
*/
- remove_asyncio_reader(reader);
- delete_asyncio_reader(reader);
- return;
+ goto disable;
}
if (NULL == buffer) {
disable:
remove_asyncio_reader(reader);
delete_asyncio_reader(reader);
+ return;
}
- return;
}
/*
*/
DPRINTF(3, ("routing message op = %d: scheduling interface update\n",
msg_type));
- timer_interfacetimeout(current_time + UPDATE_GRACE);
+ endpt_scan_timer = UPDATE_GRACE + current_time;
break;
#ifdef HAVE_RTNETLINK
case NLMSG_DONE:
{
}
#endif
-
#include <sys/stat.h>
#include <ctype.h>
-#include "ntp_types.h"
-#include "ntp_fp.h"
+#include "ntp.h"
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
#include "ntp_leapsec.h"
-#include "ntp.h"
#include "vint64ops.h"
-#include "lib_strbuf.h"
#include "isc/sha1.h"
static const char * const logPrefix = "leapsecond file";
-/* ---------------------------------------------------------------------
- * GCC is rather sticky with its 'const' attribute. We have to do it more
- * explicit than with a cast if we want to get rid of a CONST qualifier.
- * Greetings from the PASCAL world, where casting was only possible via
- * untagged unions...
- */
-static inline void*
-noconst(
- const void* ptr
- )
-{
- union {
- const void * cp;
- void * vp;
- } tmp;
- tmp.cp = ptr;
- return tmp.vp;
-}
-
/* ---------------------------------------------------------------------
* Our internal data structure
*/
static int/*BOOL*/ _electric;
/* Forward decls of local helpers */
-static int add_range(leap_table_t*, const leap_info_t*);
-static char * get_line(leapsec_reader, void*, char*, size_t);
-static char * skipws(const char*);
-static int parsefail(const char * cp, const char * ep);
-static void reload_limits(leap_table_t*, const vint64*);
-static void fetch_leap_era(leap_era_t*, const leap_table_t*,
- const vint64*);
-static int betweenu32(uint32_t, uint32_t, uint32_t);
-static void reset_times(leap_table_t*);
-static int leapsec_add(leap_table_t*, const vint64*, int);
-static int leapsec_raw(leap_table_t*, const vint64 *, int, int);
-static const char * lstostr(const vint64 * ts);
+static int add_range (leap_table_t *, const leap_info_t *);
+static char * get_line (leapsec_reader, void *, char *,
+ size_t);
+static inline char * skipws (char *ptr);
+static int parsefail (const char *cp, const char *ep);
+static void reload_limits (leap_table_t *, const vint64 *);
+static void fetch_leap_era (leap_era_t *, const leap_table_t *,
+ const vint64 *);
+static int betweenu32 (u_int32, u_int32, u_int32);
+static void reset_times (leap_table_t *);
+static int leapsec_add (leap_table_t *, const vint64 *, int);
+static int leapsec_raw (leap_table_t *, const vint64 *, int,
+ int);
+static const char * lstostr (const vint64 *ts);
/* =====================================================================
* Get & Set the current leap table
*/
int/*BOOL*/
leapsec_load(
- leap_table_t * pt ,
- leapsec_reader func,
- void * farg,
- int use_build_limit)
+ leap_table_t * pt,
+ leapsec_reader func,
+ void * farg,
+ int use_build_limit
+ )
{
- char const *ep;
- char *cp, *endp, linebuf[50];
+ char *cp, *ep, *endp, linebuf[50];
vint64 ttime, limit;
long taiof;
struct calendar build;
ttime = strtouv64(cp, &ep, 10);
if (parsefail(cp, ep))
goto fail_read;
- cp = skipws(ep);
+ cp = skipws(ep);
taiof = strtol(cp, &endp, 10);
if ( parsefail(cp, endp)
|| taiof > INT16_MAX || taiof < INT16_MIN)
}
/* ------------------------------------------------------------------ */
-/* load a file from a FILE pointer. Note: If hcheck is true, load
+/* load a file from a FILE pointer. Note: If vhash is true, load
* only after successful signature check. The stream must be seekable
* or this will fail.
*/
fname = "<unknown>";
if (vhash) {
- rcheck = leapsec_validate((leapsec_reader)getc, ifp);
+ rcheck = leapsec_validate((leapsec_reader)&getc, ifp);
if (logall)
switch (rcheck)
{
}
/* [internal] skips whitespace characters from a character buffer. */
-static char *
+static inline char *
skipws(
- const char *ptr)
+ char * ptr
+ )
{
- while (isspace((u_char)*ptr))
+ while (isspace((u_char)*ptr)) {
ptr++;
- return (char*)noconst(ptr);
+ }
+ return ptr;
}
/* [internal] check if a strtoXYZ ended at EOL or whitespace and
if (_electric)
pt->head.dtime = pt->head.ttime;
- else
+ else
pt->head.dtime = addv64i32(
&pt->head.ttime,
pt->head.next_tai - pt->head.this_tai);
-/* A Bison parser, made by GNU Bison 3.7.6. */
+/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison implementation for Yacc-like parsers in C
USER NAME SPACE" below. */
/* Identify Bison output, and Bison version. */
-#define YYBISON 30706
+#define YYBISON 30802
/* Bison version string. */
-#define YYBISON_VERSION "3.7.6"
+#define YYBISON_VERSION "3.8.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* First part of user prologue. */
-#line 11 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 11 "../../ntpd/ntp_parser.y"
#ifdef HAVE_CONFIG_H
# include <config.h>
# define ONLY_SIM(a) NULL
#endif
-#line 106 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 106 "ntp_parser.c"
# ifndef YY_CAST
# ifdef __cplusplus
/* Use api.header.include to #include this header
instead of duplicating it here. */
-#ifndef YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
-# define YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
+#ifndef YY_YY_NTP_PARSER_H_INCLUDED
+# define YY_YY_NTP_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
-#line 52 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 52 "../../ntpd/ntp_parser.y"
char * String;
double Double;
script_info * Sim_script;
script_info_fifo * Sim_script_fifo;
-#line 606 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 606 "ntp_parser.c"
};
typedef union YYSTYPE YYSTYPE;
extern YYSTYPE yylval;
+
int yyparse (void);
-#endif /* !YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED */
+
+#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */
/* Symbol kind. */
enum yysymbol_kind_t
{
# define YY_USE(E) /* empty */
#endif
-#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
+# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
+# else
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
};
#if YYDEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
+/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
0, 397, 397, 401, 402, 403, 418, 419, 420, 421,
1256, 1263, 1270, 1286, 1305, 1313, 1315, 1317, 1319, 1321,
1323, 1325, 1332, 1337, 1338, 1339, 1343, 1347, 1356, 1358,
1361, 1365, 1369, 1370, 1371, 1375, 1386, 1404, 1417, 1418,
- 1423, 1449, 1450, 1455, 1460, 1462, 1467, 1468, 1476, 1478,
- 1486, 1491, 1499, 1524, 1531, 1541, 1542, 1546, 1547, 1548,
- 1549, 1553, 1554, 1555, 1559, 1564, 1569, 1577, 1578, 1579,
- 1580, 1581, 1582, 1583, 1593, 1598, 1606, 1611, 1619, 1621,
- 1625, 1630, 1635, 1643, 1648, 1656, 1665, 1666, 1670, 1671,
- 1675, 1683, 1701, 1705, 1710, 1718, 1723, 1724, 1728, 1733,
- 1741, 1746, 1751, 1756, 1761, 1769, 1774, 1779, 1787, 1792,
- 1793, 1794, 1795, 1796
+ 1423, 1449, 1455, 1460, 1465, 1467, 1472, 1473, 1481, 1483,
+ 1491, 1496, 1504, 1529, 1536, 1546, 1547, 1551, 1552, 1553,
+ 1554, 1558, 1559, 1560, 1564, 1569, 1574, 1582, 1583, 1584,
+ 1585, 1586, 1587, 1588, 1598, 1603, 1611, 1616, 1624, 1626,
+ 1630, 1635, 1640, 1648, 1653, 1661, 1670, 1671, 1675, 1676,
+ 1680, 1688, 1706, 1710, 1715, 1723, 1728, 1729, 1733, 1738,
+ 1746, 1751, 1756, 1761, 1766, 1774, 1779, 1784, 1792, 1797,
+ 1798, 1799, 1800, 1801
};
#endif
}
#endif
-#ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
- (internal) symbol number NUM (which must be that of a token). */
-static const yytype_int16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
- 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
- 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
- 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
- 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
- 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
- 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
- 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
- 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
- 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
- 415, 416, 417, 418, 419, 420, 421, 422, 423, 424,
- 425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
- 435, 436, 437, 438, 439, 440, 441, 442, 443, 444,
- 445, 446, 447, 448, 449, 450, 451, 452, 453, 454,
- 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
- 465, 466, 467, 468, 469, 124, 61, 40, 41, 123,
- 125
-};
-#endif
-
#define YYPACT_NINF (-247)
#define yypact_value_is_default(Yyn) \
#define yytable_value_is_error(Yyn) \
0
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
static const yytype_int16 yypact[] =
{
5, -178, -19, -247, -247, -247, -2, -247, -58, 294,
33, -247, -247
};
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
- means the default is an error. */
+/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE does not specify something else to do. Zero
+ means the default is an error. */
static const yytype_int16 yydefact[] =
{
0, 0, 0, 25, 60, 253, 0, 73, 0, 0,
0, 336, 338
};
- /* YYPGOTO[NTERM-NUM]. */
+/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-247, -247, -247, -48, -247, -247, -8, -51, -247, -247,
-247, -106, -247, -122, -247
};
- /* YYDEFGOTO[NTERM-NUM]. */
+/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
0, 58, 59, 60, 61, 62, 137, 93, 94, 311,
440, 441, 454, 455, 456
};
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
+/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule whose
+ number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
92, 214, 297, 386, 215, 181, 1, 422, 129, 312,
-1, -1, -1, -1, -1, -1, -1, 133, 134
};
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
+/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
+ state STATE-NUM. */
static const yytype_int16 yystos[] =
{
0, 1, 10, 16, 17, 18, 25, 26, 31, 33,
216, 204, 320
};
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
static const yytype_int16 yyr1[] =
{
0, 221, 222, 223, 223, 223, 224, 224, 224, 224,
335, 335, 335, 335
};
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
+/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
static const yytype_int8 yyr2[] =
{
0, 2, 1, 3, 2, 2, 0, 1, 1, 1,
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
+#define YYNOMEM goto yyexhaustedlab
#define YYRECOVERING() (!!yyerrstatus)
YYFPRINTF Args; \
} while (0)
-/* This macro is provided for backward compatibility. */
-# ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
+
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
YY_USE (yyoutput);
if (!yyvaluep)
return;
-# ifdef YYPRINT
- if (yykind < YYNTOKENS)
- YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
-# endif
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YY_USE (yykind);
YY_IGNORE_MAYBE_UNINITIALIZED_END
YYDPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY; /* Cause a token to be read. */
+
goto yysetstate;
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
- goto yyexhaustedlab;
+ YYNOMEM;
#else
{
/* Get the current used size of the three stacks, in elements. */
# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
+ YYNOMEM;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
if (! yyptr)
- goto yyexhaustedlab;
+ YYNOMEM;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
}
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
+
if (yystate == YYFINAL)
YYACCEPT;
switch (yyn)
{
case 5: /* command_list: error T_EOC */
-#line 404 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 404 "../../ntpd/ntp_parser.y"
{
/* I will need to incorporate much more fine grained
* error messages. The following should suffice for
ip_ctx->errpos.nline,
ip_ctx->errpos.ncol);
}
-#line 2438 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2411 "ntp_parser.c"
break;
case 21: /* server_command: client_type address option_list */
-#line 441 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 441 "../../ntpd/ntp_parser.y"
{
peer_node *my_node;
my_node = create_peer_node((yyvsp[-2].Integer), (yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.peers, my_node);
}
-#line 2449 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2422 "ntp_parser.c"
break;
case 28: /* address: address_fam T_String */
-#line 460 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 460 "../../ntpd/ntp_parser.y"
{ (yyval.Address_node) = create_address_node((yyvsp[0].String), (yyvsp[-1].Integer)); }
-#line 2455 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2428 "ntp_parser.c"
break;
case 29: /* ip_address: T_String */
-#line 465 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 465 "../../ntpd/ntp_parser.y"
{ (yyval.Address_node) = create_address_node((yyvsp[0].String), AF_UNSPEC); }
-#line 2461 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2434 "ntp_parser.c"
break;
case 30: /* address_fam: T_Ipv4_flag */
-#line 470 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 470 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = AF_INET; }
-#line 2467 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2440 "ntp_parser.c"
break;
case 31: /* address_fam: T_Ipv6_flag */
-#line 472 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 472 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = AF_INET6; }
-#line 2473 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2446 "ntp_parser.c"
break;
case 32: /* option_list: %empty */
-#line 477 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 477 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2479 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2452 "ntp_parser.c"
break;
case 33: /* option_list: option_list option */
-#line 479 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 479 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2488 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2461 "ntp_parser.c"
break;
case 37: /* option_flag: option_flag_keyword */
-#line 493 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 493 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2494 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2467 "ntp_parser.c"
break;
case 47: /* option_int: option_int_keyword T_Integer */
-#line 510 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 510 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2500 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2473 "ntp_parser.c"
break;
case 48: /* option_int: option_int_keyword T_U_int */
-#line 512 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 512 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_uval((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2506 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2479 "ntp_parser.c"
break;
case 55: /* option_str: option_str_keyword T_String */
-#line 526 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 526 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2512 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2485 "ntp_parser.c"
break;
case 57: /* unpeer_command: unpeer_keyword address */
-#line 540 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 540 "../../ntpd/ntp_parser.y"
{
unpeer_node *my_node;
if (my_node)
APPEND_G_FIFO(cfgt.unpeers, my_node);
}
-#line 2524 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2497 "ntp_parser.c"
break;
case 60: /* other_mode_command: T_Broadcastclient */
-#line 561 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 561 "../../ntpd/ntp_parser.y"
{ cfgt.broadcastclient = 1; }
-#line 2530 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2503 "ntp_parser.c"
break;
case 61: /* other_mode_command: T_Manycastserver address_list */
-#line 563 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 563 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[0].Address_fifo)); }
-#line 2536 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2509 "ntp_parser.c"
break;
case 62: /* other_mode_command: T_Multicastclient address_list */
-#line 565 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 565 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[0].Address_fifo)); }
-#line 2542 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2515 "ntp_parser.c"
break;
case 63: /* other_mode_command: T_Mdnstries T_Integer */
-#line 567 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 567 "../../ntpd/ntp_parser.y"
{ cfgt.mdnstries = (yyvsp[0].Integer); }
-#line 2548 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2521 "ntp_parser.c"
break;
case 64: /* authentication_command: T_Automax T_Integer */
-#line 578 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 578 "../../ntpd/ntp_parser.y"
{
attr_val *atrv;
atrv = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
APPEND_G_FIFO(cfgt.vars, atrv);
}
-#line 2559 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2532 "ntp_parser.c"
break;
case 65: /* authentication_command: T_ControlKey T_Integer */
-#line 585 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 585 "../../ntpd/ntp_parser.y"
{ cfgt.auth.control_key = (yyvsp[0].Integer); }
-#line 2565 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2538 "ntp_parser.c"
break;
case 66: /* authentication_command: T_Crypto crypto_command_list */
-#line 587 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 587 "../../ntpd/ntp_parser.y"
{
cfgt.auth.cryptosw++;
CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[0].Attr_val_fifo));
}
-#line 2574 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2547 "ntp_parser.c"
break;
case 67: /* authentication_command: T_Keys T_String */
-#line 592 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 592 "../../ntpd/ntp_parser.y"
{ cfgt.auth.keys = (yyvsp[0].String); }
-#line 2580 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2553 "ntp_parser.c"
break;
case 68: /* authentication_command: T_Keysdir T_String */
-#line 594 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 594 "../../ntpd/ntp_parser.y"
{ cfgt.auth.keysdir = (yyvsp[0].String); }
-#line 2586 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2559 "ntp_parser.c"
break;
case 69: /* authentication_command: T_Requestkey T_Integer */
-#line 596 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 596 "../../ntpd/ntp_parser.y"
{ cfgt.auth.request_key = (yyvsp[0].Integer); }
-#line 2592 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2565 "ntp_parser.c"
break;
case 70: /* authentication_command: T_Revoke T_Integer */
-#line 598 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 598 "../../ntpd/ntp_parser.y"
{ cfgt.auth.revoke = (yyvsp[0].Integer); }
-#line 2598 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2571 "ntp_parser.c"
break;
case 71: /* authentication_command: T_Trustedkey integer_list_range */
-#line 600 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 600 "../../ntpd/ntp_parser.y"
{
/* [Bug 948] leaves it open if appending or
* replacing the trusted key list is the right
DESTROY_G_FIFO(cfgt.auth.trusted_key_list, destroy_attr_val); /* remove for append */
CONCAT_G_FIFOS(cfgt.auth.trusted_key_list, (yyvsp[0].Attr_val_fifo));
}
-#line 2612 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2585 "ntp_parser.c"
break;
case 72: /* authentication_command: T_NtpSignDsocket T_String */
-#line 610 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 610 "../../ntpd/ntp_parser.y"
{ cfgt.auth.ntp_signd_socket = (yyvsp[0].String); }
-#line 2618 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2591 "ntp_parser.c"
break;
case 73: /* crypto_command_list: %empty */
-#line 615 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 615 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2624 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2597 "ntp_parser.c"
break;
case 74: /* crypto_command_list: crypto_command_list crypto_command */
-#line 617 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 617 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2633 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2606 "ntp_parser.c"
break;
case 75: /* crypto_command: crypto_str_keyword T_String */
-#line 625 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 625 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2639 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2612 "ntp_parser.c"
break;
case 76: /* crypto_command: T_Revoke T_Integer */
-#line 627 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 627 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val) = NULL;
cfgt.auth.revoke = (yyvsp[0].Integer);
"please use 'revoke %d' instead.",
cfgt.auth.revoke, cfgt.auth.revoke);
}
-#line 2652 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2625 "ntp_parser.c"
break;
case 82: /* orphan_mode_command: T_Tos tos_option_list */
-#line 652 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 652 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[0].Attr_val_fifo)); }
-#line 2658 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2631 "ntp_parser.c"
break;
case 83: /* tos_option_list: tos_option_list tos_option */
-#line 657 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 657 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2667 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2640 "ntp_parser.c"
break;
case 84: /* tos_option_list: tos_option */
-#line 662 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 662 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2676 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2649 "ntp_parser.c"
break;
case 85: /* tos_option: tos_option_int_keyword T_Integer */
-#line 670 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 670 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); }
-#line 2682 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2655 "ntp_parser.c"
break;
case 86: /* tos_option: tos_option_dbl_keyword number */
-#line 672 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 672 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 2688 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2661 "ntp_parser.c"
break;
case 87: /* tos_option: T_Cohort boolean */
-#line 674 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 674 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); }
-#line 2694 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2667 "ntp_parser.c"
break;
case 88: /* tos_option: basedate */
-#line 676 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 676 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival(T_Basedate, (yyvsp[0].Integer)); }
-#line 2700 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2673 "ntp_parser.c"
break;
case 100: /* monitoring_command: T_Statistics stats_list */
-#line 703 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 703 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[0].Int_fifo)); }
-#line 2706 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2679 "ntp_parser.c"
break;
case 101: /* monitoring_command: T_Statsdir T_String */
-#line 705 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 705 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
cfgt.stats_dir = (yyvsp[0].String);
yyerror("statsdir remote configuration ignored");
}
}
-#line 2719 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2692 "ntp_parser.c"
break;
case 102: /* monitoring_command: T_Filegen stat filegen_option_list */
-#line 714 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 714 "../../ntpd/ntp_parser.y"
{
filegen_node *fgn;
fgn = create_filegen_node((yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.filegen_opts, fgn);
}
-#line 2730 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2703 "ntp_parser.c"
break;
case 103: /* stats_list: stats_list stat */
-#line 724 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 724 "../../ntpd/ntp_parser.y"
{
(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 2739 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2712 "ntp_parser.c"
break;
case 104: /* stats_list: stat */
-#line 729 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 729 "../../ntpd/ntp_parser.y"
{
(yyval.Int_fifo) = NULL;
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 2748 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2721 "ntp_parser.c"
break;
case 113: /* filegen_option_list: %empty */
-#line 748 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 748 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2754 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2727 "ntp_parser.c"
break;
case 114: /* filegen_option_list: filegen_option_list filegen_option */
-#line 750 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 750 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2763 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2736 "ntp_parser.c"
break;
case 115: /* filegen_option: T_File T_String */
-#line 758 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 758 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
(yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String));
yyerror("filegen file remote config ignored");
}
}
-#line 2777 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2750 "ntp_parser.c"
break;
case 116: /* filegen_option: T_Type filegen_type */
-#line 768 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 768 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
(yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
yyerror("filegen type remote config ignored");
}
}
-#line 2790 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2763 "ntp_parser.c"
break;
case 117: /* filegen_option: link_nolink */
-#line 777 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 777 "../../ntpd/ntp_parser.y"
{
const char *err;
yyerror(err);
}
}
-#line 2809 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2782 "ntp_parser.c"
break;
case 118: /* filegen_option: enable_disable */
-#line 792 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 792 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2815 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2788 "ntp_parser.c"
break;
case 130: /* access_control_command: T_Discard discard_option_list */
-#line 822 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 822 "../../ntpd/ntp_parser.y"
{
CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[0].Attr_val_fifo));
}
-#line 2823 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2796 "ntp_parser.c"
break;
case 131: /* access_control_command: T_Mru mru_option_list */
-#line 826 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 826 "../../ntpd/ntp_parser.y"
{
CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[0].Attr_val_fifo));
}
-#line 2831 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2804 "ntp_parser.c"
break;
case 132: /* access_control_command: T_Restrict address res_ippeerlimit ac_flag_list */
-#line 830 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 830 "../../ntpd/ntp_parser.y"
{
restrict_node *rn;
lex_current()->curpos.nline);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2843 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2816 "ntp_parser.c"
break;
case 133: /* access_control_command: T_Restrict address T_Mask ip_address res_ippeerlimit ac_flag_list */
-#line 838 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 838 "../../ntpd/ntp_parser.y"
{
restrict_node *rn;
lex_current()->curpos.nline);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2855 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2828 "ntp_parser.c"
break;
case 134: /* access_control_command: T_Restrict T_Default res_ippeerlimit ac_flag_list */
-#line 846 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 846 "../../ntpd/ntp_parser.y"
{
restrict_node *rn;
lex_current()->curpos.nline);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2867 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2840 "ntp_parser.c"
break;
case 135: /* access_control_command: T_Restrict T_Ipv4_flag T_Default res_ippeerlimit ac_flag_list */
-#line 854 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 854 "../../ntpd/ntp_parser.y"
{
restrict_node *rn;
lex_current()->curpos.nline);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2886 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2859 "ntp_parser.c"
break;
case 136: /* access_control_command: T_Restrict T_Ipv6_flag T_Default res_ippeerlimit ac_flag_list */
-#line 869 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 869 "../../ntpd/ntp_parser.y"
{
restrict_node *rn;
lex_current()->curpos.nline);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2905 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2878 "ntp_parser.c"
break;
case 137: /* access_control_command: T_Restrict T_Source res_ippeerlimit ac_flag_list */
-#line 884 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 884 "../../ntpd/ntp_parser.y"
{
restrict_node * rn;
NULL, NULL, (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), lex_current()->curpos.nline);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2918 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2891 "ntp_parser.c"
break;
case 138: /* res_ippeerlimit: %empty */
-#line 896 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 896 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = -1; }
-#line 2924 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2897 "ntp_parser.c"
break;
case 139: /* res_ippeerlimit: T_Ippeerlimit T_Integer */
-#line 898 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 898 "../../ntpd/ntp_parser.y"
{
if (((yyvsp[0].Integer) < -1) || ((yyvsp[0].Integer) > 100)) {
struct FILE_INFO * ip_ctx;
}
(yyval.Integer) = (yyvsp[0].Integer);
}
-#line 2944 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2917 "ntp_parser.c"
break;
case 140: /* ac_flag_list: %empty */
-#line 917 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 917 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2950 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2923 "ntp_parser.c"
break;
case 141: /* ac_flag_list: ac_flag_list access_control_flag */
-#line 919 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 919 "../../ntpd/ntp_parser.y"
{
attr_val *av;
av = create_attr_ival((yyvsp[0].Integer), 1);
APPEND_G_FIFO((yyval.Attr_val_fifo), av);
}
-#line 2962 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2935 "ntp_parser.c"
break;
case 142: /* ac_flag_list: ac_flag_list T_Serverresponse T_Fuzz */
-#line 927 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 927 "../../ntpd/ntp_parser.y"
{
attr_val *av;
av = create_attr_ival(T_ServerresponseFuzz, 1);
APPEND_G_FIFO((yyval.Attr_val_fifo), av);
}
-#line 2974 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2947 "ntp_parser.c"
break;
case 160: /* discard_option_list: discard_option_list discard_option */
-#line 958 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 958 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2983 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2956 "ntp_parser.c"
break;
case 161: /* discard_option_list: discard_option */
-#line 963 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 963 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2992 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2965 "ntp_parser.c"
break;
case 162: /* discard_option: discard_option_keyword T_Integer */
-#line 971 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 971 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2998 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2971 "ntp_parser.c"
break;
case 166: /* mru_option_list: mru_option_list mru_option */
-#line 982 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 982 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3007 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2980 "ntp_parser.c"
break;
case 167: /* mru_option_list: mru_option */
-#line 987 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 987 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3016 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2989 "ntp_parser.c"
break;
case 168: /* mru_option: mru_option_keyword T_Integer */
-#line 995 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 995 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3022 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2995 "ntp_parser.c"
break;
case 177: /* fudge_command: T_Fudge address fudge_factor_list */
-#line 1015 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1015 "../../ntpd/ntp_parser.y"
{
addr_opts_node *aon;
aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.fudge, aon);
}
-#line 3033 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3006 "ntp_parser.c"
break;
case 178: /* fudge_factor_list: fudge_factor_list fudge_factor */
-#line 1025 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1025 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3042 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3015 "ntp_parser.c"
break;
case 179: /* fudge_factor_list: fudge_factor */
-#line 1030 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1030 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3051 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3024 "ntp_parser.c"
break;
case 180: /* fudge_factor: fudge_factor_dbl_keyword number */
-#line 1038 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1038 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 3057 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3030 "ntp_parser.c"
break;
case 181: /* fudge_factor: fudge_factor_bool_keyword boolean */
-#line 1040 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1040 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3063 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3036 "ntp_parser.c"
break;
case 182: /* fudge_factor: T_Stratum T_Integer */
-#line 1042 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1042 "../../ntpd/ntp_parser.y"
{
if ((yyvsp[0].Integer) >= 0 && (yyvsp[0].Integer) <= 16) {
(yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
yyerror("fudge factor: stratum value not in [0..16], ignored");
}
}
-#line 3076 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3049 "ntp_parser.c"
break;
case 183: /* fudge_factor: T_Abbrev T_String */
-#line 1051 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1051 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 3082 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3055 "ntp_parser.c"
break;
case 184: /* fudge_factor: T_Refid T_String */
-#line 1053 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1053 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 3088 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3061 "ntp_parser.c"
break;
case 192: /* device_command: T_Device address device_item_list */
-#line 1075 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1075 "../../ntpd/ntp_parser.y"
{
addr_opts_node *aon;
aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.device, aon);
}
-#line 3099 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3072 "ntp_parser.c"
break;
case 193: /* device_item_list: device_item_list device_item */
-#line 1085 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1085 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3108 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3081 "ntp_parser.c"
break;
case 194: /* device_item_list: device_item */
-#line 1090 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1090 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3117 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3090 "ntp_parser.c"
break;
case 195: /* device_item: device_item_path_keyword T_String */
-#line 1098 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1098 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 3123 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3096 "ntp_parser.c"
break;
case 198: /* rlimit_command: T_Rlimit rlimit_option_list */
-#line 1112 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1112 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[0].Attr_val_fifo)); }
-#line 3129 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3102 "ntp_parser.c"
break;
case 199: /* rlimit_option_list: rlimit_option_list rlimit_option */
-#line 1117 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1117 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3138 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3111 "ntp_parser.c"
break;
case 200: /* rlimit_option_list: rlimit_option */
-#line 1122 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1122 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3147 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3120 "ntp_parser.c"
break;
case 201: /* rlimit_option: rlimit_option_keyword T_Integer */
-#line 1130 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1130 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3153 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3126 "ntp_parser.c"
break;
case 205: /* system_option_command: T_Enable system_option_list */
-#line 1146 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1146 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[0].Attr_val_fifo)); }
-#line 3159 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3132 "ntp_parser.c"
break;
case 206: /* system_option_command: T_Disable system_option_list */
-#line 1148 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1148 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[0].Attr_val_fifo)); }
-#line 3165 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3138 "ntp_parser.c"
break;
case 207: /* system_option_list: system_option_list system_option */
-#line 1153 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1153 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3174 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3147 "ntp_parser.c"
break;
case 208: /* system_option_list: system_option */
-#line 1158 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1158 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3183 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3156 "ntp_parser.c"
break;
case 209: /* system_option: system_option_flag_keyword */
-#line 1166 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1166 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 3189 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3162 "ntp_parser.c"
break;
case 210: /* system_option: system_option_local_flag_keyword */
-#line 1168 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1168 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
(yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer));
yyerror(err_str);
}
}
-#line 3207 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3180 "ntp_parser.c"
break;
case 223: /* tinker_command: T_Tinker tinker_option_list */
-#line 1207 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1207 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[0].Attr_val_fifo)); }
-#line 3213 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3186 "ntp_parser.c"
break;
case 224: /* tinker_option_list: tinker_option_list tinker_option */
-#line 1212 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1212 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3222 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3195 "ntp_parser.c"
break;
case 225: /* tinker_option_list: tinker_option */
-#line 1217 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1217 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3231 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3204 "ntp_parser.c"
break;
case 226: /* tinker_option: tinker_option_keyword number */
-#line 1225 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1225 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 3237 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3210 "ntp_parser.c"
break;
case 239: /* miscellaneous_command: misc_cmd_dbl_keyword number */
-#line 1250 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1250 "../../ntpd/ntp_parser.y"
{
attr_val *av;
av = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 3248 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3221 "ntp_parser.c"
break;
case 240: /* miscellaneous_command: misc_cmd_int_keyword T_Integer */
-#line 1257 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1257 "../../ntpd/ntp_parser.y"
{
attr_val *av;
av = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 3259 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3232 "ntp_parser.c"
break;
case 241: /* miscellaneous_command: misc_cmd_str_keyword T_String */
-#line 1264 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1264 "../../ntpd/ntp_parser.y"
{
attr_val *av;
av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 3270 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3243 "ntp_parser.c"
break;
case 242: /* miscellaneous_command: misc_cmd_str_lcl_keyword T_String */
-#line 1271 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1271 "../../ntpd/ntp_parser.y"
{
char error_text[64];
attr_val *av;
yyerror(error_text);
}
}
-#line 3290 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3263 "ntp_parser.c"
break;
case 243: /* miscellaneous_command: T_Includefile T_String command */
-#line 1287 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1287 "../../ntpd/ntp_parser.y"
{
if (!lex_from_file()) {
YYFREE((yyvsp[-1].String)); /* avoid leak */
}
YYFREE((yyvsp[-1].String)); /* avoid leak */
}
-#line 3313 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3286 "ntp_parser.c"
break;
case 244: /* miscellaneous_command: T_Leapfile T_String opt_hash_check */
-#line 1306 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1306 "../../ntpd/ntp_parser.y"
{
attr_val *av;
av->flag = (yyvsp[0].Integer);
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 3325 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3298 "ntp_parser.c"
break;
case 245: /* miscellaneous_command: T_End */
-#line 1314 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1314 "../../ntpd/ntp_parser.y"
{ lex_flush_stack(); }
-#line 3331 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3304 "ntp_parser.c"
break;
case 246: /* miscellaneous_command: T_Driftfile drift_parm */
-#line 1316 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1316 "../../ntpd/ntp_parser.y"
{ /* see drift_parm below for actions */ }
-#line 3337 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3310 "ntp_parser.c"
break;
case 247: /* miscellaneous_command: T_Logconfig log_config_list */
-#line 1318 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1318 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[0].Attr_val_fifo)); }
-#line 3343 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3316 "ntp_parser.c"
break;
case 248: /* miscellaneous_command: T_Phone string_list */
-#line 1320 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1320 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.phone, (yyvsp[0].String_fifo)); }
-#line 3349 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3322 "ntp_parser.c"
break;
case 249: /* miscellaneous_command: T_PollSkewList pollskew_list */
-#line 1322 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1322 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.pollskewlist, (yyvsp[0].Attr_val_fifo)); }
-#line 3355 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3328 "ntp_parser.c"
break;
case 250: /* miscellaneous_command: T_Setvar variable_assign */
-#line 1324 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1324 "../../ntpd/ntp_parser.y"
{ APPEND_G_FIFO(cfgt.setvar, (yyvsp[0].Set_var)); }
-#line 3361 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3334 "ntp_parser.c"
break;
case 251: /* miscellaneous_command: T_Trap ip_address trap_option_list */
-#line 1326 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1326 "../../ntpd/ntp_parser.y"
{
addr_opts_node *aon;
aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.trap, aon);
}
-#line 3372 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3345 "ntp_parser.c"
break;
case 252: /* miscellaneous_command: T_Ttl integer_list */
-#line 1333 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1333 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[0].Attr_val_fifo)); }
-#line 3378 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3351 "ntp_parser.c"
break;
case 257: /* misc_cmd_int_keyword: T_Leapsmearinterval */
-#line 1348 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1348 "../../ntpd/ntp_parser.y"
{
#ifndef LEAP_SMEAR
yyerror("Built without LEAP_SMEAR support.");
#endif
}
-#line 3388 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3361 "ntp_parser.c"
break;
case 258: /* opt_hash_check: T_Ignorehash */
-#line 1357 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1357 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = FALSE; }
-#line 3394 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3367 "ntp_parser.c"
break;
case 259: /* opt_hash_check: T_Checkhash */
-#line 1359 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1359 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = TRUE; }
-#line 3400 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3373 "ntp_parser.c"
break;
case 260: /* opt_hash_check: %empty */
-#line 1361 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1361 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = TRUE; }
-#line 3406 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3379 "ntp_parser.c"
break;
case 265: /* drift_parm: T_String */
-#line 1376 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1376 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
attr_val *av;
yyerror("driftfile remote configuration ignored");
}
}
-#line 3421 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3394 "ntp_parser.c"
break;
case 266: /* drift_parm: T_String T_Double */
-#line 1387 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1387 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
attr_val *av;
yyerror("driftfile remote configuration ignored");
}
}
-#line 3442 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3415 "ntp_parser.c"
break;
case 267: /* drift_parm: %empty */
-#line 1404 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1404 "../../ntpd/ntp_parser.y"
{
if (lex_from_file()) {
attr_val *av;
yyerror("driftfile remote configuration ignored");
}
}
-#line 3456 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3429 "ntp_parser.c"
break;
case 268: /* pollskew_list: %empty */
-#line 1417 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1417 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = NULL; }
-#line 3462 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3435 "ntp_parser.c"
break;
case 269: /* pollskew_list: pollskew_list pollskew_spec */
-#line 1419 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1419 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = append_gen_fifo((yyvsp[-1].Attr_val_fifo), (yyvsp[0].Attr_val)); }
-#line 3468 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3441 "ntp_parser.c"
break;
case 270: /* pollskew_spec: pollskew_cycle T_Integer '|' T_Integer */
-#line 1424 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1424 "../../ntpd/ntp_parser.y"
{
if ((yyvsp[-2].Integer) < 0 || (yyvsp[0].Integer) < 0) {
/* bad numbers */
}
(yyval.Attr_val) = (yyvsp[-3].Attr_val);
}
-#line 3495 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3468 "ntp_parser.c"
break;
case 271: /* pollskew_cycle: T_Integer */
-#line 1449 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
- { (yyval.Attr_val) = ((yyvsp[0].Integer) >= 3 && (yyvsp[0].Integer) <= 17) ? create_attr_rval((yyvsp[0].Integer), 0, 0) : NULL; }
-#line 3501 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 1450 "../../ntpd/ntp_parser.y"
+ {
+ (yyval.Attr_val) = ((yyvsp[0].Integer) >= NTP_MINPOLL && (yyvsp[0].Integer) <= NTP_MAXPOLL)
+ ? create_attr_rval((yyvsp[0].Integer), 0, 0)
+ : NULL;
+ }
+#line 3478 "ntp_parser.c"
break;
case 272: /* pollskew_cycle: T_Default */
-#line 1450 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1455 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_rval(-1, 0, 0); }
-#line 3507 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3484 "ntp_parser.c"
break;
case 273: /* variable_assign: T_String '=' T_String t_default_or_zero */
-#line 1456 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1461 "../../ntpd/ntp_parser.y"
{ (yyval.Set_var) = create_setvar_node((yyvsp[-3].String), (yyvsp[-1].String), (yyvsp[0].Integer)); }
-#line 3513 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3490 "ntp_parser.c"
break;
case 275: /* t_default_or_zero: %empty */
-#line 1462 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1467 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = 0; }
-#line 3519 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3496 "ntp_parser.c"
break;
case 276: /* trap_option_list: %empty */
-#line 1467 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1472 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val_fifo) = NULL; }
-#line 3525 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3502 "ntp_parser.c"
break;
case 277: /* trap_option_list: trap_option_list trap_option */
-#line 1469 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1474 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3534 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3511 "ntp_parser.c"
break;
case 278: /* trap_option: T_Port T_Integer */
-#line 1477 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1482 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3540 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3517 "ntp_parser.c"
break;
case 279: /* trap_option: T_Interface ip_address */
-#line 1479 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1484 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), estrdup((yyvsp[0].Address_node)->address));
destroy_address_node((yyvsp[0].Address_node));
}
-#line 3549 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3526 "ntp_parser.c"
break;
case 280: /* log_config_list: log_config_list log_config_command */
-#line 1487 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1492 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3558 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3535 "ntp_parser.c"
break;
case 281: /* log_config_list: log_config_command */
-#line 1492 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1497 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3567 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3544 "ntp_parser.c"
break;
case 282: /* log_config_command: T_String */
-#line 1500 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1505 "../../ntpd/ntp_parser.y"
{
char prefix;
char * type;
(yyval.Attr_val) = create_attr_sval(prefix, estrdup(type));
YYFREE((yyvsp[0].String));
}
-#line 3593 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3570 "ntp_parser.c"
break;
case 283: /* interface_command: interface_nic nic_rule_action nic_rule_class */
-#line 1525 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1530 "../../ntpd/ntp_parser.y"
{
nic_rule_node *nrn;
nrn = create_nic_rule_node((yyvsp[0].Integer), NULL, (yyvsp[-1].Integer));
APPEND_G_FIFO(cfgt.nic_rules, nrn);
}
-#line 3604 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3581 "ntp_parser.c"
break;
case 284: /* interface_command: interface_nic nic_rule_action T_String */
-#line 1532 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1537 "../../ntpd/ntp_parser.y"
{
nic_rule_node *nrn;
nrn = create_nic_rule_node(0, (yyvsp[0].String), (yyvsp[-1].Integer));
APPEND_G_FIFO(cfgt.nic_rules, nrn);
}
-#line 3615 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3592 "ntp_parser.c"
break;
case 294: /* reset_command: T_Reset counter_set_list */
-#line 1560 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1565 "../../ntpd/ntp_parser.y"
{ CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[0].Int_fifo)); }
-#line 3621 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3598 "ntp_parser.c"
break;
case 295: /* counter_set_list: counter_set_list counter_set_keyword */
-#line 1565 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1570 "../../ntpd/ntp_parser.y"
{
(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3630 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3607 "ntp_parser.c"
break;
case 296: /* counter_set_list: counter_set_keyword */
-#line 1570 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1575 "../../ntpd/ntp_parser.y"
{
(yyval.Int_fifo) = NULL;
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3639 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3616 "ntp_parser.c"
break;
case 304: /* integer_list: integer_list T_Integer */
-#line 1594 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1599 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3648 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3625 "ntp_parser.c"
break;
case 305: /* integer_list: T_Integer */
-#line 1599 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1604 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3657 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3634 "ntp_parser.c"
break;
case 306: /* integer_list_range: integer_list_range integer_list_range_elt */
-#line 1607 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1612 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3666 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3643 "ntp_parser.c"
break;
case 307: /* integer_list_range: integer_list_range_elt */
-#line 1612 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1617 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3675 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3652 "ntp_parser.c"
break;
case 308: /* integer_list_range_elt: T_Integer */
-#line 1620 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1625 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_ival('i', (yyvsp[0].Integer)); }
-#line 3681 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3658 "ntp_parser.c"
break;
case 310: /* integer_range: '(' T_Integer T_Ellipsis T_Integer ')' */
-#line 1626 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1631 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_rval('-', (yyvsp[-3].Integer), (yyvsp[-1].Integer)); }
-#line 3687 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3664 "ntp_parser.c"
break;
case 311: /* string_list: string_list T_String */
-#line 1631 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1636 "../../ntpd/ntp_parser.y"
{
(yyval.String_fifo) = (yyvsp[-1].String_fifo);
APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String)));
}
-#line 3696 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3673 "ntp_parser.c"
break;
case 312: /* string_list: T_String */
-#line 1636 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1641 "../../ntpd/ntp_parser.y"
{
(yyval.String_fifo) = NULL;
APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String)));
}
-#line 3705 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3682 "ntp_parser.c"
break;
case 313: /* address_list: address_list address */
-#line 1644 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1649 "../../ntpd/ntp_parser.y"
{
(yyval.Address_fifo) = (yyvsp[-1].Address_fifo);
APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node));
}
-#line 3714 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3691 "ntp_parser.c"
break;
case 314: /* address_list: address */
-#line 1649 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1654 "../../ntpd/ntp_parser.y"
{
(yyval.Address_fifo) = NULL;
APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node));
}
-#line 3723 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3700 "ntp_parser.c"
break;
case 315: /* boolean: T_Integer */
-#line 1657 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1662 "../../ntpd/ntp_parser.y"
{
if ((yyvsp[0].Integer) != 0 && (yyvsp[0].Integer) != 1) {
yyerror("Integer value is not boolean (0 or 1). Assuming 1");
(yyval.Integer) = (yyvsp[0].Integer);
}
}
-#line 3736 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3713 "ntp_parser.c"
break;
case 316: /* boolean: T_True */
-#line 1665 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1670 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = 1; }
-#line 3742 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3719 "ntp_parser.c"
break;
case 317: /* boolean: T_False */
-#line 1666 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1671 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = 0; }
-#line 3748 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3725 "ntp_parser.c"
break;
case 318: /* number: T_Integer */
-#line 1670 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1675 "../../ntpd/ntp_parser.y"
{ (yyval.Double) = (double)(yyvsp[0].Integer); }
-#line 3754 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3731 "ntp_parser.c"
break;
case 320: /* basedate: T_Basedate T_String */
-#line 1676 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1681 "../../ntpd/ntp_parser.y"
{ (yyval.Integer) = basedate_eval_string((yyvsp[0].String)); YYFREE((yyvsp[0].String)); }
-#line 3760 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3737 "ntp_parser.c"
break;
case 321: /* simulate_command: sim_conf_start '{' sim_init_statement_list sim_server_list '}' */
-#line 1684 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1689 "../../ntpd/ntp_parser.y"
{
sim_node *sn;
/* Revert from ; to \n for end-of-command */
old_config_style = 1;
}
-#line 3774 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3751 "ntp_parser.c"
break;
case 322: /* sim_conf_start: T_Simulate */
-#line 1701 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1706 "../../ntpd/ntp_parser.y"
{ old_config_style = 0; }
-#line 3780 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3757 "ntp_parser.c"
break;
case 323: /* sim_init_statement_list: sim_init_statement_list sim_init_statement T_EOC */
-#line 1706 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1711 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3789 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3766 "ntp_parser.c"
break;
case 324: /* sim_init_statement_list: sim_init_statement T_EOC */
-#line 1711 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1716 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3798 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3775 "ntp_parser.c"
break;
case 325: /* sim_init_statement: sim_init_keyword '=' number */
-#line 1719 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1724 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); }
-#line 3804 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3781 "ntp_parser.c"
break;
case 328: /* sim_server_list: sim_server_list sim_server */
-#line 1729 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1734 "../../ntpd/ntp_parser.y"
{
(yyval.Sim_server_fifo) = (yyvsp[-1].Sim_server_fifo);
APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server));
}
-#line 3813 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3790 "ntp_parser.c"
break;
case 329: /* sim_server_list: sim_server */
-#line 1734 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1739 "../../ntpd/ntp_parser.y"
{
(yyval.Sim_server_fifo) = NULL;
APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server));
}
-#line 3822 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3799 "ntp_parser.c"
break;
case 330: /* sim_server: sim_server_name '{' sim_server_offset sim_act_list '}' */
-#line 1742 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1747 "../../ntpd/ntp_parser.y"
{ (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[-4].Address_node), (yyvsp[-2].Double), (yyvsp[-1].Sim_script_fifo))); }
-#line 3828 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3805 "ntp_parser.c"
break;
case 331: /* sim_server_offset: T_Server_Offset '=' number T_EOC */
-#line 1747 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1752 "../../ntpd/ntp_parser.y"
{ (yyval.Double) = (yyvsp[-1].Double); }
-#line 3834 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3811 "ntp_parser.c"
break;
case 332: /* sim_server_name: T_Server '=' address */
-#line 1752 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1757 "../../ntpd/ntp_parser.y"
{ (yyval.Address_node) = (yyvsp[0].Address_node); }
-#line 3840 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3817 "ntp_parser.c"
break;
case 333: /* sim_act_list: sim_act_list sim_act */
-#line 1757 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1762 "../../ntpd/ntp_parser.y"
{
(yyval.Sim_script_fifo) = (yyvsp[-1].Sim_script_fifo);
APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script));
}
-#line 3849 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3826 "ntp_parser.c"
break;
case 334: /* sim_act_list: sim_act */
-#line 1762 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1767 "../../ntpd/ntp_parser.y"
{
(yyval.Sim_script_fifo) = NULL;
APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script));
}
-#line 3858 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3835 "ntp_parser.c"
break;
case 335: /* sim_act: T_Duration '=' number '{' sim_act_stmt_list '}' */
-#line 1770 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1775 "../../ntpd/ntp_parser.y"
{ (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[-3].Double), (yyvsp[-1].Attr_val_fifo))); }
-#line 3864 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3841 "ntp_parser.c"
break;
case 336: /* sim_act_stmt_list: sim_act_stmt_list sim_act_stmt T_EOC */
-#line 1775 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1780 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3873 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3850 "ntp_parser.c"
break;
case 337: /* sim_act_stmt_list: sim_act_stmt T_EOC */
-#line 1780 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1785 "../../ntpd/ntp_parser.y"
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3882 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3859 "ntp_parser.c"
break;
case 338: /* sim_act_stmt: sim_act_keyword '=' number */
-#line 1788 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1793 "../../ntpd/ntp_parser.y"
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); }
-#line 3888 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3865 "ntp_parser.c"
break;
-#line 3892 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3869 "ntp_parser.c"
default: break;
}
label yyerrorlab therefore never appears in user code. */
if (0)
YYERROR;
+ ++yynerrs;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
- goto yyreturn;
+ goto yyreturnlab;
/*-----------------------------------.
`-----------------------------------*/
yyabortlab:
yyresult = 1;
- goto yyreturn;
+ goto yyreturnlab;
-#if !defined yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
+/*-----------------------------------------------------------.
+| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
+`-----------------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
- goto yyreturn;
-#endif
+ goto yyreturnlab;
-/*-------------------------------------------------------.
-| yyreturn -- parsing is finished, clean up and return. |
-`-------------------------------------------------------*/
-yyreturn:
+/*----------------------------------------------------------.
+| yyreturnlab -- parsing is finished, clean up and return. |
+`----------------------------------------------------------*/
+yyreturnlab:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
return yyresult;
}
-#line 1799 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1804 "../../ntpd/ntp_parser.y"
void
-/* A Bison parser, made by GNU Bison 3.7.6. */
+/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
-#ifndef YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
-# define YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
+#ifndef YY_YY_NTP_PARSER_H_INCLUDED
+# define YY_YY_NTP_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
-#line 52 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 52 "../../ntpd/ntp_parser.y"
char * String;
double Double;
script_info * Sim_script;
script_info_fifo * Sim_script_fifo;
-#line 514 "../../../src/ntp-stable-3758/ntpd/ntp_parser.h"
+#line 514 "ntp_parser.h"
};
typedef union YYSTYPE YYSTYPE;
extern YYSTYPE yylval;
+
int yyparse (void);
-#endif /* !YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED */
+
+#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */
;
pollskew_cycle
- : T_Integer { $$ = ($1 >= 3 && $1 <= 17) ? create_attr_rval($1, 0, 0) : NULL; }
+ : T_Integer
+ {
+ $$ = ($1 >= NTP_MINPOLL && $1 <= NTP_MAXPOLL)
+ ? create_attr_rval($1, 0, 0)
+ : NULL;
+ }
| T_Default { $$ = create_attr_rval(-1, 0, 0); }
;
p->dstadr->peercnt--;
UNLINK_SLIST(unlinked, p->dstadr->peers, p, ilink,
struct peer);
- msyslog(LOG_INFO, "%s local addr %s -> %s",
- stoa(&p->srcadr), latoa(p->dstadr),
- latoa(dstadr));
+ if (!IS_MCAST(&p->srcadr)) {
+ msyslog(LOG_INFO, "%s local addr %s -> %s",
+ stoa(&p->srcadr), latoa(p->dstadr),
+ latoa(dstadr));
+ }
}
-
+
p->dstadr = dstadr;
/* link to list if we have an address after assignment */
#include "ntp_leapsec.h"
#include "ntp_psl.h"
#include "refidsmear.h"
-#include "lib_strbuf.h"
#include <stdio.h>
#ifdef HAVE_LIBSCF_H
#define SRVFUZ_SHIFT 6 /* 64 seconds */
#define SRVRSP_FUZZ(x) \
do { \
- x.l_uf &= 0; \
+ x.l_uf = 0; \
x.l_ui &= ~((1 << SRVFUZ_SHIFT) - 1U); \
- } while(0)
+ } while (FALSE)
/*
* This macro defines the authentication state. If x is 1 authentication
}
if (hismode == MODE_PRIVATE) {
if (!ntp_mode7 || (restrict_mask & RES_NOQUERY)) {
- DPRINTF(2, ("receive: drop: RES_NOQUERY\n"));
+ DPRINTF(2, ("receive: drop: !mode7 or RES_NOQUERY\n"));
sys_restricted++;
return; /* no query private */
}
- process_private(rbufp, ((restrict_mask &
- RES_NOMODIFY) == 0));
+ process_private(rbufp, !(RES_NOMODIFY & restrict_mask));
return;
}
if (hismode == MODE_CONTROL) {
INSIST(0 != hisstratum); /* paranoia check PKT_TO_STRATUM result */
DPRINTF(1, ("receive: at %ld %s<-%s ippeerlimit %d mode %d iflags %s "
- "restrict %s org %#010x.%08x xmt %#010x.%08x\n",
+ "restrict %s org 0x%8x.%08x xmt 0x%8x.%08x\n",
current_time, stoa(&rbufp->dstadr->sin),
stoa(&rbufp->recv_srcadr), r4a.ippeerlimit, hismode,
- build_iflags(rbufp->dstadr->flags),
- build_rflags(restrict_mask),
+ iflags_str(rbufp->dstadr->flags),
+ rflags_str(restrict_mask),
ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));
if (has_mac == 0) {
restrict_mask &= ~RES_MSSNTP;
is_authentic = AUTH_NONE; /* not required */
- DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %#010x.%08x xmt %#010x.%08x NOMAC\n",
+ DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org 0x%x.%08x xmt 0x%x.%08x NOMAC\n",
current_time, stoa(dstadr_sin),
stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
authlen,
} else if (crypto_nak_test == VALIDNAK) {
restrict_mask &= ~RES_MSSNTP;
is_authentic = AUTH_CRYPTO; /* crypto-NAK */
- DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x CRYPTONAK\n",
+ DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org 0x%x.%08x xmt 0x%x.%08x CRYPTONAK\n",
current_time, stoa(dstadr_sin),
stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
skeyid, authlen + has_mac, is_authentic,
&& (memcmp(zero_key, (char *)pkt + authlen + 4,
MAX_MD5_LEN - 4) == 0)) {
is_authentic = AUTH_NONE;
- DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %#010x.%08x xmt %#010x.%08x SIGND\n",
+ DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %x.%08x xmt %x.%08x SIGND\n",
current_time, stoa(dstadr_sin),
stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
authlen,
if (crypto_flags && skeyid > NTP_MAXKEY)
authtrust(skeyid, 0);
#endif /* AUTOKEY */
- DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x MAC\n",
+ DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org 0x%x.%08x xmt 0x%x.%08x MAC\n",
current_time, stoa(dstadr_sin),
stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
skeyid, authlen + has_mac, is_authentic,
if ( tdiff.l_i < 0
&& (current_time - peer->timereceived) < deadband)
{
- msyslog(LOG_INFO, "receive: broadcast packet from %s contains non-monotonic timestamp: %#010x.%08x -> %#010x.%08x",
+ msyslog(LOG_INFO, "receive: broadcast packet from %s contains non-monotonic timestamp: 0x%x.%08x -> 0x%x.%08x",
stoa(&rbufp->recv_srcadr),
peer->bxmt.l_ui, peer->bxmt.l_uf,
p_xmt.l_ui, p_xmt.l_uf
if (peer->flip == 0 && !L_ISEQU(&p_org, &peer->aorg)) {
peer->bogusorg++;
msyslog(LOG_INFO,
- "receive: flip 0 KoD origin timestamp %#010x.%08x from %s does not match %#010x.%08x - ignoring.",
+ "receive: flip 0 KoD origin timestamp 0x%x.%08x from %s does not match 0x%x.%08x - ignoring.",
p_org.l_ui, p_org.l_uf,
ntoa(&peer->srcadr),
peer->aorg.l_ui, peer->aorg.l_uf);
} else if (peer->flip == 1 && !L_ISEQU(&p_org, &peer->borg)) {
peer->bogusorg++;
msyslog(LOG_INFO,
- "receive: flip 1 KoD origin timestamp %#010x.%08x from %s does not match interleave %#010x.%08x - ignoring.",
+ "receive: flip 1 KoD origin timestamp 0x%x.%08x from %s does not match interleave 0x%x.%08x - ignoring.",
p_org.l_ui, p_org.l_uf,
ntoa(&peer->srcadr),
peer->borg.l_ui, peer->borg.l_uf);
}
/**/
msyslog(LOG_INFO,
- "receive: %s 0 origin timestamp from %s@%s xmt %#010x.%08x",
+ "receive: %s 0 origin timestamp from %s@%s xmt 0x%x.%08x",
action, hm_str, ntoa(&peer->srcadr),
ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf));
} else if (!L_ISEQU(&p_org, &peer->aorg)) {
peer->bogusorg++;
peer->flash |= TEST2; /* bogus */
msyslog(LOG_INFO,
- "receive: Unexpected origin timestamp %#010x.%08x does not match aorg %#010x.%08x from %s@%s xmt %#010x.%08x",
+ "receive: Unexpected origin timestamp 0x%x.%08x does not match aorg 0x%x.%08x from %s@%s xmt 0x%x.%08x",
ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
peer->aorg.l_ui, peer->aorg.l_uf,
hm_str, ntoa(&peer->srcadr),
double p_offset, p_del, p_disp;
l_fp p_rec, p_xmt, p_org, p_reftime, ci;
u_char pmode, pleap, pversion, pstratum;
- char statstr[NTP_MAXSTRLEN];
#ifdef ASSYM
int itemp;
double etemp, ftemp, td;
p_del = t21 - t34;
p_offset = (t21 + t34) / 2.;
if (p_del < 0 || p_del > 1.) {
- snprintf(statstr, sizeof(statstr),
- "t21 %.6f t34 %.6f", t21, t34);
- report_event(PEVNT_XERR, peer, statstr);
+ mprintf_event(PEVNT_XERR, peer,
+ "t21 %.9f t34 %.9f", t21, t34);
return;
}
/* drop all if in the initial volley */
if (FLAG_BC_VOL & peer->flags)
goto bcc_init_volley_fail;
- snprintf(statstr, sizeof(statstr),
- "offset %.6f delay %.6f", t21, t34);
- report_event(PEVNT_XERR, peer, statstr);
+ mprintf_event(PEVNT_XERR, peer,
+ "offset %.9f delay %.9f",
+ t21, t34);
return;
}
p_offset = t21;
if ( 0 != sub
|| 0 != qty) {
- do {
+ do {
val = ntp_random() & msk;
} while (val > qty);
)
{
double dst[NTP_SHIFT]; /* distance vector */
- int ord[NTP_SHIFT]; /* index vector */
- int i, j, k, m;
+ u_char ord[NTP_SHIFT]; /* index vector */
+ short i, j;
+ u_char k, m;
double dtemp, etemp;
- char tbuf[80];
/*
* A sample consists of the offset, delay, dispersion and epoch
peer->filter_disp[j] = sample_disp;
peer->filter_epoch[j] = current_time;
j = (j + 1) % NTP_SHIFT;
- peer->filter_nextpt = j;
+ peer->filter_nextpt = (u_char)j;
/*
* Update dispersions since the last update and at the same
} else {
dst[i] = peer->filter_delay[j];
}
- ord[i] = j;
+ ord[i] = (u_char)j;
j = (j + 1) % NTP_SHIFT;
}
*/
m = 0;
for (i = 0; i < NTP_SHIFT; i++) {
- peer->filter_order[i] = (u_char) ord[i];
+ peer->filter_order[i] = ord[i];
if ( dst[i] >= MAXDISPERSE
|| (m >= 2 && dst[i] >= sys_maxdist))
continue;
k = ord[0];
for (i = NTP_SHIFT - 1; i >= 0; i--) {
j = ord[i];
- peer->disp = NTP_FWEIGHT * (peer->disp +
- peer->filter_disp[j]);
- if (i < m)
+ peer->disp = NTP_FWEIGHT * ( peer->disp
+ + peer->filter_disp[j]);
+ if (i < m) {
peer->jitter += DIFF(peer->filter_offset[j],
- peer->filter_offset[k]);
+ peer->filter_offset[k]);
+ }
}
/*
* save the offset, delay and jitter. Note the jitter must not
* be less than the precision.
*/
- if (m == 0) {
+ if (0 == m) {
clock_select();
return;
}
etemp = fabs(peer->offset - peer->filter_offset[k]);
peer->offset = peer->filter_offset[k];
peer->delay = peer->filter_delay[k];
- if (m > 1)
+ if (m > 1) {
peer->jitter /= m - 1;
+ }
peer->jitter = max(SQRT(peer->jitter), LOGTOD(sys_precision));
/*
if ( peer->disp < sys_maxdist
&& peer->filter_disp[k] < sys_maxdist
&& etemp > CLOCK_SGATE * peer->jitter
- && peer->filter_epoch[k] - peer->epoch
+ && peer->filter_epoch[k] - peer->epoch
< 2. * ULOGTOD(peer->hpoll)) {
- snprintf(tbuf, sizeof(tbuf), "%.6f s", etemp);
- report_event(PEVNT_POPCORN, peer, tbuf);
+ mprintf_event(PEVNT_POPCORN, peer, "%.9f s", etemp);
return;
}
/*
* A new minimum sample is useful only if it is later than the
* last one used. In this design the maximum lifetime of any
- * sample is not greater than eight times the poll interval, so
- * the maximum interval between minimum samples is eight
- * packets.
+ * sample is not greater than NTP_SHIFT (8) times the poll
+ * interval, so the maximum interval between minimum samples is
+ * NTP_SHIFT packets.
*/
if (peer->filter_epoch[k] <= peer->epoch) {
- DPRINTF(2, ("clock_filter: old sample %lu\n", current_time -
- peer->filter_epoch[k]));
+ DPRINTF(2, ("clock_filter: old sample %lu s\n",
+ current_time - peer->filter_epoch[k]));
return;
}
peer->epoch = peer->filter_epoch[k];
* processing. If not synchronized or not in a burst, tickle the
* clock select algorithm.
*/
- record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
- peer->offset, peer->delay, peer->disp, peer->jitter);
- DPRINTF(1, ("clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n",
- m, peer->offset, peer->delay, peer->disp,
+ record_peer_stats(&peer->srcadr, ctlpeerstatus(peer), peer->offset,
+ peer->delay, peer->disp, peer->jitter);
+ DPRINTF(1, ("clock_filter: n %hu off %.9f del %.9f dsp %.9f jit %.9f\n",
+ (u_short)m, peer->offset, peer->delay, peer->disp,
peer->jitter));
- if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC)
+ if (0 == peer->burst || LEAP_NOTINSYNC == sys_leap) {
clock_select();
+ }
}
|| ((FLAG_TRUE | FLAG_PREFER) & peers[k].peer->flags))
break;
- DPRINTF(3, ("select: drop %s seljit %.6f jit %.6f\n",
+ DPRINTF(3, ("select: drop %s seljit %.9f jit %.9f\n",
ntoa(&peers[k].peer->srcadr), g, d));
if (nlist > sys_maxclock)
peers[k].peer->new_status = CTL_PST_SEL_EXCESS;
sys_clockhop = sys_mindisp;
else
sys_clockhop *= .5;
- DPRINTF(1, ("select: clockhop %d %.6f %.6f\n",
+ DPRINTF(1, ("select: clockhop %d %.9f %.9f\n",
j, x, sys_clockhop));
if (x < sys_clockhop)
typesystem = osys_peer;
}
L_SUB(&xmt_ty, &xmt_tx);
LFPTOD(&xmt_ty, peer->xleave);
- DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d len %zu xmt %#010x.%08x\n",
- current_time,
- peer->dstadr ? stoa(&peer->dstadr->sin) : "-",
+ DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d len %zu xmt 0x%x.%08x\n",
+ current_time, latoa(peer->dstadr),
stoa(&peer->srcadr), peer->hmode, sendlen,
xmt_tx.l_ui, xmt_tx.l_uf));
return;
authtrust(xkeyid, 0);
#endif /* AUTOKEY */
if (sendlen > sizeof(xpkt)) {
- msyslog(LOG_ERR, "peer_xmit: buffer overflow %zu", sendlen);
- exit (-1);
+ msyslog(LOG_ERR, "peer_xmit: buffer overflow %u", (u_int)sendlen);
+ exit(EX_SOFTWARE);
}
peer->t21_bytes = sendlen;
sendpkt(&peer->srcadr, peer->dstadr,
LFPTOD(&xmt_ty, peer->xleave);
#ifdef AUTOKEY
DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu index %d\n",
- current_time, latoa(peer->dstadr),
- ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen,
- peer->keynumber));
+ current_time, latoa(peer->dstadr), stoa(&peer->srcadr),
+ peer->hmode, xkeyid, sendlen, peer->keynumber));
#else /* !AUTOKEY follows */
DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu\n",
current_time, peer->dstadr ?
#include "ntp_assert.h"
/*
- * This code keeps a simple address-and-mask list of hosts we want
- * to place restrictions on (or remove them from). The restrictions
- * are implemented as a set of flags which tell you what the host
- * can't do. There is a subroutine entry to return the flags. The
- * list is kept sorted to reduce the average number of comparisons
- * and make sure you get the set of restrictions most specific to
- * the address.
- *
- * The algorithm is that, when looking up a host, it is first assumed
- * that the default set of restrictions will apply. It then searches
- * down through the list. Whenever it finds a match it adopts the
- * match's flags instead. When you hit the point where the sorted
- * address is greater than the target, you return with the last set of
- * flags you found. Because of the ordering of the list, the most
- * specific match will provide the final set of flags.
+ * This code keeps a simple address-and-mask list of addressses we want
+ * to place restrictions on (or remove them from). The restrictions are
+ * implemented as a set of flags which tell you what matching addresses
+ * can't do. The list is sorted retrieve the restrictions most specific
+* to the address.
*
* This was originally intended to restrict you from sync'ing to your
* own broadcasts when you are doing that, by restricting yourself from
* has been expanded, however, to suit the needs of those with more
* restrictive access policies.
*/
-/*
- * We will use two lists, one for IPv4 addresses and one for IPv6
- * addresses. This is not protocol-independant but for now I can't
- * find a way to respect this. We'll check this later... JFB 07/2001
- */
#define MASK_IPV6_ADDR(dst, src, msk) \
do { \
- int idx; \
- for (idx = 0; idx < (int)COUNTOF((dst)->s6_addr); idx++) { \
- (dst)->s6_addr[idx] = (src)->s6_addr[idx] \
- & (msk)->s6_addr[idx]; \
+ int x; \
+ \
+ for (x = 0; x < (int)COUNTOF((dst)->s6_addr); x++) { \
+ (dst)->s6_addr[x] = (src)->s6_addr[x] \
+ & (msk)->s6_addr[x]; \
} \
- } while (0)
+ } while (FALSE)
/*
* We allocate INC_RESLIST{4|6} entries to the free list whenever empty.
- * Auto-tune these to be just less than 1KB (leaving at least 16 bytes
+ * Auto-tune these to be just less than 1KB (leaving at least 32 bytes
* for allocator overhead).
*/
-#define INC_RESLIST4 ((1024 - 16) / V4_SIZEOF_RESTRICT_U)
-#define INC_RESLIST6 ((1024 - 16) / V6_SIZEOF_RESTRICT_U)
+#define INC_RESLIST4 ((1024 - 32) / V4_SIZEOF_RESTRICT_U)
+#define INC_RESLIST6 ((1024 - 32) / V6_SIZEOF_RESTRICT_U)
/*
* The restriction list
/*
* private functions
*/
-static restrict_u * alloc_res4(void);
-static restrict_u * alloc_res6(void);
-static void free_res(restrict_u *, int);
-static void inc_res_limited(void);
-static void dec_res_limited(void);
-static restrict_u * match_restrict4_addr(u_int32, u_short);
-static restrict_u * match_restrict6_addr(const struct in6_addr *,
+static restrict_u * alloc_res4(void);
+static restrict_u * alloc_res6(void);
+static void free_res(restrict_u *, int);
+static inline void inc_res_limited(void);
+static inline void dec_res_limited(void);
+static restrict_u * match_restrict4_addr(u_int32, u_short);
+static restrict_u * match_restrict6_addr(const struct in6_addr *,
u_short);
-static restrict_u * match_restrict_entry(const restrict_u *, int);
-static int res_sorts_before4(restrict_u *, restrict_u *);
-static int res_sorts_before6(restrict_u *, restrict_u *);
-static char * roptoa(restrict_op op);
-
-
-void dump_restricts(void);
+static restrict_u * match_restrict_entry(const restrict_u *, int);
+static int res_sorts_before4(restrict_u *, restrict_u *);
+static int res_sorts_before6(restrict_u *, restrict_u *);
+ void dump_restricts(void);
/*
* dump_restrict - spit out a restrict_u
init_restrict(void)
{
/*
- * The restriction lists begin with a default entry with address
+ * The restriction lists end with a default entry with address
* and mask 0, which will match any entry. The lists are kept
* sorted by descending address followed by descending mask:
*
{
const size_t cb = V4_SIZEOF_RESTRICT_U;
const size_t count = INC_RESLIST4;
- restrict_u * rl;
- restrict_u * res;
+ restrict_u* rl;
+ restrict_u* res;
size_t i;
UNLINK_HEAD_SLIST(res, resfree4, link);
- if (res != NULL)
+ if (res != NULL) {
return res;
-
+ }
rl = eallocarray(count, cb);
/* link all but the first onto free list */
res = (void *)((char *)rl + (count - 1) * cb);
LINK_SLIST(resfree4, res, link);
res = (void *)((char *)res - cb);
}
- INSIST(rl == res);
+ DEBUG_INSIST(rl == res);
/* allocate the first */
return res;
}
size_t i;
UNLINK_HEAD_SLIST(res, resfree6, link);
- if (res != NULL)
+ if (res != NULL) {
return res;
-
+ }
rl = eallocarray(count, cb);
/* link all but the first onto free list */
res = (void *)((char *)rl + (count - 1) * cb);
LINK_SLIST(resfree6, res, link);
res = (void *)((char *)res - cb);
}
- INSIST(rl == res);
+ DEBUG_INSIST(rl == res);
/* allocate the first */
return res;
}
int v6
)
{
- restrict_u ** plisthead;
+ restrict_u ** rlisthead_ptr;
+ restrict_u ** flisthead_ptr;
restrict_u * unlinked;
+ size_t sz;
restrictcount--;
- if (RES_LIMITED & res->rflags)
+ if (RES_LIMITED & res->rflags) {
dec_res_limited();
-
- if (v6)
- plisthead = &restrictlist6;
- else
- plisthead = &restrictlist4;
- UNLINK_SLIST(unlinked, *plisthead, res, link, restrict_u);
- INSIST(unlinked == res);
-
+ }
if (v6) {
- zero_mem(res, V6_SIZEOF_RESTRICT_U);
- plisthead = &resfree6;
+ rlisthead_ptr = &restrictlist6;
+ flisthead_ptr = &resfree6;
+ sz = V6_SIZEOF_RESTRICT_U;
} else {
- zero_mem(res, V4_SIZEOF_RESTRICT_U);
- plisthead = &resfree4;
+ rlisthead_ptr = &restrictlist4;
+ flisthead_ptr = &resfree4;
+ sz = V4_SIZEOF_RESTRICT_U;
}
- LINK_SLIST(*plisthead, res, link);
+ UNLINK_SLIST(unlinked, *rlisthead_ptr, res, link, restrict_u);
+ INSIST(unlinked == res);
+ zero_mem(res, sz);
+ LINK_SLIST(*flisthead_ptr, res, link);
}
-static void
+static inline void
inc_res_limited(void)
{
- if (!res_limited_refcnt)
+ if (0 == res_limited_refcnt) {
mon_start(MON_RES);
+ }
res_limited_refcnt++;
}
-static void
+static inline void
dec_res_limited(void)
{
res_limited_refcnt--;
- if (!res_limited_refcnt)
+ if (0 == res_limited_refcnt) {
mon_stop(MON_RES);
+ }
}
u_short port
)
{
- const int v6 = 0;
+ const int v6 = FALSE;
restrict_u * res;
restrict_u * next;
for (res = restrictlist4; res != NULL; res = next) {
- struct in_addr sia = { htonl(res->u.v4.addr) };
-
next = res->link;
- DPRINTF(2, ("match_restrict4_addr: Checking %s, port %d ... ",
- inet_ntoa(sia), port));
- if ( res->expire
- && res->expire <= current_time)
+ if (res->expire && res->expire <= current_time) {
free_res(res, v6); /* zeroes the contents */
+ }
if ( res->u.v4.addr == (addr & res->u.v4.mask)
&& ( !(RESM_NTPONLY & res->mflags)
|| NTP_PORT == port)) {
- DPRINTF(2, ("MATCH: ippeerlimit %d\n", res->ippeerlimit));
+
break;
}
- DPRINTF(2, ("doesn't match: ippeerlimit %d\n", res->ippeerlimit));
}
return res;
}
u_short port
)
{
- const int v6 = 1;
+ const int v6 = TRUE;
restrict_u * res;
restrict_u * next;
struct in6_addr masked;
for (res = restrictlist6; res != NULL; res = next) {
next = res->link;
- INSIST(next != res);
- if (res->expire &&
- res->expire <= current_time)
+ if (res->expire && res->expire <= current_time) {
free_res(res, v6);
+ }
MASK_IPV6_ADDR(&masked, addr, &res->u.v6.mask);
if (ADDR6_EQ(&masked, &res->u.v6.addr)
- && (!(RESM_NTPONLY & res->mflags)
- || NTP_PORT == (int)port))
+ && ( !(RESM_NTPONLY & res->mflags)
+ || NTP_PORT == (int)port)) {
+
break;
+ }
}
return res;
}
restrict_u *match;
struct in6_addr *pin6;
- REQUIRE(NULL != r4a);
+ DEBUG_REQUIRE(NULL != r4a);
res_calls++;
- r4a->rflags = RES_IGNORE;
- r4a->ippeerlimit = 0;
-
- DPRINTF(1, ("restrictions: looking up %s\n", stoa(srcadr)));
- /* IPv4 source address */
if (IS_IPV4(srcadr)) {
/*
* Ignore any packets with a multicast source address
* not later!)
*/
if (IN_CLASSD(SRCADR(srcadr))) {
- DPRINTF(1, ("restrictions: srcadr %s is multicast\n", stoa(srcadr)));
- r4a->ippeerlimit = 2; /* XXX: we should use a better value */
- return;
+ goto multicast;
}
match = match_restrict4_addr(SRCADR(srcadr),
SRCPORT(srcadr));
-
- INSIST(match != NULL);
-
+ DEBUG_INSIST(match != NULL);
match->count++;
/*
* res_not_found counts only use of the final default
res_found++;
r4a->rflags = match->rflags;
r4a->ippeerlimit = match->ippeerlimit;
- }
+ } else {
+ DEBUG_REQUIRE(IS_IPV6(srcadr));
- /* IPv6 source address */
- if (IS_IPV6(srcadr)) {
pin6 = PSOCK_ADDR6(srcadr);
/*
* (this should be done early in the receive process,
* not later!)
*/
- if (IN6_IS_ADDR_MULTICAST(pin6))
- return;
-
+ if (IN6_IS_ADDR_MULTICAST(pin6)) {
+ goto multicast;
+ }
match = match_restrict6_addr(pin6, SRCPORT(srcadr));
- INSIST(match != NULL);
+ DEBUG_INSIST(match != NULL);
match->count++;
if (&restrict_def6 == match)
res_not_found++;
}
return;
+
+ multicast:
+ r4a->rflags = RES_IGNORE;
+ r4a->ippeerlimit = 0;
}
-/*
- * roptoa - convert a restrict_op to a string
- */
-char *
-roptoa(restrict_op op) {
- static char sb[30];
-
- switch(op) {
+#ifdef DEBUG
+/* display string for restrict_op */
+const char *
+resop_str(restrict_op op)
+{
+ switch (op) {
case RESTRICT_FLAGS: return "RESTRICT_FLAGS";
case RESTRICT_UNFLAG: return "RESTRICT_UNFLAGS";
case RESTRICT_REMOVE: return "RESTRICT_REMOVE";
case RESTRICT_REMOVEIF: return "RESTRICT_REMOVEIF";
- default:
- snprintf(sb, sizeof sb, "**RESTRICT_#%d**", op);
- return sb;
}
+ DEBUG_INVARIANT(!"bad restrict_op in resop_str");
+ return ""; /* silence not all paths return value warning */
}
+#endif /* DEBUG */
/*
)
{
int v6;
+ int bump_res_limited = FALSE;
restrict_u match;
restrict_u * res;
restrict_u ** plisthead;
- DPRINTF(1, ("hack_restrict: op %s addr %s mask %s ippeerlimit %d mflags %08x rflags %08x\n",
- roptoa(op), stoa(resaddr), stoa(resmask), ippeerlimit, mflags, rflags));
+ DPRINTF(1, ("hack_restrict: op %s addr %s mask %s ippeerlimit %d "
+ "mflags %s rflags %s\n", resop_str(op), stoa(resaddr),
+ stoa(resmask), ippeerlimit, mflags_str(mflags),
+ rflags_str(rflags)));
if (NULL == resaddr) {
- REQUIRE(NULL == resmask);
- REQUIRE(RESTRICT_FLAGS == op);
+ DEBUG_REQUIRE(NULL == resmask);
+ DEBUG_REQUIRE(RESTRICT_FLAGS == op);
restrict_source_rflags = rflags;
restrict_source_mflags = mflags;
restrict_source_ippeerlimit = ippeerlimit;
- restrict_source_enabled = 1;
+ restrict_source_enabled = TRUE;
return;
}
ZERO(match);
-#if 0
- /* silence VC9 potentially uninit warnings */
- // HMS: let's use a compiler-specific "enable" for this.
- res = NULL;
- v6 = 0;
-#endif
-
if (IS_IPV4(resaddr)) {
- v6 = 0;
+ v6 = FALSE;
/*
* Get address and mask in host byte order for easy
* comparison as u_int32
match.u.v4.addr = SRCADR(resaddr);
match.u.v4.mask = SRCADR(resmask);
match.u.v4.addr &= match.u.v4.mask;
-
- } else if (IS_IPV6(resaddr)) {
- v6 = 1;
+ } else {
+ DEBUG_INVARIANT(IS_IPV6(resaddr));
+ v6 = TRUE;
/*
* Get address and mask in network byte order for easy
* comparison as byte sequences (e.g. memcmp())
match.u.v6.mask = SOCK_ADDR6(resmask);
MASK_IPV6_ADDR(&match.u.v6.addr, PSOCK_ADDR6(resaddr),
&match.u.v6.mask);
+ }
- } else /* not IPv4 nor IPv6 */
- REQUIRE(0);
-
- match.rflags = rflags;
match.mflags = mflags;
- match.ippeerlimit = ippeerlimit;
- match.expire = expire;
res = match_restrict_entry(&match, v6);
switch (op) {
case RESTRICT_FLAGS:
/*
- * Here we add bits to the rflags. If this is a
- * new restriction add it.
+ * Here we add bits to the rflags. If we already have
+ * this restriction modify it.
*/
- if (NULL == res) {
+ if (NULL != res) {
+ if ((RES_LIMITED & rflags)
+ && !(RES_LIMITED & res->rflags)) {
+
+ bump_res_limited = TRUE;
+ }
+ res->rflags |= rflags;
+ } else {
+ match.rflags = rflags;
+ match.expire = expire;
+ match.ippeerlimit = ippeerlimit;
if (v6) {
res = alloc_res6();
- memcpy(res, &match,
- V6_SIZEOF_RESTRICT_U);
+ memcpy(res, &match, V6_SIZEOF_RESTRICT_U);
plisthead = &restrictlist6;
} else {
res = alloc_res4();
- memcpy(res, &match,
- V4_SIZEOF_RESTRICT_U);
+ memcpy(res, &match, V4_SIZEOF_RESTRICT_U);
plisthead = &restrictlist4;
}
LINK_SORT_SLIST(
: res_sorts_before4(res, L_S_S_CUR()),
link, restrict_u);
restrictcount++;
- if (RES_LIMITED & rflags)
- inc_res_limited();
- } else {
- if ( (RES_LIMITED & rflags)
- && !(RES_LIMITED & res->rflags))
- inc_res_limited();
- res->rflags |= rflags;
+ if (RES_LIMITED & rflags) {
+ bump_res_limited = TRUE;
+ }
+ }
+ if (bump_res_limited) {
+ inc_res_limited();
}
-
- res->ippeerlimit = match.ippeerlimit;
-
break;
case RESTRICT_UNFLAG:
/*
* Remove an entry from the table entirely if we
* found one. Don't remove the default entry and
- * don't remove an interface entry.
+ * don't remove an interface entry unless asked.
*/
- if (res != NULL
+ if ( res != NULL
&& (RESTRICT_REMOVEIF == op
|| !(RESM_INTERFACE & res->mflags))
&& res != &restrict_def4
- && res != &restrict_def6)
+ && res != &restrict_def6) {
+
free_res(res, v6);
+ }
break;
default: /* unknown op */
DPRINTF(1, ("restrict_source: %s host restriction added\n",
stoa(addr)));
}
+
+
+#ifdef DEBUG
+/* Convert restriction RES_ flag bits into a display string */
+const char *
+rflags_str(
+ u_short rflags
+ )
+{
+ const size_t sz = LIB_BUFLENGTH;
+ char * rfs;
+
+ LIB_GETBUF(rfs);
+ rfs[0] = '\0';
+
+ if (rflags & RES_FLAKE) {
+ CLEAR_BIT_IF_DEBUG(RES_FLAKE, rflags);
+ append_flagstr(rfs, sz, "flake");
+ }
+
+ if (rflags & RES_IGNORE) {
+ CLEAR_BIT_IF_DEBUG(RES_IGNORE, rflags);
+ append_flagstr(rfs, sz, "ignore");
+ }
+
+ if (rflags & RES_KOD) {
+ CLEAR_BIT_IF_DEBUG(RES_KOD, rflags);
+ append_flagstr(rfs, sz, "kod");
+ }
+
+ if (rflags & RES_MSSNTP) {
+ CLEAR_BIT_IF_DEBUG(RES_MSSNTP, rflags);
+ append_flagstr(rfs, sz, "mssntp");
+ }
+
+ if (rflags & RES_LIMITED) {
+ CLEAR_BIT_IF_DEBUG(RES_LIMITED, rflags);
+ append_flagstr(rfs, sz, "limited");
+ }
+
+ if (rflags & RES_LPTRAP) {
+ CLEAR_BIT_IF_DEBUG(RES_LPTRAP, rflags);
+ append_flagstr(rfs, sz, "lptrap");
+ }
+
+ if (rflags & RES_NOMODIFY) {
+ CLEAR_BIT_IF_DEBUG(RES_NOMODIFY, rflags);
+ append_flagstr(rfs, sz, "nomodify");
+ }
+
+ if (rflags & RES_NOMRULIST) {
+ CLEAR_BIT_IF_DEBUG(RES_NOMRULIST, rflags);
+ append_flagstr(rfs, sz, "nomrulist");
+ }
+
+ if (rflags & RES_NOEPEER) {
+ CLEAR_BIT_IF_DEBUG(RES_NOEPEER, rflags);
+ append_flagstr(rfs, sz, "noepeer");
+ }
+
+ if (rflags & RES_NOPEER) {
+ CLEAR_BIT_IF_DEBUG(RES_NOPEER, rflags);
+ append_flagstr(rfs, sz, "nopeer");
+ }
+
+ if (rflags & RES_NOQUERY) {
+ CLEAR_BIT_IF_DEBUG(RES_NOQUERY, rflags);
+ append_flagstr(rfs, sz, "noquery");
+ }
+
+ if (rflags & RES_DONTSERVE) {
+ CLEAR_BIT_IF_DEBUG(RES_DONTSERVE, rflags);
+ append_flagstr(rfs, sz, "dontserve");
+ }
+
+ if (rflags & RES_NOTRAP) {
+ CLEAR_BIT_IF_DEBUG(RES_NOTRAP, rflags);
+ append_flagstr(rfs, sz, "notrap");
+ }
+
+ if (rflags & RES_DONTTRUST) {
+ CLEAR_BIT_IF_DEBUG(RES_DONTTRUST, rflags);
+ append_flagstr(rfs, sz, "notrust");
+ }
+
+ if (rflags & RES_SRVRSPFUZ) {
+ CLEAR_BIT_IF_DEBUG(RES_SRVRSPFUZ, rflags);
+ append_flagstr(rfs, sz, "srvrspfuz");
+ }
+
+ if (rflags & RES_VERSION) {
+ CLEAR_BIT_IF_DEBUG(RES_VERSION, rflags);
+ append_flagstr(rfs, sz, "version");
+ }
+
+ DEBUG_INVARIANT(!rflags);
+
+ if ('\0' == rfs[0]) {
+ append_flagstr(rfs, sz, "(none)");
+ }
+
+ return rfs;
+}
+
+
+/* Convert restriction match RESM_ flag bits into a display string */
+const char *
+mflags_str(
+ u_short mflags
+ )
+{
+ const size_t sz = LIB_BUFLENGTH;
+ char * mfs;
+
+ LIB_GETBUF(mfs);
+ mfs[0] = '\0';
+
+ if (mflags & RESM_NTPONLY) {
+ CLEAR_BIT_IF_DEBUG(RESM_NTPONLY, mflags);
+ append_flagstr(mfs, sz, "ntponly");
+ }
+
+ if (mflags & RESM_SOURCE) {
+ CLEAR_BIT_IF_DEBUG(RESM_SOURCE, mflags);
+ append_flagstr(mfs, sz, "source");
+ }
+
+ if (mflags & RESM_INTERFACE) {
+ CLEAR_BIT_IF_DEBUG(RESM_INTERFACE, mflags);
+ append_flagstr(mfs, sz, "interface");
+ }
+
+ DEBUG_INVARIANT(!mflags);
+
+ return mfs;
+}
+#endif /* DEBUG */
/*
* These routines provide support for the event timer. The timer is
- * implemented by an interrupt routine which sets a flag once every
+ * implemented by a signal routine which sets a flag once every
* second, and a timer routine which is called when the mainline code
* gets around to seeing the flag. The timer routine dispatches the
* clock adjustment code if its time has come, then searches the timer
* Finally, we call the hourly procedure to do cleanup and print a
* message.
*/
-volatile int interface_interval; /* init_io() sets def. 300s */
/*
* Initializing flag. All async routines watch this and only do their
/*
* The counters and timeouts
*/
-static u_long interface_timer; /* interface update timer */
+ u_long endpt_scan_timer; /* interface update timer */
static u_long adjust_timer; /* second timer */
static u_long stats_timer; /* stats timer */
static u_long leapf_timer; /* Report leapfile problems once/day */
static u_long huffpuff_timer; /* huff-n'-puff timer */
static u_long worker_idle_timer;/* next check for idle intres */
-u_long leapsec; /* seconds to next leap (proximity class) */
-int leapdif; /* TAI difference step at next leap second*/
+int endpt_scan_period; /* init_io() sets def. 301s */
+u_long leapsec; /* seconds to next leap (proximity class) */
+int leapdif; /* TAI difference step at next leap second*/
u_long orphwait; /* orphan wait time */
#ifdef AUTOKEY
static u_long revoke_timer; /* keys revoke timer */
stats_timer = SECSPERHR;
leapf_timer = SECSPERDAY;
huffpuff_timer = 0;
- interface_timer = 0;
+ endpt_scan_timer = 0;
current_time = 0;
timer_overflows = 0;
timer_xmtcalls = 0;
BOOL rc;
Period = (1 << EVENT_TIMEOUT) * 1000;
- DueTime.QuadPart = Period * 10000i64;
+ DueTime.QuadPart = Period * 10000ll;
rc = SetWaitableTimer(WaitableTimerHandle, &DueTime,
Period, NULL, NULL, FALSE);
if (!rc) {
struct peer * p;
struct peer * next_peer;
l_fp now;
- time_t tnow;
+ time_t tnow;
/*
* The basic timerevent is one second. This is used to adjust the
* usually tripped using iburst and minpoll of
* 128 s or less.
*/
- if (p->throttle > 0)
+ if (p->throttle > 0) {
p->throttle--;
+ }
if (p->nextdate <= current_time) {
#ifdef REFCLOCK
- if (FLAG_REFCLOCK & p->flags)
+ if (FLAG_REFCLOCK & p->flags) {
refclock_transmit(p);
- else
+ } else
#endif /* REFCLOCK */
+ {
transmit(p);
+ }
}
}
sys_stratum = STRATUM_UNSPEC;
}
if (sys_stratum > 1)
- sys_refid = htonl(LOOPBACKADR);
+ sys_refid = htonl(LOOPBACKADR);
else
- memcpy(&sys_refid, "LOOP", 4);
+ memcpy(&sys_refid, "LOOP", 4);
sys_offset = 0;
sys_rootdelay = 0;
sys_rootdisp = 0;
*/
if (leapsec > LSPROX_NOWARN || 0 == (current_time & 7))
check_leapsec(now.l_ui, &tnow,
- (sys_leap == LEAP_NOTINSYNC));
- if (sys_leap != LEAP_NOTINSYNC) {
- if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
- if (leapdif > 0)
- set_sys_leap(LEAP_ADDSECOND);
- else
- set_sys_leap(LEAP_DELSECOND);
- } else {
- set_sys_leap(LEAP_NOWARNING);
- }
+ (sys_leap == LEAP_NOTINSYNC));
+ if (sys_leap != LEAP_NOTINSYNC) {
+ if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
+ if (leapdif > 0)
+ set_sys_leap(LEAP_ADDSECOND);
+ else
+ set_sys_leap(LEAP_DELSECOND);
+ } else {
+ set_sys_leap(LEAP_NOWARNING);
+ }
}
/*
*/
if (revoke_timer && revoke_timer <= current_time) {
revoke_timer += (1UL << sys_revoke);
- RAND_bytes((u_char *)&sys_private, 4);
+ RAND_bytes((u_char *)&sys_private, sizeof(sys_private));
}
#endif /* AUTOKEY */
/*
- * Interface update timer
+ * Network interface rescan timer
*/
- if (interface_interval && interface_timer <= current_time) {
- timer_interfacetimeout(current_time +
- interface_interval);
- DPRINTF(2, ("timer: interface update\n"));
+ if (endpt_scan_timer && endpt_scan_timer <= current_time) {
+ if (no_periodic_scan) {
+ endpt_scan_timer = 0;
+ } else {
+ endpt_scan_timer = current_time
+ + endpt_scan_period;
+ }
interface_update(NULL, NULL);
}
#endif /* SYS_WINNT */
-void
-timer_interfacetimeout(u_long timeout)
-{
- interface_timer = timeout;
-}
-
-
/*
* timer_clr_stats - clear timer module stat counters
*/
#include "ntp_assert.h"
#include "ntp_calendar.h"
#include "ntp_leapsec.h"
-#include "lib_strbuf.h"
#include <stdio.h>
#include <ctype.h>
static char *stats_temp_file; /* temp frequency file name */
static double wander_resid; /* last frequency update */
double wander_threshold = 1e-7; /* initial frequency threshold */
-static unsigned int cmdargs_seen = 0; /* stat options seen from command line */
/*
* Statistics file stuff
/*
- * stats_config - configure the stats operation
+ * If an option was given on the command line make sure it takes
+ * precedence over the configuration file, as command-line options
+ * are processed first. Similarly, if an option is given in the
+ * configuration file, do not allow it to be overridden with runtime
+ * configuration. Done by simply remembering an option was already
+ * seen.
*/
static int
allow_config(
- unsigned int option,
- int/*BOOL*/ cmdopt)
+ u_int option,
+ int/*BOOL*/ cmdopt
+ )
{
- /* If an option was given on the command line, make sure it
- * persists and is not later changed by a corresponding option
- * from the config file. Done by simply remembering an option was
- * already seen from the command line.
- *
- * BTW, if we ever define stats options beyond 31, this needs a
- * fix. Until then, simply assume the shift will not overflow.
- */
- unsigned int mask = 1u << option;
- int retv = cmdopt || !(cmdargs_seen & mask);
- if (cmdopt)
- cmdargs_seen |= mask;
+ static u_int seen = 0; /* stat options previously set */
+ u_int mask;
+ int retv;
+
+ if (cmdopt) {
+ DEBUG_REQUIRE(option < sizeof(mask) * 8);
+ mask = 1u << option;
+ retv = !(seen & mask);
+ seen |= mask;
+ } else {
+ retv = FALSE;
+ }
return retv;
}
+/*
+ * stats_config - configure the stats operation
+ */
void
stats_config(
int item,
double old_drift;
l_fp now;
time_t ttnow;
+ char dirsep_or_nul;
#ifndef VMS
static const char temp_ext[] = ".TEMP";
#else
switch (item) {
- /*
- * Open and read frequency file.
- */
+ /*
+ * Open and read frequency file.
+ */
case STATS_FREQ_FILE:
- if (!allow_config(STATS_FREQ_FILE, optflag))
+ if (!allow_config(STATS_FREQ_FILE, optflag)) {
break;
-
- if (!value || (len = strlen(value)) == 0)
- {
+ }
+ if (!value || 0 == (len = strlen(value))) {
free(stats_drift_file);
free(stats_temp_file);
- stats_drift_file = stats_temp_file = NULL;
- }
- else
- {
- stats_drift_file = erealloc(stats_drift_file, len + 1);
+ stats_drift_file = stats_temp_file = NULL;
+ } else {
+ stats_drift_file = erealloc(stats_drift_file,
+ 1 + len);
stats_temp_file = erealloc(stats_temp_file,
- len + sizeof(".TEMP"));
- memcpy(stats_drift_file, value, (size_t)(len+1));
- memcpy(stats_temp_file, value, (size_t)len);
- memcpy(stats_temp_file + len, temp_ext, sizeof(temp_ext));
+ len + sizeof(temp_ext));
+ memcpy(stats_drift_file, value, 1 + len);
+ memcpy(stats_temp_file, value, len);
+ memcpy(stats_temp_file + len, temp_ext,
+ sizeof(temp_ext));
}
-
+
/*
* Open drift file and read frequency. If the file is
* missing or contains errors, tell the loop to reset.
*/
if (NULL == stats_drift_file) {
- loop_config(LOOP_NOFREQ, 0.0);
prev_drift_comp = 0.0;
- } else if ((fp = fopen(stats_drift_file, "r")) == NULL) {
- if (errno != ENOENT)
+ loop_config(LOOP_NOFREQ, prev_drift_comp);
+ }
+ else if ((fp = fopen(stats_drift_file, "r")) == NULL) {
+ if (errno != ENOENT) {
msyslog(LOG_WARNING,
- "cannot read frequency file %s: %s",
- stats_drift_file, strerror(errno));
- } else if (fscanf(fp, "%lf", &old_drift) != 1) {
+ "cannot read frequency file %s: %m",
+ stats_drift_file);
+ }
+ }
+ else if (fscanf(fp, "%lf", &old_drift) != 1) {
msyslog(LOG_ERR,
"format error frequency file %s",
stats_drift_file);
- fclose(fp);
} else {
loop_config(LOOP_FREQ, old_drift);
prev_drift_comp = drift_comp;
msyslog(LOG_INFO,
"initial drift restored to %f",
old_drift);
+ }
+ if (NULL != fp) {
fclose(fp);
}
break;
- /*
- * Specify statistics directory.
- */
+ /*
+ * Specify statistics directory.
+ */
case STATS_STATSDIR:
- if (!allow_config(STATS_STATSDIR, optflag))
+ if (!allow_config(STATS_STATSDIR, optflag)) {
break;
-
- /* - 1 since value may be missing the DIR_SEP. */
- if (strlen(value) >= sizeof(statsdir) - 1) {
+ }
+ /* - 2 since value may be missing the DIR_SEP. */
+ len = strlen(value);
+ if (len > sizeof(statsdir) - 2) {
msyslog(LOG_ERR,
- "statsdir too long (>%d, sigh)",
- (int)sizeof(statsdir) - 2);
+ "statsdir %s too long (>%u)",
+ (u_int)sizeof(statsdir) - 2);
+ break;
+ }
+ /* Add a DIR_SEP unless we already have one. */
+ if (0 == len || DIR_SEP == value[len - 1]) {
+ dirsep_or_nul = '\0';
} else {
- int add_dir_sep;
- size_t value_l;
-
- /* Add a DIR_SEP unless we already have one. */
- value_l = strlen(value);
- if (0 == value_l)
- add_dir_sep = FALSE;
- else
- add_dir_sep = (DIR_SEP !=
- value[value_l - 1]);
-
- if (add_dir_sep)
- snprintf(statsdir, sizeof(statsdir),
- "%s%c", value, DIR_SEP);
- else
- snprintf(statsdir, sizeof(statsdir),
- "%s", value);
- filegen_statsdir();
+ dirsep_or_nul = DIR_SEP;
}
+ snprintf(statsdir, sizeof(statsdir), "%s%c",
+ value, dirsep_or_nul);
+ filegen_statsdir();
break;
- /*
- * Open pid file.
- */
+ /*
+ * Write pid file.
+ */
case STATS_PID_FILE:
- if (!allow_config(STATS_PID_FILE, optflag))
+ if (!allow_config(STATS_PID_FILE, optflag)) {
break;
-
+ }
if ((fp = fopen(value, "w")) == NULL) {
- msyslog(LOG_ERR, "pid file %s: %m",
- value);
+ msyslog(LOG_ERR, "pid file %s: %m", value);
break;
}
- fprintf(fp, "%d", (int)getpid());
+ fprintf(fp, "%ld", (long)getpid());
fclose(fp);
break;
/*
* Read leapseconds file.
*
- * Note: Currently a leap file without SHA1 signature is
- * accepted, but if there is a signature line, the signature
- * must be valid or the file is rejected.
+ * By default a leap file without SHA1 signature is accepted,
+ * but if there is a signature line, the signature must be
+ * valid or the leapfile line in ntp.conf must have ignorehash.
*/
case STATS_LEAP_FILE:
- if (!value || (len = strlen(value)) == 0)
+ if (NULL == value || 0 == (len = strlen(value))) {
break;
-
+ }
leapfile_name = erealloc(leapfile_name, len + 1);
memcpy(leapfile_name, value, len + 1);
chck_leaphash = optflag;
if (leapsec_load_file(
leapfile_name, &leapfile_stat,
- TRUE, TRUE, chck_leaphash))
- {
+ TRUE, TRUE, chck_leaphash)) {
leap_signature_t lsig;
get_systime(&now);
time(&ttnow);
leapsec_getsig(&lsig);
mprintf_event(EVNT_TAI, NULL,
- "%d leap %s %s %s",
+ "%d leap %s expire%s %s",
lsig.taiof,
fstostr(lsig.ttime),
leapsec_expired(now.l_ui, NULL)
- ? "expired"
- : "expires",
+ ? "d"
+ : "s",
fstostr(lsig.etime));
have_leapfile = TRUE;
*/
void
record_peer_stats(
- sockaddr_u *addr,
- int status,
- double offset, /* offset */
- double delay, /* delay */
- double dispersion, /* dispersion */
- double jitter /* jitter */
+ sockaddr_u * addr,
+ int status,
+ double offset,
+ double delay,
+ double dispersion,
+ double jitter
)
{
- l_fp now;
- u_long day;
+ l_fp now;
+ u_long day;
- if (!stats_control)
+ if (!stats_control) {
return;
-
+ }
get_systime(&now);
filegen_setup(&peerstats, now.l_ui);
+ if (NULL == peerstats.fp) {
+ return;
+ }
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
- if (peerstats.fp != NULL) {
- fprintf(peerstats.fp,
- "%lu %s %s %x %.9f %.9f %.9f %.9f\n", day,
- ulfptoa(&now, 3), stoa(addr), status, offset,
- delay, dispersion, jitter);
- fflush(peerstats.fp);
- }
+ fprintf(peerstats.fp,
+ "%lu %s %s %x %.9f %.9f %.9f %.9f\n", day,
+ ulfptoa(&now, 3), stoa(addr), status, offset,
+ delay, dispersion, jitter);
+ fflush(peerstats.fp);
}
*
* Note: This loads a new leapfile on the fly. Currently a leap file
* without SHA1 signature is accepted, but if there is a signature line,
- * the signature must be valid or the file is rejected.
+ * the signature must be valid unless the ntp.conf leapfile line specified
+ * ignorehash.
*/
void
check_leap_file(
- int is_daily_check,
- uint32_t ntptime ,
- const time_t *systime
+ int is_daily_check,
+ uint32_t ntptime,
+ const time_t * systime
)
{
/* just do nothing if there is no leap file */
win_time_stepped();
#endif
}
+
+
+#ifdef DEBUG
+void
+append_flagstr(
+ char * flagstr,
+ size_t sz,
+ const char * text
+)
+{
+ if ('\0' != flagstr[0]) {
+ strlcat(flagstr, ",", sz);
+ }
+ /* bail if we ran out of room */
+ INSIST(strlcat(flagstr, text, sz) < sz);
+}
+#endif /* DEBUG */
#include "recvbuff.h"
#include "ntp_cmdargs.h"
-#if 0 /* HMS: I don't think we need this. 961223 */
-#ifdef LOCK_PROCESS
-# ifdef SYS_SOLARIS
-# include <sys/mman.h>
-# else
-# include <sys/lock.h>
-# endif
-#endif
-#endif
-
#ifdef SYS_WINNT
# include "ntservice.h"
#endif
* is associated with running with uid 0 - should be refined on
* ports that allow binding to NTP_PORT with uid != 0
*/
- disable_dynamic_updates |= (sw_uid != 0); /* also notifies routing message listener */
+ scan_addrs_once |= (sw_uid != 0); /* used by routing socket code */
# endif /* !HAVE_LINUX_CAPABILITIES && !HAVE_SOLARIS_PRIVS */
- if (disable_dynamic_updates && interface_interval) {
- interface_interval = 0;
+ if (scan_addrs_once) {
msyslog(LOG_INFO, "running as non-root disables dynamic interface tracking");
}
cap_t caps;
char *captext;
- captext = (0 != interface_interval)
- ? "cap_sys_time,cap_net_bind_service=pe"
- : "cap_sys_time=pe";
+ captext = (scan_addrs_once)
+ ? "cap_sys_time=pe";
+ : "cap_sys_time,cap_net_bind_service=pe"
caps = cap_from_text(captext);
if (!caps) {
msyslog(LOG_ERR,
}
#endif /* LIBSECCOMP and KERN_SECCOMP */
-#if defined(SYS_WINNT)
ntservice_isup();
-#elif defined(HAVE_WORKING_FORK)
+#if defined(HAVE_WORKING_FORK)
if (daemon_pipe[1] != -1 && 0 == wait_sync) {
if (2 != write(daemon_pipe[1], "R\n", 2)) {
msyslog(LOG_ERR, "daemon failed to notify parent ntpd after init");
}
#endif /* HAVE_WORKING_FORK */
+ if (scan_addrs_once || no_periodic_scan) {
+ endpt_scan_timer = 0;
+ }
+
# ifndef HAVE_IO_COMPLETION_PORT
BLOCK_IO_AND_ALARM();
was_alarmed = FALSE;
static char const * const s_eof_chars = ",*\r\n";
+#ifdef DEBUG
static int field_length(UCC *cp, unsigned int nfields)
{
char const * ep = (char const*)cp;
? (int)((UCC*)ep - cp)
: (int)strlen((char const*)cp);
}
+#endif /* DEBUG */
/* /[,*\r\n]/ --> skip */
static int _parse_eof(UCC *cp, UCC ** ep)
#include <isc/result.h>
#include "ntpq.h"
-#include "ntp_assert.h"
-#include "ntp_stdlib.h"
#include "ntp_unixtime.h"
#include "ntp_calendar.h"
#include "ntp_select.h"
-#include "ntp_assert.h"
-#include "lib_strbuf.h"
#include "ntp_lineedit.h"
#include "ntp_debug.h"
#ifdef OPENSSL
#include "ntp_malloc.h"
#include "ntp_assert.h"
#include "ntp_control.h"
-#include "lib_strbuf.h"
#include "ntpq-opts.h"
extern PGSTAFT get_sys_time_as_filetime;
extern PGSTAFT pGetSystemTimePreciseAsFileTime;
+/* This should really be in a ntpd_win.h or similar:
+ * Set thread description visible in debugger.
+ */
+typedef HRESULT (WINAPI *PSTD)(HANDLE hThread, PCWSTR pwstr);
+extern PSTD pSetThreadDescription;
+
void lock_thread_to_processor(HANDLE);
#endif
#ifndef CONFIG_H
#define CONFIG_H
-/*
- * Known predifined MS compiler version codes:
- * 1800: MSVC++ 12.0 (Visual Studio 2013)
- * 1700: MSVC++ 11.0 (Visual Studio 2012)
- * 1600: MSVC++ 10.0 (Visual Studio 2010)
- * 1500: MSVC++ 9.0 (Visual Studio 2008)
- * 1400: MSVC++ 8.0 (Visual Studio 2005)
- * 1310: MSVC++ 7.1 (Visual Studio 2003)
- * 1300: MSVC++ 7.0
- * 1200: MSVC++ 6.0 (Visual C++ 6)
- * 1100: MSVC++ 5.0
- */
+ /*
+ * Known predifined MS C compiler _MSC_VER values:
+ *
+ * 1930 MSVC++ 14.3 (Visual Studio 2022)
+ * 1920 MSVC++ 14.2 (Visual Studio 2019)
+ * 1910 MSVC++ 14.1 (Visual Studio 2017)
+ * 1900 MSVC++ 14.0 (Visual Studio 2015)
+ * 1800: MSVC++ 12.0 (Visual Studio 2013)
+ * 1700: MSVC++ 11.0 (Visual Studio 2012)
+ * 1600: MSVC++ 10.0 (Visual Studio 2010)
+ * 1500: MSVC++ 9.0 (Visual Studio 2008)
+ * 1400: MSVC++ 8.0 (Visual Studio 2005) (minimum supported)
+ *
+ * Note comparisons should be made using <, >, <=, or >= as there are
+ * other revisions released between major versions.
+ */
#if defined(_MSC_VER) && _MSC_VER < 1400
#error Minimum supported Microsoft compiler is Visual C++ 2005.
#define SIOCGIFFLAGS SIO_GET_INTERFACE_LIST /* used in ntp_io.c */
-/* Bug 2978 mitigation -- unless defined elsewhere, do it here*/
+/* Bug 2978 mitigation -- unless defined elsewhere, do it here */
#ifndef DYNAMIC_INTERLEAVE
# define DYNAMIC_INTERLEAVE 0
#endif
#if defined(HAVE_IO_COMPLETION_PORT)
+/* NotifyIpInterfaceChange() is available on Windows Vista and later. */
+typedef enum ENUM_DONTCARE_MIB_NOTIF_TYPE {
+ SomeType_DontCare
+} MIB_NOTIF_TYPE;
+
+typedef void
+(WINAPI* PMYIPINTERFACE_CHANGE_CALLBACK) (
+ PVOID CallerContext,
+ PVOID Row,
+ MIB_NOTIF_TYPE NotificationType
+ );
+
+typedef DWORD (WINAPI* NotifyIpInterfaceChange_ptr)(
+ ADDRESS_FAMILY Family,
+ PMYIPINTERFACE_CHANGE_CALLBACK Callback,
+ PVOID CallerContext,
+ BOOLEAN InitialNotification,
+ HANDLE* NotificationHandle
+ );
+
+extern NotifyIpInterfaceChange_ptr pNotifyIpInterfaceChange;
+
+
struct refclockio; /* in ntp_refclock.h but inclusion here triggers problems */
-struct interface; /* likewise */
extern void init_io_completion_port(void);
extern void uninit_io_completion_port(void);
-extern BOOL io_completion_port_add_interface(struct interface*);
-extern void io_completion_port_remove_interface(struct interface*);
+extern BOOL io_completion_port_add_interface(endpt *);
+extern void io_completion_port_remove_interface(endpt *);
-extern BOOL io_completion_port_add_socket(SOCKET fd, struct interface *, BOOL bcast);
-extern void io_completion_port_remove_socket(SOCKET fd, struct interface*);
+extern BOOL io_completion_port_add_socket(SOCKET fd, endpt *, BOOL bcast);
+extern void io_completion_port_remove_socket(SOCKET fd, endpt *);
extern int io_completion_port_sendto(endpt*, SOCKET, void *, size_t, sockaddr_u *);
extern void io_completion_port_remove_clock_io(struct refclockio *rio);
extern int GetReceivedBuffers(void);
+extern void WINAPI IpInterfaceChangedCallback(PVOID ctx, PVOID row,
+ MIB_NOTIF_TYPE type);
+
extern HANDLE WaitableExitEventHandle;
void ntservice_isup(void);
void UpdateSCM(DWORD);
void WINAPI ServiceControl(DWORD dwCtrlCode);
-void ntservice_shutdown(void);
BOOL ntservice_systemisshuttingdown(void);
BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType);
#ifndef WIN32_IO_H
#define WIN32_IO_H
-extern void InitSockets(void);
-extern void connection_reset_fix(SOCKET fd, sockaddr_u *addr);
+extern void InitSockets(void);
+extern void connection_reset_fix(SOCKET fd, sockaddr_u *addr);
#endif /* WIN32_IO_H */
MessageBoxA(NULL,
"This application cannot run on Windows 3.1.\n"
"This application will now terminate.",
- "NAMED",
+ "instsrv",
MB_OK | MB_ICONSTOP | MB_SETFOREGROUND );
return 1;
}
*/
PGSTAFT get_sys_time_as_filetime;
PGSTAFT pGetSystemTimePreciseAsFileTime;
+PSTD pSetThreadDescription;
int
} else {
get_sys_time_as_filetime = &GetSystemTimeAsFileTime;
}
+ /* Identify threads by name in debugger */
+ hDll = LoadLibrary("KernelBase");
+ pfn = GetProcAddress(hDll, "SetThreadDescription");
+ if (NULL != pfn) {
+ pSetThreadDescription = (PSTD)pfn;
+ }
}
#include <syslog.h>
#include <isc/strerror.h>
-#include <lib_strbuf.h>
-
#include "ntp_stdlib.h"
#include "messages.h"
static char progname[51] = "NTP";
static int logmask = 0;
-static struct dsn_c_pvt_sfnt {
- int val;
- const char *strval;
-} facilities[] = {
- { LOG_KERN, "kern" },
- { LOG_USER, "user" },
- { LOG_MAIL, "mail" },
- { LOG_DAEMON, "daemon" },
- { LOG_AUTH, "auth" },
- { LOG_SYSLOG, "syslog" },
- { LOG_LPR, "lpr" },
-#ifdef LOG_NEWS
- { LOG_NEWS, "news" },
-#endif
-#ifdef LOG_UUCP
- { LOG_UUCP, "uucp" },
-#endif
-#ifdef LOG_CRON
- { LOG_CRON, "cron" },
-#endif
-#ifdef LOG_AUTHPRIV
- { LOG_AUTHPRIV, "authpriv" },
-#endif
-#ifdef LOG_FTP
- { LOG_FTP, "ftp" },
-#endif
- { LOG_LOCAL0, "local0"},
- { LOG_LOCAL1, "local1"},
- { LOG_LOCAL2, "local2"},
- { LOG_LOCAL3, "local3"},
- { LOG_LOCAL4, "local4"},
- { LOG_LOCAL5, "local5"},
- { LOG_LOCAL6, "local6"},
- { LOG_LOCAL7, "local7"},
- { 0, NULL }
-};
-
-#if 0
-BOOL
-isc_syslog_facilityfromstring(const char *str, int *facilityp) {
- int i;
-
- REQUIRE(str != NULL);
- REQUIRE(facilityp != NULL);
-
- for (i = 0 ; facilities[i].strval != NULL ; i++) {
- if (strcasecmp(facilities[i].strval, str) == 0) {
- *facilityp = facilities[i].val;
- return (TRUE);
- }
- }
- return (FALSE);
-}
-#endif
/*
* Log to the NT Event Log
*/
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
#endif
+
void
InitSockets(
void
)
{
+ static int done;
WORD wVersionRequested;
WSADATA wsaData;
int err;
+ if (done) {
+ return;
+ }
+ done = TRUE;
+
/* Need Winsock 2.0 or better */
wVersionRequested = MAKEWORD(2, 0);
err = WSAStartup(wVersionRequested, &wsaData);
if ( err != 0 ) {
- SetLastError(err);
- mfprintf(stderr, "No usable winsock: %m\n");
SetLastError(err);
msyslog(LOG_ERR, "No usable winsock: %m");
exit(1);
}
/*
- * Windows 2000 systems incorrectly cause UDP sockets using WASRecvFrom
- * to not work correctly, returning a WSACONNRESET error when a WSASendTo
- * fails with an "ICMP port unreachable" response and preventing the
- * socket from using the WSARecvFrom in subsequent operations.
- * The function below fixes this, but requires that Windows 2000
- * Service Pack 2 or later be installed on the system. NT 4.0
- * systems are not affected by this and work correctly.
+ * Windows 2000 SP2 and later systems cause UDP sockets using WASRecvFrom
+ * to return a WSACONNRESET error when a prior WSASendTo on the socket
+ * fails with an "ICMP port unreachable" response. After the error the
+ * socket is unusable and must be closed. We disable this behavior.
* See Microsoft Knowledge Base Article Q263823 for details of this.
+ * https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/263823
+ * https://web.archive.org/web/20111205034113/support.microsoft.com/kb/263823
*/
void
connection_reset_fix(
BOOL
OpenHopfDevice(void)
{
- OSVERSIONINFO VersionInfo;
- ULONG deviceNumber;
+ ULONG deviceNumber = 0;
CHAR deviceName[255];
- VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&VersionInfo);
- switch (VersionInfo.dwPlatformId) {
-
- case VER_PLATFORM_WIN32_WINDOWS: // Win95/98
- return FALSE; // "NTP does not support Win 95-98."
- break;
-
- case VER_PLATFORM_WIN32_NT: // WinNT
- deviceNumber = 0;
- snprintf(deviceName, sizeof(deviceName),
- "\\\\.\\hclk6039%d", deviceNumber + 1);
- hDevice = CreateFile(
- deviceName,
- GENERIC_WRITE | GENERIC_READ,
- FILE_SHARE_WRITE | FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_OVERLAPPED,
- NULL);
- break;
-
- default:
- hDevice = INVALID_HANDLE_VALUE;
- break;
- } // end switch
+ snprintf(deviceName, sizeof(deviceName),
+ "\\\\.\\hclk6039%d", deviceNumber + 1);
+ hDevice = CreateFile(
+ deviceName,
+ GENERIC_WRITE | GENERIC_READ,
+ FILE_SHARE_WRITE | FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_OVERLAPPED,
+ NULL);
if (INVALID_HANDLE_VALUE == hDevice) // the system didn't return a handle
return FALSE; //"A handle to the driver could not be obtained properly"
*
* Created by Sven Dietrich sven@inter-yacht.com
*
- * New interpolation scheme by Dave Hart <davehart@davehart.com> in
+ * New interpolation scheme by Dave Hart <davehart@gmail.com> in
* February 2009 overcomes 500us-1ms inherent jitter with the older
* scheme, first identified by Peter Rosin (nee Ekberg)
* <peda@lysator.liu.se> in 2003 [Bug 216].
#include "config.h"
#endif
+#include "isc/win32os.h"
#include <sys/resource.h> /* our private version */
-#if defined(_MSC_VER) && _MSC_VER >= 1400 /* VS 2005 */
#include <intrin.h> /* for __rdtsc() */
-#endif
#ifdef HAVE_PPSAPI
#include <timepps.h>
#define PERF2HNS(ctr) ((ctr) * HECTONANOSECONDS / PerfCtrFreq)
-#if defined(_MSC_VER) && _MSC_VER >= 1400 /* VS 2005 */
-#define get_pcc() __rdtsc()
-#else
-/*
- * something like this can be used for a compiler without __rdtsc()
- */
-ULONGLONG __forceinline
-get_pcc(void)
-{
- /* RDTSC returns in EDX:EAX, same as C compiler */
- __asm {
- RDTSC
- }
-}
-#endif
-
-
/*
* perf_ctr() returns the current performance counter value,
* from QueryPerformanceCounter or RDTSC.
{
FT_ULL ft;
- if (use_pcc)
- return get_pcc();
- else {
+ if (use_pcc) {
+ return __rdtsc();
+ } else {
QueryPerformanceCounter(&ft.li);
return ft.ull;
}
*/
static void init_small_adjustment(void)
{
- OSVERSIONINFO vi;
- memset(&vi, 0, sizeof(vi));
- vi.dwOSVersionInfoSize = sizeof(vi);
-
- if (!GetVersionEx(&vi)) {
- msyslog(LOG_WARNING, "GetVersionEx failed with error code %d.", GetLastError());
- os_ignores_small_adjustment = FALSE;
- return;
- }
-
- if (vi.dwMajorVersion == 6 && vi.dwMinorVersion == 1) {
- // Windows 7 and Windows Server 2008 R2
- //
- // Windows 7 is documented as affected.
- // Windows Server 2008 R2 is assumed affected.
- os_ignores_small_adjustment = TRUE;
- } else if (vi.dwMajorVersion == 6 && vi.dwMinorVersion == 0) {
- // Windows Vista and Windows Server 2008
+ if ( isc_win32os_versioncheck(6, 0, 0, 0) >= 0
+ && isc_win32os_versioncheck(6, 2, 0, 0) < 0) {
+ // 6.0 Windows Vista and Windows Server 2008
+ // 6.1 Windows 7 and Windows Server 2008 R2
//
// Windows Vista is documented as affected.
// Windows Server 2008 is assumed affected.
+ // Windows 7 is documented as affected.
+ // Windows Server 2008 R2 is assumed affected.
os_ignores_small_adjustment = TRUE;
- } else {
+ }
+ else {
os_ignores_small_adjustment = FALSE;
}
}
REQUIRE(NomPerfCtrFreq != 0);
QueryPerformanceCounter(&ft1.li);
- ft2.ull = get_pcc();
+ ft2.ull = __rdtsc();
Sleep(1);
QueryPerformanceCounter(&ft3.li);
Sleep(1);
- ft4.ull = get_pcc();
+ ft4.ull = __rdtsc();
Sleep(1);
QueryPerformanceCounter(&ft5.li);
if (!SetThreadPriority(clock_thread, THREAD_PRIORITY_TIME_CRITICAL)) {
DPRINTF(1, ("Error setting thread priority\n"));
}
+ if (NULL != pSetThreadDescription) {
+ (*pSetThreadDescription)(clock_thread, L"ntpd_interp_clock");
+ }
lock_thread_to_processor(clock_thread);
ResumeThread(clock_thread);
#include "timepps.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
#include "ntp_iocpltypes.h"
#include "ntp_iocplmem.h"
* Second, for the sake of the time stamp interpolation the threads
must run on the same CPU as the time interpolation thread. This
makes using more than one thread useless, as they would compete for
- the same core and create contention.
+ the same core and create contention. This is only an issue on
+ Windows Vista and earlier. On Windows 8 and later ntpd does not use
+ its own clock interpolation.
+ Some IO operations need a possibly lengthy post-processing. Emulating
the UN*X line discipline is currently the only but prominent example.
#include "ntpd.h"
#include "ntp_request.h"
+#include <isc/win32os.h>
#include "ntp_iocompletionport.h"
#include "ntp_iocplmem.h"
PKT_SOCKET_ERROR
};
+
+
static const char * const st_packet_handling[3] = {
"accepted",
"dropped"
DWORD ActiveWaitHandles;
HANDLE WaitHandles[4];
+NotifyIpInterfaceChange_ptr pNotifyIpInterfaceChange;
+
+
/*
* -------------------------------------------------------------------
/* Socket and refclock receive call gettimeofday() so the I/O
* thread needs to be on the same processor as the main and
* timing threads to ensure consistent QueryPerformanceCounter()
- * results.
+ * results, if we are interpolating the clock (pre-Win8).
*
* This gets seriously into the way of efficient thread pooling
* on multi-core systems.
void
init_io_completion_port(void)
{
- OSVERSIONINFO vi;
+ FARPROC pfn;
+ HANDLE hNotify;
+ HANDLE hDll;
# ifdef DEBUG
atexit(&free_io_completion_port_mem);
# endif
- memset(&vi, 0, sizeof(vi));
- vi.dwOSVersionInfoSize = sizeof(vi);
-
- /* For windows 7 and above, schedule more than one receive */
- if (GetVersionEx(&vi) && vi.dwMajorVersion >= 6)
+ /* For Windows Vista and above, schedule more than one receive */
+ if (isc_win32os_versioncheck(6, 0, 0, 0) >= 0) {
s_SockRecvSched = 4;
+ }
/* Create the context pool first. */
IOCPLPoolInit(20);
- /* Create the event used to signal an IO event */
+ /* Signal I/O ready */
WaitableIoEventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (WaitableIoEventHandle == NULL) {
- msyslog(LOG_ERR, "Can't create I/O event handle: %m");
- exit(1);
- }
- /* Create the event used to signal an exit event */
+
+ /* Signal an exit request */
WaitableExitEventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (WaitableExitEventHandle == NULL) {
- msyslog(LOG_ERR, "Can't create exit event handle: %m");
- exit(1);
- }
+
+ /* Signal a pps wakeup for attaching */
hMainRpcDone = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (hMainRpcDone == NULL) {
- msyslog(LOG_ERR, "Can't create RPC sync handle: %m");
- exit(1);
- }
/* Create the IO completion port */
hndIOCPLPort = CreateIoCompletionPort(
INVALID_HANDLE_VALUE, NULL, 0, 0);
- if (hndIOCPLPort == NULL) {
- msyslog(LOG_ERR, "Can't create I/O completion port: %m");
- exit(1);
- }
+
+ INSIST( NULL != WaitableIoEventHandle
+ && NULL != WaitableExitEventHandle
+ && NULL != hMainRpcDone
+ && NULL != hndIOCPLPort);
/* Initialize the Wait Handles table */
WaitHandles[0] = WaitableTimerHandle;
*/
addremove_io_semaphore = &ntpd_addremove_semaphore;
+ /* Avoid periodic endpoint scans if we are getting change notifications */
+ hDll = LoadLibrary("iphlpapi");
+ pfn = GetProcAddress(hDll, "NotifyIpInterfaceChange");
+ if (NULL != pfn) {
+ pNotifyIpInterfaceChange = (NotifyIpInterfaceChange_ptr)pfn;
+ hNotify = NULL;
+ (*pNotifyIpInterfaceChange)(
+ AF_UNSPEC,
+ &IpInterfaceChangedCallback,
+ NULL,
+ FALSE,
+ &hNotify
+ );
+ if (NULL != hNotify) {
+ no_periodic_scan = TRUE;
+ }
+ }
+
/* Create a true handle for the main thread (APC processing) */
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
GetCurrentProcess(), &hMainThread,
0,
iocompletionthread,
NULL,
- 0,
+ CREATE_SUSPENDED,
&tidCompletionThread);
+ if (NULL != pSetThreadDescription) {
+ (*pSetThreadDescription)(hIoCompletionThread, L"ntp_iocp");
+ (*pSetThreadDescription)(hMainThread, L"ntp_main");
+ }
+ ResumeThread(hIoCompletionThread);
}
/* Thread lost. Kill off with TerminateThread. */
msyslog(LOG_ERR,
"IO completion thread refuses to terminate");
- TerminateThread(hIoCompletionThread, ~0UL);
+ TerminateThread(hIoCompletionThread, 0);
}
}
}
+/*
+ * IpInterfaceChangedCallback() is invoked on a worker thread created
+ * by the system, not the main thread nor the IOCP thread. Hand off
+ * to the main thread via APC invoking ip_interface_changed().
+ */
+void WINAPI
+IpInterfaceChangedCallback(
+ PVOID ctx,
+ PVOID row,
+ MIB_NOTIF_TYPE type
+)
+{
+ UNUSED_ARG(ctx);
+ UNUSED_ARG(row);
+ UNUSED_ARG(type);
+
+ QueueUserAPC(&ip_interface_changed, hMainThread, 0);
+}
+
+
+/*
+ * ip_interface_changed() is a user APC called on the main thread once
+ * for each changed row of a table of IP addresses mapping them to
+ * interfaces. Trigger a rescan of interfaces but delay it to the next
+ * tick of the seconds to avoid pointless multiplication of scans.
+ */
+void WINAPI
+ip_interface_changed(ULONG_PTR ctx)
+{
+ static u_long last_scan;
+
+ UNUSED_ARG(ctx);
+
+ /* delay by a few seconds if we just rescanned */
+ if (current_time - last_scan > 1) {
+ endpt_scan_timer = current_time + 1;
+ } else {
+ endpt_scan_timer = current_time + 3;
+ }
+ last_scan = current_time;
+}
+
+
/*
* -------------------------------------------------------------------
* external worker thread support (wait handle stuff)
void
iocpl_notify(
IoHndPad_T * iopad,
- void (*pfunc)(ULONG_PTR, IoCtx_t *),
+ IoCompleteFunc pfunc,
UINT_PTR fdn
)
{
/*
* -------------------------------------------------------------------
- * APC callback for scheduling interface scans.
+ * APC callback for socket send failure executed in the main thread.
*
* We get an error when trying to send if the network interface is
* gone or has lost link. Rescan interfaces to catch on sooner, but no
- * more often than once per minute. Once ntpd is able to detect
- * changes without polling this should be unnecessary.
+ * more than around once per minute.
*/
static void WINAPI
apcOnUnexpectedNetworkError(
ULONG_PTR arg
)
{
- static u_long time_next_ifscan_after_error;
+ static u_long earliest_rescan_time;
UNUSED_ARG(arg);
- if (time_next_ifscan_after_error < current_time) {
- time_next_ifscan_after_error = current_time + 60;
- timer_interfacetimeout(current_time);
+ if (earliest_rescan_time < current_time) {
+ endpt_scan_timer = current_time;
+ earliest_rescan_time = current_time + SECSPERMIN - 1;
}
DPRINTF(4, ("UnexpectedNetworkError: interface may be down\n"));
}
+
/* -------------------------------------------------------------------
*
* Prelude to madness -- common error checking code
/* 'buff->recv_length' must be set already! */
buff->fd = lpo->iopad->riofd;
buff->dstadr = NULL;
- buff->receiver = process_refclock_packet;
+ buff->receiver = &process_refclock_packet;
buff->recv_peer = lpo->iopad->rsrc.rio->srcclock;
rc = ReadFile(lpo->io.hnd,
- (char*)buff->recv_buffer + buff->recv_length,
+ (char *)buff->recv_buffer + buff->recv_length,
sizeof(buff->recv_buffer) - buff->recv_length,
NULL, &lpo->ol);
return rc || IoResultCheck(GetLastError(), lpo, msgh);
IoCtx_t * lpo
)
{
- IoCtxStartChecked(lpo, QueueSerialWait, lpo->recv_buf);
+ IoCtxStartChecked(lpo, &QueueSerialWait, lpo->recv_buf);
}
/* -------------------------------------------------------------------
- * APC deferred bouncer -- put buffer to receive queueor eventually
+ * APC deferred bouncer -- put buffer to receive queue or eventually
* discard it if source is already disabled. Runs in the context
* of the main thread exclusively.
*/
static void WINAPI
OnEnqueAPC(
ULONG_PTR arg
-)
+ )
{
- recvbuf_t * buff = (recvbuf_t*)arg;
- IoHndPad_T * iopad = (IoHndPad_T*)buff->recv_peer;
- RIO_t * rio = iopad->rsrc.rio;
+ recvbuf_t * buff = (recvbuf_t *)arg;
+ IoHndPad_T * iopad = (IoHndPad_T *)buff->recv_peer;
+ RIO_t * rio = iopad->rsrc.rio;
/* Down below we make a nasty hack to transport the iopad
* pointer in the buffer so we can avoid another temporary
if (NULL != rio) {
/* OK, refclock still attached */
buff->recv_peer = rio->srcclock;
- if (iohpQueueLocked(iopad, iohpRefClockOK, buff))
+ if (iohpQueueLocked(iopad, &iohpRefClockOK, buff))
++rio->srcclock->received;
} else {
/* refclock detached while in flight... */
/* We should never gat a zero-byte read here. If we do, nothing
* really bad happens, just a useless rescan of data we have
- * already processed. But somethings not quite right in logic
+ * already processed. But something's not quite right in logic
* and we croak loudly in debug builds.
*/
DEBUG_INSIST(lpo->byteCount > 0);
buff->recv_length = 0;
goto st_read_fresh;
}
- obuf->fd = buff->fd;
- obuf->receiver = buff->receiver;
- obuf->dstadr = NULL;
- obuf->recv_peer = buff->recv_peer;
+ obuf->fd = buff->fd;
+ obuf->receiver = buff->receiver;
+ obuf->dstadr = NULL;
+ obuf->recv_peer = buff->recv_peer;
set_serial_recv_time(obuf, lpo);
st_copy_start:
* the IOPAD matches the RIO in the buffer is dangerous: That
* pointer is manipulated by the other threads!
*/
- obuf->recv_peer = (struct peer*)iohpAttach(lpo->iopad);
- QueueUserAPC(OnEnqueAPC, hMainThread, (ULONG_PTR)obuf);
+ obuf->recv_peer = (struct peer *)iohpAttach(lpo->iopad);
+ QueueUserAPC(&OnEnqueAPC, hMainThread, (ULONG_PTR)obuf);
if (sptr != send)
goto st_new_obuf;
buff->recv_length = 0;
* just mop up the pieces.
*/
lpo->onIoDone = OnDeferredStartWait;
- if (!(hndIOCPLPort && PostQueuedCompletionStatus(hndIOCPLPort, 1, 0, &lpo->ol)))
+ if ( NULL == hndIOCPLPort
+ || !PostQueuedCompletionStatus(hndIOCPLPort, 1, 0, &lpo->ol)) {
IoCtxRelease(lpo);
+ }
return 0;
}
/* --------------------------------------------------------------------
* GetReceivedBuffers
* Note that this is in effect the main loop for processing requests
- * both send and receive. This should be reimplemented
+ * both send and receive. Executed on the main thread.
*/
int
GetReceivedBuffers(void)
{
DWORD index;
HANDLE ready;
- int errcode;
- BOOL dynbuf;
BOOL have_packet;
- char * msgbuf;
have_packet = FALSE;
while (!have_packet) {
break;
case WAIT_TIMEOUT:
- msyslog(LOG_ERR,
- "WaitForMultipleObjectsEx INFINITE timed out.");
+ DEBUG_INVARIANT(!"INFINITE wait timed out");
break;
case WAIT_FAILED:
- dynbuf = FALSE;
- errcode = GetLastError();
- msgbuf = NTstrerror(errcode, &dynbuf);
- msyslog(LOG_ERR,
- "WaitForMultipleObjectsEx Failed: Errcode = %n, msg = %s", errcode, msgbuf);
- if (dynbuf)
- LocalFree(msgbuf);
- exit(1);
- break;
+ DEBUG_INVARIANT(!"IOCP wait failed");
+ break;
default:
DEBUG_INSIST((index - WAIT_OBJECT_0) <
#include "isc/win32os.h"
#include <ssl_applink.c>
-
/*
* Globals
*/
-static SERVICE_STATUS_HANDLE hServiceStatus = 0;
+static SERVICE_STATUS_HANDLE hServiceStatus;
static BOOL foreground = FALSE;
static BOOL computer_shutting_down = FALSE;
static int glb_argc;
if (!foreground) {
/* Register handler with the SCM */
- hServiceStatus = RegisterServiceCtrlHandler(NTP_DISPLAY_NAME,
- ServiceControl);
+ hServiceStatus = RegisterServiceCtrlHandler(
+ NTP_DISPLAY_NAME,
+ &ServiceControl);
if (!hServiceStatus) {
NTReportError(NTP_SERVICE_NAME,
"could not register with SCM");
} else {
snprintf(ConsoleTitle, sizeof(ConsoleTitle),
"NTP Version %s", Version);
- ConsoleTitle[sizeof(ConsoleTitle) - 1] = '\0';
SetConsoleTitle(ConsoleTitle);
}
/* fall through to stop case */
case SERVICE_CONTROL_STOP:
+ msyslog(LOG_INFO, "SCM requests stop (%s)",
+ msg_tab[!!computer_shutting_down]);
+ UpdateSCM(SERVICE_STOP_PENDING);
if (WaitableExitEventHandle != NULL) {
- msyslog(LOG_INFO, "SCM requests stop (%s)",
- msg_tab[!!computer_shutting_down]);
- UpdateSCM(SERVICE_STOP_PENDING);
SetEvent(WaitableExitEventHandle);
- Sleep(100); //##++
- break;
+ } else {
+ exit(EX_SOFTWARE);
}
- msyslog(LOG_ERR, "SCM requests stop (%s), but have no exit event!",
- msg_tab[!!computer_shutting_down]);
- /* FALLTHROUGH */
+ break;
case SERVICE_CONTROL_PAUSE:
case SERVICE_CONTROL_CONTINUE:
RelativePath="..\..\..\libntp\numtoa.c"
>
</File>
- <File
- RelativePath="..\..\..\libntp\numtohost.c"
- >
- </File>
<File
RelativePath="..\..\..\libntp\octtoint.c"
>
RelativePath="..\..\..\..\libntp\numtoa.c"
>
</File>
- <File
- RelativePath="..\..\..\..\libntp\numtohost.c"
- >
- </File>
<File
RelativePath="..\..\..\..\libntp\octtoint.c"
>
<ClCompile Include="..\..\..\..\libntp\ntp_rfc2553.c" />
<ClCompile Include="..\..\..\..\libntp\ntp_worker.c" />
<ClCompile Include="..\..\..\..\libntp\numtoa.c" />
- <ClCompile Include="..\..\..\..\libntp\numtohost.c" />
<ClCompile Include="..\..\..\..\libntp\octtoint.c" />
<ClCompile Include="..\..\..\..\libntp\prettydate.c" />
<ClCompile Include="..\..\..\..\libntp\recvbuff.c" />
<ClCompile Include="..\..\..\..\libntp\numtoa.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\..\libntp\numtohost.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\..\libntp\octtoint.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\libntp\ntp_rfc2553.c" />
<ClCompile Include="..\..\..\..\libntp\ntp_worker.c" />
<ClCompile Include="..\..\..\..\libntp\numtoa.c" />
- <ClCompile Include="..\..\..\..\libntp\numtohost.c" />
<ClCompile Include="..\..\..\..\libntp\octtoint.c" />
<ClCompile Include="..\..\..\..\libntp\prettydate.c" />
<ClCompile Include="..\..\..\..\libntp\recvbuff.c" />
<ClCompile Include="..\..\..\..\libntp\numtoa.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\..\libntp\numtohost.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\..\libntp\octtoint.c">
<Filter>Source Files</Filter>
</ClCompile>
void
test_VerifyCMAC(void)
{
- const char* PKT_DATA =
- "sometestdata" /* Data */
- "\0\0\0\0" /* Key-ID (unused) */
- "\x4e\x0c\xf0\xe2\xc7\x8e\xbb\xbf" /* MAC */
- "\x79\xfc\x87\xc7\x8b\xb7\x4a\x0b";
- const int PKT_LEN = 12;
struct key cmac;
cmac.next = NULL;
#include "ntp.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
#define HLINE "--------------------------------------------------------------------------------\n"
#define PHLINE fprintf(output, HLINE);
test-msyslog \
test-netof \
test-numtoa \
- test-numtohost \
test-octtoint \
test-prettydate \
test-realpath \
$(srcdir)/run-msyslog.c \
$(srcdir)/run-netof.c \
$(srcdir)/run-numtoa.c \
- $(srcdir)/run-numtohost.c \
$(srcdir)/run-octtoint.c \
$(srcdir)/run-prettydate.c \
$(srcdir)/run-realpath.c \
###
-test_numtohost_SOURCES = \
- numtohost.c \
- run-numtohost.c \
- $(NULL)
-
-$(srcdir)/run-numtohost.c: $(srcdir)/numtohost.c $(std_unity_list)
- $(run_unity) $< $@
-
-###
-
test_octtoint_SOURCES = \
octtoint.c \
run-octtoint.c \
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
#include "unity.h"
#include "test-libntp.h"
void setUp(void);
-void test_ClassBAddress(void);
void test_ClassCAddress(void);
-void test_ClassAAddress(void);
void test_IPv6Address(void);
}
-void
-test_ClassBAddress(void)
-{
- sockaddr_u input = CreateSockaddr4("172.16.2.1", NTP_PORT);
- sockaddr_u expected = CreateSockaddr4("172.16.0.0", NTP_PORT);
-
- sockaddr_u* actual = netof(&input);
-
- TEST_ASSERT_TRUE(actual != NULL);
- TEST_ASSERT_TRUE(IsEqual(expected, *actual));
-
- return;
-}
-
void
test_ClassCAddress(void)
{
}
-void
-test_ClassAAddress(void)
-{
- /* Class A addresses are assumed to be classless,
- * thus the same address should be returned.
- */
- sockaddr_u input = CreateSockaddr4("10.20.30.40", NTP_PORT);
- sockaddr_u expected = CreateSockaddr4("10.20.30.40", NTP_PORT);
-
- sockaddr_u* actual = netof(&input);
-
- TEST_ASSERT_TRUE(actual != NULL);
- TEST_ASSERT_TRUE(IsEqual(expected, *actual));
-
- return;
-}
-
void
test_IPv6Address(void)
{
+++ /dev/null
-#include "config.h"
-
-#include "ntp_stdlib.h"
-#include "ntp_fp.h"
-
-#include "unity.h"
-
-void setUp(void);
-void test_LoopbackNetNonResolve(void);
-
-
-void
-setUp(void)
-{
- init_lib();
-
- return;
-}
-
-
-void
-test_LoopbackNetNonResolve(void) {
- /* A loopback address in 127.0.0.0/8 is chosen, and
- * numtohost() should not try to resolve it unless
- * it is 127.0.0.1
- */
-
- const u_int32 input = 127*256*256*256 + 1*256 + 1; // 127.0.1.1
-
- TEST_ASSERT_EQUAL_STRING("127.0.1.1", numtohost(htonl(input)));
-}
#include "config.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
#include "test-libntp.h"
#include <string.h>
progname = argv[0];
suite_setup();
UnityBegin("caljulian.c");
- RUN_TEST(test_RegularTime, 15);
- RUN_TEST(test_LeapYear, 16);
- RUN_TEST(test_uLongBoundary, 17);
- RUN_TEST(test_uLongWrapped, 18);
+ RUN_TEST(test_RegularTime, 14);
+ RUN_TEST(test_LeapYear, 15);
+ RUN_TEST(test_uLongBoundary, 16);
+ RUN_TEST(test_uLongWrapped, 17);
return (UnityEnd());
}
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
-extern void test_ClassBAddress(void);
extern void test_ClassCAddress(void);
-extern void test_ClassAAddress(void);
extern void test_IPv6Address(void);
progname = argv[0];
suite_setup();
UnityBegin("netof.c");
- RUN_TEST(test_ClassBAddress, 12);
- RUN_TEST(test_ClassCAddress, 13);
- RUN_TEST(test_ClassAAddress, 14);
- RUN_TEST(test_IPv6Address, 15);
+ RUN_TEST(test_ClassCAddress, 12);
+ RUN_TEST(test_IPv6Address, 13);
return (UnityEnd());
}
+++ /dev/null
-/* AUTOGENERATED FILE. DO NOT EDIT. */
-
-//=======Test Runner Used To Run Each Test Below=====
-#define RUN_TEST(TestFunc, TestLineNum) \
-{ \
- Unity.CurrentTestName = #TestFunc; \
- Unity.CurrentTestLineNumber = TestLineNum; \
- Unity.NumberOfTests++; \
- if (TEST_PROTECT()) \
- { \
- setUp(); \
- TestFunc(); \
- } \
- if (TEST_PROTECT() && !TEST_IS_IGNORED) \
- { \
- tearDown(); \
- } \
- UnityConcludeTest(); \
-}
-
-//=======Automagically Detected Files To Include=====
-#include "unity.h"
-#include <setjmp.h>
-#include <stdio.h>
-#include "config.h"
-#include "ntp_stdlib.h"
-#include "ntp_fp.h"
-
-//=======External Functions This Runner Calls=====
-extern void setUp(void);
-extern void tearDown(void);
-extern void test_LoopbackNetNonResolve(void);
-
-
-//=======Suite Setup=====
-static void suite_setup(void)
-{
-extern int change_iobufs(int);
-extern int change_logfile(const char*, int);
-change_iobufs(1);
-change_logfile("stderr", 0);
-}
-
-//=======Test Reset Option=====
-void resetTest(void);
-void resetTest(void)
-{
- tearDown();
- setUp();
-}
-
-char const *progname;
-
-
-//=======MAIN=====
-int main(int argc, char *argv[])
-{
- progname = argv[0];
- suite_setup();
- UnityBegin("numtohost.c");
- RUN_TEST(test_LoopbackNetNonResolve, 9);
-
- return (UnityEnd());
-}
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
#include "ntp_leapsec.h"
-#include "lib_strbuf.h"
#include "unity.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
#include "ntp_leapsec.h"
-#include "lib_strbuf.h"
#include "test-libntp.h"
#include <string.h>
progname = argv[0];
suite_setup();
UnityBegin("leapsec.c");
- RUN_TEST(test_ValidateGood, 329);
- RUN_TEST(test_ValidateNoHash, 339);
- RUN_TEST(test_ValidateBad, 349);
- RUN_TEST(test_ValidateMalformed, 359);
- RUN_TEST(test_ValidateMalformedShort, 369);
- RUN_TEST(test_ValidateNoLeadZero, 379);
- RUN_TEST(test_tableSelect, 394);
- RUN_TEST(test_loadFileExpire, 431);
- RUN_TEST(test_loadFileTTL, 449);
- RUN_TEST(test_lsQueryPristineState, 482);
- RUN_TEST(test_ls2009faraway, 496);
- RUN_TEST(test_ls2009weekaway, 515);
- RUN_TEST(test_ls2009houraway, 534);
- RUN_TEST(test_ls2009secaway, 553);
- RUN_TEST(test_ls2009onspot, 572);
- RUN_TEST(test_ls2009nodata, 591);
- RUN_TEST(test_ls2009limdata, 610);
- RUN_TEST(test_qryJumpFarAhead, 633);
- RUN_TEST(test_qryJumpAheadToTransition, 656);
- RUN_TEST(test_qryJumpAheadOverTransition, 679);
- RUN_TEST(test_addDynamic, 706);
- RUN_TEST(test_taiEmptyTable, 892);
- RUN_TEST(test_taiTableFixed, 906);
- RUN_TEST(test_taiTableDynamic, 920);
- RUN_TEST(test_taiTableDynamicDeadZone, 948);
- RUN_TEST(test_ls2009seqInsElectric, 970);
- RUN_TEST(test_ls2009seqInsDumb, 1015);
- RUN_TEST(test_ls2009seqDelElectric, 1064);
- RUN_TEST(test_ls2009seqDelDumb, 1109);
- RUN_TEST(test_ls2012seqInsElectric, 1153);
- RUN_TEST(test_ls2012seqInsDumb, 1198);
- RUN_TEST(test_lsEmptyTableDumb, 1249);
- RUN_TEST(test_lsEmptyTableElectric, 1272);
+ RUN_TEST(test_ValidateGood, 328);
+ RUN_TEST(test_ValidateNoHash, 338);
+ RUN_TEST(test_ValidateBad, 348);
+ RUN_TEST(test_ValidateMalformed, 358);
+ RUN_TEST(test_ValidateMalformedShort, 368);
+ RUN_TEST(test_ValidateNoLeadZero, 378);
+ RUN_TEST(test_tableSelect, 393);
+ RUN_TEST(test_loadFileExpire, 430);
+ RUN_TEST(test_loadFileTTL, 448);
+ RUN_TEST(test_lsQueryPristineState, 481);
+ RUN_TEST(test_ls2009faraway, 495);
+ RUN_TEST(test_ls2009weekaway, 514);
+ RUN_TEST(test_ls2009houraway, 533);
+ RUN_TEST(test_ls2009secaway, 552);
+ RUN_TEST(test_ls2009onspot, 571);
+ RUN_TEST(test_ls2009nodata, 590);
+ RUN_TEST(test_ls2009limdata, 609);
+ RUN_TEST(test_qryJumpFarAhead, 632);
+ RUN_TEST(test_qryJumpAheadToTransition, 655);
+ RUN_TEST(test_qryJumpAheadOverTransition, 678);
+ RUN_TEST(test_addDynamic, 705);
+ RUN_TEST(test_taiEmptyTable, 891);
+ RUN_TEST(test_taiTableFixed, 905);
+ RUN_TEST(test_taiTableDynamic, 919);
+ RUN_TEST(test_taiTableDynamicDeadZone, 947);
+ RUN_TEST(test_ls2009seqInsElectric, 969);
+ RUN_TEST(test_ls2009seqInsDumb, 1014);
+ RUN_TEST(test_ls2009seqDelElectric, 1063);
+ RUN_TEST(test_ls2009seqDelDumb, 1108);
+ RUN_TEST(test_ls2012seqInsElectric, 1152);
+ RUN_TEST(test_ls2012seqInsDumb, 1197);
+ RUN_TEST(test_lsEmptyTableDumb, 1248);
+ RUN_TEST(test_lsEmptyTableElectric, 1271);
return (UnityEnd());
}