reference: move definition of special refids to ntp.h

This commit is contained in:
Miroslav Lichvar 2015-06-22 09:13:15 +02:00
parent 802cdb3230
commit 6be54f366c
2 changed files with 11 additions and 14 deletions

4
ntp.h
View file

@ -109,4 +109,8 @@ typedef struct {
#define NTP_LVM(leap, version, mode) \ #define NTP_LVM(leap, version, mode) \
((((leap) << 6) & 0xc0) | (((version) << 3) & 0x38) | ((mode) & 0x07)) ((((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 */ #endif /* GOT_NTP_H */

View 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 /* Exponential moving averages of absolute clock frequencies
used as a fallback when synchronisation is lost. */ used as a fallback when synchronisation is lost. */
@ -1109,12 +1104,10 @@ REF_SetManualReference
double skew double skew
) )
{ {
uint32_t manual_refid = 0x4D414E55; /* MANU */
/* We are not synchronised to an external source, as such. This is /* We are not synchronised to an external source, as such. This is
only supposed to be used with the local source option, really 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, manual_refid, NULL, REF_SetReference(0, LEAP_Unsynchronised, 1, 0x4D414E55UL, NULL,
ref_time, offset, 0.0, frequency, skew, 0.0, 0.0); ref_time, offset, 0.0, frequency, skew, 0.0, 0.0);
} }
@ -1200,7 +1193,7 @@ REF_GetReferenceParams
*is_synchronised = 1; *is_synchronised = 1;
*stratum = local_stratum; *stratum = local_stratum;
*ref_id = LOCAL_REFERENCE_ID; *ref_id = NTP_REFID_LOCAL;
/* Make the reference time be now less a second - this will /* Make the reference time be now less a second - this will
scarcely affect the client, but will ensure that the transmit scarcely affect the client, but will ensure that the transmit
timestamp cannot come before this (which would cause test 7 to timestamp cannot come before this (which would cause test 7 to
@ -1222,7 +1215,7 @@ REF_GetReferenceParams
*leap_status = LEAP_Unsynchronised; *leap_status = LEAP_Unsynchronised;
*stratum = NTP_MAX_STRATUM; *stratum = NTP_MAX_STRATUM;
*ref_id = 0; *ref_id = NTP_REFID_UNSYNC;
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
any peer or client of ours will ignore them anyway because 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); LCL_GetOffsetCorrection(&now_raw, &correction, NULL);
UTI_AddDoubleToTimeval(&now_raw, correction, &now_cooked); UTI_AddDoubleToTimeval(&now_raw, correction, &now_cooked);
rep->ref_id = 0; rep->ref_id = NTP_REFID_UNSYNC;
rep->ip_addr.family = IPADDR_UNSPEC; rep->ip_addr.family = IPADDR_UNSPEC;
rep->stratum = 0; rep->stratum = 0;
rep->leap_status = our_leap_status; rep->leap_status = our_leap_status;
@ -1368,7 +1361,7 @@ REF_GetTrackingReport(RPT_TrackingReport *rep)
} else if (enable_local_stratum) { } else if (enable_local_stratum) {
rep->ref_id = LOCAL_REFERENCE_ID; rep->ref_id = NTP_REFID_LOCAL;
rep->ip_addr.family = IPADDR_UNSPEC; rep->ip_addr.family = IPADDR_UNSPEC;
rep->stratum = local_stratum; rep->stratum = local_stratum;
rep->ref_time = now_cooked; rep->ref_time = now_cooked;