]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: define NTP_MAX_STRATUM for other modules
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 14 Oct 2014 15:24:41 +0000 (17:24 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 14 Oct 2014 15:25:55 +0000 (17:25 +0200)
broadcast.c
ntp.h
ntp_core.c
reference.c

index ca12eec92dba42f4a3414d243dcc2f6042f26a31..30e19f131513c3b85b12ec611d629787e25ae49a 100644 (file)
@@ -90,6 +90,9 @@ timeout_handler(void *arbitrary)
     leap = LEAP_Unsynchronised;
   }
 
+  if (our_stratum >= NTP_MAX_STRATUM)
+    our_stratum = 0;
+
   message.lvm = NTP_LVM(leap, NTP_VERSION, MODE_BROADCAST);
   message.stratum = our_stratum;
   message.poll = 6; /* FIXME: what should this be? */
diff --git a/ntp.h b/ntp.h
index d06b1903ecd06575608dafc8396bb9519b3d9950..0e012be3f80b95c430c44740fb8df27fc662c5cc 100644 (file)
--- a/ntp.h
+++ b/ntp.h
@@ -41,6 +41,9 @@ typedef uint32_t NTP_int32;
 /* The NTP protocol version that we support */
 #define NTP_VERSION 4
 
+/* Maximum stratum number (infinity) */
+#define NTP_MAX_STRATUM 16
+
 /* The minimum valid length of an extension field */
 #define NTP_MIN_EXTENSION_LENGTH 16
 
index 599b3fb70c77e9ec23c42c5644dffed0a238e750..08043cdc923c4e833f2ddaf3f2472a9b821d58c6 100644 (file)
@@ -201,9 +201,6 @@ struct NCR_Instance_Record {
 /* Maximum allowed dispersion - as defined in RFC 5905 (16 seconds) */
 #define NTP_MAX_DISPERSION 16.0
 
-/* Maximum stratum number */
-#define NTP_MAX_STRATUM 16
-
 /* Invalid stratum number */
 #define NTP_INVALID_STRATUM 0
 
index 494bfe961e3fa9f0f7923401195f34d87f95e3a5..62489f0db98507f0ca01ae1f526d58dd61a7f01b 100644 (file)
@@ -1089,7 +1089,7 @@ REF_GetReferenceParams
     *is_synchronised = 0;
 
     *leap_status = LEAP_Unsynchronised;
-    *stratum = 0;
+    *stratum = NTP_MAX_STRATUM;
     *ref_id = 0;
     ref_time->tv_sec = ref_time->tv_usec = 0;
     /* These values seem to be standard for a client, and
@@ -1111,7 +1111,7 @@ REF_GetOurStratum(void)
   } else if (enable_local_stratum) {
     return local_stratum;
   } else {
-    return 16;
+    return NTP_MAX_STRATUM;
   }
 }