ntp: define NTP_MAX_STRATUM for other modules

This commit is contained in:
Miroslav Lichvar 2014-10-14 17:24:41 +02:00
parent af0b83a2c3
commit e0059bcc6b
4 changed files with 8 additions and 5 deletions

View file

@ -90,6 +90,9 @@ timeout_handler(void *arbitrary)
leap = LEAP_Unsynchronised; leap = LEAP_Unsynchronised;
} }
if (our_stratum >= NTP_MAX_STRATUM)
our_stratum = 0;
message.lvm = NTP_LVM(leap, NTP_VERSION, MODE_BROADCAST); message.lvm = NTP_LVM(leap, NTP_VERSION, MODE_BROADCAST);
message.stratum = our_stratum; message.stratum = our_stratum;
message.poll = 6; /* FIXME: what should this be? */ message.poll = 6; /* FIXME: what should this be? */

3
ntp.h
View file

@ -41,6 +41,9 @@ typedef uint32_t NTP_int32;
/* The NTP protocol version that we support */ /* The NTP protocol version that we support */
#define NTP_VERSION 4 #define NTP_VERSION 4
/* Maximum stratum number (infinity) */
#define NTP_MAX_STRATUM 16
/* The minimum valid length of an extension field */ /* The minimum valid length of an extension field */
#define NTP_MIN_EXTENSION_LENGTH 16 #define NTP_MIN_EXTENSION_LENGTH 16

View file

@ -201,9 +201,6 @@ struct NCR_Instance_Record {
/* Maximum allowed dispersion - as defined in RFC 5905 (16 seconds) */ /* Maximum allowed dispersion - as defined in RFC 5905 (16 seconds) */
#define NTP_MAX_DISPERSION 16.0 #define NTP_MAX_DISPERSION 16.0
/* Maximum stratum number */
#define NTP_MAX_STRATUM 16
/* Invalid stratum number */ /* Invalid stratum number */
#define NTP_INVALID_STRATUM 0 #define NTP_INVALID_STRATUM 0

View file

@ -1089,7 +1089,7 @@ REF_GetReferenceParams
*is_synchronised = 0; *is_synchronised = 0;
*leap_status = LEAP_Unsynchronised; *leap_status = LEAP_Unsynchronised;
*stratum = 0; *stratum = NTP_MAX_STRATUM;
*ref_id = 0; *ref_id = 0;
ref_time->tv_sec = ref_time->tv_usec = 0; ref_time->tv_sec = ref_time->tv_usec = 0;
/* These values seem to be standard for a client, and /* These values seem to be standard for a client, and
@ -1111,7 +1111,7 @@ REF_GetOurStratum(void)
} else if (enable_local_stratum) { } else if (enable_local_stratum) {
return local_stratum; return local_stratum;
} else { } else {
return 16; return NTP_MAX_STRATUM;
} }
} }