From 93b5b08bedb1c5b8fa068d51a407a929a3dade6b Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 23 Apr 2010 12:40:50 +0200 Subject: [PATCH] Add iburst server option --- candm.h | 1 + chrony.texi | 4 ++++ client.c | 3 ++- cmdmon.c | 2 ++ cmdparse.c | 4 ++++ ntp_core.c | 4 ++++ srcparams.h | 1 + 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/candm.h b/candm.h index 25f16c1..49c68f4 100644 --- a/candm.h +++ b/candm.h @@ -215,6 +215,7 @@ typedef struct { /* Flags used in NTP source requests */ #define REQ_ADDSRC_ONLINE 0x1 #define REQ_ADDSRC_AUTOOFFLINE 0x2 +#define REQ_ADDSRC_IBURST 0x4 typedef struct { IPAddr ip_addr; diff --git a/chrony.texi b/chrony.texi index e0ab4f1..7c8eeec 100644 --- a/chrony.texi +++ b/chrony.texi @@ -2597,6 +2597,10 @@ chrony when disconnecting the dial-up link. (It will still be necessary to use chronyc's @code{online} (@pxref{online command}) command when the link has been established, to enable measurements to start.) +@item iburst +On start, make four measurements over a short duration (rather than +the usual periodic measurements). + @end table @c }}} @c {{{ tempcomp diff --git a/client.c b/client.c index c6a66df..55d17e7 100644 --- a/client.c +++ b/client.c @@ -912,7 +912,8 @@ process_cmd_add_server_or_peer(CMD_Request *msg, char *line) msg->data.ntp_source.max_delay_ratio = UTI_FloatHostToNetwork(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)); + (data.params.auto_offline ? REQ_ADDSRC_AUTOOFFLINE : 0) | + (data.params.iburst ? REQ_ADDSRC_IBURST : 0)); result = 1; break; diff --git a/cmdmon.c b/cmdmon.c index 5f0e9eb..26ea72e 100644 --- a/cmdmon.c +++ b/cmdmon.c @@ -1230,6 +1230,7 @@ handle_add_server(CMD_Request *rx_message, CMD_Reply *tx_message) params.authkey = ntohl(rx_message->data.ntp_source.authkey); 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; 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); status = NSR_AddServer(&rem_addr, ¶ms); @@ -1270,6 +1271,7 @@ handle_add_peer(CMD_Request *rx_message, CMD_Reply *tx_message) params.authkey = ntohl(rx_message->data.ntp_source.authkey); 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; 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); status = NSR_AddPeer(&rem_addr, ¶ms); diff --git a/cmdparse.c b/cmdparse.c index ddb84a1..ae301dd 100644 --- a/cmdparse.c +++ b/cmdparse.c @@ -56,6 +56,7 @@ CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src) src->params.max_delay_ratio = 16384.0; src->params.online = 1; src->params.auto_offline = 0; + src->params.iburst = 0; result = CPS_Success; @@ -143,6 +144,9 @@ CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src) } else if (!strncasecmp(cmd, "auto_offline", 12)) { src->params.auto_offline = 1; + } else if (!strncasecmp(cmd, "iburst", 6)) { + src->params.iburst = 1; + } else { result = CPS_BadOption; ok = 0; diff --git a/ntp_core.c b/ntp_core.c index ae54bc6..daeacb1 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -290,6 +290,10 @@ create_instance(NTP_Remote_Address *remote_addr, NTP_Mode mode, SourceParameters result->opmode = MD_OFFLINE; } + if (params->iburst) { + NCR_InitiateSampleBurst(result, 4, 8); + } + result->auto_offline = params->auto_offline; result->local_poll = params->minpoll; diff --git a/srcparams.h b/srcparams.h index bdcb33c..c4bccf0 100644 --- a/srcparams.h +++ b/srcparams.h @@ -37,6 +37,7 @@ typedef struct { int online; int auto_offline; int presend_minpoll; + int iburst; unsigned long authkey; double max_delay; double max_delay_ratio;