From 41580fe5896e3bbd641533ec86bb4b0ca2392177 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 2 Dec 2009 15:19:54 +0100 Subject: [PATCH] Add flags field to chronyc add source request This will allow adding new flags without breaking compatibility. --- candm.h | 9 ++++++--- client.c | 5 +++-- cmdmon.c | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/candm.h b/candm.h index bedc834..7eb6042 100644 --- 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 */ diff --git a/client.c b/client.c index 0dd8ede..1981db5 100644 --- 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; diff --git a/cmdmon.c b/cmdmon.c index 5cbc89f..df52d16 100644 --- 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, ¶ms); @@ -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, ¶ms);