]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ntp.c
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / print-ntp.c
index 42853f780e00be3977b34e7089246f865241f9f6..499585fd1dfe44bd6c92b48954a45796a8181dce 100644 (file)
 
 #include "netdissect-stdinc.h"
 
-#ifdef HAVE_STRFTIME
 #include <time.h>
-#endif
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -236,39 +235,33 @@ ntp_time_print(netdissect_options *ndo,
        if (length < NTP_TIMEMSG_MINLEN)
                goto invalid;
 
-       ND_TCHECK_1(bp->stratum);
        stratum = GET_U_1(bp->stratum);
        ND_PRINT(", Stratum %u (%s)",
                stratum,
                tok2str(ntp_stratum_values, (stratum >=2 && stratum<=15) ? "secondary reference" : "reserved", stratum));
 
-       ND_TCHECK_1(bp->ppoll);
        ND_PRINT(", poll %d", GET_S_1(bp->ppoll));
        p_poll(ndo, GET_S_1(bp->ppoll));
 
-       ND_TCHECK_1(bp->precision);
        ND_PRINT(", precision %d", GET_S_1(bp->precision));
 
-       ND_TCHECK_SIZE(&bp->root_delay);
        ND_PRINT("\n\tRoot Delay: ");
        p_sfix(ndo, &bp->root_delay);
 
-       ND_TCHECK_SIZE(&bp->root_dispersion);
        ND_PRINT(", Root dispersion: ");
        p_sfix(ndo, &bp->root_dispersion);
 
-       ND_TCHECK_4(bp->refid);
        ND_PRINT(", Reference-ID: ");
        /* Interpretation depends on stratum */
        switch (stratum) {
 
        case UNSPECIFIED:
                ND_PRINT("(unspec)");
+               ND_TCHECK_4(bp->refid);
                break;
 
        case PRIM_REF:
-               if (nd_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend))
-                       goto trunc;
+               nd_printjn(ndo, (const u_char *)&(bp->refid), 4);
                break;
 
        case INFO_QUERY:
@@ -288,19 +281,15 @@ ntp_time_print(netdissect_options *ndo,
                break;
        }
 
-       ND_TCHECK_SIZE(&bp->ref_timestamp);
        ND_PRINT("\n\t  Reference Timestamp:  ");
        p_ntp_time(ndo, &(bp->ref_timestamp));
 
-       ND_TCHECK_SIZE(&bp->org_timestamp);
        ND_PRINT("\n\t  Originator Timestamp: ");
        p_ntp_time(ndo, &(bp->org_timestamp));
 
-       ND_TCHECK_SIZE(&bp->rec_timestamp);
        ND_PRINT("\n\t  Receive Timestamp:    ");
        p_ntp_time(ndo, &(bp->rec_timestamp));
 
-       ND_TCHECK_SIZE(&bp->xmt_timestamp);
        ND_PRINT("\n\t  Transmit Timestamp:   ");
        p_ntp_time(ndo, &(bp->xmt_timestamp));
 
@@ -312,21 +301,16 @@ ntp_time_print(netdissect_options *ndo,
 
        /* FIXME: this code is not aware of any extension fields */
        if (length == NTP_TIMEMSG_MINLEN + 4) {         /* Optional: key-id (crypto-NAK) */
-               ND_TCHECK_4(bp->key_id);
                ND_PRINT("\n\tKey id: %u", GET_BE_U_4(bp->key_id));
        } else if (length == NTP_TIMEMSG_MINLEN + 4 + 16) {     /* Optional: key-id + 128-bit digest */
-               ND_TCHECK_4(bp->key_id);
                ND_PRINT("\n\tKey id: %u", GET_BE_U_4(bp->key_id));
-               ND_TCHECK_LEN(bp->message_digest, 16);
                ND_PRINT("\n\tAuthentication: %08x%08x%08x%08x",
                         GET_BE_U_4(bp->message_digest),
                         GET_BE_U_4(bp->message_digest + 4),
                         GET_BE_U_4(bp->message_digest + 8),
                         GET_BE_U_4(bp->message_digest + 12));
        } else if (length == NTP_TIMEMSG_MINLEN + 4 + 20) {     /* Optional: key-id + 160-bit digest */
-               ND_TCHECK_4(bp->key_id);
                ND_PRINT("\n\tKey id: %u", GET_BE_U_4(bp->key_id));
-               ND_TCHECK_LEN(bp->message_digest, 20);
                ND_PRINT("\n\tAuthentication: %08x%08x%08x%08x%08x",
                         GET_BE_U_4(bp->message_digest),
                         GET_BE_U_4(bp->message_digest + 4),
@@ -341,10 +325,6 @@ ntp_time_print(netdissect_options *ndo,
 invalid:
        nd_print_invalid(ndo);
        ND_TCHECK_LEN(bp, length);
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
 }
 
 /*
@@ -360,7 +340,6 @@ ntp_control_print(netdissect_options *ndo,
        if (length < NTP_CTRLMSG_MINLEN)
                goto invalid;
 
-       ND_TCHECK_1(cd->control);
        control = GET_U_1(cd->control);
        R = (control & 0x80) != 0;
        E = (control & 0x40) != 0;
@@ -370,23 +349,18 @@ ntp_control_print(netdissect_options *ndo,
                  R ? "Response" : "Request", E ? "Error" : "OK",
                  M ? "More" : "Last", opcode);
 
-       ND_TCHECK_2(cd->sequence);
        sequence = GET_BE_U_2(cd->sequence);
        ND_PRINT("\tSequence=%hu", sequence);
 
-       ND_TCHECK_2(cd->status);
        status = GET_BE_U_2(cd->status);
        ND_PRINT(", Status=%#hx", status);
 
-       ND_TCHECK_2(cd->assoc);
        assoc = GET_BE_U_2(cd->assoc);
        ND_PRINT(", Assoc.=%hu", assoc);
 
-       ND_TCHECK_2(cd->offset);
        offset = GET_BE_U_2(cd->offset);
        ND_PRINT(", Offset=%hu", offset);
 
-       ND_TCHECK_2(cd->count);
        count = GET_BE_U_2(cd->count);
        ND_PRINT(", Count=%hu", count);
 
@@ -401,10 +375,6 @@ ntp_control_print(netdissect_options *ndo,
 invalid:
        nd_print_invalid(ndo);
        ND_TCHECK_LEN(cd, length);
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
 }
 
 union ntpdata {
@@ -424,7 +394,6 @@ ntp_print(netdissect_options *ndo,
        uint8_t status;
 
        ndo->ndo_protocol = "ntp";
-       ND_TCHECK_1(bp->td.status);
        status = GET_U_1(bp->td.status);
 
        version = (status & VERSIONMASK) >> VERSIONSHIFT;
@@ -465,10 +434,6 @@ ntp_print(netdissect_options *ndo,
        default:
                break;                  /* XXX: not implemented! */
        }
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
 }
 
 static void