diff options
author | Ollivier Robert <roberto@FreeBSD.org> | 2008-08-18 14:26:05 +0000 |
---|---|---|
committer | Ollivier Robert <roberto@FreeBSD.org> | 2008-08-18 14:26:05 +0000 |
commit | ff717da2cf625e3d07537a93a4c240692fa55bd6 (patch) | |
tree | 9dcf618e4446ac2b5fca7d0afe7767382664f0d6 /include/ntp.h | |
parent | cce65f439697627afbccf5a67035a957bb4d784a (diff) | |
download | src-ff717da2cf625e3d07537a93a4c240692fa55bd6.tar.gz src-ff717da2cf625e3d07537a93a4c240692fa55bd6.zip |
Import ntp 4.2.4p5 in the vendor code area. Far too many changes to list here,vendor/ntp/4.2.4p5
please see CommitLog for detailed changes.
XXX html/build/hints/solaris.xtra.4095849 is not being imported as it conflicts
with the detect-merge-conflict.sh script in our repo.
Notes
Notes:
svn path=/vendor/ntp/dist/; revision=181834
svn path=/vendor/ntp/4.2.4p5/; revision=181835; tag=vendor/ntp/4.2.4p5
Diffstat (limited to 'include/ntp.h')
-rw-r--r-- | include/ntp.h | 243 |
1 files changed, 138 insertions, 105 deletions
diff --git a/include/ntp.h b/include/ntp.h index 1ce302b7be98..dad9de136701 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -9,6 +9,10 @@ #ifdef OPENSSL #include "ntp_crypto.h" #endif /* OPENSSL */ +#include <ntp_random.h> + +#include <isc/boolean.h> +#include <isc/list.h> /* * Calendar arithmetic - contributed by G. Healton @@ -99,7 +103,7 @@ typedef char s_char; /* * Poll interval parameters */ -#define NTP_UNREACH 16 /* poll interval backoff count */ +#define NTP_UNREACH 24 /* poll unreach threshold */ #define NTP_MINPOLL 4 /* log2 min poll interval (16 s) */ #define NTP_MINDPOLL 6 /* log2 default min poll (64 s) */ #define NTP_MAXDPOLL 10 /* log2 default max poll (~17 m) */ @@ -111,7 +115,6 @@ typedef char s_char; /* * Clock filter algorithm tuning parameters */ -#define MINDISPERSE .01 /* min dispersion */ #define MAXDISPERSE 16. /* max dispersion */ #define NTP_SHIFT 8 /* clock filter stages */ #define NTP_FWEIGHT .5 /* clock filter weight */ @@ -119,28 +122,29 @@ typedef char s_char; /* * Selection algorithm tuning parameters */ -#define NTP_MINCLOCK 4 /* minimum survivors */ -#define NTP_MAXCLOCK 50 /* maximum candidates */ -#define MAXDISTANCE 1. /* max root distance */ +#define NTP_MINCLOCK 3 /* min survivors */ +#define NTP_MAXCLOCK 10 /* max candidates */ +#define NTP_MAXASSOC 50 /* max associations */ +#define MINDISPERSE .005 /* min dispersion increment */ +#define MAXDISTANCE 1. /* max root distance (select threshold) */ #define CLOCK_SGATE 3. /* popcorn spike gate */ #define HUFFPUFF 900 /* huff-n'-puff sample interval (s) */ -#define HYST .5 /* anti-clockhop hysteresis */ -#define HYST_TC .875 /* anti-clockhop hysteresis decay */ +#define MAXHOP 2 /* anti-clockhop threshold */ #define MAX_TTL 8 /* max ttl mapping vector size */ -#define NTP_MAXEXTEN 1024 /* maximum extension field size */ +#define BEACON 7200 /* manycast beacon interval */ +#define NTP_MAXEXTEN 1024 /* max extension field size */ /* * Miscellaneous stuff */ -#define NTP_MAXKEY 65535 /* maximum authentication key number */ +#define NTP_MAXKEY 65535 /* max authentication key number */ /* * Limits of things */ #define MAXFILENAME 128 /* max length of file name */ #define MAXHOSTNAME 512 /* max length of host/node name */ -#define NTP_MAXSTRLEN 256 /* maximum string length */ -#define MAXINTERFACES 512 /* max number of interfaces */ +#define NTP_MAXSTRLEN 256 /* max string length */ /* * Operations for jitter calculations (these use doubles). @@ -169,47 +173,77 @@ typedef char s_char; */ struct interface { SOCKET fd; /* socket this is opened on */ - SOCKET bfd; /* socket for receiving broadcasts */ + SOCKET bfd; /* socket for receiving broadcasts */ struct sockaddr_storage sin; /* interface address */ - struct sockaddr_storage bcast; /* broadcast address */ - struct sockaddr_storage mask; /* interface mask */ - char name[32]; /* name of interface */ - int flags; /* interface flags */ - int last_ttl; /* last TTL specified */ - u_int addr_refid; /* IPv4 addr or IPv6 hash */ - int num_mcast; /* No. of IP addresses in multicast socket */ - volatile long received; /* number of incoming packets */ - long sent; /* number of outgoing packets */ - long notsent; /* number of send failures */ + struct sockaddr_storage bcast; /* broadcast address */ + struct sockaddr_storage mask; /* interface mask */ + char name[32]; /* name of interface */ + short family; /* Address family */ + int flags; /* interface flags */ + int last_ttl; /* last TTL specified */ + u_int32 addr_refid; /* IPv4 addr or IPv6 hash */ + int num_mcast; /* No. of IP addresses in multicast socket */ + u_long starttime; /* current_time as of creation of interface structure */ + volatile long received; /* number of incoming packets */ + long sent; /* number of outgoing packets */ + long notsent; /* number of send failures */ + u_int scopeid; /* Scope used for Multicasting */ + u_int ifindex; /* interface index */ + u_int ifnum; /* sequential interface instance count */ + u_char phase; /* phase in update cycle */ + isc_boolean_t ignore_packets; /* Specify whether the packet should be ignored */ + ISC_LIST(struct peer) peers; /* list of peers for the interface */ + u_int peercnt; /* number of peers referencinf this interface - informational only */ + ISC_LINK(struct interface) link; /* interface list */ }; /* * Flags for interfaces */ -#define INT_UP 1 /* Interface is up */ -#define INT_PPP 2 /* Point-to-point interface */ -#define INT_LOOPBACK 4 /* the loopback interface */ -#define INT_BROADCAST 8 /* can broadcast out this interface */ -#define INT_MULTICAST 16 /* multicasting enabled */ -#define INT_BCASTOPEN 32 /* broadcast socket is open */ - +#define INT_UP 0x001 /* Interface is up */ +#define INT_PPP 0x002 /* Point-to-point interface */ +#define INT_LOOPBACK 0x004 /* the loopback interface */ +#define INT_BROADCAST 0x008 /* can broadcast out this interface */ +#define INT_MULTICAST 0x010 /* can multicast out this interface */ +#define INT_BCASTOPEN 0x020 /* broadcast socket is open */ +#define INT_MCASTOPEN 0x040 /* multicasting enabled */ +#define INT_WILDCARD 0x080 /* wildcard interface - usually skipped */ +#define INT_MCASTIF 0x100 /* bound directly to MCAST address */ /* * Define flasher bits (tests 1 through 11 in packet procedure) * These reveal the state at the last grumble from the peer and are * most handy for diagnosing problems, even if not strictly a state * variable in the spec. These are recorded in the peer structure. + * + * Packet errors */ -#define TEST1 0x0001 /* duplicate packet received */ -#define TEST2 0x0002 /* bogus packet received */ +#define TEST1 0X0001 /* duplicate packet */ +#define TEST2 0x0002 /* bogus packet */ #define TEST3 0x0004 /* protocol unsynchronized */ #define TEST4 0x0008 /* access denied */ -#define TEST5 0x0010 /* authentication failed */ -#define TEST6 0x0020 /* peer clock unsynchronized */ -#define TEST7 0x0040 /* peer stratum out of bounds */ -#define TEST8 0x0080 /* root delay/dispersion bounds check */ -#define TEST9 0x0100 /* peer delay/dispersion bounds check */ -#define TEST10 0x0200 /* autokey failed */ -#define TEST11 0x0400 /* proventic not confirmed */ +#define TEST5 0x0010 /* authentication error */ +#define TEST6 0x0020 /* bad synch or stratum */ +#define TEST7 0x0040 /* bad header data */ +#define TEST8 0x0080 /* autokey error */ +#define TEST9 0x0100 /* crypto error */ +#define PKT_TEST_MASK (TEST1 | TEST2 | TEST3 | TEST4 | TEST5 |\ + TEST6 | TEST7 | TEST8 | TEST9) +/* + * Peer errors + */ +#define TEST10 0x0200 /* peer bad synch or stratum */ +#define TEST11 0x0400 /* peer distance exceeded */ +#define TEST12 0x0800 /* peer synchronization loop */ +#define TEST13 0x1000 /* peer unreacable */ +#define PEER_TEST_MASK (TEST10 | TEST11 | TEST12 | TEST13) + +/* + * Authentication codes + */ +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_OK 1 /* authentication OK */ +#define AUTH_ERROR 2 /* authentication error */ +#define AUTH_CRYPTO 3 /* crypto-NAK */ /* * The peer structure. Holds state information relating to the guys @@ -221,14 +255,13 @@ struct peer { struct peer *ass_next; /* link pointer in associd hash */ struct sockaddr_storage srcadr; /* address of remote host */ struct interface *dstadr; /* pointer to address on local host */ + ISC_LINK(struct peer) ilink; /* interface link list */ associd_t associd; /* association ID */ u_char version; /* version number */ u_char hmode; /* local association mode */ u_char hpoll; /* local poll interval */ - u_char kpoll; /* last poll interval */ u_char minpoll; /* min poll interval */ u_char maxpoll; /* max poll interval */ - u_char burst; /* packets remaining in burst */ u_int flags; /* association flags */ u_char cast_flags; /* additional flags */ u_int flash; /* protocol error test tally bits */ @@ -239,10 +272,12 @@ struct peer { /* * Variables used by reference clock support */ +#ifdef REFCLOCK struct refclockproc *procptr; /* refclock structure pointer */ u_char refclktype; /* reference clock type */ u_char refclkunit; /* reference clock unit number */ u_char sstclktype; /* clock type for system status word */ +#endif /* REFCLOCK */ /* * Variables set by received packet @@ -250,8 +285,10 @@ struct peer { u_char leap; /* local leap indicator */ u_char pmode; /* remote association mode */ u_char stratum; /* remote stratum */ - s_char precision; /* remote clock precision */ u_char ppoll; /* remote poll interval */ + s_char precision; /* remote clock precision */ + double rootdelay; /* roundtrip delay to primary clock */ + double rootdispersion; /* dispersion to primary clock */ u_int32 refid; /* remote reference ID */ l_fp reftime; /* update epoch */ @@ -275,7 +312,6 @@ struct peer { BIGNUM *grpkey; /* GQ group key */ struct value cookval; /* cookie values */ struct value recval; /* receive autokey values */ - struct value tai_leap; /* leapseconds values */ struct exten *cmmd; /* extension pointer */ /* @@ -285,6 +321,7 @@ struct peer { int keynumber; /* current key number */ struct value encrypt; /* send encrypt values */ struct value sndval; /* send autokey values */ + struct value tai_leap; /* send leapsecond table */ #else /* OPENSSL */ #define clear_to_zero status #endif /* OPENSSL */ @@ -295,7 +332,8 @@ struct peer { u_char status; /* peer status */ u_char reach; /* reachability register */ u_long epoch; /* reference epoch */ - u_short filter_nextpt; /* index into filter shift register */ + u_int burst; /* packets remaining in burst */ + u_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 */ @@ -309,24 +347,18 @@ struct peer { double jitter; /* peer jitter (squares) */ double disp; /* peer dispersion */ double estbdelay; /* clock offset to broadcast server */ - double hyst; /* anti-clockhop hysteresis */ - - /* - * Variables set by received packet - */ - double rootdelay; /* roundtrip delay to primary clock */ - double rootdispersion; /* dispersion to primary clock */ /* * End of clear-to-zero area */ u_long update; /* receive epoch */ -#define end_clear_to_zero update u_int unreach; /* unreachable count */ +#define end_clear_to_zero unreach u_long outdate; /* send time last packet */ u_long nextdate; /* send time next packet */ - u_long nextaction; /* peer local activity timeout (refclocks mainly) */ + u_long nextaction; /* peer local activity timeout (refclocks) */ void (*action) P((struct peer *)); /* action timeout function */ + /* * Statistic counters */ @@ -340,9 +372,8 @@ struct peer { u_long badauth; /* packets cryptosum failed */ u_long bogusorg; /* packets bogus origin */ u_long oldpkt; /* packets duplicate packet */ - u_long seldisptoolarge; /* packets dispersion to large*/ + u_long seldisptoolarge; /* packets dispersion too large */ u_long selbroken; /* not used */ - u_long rank; /* number of times selected or in cluster */ }; /* @@ -354,17 +385,27 @@ struct peer { #define LEAP_NOTINSYNC 0x3 /* overload, clock is free running */ /* - * Values for peer.mode + * Values for peer mode and packet mode. Only the modes through + * MODE_BROADCAST and MODE_BCLIENT appear in the transition + * function. MODE_CONTROL and MODE_PRIVATE can appear in packets, + * but those never survive to the transition function. + * is a */ #define MODE_UNSPEC 0 /* unspecified (old version) */ -#define MODE_ACTIVE 1 /* symmetric active */ -#define MODE_PASSIVE 2 /* symmetric passive */ +#define MODE_ACTIVE 1 /* symmetric active mode */ +#define MODE_PASSIVE 2 /* symmetric passive mode */ #define MODE_CLIENT 3 /* client mode */ #define MODE_SERVER 4 /* server mode */ #define MODE_BROADCAST 5 /* broadcast mode */ -#define MODE_CONTROL 6 /* control mode packet */ -#define MODE_PRIVATE 7 /* implementation defined function */ -#define MODE_BCLIENT 8 /* broadcast client mode */ +/* + * These can appear in packets + */ +#define MODE_CONTROL 6 /* control mode */ +#define MODE_PRIVATE 7 /* private mode */ +/* + * This is a madeup mode for broadcast client. + */ +#define MODE_BCLIENT 6 /* broadcast client mode */ /* * Values for peer.stratum, sys_stratum @@ -387,8 +428,11 @@ struct peer { #define FLAG_PREFER 0x0080 /* this is the preferred peer */ #define FLAG_BURST 0x0100 /* burst mode */ #define FLAG_IBURST 0x0200 /* initial burst mode */ -#define FLAG_NOSELECT 0x0400 /* this is a "noselect" peer */ +#define FLAG_NOSELECT 0x0400 /* never select */ #define FLAG_ASSOC 0x0800 /* autokey request */ +#define FLAG_FIXPOLL 0x1000 /* stick at minpoll */ +#define FLAG_TRUE 0x2000 /* select truechimer */ +#define FLAG_PREEMPT 0x4000 /* preemptable association */ /* * Definitions for the clear() routine. We use memset() to clear @@ -430,13 +474,13 @@ struct peer { #define REFCLK_GPSTM_TRUE 15 /* OLD TrueTime GPS/TM-TMD Receiver */ #define REFCLK_IRIG_BANCOMM 16 /* Bancomm GPS/IRIG Interface */ #define REFCLK_GPS_DATUM 17 /* Datum Programmable Time System */ -#define REFCLK_NIST_ACTS 18 /* NIST Auto Computer Time Service */ +#define REFCLK_ACTS 18 /* Generic Auto Computer Time Service */ #define REFCLK_WWV_HEATH 19 /* Heath GC1000 WWV/WWVH Receiver */ #define REFCLK_GPS_NMEA 20 /* NMEA based GPS clock */ #define REFCLK_GPS_VME 21 /* TrueTime GPS-VME Interface */ #define REFCLK_ATOM_PPS 22 /* 1-PPS Clock Discipline */ -#define REFCLK_PTB_ACTS 23 /* PTB Auto Computer Time Service */ -#define REFCLK_USNO 24 /* Naval Observatory dialup */ +#define REFCLK_PTB_ACTS 23 /* replaced by REFCLK_ACTS */ +#define REFCLK_USNO 24 /* replaced by REFCLK_ACTS */ #define REFCLK_GPS_HP 26 /* HP 58503A Time/Frequency Receiver */ #define REFCLK_ARCRON_MSF 27 /* ARCRON MSF radio clock. */ #define REFCLK_SHM 28 /* clock attached thru shared memory */ @@ -483,7 +527,7 @@ struct peer { (sizeof(struct sockaddr_in)) : (sizeof(struct sockaddr_in6))) #define ANYSOCK(sock) \ - memset(((struct sockaddr_in *)sock), 0, \ + memset(((struct sockaddr_storage *)sock), 0, \ sizeof(struct sockaddr_storage)) #define ANY_INTERFACE_CHOOSE(sock) \ @@ -656,29 +700,15 @@ struct pkt { * To speed lookups, peers are hashed by the low order bits of the * remote IP address. These definitions relate to that. */ -#define HASH_SIZE 128 -#define HASH_MASK (HASH_SIZE-1) -#define HASH_ADDR(src) sock_hash(src) +#define NTP_HASH_SIZE 128 +#define NTP_HASH_MASK (NTP_HASH_SIZE-1) +#define NTP_HASH_ADDR(src) sock_hash(src) /* - * How we randomize polls. The poll interval is a power of two. - * We chose a random value which is between 1/4 and 3/4 of the - * poll interval we would normally use and which is an even multiple - * of the EVENT_TIMEOUT. The random number routine, given an argument - * spread value of n, returns an integer between 0 and (1<<n)-1. This - * is shifted by EVENT_TIMEOUT and added to the base value. + * How we randomize polls. The poll interval is a power of two. We chose + * a random interval which is this value plus-minus one second. */ -#if defined(HAVE_MRAND48) -# define RANDOM (mrand48()) -# define SRANDOM(x) (srand48(x)) -#else -# define RANDOM (random()) -# define SRANDOM(x) (srandom(x)) -#endif - -#define RANDPOLL(x) ((1 << (x)) - 1 + (RANDOM & 0x3)) -#define RANDOM_SPREAD(poll) ((poll) - (EVENT_TIMEOUT+1)) -#define RANDOM_POLL(poll, rval) ((((rval)+1)<<EVENT_TIMEOUT) + (1<<((poll)-2))) +#define RANDPOLL(x) ((1 << (x)) - 1 + (ntp_random() & 0x3)) /* * min, min3 and max. Makes it easier to transliterate the spec without @@ -706,12 +736,18 @@ struct pkt { #define PROTO_PPS 12 #define PROTO_CAL 13 #define PROTO_MINCLOCK 14 -#define PROTO_MINSANE 15 -#define PROTO_FLOOR 16 -#define PROTO_CEILING 17 -#define PROTO_COHORT 18 -#define PROTO_CALLDELAY 19 -#define PROTO_ADJ 20 +#define PROTO_MAXCLOCK 15 +#define PROTO_MINSANE 16 +#define PROTO_FLOOR 17 +#define PROTO_CEILING 18 +#define PROTO_COHORT 19 +#define PROTO_CALLDELAY 20 +#define PROTO_MINDISP 21 +#define PROTO_MAXDIST 22 +#define PROTO_ADJ 23 +#define PROTO_MAXHOP 24 +#define PROTO_BEACON 25 +#define PROTO_ORPHAN 26 /* * Configuration items for the loop filter @@ -726,6 +762,7 @@ struct pkt { #define LOOP_ALLAN 8 /* set minimum Allan intercept */ #define LOOP_HUFFPUFF 9 /* set huff-n'-puff filter length */ #define LOOP_FREQ 10 /* set initial frequency */ +#define LOOP_KERN_CLEAR 11 /* reset kernel pll parameters */ /* * Configuration items for the stats printer @@ -839,6 +876,7 @@ struct restrictlist6 { #define RESTRICT_FLAGS 1 /* add flags to restrict entry */ #define RESTRICT_UNFLAG 2 /* remove flags from restrict entry */ #define RESTRICT_REMOVE 3 /* remove a restrict entry */ +#define RESTRICT_REMOVEIF 4 /* remove an interface restrict entry */ /* * Endpoint structure for the select algorithm @@ -849,22 +887,17 @@ struct endpoint { }; /* - * Defines for association matching - */ -#define AM_MODES 10 /* total number of modes */ -#define NO_PEER 0 /* action when no peer is found */ - -/* * Association matching AM[] return codes */ -#define AM_ERR -1 -#define AM_NOMATCH 0 -#define AM_PROCPKT 1 -#define AM_FXMIT 2 -#define AM_MANYCAST 3 -#define AM_NEWPASS 4 -#define AM_NEWBCL 5 -#define AM_POSSBCL 6 +#define AM_ERR -1 /* error */ +#define AM_NOMATCH 0 /* no match */ +#define AM_PROCPKT 1 /* server/symmetric packet */ +#define AM_BCST 2 /* broadcast packet */ +#define AM_FXMIT 3 /* client packet */ +#define AM_MANYCAST 4 /* manycast packet */ +#define AM_NEWPASS 5 /* new passive */ +#define AM_NEWBCL 6 /* new broadcast */ +#define AM_POSSBCL 7 /* discard broadcast */ /* NetInfo configuration locations */ #ifdef HAVE_NETINFO |