diff --git a/candm.h b/candm.h index e21d494..e4eafb7 100644 --- a/candm.h +++ b/candm.h @@ -90,7 +90,8 @@ #define REQ_MODIFY_MAKESTEP 50 #define REQ_SMOOTHING 51 #define REQ_SMOOTHTIME 52 -#define N_REQUEST_TYPES 53 +#define REQ_REFRESH 53 +#define N_REQUEST_TYPES 54 /* Special utoken value used to log on with first exchange being the password. (This time value has long since gone by) */ diff --git a/client.c b/client.c index cb8e6bb..28a5fc2 100644 --- a/client.c +++ b/client.c @@ -2293,6 +2293,14 @@ process_cmd_reselect(CMD_Request *msg, char *line) /* ================================================== */ +static void +process_cmd_refresh(CMD_Request *msg, char *line) +{ + msg->command = htons(REQ_REFRESH); +} + +/* ================================================== */ + static int process_cmd_waitsync(char *line) { @@ -2520,6 +2528,8 @@ process_line(char *line) do_normal_submit = 0; quit = 1; ret = 1; + } else if (!strcmp(command, "refresh")) { + process_cmd_refresh(&tx_message, line); } else if (!strcmp(command, "rekey")) { process_cmd_rekey(&tx_message, line); } else if (!strcmp(command, "reselect")) { diff --git a/cmdmon.c b/cmdmon.c index 8eaa0a2..a5b223d 100644 --- a/cmdmon.c +++ b/cmdmon.c @@ -129,6 +129,7 @@ static const char permissions[] = { PERMIT_AUTH, /* MODIFY_MAKESTEP */ PERMIT_OPEN, /* SMOOTHING */ PERMIT_AUTH, /* SMOOTHTIME */ + PERMIT_AUTH, /* REFRESH */ }; /* ================================================== */ @@ -1140,6 +1141,14 @@ handle_reselect(CMD_Request *rx_message, CMD_Reply *tx_message) SRC_ReselectSource(); } +/* ================================================== */ + +static void +handle_refresh(CMD_Request *rx_message, CMD_Reply *tx_message) +{ + NSR_RefreshAddresses(); +} + /* ================================================== */ /* Read a packet and process it */ @@ -1534,6 +1543,10 @@ read_from_cmd_socket(void *anything) handle_modify_polltarget(&rx_message, &tx_message); break; + case REQ_REFRESH: + handle_refresh(&rx_message, &tx_message); + break; + default: assert(0); break; diff --git a/ntp_sources.c b/ntp_sources.c index 9c56255..eca681c 100644 --- a/ntp_sources.c +++ b/ntp_sources.c @@ -703,6 +703,23 @@ NSR_HandleBadSource(IPAddr *address) /* ================================================== */ +void +NSR_RefreshAddresses(void) +{ + SourceRecord *record; + unsigned int i; + + for (i = 0; i < ARR_GetSize(records); i++) { + record = get_record(i); + if (!record->remote_addr || !record->name) + continue; + + resolve_source_replacement(record); + } +} + +/* ================================================== */ + static void remove_tentative_pool_sources(int pool) { SourceRecord *record; diff --git a/ntp_sources.h b/ntp_sources.h index 828a446..9bd2d3b 100644 --- a/ntp_sources.h +++ b/ntp_sources.h @@ -80,6 +80,9 @@ extern void NSR_RemoveAllSources(void); /* Procedure to try to find a replacement for a bad source */ extern void NSR_HandleBadSource(IPAddr *address); +/* Procedure to resolve all names again */ +extern void NSR_RefreshAddresses(void); + /* This routine is called by ntp_io when a new packet arrives off the network */ extern void NSR_ProcessReceive(NTP_Packet *message, struct timeval *now, double now_err, NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr, int length); diff --git a/pktlength.c b/pktlength.c index be773c2..e123ef4 100644 --- a/pktlength.c +++ b/pktlength.c @@ -150,6 +150,8 @@ command_unpadded_length(CMD_Request *r) return offsetof(CMD_Request, data.null.EOR); case REQ_SMOOTHTIME: return offsetof(CMD_Request, data.smoothtime.EOR); + case REQ_REFRESH: + return offsetof(CMD_Request, data.null.EOR); default: /* If we fall through the switch, it most likely means we've forgotten to implement a new case */ assert(0); @@ -304,6 +306,8 @@ PKL_CommandPaddingLength(CMD_Request *r) return PADDING_LENGTH(data.null.EOR, data.smoothing.EOR); case REQ_SMOOTHTIME: return PADDING_LENGTH(data.smoothtime.EOR, data.null.EOR); + case REQ_REFRESH: + return PADDING_LENGTH(data.null.EOR, data.null.EOR); default: /* If we fall through the switch, it most likely means we've forgotten to implement a new case */ assert(0);