/* ================================================== */
void
-NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr)
+NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr, int ntp_only)
{
memset(&inst->report, 0, sizeof (inst->report));
NCR_ResetInstance(inst);
extern void NCR_ResetPoll(NCR_Instance instance);
/* Change the remote address of an instance */
-extern void NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr);
+extern void NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr,
+ int ntp_only);
/* 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 */
/* ================================================== */
static NSR_Status
-replace_source(NTP_Remote_Address *old_addr, NTP_Remote_Address *new_addr)
+change_source_address(NTP_Remote_Address *old_addr, NTP_Remote_Address *new_addr,
+ int replacement)
{
int slot1, slot2, found;
SourceRecord *record;
return NSR_AlreadyInUse;
record = get_record(slot1);
- NCR_ChangeRemoteAddress(record->data, new_addr);
+ NCR_ChangeRemoteAddress(record->data, new_addr, !replacement);
record->remote_addr = NCR_GetRemoteAddress(record->data);
if (!UTI_IsIPReal(&old_addr->ip_addr) && UTI_IsIPReal(&new_addr->ip_addr)) {
if (auto_start_sources)
/* The hash table must be rebuilt for the changed address */
rehash_records();
- LOG(severity, "Source %s replaced with %s (%s)", UTI_IPToString(&old_addr->ip_addr),
+ LOG(severity, "Source %s %s %s (%s)", UTI_IPToString(&old_addr->ip_addr),
+ replacement ? "replaced with" : "changed to",
UTI_IPToString(&new_addr->ip_addr), name ? name : "");
} else {
LOG(severity, "Source %s (%s) changed port to %d",
return 0;
}
- if (replace_source(old_addr, new_addr) == NSR_AlreadyInUse)
+ if (change_source_address(old_addr, new_addr, 1) == NSR_AlreadyInUse)
return 0;
return 1;
/* ================================================== */
+NSR_Status
+NSR_UpdateSourceNtpAddress(NTP_Remote_Address *old_addr, NTP_Remote_Address *new_addr)
+{
+ if (new_addr->ip_addr.family == IPADDR_UNSPEC)
+ return NSR_InvalidAF;
+
+ return change_source_address(old_addr, new_addr, 0);
+}
+
+/* ================================================== */
+
static void remove_pool_sources(int pool, int tentative, int unresolved)
{
SourceRecord *record;
/* Procedure to resolve all names again */
extern void NSR_RefreshAddresses(void);
+/* Procedure to update the address of a source */
+extern NSR_Status NSR_UpdateSourceNtpAddress(NTP_Remote_Address *old_addr,
+ NTP_Remote_Address *new_addr);
+
/* Procedure to get local reference ID corresponding to a source */
extern uint32_t NSR_GetLocalRefid(IPAddr *address);