/*
* Macros to determine the clock type and unit numbers from a
* 127.127.t.u address
*/
#define REFCLOCKTYPE(srcadr) ((SRCADR(srcadr) >> 8) & 0xff)
#define REFCLOCKUNIT(srcadr) (SRCADR(srcadr) & 0xff)
/*
* List of reference clock names and descriptions. These must agree with
* lib/clocktypes.c and ntpd/refclock_conf.c.
*/
struct clktype {
int code; /* driver "major" number */
const char *clocktype; /* long description */
const char *abbrev; /* short description */
};
extern struct clktype clktypes[];
/*
* Constant for disabling event reporting in
* refclock_receive. ORed in leap
* parameter
*/
#define REFCLOCK_OWN_STATES 0x80
/*
* Structure for returning clock status
*/
struct refclockstat {
u_char type; /* clock type */
u_char flags; /* clock flags */
u_short haveflags; /* bit array of valid flags */
u_short lencode; /* length of last timecode */
const char *p_lastcode; /* last timecode received */
u_int32 polls; /* transmit polls */
u_int32 noresponse; /* no response to poll */
u_int32 badformat; /* bad format timecode received */
u_int32 baddata; /* invalid data timecode received */
u_int32 timereset; /* driver resets */
const char *clockdesc; /* ASCII description */
double fudgeminjitter; /* configure fudge minjitter */
double fudgetime1; /* configure fudge time1 */
double fudgetime2; /* configure fudge time2 */
int32 fudgeval1; /* configure fudge value1 */
u_int32 fudgeval2; /* configure fudge value2 */
u_char currentstatus; /* clock status */
u_char lastevent; /* last exception event */
u_char leap; /* leap bits */
struct ctl_var *kv_list; /* additional variables */
};
/*
* Reference clock I/O structure. Used to provide an interface between
* the reference clock drivers and the I/O module.
*/
struct refclockio {
struct refclockio *next; /* link to next structure */
void (*clock_recv) (struct recvbuf *); /* completion routine */
int (*io_input) (struct recvbuf *); /* input routine -
to avoid excessive buffer use
due to small bursts
of refclock input data */
struct peer *srcclock; /* refclock peer */
int datalen; /* length of data */
int fd; /* file descriptor */
u_long recvcount; /* count of receive completions */
int active; /* nonzero when in use */
/*
* 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_int32 stimes; /* times format sign array */
u_int32 values[NCLKBUGVALUES]; /* real values */
l_fp times[NCLKBUGTIMES]; /* real times */
};
/*
* Structure interface between the reference clock support
* ntp_refclock.c and the driver utility routines
*/
#define MAXSTAGE 64 /* max median filter stages */
#define NSTAGE 5 /* default median filter stages */
#define BMAX 128 /* max timecode length */
#define GMT 0 /* I hope nobody sees this */
#define MAXDIAL 60 /* max length of modem dial strings */
char a_lastcode[BMAX]; /* last timecode received */
int lencode; /* length of last timecode */
int year; /* year of eternity */
int day; /* day of year */
int hour; /* hour of day */
int minute; /* minute of hour */
int second; /* second of minute */
long nsec; /* nanosecond of second */
u_long yearstart; /* beginning of year */
u_int coderecv; /* put pointer */
u_int codeproc; /* get pointer */
l_fp lastref; /* reference timestamp */
l_fp lastrec; /* receive timestamp */
double offset; /* mean offset */
double disp; /* sample dispersion */
double jitter; /* jitter (mean squares) */
double filter[MAXSTAGE]; /* median filter */
/*
* 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 */
};
/*
* 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 */
extern int ppsdev_reopen(const sockaddr_u *srcadr,
int ttyfd, int ppsfd, const char *ppspath,
int mode, int flags);
extern void ppsdev_close(int ttyfd, int ppsfd);