Add flags field to chronyc add source request

This will allow adding new flags without breaking compatibility.
This commit is contained in:
Miroslav Lichvar 2009-12-02 15:19:54 +01:00
parent 1c128b0076
commit 41580fe589
3 changed files with 13 additions and 8 deletions

View file

@ -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
*/

View file

@ -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;

View file

@ -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);