X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/e2982e7f6f0b624a773ec5a58885ee80fab46d34..10f1fe5fd8dfaa321621a1063d252940bb65029e:/print-ntp.c diff --git a/print-ntp.c b/print-ntp.c index 9079c616..b4fa6129 100644 --- a/print-ntp.c +++ b/print-ntp.c @@ -290,7 +290,7 @@ ntp_time_print(netdissect_options *ndo, ND_PRINT(", Root dispersion: "); p_sfix(ndo, &bp->root_dispersion); - ND_TCHECK(bp->refid); + ND_TCHECK_4(bp->refid); ND_PRINT(", Reference-ID: "); /* Interpretation depends on stratum */ switch (stratum) { @@ -317,7 +317,7 @@ ntp_time_print(netdissect_options *ndo, default: /* In NTPv4 (RFC 5905) refid is an IPv4 address or first 32 bits of MD5 sum of IPv6 address */ - ND_PRINT("0x%08x", EXTRACT_BE_U_4(&bp->refid)); + ND_PRINT("0x%08x", EXTRACT_BE_U_4(bp->refid)); break; } @@ -453,14 +453,14 @@ ntp_print(netdissect_options *ndo, const u_char *cp, u_int length) { const union ntpdata *bp = (const union ntpdata *)cp; - int mode, version, leapind; + u_int mode, version, leapind; uint8_t status; - ND_TCHECK(bp->td.status); + ND_TCHECK_1(bp->td.status); status = EXTRACT_U_1(bp->td.status); version = (status & VERSIONMASK) >> VERSIONSHIFT; - ND_PRINT("NTPv%d", version); + ND_PRINT("NTPv%u", version); mode = (status & MODEMASK) >> MODESHIFT; if (!ndo->ndo_vflag) { @@ -479,12 +479,24 @@ ntp_print(netdissect_options *ndo, tok2str(ntp_leapind_values, "Unknown", leapind), leapind); - if (mode >= MODE_UNSPEC && mode <= MODE_BROADCAST) + switch (mode) { + + case MODE_UNSPEC: + case MODE_SYM_ACT: + case MODE_SYM_PAS: + case MODE_CLIENT: + case MODE_SERVER: + case MODE_BROADCAST: ntp_time_print(ndo, &bp->td, length); - else if (mode == MODE_CONTROL) + break; + + case MODE_CONTROL: ntp_control_print(ndo, &bp->cd, length); - else - {;} /* XXX: not implemented! */ + break; + + default: + break; /* XXX: not implemented! */ + } return; trunc: @@ -499,8 +511,8 @@ p_sfix(netdissect_options *ndo, int f; double ff; - i = EXTRACT_BE_U_2(&sfp->int_part); - f = EXTRACT_BE_U_2(&sfp->fraction); + i = EXTRACT_BE_U_2(sfp->int_part); + f = EXTRACT_BE_U_2(sfp->fraction); ff = f / 65536.0; /* shift radix point by 16 bits */ f = (int)(ff * 1000000.0); /* Treat fraction as parts per million */ ND_PRINT("%d.%06d", i, f); @@ -517,8 +529,8 @@ p_ntp_time(netdissect_options *ndo, uint32_t f; double ff; - i = EXTRACT_BE_U_4(&lfp->int_part); - uf = EXTRACT_BE_U_4(&lfp->fraction); + i = EXTRACT_BE_U_4(lfp->int_part); + uf = EXTRACT_BE_U_4(lfp->fraction); ff = uf; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; @@ -575,10 +587,10 @@ p_ntp_delta(netdissect_options *ndo, double ff; int signbit; - u = EXTRACT_BE_U_4(&lfp->int_part); - ou = EXTRACT_BE_U_4(&olfp->int_part); - uf = EXTRACT_BE_U_4(&lfp->fraction); - ouf = EXTRACT_BE_U_4(&olfp->fraction); + u = EXTRACT_BE_U_4(lfp->int_part); + ou = EXTRACT_BE_U_4(olfp->int_part); + uf = EXTRACT_BE_U_4(lfp->fraction); + ouf = EXTRACT_BE_U_4(olfp->fraction); if (ou == 0 && ouf == 0) { p_ntp_time(ndo, lfp); return;