mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 20:25:06 -05:00
ntp: allow changing address of core instance
This commit is contained in:
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user