void
NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr)
{
- SRC_SelectOption sel_option;
-
inst->remote_addr = *remote_addr;
inst->tx_count = 0;
inst->presend_done = 0;
else
inst->local_addr.sock_fd = NIO_GetServerSocket(remote_addr);
- /* Replace sources and sourcestats instances */
- sel_option = SRC_GetSelectOption(inst->source);
- SRC_DestroyInstance(inst->source);
- inst->source = SRC_CreateNewInstance(UTI_IPToRefid(&remote_addr->ip_addr), SRC_NTP,
- sel_option, &inst->remote_addr.ip_addr);
+ /* Update the reference ID and reset the source/sourcestats instances */
+ SRC_SetRefid(inst->source, UTI_IPToRefid(&remote_addr->ip_addr),
+ &inst->remote_addr.ip_addr);
+ SRC_ResetInstance(inst->source);
}
/* ================================================== */
}
sources[n_sources] = result;
+
result->index = n_sources;
- result->leap_status = LEAP_Normal;
- result->ref_id = ref_id;
- result->ip_addr = addr;
- result->active = 0;
- result->updates = 0;
- result->reachability = 0;
- result->reachability_size = 0;
- result->distant = 0;
- result->status = SRC_BAD_STATS;
result->type = type;
- result->sel_score = 1.0;
result->sel_option = sel_option;
+ SRC_SetRefid(result, ref_id, addr);
+ SRC_ResetInstance(result);
+
n_sources++;
return result;
--selected_source_index;
}
+/* ================================================== */
+
+void
+SRC_ResetInstance(SRC_Instance instance)
+{
+ instance->leap_status = LEAP_Normal;
+ instance->active = 0;
+ instance->updates = 0;
+ instance->reachability = 0;
+ instance->reachability_size = 0;
+ instance->distant = 0;
+ instance->status = SRC_BAD_STATS;
+ instance->sel_score = 1.0;
+
+ SST_ResetInstance(instance->stats);
+}
+
+/* ================================================== */
+
+void
+SRC_SetRefid(SRC_Instance instance, uint32_t ref_id, IPAddr *addr)
+{
+ instance->ref_id = ref_id;
+ instance->ip_addr = addr;
+ SST_SetRefid(instance->stats, ref_id, addr);
+}
+
/* ================================================== */
/* Function to get the range of frequencies, relative to the given
source, that we believe the local clock lies within. The return
}
/* ================================================== */
-
-SRC_SelectOption SRC_GetSelectOption(SRC_Instance inst)
-{
- return inst->sel_option;
-}
-
-/* ================================================== */
extern void SRC_DestroyInstance(SRC_Instance instance);
+/* Function to reset a source */
+extern void SRC_ResetInstance(SRC_Instance instance);
+
+/* Function to change the sources's reference ID and IP address */
+extern void SRC_SetRefid(SRC_Instance instance, uint32_t ref_id, IPAddr *addr);
/* Function to get the range of frequencies, relative to the given
source, that we believe the local clock lies within. The return
extern int SRC_Samples(SRC_Instance inst);
-extern SRC_SelectOption SRC_GetSelectOption(SRC_Instance inst);
-
#endif /* GOT_SOURCES_H */
{
SST_Stats inst;
inst = MallocNew(struct SST_Stats_Record);
- inst->refid = refid;
- inst->ip_addr = addr;
+ SST_SetRefid(inst, refid, addr);
SST_ResetInstance(inst);
return inst;
inst->nruns = 0;
}
+/* ================================================== */
+
+void
+SST_SetRefid(SST_Stats inst, uint32_t refid, IPAddr *addr)
+{
+ inst->refid = refid;
+ inst->ip_addr = addr;
+}
+
/* ================================================== */
/* This function is called to prune the register down when it is full.
For now, just discard the oldest sample. */
/* This function resets an instance */
extern void SST_ResetInstance(SST_Stats inst);
+/* This function changes the reference ID and IP address */
+extern void SST_SetRefid(SST_Stats inst, uint32_t refid, IPAddr *addr);
+
/* This function accumulates a single sample into the statistics handler
sample_time is the epoch at which the sample is to be considered to