]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
reference: move definition of special refids to ntp.h
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 22 Jun 2015 07:13:15 +0000 (09:13 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 22 Jun 2015 10:54:22 +0000 (12:54 +0200)
ntp.h
reference.c

diff --git a/ntp.h b/ntp.h
index db5aabc6178737d5b66aa7f4f89356144eaee762..a61dd02af16d6d7551793aaef7f858445bf85541 100644 (file)
--- a/ntp.h
+++ b/ntp.h
@@ -109,4 +109,8 @@ typedef struct {
 #define NTP_LVM(leap, version, mode) \
   ((((leap) << 6) & 0xc0) | (((version) << 3) & 0x38) | ((mode) & 0x07))
 
+/* Special NTP reference IDs */
+#define NTP_REFID_UNSYNC 0x0UL
+#define NTP_REFID_LOCAL 0x7F7F0101UL /* 127.127.1.1 */
+
 #endif /* GOT_NTP_H */
index fc6b4ff0d52c5cc67e93fb30b2954148e31f6db8..4213a58b4afc12d29c65ba918cf0fd096c847252 100644 (file)
@@ -120,11 +120,6 @@ static LOG_FileID logfileid;
 
 /* ================================================== */
 
-/* Reference ID supplied when we are locally referenced */
-#define LOCAL_REFERENCE_ID 0x7f7f0101UL
-
-/* ================================================== */
-
 /* Exponential moving averages of absolute clock frequencies
    used as a fallback when synchronisation is lost. */
 
@@ -1109,12 +1104,10 @@ REF_SetManualReference
  double skew
 )
 {
-  uint32_t manual_refid = 0x4D414E55; /* MANU */
-
   /* We are not synchronised to an external source, as such.  This is
-   only supposed to be used with the local source option, really
-   ... */
-  REF_SetReference(0, LEAP_Unsynchronised, 1, manual_refid, NULL,
+     only supposed to be used with the local source option, really.
+     Log as MANU in the tracking log, packets will have NTP_REFID_LOCAL. */
+  REF_SetReference(0, LEAP_Unsynchronised, 1, 0x4D414E55UL, NULL,
                    ref_time, offset, 0.0, frequency, skew, 0.0, 0.0);
 }
 
@@ -1200,7 +1193,7 @@ REF_GetReferenceParams
     *is_synchronised = 1;
 
     *stratum = local_stratum;
-    *ref_id = LOCAL_REFERENCE_ID;
+    *ref_id = NTP_REFID_LOCAL;
     /* Make the reference time be now less a second - this will
        scarcely affect the client, but will ensure that the transmit
        timestamp cannot come before this (which would cause test 7 to
@@ -1222,7 +1215,7 @@ REF_GetReferenceParams
 
     *leap_status = LEAP_Unsynchronised;
     *stratum = NTP_MAX_STRATUM;
-    *ref_id = 0;
+    *ref_id = NTP_REFID_UNSYNC;
     ref_time->tv_sec = ref_time->tv_usec = 0;
     /* These values seem to be standard for a client, and
        any peer or client of ours will ignore them anyway because
@@ -1336,7 +1329,7 @@ REF_GetTrackingReport(RPT_TrackingReport *rep)
   LCL_GetOffsetCorrection(&now_raw, &correction, NULL);
   UTI_AddDoubleToTimeval(&now_raw, correction, &now_cooked);
 
-  rep->ref_id = 0;
+  rep->ref_id = NTP_REFID_UNSYNC;
   rep->ip_addr.family = IPADDR_UNSPEC;
   rep->stratum = 0;
   rep->leap_status = our_leap_status;
@@ -1368,7 +1361,7 @@ REF_GetTrackingReport(RPT_TrackingReport *rep)
 
   } else if (enable_local_stratum) {
 
-    rep->ref_id = LOCAL_REFERENCE_ID;
+    rep->ref_id = NTP_REFID_LOCAL;
     rep->ip_addr.family = IPADDR_UNSPEC;
     rep->stratum = local_stratum;
     rep->ref_time = now_cooked;