]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
New macro REFID_IS_TEXT().
authorMartin Burnicki <burnicki@ntp.org>
Tue, 19 Jun 2018 10:30:58 +0000 (12:30 +0200)
committerMartin Burnicki <burnicki@ntp.org>
Tue, 19 Jun 2018 10:30:58 +0000 (12:30 +0200)
bk: 5b28db62QmYo5BRwW7ggxo1-uj8j-A

ChangeLog
include/ntp.h
ntpd/ntp_control.c

index dcfa59c07f3fb687e22c57016ce0cd382df674e5..61e886ebddf19b16fe4221f371c9f07c92acdd4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+  New macro REFID_ISTEXT() which is also used in ntpd/ntp_control.c.
+
 ---
 (4.2.8p11) 2018/02/27 Released by Harlan Stenn <stenn@ntp.org>
 
@@ -12,7 +14,7 @@
 * [Sec 3012] Sybil vulnerability: noepeer support.  HStenn, JPerlinger.
 * [Bug 3457] OpenSSL FIPS mode regression <perlinger@ntp.org>
 * [Bug 3455] ntpd doesn't use scope id when binding multicast <perlinger@ntp.org>
- - applied patch by Sean Haugh 
+ - applied patch by Sean Haugh
 * [Bug 3452] PARSE driver prints uninitialized memory. <perlinger@ntp.org>
 * [Bug 3450] Dubious error messages from plausibility checks in get_systime()
  - removed error log caused by rounding/slew, ensured postcondition <perlinger@ntp.org>
index fb739c756848e75bd130b9bba40c921e36f0797a..cfbb7d2e7a474dc83ebea438db116e270390a1a6 100644 (file)
@@ -610,6 +610,18 @@ struct pkt {
 #define        STRATUM_TO_PKT(s)       ((u_char)(((s) == (STRATUM_UNSPEC)) ?\
                                (STRATUM_PKT_UNSPEC) : (s)))
 
+
+/*
+ * A test to determine if the refid should be interpreted as text string.
+ * This is usually the case for a refclock, which has stratum 0 internally,
+ * which results in sys_stratum 1 if the refclock becomes system peer, or
+ * in case of a kiss-of-death (KoD) packet that has STRATUM_PKT_UNSPEC (==0)
+ * in the packet which is converted to STRATUM_UNSPEC when the packet
+ * is evaluated.
+ */
+#define REFID_ISTEXT(s) (((s) <= 1) || ((s) >= STRATUM_UNSPEC))
+
+
 /*
  * Event codes. Used for reporting errors/events to the control module
  */
index f908d41fa1525fd69eece710b64d365b972b808f..72cb8c43b0b57850c545f13c66a8412193b06f8d 100644 (file)
@@ -1951,10 +1951,10 @@ ctl_putsys(
                break;
 
        case CS_REFID:
-               if (sys_stratum > 1 && sys_stratum < STRATUM_UNSPEC)
-                       ctl_putadr(sys_var[varid].text, sys_refid, NULL);
-               else
+               if (REFID_ISTEXT(sys_stratum))
                        ctl_putrefid(sys_var[varid].text, sys_refid);
+               else
+                       ctl_putadr(sys_var[varid].text, sys_refid, NULL);
                break;
 
        case CS_REFTIME:
@@ -2678,11 +2678,10 @@ ctl_putpeer(
                        break;
                }
 #endif
-               if (p->stratum > 1 && p->stratum < STRATUM_UNSPEC)
-                       ctl_putadr(peer_var[id].text, p->refid,
-                                  NULL);
-               else
+               if (REFID_ISTEXT(p->stratum))
                        ctl_putrefid(peer_var[id].text, p->refid);
+               else
+                       ctl_putadr(peer_var[id].text, p->refid, NULL);
                break;
 
        case CP_REFTIME: