Add polltarget command
This commit is contained in:
parent
7ab2c0e4a5
commit
bed5b72cbe
9 changed files with 119 additions and 2 deletions
10
candm.h
10
candm.h
|
@ -87,7 +87,8 @@
|
|||
#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) */
|
||||
|
@ -169,6 +170,12 @@ typedef struct {
|
|||
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;
|
||||
|
@ -380,6 +387,7 @@ typedef struct {
|
|||
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;
|
||||
|
|
27
chrony.texi
27
chrony.texi
|
@ -2855,6 +2855,7 @@ interface.
|
|||
* 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
|
||||
|
@ -3620,6 +3621,32 @@ The password is any string of characters not containing whitespace. It
|
|||
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
|
||||
|
|
24
client.c
24
client.c
|
@ -480,6 +480,28 @@ process_cmd_minstratum(CMD_Request *msg, char *line)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -2417,6 +2439,8 @@ process_line(char *line, int *quit)
|
|||
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);
|
||||
|
|
25
cmdmon.c
25
cmdmon.c
|
@ -159,7 +159,8 @@ static int permissions[] = {
|
|||
PERMIT_AUTH, /* MANUAL_DELETE */
|
||||
PERMIT_AUTH, /* MAKESTEP */
|
||||
PERMIT_OPEN, /* ACTIVITY */
|
||||
PERMIT_AUTH /* MODIFY_MINSTRATUM */
|
||||
PERMIT_AUTH, /* MODIFY_MINSTRATUM */
|
||||
PERMIT_AUTH /* MODIFY_POLLTARGET */
|
||||
};
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -921,6 +922,24 @@ handle_modify_minstratum(CMD_Request *rx_message, CMD_Reply *tx_message)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -2198,6 +2217,10 @@ read_from_cmd_socket(void *anything)
|
|||
handle_modify_minstratum(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_MODIFY_POLLTARGET:
|
||||
handle_modify_polltarget(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Ignore message */
|
||||
break;
|
||||
|
|
10
ntp_core.c
10
ntp_core.c
|
@ -1746,6 +1746,16 @@ NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,8 @@ extern void NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_rati
|
|||
|
||||
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);
|
||||
|
|
|
@ -574,6 +574,25 @@ NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
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)
|
||||
|
|
|
@ -93,6 +93,8 @@ extern int NSR_ModifyMaxdelayratio(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);
|
||||
|
||||
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);
|
||||
|
|
|
@ -149,6 +149,8 @@ PKL_CommandLength(CMD_Request *r)
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue