]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: add NTS support
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 7 Mar 2019 10:52:16 +0000 (11:52 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Mar 2020 15:02:15 +0000 (16:02 +0100)
Allow the nts and ntsport options to be specified for sources added from
chronyc. This is an incompatible change in the request, but there was no
release using the new REQ_ADD_SOURCE command yet.

candm.h
client.c
cmdmon.c

diff --git a/candm.h b/candm.h
index 575f1edbf7f3604d33ad5569ca8aee1695a44401..2d6699787c16d6da67bfe0cf07df1a47259b55ab 100644 (file)
--- a/candm.h
+++ b/candm.h
@@ -262,6 +262,7 @@ typedef struct {
 #define REQ_ADDSRC_REQUIRE 0x40
 #define REQ_ADDSRC_INTERLEAVED 0x80
 #define REQ_ADDSRC_BURST 0x100
+#define REQ_ADDSRC_NTS 0x200
 
 typedef struct {
   uint32_t type;
@@ -277,6 +278,7 @@ typedef struct {
   int32_t min_samples;
   int32_t max_samples;
   uint32_t authkey;
+  uint32_t nts_port;
   Float max_delay;
   Float max_delay_ratio;
   Float max_delay_dev_ratio;
index b87c1a318ec882296229d90943bbdf26077305d8..de08be23b77f8be4047765ee1e7ae6d66090c11b 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1131,6 +1131,7 @@ process_cmd_add_source(CMD_Request *msg, char *line)
       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.nts_port = htonl(data.params.nts_port);
       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 =
@@ -1144,6 +1145,7 @@ process_cmd_add_source(CMD_Request *msg, char *line)
           (data.params.iburst ? REQ_ADDSRC_IBURST : 0) |
           (data.params.interleaved ? REQ_ADDSRC_INTERLEAVED : 0) |
           (data.params.burst ? REQ_ADDSRC_BURST : 0) |
+          (data.params.nts ? REQ_ADDSRC_NTS : 0) |
           (data.params.sel_options & SRC_SELECT_PREFER ? REQ_ADDSRC_PREFER : 0) |
           (data.params.sel_options & SRC_SELECT_NOSELECT ? REQ_ADDSRC_NOSELECT : 0) |
           (data.params.sel_options & SRC_SELECT_TRUST ? REQ_ADDSRC_TRUST : 0) |
index 5e3fc5562044142cf1c3be141ccd77a1529f599e..7950e7abf7e8257f8a594618f0ed7d3f773d2ba3 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -723,6 +723,7 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
   params.max_samples = ntohl(rx_message->data.ntp_source.max_samples);
   params.filter_length = ntohl(rx_message->data.ntp_source.filter_length);
   params.authkey = ntohl(rx_message->data.ntp_source.authkey);
+  params.nts_port = ntohl(rx_message->data.ntp_source.nts_port);
   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);
@@ -738,13 +739,12 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
   params.iburst = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_IBURST ? 1 : 0;
   params.interleaved = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_INTERLEAVED ? 1 : 0;
   params.burst = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_BURST ? 1 : 0;
+  params.nts = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_NTS ? 1 : 0;
   params.sel_options =
     (ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_PREFER ? SRC_SELECT_PREFER : 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.nts = 0;
-  params.nts_port = 0;
 
   status = NSR_AddSourceByName(name, port, pool, type, &params);
   switch (status) {