Merged xntp3.3q from vendor branch.

This commit is contained in:
Garrett Wollman 1994-04-21 01:32:32 +00:00
parent 2bd971d8d2
commit 1398d54b9a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=1384
9 changed files with 167 additions and 37 deletions

View File

@ -1,5 +1,5 @@
DEFS_LOCAL=-DREFCLOCK -DPARSE
NTPDEFS= -DSYS_FREEBSD -DSYS_386BSD -DHAVE_TERMIOS
NTPDEFS= -DSYS_FREEBSD -DSYS_386BSD
AUTHDEFS= -DMD5
CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DAS2201 -DGOES -DGPSTM -DOMEGA \
-DLEITCH -DTRAK

View File

@ -1,6 +1,6 @@
This version of NTP was converted to the BSD-style Makefile system by
Garrett Wollman (wollman@freefall.cdrom.com); it is based on version
3.3p (late beta) from the University of Delaware.
3.3s (late beta) from the University of Delaware.
Besides the Makefile changes, the DES code has been completely removed
in order to make this code exportable. If you have a legal copy of

View File

@ -84,6 +84,7 @@ INFO ON NEW KERNEL PLL SYS CALLS
NTP_SYSCALLS_STD - use the "normal" ones
NTP_SYSCALL_GET - SYS_ntp_gettime id
NTP_SYSCALL_ADJ - SYS_ntp_adjtime id
NTP_SYSCALLS_LIBC - ntp_adjtime() and ntp_gettime() are in libc.
HOW TO GET IP INTERFACE INFORMATION
@ -394,6 +395,11 @@ in this file.
#define STR_SYSTEM "UNIX/*BSD"
#endif
#endif
#ifdef SYS_FREEBSD
#define HAVE_TERMIOS
#define HAVE_UNAME
#define NTP_SYSCALLS_LIBC
#endif
/*
* DEC AXP OSF/1

View File

@ -75,6 +75,7 @@ int jump = 0;
#define OC 12 /* integer, print in octal */
#define MD 13 /* mode */
#define AR 14 /* array of times */
#define TST 15 /* test flags */
#define EOV 255 /* end of table */
@ -145,7 +146,7 @@ struct ctl_var peer_var[] = {
{ CP_RECEIVED, UI, "received" }, /* 31 */
{ CP_SENT, UI, "sent" }, /* 32 */
{ CP_FILTERROR, AR, "filterror" }, /* 33 */
{ CP_FLASH, ST, "flash"}, /* 34 */
{ CP_FLASH, TST, "flash"}, /* 34 */
{ CP_DISP, AR, "disp" }, /* 35 */
/*
* These are duplicate entires so that we can
@ -188,6 +189,20 @@ struct codestring {
char *string;
};
/*
* flasher bits
*/
static char *tstflagnames[] = {
"DUPLICATE PKT",
"BOGUS PKT",
"PROTO UNSYNC",
"PEER BOUNDS",
"BAD AUTH",
"PEER CLOCK UNSYNC",
"BAD STRATUM",
"ROOT BOUNDS"
};
/*
* Leap values
*/
@ -2836,7 +2851,45 @@ outputarr(fp, name, narr, lfp)
output(fp, name, buf);
}
static char *
tstflags(val)
U_LONG val;
{
register char *cb, *s;
register int i;
register char *sep;
sep = "";
i = 0;
s = cb = &circ_buf[nextcb][0];
if (++nextcb >= NUMCB)
nextcb = 0;
sprintf(cb, "0x%x", val);
cb += strlen(cb);
if (val <= ((1<<8)-1)) {
if (!val) {
strcat(cb, "<OK>");
cb += strlen(cb);
} else {
*cb++ = '<';
while (val) {
if (val & 0x1) {
sprintf(cb, "%s%s", sep, tstflagnames[i]);
sep = ";";
cb += strlen(cb);
}
i++;
val >>= 1;
}
*cb++ = '>';
}
} else {
*cb++ = '?';
}
*cb = '\0';
return s;
}
/*
* cookedprint - output variables in cooked mode
@ -2994,6 +3047,13 @@ cookedprint(datatype, length, data, status, fp)
outputarr(fp, name, narr, lfparr);
break;
case TST:
if (!decodeuint(value, &uval))
output_raw = '?';
else
output(fp, name, tstflags(uval));
break;
default:
(void) fprintf(stderr,
"Internal error in cookedprint, %s=%s, fmt %d\n",

View File

@ -333,10 +333,13 @@ getoffsets(filex, tick_off, tickadj_off, dosync_off, noprintf_off)
#if defined(SYS_AUX3) || defined(SYS_AUX2)
#define X_TICKADJ 0
#define X_V 1
#define X_TICK 2
#define X_TICK 1
#define X_DEF
static struct nlist nl[4];
static struct nlist nl[] =
{ {"tickadj"},
{"tick"},
{""},
};
#endif
#ifdef NeXT
@ -429,13 +432,6 @@ getoffsets(filex, tick_off, tickadj_off, dosync_off, noprintf_off)
};
struct stat stbuf;
#if defined(SYS_AUX3) || defined(SYS_AUX2)
strcpy (nl[X_TICKADJ].n_name, "tickadj");
strcpy (nl[X_V].n_name, "v");
strcpy (nl[X_TICK].n_name, "tick");
nl[3].n_name[0] = '\0';
#endif
for (kname = kernels; *kname != NULL; kname++) {
if (stat(*kname, &stbuf) == -1)
continue;

View File

@ -264,8 +264,20 @@ static u_char def_clock_var[] = {
/*
* System and processor definitions. These will change for the gizmo board.
*/
#ifndef HAVE_UNAME
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX"
#endif
#ifndef STR_PROCESSOR
#define STR_PROCESSOR "unknown"
#endif
static char str_system[] = STR_SYSTEM;
static char str_processor[] = STR_PROCESSOR;
#else
#include <sys/utsname.h>
static struct utsname utsname;
#endif /* HAVE_UNAME */
/*
* Trap structures. We only allow a few of these, and send
@ -294,7 +306,7 @@ static struct utsname utsname;
static u_char clocktypes[] = {
CTL_SST_TS_NTP, /* REFCLK_NONE */
CTL_SST_TS_UNSPEC, /* REFCLK_LOCALCLOCK */
CTL_SST_TS_HF, /* REFCLK_GPS_TRAK */
CTL_SST_TS_UHF, /* REFCLK_GPS_TRAK */
CTL_SST_TS_HF, /* REFCLK_WWV_PST */
CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM */
CTL_SST_TS_UHF, /* REFCLK_GOES_TRUETIME */
@ -379,6 +391,7 @@ extern struct peer *sys_peer;
extern l_fp last_offset;
extern s_fp drift_comp;
extern int time_constant;
extern int pll_control;
/*
* Imported from the leap module
*/
@ -426,7 +439,9 @@ init_control()
{
int i;
#ifdef HAVE_UNAME
uname(&utsname);
#endif /* HAVE_UNAME */
ctl_clr_stats();
@ -716,10 +731,12 @@ ctlsysstatus()
if (sys_peer != 0)
if (sys_peer->sstclktype != CTL_SST_TS_UNSPEC)
clock = sys_peer->sstclktype;
else
else {
if (sys_peer->refclktype < sizeof(clocktypes))
clock = clocktypes[sys_peer->refclktype];
if (pps_control)
clock |= CTL_SST_TS_PPS;
}
return (u_short)CTL_SYS_STATUS(sys_leap, clock,
ctl_sys_num_events, ctl_sys_last_event);
}
@ -1262,12 +1279,22 @@ ctl_putsys(varid)
ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning);
break;
case CS_PROCESSOR:
#ifndef HAVE_UNAME
ctl_putstr(sys_var[CS_PROCESSOR].text, str_processor,
sizeof(str_processor) - 1);
#else
ctl_putstr(sys_var[CS_PROCESSOR].text, utsname.machine,
strlen(utsname.machine));
#endif /* HAVE_UNAME */
break;
case CS_SYSTEM:
ctl_putstr(sys_var[CS_SYSTEM].text, utsname.sysname,
#ifndef HAVE_UNAME
ctl_putstr(sys_var[CS_SYSTEM].text, str_system,
sizeof(str_system) - 1);
#else
ctl_putstr(sys_var[CS_SYSTEM].text, utsname.sysname,
strlen(utsname.sysname));
#endif /* HAVE_UNAME */
break;
case CS_KEYID:
ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0);

