diff options
Diffstat (limited to 'usr.sbin/xntpd/include/ntp_refclock.h')
-rw-r--r-- | usr.sbin/xntpd/include/ntp_refclock.h | 226 |
1 files changed, 154 insertions, 72 deletions
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 */ |