diff options
Diffstat (limited to 'ntpd/ntp_control.c')
| -rw-r--r-- | ntpd/ntp_control.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 49a197ed7c61..9c408034a4d7 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -28,6 +28,8 @@ #include "ntp_leapsec.h" #include "ntp_md5.h" /* provides OpenSSL digest API */ #include "lib_strbuf.h" +#include "timexsup.h" + #include <rc_cmdlength.h> #ifdef KERNEL_PLL # include "ntp_syscall.h" @@ -327,7 +329,8 @@ static const struct ctl_proc control_codes[] = { #define CC_FLAGS 11 #define CC_DEVICE 12 #define CC_VARLIST 13 -#define CC_MAXCODE CC_VARLIST +#define CC_FUDGEMINJIT 14 +#define CC_MAXCODE CC_FUDGEMINJIT /* * System variable values. The array can be indexed by the variable @@ -625,7 +628,8 @@ static const struct ctl_var clock_var[] = { { CC_FLAGS, RO, "flags" }, /* 11 */ { CC_DEVICE, RO, "device" }, /* 12 */ { CC_VARLIST, RO, "clock_var_list" }, /* 13 */ - { 0, EOV, "" } /* 14 */ + { CC_FUDGEMINJIT, RO, "minjitter" }, /* 14 */ + { 0, EOV, "" } /* 15 */ }; @@ -640,6 +644,7 @@ static const u_char def_clock_var[] = { CC_NOREPLY, CC_BADFORMAT, CC_BADDATA, + CC_FUDGEMINJIT, CC_FUDGETIME1, CC_FUDGETIME2, CC_FUDGEVAL1, @@ -1187,15 +1192,21 @@ process_control( pkt = (struct ntp_control *)&rbufp->recv_pkt; /* - * If the length is less than required for the header, or - * it is a response or a fragment, ignore this. + * If the length is less than required for the header, + * ignore it. */ - if (rbufp->recv_length < (int)CTL_HEADER_LEN - || (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op + if (rbufp->recv_length < (int)CTL_HEADER_LEN) { + DPRINTF(1, ("Short control packet\n")); + numctltooshort++; + return; + } + + /* + * If this packet is a response or a fragment, ignore it. + */ + if ( (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op || pkt->offset != 0) { DPRINTF(1, ("invalid format in control packet\n")); - if (rbufp->recv_length < (int)CTL_HEADER_LEN) - numctltooshort++; if (CTL_RESPONSE & pkt->r_m_e_op) numctlinputresp++; if (CTL_MORE & pkt->r_m_e_op) @@ -1206,6 +1217,7 @@ process_control( numctlbadoffset++; return; } + res_version = PKT_VERSION(pkt->li_vn_mode); if (res_version > NTP_VERSION || res_version < NTP_OLDVERSION) { DPRINTF(1, ("unknown version %d in control packet\n", @@ -1910,15 +1922,6 @@ ctl_putsys( static struct timex ntx; static u_long ntp_adjtime_time; - static const double to_ms_usec = - 1.0e-3; /* usec to msec */ - static const double to_ms_nusec = -# ifdef STA_NANO - 1.0e-6; /* nsec to msec */ -# else - to_ms_usec; -# endif - /* * CS_K_* variables depend on up-to-date output of ntp_adjtime() */ @@ -2321,7 +2324,8 @@ ctl_putsys( case CS_K_OFFSET: CTL_IF_KERNLOOP( ctl_putdblf, - (sys_var[varid].text, 0, -1, to_ms_nusec * ntx.offset) + (sys_var[varid].text, 0, -1, + 1000 * dbl_from_var_long(ntx.offset, ntx.status)) ); break; @@ -2336,7 +2340,7 @@ ctl_putsys( CTL_IF_KERNLOOP( ctl_putdblf, (sys_var[varid].text, 0, 6, - to_ms_usec * ntx.maxerror) + 1000 * dbl_from_usec_long(ntx.maxerror)) ); break; @@ -2344,7 +2348,7 @@ ctl_putsys( CTL_IF_KERNLOOP( ctl_putdblf, (sys_var[varid].text, 0, 6, - to_ms_usec * ntx.esterror) + 1000 * dbl_from_usec_long(ntx.esterror)) ); break; @@ -2368,7 +2372,7 @@ ctl_putsys( CTL_IF_KERNLOOP( ctl_putdblf, (sys_var[varid].text, 0, 6, - to_ms_usec * ntx.precision) + 1000 * dbl_from_var_long(ntx.precision, ntx.status)) ); break; @@ -2396,7 +2400,8 @@ ctl_putsys( case CS_K_PPS_JITTER: CTL_IF_KERNPPS( ctl_putdbl, - (sys_var[varid].text, to_ms_nusec * ntx.jitter) + (sys_var[varid].text, + 1000 * dbl_from_var_long(ntx.jitter, ntx.status)) ); break; @@ -2965,14 +2970,9 @@ ctl_putclock( break; case CC_FUDGEVAL2: - if (mustput || (pcs->haveflags & CLK_HAVEVAL2)) { - if (pcs->fudgeval1 > 1) - ctl_putadr(clock_var[id].text, - pcs->fudgeval2, NULL); - else - ctl_putrefid(clock_var[id].text, - pcs->fudgeval2); - } + /* RefID of clocks are always text even if stratum is fudged */ + if (mustput || (pcs->haveflags & CLK_HAVEVAL2)) + ctl_putrefid(clock_var[id].text, pcs->fudgeval2); break; case CC_FLAGS: @@ -3045,6 +3045,16 @@ ctl_putclock( *s = '\0'; ctl_putdata(buf, (unsigned)(s - buf), 0); break; + + case CC_FUDGEMINJIT: + if (mustput || (pcs->haveflags & CLK_HAVEMINJIT)) + ctl_putdbl(clock_var[id].text, + pcs->fudgeminjitter * 1e3); + break; + + default: + break; + } } #endif |
