cmdmon: add request to get source name

Specify a new request to get the name of the NTP source corresponding to
an address, which was originally specified in the configuration file or
chronyc add command.
This commit is contained in:
Miroslav Lichvar
2019-12-05 10:34:02 +01:00
parent 9300854439
commit 93f6358916
5 changed files with 78 additions and 2 deletions

View File

@@ -782,6 +782,29 @@ NSR_GetLocalRefid(IPAddr *address)
/* ================================================== */
char *
NSR_GetName(IPAddr *address)
{
NTP_Remote_Address remote_addr;
int slot, found;
SourceRecord *record;
remote_addr.ip_addr = *address;
remote_addr.port = 0;
find_slot(&remote_addr, &slot, &found);
if (!found)
return NULL;
record = get_record(slot);
if (record->name)
return record->name;
return UTI_IPToString(&record->remote_addr->ip_addr);
}
/* ================================================== */
/* This routine is called by ntp_io when a new packet arrives off the network,
possibly with an authentication tail */
void