ntp: allow changing address of core instance
This commit is contained in:
parent
40f8591257
commit
29c1df4610
4 changed files with 35 additions and 0 deletions
23
ntp_core.c
23
ntp_core.c
|
@ -538,6 +538,29 @@ NCR_ResetInstance(NCR_Instance instance)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
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;
|
||||
|
||||
if (inst->mode == MODE_CLIENT)
|
||||
close_client_socket(inst);
|
||||
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);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
adjust_poll(NCR_Instance inst, double adj)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,9 @@ extern void NCR_StartInstance(NCR_Instance instance);
|
|||
/* Reset an instance */
|
||||
extern void NCR_ResetInstance(NCR_Instance inst);
|
||||
|
||||
/* Change the remote address of an instance */
|
||||
extern void NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr);
|
||||
|
||||
/* This routine is called when a new packet arrives off the network,
|
||||
and it relates to a source we have an ongoing protocol exchange with */
|
||||
extern void NCR_ProcessKnown(NTP_Packet *message, struct timeval *now, double now_err, NCR_Instance data, NTP_Local_Address *local_addr, int length);
|
||||
|
|
|
@ -1311,3 +1311,10 @@ SRC_Samples(SRC_Instance inst)
|
|||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
SRC_SelectOption SRC_GetSelectOption(SRC_Instance inst)
|
||||
{
|
||||
return inst->sel_option;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
|
|
@ -174,5 +174,7 @@ extern SRC_Type SRC_GetType(int index);
|
|||
|
||||
extern int SRC_Samples(SRC_Instance inst);
|
||||
|
||||
extern SRC_SelectOption SRC_GetSelectOption(SRC_Instance inst);
|
||||
|
||||
#endif /* GOT_SOURCES_H */
|
||||
|
||||
|
|
Loading…
Reference in a new issue