/* ================================================== */
/* Structure used to hold info for selecting between sources */
struct SelectInfo {
+ NTP_Leap leap;
int stratum;
int select_ok;
double std_dev;
source */
struct SRC_Instance_Record {
SST_Stats stats;
- NTP_Leap leap_status; /* Leap status */
int index; /* Index back into the array of source */
uint32_t ref_id; /* The reference ID of this source
(i.e. from its IP address, NOT the
void
SRC_ResetInstance(SRC_Instance instance)
{
- instance->leap_status = LEAP_Normal;
instance->active = 0;
instance->updates = 0;
instance->reachability = 0;
assert(initialised);
- inst->leap_status = leap_status;
-
DEBUG_LOG("ip=[%s] t=%s ofs=%f del=%f disp=%f str=%d",
source_to_string(inst), UTI_TimespecToString(sample_time), -offset,
root_delay, root_dispersion, stratum);
/* WE HAVE TO NEGATE OFFSET IN THIS CALL, IT IS HERE THAT THE SENSE OF OFFSET
IS FLIPPED */
- SST_AccumulateSample(inst->stats, sample_time, -offset, peer_delay, peer_dispersion, root_delay, root_dispersion, stratum);
+ SST_AccumulateSample(inst->stats, sample_time, -offset, peer_delay, peer_dispersion,
+ root_delay, root_dispersion, stratum, leap_status);
SST_DoNewRegression(inst->stats);
}
}
si = &sources[i]->sel_info;
- SST_GetSelectionData(sources[i]->stats, &now, &si->stratum,
+ SST_GetSelectionData(sources[i]->stats, &now, &si->stratum, &si->leap,
&si->lo_limit, &si->hi_limit, &si->root_distance,
&si->std_dev, &first_sample_ago,
&si->last_sample_ago, &si->select_ok);
if (best_trust_depth && !(sources[index]->sel_options & SRC_SELECT_TRUST))
continue;
leap_votes++;
- if (sources[index]->leap_status == LEAP_InsertSecond)
+ if (sources[index]->sel_info.leap == LEAP_InsertSecond)
leap_ins++;
- else if (sources[index]->leap_status == LEAP_DeleteSecond)
+ else if (sources[index]->sel_info.leap == LEAP_DeleteSecond)
leap_del++;
}
at the times the samples were generated */
int strata[MAX_SAMPLES];
+ /* The leap status from the last accumulated sample */
+ NTP_Leap leap;
};
/* ================================================== */
inst->nruns = 0;
inst->asymmetry_run = 0;
inst->asymmetry = 0.0;
+ inst->leap = LEAP_Unsynchronised;
}
/* ================================================== */
double offset,
double peer_delay, double peer_dispersion,
double root_delay, double root_dispersion,
- int stratum)
+ int stratum, NTP_Leap leap)
{
int n, m;
inst->root_delays[m] = root_delay;
inst->root_dispersions[m] = root_dispersion;
inst->strata[m] = stratum;
+ inst->leap = leap;
if (inst->peer_delays[n] < inst->fixed_min_delay)
inst->peer_delays[n] = 2.0 * inst->fixed_min_delay - inst->peer_delays[n];
void
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
- int *stratum,
+ int *stratum, NTP_Leap *leap,
double *offset_lo_limit,
double *offset_hi_limit,
double *root_distance,
j = get_buf_index(inst, inst->best_single_sample);
*stratum = inst->strata[get_buf_index(inst, inst->n_samples - 1)];
+ *leap = inst->leap;
*std_dev = inst->std_dev;
sample_elapsed = fabs(UTI_DiffTimespecsToDouble(now, &inst->sample_times[i]));
stratum is the stratum of the source from which the sample came.
*/
-extern void SST_AccumulateSample(SST_Stats inst, struct timespec *sample_time, double offset, double peer_delay, double peer_dispersion, double root_delay, double root_dispersion, int stratum);
+extern void SST_AccumulateSample(SST_Stats inst, struct timespec *sample_time, double offset, double peer_delay, double peer_dispersion, double root_delay, double root_dispersion, int stratum, NTP_Leap leap);
/* This function runs the linear regression operation on the data. It
finds the set of most recent samples that give the tightest
/* Get data needed for selection */
extern void
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
- int *stratum,
+ int *stratum, NTP_Leap *leap,
double *offset_lo_limit,
double *offset_hi_limit,
double *root_distance,