ntp: change NSR_RemoveSource() to accept IP address only
Change the function to accept IP address alone to make it clear that the port is ignored.
This commit is contained in:
parent
fb4c3f31c0
commit
145423068b
5 changed files with 9 additions and 11 deletions
7
cmdmon.c
7
cmdmon.c
|
@ -782,13 +782,12 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
|
|||
static void
|
||||
handle_del_source(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
NTP_Remote_Address rem_addr;
|
||||
NSR_Status status;
|
||||
IPAddr ip_addr;
|
||||
|
||||
UTI_IPNetworkToHost(&rx_message->data.del_source.ip_addr, &rem_addr.ip_addr);
|
||||
rem_addr.port = 0;
|
||||
UTI_IPNetworkToHost(&rx_message->data.del_source.ip_addr, &ip_addr);
|
||||
|
||||
status = NSR_RemoveSource(&rem_addr);
|
||||
status = NSR_RemoveSource(&ip_addr);
|
||||
switch (status) {
|
||||
case NSR_Success:
|
||||
break;
|
||||
|
|
|
@ -749,16 +749,15 @@ clean_source_record(SourceRecord *record)
|
|||
|
||||
/* Procedure to remove a source. We don't bother whether the port
|
||||
address is matched - we're only interested in removing a record for
|
||||
the right IP address. Thus the caller can specify the port number
|
||||
as zero if it wishes. */
|
||||
the right IP address. */
|
||||
NSR_Status
|
||||
NSR_RemoveSource(NTP_Remote_Address *remote_addr)
|
||||
NSR_RemoveSource(IPAddr *address)
|
||||
{
|
||||
int slot;
|
||||
|
||||
assert(initialised);
|
||||
|
||||
if (find_slot2(remote_addr, &slot) == 0)
|
||||
if (find_slot(address, &slot) == 0)
|
||||
return NSR_NoSuchSource;
|
||||
|
||||
clean_source_record(get_record(slot));
|
||||
|
|
|
@ -76,7 +76,7 @@ extern void NSR_StartSources(void);
|
|||
extern void NSR_AutoStartSources(void);
|
||||
|
||||
/* Procedure to remove a source */
|
||||
extern NSR_Status NSR_RemoveSource(NTP_Remote_Address *remote_addr);
|
||||
extern NSR_Status NSR_RemoveSource(IPAddr *address);
|
||||
|
||||
/* Procedure to remove all sources */
|
||||
extern void NSR_RemoveAllSources(void);
|
||||
|
|
2
stubs.c
2
stubs.c
|
@ -206,7 +206,7 @@ NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type, Source
|
|||
}
|
||||
|
||||
NSR_Status
|
||||
NSR_RemoveSource(NTP_Remote_Address *remote_addr)
|
||||
NSR_RemoveSource(IPAddr *address)
|
||||
{
|
||||
return NSR_NoSuchSource;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ test_unit(void)
|
|||
|
||||
for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
|
||||
DEBUG_LOG("removing source %s", UTI_IPToString(&addrs[j].ip_addr));
|
||||
NSR_RemoveSource(&addrs[j]);
|
||||
NSR_RemoveSource(&addrs[j].ip_addr);
|
||||
|
||||
for (k = 0; k < sizeof (addrs) / sizeof (addrs[0]); k++) {
|
||||
found = find_slot2(&addrs[k], &slot);
|
||||
|
|
Loading…
Reference in a new issue