diff options
author | glebius <glebius@FreeBSD.org> | 2017-02-10 07:22:12 +0000 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-02-10 07:04:32 -0200 |
commit | abb72844124d16a7ad83487bf5f12c49b66e60d5 (patch) | |
tree | d6de71264e438b11eb1d196ca9e0c63eda8e56b4 /contrib/tcpdump/print-ntp.c | |
parent | 9c520da80579466ed328970249f2a9ea5cb61063 (diff) | |
download | FreeBSD-src-abb72844124d16a7ad83487bf5f12c49b66e60d5.zip FreeBSD-src-abb72844124d16a7ad83487bf5f12c49b66e60d5.tar.gz |
Merge r309649, r313048, r313083, r313104:
tcpdump 4.9.0
(cherry picked from commit ad0c9114e00a9a30168e0c13c17d8f65571aa67f)
Diffstat (limited to 'contrib/tcpdump/print-ntp.c')
-rw-r--r-- | contrib/tcpdump/print-ntp.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c index 8603906..0689264 100644 --- a/contrib/tcpdump/print-ntp.c +++ b/contrib/tcpdump/print-ntp.c @@ -18,25 +18,23 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * Format and print ntp packets. * By Jeffrey Mogul/DECWRL * loosely based on print-bootp.c - * - * $FreeBSD$ */ -#define NETDISSECT_REWORKED +/* \summary: Network Time Protocol (NTP) printer */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <tcpdump-stdinc.h> +#include <netdissect-stdinc.h> #ifdef HAVE_STRFTIME #include <time.h> #endif -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "extract.h" @@ -209,7 +207,7 @@ ntp_print(netdissect_options *ndo, register const struct ntpdata *bp; int mode, version, leapind; - bp = (struct ntpdata *)cp; + bp = (const struct ntpdata *)cp; ND_TCHECK(bp->status); @@ -263,7 +261,7 @@ ntp_print(netdissect_options *ndo, break; case PRIM_REF: - if (fn_printn(ndo, (u_char *)&(bp->refid), 4, ndo->ndo_snapend)) + if (fn_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend)) goto trunc; break; @@ -329,12 +327,12 @@ p_sfix(netdissect_options *ndo, { register int i; register int f; - register float ff; + register double ff; i = EXTRACT_16BITS(&sfp->int_part); f = EXTRACT_16BITS(&sfp->fraction); - ff = f / 65536.0; /* shift radix point by 16 bits */ - f = ff * 1000000.0; /* Treat fraction as parts per million */ + ff = f / 65536.0; /* shift radix point by 16 bits */ + f = (int)(ff * 1000000.0); /* Treat fraction as parts per million */ ND_PRINT((ndo, "%d.%06d", i, f)); } @@ -347,15 +345,15 @@ p_ntp_time(netdissect_options *ndo, register int32_t i; register uint32_t uf; register uint32_t f; - register float ff; + register double ff; i = EXTRACT_32BITS(&lfp->int_part); uf = EXTRACT_32BITS(&lfp->fraction); ff = uf; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; - ff = ff / FMAXINT; /* shift radix point by 32 bits */ - f = ff * 1000000000.0; /* treat fraction as parts per billion */ + ff = ff / FMAXINT; /* shift radix point by 32 bits */ + f = (uint32_t)(ff * 1000000000.0); /* treat fraction as parts per billion */ ND_PRINT((ndo, "%u.%09d", i, f)); #ifdef HAVE_STRFTIME @@ -384,7 +382,7 @@ p_ntp_delta(netdissect_options *ndo, register uint32_t u, uf; register uint32_t ou, ouf; register uint32_t f; - register float ff; + register double ff; int signbit; u = EXTRACT_32BITS(&lfp->int_part); @@ -422,8 +420,8 @@ p_ntp_delta(netdissect_options *ndo, ff = f; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; - ff = ff / FMAXINT; /* shift radix point by 32 bits */ - f = ff * 1000000000.0; /* treat fraction as parts per billion */ + ff = ff / FMAXINT; /* shift radix point by 32 bits */ + f = (uint32_t)(ff * 1000000000.0); /* treat fraction as parts per billion */ ND_PRINT((ndo, "%s%d.%09d", signbit ? "-" : "+", i, f)); } |