ntp: initialize remote address in ntpdata report
Don't wait for the first response with setting the address.
This commit is contained in:
parent
f323c814af
commit
b84d6759f9
1 changed files with 14 additions and 4 deletions
18
ntp_core.c
18
ntp_core.c
|
@ -556,6 +556,16 @@ take_offline(NCR_Instance inst)
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
reset_report(NCR_Instance inst)
|
||||||
|
{
|
||||||
|
memset(&inst->report, 0, sizeof (inst->report));
|
||||||
|
inst->report.remote_addr = inst->remote_addr.ip_addr;
|
||||||
|
inst->report.remote_port = inst->remote_addr.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
NCR_Instance
|
NCR_Instance
|
||||||
NCR_CreateInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
|
NCR_CreateInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
|
||||||
SourceParameters *params, const char *name)
|
SourceParameters *params, const char *name)
|
||||||
|
@ -672,12 +682,13 @@ NCR_CreateInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
|
||||||
zero_local_timestamp(&result->local_tx);
|
zero_local_timestamp(&result->local_tx);
|
||||||
result->burst_good_samples_to_go = 0;
|
result->burst_good_samples_to_go = 0;
|
||||||
result->burst_total_samples_to_go = 0;
|
result->burst_total_samples_to_go = 0;
|
||||||
memset(&result->report, 0, sizeof (result->report));
|
|
||||||
|
|
||||||
NCR_ResetInstance(result);
|
NCR_ResetInstance(result);
|
||||||
|
|
||||||
set_connectivity(result, params->connectivity);
|
set_connectivity(result, params->connectivity);
|
||||||
|
|
||||||
|
reset_report(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,7 +788,6 @@ NCR_ResetPoll(NCR_Instance instance)
|
||||||
void
|
void
|
||||||
NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr, int ntp_only)
|
NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr, int ntp_only)
|
||||||
{
|
{
|
||||||
memset(&inst->report, 0, sizeof (inst->report));
|
|
||||||
NCR_ResetInstance(inst);
|
NCR_ResetInstance(inst);
|
||||||
|
|
||||||
if (!ntp_only)
|
if (!ntp_only)
|
||||||
|
@ -798,6 +808,8 @@ NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr, int
|
||||||
SRC_SetRefid(inst->source, UTI_IPToRefid(&remote_addr->ip_addr),
|
SRC_SetRefid(inst->source, UTI_IPToRefid(&remote_addr->ip_addr),
|
||||||
&inst->remote_addr.ip_addr);
|
&inst->remote_addr.ip_addr);
|
||||||
SRC_ResetInstance(inst->source);
|
SRC_ResetInstance(inst->source);
|
||||||
|
|
||||||
|
reset_report(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
@ -2179,9 +2191,7 @@ process_response(NCR_Instance inst, NTP_Local_Address *local_addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the NTP report */
|
/* Update the NTP report */
|
||||||
inst->report.remote_addr = inst->remote_addr.ip_addr;
|
|
||||||
inst->report.local_addr = inst->local_addr.ip_addr;
|
inst->report.local_addr = inst->local_addr.ip_addr;
|
||||||
inst->report.remote_port = inst->remote_addr.port;
|
|
||||||
inst->report.leap = pkt_leap;
|
inst->report.leap = pkt_leap;
|
||||||
inst->report.version = pkt_version;
|
inst->report.version = pkt_version;
|
||||||
inst->report.mode = NTP_LVM_TO_MODE(message->lvm);
|
inst->report.mode = NTP_LVM_TO_MODE(message->lvm);
|
||||||
|
|
Loading…
Reference in a new issue