double root_delay;
double root_dispersion;
int stratum;
- NTP_Leap leap;
} NTP_Sample;
#endif /* GOT_NTP_H */
sample.root_delay = pkt_root_delay + sample.peer_delay;
sample.root_dispersion = pkt_root_dispersion + sample.peer_dispersion;
sample.stratum = MAX(message->stratum, inst->min_stratum);
- sample.leap = (NTP_Leap)pkt_leap;
/* Update the NTP timestamps. If it's a valid packet from a synchronised
source, the timestamps may be used later when processing a packet in the
inst->tx_count = 0;
SRC_UpdateReachability(inst->source, synced_packet);
+ SRC_SetLeapStatus(inst->source, pkt_leap);
if (good_packet) {
/* Adjust the polling interval, accumulate the sample, etc. */
sample.root_delay = instance->delay;
sample.peer_dispersion = dispersion;
sample.root_dispersion = dispersion;
- sample.leap = instance->leap_status;
/* Handle special case when PPS is used with the local reference */
if (instance->pps_active && instance->lock_ref == -1)
if (SPF_GetFilteredSample(inst->filter, &sample)) {
SRC_UpdateReachability(inst->source, 1);
+ SRC_SetLeapStatus(inst->source, inst->leap_status);
SRC_AccumulateSample(inst->source, &sample);
SRC_SelectSource(inst->source);
result->peer_delay = mean_peer_delay;
result->root_delay = mean_root_delay;
result->stratum = last_sample->stratum;
- result->leap = last_sample->leap;
return 1;
}
/* ================================================== */
+void
+SRC_SetLeapStatus(SRC_Instance inst, NTP_Leap leap)
+{
+ if (REF_IsLeapSecondClose())
+ return;
+
+ inst->leap = leap;
+}
+
+/* ================================================== */
+
/* This function is called by one of the source drivers when it has
a new sample that is to be accumulated.
SST_AccumulateSample(inst->stats, sample);
SST_DoNewRegression(inst->stats);
- inst->leap = sample->leap;
}
/* ================================================== */
/* Function to get access to the sourcestats instance */
extern SST_Stats SRC_GetSourcestats(SRC_Instance instance);
-/* This function is called by one of the source drivers when it has
- a new sample that is to be accumulated */
+/* Function to set the current leap status according to the source */
+extern void SRC_SetLeapStatus(SRC_Instance instance, NTP_Leap leap);
+
+/* Function to accumulate a new sample from the source */
extern void SRC_AccumulateSample(SRC_Instance instance, NTP_Sample *sample);
/* This routine sets the source as receiving reachability updates */
LCL_Initialise();
+ memset(&sample_in, 0, sizeof (sample_in));
+ memset(&sample_out, 0, sizeof (sample_out));
+
for (i = 0; i <= 100; i++) {
max_samples = random() % 20 + 1;
min_samples = random() % (max_samples) + 1;
sample_in.peer_delay = TST_GetRandomDouble(1.0e-2, 2.0e-2);
sample_in.root_delay = TST_GetRandomDouble(1.0e-1, 2.0e-1);
sample_in.stratum = random() % 16;
- sample_in.leap = random() % 4;
TEST_CHECK(SPF_AccumulateSample(filter, &sample_in));
TEST_CHECK(!SPF_AccumulateSample(filter, &sample_in));
sample_out.peer_delay <= 2.0e-2);
TEST_CHECK(sample_out.root_delay >= 1.0e-1 &&
sample_out.root_delay <= 2.0e-1);
- TEST_CHECK(sample_out.leap >= 0 && sample_out.leap <= 3);
TEST_CHECK(sample_out.stratum >= 0 && sample_out.stratum <= 15);
if (max_samples == 1)
sample.root_delay = sample.peer_delay;
sample.root_dispersion = sample.peer_dispersion;
sample.stratum = 1;
- sample.leap = LEAP_Normal;
DEBUG_LOG("source %d sample %d offset %f delay %f disp %f", j, k,
sample.offset, sample.peer_delay, sample.peer_dispersion);