]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Add flags field to chronyc add source request
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 2 Dec 2009 14:19:54 +0000 (15:19 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 2 Dec 2009 14:22:16 +0000 (15:22 +0100)
This will allow adding new flags without breaking compatibility.

candm.h
client.c
cmdmon.c

diff --git a/candm.h b/candm.h
index bedc834e077abffd4afb6bfe6a10c45097eb84c2..7eb604273907b6af145e0530a44ac3937c8e01fb 100644 (file)
--- a/candm.h
+++ b/candm.h
@@ -205,17 +205,20 @@ typedef struct {
   int32_t EOR;
 } REQ_Ac_Check;
 
+/* Flags used in NTP source requests */
+#define REQ_ADDSRC_ONLINE 0x1
+#define REQ_ADDSRC_AUTOOFFLINE 0x2
+
 typedef struct {
   IPAddr ip_addr;
   uint32_t port;
   int32_t minpoll;
   int32_t maxpoll;
   int32_t presend_minpoll;
-  int32_t online;
-  int32_t auto_offline;
   uint32_t authkey;
   int32_t max_delay;
   int32_t max_delay_ratio;
+  uint32_t flags;
   int32_t EOR;
 } REQ_NTP_Source;
 
@@ -322,7 +325,7 @@ typedef struct {
    Version 3 : NTP_Source message lengthened (auto_offline)
 
    Version 4 : IPv6 addressing added, 64-bit time values, sourcestats 
-   and tracking reports extended
+   and tracking reports extended, added flags to NTP source request
 
  */
 
index 0dd8ede04f5efe35d19f7df44d285e767868705d..1981db564470343405b708dee29ad05b5b2c8a63 100644 (file)
--- a/client.c
+++ b/client.c
@@ -919,11 +919,12 @@ process_cmd_add_server_or_peer(CMD_Request *msg, char *line)
       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.online = htonl(data.params.online);
-      msg->data.ntp_source.auto_offline = htonl(data.params.auto_offline);
       msg->data.ntp_source.authkey = htonl(data.params.authkey);
       msg->data.ntp_source.max_delay = REAL2WIRE(data.params.max_delay);
       msg->data.ntp_source.max_delay_ratio = REAL2WIRE(data.params.max_delay_ratio);
+      msg->data.ntp_source.flags = htonl(
+          (data.params.online ? REQ_ADDSRC_ONLINE : 0) |
+          (data.params.auto_offline ? REQ_ADDSRC_AUTOOFFLINE : 0));
       result = 1;
 
       break;
index 5cbc89f66716ee3103d1e172916ac049ac9d16fa..df52d163719886855344146af65e96c208d16e2b 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1228,8 +1228,8 @@ handle_add_server(CMD_Request *rx_message, CMD_Reply *tx_message)
   params.maxpoll = ntohl(rx_message->data.ntp_source.maxpoll);
   params.presend_minpoll = ntohl(rx_message->data.ntp_source.presend_minpoll);
   params.authkey = ntohl(rx_message->data.ntp_source.authkey);
-  params.online  = ntohl(rx_message->data.ntp_source.online);
-  params.auto_offline = ntohl(rx_message->data.ntp_source.auto_offline);
+  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.max_delay = WIRE2REAL(rx_message->data.ntp_source.max_delay);
   params.max_delay_ratio = WIRE2REAL(rx_message->data.ntp_source.max_delay_ratio);
   status = NSR_AddServer(&rem_addr, &params);
@@ -1268,7 +1268,8 @@ handle_add_peer(CMD_Request *rx_message, CMD_Reply *tx_message)
   params.maxpoll = ntohl(rx_message->data.ntp_source.maxpoll);
   params.presend_minpoll = ntohl(rx_message->data.ntp_source.presend_minpoll);
   params.authkey = ntohl(rx_message->data.ntp_source.authkey);
-  params.online  = ntohl(rx_message->data.ntp_source.online);
+  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.max_delay = WIRE2REAL(rx_message->data.ntp_source.max_delay);
   params.max_delay_ratio = WIRE2REAL(rx_message->data.ntp_source.max_delay_ratio);
   status = NSR_AddPeer(&rem_addr, &params);