View File

@ -45,8 +45,10 @@
#ifdef KERNEL_PLL
#include <sys/timex.h>
#ifndef NTP_SYSCALLS_LIBC
#define ntp_gettime(t) syscall(SYS_ntp_gettime, (t))
#define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
#endif
#endif /* KERNEL_PLL */
/*

View File

@ -18,8 +18,10 @@
#ifdef KERNEL_PLL
#include <sys/timex.h>
#ifndef NTP_SYSCALLS_LIBC
#define ntp_gettime(t) syscall(SYS_ntp_gettime, (t))
#define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
#endif
#endif /* KERNEL_PLL */
/*

View File

@ -1,7 +1,9 @@
/*
* refclock_trak.c - clock driver for the TRAK 8810 GPS STATION CLOCK
* Tsuruoka Tomoaki Oct 30, 1993
*
* tsuruoka@nc.fukuoka-u.ac.jp
* Faculty of Engineering,
* Fukuoka University, Fukuoka, JAPAN
*/
#if defined(REFCLOCK) && (defined(TRAK) || defined(TRAKCLK) || defined(TRAKPPS))
@ -63,6 +65,14 @@ static void gps_send();
* Q=2 Pahse error < 10 ns
* (note that my clock almost stable at 1 us per 10 hours)
*
* Request leap second status - if needed.
* send: rqls\n
* reply: RQLS yy,mm,dd
* where: yy is year
* mm is month
* dd is day of month.baud
* Note: Default data is all zeros
* i.e. RQLS 00,00,00
*/
/*
@ -70,7 +80,7 @@ static void gps_send();
*/
#define MAXUNITS 4 /* max number of GPS units */
#define GPS232 "/dev/gps%d" /* name of radio device */
#define SPEED232 B9600 /* uart speed (9600 baud) */
#define SPEED232 B9600 /* uart speed (9600 bps) */
/*
* Radio interface parameters
@ -78,7 +88,7 @@ static void gps_send();
#define GPSPRECISION (-20) /* precision assumed (about 1 us) */
#define GPSREFID "GPS" /* reference id */
#define GPSDESCRIPTION "TRAK 8810 GPS station clock" /* who we are */
#define GPSHSREFID 0x7f7f110a /* 127.127.17.10 refid hi strata */
#define GPSHSREFID 0x7f7f020a /* 127.127.2.10 refid hi strata */
#define GMT 0 /* hour offset from Greenwich */
#define NCODES 3 /* stages of median filter */
#define LENTOC 25 /* *RQTS U,ddd:hh:mm:ss.0,Q datecode length */
@ -191,8 +201,8 @@ trak_init()
/*
* Just zero the data arrays
*/
bzero((char *)gpsunits, sizeof gpsunits);
bzero((char *)unitinuse, sizeof unitinuse);
memset((char *)gpsunits, 0, sizeof gpsunits);
memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@ -563,21 +573,28 @@ trak_receive(rbufp)
* timecode has format *........RQTS U,ddd:hh:mm:ss.0,Q\r\n).
* 012345678901234567890123
*/
#define RQTS 0
#define RQLS 1
cp = (u_char *)gps->lastcode;
gps->leap = 0;
cmdtype=0;
if (strncmp(cp,"RQTS",4)==0) {
cmdtype=1;
cp += 7;
}
else if(strncmp(cp,"*RQTS",5)==0) {
cmdtype=2;
if(strncmp(cp,"*RQTS",5)==0) {
cmdtype=RQTS;
cp += 8;
}
else return;
else if(strncmp(cp,"RQTS",4)==0) {
cmdtype=RQTS;
cp += 7;
}
else if(strncmp(cp,"RQLS",4)==0) {
cmdtype=RQLS;
cp += 5;
}
else
return;
switch( cmdtype ) {
case 1:
case 2:
case RQTS:
/*
* Check time code format of TRAK 8810
*/
@ -598,6 +615,12 @@ trak_receive(rbufp)
return;
}
break;
case RQLS:
/*
* reply for leap second request
*/
if (cp[0] !='0' || cp[1] != '0' ) gps->leap = LEAP_ADDSECOND;
return;
default:
return;
@ -627,8 +650,10 @@ trak_receive(rbufp)
return;
}
if (!gps->polled) return;
/*
* Test for synchronization
* Test for synchronization Check for quality byte.
*/
/*
switch( cp[15] ) {
@ -646,9 +671,20 @@ trak_receive(rbufp)
break;
}
*/
gps->lasttime = current_time;
if (!gps->polled) return;
if( cp[15] == '0') /* TRAK derailed from tracking satellites */
{
gps->leap = LEAP_NOTINSYNC;
gps->noreply++;
trak_report_event(gps, CEVNT_TIMEOUT);
}
else
{
gps->lasttime = current_time;
if( gps->lastevent == CEVNT_TIMEOUT ) {
gps->status = CEVNT_NOMINAL;
trak_report_event(gps, CEVNT_NOMINAL);
}
}
/*
* Now, compute the reference time value. Use the heavy
@ -848,7 +884,7 @@ trak_poll(unit, peer)
#endif
gps->polls++;
/*
* may be polled every 64 seconds
* may be polled every 16 seconds (minpoll 4)
*/
gps->polled = 1;
}
@ -906,7 +942,8 @@ trak_control(unit, in, out)
out->flags = sloppyclockflag[unit];
if (unitinuse[unit]) {
gps = gpsunits[unit];
out->lencode = LENTOC;
out->lencode = gps->lencode; /* LENTOC */;
out->lastcode = gps->lastcode;
out->timereset = current_time - gps->timestarted;
out->polls = gps->polls;
out->noresponse = gps->noreply;