if (SRC_ReportSource(ntohl(rx_message->data.source_data.index), &report, &now_corr)) {
switch (SRC_GetType(ntohl(rx_message->data.source_data.index))) {
case SRC_NTP:
- NSR_ReportSource(&report, &now_corr);
+ if (!NSR_ReportSource(&report.ip_addr, &report))
+ return;
break;
case SRC_REFCLOCK:
- RCL_ReportSource(&report, &now_corr);
+ if (report.ip_addr.family != IPADDR_INET4 ||
+ !RCL_ReportSource(report.ip_addr.addr.in4, &report))
+ return;
break;
+ default:
+ return;
}
- tx_message->reply = htons(RPY_SOURCE_DATA);
-
UTI_IPHostToNetwork(&report.ip_addr, &tx_message->data.source_data.ip_addr);
tx_message->data.source_data.stratum = htons(report.stratum);
tx_message->data.source_data.poll = htons(report.poll);
case RPT_SELECTED:
tx_message->data.source_data.state = htons(RPY_SD_ST_SELECTED);
break;
+ default:
+ return;
}
switch (report.mode) {
case RPT_NTP_CLIENT:
case RPT_LOCAL_REFERENCE:
tx_message->data.source_data.mode = htons(RPY_SD_MD_REF);
break;
+ default:
+ return;
}
tx_message->data.source_data.flags = htons(0);
tx_message->data.source_data.reachability = htons(report.reachability);
tx_message->data.source_data.orig_latest_meas = UTI_FloatHostToNetwork(report.orig_latest_meas);
tx_message->data.source_data.latest_meas = UTI_FloatHostToNetwork(report.latest_meas);
tx_message->data.source_data.latest_meas_err = UTI_FloatHostToNetwork(report.latest_meas_err);
+
+ tx_message->reply = htons(RPY_SOURCE_DATA);
} else {
tx_message->status = htons(STT_NOSUCHSOURCE);
}
/* ================================================== */
void
-NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report, struct timespec *now)
+NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report)
{
report->poll = get_transmit_poll(inst);
extern void NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples);
-extern void NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report, struct timespec *now);
+extern void NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report);
extern void NCR_GetAuthReport(NCR_Instance inst, RPT_AuthReport *report);
extern void NCR_GetNTPReport(NCR_Instance inst, RPT_NTPReport *report);
}
/* ================================================== */
-/* The ip address is assumed to be completed on input, that is how we
- identify the source record. */
-void
-NSR_ReportSource(RPT_SourceReport *report, struct timespec *now)
+int
+NSR_ReportSource(IPAddr *ip_addr, RPT_SourceReport *report)
{
int slot;
- if (find_slot(&report->ip_addr, &slot)) {
- NCR_ReportSource(get_record(slot)->data, report, now);
- } else {
- report->poll = 0;
- report->latest_meas_ago = 0;
- }
+ if (!find_slot(ip_addr, &slot))
+ return 0;
+
+ NCR_ReportSource(get_record(slot)->data, report);
+ return 1;
}
/* ================================================== */
extern int NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples, IPAddr *mask, IPAddr *address);
-extern void NSR_ReportSource(RPT_SourceReport *report, struct timespec *now);
+extern int NSR_ReportSource(IPAddr *ip_addr, RPT_SourceReport *report);
extern int NSR_GetAuthReport(IPAddr *address, RPT_AuthReport *report);
}
}
-void
-RCL_ReportSource(RPT_SourceReport *report, struct timespec *now)
+int
+RCL_ReportSource(uint32_t ref_id, RPT_SourceReport *report)
{
unsigned int i;
- uint32_t ref_id;
-
- assert(report->ip_addr.family == IPADDR_INET4);
- ref_id = report->ip_addr.addr.in4;
for (i = 0; i < ARR_GetSize(refclocks); i++) {
RCL_Instance inst = get_refclock(i);
if (inst->ref_id == ref_id) {
report->poll = inst->poll;
report->mode = RPT_LOCAL_REFERENCE;
- break;
+ return 1;
}
}
+
+ return 0;
}
int
extern void RCL_Finalise(void);
extern int RCL_AddRefclock(RefclockParameters *params);
extern void RCL_StartRefclocks(void);
-extern void RCL_ReportSource(RPT_SourceReport *report, struct timespec *now);
+extern int RCL_ReportSource(uint32_t ref_id, RPT_SourceReport *report);
extern int RCL_ModifyOffset(uint32_t ref_id, double offset);
/* functions used by drivers */
{
}
-void
-RCL_ReportSource(RPT_SourceReport *report, struct timespec *now)
+int
+RCL_ReportSource(uint32_t ref_id, RPT_SourceReport *report)
{
- memset(report, 0, sizeof (*report));
+ return 0;
}
int