diff options
Diffstat (limited to 'usr.sbin/xntpd/include')
-rw-r--r-- | usr.sbin/xntpd/include/l_stdlib.h | 8 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp.h | 15 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp_control.h | 1 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp_if.h | 4 | ||||
-rwxr-xr-x | usr.sbin/xntpd/include/ntp_in.h | 259 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp_io.h | 1 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp_machine.h | 34 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp_request.h | 66 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntp_timex.h | 227 | ||||
-rw-r--r-- | usr.sbin/xntpd/include/ntpd.h | 9 |
10 files changed, 538 insertions, 86 deletions
diff --git a/usr.sbin/xntpd/include/l_stdlib.h b/usr.sbin/xntpd/include/l_stdlib.h index 89a8092..e0b7c47 100644 --- a/usr.sbin/xntpd/include/l_stdlib.h +++ b/usr.sbin/xntpd/include/l_stdlib.h @@ -70,11 +70,11 @@ extern int getppid P((void)); extern int close P((int)); extern int ioctl P((int, int, char *)); -extern int read P((int, char *, unsigned)); +extern int read P((int, void *, unsigned)); extern int rename P((char *, char *)); -extern int write P((int, char *, int)); -extern int unlink P((char *)); -extern int link P((char *, char *)); +extern int write P((int, const void *, unsigned)); +extern int unlink P((const char *)); +extern int link P((const char *, const char *)); #ifdef FILE extern int fclose P((FILE *)); diff --git a/usr.sbin/xntpd/include/ntp.h b/usr.sbin/xntpd/include/ntp.h index b3fd0ce..01bfa16 100644 --- a/usr.sbin/xntpd/include/ntp.h +++ b/usr.sbin/xntpd/include/ntp.h @@ -173,6 +173,7 @@ struct interface { #define INT_BROADCAST 1 /* can broadcast out this interface */ #define INT_BCASTOPEN 2 /* broadcast socket is open */ #define INT_LOOPBACK 4 /* the loopback interface */ +#define INT_MULTICAST 8 /* multicasting enabled */ /* * Define flasher bits (tests 1 through 8 in packet procedure) @@ -222,7 +223,7 @@ struct peer { U_LONG keyid; /* encription key ID */ U_LONG pkeyid; /* keyid used to encrypt last message */ u_short associd; /* association ID, a unique integer */ - u_char unused; + u_char ttl; /* time to live (multicast) */ /* **Start of clear-to-zero area.*** */ /* Everything that is cleared to zero goes below here */ u_char valid; /* valid counter */ @@ -248,12 +249,6 @@ struct peer { s_fp soffset; /* fp version of above */ s_fp synch; /* synch distance from above */ u_fp selectdisp; /* select dispersion */ - - /* - * Stuff related to the experimental broadcast delay - * determination code. The registers will probably go away - * later. - */ U_LONG estbdelay; /* broadcast delay, as a ts fraction */ /* @@ -579,8 +574,8 @@ struct recvbuf { #define PROTO_AUTHENTICATE 3 #define PROTO_BROADDELAY 4 #define PROTO_AUTHDELAY 5 -#define PROTO_MAXSKEW 6 -#define PROTO_SELECT 7 +#define PROTO_MULTICAST_ADD 6 +#define PROTO_MULTICAST_DEL 7 /* * Configuration items for the loop filter @@ -603,7 +598,7 @@ struct recvbuf { */ #define DEFPRECISION (-5) /* conservatively low */ #define DEFBROADDELAY (0x020c49ba) /* 8 ms. This is round trip delay */ - +#define INADDR_NTP 0xe0000101 /* NTP multicast address 224.0.1.1 */ /* * Structure used optionally for monitoring when this is turned on. */ diff --git a/usr.sbin/xntpd/include/ntp_control.h b/usr.sbin/xntpd/include/ntp_control.h index 74f75f1..1e19383 100644 --- a/usr.sbin/xntpd/include/ntp_control.h +++ b/usr.sbin/xntpd/include/ntp_control.h @@ -68,6 +68,7 @@ struct ntp_control { #define CTL_SST_TS_UDPTIME 7 /* time source UDP/TIME */ #define CTL_SST_TS_WRSTWTCH 8 /* time source is wristwatch */ #define CTL_SST_TS_TELEPHONE 9 /* time source is telephone modem */ +#define CTL_SST_TS_PPS 0x20 /* time source is PPS signal */ #define CTL_SYS_MAXEVENTS 15 diff --git a/usr.sbin/xntpd/include/ntp_if.h b/usr.sbin/xntpd/include/ntp_if.h index 1a76ca0..45a70c5 100644 --- a/usr.sbin/xntpd/include/ntp_if.h +++ b/usr.sbin/xntpd/include/ntp_if.h @@ -16,6 +16,10 @@ #include <sys/sockio.h> #endif +#if defined(SYS_UNIXWARE1) +#include <sys/sockio.h> +#endif + #if defined(SYS_PTX) || defined(SYS_SINIXM) #include <sys/stream.h> #include <sys/stropts.h> diff --git a/usr.sbin/xntpd/include/ntp_in.h b/usr.sbin/xntpd/include/ntp_in.h new file mode 100755 index 0000000..80aa451 --- /dev/null +++ b/usr.sbin/xntpd/include/ntp_in.h @@ -0,0 +1,259 @@ +/* @(#)in.h 1.19 90/07/27 SMI; from UCB 7.5 2/22/88 */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981. + */ + +#ifndef _netinet_in_h +#define _netinet_in_h +#define _NETINET_IN_H_ +#define _SYS_IN_INCLUDED +#define __IN_HEADER + +/* + * Protocols + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_IGMP 2 /* group control protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_ST 5 /* st */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_HELLO 63 /* "hello" routing protocol */ +#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ +#define IPPROTO_OSPF 89 /* Open SPF IGP */ + +#define IPPROTO_RAW 255 /* raw IP packet */ +#define IPPROTO_MAX 256 + +/* + * Port/socket numbers: network standard functions + */ +#define IPPORT_ECHO 7 +#define IPPORT_DISCARD 9 +#define IPPORT_SYSTAT 11 +#define IPPORT_DAYTIME 13 +#define IPPORT_NETSTAT 15 +#define IPPORT_FTP 21 +#define IPPORT_TELNET 23 +#define IPPORT_SMTP 25 +#define IPPORT_TIMESERVER 37 +#define IPPORT_NAMESERVER 42 +#define IPPORT_WHOIS 43 +#define IPPORT_MTP 57 + +/* + * Port/socket numbers: host specific functions + */ +#define IPPORT_TFTP 69 +#define IPPORT_RJE 77 +#define IPPORT_FINGER 79 +#define IPPORT_TTYLINK 87 +#define IPPORT_SUPDUP 95 + +/* + * UNIX TCP sockets + */ +#define IPPORT_EXECSERVER 512 +#define IPPORT_LOGINSERVER 513 +#define IPPORT_CMDSERVER 514 +#define IPPORT_EFSSERVER 520 + +/* + * UNIX UDP sockets + */ +#define IPPORT_BIFFUDP 512 +#define IPPORT_WHOSERVER 513 +#define IPPORT_ROUTESERVER 520 /* 520+1 also used */ + +/* + * Ports < IPPORT_RESERVED are reserved for + * privileged processes (e.g. root). + * Ports > IPPORT_USERRESERVED are reserved + * for servers, not necessarily privileged. + */ +#define IPPORT_RESERVED 1024 +#define IPPORT_USERRESERVED 5000 + +/* + * Link numbers + */ +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 + +/* + * Internet address + * This definition contains obsolete fields for compatibility + * with SunOS 3.x and 4.2bsd. The presence of subnets renders + * divisions into fixed fields misleading at best. New code + * should use only the s_addr field. + */ +struct in_addr { + union { + struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; + struct { u_short s_w1,s_w2; } S_un_w; + u_long S_addr; + } S_un; +#define s_addr S_un.S_addr /* should be used for all code */ +#define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */ +#define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */ +#define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */ +#define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */ +#define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */ +}; + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + */ +#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ff + +#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) +#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) +#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) + +#define INADDR_ANY (u_long)0x00000000 +#define INADDR_LOOPBACK (u_long)0x7F000001 +#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ + +#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */ +#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */ + +#define IN_LOOPBACKNET 127 /* official! */ + +/* + * Define a macro to stuff the loopback address into an Internet address + */ +#define IN_SET_LOOPBACK_ADDR(a) {(a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \ + (a)->sin_family = AF_INET;} + +/* + * Socket address, internet style. + */ +struct sockaddr_in { + short sin_family; + u_short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +/* + * Options for use with [gs]etsockopt at the IP level. + */ +#define IP_OPTIONS 1 /* set/get IP per-packet options */ +#define IP_MULTICAST_IF 2 /* set/get IP multicast interface */ +#define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */ +#define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */ +#define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */ + +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ +#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */ + +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +#if !defined(vax) && !defined(ntohl) && !defined(i386) +/* + * Macros for number representation conversion. + */ +#define ntohl(x) (x) +#define ntohs(x) (x) +#define htonl(x) (x) +#define htons(x) (x) +#endif + +#if !defined(ntohl) && (defined(vax) || defined(i386)) +u_short ntohs(), htons(); +u_long ntohl(), htonl(); +#endif + +#ifdef KERNEL +extern struct domain inetdomain; +extern struct protosw inetsw[]; +struct in_addr in_makeaddr(); +u_long in_netof(), in_lnaof(); +#endif + +#ifndef BYTE_ORDER +/* + * Definitions for byte order, + * according to byte significance from low address to high. + */ +#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ +#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ + +#if defined(vax) || defined(i386) +#define BYTE_ORDER LITTLE_ENDIAN +#else +#define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */ +#endif +#endif BYTE_ORDER + +/* + * Macros for number representation conversion. + */ +#if BYTE_ORDER==LITTLE_ENDIAN +#define NTOHL(d) ((d) = ntohl((d))) +#define NTOHS(d) ((d) = ntohs((d))) +#define HTONL(d) ((d) = htonl((d))) +#define HTONS(d) ((d) = htons((d))) +#else +#define ntohl(x) (x) +#define ntohs(x) (x) +#define htonl(x) (x) +#define htons(x) (x) +#define NTOHL(d) +#define NTOHS(d) +#define HTONL(d) +#define HTONS(d) +#endif + +#endif /*!_netinet_in_h*/ diff --git a/usr.sbin/xntpd/include/ntp_io.h b/usr.sbin/xntpd/include/ntp_io.h index c3b79be..d60f083 100644 --- a/usr.sbin/xntpd/include/ntp_io.h +++ b/usr.sbin/xntpd/include/ntp_io.h @@ -3,6 +3,7 @@ * SEEK_SET symbol form <untisd.h>. */ #if defined(NTP_POSIX_SOURCE) + /* * POSIX way */ diff --git a/usr.sbin/xntpd/include/ntp_machine.h b/usr.sbin/xntpd/include/ntp_machine.h index 4c7c3ea..abc0acb 100644 --- a/usr.sbin/xntpd/include/ntp_machine.h +++ b/usr.sbin/xntpd/include/ntp_machine.h @@ -526,6 +526,40 @@ typedef unsigned long u_long; #endif /* + * (Univel/Novell) Unixware1 SVR4 on intel x86 processor + */ +#if defined(SYS_UNIXWARE1) +/* #define _POSIX_SOURCE */ +#undef HAVE_ATT_SETPGRP +#define USE_PROTOTYPES +#define NTP_POSIX_SOURCE +#define HAVE_ATT_NICE +#define HAVE_READKMEM +#define USE_TTY_SIGPOLL +#define USE_UDP_SIGPOLL +#define UDP_WILDCARD_DELIVERY +#undef HAVE_SIGNALED_IO +#define STREAM +#define STREAMS +#ifndef STREAMS_TLI +/*#define STREAMS_TLI*/ +#endif +/* #define USE_STREAMS_DEVICE_FOR_IF_CONFIG */ +#undef STEP_SLEW /* TWO step */ +#define LOCK_PROCESS +#define NO_SIGNED_CHAR_DECL +#undef SYSV_TIMEOFDAY +#define SIZE_RETURNED_IN_BUFFER +#define RETSIGTYPE void +#include <sys/sockio.h> +#include <sys/types.h> +#include <netinet/in_systm.h> +#ifndef STR_SYSTEM +#define STR_SYSTEM "UNIX/Unixware1" +#endif +#endif + +/* * DomainOS */ #if defined(SYS_DOMAINOS) diff --git a/usr.sbin/xntpd/include/ntp_request.h b/usr.sbin/xntpd/include/ntp_request.h index b791c18..b1a9472 100644 --- a/usr.sbin/xntpd/include/ntp_request.h +++ b/usr.sbin/xntpd/include/ntp_request.h @@ -254,9 +254,8 @@ struct resp_pkt { #define REQ_GET_LEAPINFO 35 /* get leap information */ #define REQ_GET_CLOCKINFO 36 /* get clock information */ #define REQ_SET_CLKFUDGE 37 /* set clock fudge factors */ -#define REQ_SET_MAXSKEW 38 /* set the maximum skew factor */ +#define REQ_GET_KERNEL 38 /* get kernel pll/pps information */ #define REQ_GET_CLKBUGINFO 39 /* get clock debugging info */ -#define REQ_SET_SELECT_CODE 40 /* set selection algorithm */ #define REQ_SET_PRECISION 41 /* set clock precision */ @@ -267,8 +266,9 @@ struct resp_pkt { #define INFO_FLAG_SYSPEER 0x2 #define INFO_FLAG_MINPOLL 0x4 #define INFO_FLAG_REFCLOCK 0x8 +#define INFO_FLAG_MCLIENT 0x8 /* danger */ #define INFO_FLAG_BCLIENT 0x10 -#define INFO_FLAG_PREFER 0x10 /* SHARES BCLIENT bit - ok since mutually exclusive - Oh why ist flags a u_char ? */ +#define INFO_FLAG_PREFER 0x10 /* danger */ #define INFO_FLAG_AUTHENABLE 0x20 #define INFO_FLAG_SEL_CANDIDATE 0x40 #define INFO_FLAG_SHORTLIST 0x80 @@ -323,10 +323,10 @@ struct info_peer { u_char valid; /* peer.valid */ u_char reach; /* peer.reach */ u_char unreach; /* peer.unreach */ - u_char trust; /* peer.trust */ - u_char unused1; - u_char unused2; - u_char unused3; + u_char flash; /* peer.flash */ + u_char ttl; /* peer.ttl */ + u_char unused8; /* (obsolete) */ + u_char unused9; u_short associd; /* association ID */ U_LONG keyid; /* auth key in use */ U_LONG pkeyid; /* peer.pkeyid */ @@ -344,7 +344,14 @@ struct info_peer { s_fp delay; /* peer.estdelay */ u_fp dispersion; /* peer.estdisp */ l_fp offset; /* peer.estoffset */ - U_LONG bdelay[NTP_SHIFT]; /* broadcast delay filters */ + u_fp selectdisp; /* peer select dispersion */ + LONG unused1; /* (obsolete) */ + LONG unused2; + LONG unused3; + LONG unused4; + LONG unused5; + LONG unused6; + LONG unused7; U_LONG estbdelay; /* broadcast delay */ }; @@ -406,12 +413,13 @@ struct info_sys { U_LONG refid; /* reference ID of sync source */ l_fp reftime; /* system reference time */ U_LONG poll; /* system poll interval */ - u_short flags; /* system flags */ - u_char selection; /* selection algorithm code */ - u_char unused; - l_fp bdelay; /* default broadcast delay, a ts fraction */ + u_char flags; /* system flags */ + u_char unused1; /* unused */ + u_char unused2; /* unused */ + u_char unused3; /* unused */ + l_fp bdelay; /* default broadcast delay */ l_fp authdelay; /* default authentication delay */ - u_fp maxskew; /* maximum skew parameter (obsolete) */ + u_fp maxskew; /* (obsolete) */ }; @@ -428,7 +436,7 @@ struct info_sys_stats { U_LONG badlength; /* packets with bad length */ U_LONG processed; /* packets processed */ U_LONG badauth; /* packets dropped because of authorization */ - U_LONG wanderhold; + U_LONG wanderhold; /* (obsolete) */ U_LONG limitrejected; /* rejected because of client limitation */ }; @@ -504,7 +512,8 @@ struct conf_peer { u_char minpoll; /* min host poll interval */ u_char maxpoll; /* max host poll interval */ u_char flags; /* flags for this request */ - u_char unused; + u_char ttl; /* time to live (multicast) */ + u_short unused; /* unused */ U_LONG keyid; /* key to use for this association */ }; @@ -534,6 +543,7 @@ struct conf_sys_flags { */ #define SYS_FLAG_BCLIENT 0x1 #define SYS_FLAG_AUTHENTICATE 0x2 +#define SYS_FLAG_MCLIENT 0x4 /* * Structure used for returning restrict entries @@ -742,3 +752,29 @@ struct info_clkbug { U_LONG values[NUMCBUGVALUES]; l_fp times[NUMCBUGTIMES]; }; + +/* + * Structure used for returning kernel pll/PPS information + */ +struct info_kernel { + LONG offset; + LONG freq; + LONG maxerror; + LONG esterror; + u_short status; + u_short shift; + LONG constant; + LONG precision; + LONG tolerance; + +/* + * Variables used only if PPS signal discipline is implemented + */ + LONG ppsfreq; + LONG jitter; + LONG stabil; + LONG jitcnt; + LONG calcnt; + LONG errcnt; + LONG stbcnt; +}; diff --git a/usr.sbin/xntpd/include/ntp_timex.h b/usr.sbin/xntpd/include/ntp_timex.h index 43b6ae7..cb8396a 100644 --- a/usr.sbin/xntpd/include/ntp_timex.h +++ b/usr.sbin/xntpd/include/ntp_timex.h @@ -17,6 +17,10 @@ /* * Modification history timex.h * + * 19 Mar 94 David L. Mills + * Moved defines from kernel routines to header file and added new + * defines for PPS phase-lock loop. + * * 20 Feb 94 David L. Mills * Revised status codes and structures for external clock and PPS * signal discipline. @@ -24,7 +28,7 @@ * 28 Nov 93 David L. Mills * Adjusted parameters to improve stability and increase poll * interval. - * + * * 17 Sep 93 David L. Mills * Created file */ @@ -57,98 +61,213 @@ * struct timex *tptr pointer to timex structure * */ +#ifndef MSDOS /* Microsoft specific */ #include <sys/syscall.h> +#endif /* MSDOS */ /* - * The following defines establish the engineering parameters of the PLL - * model. The hz variable is defined in the kernel build environment. It + * The following defines establish the engineering parameters of the + * phase-lock loop (PLL) model used in the kernel implementation. These + * parameters have been carefully chosen by analysis for good stability + * and wide dynamic range. + * + * The hz variable is defined in the kernel build environment. It * establishes the timer interrupt frequency, 100 Hz for the SunOS * kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1 - * kernel. The SHIFT_HZ define expresses the same value as the nearest - * power of two in order to avoid hardware multiply operations. + * kernel. SHIFT_HZ expresses the same value as the nearest power of two + * in order to avoid hardware multiply operations. + * + * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen + * for a slightly underdamped convergence characteristic. + * + * MAXTC establishes the maximum time constant of the PLL. With the + * SHIFT_KG and SHIFT_KF values given and a time constant range from + * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours, + * respectively. */ #define SHIFT_HZ 7 /* log2(hz) */ - -/* - * The SHIFT_KG and SHIFT_KF defines establish the damping of the PLL - * and are chosen by analysis for a slightly underdamped convergence - * characteristic. The MAXTC define establishes the maximum time - * constant of the PLL. With the parameters given and the minimum time - * constant of zero, the PLL will converge in about 15 minutes. - */ #define SHIFT_KG 6 /* phase factor (shift) */ #define SHIFT_KF 16 /* frequency factor (shift) */ #define MAXTC 6 /* maximum time constant (shift) */ /* + * The following defines establish the scaling of the various variables + * used by the PLL. They are chosen to allow the greatest precision + * possible without overflow of a 32-bit word. + * * SHIFT_SCALE defines the scaling (shift) of the time_phase variable, * which serves as a an extension to the low-order bits of the system - * clock variable time.tv_usec. SHIFT_UPDATE defines the scaling (shift) - * of the time_offset variable, which represents the current time offset - * with respect to standard time. SHIFT_USEC defines the scaling (shift) - * of the time_freq and time_tolerance variables, which represent the - * current frequency offset and frequency tolerance. FINEUSEC is 1 us in - * SHIFT_UPDATE units of the time_phase variable. + * clock variable time.tv_usec. + * + * SHIFT_UPDATE defines the scaling (shift) of the time_offset variable, + * which represents the current time offset with respect to standard + * time. + * + * SHIFT_USEC defines the scaling (shift) of the time_freq and + * time_tolerance variables, which represent the current frequency + * offset and maximum frequency tolerance. + * + * FINEUSEC is 1 us in SHIFT_UPDATE units of the time_phase variable. */ #define SHIFT_SCALE 23 /* phase scale (shift) */ #define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */ #define SHIFT_USEC 16 /* frequency offset scale (shift) */ -#define FINEUSEC (1 << SHIFT_SCALE) /* 1 us in phase units */ +#define FINEUSEC (1L << SHIFT_SCALE) /* 1 us in phase units */ + +/* + * The following defines establish the performance envelope of the PLL. + * They insure it operates within predefined limits, in order to satisfy + * correctness assertions. An excursion which exceeds these bounds is + * clamped to the bound and operation proceeds accordingly. In practice, + * this can occur only if something has failed or is operating out of + * tolerance, but otherwise the PLL continues to operate in a stable + * mode. + * + * MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as + * defined in the NTP specification. CLOCK.MAX establishes the maximum + * time offset allowed before the system time is reset, rather than + * incrementally adjusted. Here, the maximum offset is clamped to + * MAXPHASE only in order to prevent overflow errors due to defective + * protocol implementations. + * + * MAXFREQ is the maximum frequency tolerance of the CPU clock + * oscillator plus the maximum slew rate allowed by the protocol. It + * should be set to at least the frequency tolerance of the oscillator + * plus 100 ppm for vernier frequency adjustments. If the kernel + * PPS discipline code is configured (PPS_SYNC), the oscillator time and + * frequency are disciplined to an external source, presumably with + * negligible time and frequency error relative to UTC, and MAXFREQ can + * be reduced. + * + * MAXTIME is the maximum jitter tolerance of the PPS signal if the + * kernel PPS discipline code is configured (PPS_SYNC). + * + * MINSEC and MAXSEC define the lower and upper bounds on the interval + * between protocol updates. + */ +#define MAXPHASE 128000L /* max phase error (us) */ +#ifdef PPS_SYNC +#define MAXFREQ (100L << SHIFT_USEC) /* max freq error (100 ppm) */ +#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */ +#else +#define MAXFREQ (200L << SHIFT_USEC) /* max freq error (200 ppm) */ +#endif /* PPS_SYNC */ +#define MINSEC 16L /* min interval between updates (s) */ +#define MAXSEC 1200L /* max interval between updates (s) */ + +#ifdef PPS_SYNC +/* + * The following defines are used only if a pulse-per-second (PPS) + * signal is available and connected via a modem control lead, such as + * produced by the optional ppsclock feature incorporated in the Sun + * asynch driver. They establish the design parameters of the frequency- + * lock loop used to discipline the CPU clock oscillator to the PPS + * signal. + * + * PPS_AVG is the averaging factor for the frequency loop, as well as + * the time and frequency dispersion. + * + * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum + * calibration intervals, respectively, in seconds as a power of two. + * + * PPS_VALID is the maximum interval before the PPS signal is considered + * invalid and protocol updates used directly instead. + * + * MAXGLITCH is the maximum interval before a time offset of more than + * MAXTIME is believed. + */ +#define PPS_AVG 2 /* pps averaging constant (shift) */ +#define PPS_SHIFT 2 /* min interval duration (s) (shift) */ +#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */ +#define PPS_VALID 120 /* pps signal watchdog max (s) */ +#define MAXGLITCH 30 /* pps signal glitch max (s) */ +#endif /* PPS_SYNC */ + +/* + * The following defines and structures define the user interface for + * the ntp_gettime() and ntp_adjtime() system calls. + * + * Control mode codes (timex.modes) + */ +#define MOD_OFFSET 0x0001 /* set time offset */ +#define MOD_FREQUENCY 0x0002 /* set frequency offset */ +#define MOD_MAXERROR 0x0004 /* set maximum time error */ +#define MOD_ESTERROR 0x0008 /* set estimated time error */ +#define MOD_STATUS 0x0010 /* set clock status bits */ +#define MOD_TIMECONST 0x0020 /* set pll time constant */ +#define MOD_CLKB 0x4000 /* set clock B */ +#define MOD_CLKA 0x8000 /* set clock A */ /* - * Mode codes (timex.mode) + * Status codes (timex.status) */ -#define ADJ_OFFSET 0x0001 /* time offset */ -#define ADJ_FREQUENCY 0x0002 /* frequency offset */ -#define ADJ_MAXERROR 0x0004 /* maximum time error */ -#define ADJ_ESTERROR 0x0008 /* estimated time error */ -#define ADJ_STATUS 0x0010 /* clock status */ -#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ + +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ + +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ + +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ + +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ + STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ /* - * Clock command/status codes (timex.status) + * Clock states (time_state) */ -#define TIME_OK 0 /* clock synchronized */ -#define TIME_INS 1 /* insert leap second */ -#define TIME_DEL 2 /* delete leap second */ +#define TIME_OK 0 /* no leap second warning */ +#define TIME_INS 1 /* insert leap second warning */ +#define TIME_DEL 2 /* delete leap second warning */ #define TIME_OOP 3 /* leap second in progress */ -#define TIME_BAD 4 /* kernel clock not synchronized */ -#define TIME_ERR 5 /* external clock not synchronized */ +#define TIME_WAIT 4 /* leap second has occured */ +#define TIME_ERROR 5 /* clock not synchronized */ + /* - * NTP user interface - used to read kernel clock values + * NTP user interface (ntp_gettime()) - used to read kernel clock values + * * Note: maximum error = NTP synch distance = dispersion + delay / 2; * estimated error = NTP dispersion. */ struct ntptimeval { - struct timeval time; /* current time */ - long maxerror; /* maximum error (us) */ - long esterror; /* estimated error (us) */ + struct timeval time; /* current time (ro) */ + LONG maxerror; /* maximum error (us) (ro) */ + LONG esterror; /* estimated error (us) (ro) */ }; /* - * NTP daemon interface - used to discipline kernel clock oscillator + * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock + * oscillator */ struct timex { - int mode; /* mode selector */ - long offset; /* time offset (us) */ - long frequency; /* frequency offset (scaled ppm) */ - long maxerror; /* maximum error (us) */ - long esterror; /* estimated error (us) */ - int status; /* clock command/status */ - long time_constant; /* pll time constant */ - long precision; /* clock precision (us) (read only) */ - long tolerance; /* clock frequency tolerance (scaled - * ppm) (read only) */ + unsigned int modes; /* clock mode bits (wo) */ + LONG offset; /* time offset (us) (rw) */ + LONG freq; /* frequency offset (scaled ppm) (rw) */ + LONG maxerror; /* maximum error (us) (rw) */ + LONG esterror; /* estimated error (us) (rw) */ + int status; /* clock status bits (rw) */ + LONG constant; /* pll time constant (rw) */ + LONG precision; /* clock precision (us) (ro) */ + LONG tolerance; /* clock frequency tolerance (scaled + * ppm) (ro) */ /* * The following read-only structure members are implemented * only if the PPS signal discipline is configured in the * kernel. */ - long ybar; /* frequency estimate (scaled ppm) */ - long disp; /* dispersion estimate (scaled ppm) */ - int shift; /* interval duration (s) (shift) */ - long calcnt; /* calibration intervals */ - long jitcnt; /* jitter limit exceeded */ - long discnt; /* dispersion limit exceeded */ + LONG ppsfreq; /* pps frequency (scaled ppm) (ro) */ + LONG jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + LONG stabil; /* pps stability (scaled ppm) (ro) */ + LONG jitcnt; /* jitter limit exceeded (ro) */ + LONG calcnt; /* calibration intervals (ro) */ + LONG errcnt; /* calibration errors (ro) */ + LONG stbcnt; /* stability limit exceeded (ro) */ }; diff --git a/usr.sbin/xntpd/include/ntpd.h b/usr.sbin/xntpd/include/ntpd.h index 590aaae..037e8cb 100644 --- a/usr.sbin/xntpd/include/ntpd.h +++ b/usr.sbin/xntpd/include/ntpd.h @@ -63,6 +63,9 @@ extern void input_handler P((l_fp *)); extern void io_clr_stats P((void)); extern void io_setbclient P((void)); extern void io_unsetbclient P((void)); +extern void io_multicast_add P((U_LONG)); +extern void io_multicast_del P((U_LONG)); + extern void sendpkt P((struct sockaddr_in *, struct interface *, struct pkt *, int)); #ifdef HAVE_SIGNALED_IO extern void wait_for_signal P((void)); @@ -102,10 +105,10 @@ extern void init_peer P((void)); extern struct peer *findexistingpeer P((struct sockaddr_in *, struct peer *)); extern struct peer *findpeer P((struct sockaddr_in *, struct interface *)); extern struct peer *findpeerbyassoc P((int)); -extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, int, int, int, U_LONG)); +extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, int, int, int, int, U_LONG)); extern void peer_all_reset P((void)); extern void peer_clr_stats P((void)); -extern struct peer *peer_config P((struct sockaddr_in *, struct interface *, int, int, int, int, U_LONG, int)); +extern struct peer *peer_config P((struct sockaddr_in *, struct interface *, int, int, int, int, int, int, U_LONG)); extern void peer_reset P((struct peer *)); extern int peer_unconfig P((struct sockaddr_in *, struct interface *)); extern void unpeer P((struct peer *)); @@ -131,7 +134,7 @@ extern void clock_select P((void)); extern void clock_combine P((struct peer **, int)); extern void fast_xmit P((struct recvbuf *, int, int)); extern void init_proto P((void)); -extern void proto_config P((int, LONG)); +extern void proto_config P((int, U_LONG)); extern void proto_clr_stats P((void)); #ifdef REFCLOCK |