#define REQ_CLIENT_ACCESSES_BY_INDEX2 55
#define REQ_LOCAL2 56
#define REQ_NTP_DATA 57
-#define N_REQUEST_TYPES 58
+#define REQ_ADD_SERVER2 58
+#define REQ_ADD_PEER2 59
+#define N_REQUEST_TYPES 60
/* Structure used to exchange timespecs independent of time_t size */
typedef struct {
int32_t minpoll;
int32_t maxpoll;
int32_t presend_minpoll;
+ uint32_t min_stratum;
+ uint32_t poll_target;
+ uint32_t version;
+ uint32_t max_sources;
+ int32_t min_samples;
+ int32_t max_samples;
uint32_t authkey;
Float max_delay;
Float max_delay_ratio;
+ Float max_delay_dev_ratio;
+ Float offset;
uint32_t flags;
int32_t EOR;
} REQ_NTP_Source;
break;
}
- if (data.params.max_delay_dev_ratio != SRC_DEFAULT_MAXDELAYDEVRATIO)
- opt_name = "maxdelaydevratio";
- else if (data.params.max_samples != SRC_DEFAULT_MAXSAMPLES)
- opt_name = "maxsamples";
- else if (data.params.min_samples != SRC_DEFAULT_MINSAMPLES)
- opt_name = "minsamples";
- else if (data.params.max_sources != SRC_DEFAULT_MAXSOURCES)
- opt_name = "maxsources";
- else if (data.params.min_stratum != SRC_DEFAULT_MINSTRATUM)
- opt_name = "minstratum";
- else if (data.params.offset != 0.0)
- opt_name = "offset";
- else if (data.params.poll_target != SRC_DEFAULT_POLLTARGET)
- opt_name = "polltarget";
- else if (data.params.version != 0)
- opt_name = "version";
- else
- opt_name = NULL;
-
+ opt_name = NULL;
if (opt_name) {
LOG(LOGS_ERR, LOGF_Client, "%s can't be set in chronyc", opt_name);
break;
msg->data.ntp_source.minpoll = htonl(data.params.minpoll);
msg->data.ntp_source.maxpoll = htonl(data.params.maxpoll);
msg->data.ntp_source.presend_minpoll = htonl(data.params.presend_minpoll);
+ msg->data.ntp_source.min_stratum = htonl(data.params.min_stratum);
+ msg->data.ntp_source.poll_target = htonl(data.params.poll_target);
+ msg->data.ntp_source.version = htonl(data.params.version);
+ msg->data.ntp_source.max_sources = htonl(data.params.max_sources);
+ msg->data.ntp_source.min_samples = htonl(data.params.min_samples);
+ msg->data.ntp_source.max_samples = htonl(data.params.max_samples);
msg->data.ntp_source.authkey = htonl(data.params.authkey);
msg->data.ntp_source.max_delay = UTI_FloatHostToNetwork(data.params.max_delay);
msg->data.ntp_source.max_delay_ratio = UTI_FloatHostToNetwork(data.params.max_delay_ratio);
+ msg->data.ntp_source.max_delay_dev_ratio =
+ UTI_FloatHostToNetwork(data.params.max_delay_dev_ratio);
+ msg->data.ntp_source.offset = UTI_FloatHostToNetwork(data.params.offset);
msg->data.ntp_source.flags = htonl(
(data.params.online ? REQ_ADDSRC_ONLINE : 0) |
(data.params.auto_offline ? REQ_ADDSRC_AUTOOFFLINE : 0) |
static int
process_cmd_add_server(CMD_Request *msg, char *line)
{
- msg->command = htons(REQ_ADD_SERVER);
+ msg->command = htons(REQ_ADD_SERVER2);
return process_cmd_add_server_or_peer(msg, line);
}
static int
process_cmd_add_peer(CMD_Request *msg, char *line)
{
- msg->command = htons(REQ_ADD_PEER);
+ msg->command = htons(REQ_ADD_PEER2);
return process_cmd_add_server_or_peer(msg, line);
}
PERMIT_AUTH, /* CLIENT_ACCESSES_BY_INDEX2 */
PERMIT_AUTH, /* LOCAL2 */
PERMIT_AUTH, /* NTP_DATA */
+ PERMIT_AUTH, /* ADD_SERVER2 */
+ PERMIT_AUTH, /* ADD_PEER2 */
};
/* ================================================== */
params.minpoll = ntohl(rx_message->data.ntp_source.minpoll);
params.maxpoll = ntohl(rx_message->data.ntp_source.maxpoll);
params.presend_minpoll = ntohl(rx_message->data.ntp_source.presend_minpoll);
+ params.min_stratum = ntohl(rx_message->data.ntp_source.min_stratum);
+ params.poll_target = ntohl(rx_message->data.ntp_source.poll_target);
+ params.version = ntohl(rx_message->data.ntp_source.version);
+ params.max_sources = ntohl(rx_message->data.ntp_source.max_sources);
+ params.min_samples = ntohl(rx_message->data.ntp_source.min_samples);
+ params.max_samples = ntohl(rx_message->data.ntp_source.max_samples);
params.authkey = ntohl(rx_message->data.ntp_source.authkey);
+ params.max_delay = UTI_FloatNetworkToHost(rx_message->data.ntp_source.max_delay);
+ params.max_delay_ratio =
+ UTI_FloatNetworkToHost(rx_message->data.ntp_source.max_delay_ratio);
+ params.max_delay_dev_ratio =
+ UTI_FloatNetworkToHost(rx_message->data.ntp_source.max_delay_dev_ratio);
+ params.offset = UTI_FloatNetworkToHost(rx_message->data.ntp_source.offset);
+
params.online = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_ONLINE ? 1 : 0;
params.auto_offline = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_AUTOOFFLINE ? 1 : 0;
params.iburst = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_IBURST ? 1 : 0;
(ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_NOSELECT ? SRC_SELECT_NOSELECT : 0) |
(ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_TRUST ? SRC_SELECT_TRUST : 0) |
(ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_REQUIRE ? SRC_SELECT_REQUIRE : 0);
- params.max_delay = UTI_FloatNetworkToHost(rx_message->data.ntp_source.max_delay);
- params.max_delay_ratio = UTI_FloatNetworkToHost(rx_message->data.ntp_source.max_delay_ratio);
-
- /* not transmitted in cmdmon protocol yet */
- params.min_stratum = SRC_DEFAULT_MINSTRATUM;
- params.poll_target = SRC_DEFAULT_POLLTARGET;
- params.max_delay_dev_ratio = SRC_DEFAULT_MAXDELAYDEVRATIO;
- params.version = NTP_VERSION;
- params.max_sources = SRC_DEFAULT_MAXSOURCES;
- params.min_samples = SRC_DEFAULT_MINSAMPLES;
- params.max_samples = SRC_DEFAULT_MAXSAMPLES;
status = NSR_AddSource(&rem_addr, type, ¶ms);
switch (status) {
handle_cmdaccheck(&rx_message, &tx_message);
break;
- case REQ_ADD_SERVER:
+ case REQ_ADD_SERVER2:
handle_add_source(NTP_SERVER, &rx_message, &tx_message);
break;
- case REQ_ADD_PEER:
+ case REQ_ADD_PEER2:
handle_add_source(NTP_PEER, &rx_message, &tx_message);
break;
REQ_LENGTH_ENTRY(allow_deny, null), /* CMDDENYALL */
REQ_LENGTH_ENTRY(ac_check, null), /* ACCHECK */
REQ_LENGTH_ENTRY(ac_check, null), /* CMDACCHECK */
- REQ_LENGTH_ENTRY(ntp_source, null), /* ADD_SERVER */
- REQ_LENGTH_ENTRY(ntp_source, null), /* ADD_PEER */
+ { 0, 0 }, /* ADD_SERVER */
+ { 0, 0 }, /* ADD_PEER */
REQ_LENGTH_ENTRY(del_source, null), /* DEL_SOURCE */
REQ_LENGTH_ENTRY(null, null), /* WRITERTC */
REQ_LENGTH_ENTRY(dfreq, null), /* DFREQ */
client_accesses_by_index), /* CLIENT_ACCESSES_BY_INDEX2 */
REQ_LENGTH_ENTRY(local, null), /* LOCAL2 */
REQ_LENGTH_ENTRY(ntp_data, ntp_data), /* NTP_DATA */
+ REQ_LENGTH_ENTRY(ntp_source, null), /* ADD_SERVER2 */
+ REQ_LENGTH_ENTRY(ntp_source, null), /* ADD_PEER2 */
};
static const uint16_t reply_lengths[] = {