summaryrefslogtreecommitdiff
path: root/ntpd
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2020-06-24 00:20:45 +0000
committerCy Schubert <cy@FreeBSD.org>2020-06-24 00:20:45 +0000
commit3914721463f70500ecc1f59312b122d8788465cf (patch)
treef253e72838d762e229ca71912a4a928e96cac2bd /ntpd
parent5171bc9b11192d9ad273db7854787eaa65eb9997 (diff)
Notes
Diffstat (limited to 'ntpd')
-rw-r--r--ntpd/invoke-ntp.conf.texi2
-rw-r--r--ntpd/invoke-ntp.keys.texi2
-rw-r--r--ntpd/invoke-ntpd.texi4
-rw-r--r--ntpd/ntp.conf.5man4
-rw-r--r--ntpd/ntp.conf.5mdoc4
-rw-r--r--ntpd/ntp.conf.html2
-rw-r--r--ntpd/ntp.conf.man.in4
-rw-r--r--ntpd/ntp.conf.mdoc.in4
-rw-r--r--ntpd/ntp.keys.5man4
-rw-r--r--ntpd/ntp.keys.5mdoc4
-rw-r--r--ntpd/ntp.keys.html2
-rw-r--r--ntpd/ntp.keys.man.in4
-rw-r--r--ntpd/ntp.keys.mdoc.in4
-rw-r--r--ntpd/ntp_config.c10
-rw-r--r--ntpd/ntp_io.c36
-rw-r--r--ntpd/ntp_proto.c57
-rw-r--r--ntpd/ntp_refclock.c72
-rw-r--r--ntpd/ntp_request.c2
-rw-r--r--ntpd/ntp_timer.c35
-rw-r--r--ntpd/ntpd-opts.c14
-rw-r--r--ntpd/ntpd-opts.h6
-rw-r--r--ntpd/ntpd.1ntpdman4
-rw-r--r--ntpd/ntpd.1ntpdmdoc4
-rw-r--r--ntpd/ntpd.html4
-rw-r--r--ntpd/ntpd.man.in4
-rw-r--r--ntpd/ntpd.mdoc.in4
-rw-r--r--ntpd/refclock_jjy.c108
-rw-r--r--ntpd/refclock_nmea.c2
-rw-r--r--ntpd/refclock_palisade.c48
-rw-r--r--ntpd/refclock_parse.c2
30 files changed, 273 insertions, 183 deletions
diff --git a/ntpd/invoke-ntp.conf.texi b/ntpd/invoke-ntp.conf.texi
index 5ef61c7aaf3a3..b504ce0b047f3 100644
--- a/ntpd/invoke-ntp.conf.texi
+++ b/ntpd/invoke-ntp.conf.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi)
#
-# It has been AutoGen-ed March 3, 2020 at 05:40:57 PM by AutoGen 5.18.5
+# It has been AutoGen-ed June 23, 2020 at 02:20:31 AM by AutoGen 5.18.5
# From the definitions ntp.conf.def
# and the template file agtexi-file.tpl
@end ignore
diff --git a/ntpd/invoke-ntp.keys.texi b/ntpd/invoke-ntp.keys.texi
index 1687d9d6b338d..fcaa19499102e 100644
--- a/ntpd/invoke-ntp.keys.texi
+++ b/ntpd/invoke-ntp.keys.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi)
#
-# It has been AutoGen-ed March 3, 2020 at 05:40:59 PM by AutoGen 5.18.5
+# It has been AutoGen-ed June 23, 2020 at 02:20:33 AM by AutoGen 5.18.5
# From the definitions ntp.keys.def
# and the template file agtexi-file.tpl
@end ignore
diff --git a/ntpd/invoke-ntpd.texi b/ntpd/invoke-ntpd.texi
index 47919ffb2105f..3438285956e5d 100644
--- a/ntpd/invoke-ntpd.texi
+++ b/ntpd/invoke-ntpd.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi)
#
-# It has been AutoGen-ed March 3, 2020 at 05:41:00 PM by AutoGen 5.18.5
+# It has been AutoGen-ed June 23, 2020 at 02:20:35 AM by AutoGen 5.18.5
# From the definitions ntpd-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -142,7 +142,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntpd - NTP daemon program - Ver. 4.2.8p14
+ntpd - NTP daemon program - Ver. 4.2.8p15
Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
[ <server1> ... <serverN> ]
Flg Arg Option-Name Description
diff --git a/ntpd/ntp.conf.5man b/ntpd/ntp.conf.5man
index a24c9866d21ee..a3649f052106a 100644
--- a/ntpd/ntp.conf.5man
+++ b/ntpd/ntp.conf.5man
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp.conf 5man "03 Mar 2020" "4.2.8p14" "File Formats"
+.TH ntp.conf 5man "23 Jun 2020" "4.2.8p15" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:41:02 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:36 AM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/ntpd/ntp.conf.5mdoc b/ntpd/ntp.conf.5mdoc
index 2272d58b27500..c833cf008badf 100644
--- a/ntpd/ntp.conf.5mdoc
+++ b/ntpd/ntp.conf.5mdoc
@@ -1,9 +1,9 @@
-.Dd March 3 2020
+.Dd June 23 2020
.Dt NTP_CONF 5mdoc File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:40:53 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:27 AM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/ntpd/ntp.conf.html b/ntpd/ntp.conf.html
index 7dc61eda73aaf..686ec9981104a 100644
--- a/ntpd/ntp.conf.html
+++ b/ntpd/ntp.conf.html
@@ -61,7 +61,7 @@ Next: <a href="#ntp_002econf-Description" accesskey="n" rel="next">ntp.conf Desc
<p>This document describes the configuration file for the NTP Project&rsquo;s
<code>ntpd</code> program.
</p>
-<p>This document applies to version 4.2.8p14 of <code>ntp.conf</code>.
+<p>This document applies to version 4.2.8p15 of <code>ntp.conf</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
diff --git a/ntpd/ntp.conf.man.in b/ntpd/ntp.conf.man.in
index f871c3bb17ea4..ba4cff523831b 100644
--- a/ntpd/ntp.conf.man.in
+++ b/ntpd/ntp.conf.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp.conf 5 "03 Mar 2020" "4.2.8p14" "File Formats"
+.TH ntp.conf 5 "23 Jun 2020" "4.2.8p15" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:41:02 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:36 AM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/ntpd/ntp.conf.mdoc.in b/ntpd/ntp.conf.mdoc.in
index eaaf14cb09427..973e52823e308 100644
--- a/ntpd/ntp.conf.mdoc.in
+++ b/ntpd/ntp.conf.mdoc.in
@@ -1,9 +1,9 @@
-.Dd March 3 2020
+.Dd June 23 2020
.Dt NTP_CONF 5 File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:40:53 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:27 AM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/ntpd/ntp.keys.5man b/ntpd/ntp.keys.5man
index 6225ee3f0ccd1..1470ee73a25e7 100644
--- a/ntpd/ntp.keys.5man
+++ b/ntpd/ntp.keys.5man
@@ -1,8 +1,8 @@
-.TH ntp.keys 5man "03 Mar 2020" "4.2.8p14" "File Formats"
+.TH ntp.keys 5man "23 Jun 2020" "4.2.8p15" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:41:04 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:38 AM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
diff --git a/ntpd/ntp.keys.5mdoc b/ntpd/ntp.keys.5mdoc
index 7a728a3d435fa..cec0a573aeb01 100644
--- a/ntpd/ntp.keys.5mdoc
+++ b/ntpd/ntp.keys.5mdoc
@@ -1,9 +1,9 @@
-.Dd March 3 2020
+.Dd June 23 2020
.Dt NTP_KEYS 5mdoc File Formats
.Os FreeBSD 11.2-RELEASE_SI
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:40:54 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:28 AM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
diff --git a/ntpd/ntp.keys.html b/ntpd/ntp.keys.html
index 0151116926273..afe07283b87f5 100644
--- a/ntpd/ntp.keys.html
+++ b/ntpd/ntp.keys.html
@@ -61,7 +61,7 @@ Next: <a href="#ntp_002ekeys-Description" accesskey="n" rel="next">ntp.keys Desc
<p>This document describes the symmetric key file for the NTP Project&rsquo;s
<code>ntpd</code> program.
</p>
-<p>This document applies to version 4.2.8p14 of <code>ntp.keys</code>.
+<p>This document applies to version 4.2.8p15 of <code>ntp.keys</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
diff --git a/ntpd/ntp.keys.man.in b/ntpd/ntp.keys.man.in
index dac04dda45fd4..2437cd1cdab2c 100644
--- a/ntpd/ntp.keys.man.in
+++ b/ntpd/ntp.keys.man.in
@@ -1,8 +1,8 @@
-.TH ntp.keys 5 "03 Mar 2020" "4.2.8p14" "File Formats"
+.TH ntp.keys 5 "23 Jun 2020" "4.2.8p15" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:41:04 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:38 AM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
diff --git a/ntpd/ntp.keys.mdoc.in b/ntpd/ntp.keys.mdoc.in
index 0cbb20e0f4329..f2a8bb98471ce 100644
--- a/ntpd/ntp.keys.mdoc.in
+++ b/ntpd/ntp.keys.mdoc.in
@@ -1,9 +1,9 @@
-.Dd March 3 2020
+.Dd June 23 2020
.Dt NTP_KEYS 5 File Formats
.Os FreeBSD 11.2-RELEASE_SI
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:40:54 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:28 AM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c
index ee9df318a630a..cdc391c1b95b0 100644
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -137,6 +137,16 @@ typedef struct peer_resolved_ctx_tag {
#define MAXPPS 20 /* maximum length of PPS device string */
/*
+ * Poll Skew List
+ */
+
+static psl_item psl[17-3+1]; /* values for polls 3-17 */
+ /* To simplify the runtime code we */
+ /* don't want to have to special-case */
+ /* dealing with a default */
+
+
+/*
* Miscellaneous macros
*/
#define ISEOL(c) ((c) == '#' || (c) == '\n' || (c) == '\0')
diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c
index 4ad1c7fbc3e5f..c0dcea598121e 100644
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3293,15 +3293,20 @@ read_refclock_packet(
int consumed;
struct recvbuf * rb;
- rb = get_free_recv_buffer();
+ rb = get_free_recv_buffer(TRUE);
if (NULL == rb) {
/*
- * No buffer space available - just drop the packet
+ * No buffer space available - just drop the 'packet'.
+ * Since this is a non-blocking character stream we read
+ * all data that we can.
+ *
+ * ...hmmmm... what about "tcflush(fd,TCIFLUSH)" here?!?
*/
- char buf[RX_BUFF_SIZE];
-
- buflen = read(fd, buf, sizeof buf);
+ char buf[128];
+ do
+ buflen = read(fd, buf, sizeof(buf));
+ while (buflen > 0);
packets_dropped++;
return (buflen);
}
@@ -3487,15 +3492,18 @@ read_network_packet(
#endif
/*
- * Get a buffer and read the frame. If we
- * haven't got a buffer, or this is received
- * on a disallowed socket, just dump the
+ * Get a buffer and read the frame. If we haven't got a buffer,
+ * or this is received on a disallowed socket, just dump the
* packet.
*/
- rb = get_free_recv_buffer();
- if (NULL == rb || itf->ignore_packets) {
- char buf[RX_BUFF_SIZE];
+ rb = itf->ignore_packets ? NULL : get_free_recv_buffer(FALSE);
+ if (NULL == rb) {
+ /* A partial read on a UDP socket truncates the data and
+ * removes the message from the queue. So there's no
+ * need to have a full buffer here on the stack.
+ */
+ char buf[16];
sockaddr_u from;
if (rb != NULL)
@@ -4740,12 +4748,14 @@ process_routing_msgs(struct asyncio_reader *reader)
#ifdef HAVE_RTNETLINK
for (nh = UA_PTR(struct nlmsghdr, buffer);
NLMSG_OK(nh, cnt);
- nh = NLMSG_NEXT(nh, cnt)) {
+ nh = NLMSG_NEXT(nh, cnt))
+ {
msg_type = nh->nlmsg_type;
#else
for (p = buffer;
(p + sizeof(struct rt_msghdr)) <= (buffer + cnt);
- p += rtm.rtm_msglen) {
+ p += rtm.rtm_msglen)
+ {
memcpy(&rtm, p, sizeof(rtm));
if (rtm.rtm_version != RTM_VERSION) {
msyslog(LOG_ERR,
diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c
index 33e97ef9d9893..cde5a30852dd4 100644
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -1333,9 +1333,10 @@ receive(
* manycaster has already synchronized to us.
*/
if ( sys_leap == LEAP_NOTINSYNC
- || sys_stratum >= hisstratum
+ || sys_stratum > hisstratum + 1
|| (!sys_cohort && sys_stratum == hisstratum + 1)
|| rbufp->dstadr->addr_refid == pkt->refid) {
+ DPRINTF(2, ("receive: sys leap: %0x, sys_stratum %d > hisstratum+1 %d, !sys_cohort %d && sys_stratum == hisstratum+1, loop refid %#x == pkt refid %#x\n", sys_leap, sys_stratum, hisstratum + 1, !sys_cohort, rbufp->dstadr->addr_refid, pkt->refid));
DPRINTF(2, ("receive: AM_FXMIT drop: LEAP_NOTINSYNC || stratum || loop\n"));
sys_declined++;
return; /* no help */
@@ -1681,8 +1682,9 @@ receive(
* MODE_ACTIVE KoDs, which will time out eventually.
*/
if ( hisleap != LEAP_NOTINSYNC
- && (hisstratum < sys_floor || hisstratum >= sys_ceiling)) {
- DPRINTF(2, ("receive: AM_NEWPASS drop: Autokey group mismatch\n"));
+ && (hisstratum < sys_floor || hisstratum >= sys_ceiling)) {
+ DPRINTF(2, ("receive: AM_NEWPASS drop: Remote stratum (%d) out of range\n",
+ hisstratum));
sys_declined++;
return; /* no help */
}
@@ -2485,10 +2487,6 @@ process_packet(
double etemp, ftemp, td;
#endif /* ASSYM */
-#if 0
- sys_processed++;
- peer->processed++;
-#endif
p_del = FPTOD(NTOHS_FP(pkt->rootdelay));
p_offset = 0;
p_disp = FPTOD(NTOHS_FP(pkt->rootdisp));
@@ -2501,10 +2499,6 @@ process_packet(
pversion = PKT_VERSION(pkt->li_vn_mode);
pstratum = PKT_TO_STRATUM(pkt->stratum);
- /**/
-
- /**/
-
/*
* Verify the server is synchronized; that is, the leap bits,
* stratum and root distance are valid.
@@ -2524,19 +2518,15 @@ process_packet(
peer->seldisptoolarge++;
DPRINTF(1, ("packet: flash header %04x\n",
peer->flash));
-
- /* ppoll updated? */
- /* XXX: Fuzz the poll? */
- poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
+ /* [Bug 3592] do *not* update poll on bad packets! */
return;
}
- /**/
-
-#if 1
+ /*
+ * update stats, now that we really handle this packet:
+ */
sys_processed++;
peer->processed++;
-#endif
/*
* Capture the header values in the client/peer association..
@@ -2571,9 +2561,6 @@ process_packet(
if (peer->burst > 0)
peer->nextdate = current_time;
}
- poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
-
- /**/
/*
* If the peer was previously unreachable, raise a trap. In any
@@ -3455,11 +3442,13 @@ clock_select(void)
double d, e, f, g;
double high, low;
double speermet;
+ double lastresort_dist = MAXDISPERSE;
double orphmet = 2.0 * U_INT32_MAX; /* 2x is greater than */
struct endpoint endp;
struct peer *osys_peer;
struct peer *sys_prefer = NULL; /* prefer peer */
struct peer *typesystem = NULL;
+ struct peer *typelastresort = NULL;
struct peer *typeorphan = NULL;
#ifdef REFCLOCK
struct peer *typeacts = NULL;
@@ -3524,6 +3513,22 @@ clock_select(void)
}
/*
+ * If we have never been synchronised, look for any peer
+ * which has ever been synchronised and pick the one which
+ * has the lowest root distance. This can be used as a last
+ * resort if all else fails. Once we get an initial sync
+ * with this peer, sys_reftime gets set and so this
+ * function becomes disabled.
+ */
+ if (L_ISZERO(&sys_reftime)) {
+ d = root_distance(peer);
+ if (!L_ISZERO(&peer->reftime) && d < lastresort_dist) {
+ typelastresort = peer;
+ lastresort_dist = d;
+ }
+ }
+
+ /*
* If this peer is an orphan parent, elect the
* one with the lowest metric defined as the
* IPv4 address or the first 64 bits of the
@@ -3756,6 +3761,9 @@ clock_select(void)
if (typeorphan != NULL) {
peers[0].peer = typeorphan;
nlist = 1;
+ } else if (typelastresort != NULL) {
+ peers[0].peer = typelastresort;
+ nlist = 1;
}
}
@@ -3949,8 +3957,7 @@ clock_select(void)
*/
if (typesystem == NULL) {
if (osys_peer != NULL) {
- if (sys_orphwait > 0)
- orphwait = current_time + sys_orphwait;
+ orphwait = current_time + sys_orphwait;
report_event(EVNT_NOPEER, NULL, NULL);
}
sys_peer = NULL;
@@ -5344,7 +5351,7 @@ proto_config(
case PROTO_ORPHWAIT: /* orphan wait (orphwait) */
orphwait -= sys_orphwait;
- sys_orphwait = (int)dvalue;
+ sys_orphwait = (dvalue >= 1) ? (int)dvalue : NTP_ORPHWAIT;
orphwait += sys_orphwait;
break;
diff --git a/ntpd/ntp_refclock.c b/ntpd/ntp_refclock.c
index 6a0861ed03bcb..872f4a05263f1 100644
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -48,15 +48,15 @@
* structure, which contains for most drivers the decimal equivalants
* of the year, day, month, hour, second and millisecond/microsecond
* decoded from the ASCII timecode. Additional information includes
- * the receive timestamp, exception report, statistics tallies, etc.
+ * the receive timestamp, exception report, statistics tallies, etc.
* In addition, there may be a driver-specific unit structure used for
* local control of the device.
*
* The support routines are passed a pointer to the peer structure,
* which is used for all peer-specific processing and contains a
* pointer to the refclockproc structure, which in turn contains a
- * pointer to the unit structure, if used. The peer structure is
- * identified by an interface address in the dotted quad form
+ * pointer to the unit structure, if used. The peer structure is
+ * identified by an interface address in the dotted quad form
* 127.127.t.u, where t is the clock type and u the unit.
*/
#define FUDGEFAC .1 /* fudge correction factor */
@@ -343,7 +343,7 @@ refclock_timer(
if (pp->action != NULL && pp->nextaction <= current_time)
(*pp->action)(p);
}
-
+
/*
* refclock_transmit - simulate the transmit procedure
@@ -435,17 +435,17 @@ refclock_samples_avail(
)
{
u_int na;
-
+
# if MAXSTAGE & (MAXSTAGE - 1)
-
+
na = pp->coderecv - pp->codeproc;
if (na > MAXSTAGE)
na += MAXSTAGE;
-
+
# else
-
+
na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
-
+
# endif
return na;
}
@@ -462,26 +462,26 @@ refclock_samples_expire(
)
{
u_int na;
-
+
if (nd <= 0)
return 0;
# if MAXSTAGE & (MAXSTAGE - 1)
-
+
na = pp->coderecv - pp->codeproc;
if (na > MAXSTAGE)
na += MAXSTAGE;
if ((u_int)nd < na)
- nd = na;
+ nd = na;
pp->codeproc = (pp->codeproc + nd) % MAXSTAGE;
-
+
# else
-
+
na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
if ((u_int)nd > na)
nd = (int)na;
pp->codeproc = (pp->codeproc + nd) & (MAXSTAGE - 1);
-
+
# endif
return nd;
}
@@ -615,14 +615,14 @@ refclock_sample(
/*
* Determine the offset and jitter.
*/
- pp->offset = 0;
+ pp->offset = off[i];
pp->jitter = 0;
- for (k = i; k < j; k++) {
+ for (k = i + 1; k < j; k++) {
pp->offset += off[k];
- if (k > i)
- pp->jitter += SQUARE(off[k] - off[k - 1]);
+ pp->jitter += SQUARE(off[k] - off[k - 1]);
}
pp->offset /= m;
+ m -= (m > 1); /* only (m-1) terms attribute to jitter! */
pp->jitter = max(SQRT(pp->jitter / m), LOGTOD(sys_precision));
/*
@@ -736,7 +736,7 @@ refclock_gtlin(
while (sp != spend && dp != dpend) {
char c;
-
+
c = *sp++ & 0x7f;
if (c >= 0x20 && c < 0x7f)
*dp++ = c;
@@ -1407,7 +1407,7 @@ refclock_params(
ap->pps_params.mode & ~PPS_TSFMT_TSPEC,
PPS_TSFMT_TSPEC) < 0)
{
- if (errno != EOPNOTSUPP) {
+ if (errno != EOPNOTSUPP) {
msyslog(LOG_ERR,
"refclock_params: time_pps_kcbind: %m");
return (0);
@@ -1431,7 +1431,7 @@ int
refclock_pps(
struct peer *peer, /* peer structure pointer */
struct refclock_atom *ap, /* atom structure pointer */
- int mode /* mode bits */
+ int mode /* mode bits */
)
{
struct refclockproc *pp;
@@ -1443,7 +1443,7 @@ refclock_pps(
* We require the clock to be synchronized before setting the
* parameters. When the parameters have been set, fetch the
* most recent PPS timestamp.
- */
+ */
pp = peer->procptr;
if (ap->handle == 0)
return (0);
@@ -1519,7 +1519,7 @@ refclock_pps(
pp->lastrec.l_uf = (u_int32)(dtemp * FRAC);
clk_add_sample(pp, dcorr);
refclock_checkburst(peer, pp);
-
+
#ifdef DEBUG
if (debug > 1)
printf("refclock_pps: %lu %f %f\n", current_time,
@@ -1579,7 +1579,7 @@ refclock_ppsaugment(
)
{
l_fp delta[1];
-
+
#ifdef HAVE_PPSAPI
pps_info_t pps_info;
@@ -1589,14 +1589,14 @@ refclock_ppsaugment(
static const uint32_t s_plim_hi = UINT32_C(1932735284);
static const uint32_t s_plim_lo = UINT32_C(2362232013);
-
+
/* fixup receive time in case we have to bail out early */
DTOLFP(rcvfudge, delta);
L_SUB(rcvtime, delta);
if (NULL == ap)
return FALSE;
-
+
ZERO(timeout);
ZERO(pps_info);
@@ -1630,7 +1630,7 @@ refclock_ppsaugment(
phase = delta->l_ui;
if (phase >= 2 && phase < (uint32_t)-2)
return FALSE; /* PPS is stale, don't use it */
-
+
/* If the phase is too close to 0.5, the decision whether to
* move up or down is becoming noise sensitive. That is, we
* might amplify usec noise between samples into seconds with a
@@ -1642,7 +1642,7 @@ refclock_ppsaugment(
phase = delta->l_uf;
if (phase > s_plim_hi && phase < s_plim_lo)
return FALSE; /* we're in the noise lock gap */
-
+
/* sign-extend fraction into seconds */
delta->l_ui = UINT32_C(0) - ((phase >> 31) & 1);
/* add it up now */
@@ -1650,7 +1650,7 @@ refclock_ppsaugment(
return TRUE;
# else /* have no PPS support at all */
-
+
/* just fixup receive time and fail */
UNUSED_ARG(ap);
UNUSED_ARG(ppsfudge);
@@ -1658,7 +1658,7 @@ refclock_ppsaugment(
DTOLFP(rcvfudge, delta);
L_SUB(rcvtime, delta);
return FALSE;
-
+
# endif
}
@@ -1694,7 +1694,7 @@ refclock_checkburst(
* reach mask. With less samples available, we break away.
*/
needs = peer->reach;
- needs -= (needs >> 1) & 0x55;
+ needs -= (needs >> 1) & 0x55;
needs = (needs & 0x33) + ((needs >> 2) & 0x33);
needs = (needs + (needs >> 4)) & 0x0F;
if (needs > 6)
@@ -1706,7 +1706,7 @@ refclock_checkburst(
/* Get serious. Reduce the poll to minimum and schedule early.
* (Changing the peer poll is probably in vain, as it will be
- * re-adjusted, but maybe some time the hint will work...)
+ * re-adjusted, but maybe some time the hint will work...)
*/
peer->hpoll = peer->minpoll;
peer->nextdate = limit;
@@ -1749,7 +1749,7 @@ refclock_vformat_lcode(
len = 0;
else if (len >= sizeof(pp->a_lastcode))
len = sizeof(pp->a_lastcode) - 1;
-
+
pp->lencode = (u_short)len;
pp->a_lastcode[len] = '\0';
/* !note! the NUL byte is needed in case vsnprintf() really fails */
@@ -1763,10 +1763,10 @@ refclock_format_lcode(
)
{
va_list va;
-
+
va_start(va, fmt);
refclock_vformat_lcode(pp, fmt, va);
- va_end(va);
+ va_end(va);
}
#endif /* REFCLOCK */
diff --git a/ntpd/ntp_request.c b/ntpd/ntp_request.c
index bffdec5a9d1dd..e7997a3b90951 100644
--- a/ntpd/ntp_request.c
+++ b/ntpd/ntp_request.c
@@ -1184,7 +1184,7 @@ mem_stats(
for (i = 0; i < NTP_HASH_SIZE; i++)
ms->hashcount[i] = (u_char)
- max((u_int)peer_hash_count[i], UCHAR_MAX);
+ min((u_int)peer_hash_count[i], UCHAR_MAX);
(void) more_pkt();
flush_pkt();
diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c
index 9725b5bda3120..4f669f0699fab 100644
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -350,21 +350,38 @@ timer(void)
* than the orphan stratum are available. A server with no other
* synchronization source is an orphan. It shows offset zero and
* reference ID the loopback address.
+ *
+ * [bug 3644] If the orphan stratum is >= STRATUM_UNSPEC, we
+ * have to do it a bit different. 'clock_select()' simply
+ * tiptoed home, but since we're unsync'd and have no peer, we
+ * should eventually declare we're out of sync. Otherwise we
+ * would persistently claim we're good, and we're everything but
+ * that...
+ *
+ * XXX: do we want to log an event about this?
*/
- if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL &&
- current_time > orphwait) {
- if (sys_leap == LEAP_NOTINSYNC) {
- set_sys_leap(LEAP_NOWARNING);
+ if (sys_peer == NULL && current_time > orphwait) {
+ if (sys_orphan < STRATUM_UNSPEC) {
+ if (sys_leap == LEAP_NOTINSYNC) {
+ set_sys_leap(LEAP_NOWARNING);
#ifdef AUTOKEY
- if (crypto_flags)
- crypto_update();
+ if (crypto_flags)
+ crypto_update();
#endif /* AUTOKEY */
+ }
+ sys_stratum = (u_char)sys_orphan;
+ } else {
+ if (sys_leap != LEAP_NOTINSYNC) {
+ set_sys_leap(LEAP_NOTINSYNC);
+ msyslog(LOG_WARNING, "%s",
+ "no peer for too long, server running free now");
+ }
+ sys_stratum = STRATUM_UNSPEC;
}
- sys_stratum = (u_char)sys_orphan;
if (sys_stratum > 1)
- sys_refid = htonl(LOOPBACKADR);
+ sys_refid = htonl(LOOPBACKADR);
else
- memcpy(&sys_refid, "LOOP", 4);
+ memcpy(&sys_refid, "LOOP", 4);
sys_offset = 0;
sys_rootdelay = 0;
sys_rootdisp = 0;
diff --git a/ntpd/ntpd-opts.c b/ntpd/ntpd-opts.c
index e463b4b4822f8..42b2a7722cc17 100644
--- a/ntpd/ntpd-opts.c
+++ b/ntpd/ntpd-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.c)
*
- * It has been AutoGen-ed March 3, 2020 at 05:40:30 PM by AutoGen 5.18.5
+ * It has been AutoGen-ed June 23, 2020 at 02:20:04 AM by AutoGen 5.18.5
* From the definitions ntpd-opts.def
* and the template file options
*
@@ -75,7 +75,7 @@ extern FILE * option_usage_fp;
* static const strings for ntpd options
*/
static char const ntpd_opt_strs[3132] =
-/* 0 */ "ntpd 4.2.8p14\n"
+/* 0 */ "ntpd 4.2.8p15\n"
"Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -205,12 +205,12 @@ static char const ntpd_opt_strs[3132] =
/* 2901 */ "output version information and exit\0"
/* 2937 */ "version\0"
/* 2945 */ "NTPD\0"
-/* 2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p14\n"
+/* 2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p15\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
"\t\t[ <server1> ... <serverN> ]\n\0"
/* 3082 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 3116 */ "\n\0"
-/* 3118 */ "ntpd 4.2.8p14";
+/* 3118 */ "ntpd 4.2.8p15";
/**
* ipv4 option description with
@@ -1529,7 +1529,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpdOptions.pzCopyright */
- puts(_("ntpd 4.2.8p14\n\
+ puts(_("ntpd 4.2.8p15\n\
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -1670,7 +1670,7 @@ implied warranty.\n"));
puts(_("output version information and exit"));
/* referenced via ntpdOptions.pzUsageTitle */
- puts(_("ntpd - NTP daemon program - Ver. 4.2.8p14\n\
+ puts(_("ntpd - NTP daemon program - Ver. 4.2.8p15\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
\t\t[ <server1> ... <serverN> ]\n"));
@@ -1678,7 +1678,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
puts(_("\n"));
/* referenced via ntpdOptions.pzFullVersion */
- puts(_("ntpd 4.2.8p14"));
+ puts(_("ntpd 4.2.8p15"));
/* referenced via ntpdOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/ntpd/ntpd-opts.h b/ntpd/ntpd-opts.h
index a2e1904003c0c..07cdc2e3e54b9 100644
--- a/ntpd/ntpd-opts.h
+++ b/ntpd/ntpd-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.h)
*
- * It has been AutoGen-ed March 3, 2020 at 05:40:30 PM by AutoGen 5.18.5
+ * It has been AutoGen-ed June 23, 2020 at 02:20:04 AM by AutoGen 5.18.5
* From the definitions ntpd-opts.def
* and the template file options
*
@@ -106,9 +106,9 @@ typedef enum {
/** count of all options for ntpd */
#define OPTION_CT 38
/** ntpd version */
-#define NTPD_VERSION "4.2.8p14"
+#define NTPD_VERSION "4.2.8p15"
/** Full ntpd version text */
-#define NTPD_FULL_VERSION "ntpd 4.2.8p14"
+#define NTPD_FULL_VERSION "ntpd 4.2.8p15"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/ntpd/ntpd.1ntpdman b/ntpd/ntpd.1ntpdman
index 675bd799bd905..461f37d43be87 100644
--- a/ntpd/ntpd.1ntpdman
+++ b/ntpd/ntpd.1ntpdman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpd 1ntpdman "03 Mar 2020" "4.2.8p14" "User Commands"
+.TH ntpd 1ntpdman "23 Jun 2020" "4.2.8p15" "User Commands"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:41:05 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:39 AM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/ntpd/ntpd.1ntpdmdoc b/ntpd/ntpd.1ntpdmdoc
index 8d06869e5afcd..60703324ea10e 100644
--- a/ntpd/ntpd.1ntpdmdoc
+++ b/ntpd/ntpd.1ntpdmdoc
@@ -1,9 +1,9 @@
-.Dd March 3 2020
+.Dd June 23 2020
.Dt NTPD 1ntpdmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:40:55 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:30 AM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/ntpd/ntpd.html b/ntpd/ntpd.html
index 4ac6127dda456..f002faa2ac5e8 100644
--- a/ntpd/ntpd.html
+++ b/ntpd/ntpd.html
@@ -67,7 +67,7 @@ The program can operate in any of several modes, including client/server,
symmetric and broadcast modes, and with both symmetric-key and public-key
cryptography.
</p>
-<p>This document applies to version 4.2.8p14 of <code>ntpd</code>.
+<p>This document applies to version 4.2.8p15 of <code>ntpd</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -309,7 +309,7 @@ used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
-<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p14
+<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p15
Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ &lt;server1&gt; ... &lt;serverN&gt; ]
Flg Arg Option-Name Description
diff --git a/ntpd/ntpd.man.in b/ntpd/ntpd.man.in
index 087af030cf208..00c567f508dfb 100644
--- a/ntpd/ntpd.man.in
+++ b/ntpd/ntpd.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpd @NTPD_MS@ "03 Mar 2020" "4.2.8p14" "User Commands"
+.TH ntpd @NTPD_MS@ "23 Jun 2020" "4.2.8p15" "User Commands"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:41:05 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:39 AM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/ntpd/ntpd.mdoc.in b/ntpd/ntpd.mdoc.in
index 9f360073d3324..8eb547a438f68 100644
--- a/ntpd/ntpd.mdoc.in
+++ b/ntpd/ntpd.mdoc.in
@@ -1,9 +1,9 @@
-.Dd March 3 2020
+.Dd June 23 2020
.Dt NTPD @NTPD_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
-.\" It has been AutoGen-ed March 3, 2020 at 05:40:55 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed June 23, 2020 at 02:20:30 AM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/ntpd/refclock_jjy.c b/ntpd/refclock_jjy.c
index a73cdd88948dc..0b554fac66744 100644
--- a/ntpd/refclock_jjy.c
+++ b/ntpd/refclock_jjy.c
@@ -4,7 +4,7 @@
/**********************************************************************/
/* */
-/* Copyright (C) 2001-2015, Takao Abe. All rights reserved. */
+/* Copyright (C) 2001-2020, Takao Abe. All rights reserved. */
/* */
/* Permission to use, copy, modify, and distribute this software */
/* and its documentation for any purpose is hereby granted */
@@ -115,6 +115,13 @@
/* tool. ( The code is harmless and has no bug. ) */
/* teljjy_conn_send() */
/* */
+/* 2020/01/19 */
+/* [Change] Handling TS-JJY01/02 status of the the STUS reply. */
+/* Time synchronization can be skipped by the settings of */
+/* the flag2 when the status of the reply is UNADJUSTED. */
+/* [Change] Quiet compilation for the GCC 9.2.0. */
+/* [Fix] Correct typos in comment lines */
+/* */
/**********************************************************************/
#ifdef HAVE_CONFIG_H
@@ -194,6 +201,10 @@ struct jjyunit {
char sTextBuf [ MAX_RAWBUF ] ;
int iTextBufLen ;
char bSkipCntrlCharOnly ;
+/* TS-JJY01, TS-JJY02 */
+ time_t tLastAdjustedTimestamp ;
+ char bStusReplyAdjusted ;
+ char bStusReplyAdjustedAtLeastOnce ;
/* Telephone JJY auto measurement of the loopback delay */
char bLoopbackMode ;
short iLoopbackCount ;
@@ -371,7 +382,7 @@ struct refclock refclock_jjy = {
* Local constants definition
*/
-#define MAX_LOGTEXT 100
+#define MAX_LOGTEXT 200
#ifndef TRUE
#define TRUE (0==0)
@@ -410,6 +421,7 @@ struct refclock refclock_jjy = {
#define JJY_CLOCKSTATS_MESSAGE_LOOPBACK_DELAY "* Loopback delay : %d.%03d mSec."
#define JJY_CLOCKSTATS_MESSAGE_DELAY_ADJUST "* Delay adjustment : %d mSec. ( valid=%hd/%d )"
#define JJY_CLOCKSTATS_MESSAGE_DELAY_UNADJUST "* Delay adjustment : None ( valid=%hd/%d )"
+#define JJY_CLOCKSTATS_MESSAGE_STUS_UNADJUSTED "* Skip time synchronization : STUS is 'UNADJUSTED' for %.0lf %s"
#define JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY "# Unexpected reply : [%s]"
#define JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH "# Invalid length : length=%d"
@@ -619,7 +631,7 @@ jjy_receive ( struct recvbuf *rbufp )
/* To avoid its claim, pass the value BMAX-1. */
/*
- * Append received charaters to temporary buffer
+ * Append received characters to temporary buffer
*/
for ( i = 0 ;
i < pp->lencode && up->iRawBufLen < MAX_RAWBUF - 2 ;
@@ -703,7 +715,7 @@ jjy_receive ( struct recvbuf *rbufp )
iBreakPosition = up->iRawBufLen - 1 ;
}
- /* Copy charaters from temporary buffer to process buffer */
+ /* Copy characters from temporary buffer to process buffer */
up->iLineBufLen = up->iTextBufLen = 0 ;
for ( i = iReadRawBuf ; i <= iBreakPosition ; i ++ ) {
@@ -926,7 +938,7 @@ jjy_poll ( int unit, struct peer *peer )
up->iRawBufLen = 0 ;
switch ( up->unittype ) {
-
+
case UNITTYPE_TRISTATE_JJY01 :
jjy_poll_tristate_jjy01 ( unit, peer ) ;
break ;
@@ -991,7 +1003,7 @@ jjy_timer ( int unit, struct peer *peer )
}
switch ( up->unittype ) {
-
+
case UNITTYPE_TELEPHONE :
jjy_timer_telephone ( unit, peer ) ;
break ;
@@ -1020,8 +1032,8 @@ jjy_synctime ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
pp->second = up->second ;
pp->nsec = up->msecond * 1000000 ;
- /*
- * JST to UTC
+ /*
+ * JST to UTC
*/
pp->hour -= 9 ;
if ( pp->hour < 0 ) {
@@ -1070,7 +1082,7 @@ jjy_synctime ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
case 5 : cStatus = '#' ; pStatus = "Selected" ; break ;
case 6 : cStatus = '*' ; pStatus = "Sys.Peer" ; break ;
case 7 : cStatus = 'o' ; pStatus = "PPS.Peer" ; break ;
- default : break ;
+ default : break ;
}
snprintf ( sLog, sizeof(sLog),
@@ -1151,6 +1163,9 @@ jjy_start_tristate_jjy01 ( int unit, struct peer *peer, struct jjyunit *up )
up->linespeed = SPEED232_TRISTATE_JJY01 ;
up->linediscipline = LDISC_CLK ;
+ time( &(up->tLastAdjustedTimestamp) ) ;
+ up->bStusReplyAdjustedAtLeastOnce = FALSE ;
+
return 0 ;
}
@@ -1164,10 +1179,12 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
struct refclockproc *pp ;
struct peer *peer;
- char * pBuf ;
- char sLog [ 100 ] ;
- int iLen ;
- int rc ;
+ char * pBuf ;
+ char sLog [ MAX_LOGTEXT ] ;
+ int iLen ;
+ int rc ;
+ time_t now ;
+ double fSeconds ;
const char * pCmd ;
int iCmdLen ;
@@ -1269,11 +1286,17 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
case TS_JJY01_COMMAND_NUMBER_STUS :
if ( strncmp( pBuf, TS_JJY01_REPLY_STUS_ADJUSTED,
- TS_JJY01_REPLY_LENGTH_STUS_ADJUSTED ) == 0
- || strncmp( pBuf, TS_JJY01_REPLY_STUS_UNADJUSTED,
- TS_JJY01_REPLY_LENGTH_STUS_UNADJUSTED ) == 0 ) {
- /* Good */
+ TS_JJY01_REPLY_LENGTH_STUS_ADJUSTED ) == 0 ) {
+ /* STUS reply : adjusted */
+ up->bStusReplyAdjusted = TRUE ;
+ up->bStusReplyAdjustedAtLeastOnce = TRUE ;
+ time( &(up->tLastAdjustedTimestamp) ) ;
+ } else if ( strncmp( pBuf, TS_JJY01_REPLY_STUS_UNADJUSTED,
+ TS_JJY01_REPLY_LENGTH_STUS_UNADJUSTED ) == 0 ) {
+ /* STUS reply : unadjusted */
+ up->bStusReplyAdjusted = FALSE ;
} else {
+ /* Bad reply */
snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY,
pBuf ) ;
jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
@@ -1286,11 +1309,12 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
case TS_JJY01_COMMAND_NUMBER_DCST :
if ( strncmp( pBuf, TS_JJY01_REPLY_DCST_VALID,
- TS_JJY01_REPLY_LENGTH_DCST_VALID ) == 0
+ TS_JJY01_REPLY_LENGTH_DCST_VALID ) == 0
|| strncmp( pBuf, TS_JJY01_REPLY_DCST_INVALID,
- TS_JJY01_REPLY_LENGTH_DCST_INVALID ) == 0 ) {
- /* Good */
+ TS_JJY01_REPLY_LENGTH_DCST_INVALID ) == 0 ) {
+ /* Valid reply */
} else {
+ /* Bad reply */
snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY,
pBuf ) ;
jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
@@ -1300,7 +1324,7 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
break ;
- default : /* Unexpected reply */
+ default : /* Unexpected reply */
snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY,
pBuf ) ;
@@ -1313,9 +1337,27 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
if ( up->iTimestampCount == 2 ) {
/* Process date and time */
- if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0]
- && up->iTimestamp[0] <= up->iTimestamp[1] ) {
- /* 3 commands (time,date,stim) was excuted in two seconds */
+ time( &now ) ;
+ fSeconds = difftime( now, up->tLastAdjustedTimestamp ) ;
+
+ if ( ( pp->sloppyclockflag & CLK_FLAG2 ) != 0
+ && ( ! up->bStusReplyAdjusted )
+ && ( fSeconds >= ( pp->fudgetime2 * 3600 ) || ( ! up->bStusReplyAdjustedAtLeastOnce ) ) ) {
+ /* STUS is not ADJUSTED */
+ if ( fSeconds < 60 ) {
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_STUS_UNADJUSTED, fSeconds, "seconds" ) ;
+ } else if ( fSeconds < 3600 ) {
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_STUS_UNADJUSTED, fSeconds / 60, "minutes" ) ;
+ } else if ( fSeconds < 86400 ) {
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_STUS_UNADJUSTED, fSeconds / 3600, "hours" ) ;
+ } else {
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_STUS_UNADJUSTED, fSeconds / 86400, "days" ) ;
+ }
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, sLog ) ;
+ return JJY_RECEIVE_SKIP ;
+ } else if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0]
+ && up->iTimestamp[0] <= up->iTimestamp[1] ) {
+ /* 3 commands (time,date,stim) was executed in two seconds */
jjy_synctime( peer, pp, up ) ;
return JJY_RECEIVE_DONE ;
} else if ( up->iTimestamp[0] > up->iTimestamp[1] ) {
@@ -1385,6 +1427,8 @@ jjy_poll_tristate_jjy01 ( int unit, struct peer *peer )
up->iLineCount = 2 ;
}
+ up->bStusReplyAdjusted = FALSE ;
+
#ifdef DEBUG
if ( debug ) {
printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->iLineCount=%d\n",
@@ -1421,7 +1465,7 @@ jjy_poll_tristate_jjy01 ( int unit, struct peer *peer )
/* */
/* Command Response Remarks */
/* -------------------- ---------------------------------------- ---------------------------- */
-/* <ENQ>1J<ETX> <STX>JYYMMDD HHMMSSS<ETX> J is a fixed character */
+/* <ENQ>1J<ETX> <STX>JYYMMDDWHHMMSSS<ETX> J is a fixed character */
/* */
/*################################################################################################*/
@@ -1461,7 +1505,7 @@ jjy_receive_cdex_jst2000 ( struct recvbuf *rbufp )
struct refclockproc *pp ;
struct peer *peer ;
- char *pBuf, sLog [ 100 ] ;
+ char *pBuf, sLog [ MAX_LOGTEXT ] ;
int iLen ;
int rc ;
@@ -1946,8 +1990,8 @@ jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer )
/*################################################################################################*/
/*################################################################################################*/
/* */
-/* This clock has NMEA mode and command/respose mode. */
-/* When this jjy driver are used, set to command/respose mode of this clock */
+/* This clock has NMEA mode and command/response mode. */
+/* When this jjy driver are used, set to command/response mode of this clock */
/* by the onboard switch SW4, and make sure the LED-Y is tured on. */
/* Other than this JJY driver, the refclock driver type 20, generic NMEA driver, */
/* works with the NMEA mode of this clock. */
@@ -2022,7 +2066,7 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp )
struct peer *peer;
char * pBuf ;
- char sLog [ 100 ] ;
+ char sLog [ MAX_LOGTEXT ] ;
int iLen ;
int rc ;
@@ -2189,7 +2233,7 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp )
if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0]
&& up->iTimestamp[0] <= up->iTimestamp[1] ) {
- /* 3 commands (time,date,stim) was excuted in two seconds */
+ /* 3 commands (time,date,stim) was executed in two seconds */
jjy_synctime( peer, pp, up ) ;
return JJY_RECEIVE_DONE ;
} else if ( up->iTimestamp[0] > up->iTimestamp[1] ) {
@@ -2344,7 +2388,7 @@ jjy_receive_seiko_tsys_tdc_300 ( struct recvbuf *rbufp )
struct refclockproc *pp ;
struct jjyunit *up ;
- char *pBuf, sLog [ 100 ] ;
+ char *pBuf, sLog [ MAX_LOGTEXT ] ;
int iLen, i ;
int rc, iWeekday ;
time_t now ;
@@ -3402,7 +3446,7 @@ teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
char *pBuf ;
int iLen, rc ;
- char sLog [ 80 ] ;
+ char sLog [ MAX_LOGTEXT ] ;
char bAdjustment ;
diff --git a/ntpd/refclock_nmea.c b/ntpd/refclock_nmea.c
index 4fdadea61dffa..1d7997c6aaf99 100644
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -289,7 +289,7 @@ static int nmea_start (int, struct peer *);
static void nmea_shutdown (int, struct peer *);
static void nmea_receive (struct recvbuf *);
static void nmea_poll (int, struct peer *);
-static void nmea_procrec (struct peer *, l_fp);
+static void nmea_procrec (struct peer * const, l_fp);
#ifdef HAVE_PPSAPI
static double tabsdiffd (l_fp, l_fp);
static void nmea_control (int, const struct refclockstat *,
diff --git a/ntpd/refclock_palisade.c b/ntpd/refclock_palisade.c
index e698d72cc5219..cb68255d05b0e 100644
--- a/ntpd/refclock_palisade.c
+++ b/ntpd/refclock_palisade.c
@@ -304,13 +304,13 @@ palisade_start (
int fd;
char gpsdev[20];
struct termios tio;
+ u_int speed;
snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
/*
* Open serial port.
*/
- u_int speed;
speed = (CLK_TYPE(peer) == CLK_COPERNICUS) ? SPEED232COP : SPEED232;
fd = refclock_open(gpsdev, speed, LDISC_RAW);
if (fd <= 0) {
@@ -941,30 +941,32 @@ TSIP_decode (
return 0;
}
/* Get date & time from WN & ToW minus offset */
- TCivilDate cd;
- TGpsDatum wd;
- l_fp ugo; /* UTC-GPS offset, negative number */
- ugo.Ul_i.Xl_i = (int32_t)-GPS_UTC_Offset;
- ugo.l_uf = 0;
- wd = gpscal_from_gpsweek((wn % 1024), (int32_t)tow, ugo);
- gpscal_to_calendar(&cd, &wd);
- pp->year = cd.year;
- pp->day = cd.yearday;
- pp->hour = cd.hour;
- pp->minute = cd.minute;
- pp->second = cd.second;
- pp->nsec = 0;
- pp->leap = LEAP_NOWARNING;
+ {
+ TCivilDate cd;
+ TGpsDatum wd;
+ l_fp ugo; /* UTC-GPS offset, negative number */
+ ugo.Ul_i.Xl_i = (int32_t)-GPS_UTC_Offset;
+ ugo.l_uf = 0;
+ wd = gpscal_from_gpsweek((wn % 1024), (int32_t)tow, ugo);
+ gpscal_to_calendar(&cd, &wd);
+ pp->year = cd.year;
+ pp->day = cd.yearday;
+ pp->hour = cd.hour;
+ pp->minute = cd.minute;
+ pp->second = cd.second;
+ pp->nsec = 0;
+ pp->leap = LEAP_NOWARNING;
#ifdef DEBUG
- if (debug > 1) {
- printf("GPS TOW: %ld\n", tow);
- printf("GPS WN: %d\n", wn);
- printf("GPS UTC-GPS Offset: %d\n", GPS_UTC_Offset);
- printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d ",
- up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, pp->second,
- pp->nsec, cd.month, cd.monthday, pp->year);
- }
+ if (debug > 1) {
+ printf("GPS TOW: %ld\n", tow);
+ printf("GPS WN: %d\n", wn);
+ printf("GPS UTC-GPS Offset: %d\n", GPS_UTC_Offset);
+ printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d ",
+ up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, pp->second,
+ pp->nsec, cd.month, cd.monthday, pp->year);
+ }
#endif
+ }
return 1;
}
diff --git a/ntpd/refclock_parse.c b/ntpd/refclock_parse.c
index b4a65b80377fb..043bc8673c7e2 100644
--- a/ntpd/refclock_parse.c
+++ b/ntpd/refclock_parse.c
@@ -2366,7 +2366,7 @@ local_input(
}
if (count)
{ /* simulate receive */
- buf = get_free_recv_buffer();
+ buf = get_free_recv_buffer(TRUE);
if (buf != NULL) {
memmove((caddr_t)buf->recv_buffer,
(caddr_t)&parse->parseio.parse_dtime,