#define REQ_MANUAL_DELETE 42
#define REQ_MAKESTEP 43
#define REQ_ACTIVITY 44
-#define N_REQUEST_TYPES 45
+#define REQ_MODIFY_MINSTRATUM 45
+#define N_REQUEST_TYPES 46
/* 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;
+ int32_t new_min_stratum;
+ int32_t EOR;
+} REQ_Modify_Minstratum;
+
typedef struct {
Float new_max_update_skew;
int32_t EOR;
REQ_Dump dump;
REQ_Modify_Maxdelay modify_maxdelay;
REQ_Modify_Maxdelayratio modify_maxdelayratio;
+ REQ_Modify_Minstratum modify_minstratum;
REQ_Modify_Maxupdateskew modify_maxupdateskew;
REQ_Logon logon;
REQ_Settime settime;
* 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
+* minstratum command:: Set minimum stratum for a source
* 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
Note that the new minimum polling interval only takes effect after the
next measurement has been made.
@c }}}
+@c {{{ minstratum
+@node minstratum command
+@subsubsection minstratum
+The @code{minstratum} command is used to modify the minimum stratum
+for one of the current set of sources. It is equivalent to the
+@code{minstratum} option in the @code{server} directive in the
+configuration file (@pxref{server directive}).
+
+The syntax is as follows
+
+@example
+minstratum <host> <new-min-stratum>
+@end example
+
+where the host can be specified as either a machine name or
+IP address.
+
+An example is
+
+@example
+minpoll foo.bar.com 5
+@end example
+
+which sets the minimum stratum for the host @code{foo.bar.com}
+to 5.
+
+Note that the new minimum stratum only takes effect after the
+next measurement has been made.
+@c }}}
@c {{{ offline
@node offline command
@subsubsection offline
/* ================================================== */
+static int
+process_cmd_minstratum(CMD_Request *msg, char *line)
+{
+ IPAddr address;
+ int min_stratum;
+ int ok;
+
+ if (read_address_integer(line, &address, &min_stratum)) {
+ UTI_IPHostToNetwork(&address, &msg->data.modify_minstratum.address);
+ msg->data.modify_minstratum.new_min_stratum = htonl(min_stratum);
+ msg->command = htons(REQ_MODIFY_MINSTRATUM);
+ ok = 1;
+ } else {
+ ok = 0;
+ }
+
+ return ok;
+
+}
+
+/* ================================================== */
+
static int
process_cmd_maxupdateskew(CMD_Request *msg, char *line)
{
printf("manual list : Show previous settime entries\n");
printf("maxdelay <address> <new-max-delay> : Modify maximum round-trip valid sample delay for source\n");
printf("maxdelayratio <address> <new-max-ratio> : Modify max round-trip delay ratio for source\n");
- printf("maxpoll <address> <new-minpoll> : Modify maximum polling interval of source\n");
+ printf("maxpoll <address> <new-maxpoll> : Modify maximum polling interval of source\n");
printf("maxupdateskew <new-max-skew> : Modify maximum skew for a clock frequency update to be made\n");
printf("minpoll <address> <new-minpoll> : Modify minimum polling interval of source\n");
+ printf("minstratum <address> <new-min-stratum> : Modify minimum stratum of source\n");
printf("offline [<mask>/<masked-address>] : Set sources in subnet to offline status\n");
printf("online [<mask>/<masked-address>] : Set sources in subnet to online status\n");
printf("password [<new-password>] : Set command authentication password\n");
do_normal_submit = process_cmd_maxdelay(&tx_message, p+8);
} else if (!strncmp(p, "maxupdateskew", 13)) {
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, "settime", 7)) {
do_normal_submit = 0;
ret = process_cmd_settime(p+7);
PERMIT_OPEN, /* MANUAL_LIST */
PERMIT_AUTH, /* MANUAL_DELETE */
PERMIT_AUTH, /* MAKESTEP */
- PERMIT_OPEN /* ACTIVITY */
+ PERMIT_OPEN, /* ACTIVITY */
+ PERMIT_AUTH /* MODIFY_MINSTRATUM */
};
/* ================================================== */
/* ================================================== */
+static void
+handle_modify_minstratum(CMD_Request *rx_message, CMD_Reply *tx_message)
+{
+ int status;
+ IPAddr address;
+ UTI_IPNetworkToHost(&rx_message->data.modify_minpoll.address, &address);
+ status = NSR_ModifyMinstratum(&address,
+ ntohl(rx_message->data.modify_minstratum.new_min_stratum));
+
+ 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_activity(&rx_message, &tx_message);
break;
+ case REQ_MODIFY_MINSTRATUM:
+ handle_modify_minstratum(&rx_message, &tx_message);
+ break;
+
default:
/* Ignore message */
break;
/* ================================================== */
+void
+NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum)
+{
+ inst->min_stratum = new_min_stratum;
+ LOG(LOGS_INFO, LOGF_NtpCore, "Source %s new minstratum %d",
+ UTI_IPToString(&inst->remote_addr.ip_addr), new_min_stratum);
+}
+
+/* ================================================== */
+
void
NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples)
{
extern void NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_ratio);
+extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
+
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_ModifyMinstratum(IPAddr *address, int new_min_stratum)
+{
+ 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_ModifyMinstratum(records[slot].data, new_min_stratum);
+ return 1;
+ }
+}
+
+/* ================================================== */
+
int
NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples,
IPAddr *mask, IPAddr *address)
extern int NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio);
+extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
+
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.make_step.EOR);
case REQ_ACTIVITY:
return offsetof(CMD_Request, data.activity.EOR);
+ case REQ_MODIFY_MINSTRATUM:
+ return offsetof(CMD_Request, data.modify_minstratum.EOR);
default:
/* If we fall through the switch, it most likely means we've forgotten to implement a new case */
assert(0);