summaryrefslogtreecommitdiffstats
path: root/usr.sbin/xntpd/parse
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1994-09-29 23:04:24 +0000
committerwollman <wollman@FreeBSD.org>1994-09-29 23:04:24 +0000
commit1cba639cb2d728cbbb3866d923f8826a01269414 (patch)
tree18dfbc130c063c415f026919cb34f9b7d2c18322 /usr.sbin/xntpd/parse
parent2bf66335a61004f895541f2c64c7fb1508224e34 (diff)
parent96f7e86b724c797f2b44beaaf956cf14550e57df (diff)
downloadFreeBSD-src-1cba639cb2d728cbbb3866d923f8826a01269414.zip
FreeBSD-src-1cba639cb2d728cbbb3866d923f8826a01269414.tar.gz
This commit was generated by cvs2svn to compensate for changes in r3215,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'usr.sbin/xntpd/parse')
-rw-r--r--usr.sbin/xntpd/parse/Makefile.kernel14
-rw-r--r--usr.sbin/xntpd/parse/Makefile.tmpl4
-rw-r--r--usr.sbin/xntpd/parse/README.new_clocks44
-rw-r--r--usr.sbin/xntpd/parse/clk_dcf7000.c19
-rw-r--r--usr.sbin/xntpd/parse/clk_meinberg.c29
-rw-r--r--usr.sbin/xntpd/parse/clk_rawdcf.c45
-rw-r--r--usr.sbin/xntpd/parse/clk_schmid.c30
-rw-r--r--usr.sbin/xntpd/parse/clk_trimtaip.c140
-rw-r--r--usr.sbin/xntpd/parse/clk_trimtsip.c471
-rw-r--r--usr.sbin/xntpd/parse/parse.c361
-rw-r--r--usr.sbin/xntpd/parse/parse_conf.c15
-rw-r--r--usr.sbin/xntpd/parse/parsesolaris.c61
-rw-r--r--usr.sbin/xntpd/parse/parsestreams.c61
-rw-r--r--usr.sbin/xntpd/parse/util/dcfd.c47
-rw-r--r--usr.sbin/xntpd/parse/util/parsetest.c34
-rw-r--r--usr.sbin/xntpd/parse/util/testdcf.c16
16 files changed, 1087 insertions, 304 deletions
diff --git a/usr.sbin/xntpd/parse/Makefile.kernel b/usr.sbin/xntpd/parse/Makefile.kernel
index aceb0a5..4cd0ace 100644
--- a/usr.sbin/xntpd/parse/Makefile.kernel
+++ b/usr.sbin/xntpd/parse/Makefile.kernel
@@ -2,7 +2,7 @@
# very simple makefile (SunOS!)
#
# Possible defines:
-# DEBUG_DCF: include debug code (STREAMS mechanism and parsing)
+# DEBUG_PARSE: include debug code (STREAMS mechanism and parsing)
# DEBUG_CD: include signal propagation to sun4c LED (sun4c only)
#
# Possible defines (parsestreams variants only):
@@ -30,19 +30,19 @@ parse: parsesolaris.c libparse_kernel.a ../lib/libntp.a
ld -r -o parse parsesolaris.o libparse_kernel.a ../lib/libntp.a
@echo "--- Install 'parse' in /kernel/strmod for automatic loading"
-mparsestreams.o: mparsestreams.o.$(KARCH)
- @echo "--- You may load mparsestreams.o.$(KARCH) via 'modload mparsestreams.o.$(KARCH)' into the kernel"
+mparsestreams.o: mparsestreams.$(KARCH).o
+ @echo "--- You may load mparsestreams.$(KARCH).o via 'modload mparsestreams.$(KARCH).o' into the kernel"
-mparsestreams.o.$(KARCH): parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
+mparsestreams.$(KARCH).o: parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
cc -c -DMICROTIME $(DEFS) -I../include parsestreams.c
ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a \
microtime.o
rm -f parsestreams.o
-parsestreams.o: parsestreams.o.$(KARCH)
- @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o' (put in e.g. /sys/<karch>/OBJ) into the kernel"
+parsestreams.o: parsestreams.$(KARCH).o
+ @echo "--- You may load parsestreams.$(KARCH).o via 'modload parsestreams.o' (put in e.g. /sys/<karch>/OBJ) into the kernel"
-parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
+parsestreams.$(KARCH).o: parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
cc -c $(DEFS) -I../include parsestreams.c
ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a
rm -f parsestreams.o
diff --git a/usr.sbin/xntpd/parse/Makefile.tmpl b/usr.sbin/xntpd/parse/Makefile.tmpl
index 29a3029..781fed6 100644
--- a/usr.sbin/xntpd/parse/Makefile.tmpl
+++ b/usr.sbin/xntpd/parse/Makefile.tmpl
@@ -22,10 +22,10 @@ CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL)
CC= $(COMPILER)
#
SOURCE= parse.c parse_conf.c clk_meinberg.c clk_schmid.c clk_rawdcf.c \
- clk_dcf7000.c clk_trimble.c
+ clk_dcf7000.c clk_trimtaip.c clk_trimtsip.c
OBJS= parse.o parse_conf.o clk_meinberg.o clk_schmid.o clk_rawdcf.o \
- clk_dcf7000.o clk_trimble.o
+ clk_dcf7000.o clk_trimtaip.o clk_trimtsip.o
all:
@echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) | \
diff --git a/usr.sbin/xntpd/parse/README.new_clocks b/usr.sbin/xntpd/parse/README.new_clocks
index 8fdd7cb..5b2d29e 100644
--- a/usr.sbin/xntpd/parse/README.new_clocks
+++ b/usr.sbin/xntpd/parse/README.new_clocks
@@ -15,16 +15,16 @@ Make a conversion module (parse/clk_*.c)
You will have to convert the data from a string into a struct clocktime:
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 utcoffset; /* true utc time instead of date/time */
- LONG flags; /* current clock status */
+ long flags; /* current clock status */
};
Conversion is usually simple and straight forward. For the flags following
@@ -87,14 +87,14 @@ Make a conversion module (parse/clk_*.c)
struct clockformat
{
- unsigned LONG (*convert)();
+ u_long (*convert)();
/* conversion routine - your routine - cvt_<yourclock> */
void (*syncevt)();
/* routine for handling RS232 sync events (time stamps) - usually sync_simple */
- unsigned LONG (*syncpps)();
+ u_long (*syncpps)();
/* PPS input routine - usually pps_simple */
- unsigned LONG (*synth)();
- /* time code synthesizer - usually not used - (LONG (*)())0 */
+ u_long (*synth)();
+ /* time code synthesizer - usually not used - (long (*)())0 */
void *data;
/* local parameters - any parameters/data/configuration info your conversion
routine might need */
@@ -102,7 +102,7 @@ struct clockformat
/* clock format name - Name of the time code */
unsigned short length;
/* maximum length of data packet for your clock format */
- unsigned LONG flags;
+ u_long flags;
/* information for the parser what to look for */
struct timeval timeout;
/* buffer restart after timeout (us) - some clocks preceede new data by
@@ -148,7 +148,7 @@ xntpd/refclock_parse.c
(see all the other clocks for example)
struct clockinfo
{
- U_LONG cl_flags; /* operation flags (io modes) */
+ u_long cl_flags; /* operation flags (io modes) */
PARSE_F_NOPOLLONLY always do async io - read whenever input comes
PARSE_F_POLLONLY never do async io - only read when expecting data
PARSE_F_PPSPPS use loopfilter PPS code (CIOGETEV)
@@ -166,10 +166,10 @@ xntpd/refclock_parse.c
local data for polling routines
u_fp cl_rootdelay; /* rootdelay */
NTP rottdelay estimate (usually 0)
- U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional par
+ u_long cl_basedelay; /* current offset - unsigned l_fp fractional par
time (fraction) by which the RS232 time code is delayed from the actual time.
t */
- U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional
+ u_long cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional
time (fraction) by which the PPS time stamp is delayed (usually 0)
part */
char *cl_id; /* ID code (usually "DCF") */
@@ -181,14 +181,14 @@ xntpd/refclock_parse.c
as in clk_*.c clockformat.
u_char cl_type; /* clock type (ntp control) */
Type if clock as in clock status word (ntp control messages) - usually 0
- U_LONG cl_maxunsync; /* time to trust oscillator after loosing synch
+ u_long cl_maxunsync; /* time to trust oscillator after loosing synch
*/
seconds a clock can be trusted after loosing synchronisation.
- U_LONG cl_cflag; /* terminal io flags */
- U_LONG cl_iflag; /* terminal io flags */
- U_LONG cl_oflag; /* terminal io flags */
- U_LONG cl_lflag; /* terminal io flags */
+ u_long cl_cflag; /* terminal io flags */
+ u_long cl_iflag; /* terminal io flags */
+ u_long cl_oflag; /* terminal io flags */
+ u_long cl_lflag; /* terminal io flags */
termio*.h tty modes.
} clockinfo[] = {
...,<other clocks>,...
diff --git a/usr.sbin/xntpd/parse/clk_dcf7000.c b/usr.sbin/xntpd/parse/clk_dcf7000.c
index 8b55e2f..208e529 100644
--- a/usr.sbin/xntpd/parse/clk_dcf7000.c
+++ b/usr.sbin/xntpd/parse/clk_dcf7000.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.11 1994/02/02 17:45:14 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.12 1994/05/30 10:19:57 kardel Exp
*
- * clk_dcf7000.c,v 3.11 1994/02/02 17:45:14 kardel Exp
+ * clk_dcf7000.c,v 3.12 1994/05/30 10:19:57 kardel Exp
*
* ELV DCF7000 module
*
@@ -35,18 +35,20 @@ static struct format dcf7000_fmt =
0
};
-static unsigned LONG cvt_dcf7000();
+static u_long cvt_dcf7000();
clockformat_t clock_dcf7000 =
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_dcf7000, /* ELV DCF77 conversion */
syn_simple, /* easy time stamps */
- (unsigned LONG (*)())0, /* no direct PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no direct PPS monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&dcf7000_fmt, /* conversion configuration */
"ELV DCF7000", /* ELV clock */
24, /* string buffer */
F_END|SYNC_END, /* END packet delimiter / synchronisation */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\0',
'\r',
@@ -58,7 +60,7 @@ clockformat_t clock_dcf7000 =
*
* convert dcf7000 type format
*/
-static unsigned LONG
+static u_long
cvt_dcf7000(buffer, size, format, clock)
register char *buffer;
register int size;
@@ -89,7 +91,7 @@ cvt_dcf7000(buffer, size, format, clock)
else
{
char *f = &buffer[format->field_offsets[O_FLAGS].offset];
- LONG flags;
+ long flags;
clock->flags = 0;
clock->usecond = 0;
@@ -121,6 +123,9 @@ cvt_dcf7000(buffer, size, format, clock)
* History:
*
* clk_dcf7000.c,v
+ * Revision 3.12 1994/05/30 10:19:57 kardel
+ * LONG cleanup
+ *
* Revision 3.11 1994/02/02 17:45:14 kardel
* rcs ids fixed
*
diff --git a/usr.sbin/xntpd/parse/clk_meinberg.c b/usr.sbin/xntpd/parse/clk_meinberg.c
index 69f88b9..6e3b224 100644
--- a/usr.sbin/xntpd/parse/clk_meinberg.c
+++ b/usr.sbin/xntpd/parse/clk_meinberg.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.15 1994/05/30 10:19:59 kardel Exp
*
- * clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp
+ * clk_meinberg.c,v 3.15 1994/05/30 10:19:59 kardel Exp
*
* Meinberg clock support
*
@@ -136,48 +136,54 @@ static struct format meinberg_fmt[] =
}
};
-static unsigned LONG cvt_meinberg();
-static unsigned LONG cvt_mgps();
+static u_long cvt_meinberg();
+static u_long cvt_mgps();
clockformat_t clock_meinberg[] =
{
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_meinberg, /* Meinberg conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
pps_simple, /* easy PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&meinberg_fmt[0], /* conversion configuration */
"Meinberg Standard", /* Meinberg simple format - beware */
32, /* string buffer */
F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\2',
'\3',
'\0'
},
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_meinberg, /* Meinberg conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
pps_simple, /* easy PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&meinberg_fmt[1], /* conversion configuration */
"Meinberg Extended", /* Meinberg enhanced format */
32, /* string buffer */
F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\2',
'\3',
'\0'
},
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_mgps, /* Meinberg GPS166 conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
pps_simple, /* easy PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&meinberg_fmt[2], /* conversion configuration */
"Meinberg GPS Extended", /* Meinberg FAU GPS format */
70, /* string buffer */
F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\2',
'\3',
@@ -190,7 +196,7 @@ clockformat_t clock_meinberg[] =
*
* convert simple type format
*/
-static unsigned LONG
+static u_long
cvt_meinberg(buffer, size, format, clock)
register char *buffer;
register int size;
@@ -305,7 +311,7 @@ cvt_meinberg(buffer, size, format, clock)
*
* convert Meinberg GPS format
*/
-static unsigned LONG
+static u_long
cvt_mgps(buffer, size, format, clock)
register char *buffer;
register int size;
@@ -335,7 +341,7 @@ cvt_mgps(buffer, size, format, clock)
}
else
{
- LONG h;
+ long h;
char *f = &buffer[format->field_offsets[O_FLAGS].offset];
clock->flags = PARSEB_S_LEAP|PARSEB_S_POSITION;
@@ -422,6 +428,9 @@ cvt_mgps(buffer, size, format, clock)
* History:
*
* clk_meinberg.c,v
+ * Revision 3.15 1994/05/30 10:19:59 kardel
+ * LONG cleanup
+ *
* Revision 3.14 1994/02/20 13:04:37 kardel
* parse add/delete second support
*
diff --git a/usr.sbin/xntpd/parse/clk_rawdcf.c b/usr.sbin/xntpd/parse/clk_rawdcf.c
index 6b02031..296af9e 100644
--- a/usr.sbin/xntpd/parse/clk_rawdcf.c
+++ b/usr.sbin/xntpd/parse/clk_rawdcf.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.16 1994/05/31 20:02:40 kardel Exp
*
- * clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp
+ * clk_rawdcf.c,v 3.16 1994/05/31 20:02:40 kardel Exp
*
* Raw DCF77 pulse clock support
*
@@ -79,12 +79,13 @@
* 59 - usually missing (minute indication), except for leap insertion
*/
-static unsigned LONG cvt_rawdcf();
-static unsigned LONG pps_rawdcf();
-static unsigned LONG snt_rawdcf();
+static u_long cvt_rawdcf();
+static u_long pps_rawdcf();
+static u_long snt_rawdcf();
clockformat_t clock_rawdcf =
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_rawdcf, /* raw dcf input conversion */
(void (*)())0, /* no character bound synchronisation */
pps_rawdcf, /* examining PPS information */
@@ -94,6 +95,7 @@ clockformat_t clock_rawdcf =
61, /* bit buffer */
SYNC_ONE|SYNC_ZERO|SYNC_TIMEOUT|SYNC_SYNTHESIZE|CVT_FIXEDONLY,
/* catch all transitions, buffer restart on timeout, fixed configuration only */
+ 0, /* no private data (currently in input buffer) */
{ 1, 500000}, /* restart after 1.5 seconds */
'\0',
'\0',
@@ -155,12 +157,12 @@ static struct partab
#define DCF_Z_MET 0x2
#define DCF_Z_MED 0x1
-static unsigned LONG ext_bf(buf, idx, zero)
+static u_long ext_bf(buf, idx, zero)
register char *buf;
register int idx;
register char *zero;
{
- register unsigned LONG sum = 0;
+ register u_long sum = 0;
register int i, first;
first = rawdcfcode[idx].offset;
@@ -189,7 +191,7 @@ static unsigned pcheck(buf, idx, zero)
return psum;
}
-static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
+static u_long convert_rawdcf(buffer, size, dcfparam, clock)
register unsigned char *buffer;
register int size;
register struct dcfparam *dcfparam;
@@ -284,9 +286,9 @@ static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
if (ext_bf(buffer, DCF_R, dcfparam->zerobits))
clock->flags |= PARSEB_ALTERNATE;
- parseprintf(DD_RAWDCF,("parse: convert_rawdcf: TIME CODE OK: %d:%d, %d.%d.%d, flags 0x%x\n",
- clock->hour, clock->minute, clock->day, clock->month, clock->year,
- clock->flags));
+ parseprintf(DD_RAWDCF,("parse: convert_rawdcf: TIME CODE OK: %d:%d, %d.%d.%d, flags 0x%lx\n",
+ (int)clock->hour, (int)clock->minute, (int)clock->day, (int)clock->month,(int) clock->year,
+ (u_long)clock->flags));
return CVT_OK;
}
else
@@ -307,7 +309,7 @@ static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
* raw dcf input routine - needs to fix up 50 baud
* characters for 1/0 decision
*/
-static unsigned LONG cvt_rawdcf(buffer, size, param, clock)
+static u_long cvt_rawdcf(buffer, size, param, clock)
register unsigned char *buffer;
register int size;
register void *param;
@@ -465,12 +467,12 @@ static unsigned LONG cvt_rawdcf(buffer, size, param, clock)
* also ones and zeros (which is easy)
*/
/*ARGSUSED*/
-static unsigned LONG pps_rawdcf(parseio, status, ptime)
+static u_long pps_rawdcf(parseio, status, ptime)
register parse_t *parseio;
register int status;
register timestamp_t *ptime;
{
- if (!status)
+ if (status)
{
parseio->parse_dtime.parse_ptime = *ptime;
parseio->parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
@@ -480,12 +482,12 @@ static unsigned LONG pps_rawdcf(parseio, status, ptime)
}
/*ARGSUSED*/
-static unsigned LONG snt_rawdcf(parseio, ptime)
+static u_long snt_rawdcf(parseio, ptime)
register parse_t *parseio;
register timestamp_t *ptime;
{
clocktime_t clock;
- unsigned LONG cvtrtc;
+ u_long cvtrtc;
time_t t;
/*
@@ -529,7 +531,16 @@ static unsigned LONG snt_rawdcf(parseio, ptime)
/*
* History:
*
- * clk_rawdcf.c,v
+ * clk_rawdcf.c,v $
+ * Revision 3.16 1994/05/31 20:02:40 kardel
+ * sync on ONE transition
+ *
+ * Revision 3.15 1994/05/30 10:20:01 kardel
+ * LONG cleanup
+ *
+ * Revision 3.14 1994/05/12 12:49:09 kardel
+ * printf fmt/arg cleanup
+ *
* Revision 3.13 1994/03/10 19:00:43 kardel
* clear utctime field to avoid confusion on synthesize time stamps
*
diff --git a/usr.sbin/xntpd/parse/clk_schmid.c b/usr.sbin/xntpd/parse/clk_schmid.c
index 8129474..d15ba90 100644
--- a/usr.sbin/xntpd/parse/clk_schmid.c
+++ b/usr.sbin/xntpd/parse/clk_schmid.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.16 1994/05/30 10:20:03 kardel Exp
*
- * clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp
+ * clk_schmid.c,v 3.16 1994/05/30 10:20:03 kardel Exp
*
* Schmid clock support
*
@@ -58,18 +58,20 @@
#define WS_MEST 0x04
#define WS_LEAP 0x10
-static unsigned LONG cvt_schmid();
+static u_long cvt_schmid();
clockformat_t clock_schmid =
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_schmid, /* Schmid conversion */
syn_simple, /* easy time stamps */
- (unsigned LONG (*)())0, /* not direct PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* not direct PPS monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)0, /* conversion configuration */
"Schmid", /* Schmid receiver */
12, /* binary data buffer */
F_END|SYNC_START, /* END packet delimiter / synchronisation */
+ 0, /* no private data (complete messages) */
{ 0, 0},
'\0',
(unsigned char)'\375',
@@ -77,21 +79,20 @@ clockformat_t clock_schmid =
};
-static unsigned LONG
+static u_long
cvt_schmid(buffer, size, format, clock)
- register char *buffer;
+ register unsigned char *buffer;
register int size;
register struct format *format;
register clocktime_t *clock;
{
- if ((size != 11) || (buffer[10] != '\375'))
+ if ((size != 11) || (buffer[10] != (unsigned char)'\375'))
{
return CVT_NONE;
}
else
{
- if (buffer[0] > 23 || buffer[1] > 59 || buffer[2] > 59 || buffer[3] > 9 /* Time */
- || buffer[0] < 0 || buffer[1] < 0 || buffer[2] < 0 || buffer[3] < 0)
+ if (buffer[0] > 23 || buffer[1] > 59 || buffer[2] > 59 || buffer[3] > 9) /* Time */
{
return CVT_FAIL|CVT_BADTIME;
}
@@ -168,6 +169,15 @@ cvt_schmid(buffer, size, format, clock)
* History:
*
* clk_schmid.c,v
+ * Revision 3.16 1994/05/30 10:20:03 kardel
+ * LONG cleanup
+ *
+ * Revision 3.15 1994/05/12 12:34:48 kardel
+ * data type cleanup
+ *
+ * Revision 3.14 1994/04/12 14:56:31 kardel
+ * fix declaration
+ *
* Revision 3.13 1994/02/20 13:04:41 kardel
* parse add/delete second support
*
diff --git a/usr.sbin/xntpd/parse/clk_trimtaip.c b/usr.sbin/xntpd/parse/clk_trimtaip.c
new file mode 100644
index 0000000..87538f1
--- /dev/null
+++ b/usr.sbin/xntpd/parse/clk_trimtaip.c
@@ -0,0 +1,140 @@
+#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMTAIP)
+/*
+ * $Header: /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.9 1994/02/02 17:45:27 kardel Exp $
+ *
+ * Trimble SV6 clock support
+ */
+
+#include "sys/types.h"
+#include "sys/time.h"
+#include "sys/errno.h"
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+/* 0000000000111111111122222222223333333 / char
+ * 0123456789012345678901234567890123456 \ posn
+ * >RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx< Actual
+ * ----33445566600112222BB7__-_____--99- Parse
+ * >RTM 1 ;* <", Check
+ */
+
+#define hexval(x) (('0' <= (x) && (x) <= '9') ? (x) - '0' : \
+ ('a' <= (x) && (x) <= 'f') ? (x) - 'a' + 10 : \
+ ('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \
+ -1)
+#define O_USEC O_WDAY
+#define O_GPSFIX O_FLAGS
+#define O_CHKSUM O_UTCHOFFSET
+static struct format trimsv6_fmt =
+{ { { 13, 2 }, {15, 2}, { 17, 4}, /* Day, Month, Year */
+ { 4, 2 }, { 6, 2}, { 8, 2}, /* Hour, Minute, Second */
+ { 10, 3 }, {23, 1}, { 0, 0}, /* uSec, FIXes (WeekDAY, FLAGS, ZONE) */
+ { 34, 2 }, { 0, 0}, { 21, 2}, /* cksum, -, utcS (UTC[HMS]OFFSET) */
+ },
+ ">RTM 1 ;* <",
+ 0
+};
+
+static unsigned LONG cvt_trimtaip();
+
+clockformat_t clock_trimtaip =
+{
+ (unsigned LONG (*)())0, /* no input handling */
+ cvt_trimtaip, /* Trimble conversion */
+ syn_simple, /* easy time stamps for RS232 (fallback) */
+ pps_simple, /* easy PPS monitoring */
+ (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (void *)&trimsv6_fmt, /* conversion configuration */
+ "Trimble SV6/TAIP",
+ 37, /* string buffer */
+ F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data */
+ { 0, 0},
+ '>',
+ '<',
+ '\0'
+};
+
+static unsigned LONG
+cvt_trimtaip(buffer, size, format, clock)
+ register char *buffer;
+ register int size;
+ register struct format *format;
+ register clocktime_t *clock;
+{
+ LONG gpsfix;
+ u_char calc_csum = 0;
+ long recv_csum;
+ int i;
+
+ if (!Strok(buffer, format->fixed_string)) return CVT_NONE;
+#define OFFS(x) format->field_offsets[(x)].offset
+#define STOI(x, y) \
+ Stoi(&buffer[OFFS(x)], y, \
+ format->field_offsets[(x)].length)
+ if ( STOI(O_DAY, &clock->day) ||
+ STOI(O_MONTH, &clock->month) ||
+ STOI(O_YEAR, &clock->year) ||
+ STOI(O_HOUR, &clock->hour) ||
+ STOI(O_MIN, &clock->minute) ||
+ STOI(O_SEC, &clock->second) ||
+ STOI(O_USEC, &clock->usecond)||
+ STOI(O_GPSFIX, &gpsfix)
+ ) return CVT_FAIL|CVT_BADFMT;
+
+ clock->usecond *= 1000;
+ /* Check that the checksum is right */
+ for (i=OFFS(O_CHKSUM)-1; i >= 0; i--) calc_csum ^= buffer[i];
+ recv_csum = (hexval(buffer[OFFS(O_CHKSUM)]) << 4) |
+ hexval(buffer[OFFS(O_CHKSUM)+1]);
+ if (recv_csum < 0) return CVT_FAIL|CVT_BADTIME;
+ if (((u_char) recv_csum) != calc_csum) return CVT_FAIL|CVT_BADTIME;
+
+ clock->utcoffset = 0;
+
+ /* What should flags be set to ? */
+ clock->flags = PARSEB_UTC;
+
+ /* if the current GPS fix is 9 (unknown), reject */
+ if (0 > gpsfix || gpsfix > 9) clock->flags |= PARSEB_POWERUP;
+
+ return CVT_OK;
+}
+#endif /* defined(PARSE) && defined(CLOCK_TRIMTAIP) */
+
+/*
+ * History:
+ *
+ * $Log: clk_trimble.c,v $
+ * Revision 3.9 1994/02/02 17:45:27 kardel
+ * rcs ids fixed
+ *
+ * Revision 3.7 1994/01/25 19:05:17 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.6 1993/10/30 09:44:45 kardel
+ * conditional compilation flag cleanup
+ *
+ * Revision 3.5 1993/10/09 15:01:35 kardel
+ * file structure unified
+ *
+ * revision 3.4
+ * date: 1993/10/08 14:44:51; author: kardel;
+ * trimble - initial working version
+ *
+ * revision 3.3
+ * date: 1993/10/03 19:10:50; author: kardel;
+ * restructured I/O handling
+ *
+ * revision 3.2
+ * date: 1993/09/27 21:07:17; author: kardel;
+ * Trimble alpha integration
+ *
+ * revision 3.1
+ * date: 1993/09/26 23:40:29; author: kardel;
+ * new parse driver logic
+ *
+ */
diff --git a/usr.sbin/xntpd/parse/clk_trimtsip.c b/usr.sbin/xntpd/parse/clk_trimtsip.c
new file mode 100644
index 0000000..f622bea
--- /dev/null
+++ b/usr.sbin/xntpd/parse/clk_trimtsip.c
@@ -0,0 +1,471 @@
+#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMTSIP)
+/*
+ * $Header: /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.9 1994/02/02 17:45:27 kardel Exp $
+ *
+ * Trimble TSIP support - CURRENTLY VERY MUCH UNDER CONSTRUCTION
+ */
+
+#include "sys/types.h"
+#include "sys/time.h"
+#include "sys/errno.h"
+
+#include "ntp_syslog.h"
+#include "ntp_types.h"
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+/*
+ * Trimble TSIP parser
+ *
+ * The receiver uses a serial message protocol called Trimble Standard
+ * Interface Protocol (it can support others but this driver only supports
+ * TSIP). Messages in this protocol have the following form:
+ *
+ * <DLE><id> ... <data> ... <DLE><ETX>
+ *
+ * Any bytes within the <data> portion of value 10 hex (<DLE>) are doubled
+ * on transmission and compressed back to one on reception. Otherwise
+ * the values of data bytes can be anything. The serial interface is RS-422
+ * asynchronous using 9600 baud, 8 data bits with odd party (**note** 9 bits
+ * in total!), and 1 stop bit. The protocol supports byte, integer, single,
+ * and double datatypes. Integers are two bytes, sent most significant first.
+ * Singles are IEEE754 single precision floating point numbers (4 byte) sent
+ * sign & exponent first. Doubles are IEEE754 double precision floating point
+ * numbers (8 byte) sent sign & exponent first.
+ * The receiver supports a large set of messages, only a small subset of
+ * which are used here. From driver to receiver the following are used:
+ *
+ * ID Description
+ *
+ * 21 Request current time
+ * 22 Mode Select
+ * 2C Set/Request operating parameters
+ * 2F Request UTC info
+ * 35 Set/Request I/O options
+ *
+ * From receiver to driver the following are recognised:
+ *
+ * ID Description
+ *
+ * 41 GPS Time
+ * 44 Satellite selection, PDOP, mode
+ * 46 Receiver health
+ * 4B Machine code/status
+ * 4C Report operating parameters (debug only)
+ * 4F UTC correction data (used to get leap second warnings)
+ * 55 I/O options (debug only)
+ *
+ * All others are accepted but ignored.
+ *
+ */
+
+extern int debug;
+
+struct trimble
+{
+ u_char t_in_pkt; /* first DLE received */
+ u_char t_dle; /* subsequent DLE received */
+ u_char t_status; /* last status */
+ u_char t_error; /* last error */
+ u_short t_week; /* GPS week */
+ u_short t_weekleap; /* GPS week of next/last week */
+ u_short t_dayleap; /* day in week */
+ u_short t_gpsutc; /* GPS - UTC offset */
+ u_short t_gpsutcleap; /* offset at next/last leap */
+ u_char t_operable; /* receiver feels OK */
+ u_char t_leap; /* possible leap warning */
+};
+
+static unsigned LONG inp_tsip();
+static unsigned LONG cvt_trimtsip();
+
+struct clockformat clock_trimtsip =
+{
+ inp_tsip, /* Trimble TSIP input handler */
+ cvt_trimtsip, /* Trimble TSIP conversion */
+ syn_simple, /* easy time stamps for RS232 (fallback) */
+ pps_simple, /* easy PPS monitoring */
+ (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (void *)0, /* no configuration data */
+ "Trimble SV6/TSIP",
+ 128, /* input buffer */
+ CVT_FIXEDONLY, /* we do our own input handling */
+ sizeof(struct trimble), /* no private data */
+ { 0, 0},
+ '\0',
+ '\0',
+ '\0'
+};
+
+#define ADDSECOND 0x01
+#define DELSECOND 0x02
+
+#define DLE 0x10
+#define ETX 0x03
+
+static unsigned LONG inp_tsip(parseio, ch, ctime)
+ register parse_t *parseio;
+ register unsigned char ch;
+ register timestamp_t *ctime;
+{
+ register struct trimble *t = (struct trimble *)parseio->parse_pdata;
+
+ if (!t)
+ return 0; /* local data not allocated - sigh! */
+
+ if (!t->t_in_pkt && ch != DLE) {
+ /* wait for start of packet */
+#ifdef DEBUG
+ if (debug > 2)
+ printf("sv6+ discarding %2.2x\n", ch);
+#endif
+ return 0;
+ }
+
+ switch (ch) {
+ case DLE:
+ if (!t->t_in_pkt) {
+ t->t_dle = 0;
+ t->t_in_pkt = 1;
+ parseio->parse_index = 0;
+ parseio->parse_data[parseio->parse_index++] = ch;
+ parseio->parse_dtime.parse_stime = *ctime; /* pick up time stamp at packet start */
+ } else if (t->t_dle) {
+ /* Double DLE -> insert a DLE */
+ t->t_dle = 0;
+ parseio->parse_data[parseio->parse_index++] = DLE;
+ } else
+ t->t_dle = 1;
+ break;
+ case ETX:
+ if (t->t_dle) {
+ /* DLE,ETX -> end of packet */
+ parseio->parse_data[parseio->parse_index++] = DLE;
+ parseio->parse_data[parseio->parse_index++] = ch;
+ parseio->parse_data[parseio->parse_index] = '\0';
+ parseio->parse_ldsize = parseio->parse_index+1;
+ bcopy(parseio->parse_data, parseio->parse_ldata, parseio->parse_ldsize);
+ t->t_in_pkt = t->t_dle = 0;
+ return 1;
+ }
+ /* fall into ... */
+ default:
+ t->t_dle = 0;
+ parseio->parse_data[parseio->parse_index++] = ch;
+ }
+
+ return (parseio->parse_index == parseio->parse_dsize-1); /* buffer full - attempt to parse (likely to fail) */
+}
+
+#define GPSORIGIN 2524953600 /* NTP origin - GPS origin in seconds */
+#define SECSPERWEEK 604800 /* seconds per week - GPS tells us about weeks */
+#define L_UF_SCALE 4294967296.0 /* scale a float fraction to l_uf units */
+
+/*
+ * mapping union for ints, floats, doubles for both input & output to the
+ * receiver
+ *
+ * CAVEAT: must disappear - non portable
+ */
+
+union {
+ u_char bd[8];
+ int iv;
+ float fv;
+ double dv;
+} uval;
+
+static float getflt P((u_char *));
+static double getdbl P((u_char *));
+static int getint P((u_char *));
+
+/*
+ * cvt_trimtsip
+ *
+ * convert TSIP type format
+ */
+static unsigned LONG
+cvt_trimtsip(buffer, size, format, clock, t)
+ register char *buffer;
+ register int size;
+ register struct format *format;
+ register clocktime_t *clock;
+ register struct trimble *t;
+{
+#define mb(_X_) (buffer[2+(_X_)]) /* shortcut for buffer access */
+ register u_char cmd;
+
+ if (!t) {
+#ifdef DEBUG
+ if (debug) printf("sv6+ BAD call (t=0)\n");
+#endif
+ return CVT_NONE; /* local data not allocated - sigh! */
+ }
+
+ if ((size < 4) ||
+ (buffer[0] != DLE) ||
+ (buffer[size-1] != ETX) ||
+ (buffer[size-2] != DLE))
+ {
+#ifdef DEBUG
+ if (debug > 2) {
+ int i;
+
+ printf("sv6+ BAD packet, size %d:\n ", size);
+ for (i = 0; i < size; i++) {
+ printf ("%2.2x, ", buffer[i]&0xff);
+ if (i%16 == 15) printf("\n\t");
+ }
+ printf("\n");
+ }
+#endif
+ return CVT_NONE;
+ }
+ else
+ {
+ cmd = buffer[1];
+
+#ifdef DEBUG
+ if (debug > 1)
+ switch(cmd)
+ {
+ case 0x41:
+ printf("sv6+ gps time: %f, %d, %f\n",
+ getflt(&mb(0)), getint(&mb(4)), getflt(&mb(6)));
+ break;
+
+ case 0x44:
+ printf("sv6+ sats: %2x, %2d %2d %2d %2d, %.2f\n",
+ mb(0), mb(1), mb(2), mb(3), mb(4), getflt(&mb(5)));
+ break;
+
+ case 0x45:
+ printf("sv6+ software: %d.%d (19%d/%d/%d)\n",
+ mb(0)&0xff, mb(1)&0xff, mb(4)&0xff, mb(2)&0xff, mb(3)&0xff);
+ break;
+
+ case 0x46:
+ printf("sv6+ health: %2x %2x\n",
+ mb(0), mb(1));
+ break;
+
+ case 0x48:
+ printf("sv6+ gps message: '%.22s'\n", &mb(0));
+ break;
+
+ case 0x4b:
+ printf("sv6+ status: %2d %2x\n",
+ mb(0), mb(1));
+ break;
+
+ case 0x4c:
+ printf("sv6+ op params: %2x %.1f %.1f %.1f %.1f\n",
+ mb(0), getflt(&mb(1)), getflt(&mb(5)),
+ getflt(&mb(9)), getflt(&mb(13)));
+ break;
+
+ case 0x4f:
+ printf("sv6+ utc data: %.3e %.3e %d %d %d %d %d\n",
+ getdbl(&mb(0)), getflt(&mb(8)), getint(&mb(18)),
+ getint(&mb(12)), getint(&mb(20)), getint(&mb(22)), getint(&mb(24)));
+ break;
+
+ case 0x54:
+ /*printf("sv6+ bias and rate: %.1fm %.2fm/s at %.1fs\n",
+ getflt(&mb(0)), getflt(&mb(4)), getflt(&mb(8))); ignore it*/
+ break;
+
+ case 0x55:
+ printf("sv6+ io opts: %2x %2x %2x %2x\n",
+ mb(0), mb(1), mb(2), mb(3));
+ break;
+
+ case 0x8f:
+ {
+#define RTOD (180.0 / 3.1415926535898)
+ double lat = getdbl(&mb(2));
+ double lng = getdbl(&mb(10));
+ printf("sv6+ last fix: %2.2x %d lat %f %c, long %f %c, alt %.2fm\n",
+ mb(1)&0xff, mb(40)&0xff,
+ ((lat < 0) ? (-lat) : (lat))*RTOD, (lat < 0 ? 'S' : 'N'),
+ ((lng < 0) ? (-lng) : (lng))*RTOD, (lng < 0 ? 'W' : 'E'),
+ getdbl(&mb(18)));
+ }
+ break;
+
+ case 0x40:
+ case 0x5b:
+ case 0x6d:
+ /* Ignore */
+ break;
+
+ default:
+ printf("sv6+ cmd ignored: %2x, length: %d\n",
+ cmd, size);
+ break;
+ }
+#endif /* DEBUG */
+
+ switch(cmd)
+ {
+ case 0x41:
+ { /* GPS time */
+ float secs = getflt(&mb(0));
+ int week = getint(&mb(4));
+ int secint;
+ float secfrac;
+ l_fp gpstime, off;
+
+ if (secs <= 0)
+ {
+#ifdef DEBUG
+ if (debug)
+ printf("sv6+ seconds <= 0 (%e), setting POWERUP\n");
+#endif
+ clock->flags = PARSEB_POWERUP;
+ return CVT_OK;
+ }
+
+ /* time OK */
+ secint = secs; /* integer part, hopefully */
+ secfrac = secs - secint; /* 0.0 <= secfrac < 1.0 */
+ secint -= getflt(&mb(6)); /* UTC offset */
+ gpstime.l_ui = week*SECSPERWEEK + secint + GPSORIGIN; /* convert to NTP time */
+ gpstime.l_uf = secfrac*L_UF_SCALE;
+
+ clock->utctime = gpstime.l_ui - JAN_1970;
+ TSFTOTVU(gpstime.l_uf, clock->usecond);
+
+ if (t->t_leap == ADDSECOND)
+ clock->flags |= PARSEB_LEAPADD;
+
+ if (t->t_leap == DELSECOND)
+ clock->flags |= PARSEB_LEAPDEL;
+
+ if (t->t_operable)
+ clock->flags &= ~(PARSEB_NOSYNC|PARSEB_POWERUP);
+ else
+ clock->flags |= PARSEB_NOSYNC;
+ return CVT_OK;
+
+ } /* case 0x41 */
+ break;
+
+ case 0x46:
+ {
+ /* sv6+ health */
+ u_char status = t->t_status = mb(0);
+ u_char error = t->t_error = mb(1);
+
+ if (status == 0 || status == 9 || status == 10 || status == 11)
+ {
+ if (!t->t_operable)
+ syslog(LOG_ERR, "Trimble clock synced");
+ t->t_operable = 1;
+ }
+ else
+ {
+ if (t->t_operable)
+ syslog(LOG_ERR, "Trimble clock unsynced");
+ t->t_operable = 0;
+ }
+ }
+ break;
+
+ case 0x4f:
+ {
+ /* UTC correction data - derive a leap warning */
+ int tls = t->t_gpsutc = getint(&mb(12)); /* current leap correction (GPS-UTC) */
+ int wnlsf = t->t_weekleap = getint(&mb(20)); /* week no of leap correction */
+ int dn = t->t_dayleap = getint(&mb(22)); /* day in week of leap correction */
+ int tlsf = t->t_gpsutcleap = getint(&mb(24)); /* new leap correction */
+ U_LONG now, leaptime;
+
+ t->t_week = getint(&mb(18)); /* current week no */
+
+ /* this stuff hasn't been tested yet... */
+ now = clock->utctime + JAN_1970; /* now in GPS seconds */
+ leaptime = (wnlsf*7 + dn)*86400; /* time of leap in GPS seconds */
+ if ((leaptime > now) && ((leaptime-now) < 86400*28))
+ {
+ /* generate a leap warning */
+ if (tlsf > tls)
+ t->t_leap = ADDSECOND;
+ else
+ t->t_leap = DELSECOND;
+ }
+ else
+ {
+ t->t_leap = 0;
+ }
+ }
+ break;
+
+ default:
+ /* it's validly formed, but we don't care about it! */
+ break;
+ }
+ }
+ return CVT_SKIP;
+}
+
+/*
+ * getflt, getdbl, getint convert fields in the incoming data into the
+ * appropriate type of item
+ *
+ * CAVEAT: these routines are currently definitely byte order dependent
+ * and assume Representation(float) == IEEE754
+ * These functions MUST be converted to portable versions (especially
+ * converting the float representation into ntp_fp formats in order
+ * to avoid floating point operations at all!
+ */
+
+static float
+getflt(bp)
+ u_char *bp;
+{
+ uval.bd[0] = *bp++;
+ uval.bd[1] = *bp++;
+ uval.bd[2] = *bp++;
+ uval.bd[3] = *bp;
+ return uval.fv;
+}
+
+static double
+getdbl(bp)
+ u_char *bp;
+{
+ uval.bd[0] = *bp++;
+ uval.bd[1] = *bp++;
+ uval.bd[2] = *bp++;
+ uval.bd[3] = *bp++;
+ uval.bd[4] = *bp++;
+ uval.bd[5] = *bp++;
+ uval.bd[6] = *bp++;
+ uval.bd[7] = *bp;
+ return uval.dv;
+}
+
+static int
+getint(bp)
+ u_char *bp;
+{
+ uval.bd[2] = *bp++;
+ uval.bd[3] = *bp;
+ if (uval.bd[2] & 0x80) /* sign-extend */
+ uval.bd[0] = uval.bd[1] = 0xff;
+ else
+ uval.bd[0] = uval.bd[1] = 0;
+ return uval.iv;
+}
+
+#endif /* defined(PARSE) && defined(CLOCK_TRIMTSIP) */
+
+/*
+ * History:
+ *
+ * $Log: clk_trimble.c,v $
+ */
diff --git a/usr.sbin/xntpd/parse/parse.c b/usr.sbin/xntpd/parse/parse.c
index 84bfa39..16c7813 100644
--- a/usr.sbin/xntpd/parse/parse.c
+++ b/usr.sbin/xntpd/parse/parse.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
/*
- * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.27 1994/06/01 08:18:33 kardel Exp
*
- * parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp
+ * parse.c,v 3.27 1994/06/01 08:18:33 kardel Exp
*
* Parser module for reference clock
*
@@ -64,7 +64,7 @@ static char rcsid[] = "parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp";
extern clockformat_t *clockformats[];
extern unsigned short nformats;
-static unsigned LONG timepacket();
+static u_long timepacket();
/*
* strings support usually not in kernel - duplicated, but what the heck
@@ -120,9 +120,9 @@ timedout(parseio, ctime)
delta.tv_usec += 1000000;
}
#else
- extern LONG tstouslo[];
- extern LONG tstousmid[];
- extern LONG tstoushi[];
+ extern long tstouslo[];
+ extern long tstousmid[];
+ extern long tstoushi[];
l_fp delt;
@@ -145,6 +145,8 @@ timedout(parseio, ctime)
/*
* setup_bitmaps
+ * WARNING: NOT TO BE CALLED CONCURRENTLY WITH
+ * parse_ioread, parse_ioend, parse_ioinit
*/
static int
setup_bitmaps(parseio, low, high)
@@ -155,7 +157,7 @@ setup_bitmaps(parseio, low, high)
register unsigned short i;
register int f = 0;
register clockformat_t *fmt;
- register unsigned index, mask;
+ register unsigned short index, mask, plen;
if ((low >= high) ||
(high > nformats))
@@ -167,6 +169,9 @@ setup_bitmaps(parseio, low, high)
bzero(parseio->parse_startsym, sizeof (parseio->parse_startsym));
bzero(parseio->parse_endsym, sizeof (parseio->parse_endsym));
bzero(parseio->parse_syncsym, sizeof (parseio->parse_syncsym));
+
+ plen = 0;
+
parseio->parse_syncflags = 0;
parseio->parse_timeout.tv_sec = 0;
parseio->parse_timeout.tv_usec = 0;
@@ -179,13 +184,16 @@ setup_bitmaps(parseio, low, high)
fmt = clockformats[i];
if (!(parseio->parse_flags & PARSE_FIXED_FMT) &&
- (fmt->flags & CVT_FIXEDONLY))
+ (fmt->flags & CVT_FIXEDONLY)) {
+ if (parseio->parse_dsize < fmt->length)
+ parseio->parse_dsize = fmt->length;
continue;
+ }
if (fmt->flags & F_START)
{
- index = fmt->startsym / 8;
- mask = 1 << (fmt->startsym % 8);
+ index = fmt->startsym >> 3;
+ mask = 1 << (fmt->startsym & 0x7);
if (parseio->parse_endsym[index] & mask)
{
@@ -205,8 +213,8 @@ setup_bitmaps(parseio, low, high)
if (fmt->flags & F_END)
{
- index = fmt->endsym / 8;
- mask = 1 << (fmt->endsym % 8);
+ index = fmt->endsym >> 3;
+ mask = 1 << (fmt->endsym & 0x7);
if (parseio->parse_startsym[index] & mask)
{
@@ -226,12 +234,12 @@ setup_bitmaps(parseio, low, high)
if (fmt->flags & SYNC_CHAR)
{
- parseio->parse_syncsym[fmt->syncsym / 8] |= (1 << (fmt->syncsym % 8));
+ parseio->parse_syncsym[fmt->syncsym >> 3] |= (1 << (fmt->syncsym & 0x7));
}
parseio->parse_syncflags |= fmt->flags & (SYNC_START|SYNC_END|SYNC_CHAR|SYNC_ONE|SYNC_ZERO|SYNC_TIMEOUT|SYNC_SYNTHESIZE);
- if ((fmt->flags & SYNC_TIMEOUT) &&
+ if (((fmt->flags & (SYNC_TIMEOUT|CVT_FIXEDONLY)) == (SYNC_TIMEOUT|CVT_FIXEDONLY)) &&
((parseio->parse_timeout.tv_sec || parseio->parse_timeout.tv_usec) ? timercmp(&parseio->parse_timeout, &fmt->timeout, >) : 1))
{
parseio->parse_timeout = fmt->timeout;
@@ -241,6 +249,13 @@ setup_bitmaps(parseio, low, high)
parseio->parse_dsize = fmt->length;
}
+ if (parseio->parse_pdata)
+ {
+ FREE(parseio->parse_pdata, parseio->parse_plen);
+ parseio->parse_plen = 0;
+ parseio->parse_pdata = (void *)0;
+ }
+
if (!f && ((int)(high - low) > 1))
{
/*
@@ -254,6 +269,27 @@ setup_bitmaps(parseio, low, high)
return 0;
}
+ if ((high - low == 1) && (clockformats[low]->flags & CVT_FIXEDONLY) &&
+ (clockformats[low]->plen))
+ {
+ parseio->parse_plen = clockformats[low]->plen;
+ parseio->parse_pdata = (void *)MALLOC(parseio->parse_plen);
+
+ if (!parseio->parse_pdata)
+ {
+ /*
+ * no memory
+ */
+#ifdef PARSEKERNEL
+ printf("parse: setup_bitmaps: failed: no memory for private data\n");
+#else
+ syslog(LOG_ERR, "parse: setup_bitmaps: failed: no memory for private data\n");
+#endif
+ return 0;
+ }
+ bzero((char *)parseio->parse_pdata, parseio->parse_plen);
+ }
+
return 1;
}
@@ -264,6 +300,9 @@ parse_ioinit(parseio)
{
parseprintf(DD_PARSE, ("parse_iostart\n"));
+ parseio->parse_plen = 0;
+ parseio->parse_pdata = (void *)0;
+
if (!setup_bitmaps(parseio, 0, nformats))
return 0;
@@ -294,6 +333,10 @@ parse_ioend(parseio)
register parse_t *parseio;
{
parseprintf(DD_PARSE, ("parse_ioend\n"));
+
+ if (parseio->parse_pdata)
+ FREE(parseio->parse_pdata, parseio->parse_plen);
+
if (parseio->parse_data)
FREE(parseio->parse_data, parseio->parse_dsize * 2 + 2);
}
@@ -309,24 +352,6 @@ parse_ioread(parseio, ch, ctime)
register unsigned short low, high;
register unsigned index, mask;
- parseprintf(DD_PARSE, ("parse_ioread(0x%x, char=0x%x, ..., ...)\n", (unsigned int)parseio, ch & 0xFF));
-
- if (parseio->parse_flags & PARSE_FIXED_FMT)
- {
- if (!clockformats[parseio->parse_lformat]->convert)
- {
- parseprintf(DD_PARSE, ("parse_ioread: input dropped.\n"));
- return CVT_NONE;
- }
- low = parseio->parse_lformat;
- high = low + 1;
- }
- else
- {
- low = 0;
- high = nformats;
- }
-
/*
* within STREAMS CSx (x < 8) chars still have the upper bits set
* so we normalize the characters by masking unecessary bits off.
@@ -349,114 +374,146 @@ parse_ioread(parseio, ch, ctime)
break;
}
- index = ch / 8;
- mask = 1 << (ch % 8);
+ parseprintf(DD_PARSE, ("parse_ioread(0x%x, char=0x%x, ..., ...)\n", (unsigned int)parseio, ch & 0xFF));
- if ((parseio->parse_syncflags & SYNC_CHAR) &&
- (parseio->parse_syncsym[index] & mask))
+ if (parseio->parse_flags & PARSE_FIXED_FMT)
{
- register clockformat_t *fmt;
- register unsigned short i;
- /*
- * got a sync event - call sync routine
- */
-
- for (i = low; i < high; i++)
+ if (!clockformats[parseio->parse_lformat]->convert)
{
- fmt = clockformats[i];
+ parseprintf(DD_PARSE, ("parse_ioread: input dropped.\n"));
+ return CVT_NONE;
+ }
- if ((fmt->flags & SYNC_CHAR) &&
- (fmt->syncsym == ch))
- {
- parseprintf(DD_PARSE, ("parse_ioread: SYNC_CHAR event\n"));
- if (fmt->syncevt)
- fmt->syncevt(parseio, ctime, fmt->data, SYNC_CHAR);
- }
+ if (clockformats[parseio->parse_lformat]->input)
+ {
+ if (clockformats[parseio->parse_lformat]->input(parseio, ch, ctime))
+ updated = timepacket(parseio); /* got a datagram - process */
+
+ low = high = 0; /* all done - just post processing */
}
- }
-
- if ((((parseio->parse_syncflags & SYNC_START) &&
- (parseio->parse_startsym[index] & mask)) ||
- (parseio->parse_index == 0)) ||
- ((parseio->parse_syncflags & SYNC_TIMEOUT) &&
- timedout(parseio, ctime)))
- {
- register unsigned short i;
- /*
- * packet start - re-fill buffer
- */
- if (parseio->parse_index)
+ else
{
- /*
- * filled buffer - thus not end character found
- * do processing now
- */
- parseio->parse_data[parseio->parse_index] = '\0';
-
- updated = timepacket(parseio);
- bcopy(parseio->parse_data, parseio->parse_ldata, parseio->parse_index+1);
- parseio->parse_ldsize = parseio->parse_index+1;
- if (parseio->parse_syncflags & SYNC_TIMEOUT)
- parseio->parse_dtime.parse_stime = *ctime;
+ low = parseio->parse_lformat;
+ high = low + 1; /* scan just one format */
}
-
- /*
- * could be a sync event - call sync routine if needed
- */
- if (parseio->parse_syncflags & SYNC_START)
- for (i = low; i < high; i++)
- {
- register clockformat_t *fmt = clockformats[i];
-
- if ((parseio->parse_index == 0) ||
- ((fmt->flags & SYNC_START) && (fmt->startsym == ch)))
- {
- parseprintf(DD_PARSE, ("parse_ioread: SYNC_START event\n"));
- if (fmt->syncevt)
- fmt->syncevt(parseio, ctime, fmt->data, SYNC_START);
- }
- }
- parseio->parse_index = 1;
- parseio->parse_data[0] = ch;
- parseprintf(DD_PARSE, ("parse: parse_ioread: buffer start\n"));
}
else
{
- register unsigned short i;
+ low = 0;
+ high = nformats; /* scan all non fixed formats */
+ }
+
+ if (low != high)
+ {
+ index = ch >> 3;
+ mask = 1 << (ch & 0x7);
- if (parseio->parse_index < parseio->parse_dsize)
+ if ((parseio->parse_syncflags & SYNC_CHAR) &&
+ (parseio->parse_syncsym[index] & mask))
{
+ register clockformat_t *fmt;
+ register unsigned short i;
/*
- * collect into buffer
+ * got a sync event - call sync routine
*/
- parseprintf(DD_PARSE, ("parse: parse_ioread: buffer[%d] = 0x%x\n", parseio->parse_index, ch));
- parseio->parse_data[parseio->parse_index++] = ch;
- }
- if ((parseio->parse_endsym[index] & mask) ||
- (parseio->parse_index >= parseio->parse_dsize))
+ for (i = low; i < high; i++)
+ {
+ fmt = clockformats[i];
+
+ if ((fmt->flags & SYNC_CHAR) &&
+ (fmt->syncsym == ch))
+ {
+ parseprintf(DD_PARSE, ("parse_ioread: SYNC_CHAR event\n"));
+ if (fmt->syncevt)
+ fmt->syncevt(parseio, ctime, fmt->data, SYNC_CHAR);
+ }
+ }
+ }
+
+ if ((((parseio->parse_syncflags & SYNC_START) &&
+ (parseio->parse_startsym[index] & mask)) ||
+ (parseio->parse_index == 0)) ||
+ ((parseio->parse_syncflags & SYNC_TIMEOUT) &&
+ timedout(parseio, ctime)))
{
+ register unsigned short i;
+ /*
+ * packet start - re-fill buffer
+ */
+ if (parseio->parse_index)
+ {
+ /*
+ * filled buffer - thus not end character found
+ * do processing now
+ */
+ parseio->parse_data[parseio->parse_index] = '\0';
+
+ updated = timepacket(parseio);
+ bcopy(parseio->parse_data, parseio->parse_ldata, parseio->parse_index+1);
+ parseio->parse_ldsize = parseio->parse_index+1;
+ if (parseio->parse_syncflags & SYNC_TIMEOUT)
+ parseio->parse_dtime.parse_stime = *ctime;
+ }
+
/*
- * packet end - process buffer
+ * could be a sync event - call sync routine if needed
*/
- if (parseio->parse_syncflags & SYNC_END)
+ if (parseio->parse_syncflags & SYNC_START)
for (i = low; i < high; i++)
{
register clockformat_t *fmt = clockformats[i];
- if ((fmt->flags & SYNC_END) && (fmt->endsym == ch))
+ if ((parseio->parse_index == 0) ||
+ ((fmt->flags & SYNC_START) && (fmt->startsym == ch)))
{
- parseprintf(DD_PARSE, ("parse_ioread: SYNC_END event\n"));
+ parseprintf(DD_PARSE, ("parse_ioread: SYNC_START event\n"));
if (fmt->syncevt)
- fmt->syncevt(parseio, ctime, fmt->data, SYNC_END);
+ fmt->syncevt(parseio, ctime, fmt->data, SYNC_START);
}
}
- parseio->parse_data[parseio->parse_index] = '\0';
- updated = timepacket(parseio);
- bcopy(parseio->parse_data, parseio->parse_ldata, parseio->parse_index+1);
- parseio->parse_ldsize = parseio->parse_index+1;
- parseio->parse_index = 0;
- parseprintf(DD_PARSE, ("parse: parse_ioread: buffer end\n"));
+ parseio->parse_index = 1;
+ parseio->parse_data[0] = ch;
+ parseprintf(DD_PARSE, ("parse: parse_ioread: buffer start\n"));
+ }
+ else
+ {
+ register unsigned short i;
+
+ if (parseio->parse_index < parseio->parse_dsize)
+ {
+ /*
+ * collect into buffer
+ */
+ parseprintf(DD_PARSE, ("parse: parse_ioread: buffer[%d] = 0x%x\n", parseio->parse_index, ch));
+ parseio->parse_data[parseio->parse_index++] = ch;
+ }
+
+ if ((parseio->parse_endsym[index] & mask) ||
+ (parseio->parse_index >= parseio->parse_dsize))
+ {
+ /*
+ * packet end - process buffer
+ */
+ if (parseio->parse_syncflags & SYNC_END)
+ for (i = low; i < high; i++)
+ {
+ register clockformat_t *fmt = clockformats[i];
+
+ if ((fmt->flags & SYNC_END) && (fmt->endsym == ch))
+ {
+ parseprintf(DD_PARSE, ("parse_ioread: SYNC_END event\n"));
+ if (fmt->syncevt)
+ fmt->syncevt(parseio, ctime, fmt->data, SYNC_END);
+ }
+ }
+ parseio->parse_data[parseio->parse_index] = '\0';
+ updated = timepacket(parseio);
+ bcopy(parseio->parse_data, parseio->parse_ldata, parseio->parse_index+1);
+ parseio->parse_ldsize = parseio->parse_index+1;
+ parseio->parse_index = 0;
+ parseprintf(DD_PARSE, ("parse: parse_ioread: buffer end\n"));
+ }
}
}
@@ -476,7 +533,9 @@ parse_ioread(parseio, ch, ctime)
#ifdef DEBUG
if ((updated & CVT_MASK) != CVT_NONE)
- parseprintf(DD_PARSE, ("parse_ioread: time sample accumulated (status=0x%x)\n", updated));
+ {
+ parseprintf(DD_PARSE, ("parse_ioread: time sample accumulated (status=0x%x)\n", updated));
+ }
#endif
parseio->parse_dtime.parse_status = updated;
@@ -537,6 +596,7 @@ parse_iodone(parseio)
/*
* we need to clean up certain flags for the next round
*/
+ parseprintf(DD_PARSE, ("parse_iodone: DONE\n"));
parseio->parse_dtime.parse_state = 0; /* no problems with ISRs */
}
@@ -550,7 +610,7 @@ parse_iodone(parseio)
time_t
parse_to_unixtime(clock, cvtrtc)
register clocktime_t *clock;
- register unsigned LONG *cvtrtc;
+ register u_long *cvtrtc;
{
#define SETRTC(_X_) { if (cvtrtc) *cvtrtc = (_X_); }
static int days_of_month[] =
@@ -646,7 +706,7 @@ parse_to_unixtime(clock, cvtrtc)
int
Stoi(s, zp, cnt)
char *s;
- LONG *zp;
+ long *zp;
int cnt;
{
char *b = s;
@@ -710,24 +770,24 @@ Strok(s, m)
return !*m;
}
-unsigned LONG
+u_long
updatetimeinfo(parseio, t, usec, flags)
register parse_t *parseio;
register time_t t;
- register unsigned LONG usec;
- register unsigned LONG flags;
+ register u_long usec;
+ register u_long flags;
{
- register LONG usecoff;
- register LONG mean;
- LONG delta[PARSE_DELTA];
+ register long usecoff;
+ register long mean;
+ long delta[PARSE_DELTA];
#ifdef PARSEKERNEL
usecoff = (t - parseio->parse_dtime.parse_stime.tv.tv_sec) * 1000000
- parseio->parse_dtime.parse_stime.tv.tv_usec + usec;
#else
- extern LONG tstouslo[];
- extern LONG tstousmid[];
- extern LONG tstoushi[];
+ extern long tstouslo[];
+ extern long tstousmid[];
+ extern long tstoushi[];
TSFTOTVU(parseio->parse_dtime.parse_stime.fp.l_uf, usecoff);
usecoff = -usecoff;
@@ -756,7 +816,7 @@ updatetimeinfo(parseio, t, usec, flags)
{ /* Yes - it's slow sort */
if (delta[s] > delta[k])
{
- register LONG tmp;
+ register long tmp;
tmp = delta[k];
delta[k] = delta[s];
@@ -772,9 +832,9 @@ updatetimeinfo(parseio, t, usec, flags)
*/
while ((n - i) > 8)
{
- register LONG top = delta[n-1];
- register LONG mid = delta[(n+i)>>1];
- register LONG low = delta[i];
+ register long top = delta[n-1];
+ register long mid = delta[(n+i)>>1];
+ register long low = delta[i];
if ((top - mid) > (mid - low))
{
@@ -823,7 +883,8 @@ updatetimeinfo(parseio, t, usec, flags)
}
parseprintf(DD_PARSE,("parse: updatetimeinfo: T=%x+%d usec, useccoff=%d, usecerror=%d, usecdisp=%d\n",
- t, usec, usecoff, parseio->parse_dtime.parse_usecerror, parseio->parse_dtime.parse_usecdisp));
+ (int)t, (int)usec, (int)usecoff, (int)parseio->parse_dtime.parse_usecerror,
+ (int)parseio->parse_dtime.parse_usecdisp));
#ifdef PARSEKERNEL
@@ -855,7 +916,7 @@ syn_simple(parseio, ts, format, why)
register parse_t *parseio;
register timestamp_t *ts;
register struct format *format;
- register unsigned LONG why;
+ register u_long why;
{
parseio->parse_dtime.parse_stime = *ts;
}
@@ -866,7 +927,7 @@ syn_simple(parseio, ts, format, why)
* handle a pps time stamp
*/
/*ARGSUSED*/
-unsigned LONG
+u_long
pps_simple(parseio, status, ptime)
register parse_t *parseio;
register int status;
@@ -883,26 +944,25 @@ pps_simple(parseio, status, ptime)
*
* process a data packet
*/
-static unsigned LONG
+static u_long
timepacket(parseio)
register parse_t *parseio;
{
register int k;
register unsigned short format;
register time_t t;
- register unsigned LONG cvtsum = 0;/* accumulated CVT_FAIL errors */
- unsigned LONG cvtrtc; /* current conversion result */
+ register u_long cvtsum = 0;/* accumulated CVT_FAIL errors */
+ u_long cvtrtc; /* current conversion result */
clocktime_t clock;
+ bzero(&clock, sizeof clock);
format = parseio->parse_lformat;
k = 0;
if (parseio->parse_flags & PARSE_FIXED_FMT)
{
- clock.utctime = 0;
-
- switch ((cvtrtc = clockformats[format]->convert ? clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) : CVT_NONE) & CVT_MASK)
+ switch ((cvtrtc = clockformats[format]->convert ? clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock, parseio->parse_pdata) : CVT_NONE) & CVT_MASK)
{
case CVT_FAIL:
parseio->parse_badformat++;
@@ -924,13 +984,16 @@ timepacket(parseio)
*/
parseio->parse_badformat++;
cvtsum = CVT_BADFMT;
-
break;
case CVT_OK:
k = 1;
break;
+ case CVT_SKIP:
+ k = 2;
+ break;
+
default:
/* shouldn't happen */
#ifdef PARSEKERNEL
@@ -953,10 +1016,8 @@ timepacket(parseio)
{
do
{
- clock.utctime = 0;
-
switch ((cvtrtc = (clockformats[format]->convert && !(clockformats[format]->flags & CVT_FIXEDONLY)) ?
- clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) :
+ clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock, parseio->parse_pdata) :
CVT_NONE) & CVT_MASK)
{
case CVT_FAIL:
@@ -1006,6 +1067,8 @@ timepacket(parseio)
return CVT_FAIL|cvtsum;
}
+ if (k == 2) return CVT_OK;
+
if ((t = parse_to_unixtime(&clock, &cvtrtc)) == -1)
{
#ifdef PARSEKERNEL
@@ -1162,6 +1225,18 @@ parse_setcs(dct, parse)
* History:
*
* parse.c,v
+ * Revision 3.27 1994/06/01 08:18:33 kardel
+ * more debug info
+ *
+ * Revision 3.26 1994/05/30 10:20:07 kardel
+ * LONG cleanup
+ *
+ * Revision 3.25 1994/05/12 12:49:12 kardel
+ * printf fmt/arg cleanup
+ *
+ * Revision 3.24 1994/03/27 15:01:36 kardel
+ * reorder include file to cope with PTX
+ *
* Revision 3.23 1994/03/25 13:09:02 kardel
* considering FIXEDONLY entries only in FIXEDONLY mode
*
diff --git a/usr.sbin/xntpd/parse/parse_conf.c b/usr.sbin/xntpd/parse/parse_conf.c
index 238dd12..ed306d4 100644
--- a/usr.sbin/xntpd/parse/parse_conf.c
+++ b/usr.sbin/xntpd/parse/parse_conf.c
@@ -46,8 +46,12 @@ extern clockformat_t clock_meinberg[];
extern clockformat_t clock_rawdcf;
#endif
-#ifdef CLOCK_TRIMSV6
-extern clockformat_t clock_trimsv6;
+#ifdef CLOCK_TRIMTAIP
+extern clockformat_t clock_trimtaip;
+#endif
+
+#ifdef CLOCK_TRIMTSIP
+extern clockformat_t clock_trimtsip;
#endif
/*
@@ -69,8 +73,11 @@ clockformat_t *clockformats[] =
#ifdef CLOCK_RAWDCF
&clock_rawdcf,
#endif
-#ifdef CLOCK_TRIMSV6
- &clock_trimsv6,
+#ifdef CLOCK_TRIMTAIP
+ &clock_trimtaip,
+#endif
+#ifdef CLOCK_TRIMTSIP
+ &clock_trimtsip,
#endif
0};
diff --git a/usr.sbin/xntpd/parse/parsesolaris.c b/usr.sbin/xntpd/parse/parsesolaris.c
index 23bc252..513cd00 100644
--- a/usr.sbin/xntpd/parse/parsesolaris.c
+++ b/usr.sbin/xntpd/parse/parsesolaris.c
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.16 1994/05/30 09:57:40 kardel Exp
*
- * parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp
+ * parsesolaris.c,v 3.16 1994/05/30 09:57:40 kardel Exp
*
* STREAMS module for reference clocks
* (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be
@@ -19,7 +19,7 @@
*/
#ifndef lint
-static char rcsid[] = "parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp";
+static char rcsid[] = "parsesolaris.c,v 3.16 1994/05/30 09:57:40 kardel Exp";
#endif
/*
@@ -139,7 +139,7 @@ int Strcmp(s, t)
/*ARGSUSED*/
int _init(void)
{
- static char revision[] = "3.15";
+ static char revision[] = "3.16";
char *s, *S, *t;
/*
@@ -401,6 +401,11 @@ static int parseopen(queue_t *q, dev_t *dev, int flag, int sflag, cred_t *credp)
parsebusy++;
q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t), KM_SLEEP);
+ if (q->q_ptr == (caddr_t)0)
+ {
+ return ENOMEM;
+ }
+
parseprintf(DD_OPEN,("parse: OPEN - parse area q=%x, q->q_ptr=%x\n", q, q->q_ptr));
SAFE_WR(q)->q_ptr = q->q_ptr;
parseprintf(DD_OPEN,("parse: OPEN - WQ parse area q=%x, q->q_ptr=%x\n", SAFE_WR(q), SAFE_WR(q)->q_ptr));
@@ -938,29 +943,38 @@ static int init_zs_linemon(queue_t *q, queue_t *my_q)
*/
szs = (struct savedzsops *) kmem_alloc(sizeof(struct savedzsops), KM_SLEEP);
- parsestream->parse_data = (void *)szs;
+ if (szs == (struct savedzsops *)0)
+ {
+ parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor NOT installed - no memory\n"));
- mutex_enter(zs->zs_excl);
+ return 0;
+ }
+ else
+ {
+ parsestream->parse_data = (void *)szs;
- parsestream->parse_dqueue = q; /* remember driver */
+ mutex_enter(zs->zs_excl);
- szs->zsops = *zs->zs_ops;
- szs->zsops.zsop_xsint = (void (*)())zs_xsisr; /* place our bastard */
- szs->oldzsops = zs->zs_ops;
- emergencyzs = zs->zs_ops;
-
- zs->zs_ops = &szs->zsops; /* hook it up */
- /*
- * XXX: this is usually done via zsopinit()
- * - have yet to find a way to call that routine
- */
- zs->zs_xsint = (void (*)())zs_xsisr;
-
- mutex_exit(zs->zs_excl);
+ parsestream->parse_dqueue = q; /* remember driver */
+
+ szs->zsops = *zs->zs_ops;
+ szs->zsops.zsop_xsint = (void (*)())zs_xsisr; /* place our bastard */
+ szs->oldzsops = zs->zs_ops;
+ emergencyzs = zs->zs_ops;
+
+ zs->zs_ops = &szs->zsops; /* hook it up */
+ /*
+ * XXX: this is usually done via zsopinit()
+ * - have yet to find a way to call that routine
+ */
+ zs->zs_xsint = (void (*)())zs_xsisr;
+
+ mutex_exit(zs->zs_excl);
- parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor installed\n"));
+ parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor installed\n"));
- return 1;
+ return 1;
+ }
}
}
@@ -1190,6 +1204,9 @@ static void zs_xsisr(struct zscom *zs)
* History:
*
* parsesolaris.c,v
+ * Revision 3.16 1994/05/30 09:57:40 kardel
+ * kmem_alloc checking
+ *
* Revision 3.15 1994/02/15 22:20:51 kardel
* rcsid fixed
*
diff --git a/usr.sbin/xntpd/parse/parsestreams.c b/usr.sbin/xntpd/parse/parsestreams.c
index 45d2963..19e5c10 100644
--- a/usr.sbin/xntpd/parse/parsestreams.c
+++ b/usr.sbin/xntpd/parse/parsestreams.c
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.22 1994/06/01 10:41:16 kardel Exp
*
- * parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp
+ * parsestreams.c,v 3.22 1994/06/01 10:41:16 kardel Exp
*
* STREAMS module for reference clocks
* (SunOS4.x)
@@ -16,7 +16,7 @@
*/
#ifndef lint
-static char rcsid[] = "parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp";
+static char rcsid[] = "parsestreams.c,v 3.22 1994/06/01 10:41:16 kardel Exp";
#endif
#include "sys/types.h"
@@ -195,7 +195,7 @@ int xxxinit(fc, vdp, vdi, vds)
}
else
{
- static char revision[] = "3.19";
+ static char revision[] = "3.22";
char *s, *S, *t;
strncpy(ifm->f_name, mname, FMNAMESZ);
@@ -493,6 +493,11 @@ static int parseopen(q, dev, flag, sflag)
#endif
q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t));
+ if (q->q_ptr == (caddr_t)0)
+ {
+ parseprintf(DD_OPEN,("parse: OPEN - FAILED - no memory\n"));
+ return OPENFAIL;
+ }
WR(q)->q_ptr = q->q_ptr;
parse = (parsestream_t *) q->q_ptr;
@@ -1022,24 +1027,33 @@ static int init_zs_linemon(q, my_q)
*/
szs = (struct savedzsops *) kmem_alloc(sizeof(struct savedzsops));
- parsestream->parse_data = (void *)szs;
+ if (szs == (struct savedzsops *)0)
+ {
+ parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor NOT installed - no memory\n"));
- s = splhigh();
+ return 0;
+ }
+ else
+ {
+ parsestream->parse_data = (void *)szs;
- parsestream->parse_dqueue = q; /* remember driver */
+ s = splhigh();
- szs->zsops = *zs->zs_ops;
- szs->zsops.zsop_xsint = (int (*)())zs_xsisr; /* place our bastard */
- szs->oldzsops = zs->zs_ops;
- emergencyzs = zs->zs_ops;
-
- zsopinit(zs, &szs->zsops); /* hook it up */
-
- (void) splx(s);
+ parsestream->parse_dqueue = q; /* remember driver */
- parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor installed\n"));
+ szs->zsops = *zs->zs_ops;
+ szs->zsops.zsop_xsint = (int (*)())zs_xsisr; /* place our bastard */
+ szs->oldzsops = zs->zs_ops;
+ emergencyzs = zs->zs_ops;
+
+ zsopinit(zs, &szs->zsops); /* hook it up */
+
+ (void) splx(s);
- return 1;
+ parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor installed\n"));
+
+ return 1;
+ }
}
}
@@ -1133,7 +1147,7 @@ static void zs_xsisr(zs)
/*
* logical state
*/
- status = cd_invert ? (zsstatus & (ZSRR0_CD|ZSRR0_SYNC)) == 0 : (zsstatus & (ZSRR0_CD|ZSRR0_SYNC)) != 0;
+ status = cd_invert ? (zsstatus & ZSRR0_SYNC) == 0 : (zsstatus & ZSRR0_SYNC) != 0;
#ifdef PPS_SYNC
if (status)
@@ -1286,8 +1300,17 @@ static void zs_xsisr(zs)
* History:
*
* parsestreams.c,v
+ * Revision 3.22 1994/06/01 10:41:16 kardel
+ * CD seems to happen on ZSRR0_SYNC
+ *
+ * Revision 3.21 1994/06/01 08:18:57 kardel
+ * look at CD only
+ *
+ * Revision 3.20 1994/05/30 09:57:43 kardel
+ * kmem_alloc checking
+ *
* Revision 3.19 1994/02/24 16:33:54 kardel
- * CD events can also be posted on sync flag
+ * CD events can olso be posted on sync flag
*
* Revision 3.18 1994/02/24 14:12:58 kardel
* initial PPS_SYNC support version
diff --git a/usr.sbin/xntpd/parse/util/dcfd.c b/usr.sbin/xntpd/parse/util/dcfd.c
index 23934a8..3f04a55 100644
--- a/usr.sbin/xntpd/parse/util/dcfd.c
+++ b/usr.sbin/xntpd/parse/util/dcfd.c
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/util/dcfd.c,v 3.15 1994/01/25 19:05:42 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/util/dcfd.c,v 3.18 1994/05/12 12:49:23 kardel Exp
*
- * dcfd.c,v 3.15 1994/01/25 19:05:42 kardel Exp
+ * dcfd.c,v 3.18 1994/05/12 12:49:23 kardel Exp
*
* DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line)
*
@@ -703,6 +703,11 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
* if everything went well so far return the result of the symbolic
* conversion routine else just the accumulated errors
*/
+ if (rtc != CVT_NONE)
+ {
+ PRINTF("%-30s", "*** BAD DATA");
+ }
+
return (rtc == CVT_NONE) ? convert_rawdcf(buffer, size, clock) : rtc;
}
@@ -864,9 +869,9 @@ static char * pr_timeval(val)
static char buf[20];
if (val->tv_sec == 0)
- sprintf(buf, "%c0.%06d", (val->tv_usec < 0) ? '-' : '+', abs(val->tv_usec));
+ sprintf(buf, "%c0.%06ld", (val->tv_usec < 0) ? '-' : '+', (long int)abs(val->tv_usec));
else
- sprintf(buf, "%d.%06d", val->tv_sec, abs(val->tv_usec));
+ sprintf(buf, "%ld.%06ld", (long int)val->tv_sec, (long int)abs(val->tv_usec));
return buf;
}
@@ -912,7 +917,7 @@ static void adj_time(offset)
time_offset.tv_sec = offset / 1000000;
time_offset.tv_usec = offset % 1000000;
- LPRINTF("adj_time: %d us ", offset);
+ LPRINTF("adj_time: %ld us ", (long int)offset);
if (adjtime(&time_offset, 0L) == -1)
perror("adjtime()");
}
@@ -937,7 +942,7 @@ static void read_drift(drift_file)
drift_comp = idrift << USECSCALE;
fdrift = (fdrift << USECSCALE) / 1000;
drift_comp += fdrift & (1<<USECSCALE);
- LPRINTF("read_drift: drift_comp %d ", drift_comp);
+ LPRINTF("read_drift: drift_comp %ld ", (long int)drift_comp);
}
}
@@ -957,11 +962,11 @@ static void update_drift(drift_file, offset, reftime)
int idrift = R_SHIFT(drift_comp, USECSCALE);
int fdrift = drift_comp & ((1<<USECSCALE)-1);
- LPRINTF("update_drift: drift_comp %d ", drift_comp);
+ LPRINTF("update_drift: drift_comp %ld ", (long int)drift_comp);
fdrift = (fdrift * 1000) / (1<<USECSCALE);
- fprintf(df, "%4d.%03d %c%d.%06d %.24s\n", idrift, fdrift,
- (offset < 0) ? '-' : '+', abs(offset) / 1000000, abs(offset) % 1000000,
- asctime(localtime(&reftime)));
+ fprintf(df, "%4d.%03d %c%ld.%06ld %.24s\n", idrift, fdrift,
+ (offset < 0) ? '-' : '+', (long int)(abs(offset) / 1000000),
+ (long int)(abs(offset) % 1000000), asctime(localtime(&reftime)));
fclose(df);
LPRINTF("update_drift: %d.%03d ppm ", idrift, fdrift);
}
@@ -1023,8 +1028,9 @@ static void adjust_clock(offset, drift_file, reftime)
drift_comp = -MAX_DRIFT;
update_drift(drift_file, usecoffset, reftime);
- LPRINTF("clock_adjust: %s, clock_adjust %d, drift_comp %d(%d) ",
- pr_timeval(offset), R_SHIFT(clock_adjust, USECSCALE) , R_SHIFT(drift_comp, USECSCALE), drift_comp);
+ LPRINTF("clock_adjust: %s, clock_adjust %ld, drift_comp %ld(%ld) ",
+ pr_timeval(offset),(long int) R_SHIFT(clock_adjust, USECSCALE),
+ (long int)R_SHIFT(drift_comp, USECSCALE), (long int)drift_comp);
}
/*-----------------------------------------------------------------------
@@ -1303,8 +1309,8 @@ main(argc, argv)
memset(term.c_cc, 0, sizeof(term.c_cc));
term.c_cc[VMIN] = 1;
- term.c_cflag = B50|CS8|CREAD|CLOCAL;
- term.c_iflag = 0;
+ term.c_cflag = B50|CS8|CREAD|CLOCAL|PARENB;
+ term.c_iflag = IGNPAR;
term.c_oflag = 0;
term.c_lflag = 0;
@@ -1369,7 +1375,7 @@ main(argc, argv)
(void) alarm(1<<ADJINTERVAL);
#endif
- PRINTF(" DCF77 monitor - Copyright 1993, Frank Kardel\n\n");
+ PRINTF(" DCF77 monitor - Copyright 1993,1994, Frank Kardel\n\n");
pbuf[60] = '\0';
for ( i = 0; i < 60; i++)
@@ -1423,6 +1429,12 @@ main(argc, argv)
}
errs++;
}
+ else
+ if (trace)
+ {
+ PRINTF("\r %.*s ", 59 - offset, &buf[offset]);
+ }
+
buf[0] = c;
@@ -1491,11 +1503,6 @@ main(argc, argv)
if (rtc == CVT_OK)
{
- if (trace && (i == 0))
- {
- PRINTF("\r %.*s ", 59 - offset, &buf[offset]);
- }
-
if (i == 0)
{
/*
diff --git a/usr.sbin/xntpd/parse/util/parsetest.c b/usr.sbin/xntpd/parse/util/parsetest.c
index 21e4128..7fa62a9 100644
--- a/usr.sbin/xntpd/parse/util/parsetest.c
+++ b/usr.sbin/xntpd/parse/util/parsetest.c
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/util/parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/util/parsetest.c,v 3.14 1994/05/12 12:49:27 kardel Exp
*
- * parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp
+ * parsetest.c,v 3.14 1994/05/12 12:49:27 kardel Exp
*
* Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
@@ -10,7 +10,13 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * parsetest.c,v
+ * $Log: parsetest.c,v $
+ * Revision 3.14 1994/05/12 12:49:27 kardel
+ * printf fmt/arg cleanup
+ *
+ * Revision 3.14 1994/05/11 09:25:43 kardel
+ * 3.3r + printf fmt/arg fixes
+ *
* Revision 3.13 1994/02/20 13:04:46 kardel
* parse add/delete second support
*
@@ -59,7 +65,8 @@ static char *strstatus(buffer, state)
{ PARSEB_NOSYNC, "TIME CODE NOT CONFIRMED" },
{ PARSEB_DST, "DST" },
{ PARSEB_UTC, "UTC DISPLAY" },
- { PARSEB_LEAP, "LEAP WARNING" },
+ { PARSEB_LEAPADD, "LEAP ADDITION WARNING" },
+ { PARSEB_LEAPDEL, "LEAP DELETION WARNING" },
{ PARSEB_LEAPSECOND, "LEAP SECOND" },
{ PARSEB_ALTERNATE,"ALTERNATE ANTENNA" },
{ PARSEB_TIMECODE, "TIME CODE" },
@@ -194,7 +201,7 @@ main(argc, argv)
parsetime_t parsetime;
struct strioctl strioc;
- printf("parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp\n");
+ printf("parsetest.c,v 3.11 1994/01/23 19:00:01 kardel Exp\n");
while (ioctl(fd, I_POP, 0) == 0)
;
@@ -215,7 +222,7 @@ main(argc, argv)
perror("ioctl(fd, I_STR(PARSEIOC_GETSTAT))");
exit(1);
}
- printf("parse status: %04x\n", dct.parsestatus.flags);
+ printf("parse status: %04lx\n", (unsigned long)dct.parsestatus.flags);
dct.parsestatus.flags |= PARSE_STAT_FILTER;
strioc.ic_cmd = PARSEIOC_SETSTAT;
@@ -232,7 +239,7 @@ main(argc, argv)
perror("ioctl(fd, I_STR(PARSEIOC_GETSTAT))");
exit(1);
}
- printf("parse status: %04x\n", dct.parsestatus.flags);
+ printf("parse status: %04lx\n", (unsigned long)dct.parsestatus.flags);
while (read(fd, &parsetime, sizeof(parsetime)) == sizeof(parsetime))
{
@@ -245,15 +252,16 @@ main(argc, argv)
tmp1[24] = '\0';
tmp2[24] = '\0';
- printf("%s (+%06dus) %s PPS: %s (+%06dus), ", tmp1, parsetime.parse_stime.tv.tv_usec, tmp, tmp2, parsetime.parse_ptime.tv.tv_usec);
+ printf("%s (+%06ldus) %s PPS: %s (+%06ldus), ", tmp1, (long int)parsetime.parse_stime.tv.tv_usec, tmp, tmp2,
+ (long int)parsetime.parse_ptime.tv.tv_usec);
strstatus(tmp, parsetime.parse_state);
- printf("state: 0x%x (%s) error: %dus, dispersion: %dus, Status: 0x%x (%s)\n",
- parsetime.parse_state,
+ printf("state: 0x%lx (%s) error: %ldus, dispersion: %ldus, Status: 0x%lx (%s)\n",
+ (unsigned long)parsetime.parse_state,
tmp,
- parsetime.parse_usecerror,
- parsetime.parse_usecdisp,
- parsetime.parse_status,
+ (long)parsetime.parse_usecerror,
+ (long)parsetime.parse_usecdisp,
+ (unsigned long)parsetime.parse_status,
parsestatus(parsetime.parse_status, tmp1));
}
diff --git a/usr.sbin/xntpd/parse/util/testdcf.c b/usr.sbin/xntpd/parse/util/testdcf.c
index 560ab27..73c8d89 100644
--- a/usr.sbin/xntpd/parse/util/testdcf.c
+++ b/usr.sbin/xntpd/parse/util/testdcf.c
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.13 1994/05/12 12:49:31 kardel Exp
*
- * testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp
+ * testdcf.c,v 3.13 1994/05/12 12:49:31 kardel Exp
*
* simple DCF77 100/200ms pulse test program (via 50Baud serial line)
*
@@ -354,8 +354,8 @@ main(argc, argv)
memset(term.c_cc, 0, sizeof(term.c_cc));
term.c_cc[VMIN] = 1;
- term.c_cflag = B50|CS8|CREAD|CLOCAL;
- term.c_iflag = 0;
+ term.c_cflag = B50|CS8|CREAD|CLOCAL|PARENB;
+ term.c_iflag = IGNPAR;
term.c_oflag = 0;
term.c_lflag = 0;
@@ -411,8 +411,8 @@ main(argc, argv)
}
if (t.tv_sec > 1 ||
- t.tv_sec == 1 &&
- t.tv_usec > 500000)
+ (t.tv_sec == 1 &&
+ t.tv_usec > 500000))
{
printf("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &buf[offset]);
@@ -453,8 +453,8 @@ main(argc, argv)
{
printf("%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s>",
wday[clock.wday],
- clock.hour, clock.minute, i, clock.day, clock.month,
- clock.year,
+ (int)clock.hour, (int)clock.minute, (int)i, (int)clock.day, (int)clock.month,
+ (int)clock.year,
(clock.flags & DCFB_ALTERNATE) ? "R" : "_",
(clock.flags & DCFB_ANNOUNCE) ? "A" : "_",
(clock.flags & DCFB_DST) ? "D" : "_",
OpenPOWER on IntegriCloud