#define REQ_MAKESTEP 43
#define REQ_ACTIVITY 44
#define REQ_MODIFY_MINSTRATUM 45
-#define N_REQUEST_TYPES 46
+#define REQ_MODIFY_POLLTARGET 46
+#define N_REQUEST_TYPES 47
/* Special utoken value used to log on with first exchange being the
password. (This time value has long since gone by) */
int32_t EOR;
} REQ_Modify_Minstratum;
+typedef struct {
+ IPAddr address;
+ int32_t new_poll_target;
+ int32_t EOR;
+} REQ_Modify_Polltarget;
+
typedef struct {
Float new_max_update_skew;
int32_t EOR;
REQ_Modify_Maxdelay modify_maxdelay;
REQ_Modify_Maxdelayratio modify_maxdelayratio;
REQ_Modify_Minstratum modify_minstratum;
+ REQ_Modify_Polltarget modify_polltarget;
REQ_Modify_Maxupdateskew modify_maxupdateskew;
REQ_Logon logon;
REQ_Settime settime;
* offline command:: Warn that connectivity to a source will be lost
* online command:: Warn that connectivity to a source has been restored
* password command:: Provide password needed for most commands
+* polltarget command:: Set poll target for a source
* quit command:: Exit from chronyc
* retries command:: Set maximum number of retries
* rtcdata command:: Display RTC parameters
has to match @code{chronyd's} currently defined command key (@pxref{commandkey
directive}).
@c }}}
+@c {{{ polltarget
+@node polltarget command
+@subsubsection polltarget
+The @code{polltarget} command is used to modify the poll target for
+one of the current set of sources. It is equivalent to the
+@code{polltarget} option in the @code{server} directive in the
+configuration file (@pxref{server directive}).
+
+The syntax is as follows
+
+@example
+polltarget <host> <new-poll-target>
+@end example
+
+where the host can be specified as either a machine name or
+IP address.
+
+An example is
+
+@example
+polltarget foo.bar.com 12
+@end example
+
+which sets the poll target for the host @code{foo.bar.com}
+to 12.
+@c }}}
@c {{{ quit
@node quit command
@subsubsection quit
/* ================================================== */
+static int
+process_cmd_polltarget(CMD_Request *msg, char *line)
+{
+ IPAddr address;
+ int poll_target;
+ int ok;
+
+ if (read_address_integer(line, &address, &poll_target)) {
+ UTI_IPHostToNetwork(&address, &msg->data.modify_polltarget.address);
+ msg->data.modify_polltarget.new_poll_target = htonl(poll_target);
+ msg->command = htons(REQ_MODIFY_POLLTARGET);
+ ok = 1;
+ } else {
+ ok = 0;
+ }
+
+ return ok;
+
+}
+
+/* ================================================== */
+
static int
process_cmd_maxupdateskew(CMD_Request *msg, char *line)
{
do_normal_submit = process_cmd_maxupdateskew(&tx_message, p+13);
} else if (!strncmp(p, "minstratum", 10)) {
do_normal_submit = process_cmd_minstratum(&tx_message, p+10);
+ } else if (!strncmp(p, "polltarget", 10)) {
+ do_normal_submit = process_cmd_polltarget(&tx_message, p+10);
} else if (!strncmp(p, "settime", 7)) {
do_normal_submit = 0;
ret = process_cmd_settime(p+7);
PERMIT_AUTH, /* MANUAL_DELETE */
PERMIT_AUTH, /* MAKESTEP */
PERMIT_OPEN, /* ACTIVITY */
- PERMIT_AUTH /* MODIFY_MINSTRATUM */
+ PERMIT_AUTH, /* MODIFY_MINSTRATUM */
+ PERMIT_AUTH /* MODIFY_POLLTARGET */
};
/* ================================================== */
/* ================================================== */
+static void
+handle_modify_polltarget(CMD_Request *rx_message, CMD_Reply *tx_message)
+{
+ int status;
+ IPAddr address;
+ UTI_IPNetworkToHost(&rx_message->data.modify_polltarget.address, &address);
+ status = NSR_ModifyPolltarget(&address,
+ ntohl(rx_message->data.modify_polltarget.new_poll_target));
+
+ if (status) {
+ tx_message->status = htons(STT_SUCCESS);
+ } else {
+ tx_message->status = htons(STT_NOSUCHSOURCE);
+ }
+}
+
+/* ================================================== */
+
static void
handle_modify_maxupdateskew(CMD_Request *rx_message, CMD_Reply *tx_message)
{
handle_modify_minstratum(&rx_message, &tx_message);
break;
+ case REQ_MODIFY_POLLTARGET:
+ handle_modify_polltarget(&rx_message, &tx_message);
+ break;
+
default:
/* Ignore message */
break;
/* ================================================== */
+void
+NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target)
+{
+ inst->poll_target = new_poll_target;
+ LOG(LOGS_INFO, LOGF_NtpCore, "Source %s new polltarget %d",
+ UTI_IPToString(&inst->remote_addr.ip_addr), new_poll_target);
+}
+
+/* ================================================== */
+
void
NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples)
{
extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
+extern void NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target);
+
extern void NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples);
extern void NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report, struct timeval *now);
/* ================================================== */
+int
+NSR_ModifyPolltarget(IPAddr *address, int new_poll_target)
+{
+ int slot, found;
+ NTP_Remote_Address addr;
+ addr.ip_addr = *address;
+ addr.port = 0;
+
+ find_slot(&addr, &slot, &found);
+ if (found == 0) {
+ return 0;
+ } else {
+ NCR_ModifyPolltarget(records[slot].data, new_poll_target);
+ return 1;
+ }
+}
+
+/* ================================================== */
+
int
NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples,
IPAddr *mask, IPAddr *address)
extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
+extern int NSR_ModifyPolltarget(IPAddr *address, int new_poll_target);
+
extern int NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples, IPAddr *mask, IPAddr *address);
extern void NSR_ReportSource(RPT_SourceReport *report, struct timeval *now);
return offsetof(CMD_Request, data.activity.EOR);
case REQ_MODIFY_MINSTRATUM:
return offsetof(CMD_Request, data.modify_minstratum.EOR);
+ case REQ_MODIFY_POLLTARGET:
+ return offsetof(CMD_Request, data.modify_polltarget.EOR);
default:
/* If we fall through the switch, it most likely means we've forgotten to implement a new case */
assert(0);