diff options
Diffstat (limited to 'usr.sbin/xntpd/include')
29 files changed, 1171 insertions, 320 deletions
diff --git a/usr.sbin/xntpd/include/README b/usr.sbin/xntpd/include/README index 5127b70..73d0620 100644 --- a/usr.sbin/xntpd/include/README +++ b/usr.sbin/xntpd/include/README @@ -4,3 +4,18 @@ This directory contains the include files used by most programs in this distribution. The ./sys directory in this directory contains system header files used by the clock discipline and STREAMS modules in the ../kernel directory. + +Note that multicast support (MCAST define) requires the header file +/usr/include/netinet/in.h for the particular architecture to be in place. +This file is constructed during the installation process in older systems; +it is already in place for those machines that support multicast ex box. +The file in.h included in this distribution is for Suns; the files for +other systems can be found in the multicast distribtutions for each +architecture separately. + +If the precision-time kernel (KERNEL_PLL define) is configured, the +installation process requires the header file /usr/include/sys/timex.h +for the particular architecture to be in place. The file timex.h included +in this distribution is for Suns; the files for other systems can be +found in the kernel distributions available from the manufacturer's +representatives. diff --git a/usr.sbin/xntpd/include/in.h b/usr.sbin/xntpd/include/in.h new file mode 100644 index 0000000..abd404c --- /dev/null +++ b/usr.sbin/xntpd/include/in.h @@ -0,0 +1,256 @@ +/* @(#)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 + +/* + * 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/l_stdlib.h b/usr.sbin/xntpd/include/l_stdlib.h index e0b7c47..426dc48 100644 --- a/usr.sbin/xntpd/include/l_stdlib.h +++ b/usr.sbin/xntpd/include/l_stdlib.h @@ -80,6 +80,7 @@ extern int link P((const char *, const char *)); extern int fclose P((FILE *)); extern int fflush P((FILE *)); extern int fprintf P((FILE *, char *, ...)); +extern int fscanf P((FILE *, char *, ...)); extern int fputs P((char *, FILE *)); extern int fputc P((char, FILE *)); extern int fread P((char *, int, int, FILE *)); @@ -87,6 +88,7 @@ extern int printf P((char *, ...)); extern int setbuf P((FILE *, char *)); extern int setvbuf P((FILE *, char *, int, int)); extern int scanf P((char *, ...)); +extern int sscanf P((char *, char *, ...)); extern int vsprintf P((char *, char *, ...)); extern int _flsbuf P((int, FILE *)); extern int _filbuf P((FILE *)); @@ -151,7 +153,43 @@ extern int nlist P((char *, struct nlist *)); #endif /* SYS_SUNOS4 */ /* - * Unprototyped library functions for ULTRIX. + * Unprototyped library functions for DEC OSF/1 + */ +#ifdef SYS_DECOSF1 +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ +extern u_short htons P((u_short)); +extern u_short ntohs P((u_short)); +extern U_LONG htonl P((U_LONG)); +extern U_LONG ntohl P((U_LONG)); +#endif /* _MACHINE_ENDIAN_H_ */ + +/* +extern char * getpass P((char *)); +*/ +extern char * mktemp P((char *)); +#ifndef SYS_IX86OSF1 +extern int ioctl P((int, u_long, char *)); +extern void bzero P((char *, int)); +#endif + +#ifdef SOCK_DGRAM +extern int bind P((int, const struct sockaddr *, int)); +extern int connect P((int, const struct sockaddr *, int)); +extern int socket P((int, int, int)); +extern int sendto P((int, const void *, int, int, const struct sockaddr *, int)); +extern int setsockopt P((int, int, int, const void *, int)); +extern int recvfrom P((int, void *, int, int, struct sockaddr *, int *)); +#endif /* SOCK_STREAM */ + +#ifdef _ntp_select_h +extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); +#endif + +#endif /* DECOSF1 */ + +/* + * Unprototyped library functions for Ultrix */ #ifdef SYS_ULTRIX extern int close P((int)); @@ -162,7 +200,6 @@ extern char *mktemp P((char *)); extern int unlink P((const char *)); extern int link P((const char *, const char *)); -#if defined(LOG_DEBUG) extern void closelog P((void)); extern void syslog P((int, char *, ...)); #ifndef LOG_DAEMON @@ -170,7 +207,6 @@ extern void openlog P((char *, int)); #else extern void openlog P((char *, int, int)); #endif -#endif extern int setpriority P((int ,int ,int )); @@ -184,7 +220,9 @@ extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *)); #endif /* SOCK_STREAM */ #ifdef _TIME_H_ -extern int adjtime P((struct timeval *, struct timeval *)); +extern int gettimeofday P((struct timeval *, struct timezone *)); +extern int settimeofday P((struct timeval *, struct timezone *)); +extern int adjtime P((struct timeval *, struct timeval *)); extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); extern int setitimer P((int , struct itimerval *, struct itimerval *)); #endif /* _TIME_H_ */ @@ -193,6 +231,12 @@ extern int setitimer P((int , struct itimerval *, struct itimerval *)); extern int nlist P((char *, struct nlist *)); #endif +#ifndef bzero /* XXX macro prototyping clash */ +extern void bzero P((char *, int)); +extern int bcmp P((char *, char *, int)); +extern void bcopy P((char *, char *, int)); +#endif + #ifndef NTP_POSIX_SOURCE extern int atoi P((char *)); extern void bzero P((char *, int)); @@ -204,15 +248,17 @@ extern int getdtablesize P((void)); extern int ran P((void)); extern int rand P((void)); extern void srand P((unsigned int)); -#if defined(_STDIO_H_) -extern int setlinebuf P((FILE *)); -#endif #ifdef _TIME_H_ extern int gettimeofday P((struct timeval *, struct timezone *)); +extern int settimeofday P((struct timeval *, struct timezone *)); +#endif #endif + +#ifdef _RESOURCE_H_ +extern int getrusage P((int, struct rusage *)); #endif -#endif /* SYS_ULTIRX */ +#endif /* SYS_ULTRIX */ #if defined(__convex__) extern char * getpass P((char *)); @@ -230,5 +276,9 @@ extern char * getpass P((char *)); extern char * getpass P((char *)); #endif /* SYS_DOMAINOS */ +#ifdef SYS_BSD +#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) +#endif + #endif /* l_stdlib_h */ diff --git a/usr.sbin/xntpd/include/md5.h b/usr.sbin/xntpd/include/md5.h index c13f639..82b43e1 100644 --- a/usr.sbin/xntpd/include/md5.h +++ b/usr.sbin/xntpd/include/md5.h @@ -1,4 +1,4 @@ -/* md5.h,v 3.1 1993/07/06 01:06:44 jbj Exp +/* *********************************************************************** ** md5.h -- header file for implementation of MD5 ** ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** diff --git a/usr.sbin/xntpd/include/mx4200.h b/usr.sbin/xntpd/include/mx4200.h index 5a9e496..13058de 100644 --- a/usr.sbin/xntpd/include/mx4200.h +++ b/usr.sbin/xntpd/include/mx4200.h @@ -1,5 +1,3 @@ -/* @(#) mx4200.h,v 3.1 1993/07/06 01:06:46 jbj Exp */ - /* records transmitted from extern CDU to MX 4200 */ #define PMVXG_S_INITMODEA 0 /* initialization/mode part A */ diff --git a/usr.sbin/xntpd/include/ntp.h b/usr.sbin/xntpd/include/ntp.h index 01bfa16..733f2e7 100644 --- a/usr.sbin/xntpd/include/ntp.h +++ b/usr.sbin/xntpd/include/ntp.h @@ -1,4 +1,4 @@ -/* ntp.h,v 3.1 1993/07/06 01:06:47 jbj Exp +/* * ntp.h - NTP definitions for the masses */ @@ -32,18 +32,20 @@ typedef signed char s_char; #define NTP_MAXSKEW 1 /* 1 sec, skew after NTP_MAXAGE w/o updates */ #define NTP_SKEWINC 49170 /* skew increment for clock updates (l_f) */ #define NTP_SKEWFACTOR 16 /* approximation of factor for peer calcs */ -#define NTP_MAXDISTANCE (1*FP_SECOND) /* max. rootdelay for synchr. */ -#define NTP_MINDPOLL 6 /* default min poll (64 sec) */ -#define NTP_MINPOLL 4 /* absolute min poll (16 sec) */ -#define NTP_MAXPOLL 10 /* actually 1<<10, or 1024 sec */ +#define NTP_MAXDISTANCE (1 * FP_SECOND) /* max. rootdelay for synchr. */ +#define NTP_MINDPOLL 6 /* log2 default min poll interval (64 s) */ +#define NTP_MAXDPOLL 10 /* log2 default max poll interval (~17 m) */ +#define NTP_MINPOLL 4 /* log2 min poll interval (16 s) */ +#define NTP_MAXPOLL 14 /* log2 max poll interval (~4.5 h) */ #define NTP_MINCLOCK 3 /* minimum for outlyer detection */ #define NTP_MAXCLOCK 10 /* maximum select list size */ -#define NTP_MINDISPERSE 0x28f /* 0.01 sec in fp format */ -#define NTP_MAXDISPERSE (16*FP_SECOND) /* maximum dispersion (fp 16) */ -#define NTP_DISPFACTOR 20 /* MAXDISPERSE as a shift */ +#define NTP_MINDISPERSE (FP_SECOND / 100) /* min dispersion (u_fp 10 ms) */ +#define NTP_MAXDISPERSE (FP_SECOND * 16) /* max dispersion (u_fp 16 s) */ +#define NTP_DISPFACTOR 20 /* MAXDISPERSE as a shift (u_fp 16 s) */ #define NTP_WINDOW 8 /* reachability register size */ #define NTP_SHIFT 8 /* 8 suitable for crystal time base */ #define NTP_MAXKEY 65535 /* maximum authentication key number */ +#define NTP_MAXD 3 /* log2 estimated error averaging factor */ /* * Loop filter parameters. See section 5.1 of the specification. @@ -62,27 +64,23 @@ typedef signed char s_char; #define CLOCK_DSCALE 20 /* skew reg. scale: unit is 2**-20 ~= 1 ppm */ #define CLOCK_FREQ 16 /* log2 frequency weight (65536) */ #define CLOCK_PHASE 6 /* log2 phase weight (64) */ -#define CLOCK_WEIGHTTC 5 /* log2 time constant weight (32) */ -#define CLOCK_HOLDTC 128 /* time constant hold (sec) */ +#define CLOCK_LIMIT 30 /* time constant adjust threshold */ +#define CLOCK_G 2 /* log2 frequency averaging factor */ +#define CLOCK_MAXSEC 800 /* max update interval for pll */ -#define CLOCK_MAX_F 0x20c49ba6 /* 128 ms, in time stamp format */ -#define CLOCK_MAX_I 0x0 /* both fractional and integral parts */ +#define CLOCK_MAX_FP 0x000020c5 /* max clock offset (s_fp 128 ms) */ +#define CLOCK_MAX_F 0x20c49ba6 /* max clock offset (l_fp 128 ms) */ +#define CLOCK_MAX_I 0x00000000 /* both fractional and integral parts */ #define CLOCK_WAYTOOBIG 1000 /* if clock 1000 sec off, forget it */ /* - * Unspecified default. sys.precision defaults to -6 unless otherwise - * adjusted. - */ -#define DEFAULT_SYS_PRECISION (-6) - -/* * Event timers are actually implemented as a sorted queue of expiry * times. The queue is slotted, with each slot holding timers which * expire in a 2**(NTP_MINPOLL-1) (8) second period. The timers in * each slot are sorted by increasing expiry time. The number of - * slots is 2**(NTP_MAXPOLL-(NTP_MINPOLL-1)), or 128, to cover a time - * period of 2**NTP_MAXPOLL (1024) seconds into the future before + * slots is 2**(NTP_MAXPOLL-(NTP_MINPOLL-1)), or 512, to cover a time + * period of 2**NTP_MAXPOLL (16384) seconds into the future before * wrapping. */ #define EVENT_TIMEOUT CLOCK_ADJ @@ -92,7 +90,7 @@ struct event { struct event *prev; /* previous in chain */ struct peer *peer; /* peer this counter belongs to */ void (*event_handler)(); /* routine to call to handle event */ - U_LONG event_time; /* expiry time of counter */ + u_long event_time; /* expiry time of counter */ }; #define TIMER_SLOTTIME (1<<(NTP_MINPOLL-1)) @@ -162,9 +160,10 @@ struct interface { struct sockaddr_in mask; /* interface mask */ char name[8]; /* name of interface */ int flags; /* interface flags */ - LONG received; /* number of incoming packets */ - LONG sent; /* number of outgoing packets */ - LONG notsent; /* number of send failures */ + int last_ttl; /* last TTL specified */ + long received; /* number of incoming packets */ + long sent; /* number of outgoing packets */ + long notsent; /* number of send failures */ }; /* @@ -200,6 +199,7 @@ struct peer { struct peer *ass_next; /* link pointer in associd hash */ struct sockaddr_in srcadr; /* address of remote host */ struct interface *dstadr; /* pointer to address on local host */ + struct refclockproc *procptr; /* pointer to reference clock sutuff */ u_char leap; /* leap indicator */ u_char hmode; /* association mode with this peer */ u_char pmode; /* peer's association mode */ @@ -211,6 +211,7 @@ struct peer { u_char maxpoll; /* max local host poll interval */ u_char version; /* version number */ u_char flags; /* peer flags */ + u_char cast_flags; /* flags MDF_?CAST */ u_char flash; /* peer flashers (for maint) */ u_char refclktype; /* reference clock type */ u_char refclkunit; /* reference clock unit number */ @@ -242,33 +243,30 @@ struct peer { u_char filter_order[NTP_SHIFT]; /* we keep the filter sorted here */ #define end_clear_to_zero filter_order[0] u_fp filter_error[NTP_SHIFT]; /* error part of shift register */ - LONG update; /* base sys_clock for skew calc.s */ + long update; /* base sys_clock for skew calc.s */ s_fp delay; /* filter estimated delay */ u_fp dispersion; /* filter estimated dispersion */ l_fp offset; /* filter estimated clock offset */ s_fp soffset; /* fp version of above */ s_fp synch; /* synch distance from above */ u_fp selectdisp; /* select dispersion */ - U_LONG estbdelay; /* broadcast delay, as a ts fraction */ + s_fp estbdelay; /* broadcast offset */ /* * statistic counters */ - U_LONG timereset; /* time stat counters were reset */ - U_LONG sent; /* number of updates sent */ - U_LONG received; /* number of frames received */ - U_LONG timereceived; /* last time a frame received */ - U_LONG timereachable; /* last reachable/unreachable event */ - U_LONG processed; /* processed by the protocol */ - U_LONG badauth; /* bad credentials detected */ - U_LONG bogusorg; /* rejected due to bogus origin */ - U_LONG bogusrec; /* rejected due to bogus receive */ - U_LONG bogusdelay; /* rejected due to bogus delay */ - U_LONG disttoolarge; /* rejected due to large distance */ - U_LONG oldpkt; /* rejected as duplicate packet */ - U_LONG seldisptoolarge; /* too much dispersion for selection */ - U_LONG selbroken; /* broken NTP detected in selection */ - U_LONG seltooold; /* too LONG since sync in selection */ + u_long timereset; /* time stat counters were reset */ + u_long sent; /* number of updates sent */ + u_long received; /* number of frames received */ + u_long timereceived; /* last time a frame received */ + u_long timereachable; /* last reachable/unreachable event */ + u_long processed; /* processed by the protocol */ + u_long badauth; /* bad credentials detected */ + u_long bogusorg; /* rejected due to bogus origin */ + u_long oldpkt; /* rejected as duplicate packet */ + u_long seldisptoolarge; /* too much dispersion for selection */ + u_long selbroken; /* broken NTP detected in selection */ + u_long seltooold; /* too long since sync in selection */ u_char candidate; /* position after candidate selection */ u_char select; /* position at end of falseticker sel */ u_char was_sane; /* set to 1 if it passed sanity check */ @@ -298,7 +296,7 @@ struct peer { #define MODE_PRIVATE 7 /* implementation defined function */ #define MODE_BCLIENT 8 /* a pseudo mode, used internally */ - +#define MODE_MCLIENT 9 /* multicast mode, used internally */ /* * Values for peer.stratum, sys_stratum @@ -315,8 +313,8 @@ struct peer { */ #define FLAG_CONFIG 0x1 /* association was configured */ #define FLAG_AUTHENABLE 0x2 /* this guy needs authentication */ -#define FLAG_UNUSED 0x4 /* (not used) */ -#define FLAG_DEFBDELAY 0x8 /* using default bdelay */ +#define FLAG_MCAST1 0x4 /* multicast client/server mode */ +#define FLAG_MCAST2 0x8 /* multicast client mode */ #define FLAG_AUTHENTIC 0x10 /* last message was authentic */ #define FLAG_REFCLOCK 0x20 /* this is actually a reference clock */ #define FLAG_SYSPEER 0x40 /* this is one of the selected peers */ @@ -334,13 +332,13 @@ struct peer { /* * Reference clock identifiers (for pps signal) */ -#define PPSREFID "PPS " /* used when pps controls stratum > 1 */ +#define PPSREFID (U_LONG)"PPS " /* used when pps controls stratum > 1 */ /* * Reference clock types. Added as necessary. */ #define REFCLK_NONE 0 /* unknown or missing */ -#define REFCLK_LOCALCLOCK 1 /* external (e.g., ACTS) */ +#define REFCLK_LOCALCLOCK 1 /* external (e.g., lockclock) */ #define REFCLK_GPS_TRAK 2 /* TRAK 8810 GPS Receiver */ #define REFCLK_WWV_PST 3 /* PST/Traconex 1020 WWV/H */ #define REFCLK_WWVB_SPECTRACOM 4 /* Spectracom 8170/Netclock WWVB */ @@ -353,8 +351,16 @@ struct peer { #define REFCLK_OMEGA_TRUETIME 11 /* TrueTime OM-DC OMEGA */ #define REFCLK_IRIG_TPRO 12 /* KSI/Odetics TPRO-S IRIG */ #define REFCLK_ATOM_LEITCH 13 /* Leitch CSD 5300 Master Clock */ -#define REFCLK_MSF_EES 14 /* MSF EES M201, UK */ -#define REFCLK_GPSTM_TRUETIME 15 /* TrueTime GPS/TM-TMD */ +#define REFCLK_MSF_EES 14 /* EES M201 MSF Receiver */ +#define REFCLK_GPSTM_TRUETIME 15 /* 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_WWV_HEATH 19 /* Heath GC1000 WWV/WWVH Receiver */ +#define REFCLK_GPS_NMEA 20 /* NMEA based GPS clock */ +#define REFCLK_GPS_MOTO 21 /* Motorola GPS clock */ +#define REFCLK_ATOM_PPS 22 /* 1-PPS Clock Discipline */ +#define REFCLK_MAX 24 /* maximum index (room to expand) */ /* * We tell reference clocks from real peers by giving the reference @@ -474,6 +480,7 @@ struct recvbuf { #define recv_srcclock X_from_where.X_recv_srcclock struct sockaddr_in srcadr; /* where packet came from */ struct interface *dstadr; /* interface datagram arrived thru */ + int fd; /* fd on which it was received */ l_fp recv_time; /* time of arrival */ void (*receiver)(); /* routine to receive buffer */ int recv_length; /* number of octets received */ @@ -576,6 +583,10 @@ struct recvbuf { #define PROTO_AUTHDELAY 5 #define PROTO_MULTICAST_ADD 6 #define PROTO_MULTICAST_DEL 7 +#define PROTO_PLL 8 +#define PROTO_PPS 9 +#define PROTO_MONITOR 10 +#define PROTO_FILEGEN 11 /* * Configuration items for the loop filter @@ -596,29 +607,38 @@ struct recvbuf { /* * Default parameters. We use these in the absense of something better. */ -#define DEFPRECISION (-5) /* conservatively low */ -#define DEFBROADDELAY (0x020c49ba) /* 8 ms. This is round trip delay */ +#define DEFPRECISION (-7) /* default precision (~10 ms) */ +#define DEFBROADDELAY 0x00000100 /* default broadcast offset */ + /* (~4 ms as s_fp) */ +#define DEFAUTHDELAY 0x00080000 /* default authentcation delay */ + /* (~100 us as l_fp.u_f) */ #define INADDR_NTP 0xe0000101 /* NTP multicast address 224.0.1.1 */ /* * Structure used optionally for monitoring when this is turned on. */ struct mon_data { struct mon_data *hash_next; /* next structure in hash list */ - struct mon_data *hash_prev; /* previous structure in hash list */ struct mon_data *mru_next; /* next structure in MRU list */ struct mon_data *mru_prev; /* previous structure in MRU list */ struct mon_data *fifo_next; /* next structure in FIFO list */ struct mon_data *fifo_prev; /* previous structure in FIFO list */ - U_LONG lastdrop; /* last time dropped due to RES_LIMIT*/ - U_LONG lasttime; /* last time data updated */ - U_LONG firsttime; /* time structure initialized */ - U_LONG count; /* count we have seen */ + u_long lastdrop; /* last time dropped due to RES_LIMIT*/ + u_long lasttime; /* last time data updated */ + u_long firsttime; /* time structure initialized */ + u_long count; /* count we have seen */ U_LONG rmtadr; /* address of remote host */ + struct interface *interface; /* interface on which this arrived */ u_short rmtport; /* remote port last came from */ u_char mode; /* mode of incoming packet */ u_char version; /* version of incoming packet */ + u_char cast_flags; /* flags MDF_?CAST */ }; +#define MDF_UCAST 1 /* unicast packet */ +#define MDF_MCAST 2 /* multicast packet */ +#define MDF_BCAST 4 /* broadcast packet */ +#define MDF_LCAST 8 /* local packet */ + /* * Values used with mon_enabled to indicate reason for enabling monitoring */ @@ -632,7 +652,7 @@ struct restrictlist { struct restrictlist *next; /* link to next entry */ U_LONG addr; /* host address (host byte order) */ U_LONG mask; /* mask for address (host byte order) */ - U_LONG count; /* number of packets matched */ + u_long count; /* number of packets matched */ u_short flags; /* accesslist flags */ u_short mflags; /* match flags */ }; diff --git a/usr.sbin/xntpd/include/ntp_calendar.h b/usr.sbin/xntpd/include/ntp_calendar.h index fc12f0b..461aee4 100644 --- a/usr.sbin/xntpd/include/ntp_calendar.h +++ b/usr.sbin/xntpd/include/ntp_calendar.h @@ -1,4 +1,4 @@ -/* ntp_calendar.h,v 3.1 1993/07/06 01:06:48 jbj Exp +/* * ntp_calendar.h - definitions for the calendar time-of-day routine */ @@ -66,8 +66,8 @@ struct calendar { * STARTCYCLE22 seconds after the start of cycle 0. */ #define CYCLE22 (22) -#define STARTCYCLE22 (U_LONG)(0xa586b500) /* 2777068800 */ -#define MAR1988 (U_LONG)(STARTCYCLE22 + (U_LONG)MAR1900) +#define STARTCYCLE22 (u_long)(0xa586b500) /* 2777068800 */ +#define MAR1988 (u_long)(STARTCYCLE22 + (u_long)MAR1900) /* * The length of January + February in leap and non-leap years. @@ -75,6 +75,6 @@ struct calendar { #define JANFEBNOLEAP ((JAN+FEB) * SECSPERDAY) #define JANFEBLEAP ((JAN+FEBLEAP) * SECSPERDAY) -extern void caljulian P((U_LONG, struct calendar *)); -extern U_LONG caltontp P((const struct calendar *)); +extern void caljulian P((u_long, struct calendar *)); +extern u_long caltontp P((const struct calendar *)); diff --git a/usr.sbin/xntpd/include/ntp_control.h b/usr.sbin/xntpd/include/ntp_control.h index 1e19383..1124bb0 100644 --- a/usr.sbin/xntpd/include/ntp_control.h +++ b/usr.sbin/xntpd/include/ntp_control.h @@ -1,4 +1,4 @@ -/* ntp_control.h,v 3.1 1993/07/06 01:06:50 jbj Exp +/* * ntp_control.h - definitions related to NTP mode 6 control messages */ @@ -236,10 +236,10 @@ struct ntp_control { struct ctl_trap { struct sockaddr_in tr_addr; /* address of trap recipient */ struct interface *tr_localaddr; /* interface to send this through */ - U_LONG tr_settime; /* time trap was set */ - U_LONG tr_count; /* async messages sent to this guy */ - U_LONG tr_origtime; /* time trap was originally set */ - U_LONG tr_resets; /* count of resets for this trap */ + u_long tr_settime; /* time trap was set */ + u_long tr_count; /* async messages sent to this guy */ + u_long tr_origtime; /* time trap was originally set */ + u_long tr_resets; /* count of resets for this trap */ u_short tr_sequence; /* trap sequence id */ u_char tr_flags; /* trap flags */ u_char tr_version; /* version number of trapper */ diff --git a/usr.sbin/xntpd/include/ntp_datum.h b/usr.sbin/xntpd/include/ntp_datum.h new file mode 100644 index 0000000..2aa2cb7 --- /dev/null +++ b/usr.sbin/xntpd/include/ntp_datum.h @@ -0,0 +1,30 @@ +struct btfp_time /* Structure for reading 5 time words */ + /* in one ioctl(2) operation. */ +{ + unsigned short btfp_time[5]; /* Time words 0,1,2,3, and 4. (16bit)*/ +}; + +/***** Simple ioctl commands *****/ + +#define RUNLOCK _IO('X',19) /* Release Capture Lockout */ +#define RCR0 _IOR('X',22,unsigned int) /* Read control register */ +#define WCR0 _IOW('X',23,unsigned int) /* Write control register */ + +/***** Compound ioctl commands *****/ + +/* Read all 5 time words in one call. */ +#define READTIME _IOR('X',32,struct btfp_time) +#define VMEFD "/dev/btfp0" + + struct vmedate { /* structure returned by get_vmetime.c */ + unsigned short year; + unsigned short doy; + unsigned short hr; + unsigned short mn; + unsigned short sec; + unsigned long frac; + unsigned short status; + }; + +#define PRIO 120 /* set the realtime priority */ +#define NREGS 7 /* number of registers we will use */ diff --git a/usr.sbin/xntpd/include/ntp_filegen.h b/usr.sbin/xntpd/include/ntp_filegen.h index 7281d59..9e75bc6 100644 --- a/usr.sbin/xntpd/include/ntp_filegen.h +++ b/usr.sbin/xntpd/include/ntp_filegen.h @@ -1,5 +1,5 @@ /* - * ntp_filegen.h,v 3.7 1994/01/25 19:04:16 kardel Exp + * ntp_filegen.h,v 3.8 1994/05/30 09:48:53 kardel Exp * * definitions for NTP file generations support * @@ -40,12 +40,12 @@ typedef struct FILEGEN char *prefix; /* filename prefix and basename to be used*/ char *basename; /* for constructing filename of generation file */ /* WARNING: must be malloced !!! will be fed to free()*/ - U_LONG id; /* id of current generation */ + u_long id; /* id of current generation */ u_char type; /* type of file generation */ u_char flag; /* flags modifying processing of file generation */ } FILEGEN; -extern void filegen_setup P((FILEGEN *, U_LONG)); +extern void filegen_setup P((FILEGEN *, u_long)); extern void filegen_config P((FILEGEN *, char *, u_int, u_int)); extern FILEGEN *filegen_get P((char *)); extern void filegen_register P((char *, FILEGEN *)); diff --git a/usr.sbin/xntpd/include/ntp_fp.h b/usr.sbin/xntpd/include/ntp_fp.h index 3273060..ec657f7 100644 --- a/usr.sbin/xntpd/include/ntp_fp.h +++ b/usr.sbin/xntpd/include/ntp_fp.h @@ -1,4 +1,4 @@ -/* ntp_fp.h,v 3.1 1993/07/06 01:06:54 jbj Exp +/* * ntp_fp.h - definitions for NTP fixed point arithmetic */ @@ -10,7 +10,7 @@ /* * NTP uses two fixed point formats. The first (l_fp) is the "long" format - * and is 64 bits LONG with the decimal between bits 31 and 32. This + * and is 64 bits long with the decimal between bits 31 and 32. This * is used for time stamps in the NTP packet header (in network byte * order) and for internal computations of offsets (in local host byte * order). We use the same structure for both signed and unsigned values, @@ -103,13 +103,13 @@ typedef U_LONG u_fp; * Conversions between the two fixed point types */ #define MFPTOFP(x_i, x_f) (((x_i)<<16) | (((x_f)>>16)&0xffff)) -#define LFPTOFP(v) MFPTOFP((v)->l_ui, (v)->l_uf) +#define LFPTOFP(v) MFPTOFP((v)->l_i, (v)->l_f) #define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16) #define FPTOLFP(x, v) (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0) /* - * Primitive operations on LONG fixed point values. If these are + * Primitive operations on long fixed point values. If these are * reminiscent of assembler op codes it's only because some may * be replaced by inline assembler for particular machines someday. * These are the (kind of inefficient) run-anywhere versions. @@ -263,7 +263,7 @@ typedef U_LONG u_fp; ((a_i) == (b_i) && (a_f) == (b_f)) /* - * Operations on the LONG fp format + * Operations on the long fp format */ #define L_ADD(r, a) M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf) #define L_SUB(r, a) M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf) @@ -277,6 +277,7 @@ typedef U_LONG u_fp; #define L_CLR(v) ((v)->l_ui = (v)->l_uf = 0) #define L_ISNEG(v) (((v)->l_ui & 0x80000000) != 0) +#define L_ISZERO(v) ((v)->l_ui == 0 && (v)->l_uf == 0) #define L_ISHIS(a, b) ((a)->l_ui > (b)->l_ui || \ ((a)->l_ui == (b)->l_ui && (a)->l_uf >= (b)->l_uf)) #define L_ISGEQ(a, b) ((a)->l_i > (b)->l_i || \ @@ -284,7 +285,7 @@ typedef U_LONG u_fp; #define L_ISEQU(a, b) M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf) extern char * dofptoa P((u_fp, int, int, int)); -extern char * dolfptoa P((U_LONG, U_LONG, int, int, int)); +extern char * dolfptoa P((u_long, u_long, int, int, int)); extern int atolfp P((const char *, l_fp *)); extern int buftvtots P((const char *, l_fp *)); diff --git a/usr.sbin/xntpd/include/ntp_if.h b/usr.sbin/xntpd/include/ntp_if.h index 45a70c5..bc842fb 100644 --- a/usr.sbin/xntpd/include/ntp_if.h +++ b/usr.sbin/xntpd/include/ntp_if.h @@ -12,7 +12,7 @@ #include <time.h> #endif -#if defined(SOLARIS)&&!defined(bsd) +#if (defined(SOLARIS) && !defined(bsd)) || defined(SYS_SUNOS4) #include <sys/sockio.h> #endif diff --git a/usr.sbin/xntpd/include/ntp_machine.h b/usr.sbin/xntpd/include/ntp_machine.h index abc0acb..91c18dc 100644 --- a/usr.sbin/xntpd/include/ntp_machine.h +++ b/usr.sbin/xntpd/include/ntp_machine.h @@ -1,4 +1,4 @@ -/* ntp_machine.h,v 3.1 1993/07/06 01:06:49 jbj Exp +/* * Collect all machine dependent idiosyncrasies in one place. */ @@ -180,6 +180,7 @@ in this file. #define RETSIGTYPE void #define NTP_SYSCALL_GET 132 #define NTP_SYSCALL_ADJ 147 +#define HAVE_MODEM_CONTROL #ifndef STR_SYSTEM #define STR_SYSTEM "UNIX/SunOS 4.x" #endif @@ -218,6 +219,7 @@ in this file. #define HAVE_ATT_SETPGRP #define HAVE_ATT_NICE #define UDP_WILDCARD_DELIVERY +#define HAVE_MODEM_CONTROL #ifndef STR_SYSTEM #define STR_SYSTEM "UNIX/Solaris 2.x" #endif @@ -276,6 +278,7 @@ in this file. #define HAVE_BSD_NICE #define RETSIGTYPE void #define NTP_SYSCALLS_STD +#define HAVE_MODEM_CONTROL #ifndef STR_SYSTEM #define STR_SYSTEM "UNIX/Ultrix" #endif @@ -364,6 +367,19 @@ in this file. #endif /* + * 4.4 bsd + */ +#if defined(SYS_44BSD) +#define HAVE_SIGNALED_IO +#define HAVE_LIBKVM +#define NTP_POSIX_SOURCE +#define HAVE_BSD_NICE +#ifndef STR_SYSTEM +#define STR_SYSTEM "UNIX/4.4BSD" +#endif +#endif + +/* * Linux */ #if defined(SYS_LINUX) @@ -391,7 +407,7 @@ in this file. #define NTP_POSIX_SOURCE #define HAVE_BSD_NICE #ifndef STR_SYSTEM -#define STR_SYSTEM "UNIX/*BSD" +#define STR_SYSTEM "UNIX/\052BSD" #endif #endif @@ -404,12 +420,42 @@ in this file. #define NTP_POSIX_SOURCE #define NTP_SYSCALLS_STD #define HAVE_BSD_NICE +#define HAVE_MODEM_CONTROL #ifndef STR_SYSTEM #define STR_SYSTEM "UNIX/DECOSF1" #endif #endif /* + * Intel x86 OSF/1 + */ +#if defined(SYS_IX86OSF1) +#define HAVE_SIGNALED_IO +#define HAVE_READKMEM +#define NTP_POSIX_SOURCE +#define NTP_SYSCALLS_STD +#define HAVE_BSD_NICE +#define HAVE_MODEM_CONTROL +#define SYS_DECOSF1 +#ifndef STR_SYSTEM +#define STR_SYSTEM "UNIX/IX86OSF1" +#endif +#endif + +/* + * ISI + */ +#if defined(SYS_BSD) +#define NO_SIGNED_CHAR_DECL +#define HAVE_BSD_NICE +#define HAVE_BSD_TTYS +#define HAVE_READKMEM +#define HAVE_SIGNALED_IO +#define NEED_VSPRINTF +#undef NTP_POSIX_SOURCE +#endif + +/* * I386 * XXX - what OS? */ diff --git a/usr.sbin/xntpd/include/ntp_refclock.h b/usr.sbin/xntpd/include/ntp_refclock.h index cc026f5..fcc1200 100644 --- a/usr.sbin/xntpd/include/ntp_refclock.h +++ b/usr.sbin/xntpd/include/ntp_refclock.h @@ -4,40 +4,48 @@ #include "ntp_types.h" +#if defined(HAVE_BSD_TTYS) +#include <sgtty.h> +#endif /* HAVE_BSD_TTYS */ + +#if defined(HAVE_SYSV_TTYS) +#include <termio.h> +#endif /* HAVE_SYSV_TTYS */ + +#if defined(HAVE_TERMIOS) +#include <termios.h> +#endif + +#if defined(STREAM) +#include <stropts.h> +#if defined(CLK) +#include <sys/clkdefs.h> +#endif /* CLK */ +#endif /* STREAM */ + #if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS) #define BSD_TTYS #endif /* SYSV_TTYS STREAM BSD_TTYS */ /* * Macros to determine the clock type and unit numbers from a - * 127.127.t.u address. + * 127.127.t.u address */ #define REFCLOCKTYPE(srcadr) ((SRCADR(srcadr) >> 8) & 0xff) #define REFCLOCKUNIT(srcadr) (SRCADR(srcadr) & 0xff) /* - * list of reference clock names - * see lib/clocktypes.c (must also agree with xntpd/refclock_conf.c) + * List of reference clock names and descriptions. These must agree with + * lib/clocktypes.c and xntpd/refclock_conf.c. */ struct clktype { int code; /* driver "major" number */ - char *clocktype; /* LONG description */ + char *clocktype; /* long description */ char *abbrev; /* short description */ }; /* - * Definitions for default values - */ -#define noentry 0 /* flag for null routine */ - -/* - * Definitions for flags - */ -#define NOFLAGS 0 -#define REF_FLAG_BCLIENT 0x1 /* clock prefers to run as a bclient */ - -/* - * Flag values + * Configuration flag values */ #define CLK_HAVETIME1 0x1 #define CLK_HAVETIME2 0x2 @@ -58,25 +66,25 @@ struct clktype { * Structure for returning clock status */ struct refclockstat { - u_char type; - u_char flags; - u_char haveflags; - u_short lencode; /* ahem, we do have some longer "time-codes" */ - char *lastcode; - U_LONG polls; - U_LONG noresponse; - U_LONG badformat; - U_LONG baddata; - U_LONG timereset; - char *clockdesc; /* description of clock, in ASCII */ - l_fp fudgetime1; - l_fp fudgetime2; - LONG fudgeval1; - LONG fudgeval2; - u_char currentstatus; - u_char lastevent; - u_char unused; - struct ctl_var *kv_list; /* additional variables */ + u_char type; /* clock type */ + u_char flags; /* clock flags */ + u_char haveflags; /* bit array of valid flags */ + u_char lencode; /* length of last timecode */ + char *lastcode; /* last timecode received */ + U_LONG polls; /* transmit polls */ + U_LONG noresponse; /* no response to poll */ + U_LONG badformat; /* bad format timecode received */ + U_LONG baddata; /* invalid data timecode received */ + U_LONG timereset; /* driver resets */ + char *clockdesc; /* ASCII description */ + l_fp fudgetime1; /* configure fudge time1 */ + l_fp fudgetime2; /* configure fudge time2 */ + LONG fudgeval1; /* configure fudge value1 */ + LONG fudgeval2; /* configure fudge value2 */ + u_char currentstatus; /* clock status */ + u_char lastevent; /* last exception event */ + u_char unused; /* spare */ + struct ctl_var *kv_list; /* additional variables */ }; /* @@ -84,59 +92,133 @@ struct refclockstat { * the reference clock drivers and the I/O module. */ struct refclockio { - struct refclockio *next; - void (*clock_recv)(); - caddr_t srcclock; /* pointer to clock structure */ - int datalen; - int fd; - U_LONG recvcount; + struct refclockio *next; /* link to next structure */ + void (*clock_recv)();/* completion routine */ + caddr_t srcclock; /* pointer to clock structure */ + int datalen; /* lenth of data */ + int fd; /* file descriptor */ + u_long recvcount; /* count of receive completions */ }; +/* + * Structure for returning debugging info + */ +#define NCLKBUGVALUES 16 +#define NCLKBUGTIMES 32 + +struct refclockbug { + u_char nvalues; /* values following */ + u_char ntimes; /* times following */ + u_short svalues; /* values format sign array */ + U_LONG stimes; /* times format sign array */ + U_LONG values[NCLKBUGVALUES]; /* real values */ + l_fp times[NCLKBUGTIMES]; /* real times */ +}; /* - * Sizes of things we return for debugging + * Structure interface between the reference clock support + * ntp_refclock.c and the driver utility routines */ -#define NCLKBUGVALUES 16 -#define NCLKBUGTIMES 32 +#define MAXSTAGE 64 /* max stages in shift register */ +#define BMAX 128 /* max timecode length */ +#define GMT 0 /* I hope nobody sees this */ +#define MAXDIAL 20 /* max length of modem dial strings */ /* - * Structure for returning debugging info + * Line discipline flags. These require line discipline or streams + * modules to be installed/loaded in the kernel. If specified, but not + * installed, the code runs as if unspecified. */ -struct refclockbug { - u_char nvalues; - u_char ntimes; - u_short svalues; - U_LONG stimes; - U_LONG values[NCLKBUGVALUES]; - l_fp times[NCLKBUGTIMES]; +#define LDISC_STD 0x0 /* standard */ +#define LDISC_CLK 0x1 /* tty_clk \n intercept */ +#define LDISC_CLKPPS 0x2 /* tty_clk \377 intercept */ +#define LDISC_ACTS 0x4 /* tty_clk #* intercept */ +#define LDISC_CHU 0x8 /* tty_chu */ +#define LDISC_PPS 0x10 /* ppsclock */ + +struct refclockproc { + struct refclockio io; /* I/O handler structure */ + caddr_t unitptr; /* pointer to unit structure */ + u_long lasttime; /* last clock update time */ + u_char leap; /* leap/synchronization code */ + u_char currentstatus; /* clock status */ + u_char lastevent; /* last exception event */ + u_char type; /* clock type */ + char *clockdesc; /* clock description */ + char lastcode[BMAX]; /* last timecode received */ + u_char lencode; /* length of last timecode */ + + u_int year; /* year of eternity */ + u_int day; /* day of year */ + u_int hour; /* hour of day */ + u_int minute; /* minute of hour */ + u_int second; /* second of minute */ + u_int msec; /* millisecond of second */ + u_long usec; /* microsecond of second (alt) */ + u_int nstages; /* median filter stages */ + u_long yearstart; /* beginning of year */ + u_long coderecv; /* sample counter */ + l_fp lastref; /* last reference timestamp */ + l_fp lastrec; /* last local timestamp */ + l_fp offset; /* median offset */ + u_fp dispersion; /* sample dispersion */ + l_fp filter[MAXSTAGE]; /* median filter */ + + /* + * Configuration data + */ + l_fp fudgetime1; /* fudge time1 */ + l_fp fudgetime2; /* fudge time2 */ + u_long refid; /* reference identifier */ + u_long sloppyclockflag; /* fudge flags */ + + /* + * Status tallies + */ + u_long timestarted; /* time we started this */ + u_long polls; /* polls sent */ + u_long noreply; /* no replies to polls */ + u_long badformat; /* bad format reply */ + u_long baddata; /* bad data reply */ }; /* - * Struct refclock provides the interface between the reference - * clock support and particular clock drivers. There are entries - * to open and close a unit, optional values to specify the - * timer interval for calls to the transmit procedure and to - * specify a polling routine to be called when the transmit - * procedure executes. There is an entry which is called when - * the transmit routine is about to shift zeroes into the - * filter register, and entries for stuffing fudge factors into - * the driver and getting statistics from it. + * Structure interface between the reference clock support + * ntp_refclock.c and particular clock drivers. This must agree with the + * structure defined in the driver. */ +#define noentry 0 /* flag for null routine */ +#define NOFLAGS 0 /* flag for null flags */ + struct refclock { - int (*clock_start) P((u_int, struct peer *)); /* start a clock unit */ - void (*clock_shutdown) P((int)); /* shut a clock down */ - void (*clock_poll) P((int, struct peer *)); /* called from the xmit routine */ - void (*clock_control) P((u_int, struct refclockstat *, struct refclockstat *)); /* set fudge values, return stats */ - void (*clock_init) P((void)); /* initialize driver data at startup */ - void (*clock_buginfo) P((int, struct refclockbug *)); /* get clock dependent bug info */ - U_LONG clock_flags; /* flag values */ + int (*clock_start) P((int, struct peer *)); + void (*clock_shutdown) P((int, struct peer *)); + void (*clock_poll) P((int, struct peer *)); + void (*clock_control) P((int, struct refclockstat *, + struct refclockstat *)); + void (*clock_init) P((void)); + void (*clock_buginfo) P((int, struct refclockbug *)); + u_long clock_flags; }; +/* + * Function prototypes + */ extern int io_addclock_simple P((struct refclockio *)); extern int io_addclock P((struct refclockio *)); extern void io_closeclock P((struct refclockio *)); -#ifdef REFCLOCK -extern void refclock_buginfo P((struct sockaddr_in *, struct refclockbug *)); -extern void refclock_control P((struct sockaddr_in *, struct refclockstat *, struct refclockstat *)); -#endif /* REFCLOCK */ +#ifdef REFCLOCK +extern void refclock_buginfo P((struct sockaddr_in *, + struct refclockbug *)); +extern void refclock_control P((struct sockaddr_in *, + struct refclockstat *, + struct refclockstat *)); +extern int refclock_open P((char *, int, int)); +extern void refclock_transmit P((struct peer *)); +extern int refclock_ioctl P((int, int)); +extern int refclock_process P((struct refclockproc *, int, int)); +extern void refclock_report P((struct peer *, u_char)); +extern int refclock_gtlin P((struct recvbuf *, char *, int, + l_fp *)); +#endif /* REFCLOCK */ diff --git a/usr.sbin/xntpd/include/ntp_request.h b/usr.sbin/xntpd/include/ntp_request.h index b1a9472..698e20a 100644 --- a/usr.sbin/xntpd/include/ntp_request.h +++ b/usr.sbin/xntpd/include/ntp_request.h @@ -1,4 +1,4 @@ -/* ntp_request.h,v 3.1 1993/07/06 01:06:57 jbj Exp +/* * ntp_request.h - definitions for the xntpd remote query facility */ @@ -207,7 +207,6 @@ struct resp_pkt { * the receive time stamp by no more than 10 seconds. */ #define INFO_TS_MAXSKEW_UI 10 -#define INFO_TS_MAXSKEW_UF 0 /* * Universal request codes go here. There aren't any. @@ -257,23 +256,33 @@ struct resp_pkt { #define REQ_GET_KERNEL 38 /* get kernel pll/pps information */ #define REQ_GET_CLKBUGINFO 39 /* get clock debugging info */ #define REQ_SET_PRECISION 41 /* set clock precision */ - +#define REQ_MON_GETLIST_1 42 /* return data collected by monitor v1*/ /* - * Flags in the information returns + * Flags in the peer information returns */ #define INFO_FLAG_CONFIG 0x1 #define INFO_FLAG_SYSPEER 0x2 -#define INFO_FLAG_MINPOLL 0x4 +#define INFO_FLAG_UNUSED 0x4 #define INFO_FLAG_REFCLOCK 0x8 -#define INFO_FLAG_MCLIENT 0x8 /* danger */ -#define INFO_FLAG_BCLIENT 0x10 -#define INFO_FLAG_PREFER 0x10 /* danger */ +#define INFO_FLAG_PREFER 0x10 #define INFO_FLAG_AUTHENABLE 0x20 #define INFO_FLAG_SEL_CANDIDATE 0x40 #define INFO_FLAG_SHORTLIST 0x80 /* + * Flags in the system information returns + */ +#define INFO_FLAG_BCLIENT 0x1 +#define INFO_FLAG_AUTHENTICATE 0x2 +#define INFO_FLAG_PLL 0x4 +#define INFO_FLAG_PPS 0x8 /* unused */ +#define INFO_FLAG_PLL_SYNC 0x10 +#define INFO_FLAG_PPS_SYNC 0x20 +#define INFO_FLAG_MONITOR 0x40 +#define INFO_FLAG_FILEGEN 0x80 + +/* * Peer list structure. Used to return raw lists of peers. It goes * without saying that everything returned is in network byte order. */ @@ -352,7 +361,7 @@ struct info_peer { LONG unused5; LONG unused6; LONG unused7; - U_LONG estbdelay; /* broadcast delay */ + s_fp estbdelay; /* broadcast offset */ }; @@ -369,21 +378,21 @@ struct info_peer_stats { U_LONG timetosend; /* time until a packet sent */ U_LONG timereachable; /* time peer has been reachable */ U_LONG sent; /* number sent */ - U_LONG received; /* number received */ + U_LONG unused1; /* (unused) */ U_LONG processed; /* number processed */ - U_LONG badlength; /* rejected due to bad length */ - U_LONG badauth; /* rejected due to bad auth */ - U_LONG bogusorg; /* funny org time stamps */ - U_LONG oldpkt; /* duplicate packets */ - U_LONG baddelay; /* dropped due to bad delays */ - U_LONG seldelay; /* not selected due to delay */ - U_LONG seldisp; /* not selected due to dispersion */ - U_LONG selbroken; /* not selected because of brokenness */ - U_LONG selold; /* not selected because too old */ - u_char candidate; /* order after falseticker candidate select */ - u_char falseticker; /* order after resort for falseticker */ - u_char select; /* order after select */ - u_char select_total; /* number who made it to selection */ + U_LONG unused2; /* (unused) */ + U_LONG badauth; /* bad authentication */ + U_LONG bogusorg; /* bogus origin */ + U_LONG oldpkt; /* duplicate */ + U_LONG unused3; /* (unused) */ + U_LONG unused4; /* (unused) */ + U_LONG seldisp; /* bad dispersion */ + U_LONG selbroken; /* bad reference time */ + U_LONG unused5; /* (unused) */ + u_char candidate; /* select order */ + u_char unused6; /* (unused) */ + u_char unused7; /* (unused) */ + u_char unused8; /* (unused) */ }; @@ -417,9 +426,10 @@ struct info_sys { u_char unused1; /* unused */ u_char unused2; /* unused */ u_char unused3; /* unused */ - l_fp bdelay; /* default broadcast delay */ + s_fp bdelay; /* default broadcast offset */ + s_fp frequency; /* frequency residual (scaled ppm) */ l_fp authdelay; /* default authentication delay */ - u_fp maxskew; /* (obsolete) */ + u_fp stability; /* clock stability (scaled ppm) */ }; @@ -518,8 +528,7 @@ struct conf_peer { }; #define CONF_FLAG_AUTHENABLE 0x1 -#define CONF_FLAG_MINPOLL 0x2 -#define CONF_FLAG_PREFER 0x4 +#define CONF_FLAG_PREFER 0x2 /* * Structure for passing peer deletion information. Currently @@ -530,7 +539,6 @@ struct conf_unpeer { U_LONG peeraddr; /* address of peer */ }; - /* * Structure for carrying system flags. */ @@ -543,7 +551,10 @@ struct conf_sys_flags { */ #define SYS_FLAG_BCLIENT 0x1 #define SYS_FLAG_AUTHENTICATE 0x2 -#define SYS_FLAG_MCLIENT 0x4 +#define SYS_FLAG_PLL 0x4 +#define SYS_FLAG_PPS 0x8 +#define SYS_FLAG_MONITOR 0x10 +#define SYS_FLAG_FILEGEN 0x20 /* * Structure used for returning restrict entries @@ -571,6 +582,23 @@ struct conf_restrict { /* * Structure used for returning monitor data */ +struct info_monitor_1 { + U_LONG lasttime; /* last packet from this host */ + U_LONG firsttime; /* first time we received a packet */ + U_LONG lastdrop; /* last time we rejected a packet due to client limitation policy */ + U_LONG count; /* count of packets received */ + U_LONG addr; /* host address */ + U_LONG daddr; /* destination host address */ + U_LONG flags; /* flags about destination */ + u_short port; /* port number of last reception */ + u_char mode; /* mode of last packet */ + u_char version; /* version number of last packet */ +}; + + +/* + * Structure used for returning monitor data + */ struct info_monitor { U_LONG lasttime; /* last packet from this host */ U_LONG firsttime; /* first time we received a packet */ @@ -626,7 +654,7 @@ struct info_auth { U_LONG keynotfound; /* requested key unknown */ U_LONG encryptions; /* number of encryptions */ U_LONG decryptions; /* number of decryptions */ - U_LONG decryptok; /* number of successful decryptions */ + U_LONG unused; /* (unused) */ U_LONG keyuncached; /* calls to encrypt/decrypt with uncached key */ }; diff --git a/usr.sbin/xntpd/include/ntp_stdlib.h b/usr.sbin/xntpd/include/ntp_stdlib.h index f68c768..646ce60 100644 --- a/usr.sbin/xntpd/include/ntp_stdlib.h +++ b/usr.sbin/xntpd/include/ntp_stdlib.h @@ -1,4 +1,4 @@ -/* ntp_stdlib.h,v 3.1 1993/07/06 01:06:58 jbj Exp +/* * ntp_stdlib.h - Prototypes for XNTP lib. */ #include <sys/types.h> @@ -24,28 +24,28 @@ extern void msyslog P((int, char *, ...)); extern void msyslog P(()); #endif -extern void auth_des P((U_LONG *, u_char *)); +extern void auth_des P((u_long *, u_char *)); extern void auth_delkeys P((void)); -extern int auth_havekey P((U_LONG)); -extern int auth_parity P((U_LONG *)); -extern void auth_setkey P((U_LONG, U_LONG *)); -extern void auth_subkeys P((U_LONG *, u_char *, u_char *)); -extern int authistrusted P((U_LONG)); -extern int authusekey P((U_LONG, int, const char *)); +extern int auth_havekey P((u_long)); +extern int auth_parity P((u_long *)); +extern void auth_setkey P((u_long, u_long *)); +extern void auth_subkeys P((u_long *, u_char *, u_char *)); +extern int authistrusted P((u_long)); +extern int authusekey P((u_long, int, const char *)); extern void auth_delkeys P((void)); -extern void auth1crypt P((U_LONG, U_LONG *, int)); -extern int auth2crypt P((U_LONG, U_LONG *, int)); -extern int authdecrypt P((U_LONG, U_LONG *, int)); -extern int authencrypt P((U_LONG, U_LONG *, int)); -extern int authhavekey P((U_LONG)); +extern void auth1crypt P((u_long, U_LONG *, int)); +extern int auth2crypt P((u_long, U_LONG *, int)); +extern int authdecrypt P((u_long, U_LONG *, int)); +extern int authencrypt P((u_long, U_LONG *, int)); +extern int authhavekey P((u_long)); extern int authreadkeys P((const char *)); -extern void authtrust P((U_LONG, int)); -extern void calleapwhen P((U_LONG, U_LONG *, U_LONG *)); -extern U_LONG calyearstart P((U_LONG)); +extern void authtrust P((u_long, int)); +extern void calleapwhen P((u_long, u_long *, u_long *)); +extern u_long calyearstart P((u_long)); extern const char *clockname P((int)); -extern int clocktime P((int, int, int, int, int, U_LONG, U_LONG *, U_LONG *)); +extern int clocktime P((int, int, int, int, int, u_long, u_long *, U_LONG *)); extern char * emalloc P((u_int)); extern int ntp_getopt P((int, char **, char *)); extern void init_auth P((void)); @@ -53,41 +53,41 @@ extern void init_lib P((void)); extern void init_random P((void)); #ifdef DES -extern void DESauth1crypt P((U_LONG, U_LONG *, int)); -extern int DESauth2crypt P((U_LONG, U_LONG *, int)); -extern int DESauthdecrypt P((U_LONG, const U_LONG *, int)); -extern int DESauthencrypt P((U_LONG, U_LONG *, int)); -extern void DESauth_setkey P((U_LONG, const U_LONG *)); +extern void DESauth1crypt P((u_long, U_LONG *, int)); +extern int DESauth2crypt P((u_long, U_LONG *, int)); +extern int DESauthdecrypt P((u_long, const U_LONG *, int)); +extern int DESauthencrypt P((u_long, U_LONG *, int)); +extern void DESauth_setkey P((u_long, const U_LONG *)); extern void DESauth_subkeys P((const U_LONG *, u_char *, u_char *)); extern void DESauth_des P((U_LONG *, u_char *)); extern int DESauth_parity P((U_LONG *)); #endif /* DES */ #ifdef MD5 -extern void MD5auth1crypt P((U_LONG, U_LONG *, int)); -extern int MD5auth2crypt P((U_LONG, U_LONG *, int)); -extern int MD5authdecrypt P((U_LONG, const U_LONG *, int)); -extern int MD5authencrypt P((U_LONG, U_LONG *, int)); -extern void MD5auth_setkey P((U_LONG, const U_LONG *)); +extern void MD5auth1crypt P((u_long, U_LONG *, int)); +extern int MD5auth2crypt P((u_long, U_LONG *, int)); +extern int MD5authdecrypt P((u_long, const U_LONG *, int)); +extern int MD5authencrypt P((u_long, U_LONG *, int)); +extern void MD5auth_setkey P((u_long, const U_LONG *)); #endif /* MD5 */ -extern int atoint P((const char *, LONG *)); -extern int atouint P((const char *, U_LONG *)); -extern int hextoint P((const char *, U_LONG *)); -extern char * humandate P((U_LONG)); -extern char * inttoa P((LONG)); -extern char * mfptoa P((U_LONG, U_LONG, int)); -extern char * mfptoms P((U_LONG, U_LONG, int)); +extern int atoint P((const char *, long *)); +extern int atouint P((const char *, u_long *)); +extern int hextoint P((const char *, u_long *)); +extern char * humandate P((u_long)); +extern char * inttoa P((long)); +extern char * mfptoa P((u_long, u_long, int)); +extern char * mfptoms P((u_long, u_long, int)); extern char * modetoa P((int)); -extern U_LONG netof P((U_LONG)); -extern char * numtoa P((U_LONG)); -extern char * numtohost P((U_LONG)); -extern int octtoint P((const char *, U_LONG *)); -extern U_LONG ranp2 P((int)); -extern char * refnumtoa P((U_LONG)); -extern int tsftomsu P((U_LONG, int)); -extern char * uinttoa P((U_LONG)); +extern u_long netof P((u_long)); +extern char * numtoa P((u_long)); +extern char * numtohost P((u_long)); +extern int octtoint P((const char *, u_long *)); +extern u_long ranp2 P((int)); +extern char * refnumtoa P((u_long)); +extern int tsftomsu P((u_long, int)); +extern char * uinttoa P((u_long)); -extern int decodenetnum P((const char *, U_LONG *)); +extern int decodenetnum P((const char *, u_long *)); extern RETSIGTYPE signal_no_reset P((int, RETSIGTYPE (*func)())); diff --git a/usr.sbin/xntpd/include/ntp_syslog.h b/usr.sbin/xntpd/include/ntp_syslog.h index 0d5dff8..38b847b 100644 --- a/usr.sbin/xntpd/include/ntp_syslog.h +++ b/usr.sbin/xntpd/include/ntp_syslog.h @@ -1,4 +1,4 @@ -/* ntp_syslog.h,v 3.1 1993/07/06 01:06:59 jbj Exp +/* * A hack for platforms which require specially built syslog facilities */ #ifdef GIZMO diff --git a/usr.sbin/xntpd/include/ntp_types.h b/usr.sbin/xntpd/include/ntp_types.h index 7a2a347..ac3d76c 100644 --- a/usr.sbin/xntpd/include/ntp_types.h +++ b/usr.sbin/xntpd/include/ntp_types.h @@ -1,4 +1,4 @@ -/* ntp_types.h,v 3.1 1993/07/06 01:07:00 jbj Exp +/* * ntp_types.h - defines how LONG and U_LONG are treated. For 64 bit systems * like the DEC Alpha, they has to be defined as int and u_int. for 32 bit * systems, define them as long and u_long diff --git a/usr.sbin/xntpd/include/ntp_unixtime.h b/usr.sbin/xntpd/include/ntp_unixtime.h index c1ab573..8007a06 100644 --- a/usr.sbin/xntpd/include/ntp_unixtime.h +++ b/usr.sbin/xntpd/include/ntp_unixtime.h @@ -1,4 +1,4 @@ -/* ntp_unixtime.h,v 3.1 1993/07/06 01:07:02 jbj Exp +/* * ntp_unixtime.h - contains constants and macros for converting between * NTP time stamps (l_fp) and Unix times (struct timeval) */ @@ -34,9 +34,9 @@ * Convert usec to a time stamp fraction. If you use this the program * must include the following declarations: */ -extern U_LONG ustotslo[]; -extern U_LONG ustotsmid[]; -extern U_LONG ustotshi[]; +extern u_long ustotslo[]; +extern u_long ustotsmid[]; +extern u_long ustotshi[]; #define TVUTOTSF(tvu, tsf) \ (tsf) = ustotslo[(tvu) & 0xff] \ @@ -48,14 +48,14 @@ extern U_LONG ustotshi[]; */ #define TVTOTS(tv, ts) \ do { \ - (ts)->l_ui = (unsigned LONG)(tv)->tv_sec; \ + (ts)->l_ui = (u_long)(tv)->tv_sec; \ TVUTOTSF((tv)->tv_usec, (ts)->l_uf); \ } while(0) #define sTVTOTS(tv, ts) \ do { \ int isneg = 0; \ - LONG usec; \ + long usec; \ (ts)->l_ui = (tv)->tv_sec; \ usec = (tv)->tv_usec; \ if (((tv)->tv_sec < 0) || ((tv)->tv_usec < 0)) { \ @@ -81,9 +81,9 @@ extern U_LONG ustotshi[]; * Convert a time stamp fraction to microseconds. The time stamp * fraction is assumed to be unsigned. To use this in a program, declare: */ -extern LONG tstouslo[]; -extern LONG tstousmid[]; -extern LONG tstoushi[]; +extern long tstouslo[]; +extern long tstousmid[]; +extern long tstoushi[]; #define TSFTOTVU(tsf, tvu) \ (tvu) = (tstoushi[((tsf) >> 24) & 0xff] \ @@ -109,8 +109,8 @@ extern LONG tstoushi[]; * here, but it is convenient since the guys who use the definition will * often be including this file anyway. */ -extern U_LONG msutotsflo[]; -extern U_LONG msutotsfhi[]; +extern u_long msutotsflo[]; +extern u_long msutotsfhi[]; #define MSUTOTSF(msu, tsf) \ (tsf) = msutotsfhi[((msu) >> 5) & 0x1f] + msutotsflo[(msu) & 0x1f] diff --git a/usr.sbin/xntpd/include/ntpd.h b/usr.sbin/xntpd/include/ntpd.h index 037e8cb..53e3a91 100644 --- a/usr.sbin/xntpd/include/ntpd.h +++ b/usr.sbin/xntpd/include/ntpd.h @@ -63,10 +63,10 @@ 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 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)); +extern void sendpkt P((struct sockaddr_in *, struct interface *, int, struct pkt *, int)); #ifdef HAVE_SIGNALED_IO extern void wait_for_signal P((void)); extern void unblock_io_and_alarm P((void)); @@ -88,6 +88,7 @@ extern int leap_actual P((int)); /* ntp_loopfilter.c */ extern void init_loopfilter P((void)); extern int local_clock P((l_fp *, struct peer *)); +extern void adj_frequency P((s_fp)); extern void adj_host_clock P((void)); extern void loop_config P((int, l_fp *, int)); #if defined(PPS) || defined(PPSPPS) || defined(PPSCD) @@ -103,12 +104,12 @@ extern void monitor P((struct recvbuf *)); /* ntp_peer.c */ 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 *findpeer P((struct sockaddr_in *, struct interface *, int)); extern struct peer *findpeerbyassoc P((int)); -extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, 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, int, int, U_LONG)); +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 *)); @@ -134,7 +135,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, U_LONG)); +extern void proto_config P((int, u_long)); extern void proto_clr_stats P((void)); #ifdef REFCLOCK @@ -168,7 +169,7 @@ extern void init_util P((void)); extern void hourly_stats P((void)); extern void stats_config P((int, char *)); extern void record_peer_stats P((struct sockaddr_in *, int, l_fp *, s_fp, u_fp)); -extern void record_loop_stats P((l_fp *, s_fp *, int)); +extern void record_loop_stats P((l_fp *, s_fp, int)); extern void record_clock_stats P((struct sockaddr_in *, char *)); extern void getauthkeys P((char *)); extern void rereadkeys P((void)); diff --git a/usr.sbin/xntpd/include/parse.h b/usr.sbin/xntpd/include/parse.h index 6ce3f19..49ed4e5 100644 --- a/usr.sbin/xntpd/include/parse.h +++ b/usr.sbin/xntpd/include/parse.h @@ -1,7 +1,7 @@ /* - * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp + * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.21 1994/05/30 20:58:34 kardel Exp * - * parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp + * parse.h,v 3.21 1994/05/30 20:58:34 kardel Exp * * Copyright (c) 1989,1990,1991,1992,1993,1994 * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg @@ -15,7 +15,7 @@ #ifndef __PARSE_H__ #define __PARSE_H__ #if !(defined(lint) || defined(__GNUC__)) - static char parsehrcsid[]="parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp"; + static char parsehrcsid[]="parse.h,v 3.21 1994/05/30 20:58:34 kardel Exp"; #endif #include "ntp_types.h" @@ -50,7 +50,6 @@ extern int splhigh(); #define FREE(_X_, _Y_) kmem_free((caddr_t)_X_, _Y_) #endif #else -/* extern char *malloc(); XXX defined elsewhere */ #define MALLOC(_X_) malloc(_X_) #define FREE(_X_, _Y_) free(_X_) #endif @@ -74,6 +73,13 @@ extern int debug; #endif /* DEBUG */ #endif /* PARSESTREAM */ +#if defined(timercmp) && defined(__GNUC__) +#undef timercmp +#define timercmp(tvp, uvp, cmp) \ + ((tvp)->tv_sec cmp (uvp)->tv_sec || \ + ((tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)) +#endif + #ifndef TIMES10 #define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1)) #endif @@ -149,6 +155,7 @@ extern int debug; #define PARSE_STAT_FILTER 0x01 /* filter incoming data */ #define PARSE_STAT_AVG 0x02 /* 1:median average / 0: median point */ #define PARSE_LEAP_DELETE 0x04 /* delete leap */ +#define PARSE_STATISTICS 0x08 /* enable statistics */ #define PARSE_FIXED_FMT 0x10 /* fixed format */ #define PARSE_PPSCLOCK 0x20 /* try to get PPS time stamp via ppsclock ioctl */ @@ -163,13 +170,13 @@ typedef union timestamp */ struct parsetime { - unsigned LONG parse_status; /* data status - CVT_OK, CVT_NONE, CVT_FAIL ... */ + u_long parse_status; /* data status - CVT_OK, CVT_NONE, CVT_FAIL ... */ timestamp_t parse_time; /* PARSE timestamp */ timestamp_t parse_stime; /* telegram sample timestamp */ timestamp_t parse_ptime; /* PPS time stamp */ - LONG parse_usecerror; /* sampled/filtered usec error */ - LONG parse_usecdisp; /* sampled usecdispersion */ - unsigned LONG parse_state; /* current receiver state */ + long parse_usecerror; /* sampled/filtered usec error */ + long parse_usecdisp; /* sampled usecdispersion */ + u_long parse_state; /* current receiver state */ unsigned short parse_format; /* format code */ }; @@ -212,13 +219,13 @@ union parsectl { struct parsestatus { - unsigned LONG flags; /* new/old flags */ + u_long flags; /* new/old flags */ } parsestatus; struct parsegettc { - unsigned LONG parse_state; /* last state */ - unsigned LONG parse_badformat; /* number of bad packets since last query */ + u_long parse_state; /* last state */ + u_long parse_badformat; /* number of bad packets since last query */ unsigned short parse_format;/* last decoded format */ unsigned short parse_count; /* count of valid time code bytes */ char parse_buffer[PARSE_TCMAX+1]; /* timecode buffer */ @@ -233,7 +240,7 @@ union parsectl struct parsesetcs { - unsigned LONG parse_cs; /* character size (needed for stripping) */ + u_long parse_cs; /* character size (needed for stripping) */ } parsesetcs; }; @@ -269,21 +276,27 @@ struct parse /* parse module local data */ timestamp_t parse_lastchar; /* time stamp of last received character */ /* + * private data - fixed format only + */ + unsigned short parse_plen; /* length of private data */ + void *parse_pdata; /* private data pointer */ + + /* * time code input buffer (from RS232 or PPS) */ unsigned short parse_index; /* current buffer index */ char *parse_data; /* data buffer */ unsigned short parse_dsize; /* size of data buffer */ unsigned short parse_lformat; /* last format used */ - unsigned LONG parse_lstate; /* last state code */ + u_long parse_lstate; /* last state code */ char *parse_ldata; /* last data buffer */ unsigned short parse_ldsize; /* last data buffer length */ - unsigned LONG parse_badformat; /* number of unparsable pakets */ + u_long parse_badformat; /* number of unparsable pakets */ /* * time stamp filtering */ - LONG parse_delta[PARSE_DELTA]; /* delta buffer */ + long parse_delta[PARSE_DELTA]; /* delta buffer */ int parse_dindex; parsetime_t parse_dtime; /* external data prototype */ @@ -293,16 +306,16 @@ typedef struct parse parse_t; struct clocktime /* clock time broken up from time code */ { - LONG day; - LONG month; - LONG year; - LONG hour; - LONG minute; - LONG second; - LONG usecond; - LONG utcoffset; /* in seconds */ + long day; + long month; + long year; + long hour; + long minute; + long second; + long usecond; + long utcoffset; /* in seconds */ time_t utctime; /* the actual time - alternative to date/time */ - LONG flags; /* current clock status */ + long flags; /* current clock status */ }; typedef struct clocktime clocktime_t; @@ -335,20 +348,23 @@ typedef struct clocktime clocktime_t; #define CVT_NONE 0x00000001 /* format not applicable */ #define CVT_FAIL 0x00000002 /* conversion failed - error code returned */ #define CVT_OK 0x00000004 /* conversion succeeded */ +#define CVT_SKIP 0x00000008 /* conversion succeeded */ #define CVT_BADFMT 0x00000010 /* general format error - (unparsable) */ #define CVT_BADDATE 0x00000020 /* date field incorrect */ #define CVT_BADTIME 0x00000040 /* time field incorrect */ struct clockformat { - unsigned LONG (*convert)(); /* conversion routine */ + u_long (*input)(); /* special input protocol - implies fixed format */ + u_long (*convert)(); /* conversion routine */ void (*syncevt)(); /* routine for handling RS232 sync events (time stamps) */ - unsigned LONG (*syncpps)(); /* PPS input routine */ - unsigned LONG (*synth)(); /* time code synthesizer */ + u_long (*syncpps)(); /* PPS input routine */ + u_long (*synth)(); /* time code synthesizer */ void *data; /* local parameters */ char *name; /* clock format name */ unsigned short length; /* maximum length of data packet */ - unsigned LONG flags; /* valid start symbols etc. */ + u_long flags; /* valid start symbols etc. */ + unsigned short plen; /* length of private data - implies fixed format */ struct timeval timeout; /* buffer restart after timeout (us) */ unsigned char startsym; /* start symbol */ unsigned char endsym; /* end symbol */ @@ -360,32 +376,44 @@ typedef struct clockformat clockformat_t; /* * parse interface */ -extern int parse_ioinit(/* parse_t *parseio */); -extern void parse_ioend(/* parse_t *parseio */); -extern int parse_ioread(/* parse_t *parseio, char ch, timestamp_t *ctime */); -extern int parse_iopps(/* parse_t *parseio, int status, struct timeval *ptime, parsetime_t *dtime */); -extern void parse_iodone(/* parse_t *parseio */); - -extern int parse_getstat(/* parsectl_t *dct, parse_t *parse */); -extern int parse_setstat(/* parsectl_t *dct, parse_t *parse */); -extern int parse_timecode(/* parsectl_t *dct, parse_t *parse */); -extern int parse_getfmt(/* parsectl_t *dct, parse_t *parse */); -extern int parse_setfmt(/* parsectl_t *dct, parse_t *parse */); -extern int parse_setcs(/* parsectl_t *dct, parse_t *parse */); +extern int parse_ioinit P((parse_t *)); +extern void parse_ioend P((parse_t *)); +extern int parse_ioread P((parse_t *, unsigned char, timestamp_t *)); +extern int parse_iopps P((parse_t *, int, timestamp_t *)); +extern void parse_iodone P((parse_t *)); + +extern int parse_getstat P((parsectl_t *, parse_t *)); +extern int parse_setstat P((parsectl_t *, parse_t *)); +extern int parse_timecode P((parsectl_t *, parse_t *)); +extern int parse_getfmt P((parsectl_t *, parse_t *)); +extern int parse_setfmt P((parsectl_t *, parse_t *)); +extern int parse_setcs P((parsectl_t *, parse_t *)); extern int Strok P((char *, char *)); -extern int Stoi P((char *, LONG *, int)); +extern int Stoi P((char *, long *, int)); -extern time_t parse_to_unixtime P((clocktime_t *, unsigned LONG *)); -extern unsigned LONG updatetimeinfo P((parse_t *, time_t, unsigned LONG, unsigned LONG)); -extern void syn_simple P((parse_t *, timestamp_t *, struct format *, unsigned LONG)); -extern unsigned LONG pps_simple P((parse_t *, int status, timestamp_t *)); +extern time_t parse_to_unixtime P((clocktime_t *, u_long *)); +extern u_long updatetimeinfo P((parse_t *, time_t, u_long, u_long)); +extern void syn_simple P((parse_t *, timestamp_t *, struct format *, u_long)); +extern u_long pps_simple P((parse_t *, int, timestamp_t *)); #endif /* * History: * * parse.h,v + * Revision 3.21 1994/05/30 20:58:34 kardel + * fix prototypes + * + * Revision 3.20 1994/05/30 10:19:44 kardel + * LONG cleanup + * + * Revision 3.19 1994/05/15 11:30:33 kardel + * documented flag4 as statistics enable flag + * + * Revision 3.18 1994/05/12 12:40:34 kardel + * shut up gcc about broken Sun/BSD code + * * Revision 3.17 1994/03/03 09:27:20 kardel * rcs ids fixed * diff --git a/usr.sbin/xntpd/include/parse_conf.h b/usr.sbin/xntpd/include/parse_conf.h index 13cec55..47f8c0c 100644 --- a/usr.sbin/xntpd/include/parse_conf.h +++ b/usr.sbin/xntpd/include/parse_conf.h @@ -1,7 +1,7 @@ /* - * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp + * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.6 1994/05/30 10:19:49 kardel Exp * - * parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp + * parse_conf.h,v 3.6 1994/05/30 10:19:49 kardel Exp * * Copyright (c) 1993,1994 * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg @@ -15,7 +15,7 @@ #ifndef __PARSE_CONF_H__ #define __PARSE_CONF_H__ #if !(defined(lint) || defined(__GNUC__)) - static char dcfhrcsid[]="parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp FAU"; + static char dcfhrcsid[]="parse_conf.h,v 3.6 1994/05/30 10:19:49 kardel Exp FAU"; #endif /* @@ -49,6 +49,6 @@ struct format char length; /* length of field */ } field_offsets[O_COUNT]; char *fixed_string; /* string with must be chars (blanks = wildcards) */ - unsigned LONG flags; + u_long flags; }; #endif diff --git a/usr.sbin/xntpd/include/sys/bsd_audioirig.h b/usr.sbin/xntpd/include/sys/bsd_audioirig.h index 1daeec7..6a23260 100644 --- a/usr.sbin/xntpd/include/sys/bsd_audioirig.h +++ b/usr.sbin/xntpd/include/sys/bsd_audioirig.h @@ -13,14 +13,14 @@ /* * irig ioctls */ -#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__) -#define AUDIO_IRIG_OPEN _IO(A, 50) -#define AUDIO_IRIG_CLOSE _IO(A, 51) -#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int) -#else +#if defined(__STDC__) || !(defined(ibm032) && !defined(__GNUC)) #define AUDIO_IRIG_OPEN _IO('A', 50) #define AUDIO_IRIG_CLOSE _IO('A', 51) #define AUDIO_IRIG_SETFORMAT _IOWR('A', 52, int) +#else +#define AUDIO_IRIG_OPEN _IO(A, 50) +#define AUDIO_IRIG_CLOSE _IO(A, 51) +#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int) #endif /* diff --git a/usr.sbin/xntpd/include/sys/chudefs.h b/usr.sbin/xntpd/include/sys/chudefs.h index 50f8252..f5549f5 100644 --- a/usr.sbin/xntpd/include/sys/chudefs.h +++ b/usr.sbin/xntpd/include/sys/chudefs.h @@ -1,4 +1,4 @@ -/* chudefs.h,v 3.1 1993/07/06 01:07:11 jbj Exp +/* * Definitions for the CHU line discipline v2.0 */ diff --git a/usr.sbin/xntpd/include/sys/clkdefs.h b/usr.sbin/xntpd/include/sys/clkdefs.h index b2596e1..afbc77a 100644 --- a/usr.sbin/xntpd/include/sys/clkdefs.h +++ b/usr.sbin/xntpd/include/sys/clkdefs.h @@ -1,8 +1,12 @@ -/* clkdefs.h,v 3.1 1993/07/06 01:07:12 jbj Exp +/* * Defines for the "clk" timestamping STREAMS module */ +#if defined(sun) #include <sys/ioccom.h> +#else +#include <sys/ioctl.h> +#endif /* * First, we need to define the maximum size of the set of @@ -10,6 +14,9 @@ */ #define CLK_MAXSTRSIZE 32 +struct clk_tstamp_charset { /* XXX to use _IOW not _IOWN */ + char val[CLK_MAXSTRSIZE]; +}; /* * ioctl(fd, CLK_SETSTR, (char*)c ); @@ -23,9 +30,9 @@ * change this file. */ -#if __STDC__ -#define CLK_SETSTR _IOWN('K',01,CLK_MAXSTRSIZE) +#if defined(__STDC__) /* XXX avoid __STDC__=0 on SOLARIS */ +#define CLK_SETSTR _IOW('K', 01, struct clk_tstamp_charset) #else -#define CLK_SETSTR _IOWN(K,01,CLK_MAXSTRSIZE) +#define CLK_SETSTR _IOW(K, 01, struct clk_tstamp_charset) #endif diff --git a/usr.sbin/xntpd/include/sys/parsestreams.h b/usr.sbin/xntpd/include/sys/parsestreams.h index d07e75c..7c054af 100644 --- a/usr.sbin/xntpd/include/sys/parsestreams.h +++ b/usr.sbin/xntpd/include/sys/parsestreams.h @@ -1,7 +1,7 @@ /* - * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp + * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.12 1994/06/01 08:21:08 kardel Exp * - * parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp + * parsestreams.h,v 3.12 1994/06/01 08:21:08 kardel Exp * * Copyright (c) 1989,1990,1991,1992,1993,1994 * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg @@ -13,7 +13,7 @@ */ #if !(defined(lint) || defined(__GNUC__)) - static char parse77hrcsid[]="parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp"; + static char parse77hrcsid[]="parsestreams.h,v 3.12 1994/06/01 08:21:08 kardel Exp"; #endif #undef PARSEKERNEL @@ -42,7 +42,7 @@ typedef struct parsestream parsestream_t; /*--------------- debugging support ---------------------------------*/ -#ifdef DEBUG_DCF +#ifdef DEBUG_PARSE extern int parsedebug; diff --git a/usr.sbin/xntpd/include/sys/ppsclock.h b/usr.sbin/xntpd/include/sys/ppsclock.h index 952a57b..edf28aa 100644 --- a/usr.sbin/xntpd/include/sys/ppsclock.h +++ b/usr.sbin/xntpd/include/sys/ppsclock.h @@ -1,4 +1,3 @@ -/* ppsclock.h,v 3.1 1993/07/06 01:07:14 jbj Exp */ /* * This software was developed by the Computer Systems Engineering group * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66. diff --git a/usr.sbin/xntpd/include/sys/timex.h b/usr.sbin/xntpd/include/sys/timex.h new file mode 100644 index 0000000..bc2d634 --- /dev/null +++ b/usr.sbin/xntpd/include/sys/timex.h @@ -0,0 +1,290 @@ +/****************************************************************************** + * * + * Copyright (c) David L. Mills 1993, 1994 * + * * + * Permission to use, copy, modify, and distribute this software and its * + * documentation for any purpose and without fee is hereby granted, provided * + * that the above copyright notice appears in all copies and that both the * + * copyright notice and this permission notice appear in supporting * + * documentation, and that the name University of Delaware not be used in * + * advertising or publicity pertaining to distribution of the software * + * without specific, written prior permission. The University of Delaware * + * makes no representations about the suitability this software for any * + * purpose. It is provided "as is" without express or implied warranty. * + * * + ******************************************************************************/ + +/* + * 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. + * + * 28 Nov 93 David L. Mills + * Adjusted parameters to improve stability and increase poll + * interval. + * + * 17 Sep 93 David L. Mills + * Created file + */ +/* + * This header file defines the Network Time Protocol (NTP) interfaces + * for user and daemon application programs. These are implemented using + * private syscalls and data structures and require specific kernel + * support. + * + * NAME + * ntp_gettime - NTP user application interface + * + * SYNOPSIS + * #include <sys/timex.h> + * + * int syscall(SYS_ntp_gettime, tptr) + * + * int SYS_ntp_gettime defined in syscall.h header file + * struct ntptimeval *tptr pointer to ntptimeval structure + * + * NAME + * ntp_adjtime - NTP daemon application interface + * + * SYNOPSIS + * #include <sys/timex.h> + * + * int syscall(SYS_ntp_adjtime, mode, tptr) + * + * int SYS_ntp_adjtime defined in syscall.h header file + * struct timex *tptr pointer to timex structure + * + */ +#ifndef _SYS_TIMEX_H_ +#define _SYS_TIMEX_H_ 1 + +#ifndef MSDOS /* Microsoft specific */ +#include <sys/syscall.h> +#endif /* MSDOS */ + +/* + * 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. 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) */ +#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 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 (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 */ + +/* + * Status codes (timex.status) + */ +#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 states (time_state) + */ +#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_WAIT 4 /* leap second has occured */ +#define TIME_ERROR 5 /* clock not synchronized */ + +/* + * 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 (ro) */ + long maxerror; /* maximum error (us) (ro) */ + long esterror; /* estimated error (us) (ro) */ +}; + +/* + * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock + * oscillator + */ +struct timex { + 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 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) */ + +}; +#ifdef __FreeBSD__ + +#ifndef KERNEL +#include <sys/cdefs.h> + +__BEGIN_DECLS +extern int ntp_gettime __P((struct ntptimeval *)); +extern int ntp_adjtime __P((struct timex *)); +__END_DECLS + +#endif /* not KERNEL */ + +#endif /* __FreeBSD__ */ +#endif /* _SYS_TIMEX_H_ */ diff --git a/usr.sbin/xntpd/include/sys/tpro.h b/usr.sbin/xntpd/include/sys/tpro.h index 1cdaf9c..f276f81 100644 --- a/usr.sbin/xntpd/include/sys/tpro.h +++ b/usr.sbin/xntpd/include/sys/tpro.h @@ -1,4 +1,4 @@ -/* tpro.h,v 3.1 1993/07/06 01:07:07 jbj Exp +/* * Structure for the KSI/Odetics TPRO-S data returned in reponse to a * read() call. Note that these are driver-specific and not dependent on * 32/64-bit architecture. |