#define REQ_ACTIVITY 44
#define REQ_MODIFY_MINSTRATUM 45
#define REQ_MODIFY_POLLTARGET 46
-#define N_REQUEST_TYPES 47
+#define REQ_MODIFY_MAXDELAYDEVRATIO 47
+#define N_REQUEST_TYPES 48
/* 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_Maxdelayratio;
+typedef struct {
+ IPAddr address;
+ Float new_max_delay_dev_ratio;
+ int32_t EOR;
+} REQ_Modify_Maxdelaydevratio;
+
typedef struct {
IPAddr address;
int32_t new_min_stratum;
REQ_Dump dump;
REQ_Modify_Maxdelay modify_maxdelay;
REQ_Modify_Maxdelayratio modify_maxdelayratio;
+ REQ_Modify_Maxdelaydevratio modify_maxdelaydevratio;
REQ_Modify_Minstratum modify_minstratum;
REQ_Modify_Polltarget modify_polltarget;
REQ_Modify_Maxupdateskew modify_maxupdateskew;
* manual command:: Enable/disable/configure options for settime
* maxdelay command:: Set max measurement delay for a source
* maxdelayratio command:: Set max measurement delay for a source as ratio
+* maxdelaydevratio command:: Set max measurement delay for a source as ratio to deviation
* maxpoll command:: Set maximum polling interval for a source
* maxupdateskew command:: Set safety threshold for clock gain/loss rate
* minpoll command:: Set minimum polling interval for a source
As for @code{maxdelay}, any measurement whose network delay is too large
will be discarded.
@c }}}
+@c {{{ maxdelaydevratio
+@node maxdelaydevratio command
+@subsubsection maxdelaydevratio
+This allows the @code{maxdelaydevratio} option for one of the sources to be
+modified, in the same way as specifying the @code{maxdelaydevratio} option
+for the @code{server} directive in the configuration file (@pxref{server
+directive}).
+
+The following examples illustrate the syntax
+
+@example
+maxdelaydevratio foo.bar.com 0.1
+maxdelaydevratio 1.2.3.4 1.0
+maxdelaydevratio 2001:db8::1 100.0
+@end example
+@c }}}
@c {{{ maxpoll
@node maxpoll command
@subsubsection maxpoll
/* ================================================== */
+static int
+process_cmd_maxdelaydevratio(CMD_Request *msg, char *line)
+{
+ IPAddr address;
+ double max_delay_dev_ratio;
+ int ok;
+
+ if (read_address_double(line, &address, &max_delay_dev_ratio)) {
+ UTI_IPHostToNetwork(&address, &msg->data.modify_maxdelaydevratio.address);
+ msg->data.modify_maxdelayratio.new_max_delay_ratio = UTI_FloatHostToNetwork(max_delay_dev_ratio);
+ msg->command = htons(REQ_MODIFY_MAXDELAYDEVRATIO);
+ ok = 1;
+ } else {
+ ok = 0;
+ }
+
+ return ok;
+
+}
+
+/* ================================================== */
+
static int
process_cmd_maxdelayratio(CMD_Request *msg, char *line)
{
do_normal_submit = process_cmd_maxpoll(&tx_message, p+7);
} else if (!strncmp(p, "dump", 4)) {
process_cmd_dump(&tx_message, p+4);
+ } else if (!strncmp(p, "maxdelaydevratio", 16)) {
+ do_normal_submit = process_cmd_maxdelaydevratio(&tx_message, p+16);
} else if (!strncmp(p, "maxdelayratio", 13)) {
do_normal_submit = process_cmd_maxdelayratio(&tx_message, p+13);
} else if (!strncmp(p, "maxdelay", 8)) {
PERMIT_AUTH, /* MAKESTEP */
PERMIT_OPEN, /* ACTIVITY */
PERMIT_AUTH, /* MODIFY_MINSTRATUM */
- PERMIT_AUTH /* MODIFY_POLLTARGET */
+ PERMIT_AUTH, /* MODIFY_POLLTARGET */
+ PERMIT_AUTH /* MODIFY_MAXDELAYDEVRATIO */
};
/* ================================================== */
/* ================================================== */
+static void
+handle_modify_maxdelaydevratio(CMD_Request *rx_message, CMD_Reply *tx_message)
+{
+ int status;
+ IPAddr address;
+ UTI_IPNetworkToHost(&rx_message->data.modify_maxdelaydevratio.address, &address);
+ status = NSR_ModifyMaxdelaydevratio(&address,
+ UTI_FloatNetworkToHost(rx_message->data.modify_maxdelaydevratio.new_max_delay_dev_ratio));
+ if (status) {
+ tx_message->status = htons(STT_SUCCESS);
+ } else {
+ tx_message->status = htons(STT_NOSUCHSOURCE);
+ }
+}
+
+/* ================================================== */
+
static void
handle_modify_minstratum(CMD_Request *rx_message, CMD_Reply *tx_message)
{
handle_modify_maxdelayratio(&rx_message, &tx_message);
break;
+ case REQ_MODIFY_MAXDELAYDEVRATIO:
+ handle_modify_maxdelaydevratio(&rx_message, &tx_message);
+ break;
+
case REQ_MODIFY_MAXUPDATESKEW:
handle_modify_maxupdateskew(&rx_message, &tx_message);
break;
/* ================================================== */
+void
+NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_dev_ratio)
+{
+ inst->max_delay_dev_ratio = new_max_delay_dev_ratio;
+ LOG(LOGS_INFO, LOGF_NtpCore, "Source %s new max delay dev ratio %f",
+ UTI_IPToString(&inst->remote_addr.ip_addr), new_max_delay_dev_ratio);
+}
+
+/* ================================================== */
+
void
NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum)
{
extern void NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_ratio);
+extern void NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_dev_ratio);
+
extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
extern void NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target);
/* ================================================== */
+int
+NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_dev_ratio)
+{
+ 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_ModifyMaxdelaydevratio(records[slot].data, new_max_delay_dev_ratio);
+ return 1;
+ }
+}
+
+/* ================================================== */
+
int
NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum)
{
extern int NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio);
+extern int NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_ratio);
+
extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
extern int NSR_ModifyPolltarget(IPAddr *address, int new_poll_target);
return offsetof(CMD_Request, data.modify_maxdelay.EOR);
case REQ_MODIFY_MAXDELAYRATIO:
return offsetof(CMD_Request, data.modify_maxdelayratio.EOR);
+ case REQ_MODIFY_MAXDELAYDEVRATIO:
+ return offsetof(CMD_Request, data.modify_maxdelaydevratio.EOR);
case REQ_MODIFY_MAXUPDATESKEW:
return offsetof(CMD_Request, data.modify_maxupdateskew.EOR);
case REQ_LOGON :