ntp_refclock.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ntp_refclock.h - definitions for reference clock support
*/
#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(HAVE_SYS_MODEM_H)
#endif
#if defined(STREAM)
#include <stropts.h>
#if defined(CLK)
#endif /* CLK */
#endif /* STREAM */
#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
*/
/*
* 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 */
const char *clocktype; /* long description */
const char *abbrev; /* short description */
};
/*
* Configuration flag values
*/
#define CLK_HAVETIME1 0x1
#define CLK_HAVETIME2 0x2
#define CLK_HAVEVAL1 0x4
#define CLK_HAVEVAL2 0x8
#define CLK_FLAG1 0x1
#define CLK_FLAG2 0x2
#define CLK_FLAG3 0x4
#define CLK_FLAG4 0x8
#define CLK_HAVEFLAG1 0x10
#define CLK_HAVEFLAG2 0x20
#define CLK_HAVEFLAG3 0x40
#define CLK_HAVEFLAG4 0x80
/*
* Constant for disabling event reporting in
* refclock_receive. ORed in leap
* parameter
*/
#define REFCLOCK_OWN_STATES 0x80
/*
* Structure for returning clock status
*/
struct refclockstat {
char *p_lastcode; /* last timecode received */
char *clockdesc; /* ASCII description */
};
/*
* Reference clock I/O structure. Used to provide an interface between
* the reference clock drivers and the I/O module.
*/
struct refclockio {
int datalen; /* lenth of data */
int fd; /* file descriptor */
};
/*
* Structure for returning debugging info
*/
#define NCLKBUGVALUES 16
#define NCLKBUGTIMES 32
struct refclockbug {
};
/*
* Structure interface between the reference clock support
* ntp_refclock.c and the driver utility routines
*/
#define GMT 0 /* I hope nobody sees this */
/*
* Line discipline flags. These require line discipline or streams
* installed, the code runs as if unspecified.
*/
struct refclockproc {
char *clockdesc; /* clock description */
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 */
int msec; /* millisecond of second */
long usec; /* microsecond of second (alt) */
/*
* Configuration data
*/
/*
* Status tallies
*/
};
/*
* 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((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 *));
};
/*
* 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 *));
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 int refclock_gtlin P((struct recvbuf *, char *, int,
l_fp *));
#endif /* REFCLOCK */