]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Update the ND_LCHECK*() macros to ND_ICHECK*() macros
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 29 Dec 2021 13:38:08 +0000 (14:38 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 29 Dec 2021 14:11:32 +0000 (15:11 +0100)
ICHECK like Invalid-Check.
Reminder: If the checked expression is true an error message is printed
and a 'goto invalid' is executed.

This change adds the parameter 'operator'.

Before this change, '<' comparison was hard coded.
We can do now:
ND_ICHECK_U(length, <, HEADER_LEN);
ND_ICHECK_U(length, ==, 24);
ND_ICHECK_U(length, !=, 8);
ND_ICHECK_ZU(length, <, sizeof(struct my_struct));
ND_ICHECKMSG_U("message length", msg_tlen, <, 4);
...
(Any comparison operator)

Remark: The change of names from ND_LCHECK*() to ND_ICHECK*() is
because something else than a length(L) can be checked.

Moreover:
Place the 'message' parameter at the beginning of ND_ICHECKMSG_U()
and ND_ICHECKMSG_ZU() paramaters lists.

17 files changed:
netdissect.h
print-aodv.c
print-atalk.c
print-egp.c
print-ether.c
print-geneve.c
print-gre.c
print-ipx.c
print-juniper.c
print-l2tp.c
print-olsr.c
print-ptp.c
print-rip.c
print-rsvp.c
print-sflow.c
print-udp.c
print-zep.c

index 6bc442fc3083548ea3c2485b3eb9e92d03772309..5b104df6193ad776203ed4ce93789bb6481b57af 100644 (file)
@@ -384,27 +384,39 @@ extern void nd_pop_all_packet_info(netdissect_options *);
  */
 #define ND_BYTES_AVAILABLE_AFTER(p) ND_BYTES_BETWEEN(ndo->ndo_snapend, (p))
 
-/* Check length < minimum for invalid packet with a custom message, format %u */
-#define ND_LCHECKMSG_U(length, minimum, what) \
-if ((length) < (minimum)) { \
-ND_PRINT(" [%s %u < %u]", (what), (length), (minimum)); \
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * a custom message, format %u
+ */
+#define ND_ICHECKMSG_U(message, expression_1, operator, expression_2) \
+if ((expression_1) operator (expression_2)) { \
+ND_PRINT(" [%s %u %s %u]", (message), (expression_1), (#operator), (expression_2)); \
 goto invalid; \
 }
 
-/* Check length < minimum for invalid packet with #length message, format %u */
-#define ND_LCHECK_U(length, minimum) \
-ND_LCHECKMSG_U((length), (minimum), (#length))
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * "expression_1" message, format %u
+ */
+#define ND_ICHECK_U(expression_1, operator, expression_2) \
+ND_ICHECKMSG_U((#expression_1), (expression_1), operator, (expression_2))
 
-/* Check length < minimum for invalid packet with a custom message, format %zu */
-#define ND_LCHECKMSG_ZU(length, minimum, what) \
-if ((length) < (minimum)) { \
-ND_PRINT(" [%s %u < %zu]", (what), (length), (minimum)); \
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * a custom message, format %zu
+ */
+#define ND_ICHECKMSG_ZU(message, expression_1, operator, expression_2) \
+if ((expression_1) operator (expression_2)) { \
+ND_PRINT(" [%s %u %s %zu]", (message), (expression_1), (#operator), (expression_2)); \
 goto invalid; \
 }
 
-/* Check length < minimum for invalid packet with #length message, format %zu */
-#define ND_LCHECK_ZU(length, minimum) \
-ND_LCHECKMSG_ZU((length), (minimum), (#length))
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * "expression_1" message, format %zu
+ */
+#define ND_ICHECK_ZU(expression_1, operator, expression_2) \
+ND_ICHECKMSG_ZU((#expression_1), (expression_1), operator, (expression_2))
 
 #define ND_PRINT(...) (ndo->ndo_printf)(ndo, __VA_ARGS__)
 #define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
index da3c37c9e85b3e18c44bebfc1a93478ff50c1718..b014c49cfab1b8c478d382b11f76d18dd18026e7 100644 (file)
@@ -161,7 +161,8 @@ aodv_extension(netdissect_options *ndo,
        switch (ext_type) {
        case AODV_EXT_HELLO:
                ah = (const struct aodv_hello *)(const void *)ep;
-               ND_LCHECKMSG_ZU(length, sizeof(struct aodv_hello), "ext data length");
+               ND_ICHECKMSG_ZU("ext data length", length, <,
+                               sizeof(struct aodv_hello));
                if (ext_length < 4) {
                        ND_PRINT("\n\text HELLO - bad length %u", ext_length);
                        goto invalid;
@@ -186,7 +187,7 @@ aodv_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
        u_int i;
        const struct aodv_rreq *ap = (const struct aodv_rreq *)dat;
 
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+       ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
        ND_PRINT(" %u %s%s%s%s%shops %u id 0x%08x\n"
            "\tdst %s seq %u src %s seq %u", length,
            GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
@@ -215,7 +216,7 @@ aodv_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
        u_int i;
        const struct aodv_rrep *ap = (const struct aodv_rrep *)dat;
 
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+       ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
        ND_PRINT(" %u %s%sprefix %u hops %u\n"
            "\tdst %s dseq %u src %s %u ms", length,
            GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
@@ -242,14 +243,14 @@ aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
        const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
        const struct rerr_unreach *dp;
 
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+       ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
        ND_PRINT(" %s [items %u] [%u]:",
            GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
            GET_U_1(ap->rerr_dc), length);
        dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
        i = length - sizeof(*ap);
        for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
-               ND_LCHECKMSG_ZU(i, sizeof(*dp), "remaining length");
+               ND_ICHECKMSG_ZU("remaining length", i, <, sizeof(*dp));
                ND_PRINT(" {%s}(%u)", GET_IPADDR_STRING(dp->u_da),
                    GET_BE_U_4(dp->u_ds));
                dp++;
@@ -267,7 +268,7 @@ aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
        u_int i;
        const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
 
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+       ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
        ND_PRINT(" %u %s%s%s%s%shops %u id 0x%08x\n"
            "\tdst %s seq %u src %s seq %u", length,
            GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
@@ -296,7 +297,7 @@ aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
        u_int i;
        const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
 
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+       ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
        ND_PRINT(" %u %s%sprefix %u hops %u\n"
           "\tdst %s dseq %u src %s %u ms", length,
            GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
@@ -323,14 +324,14 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
        const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
        const struct rerr_unreach6 *dp6;
 
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+       ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
        ND_PRINT(" %s [items %u] [%u]:",
            GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
            GET_U_1(ap->rerr_dc), length);
        dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
        i = length - sizeof(*ap);
        for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
-               ND_LCHECKMSG_ZU(i, sizeof(*dp6), "remaining length");
+               ND_ICHECKMSG_ZU("remaining length", i, <, sizeof(*dp6));
                ND_PRINT(" {%s}(%u)", GET_IP6ADDR_STRING(dp6->u_da),
                         GET_BE_U_4(dp6->u_ds));
                dp6++;
index 4e1fa3d2163edd9c7536d0a6a2d3e277196edb76..57c65c096265889eb54ec7cad87df14e4963f490 100644 (file)
@@ -166,7 +166,7 @@ llap_print(netdissect_options *ndo,
        u_int hdrlen;
 
        ndo->ndo_protocol = "llap";
-       ND_LCHECKMSG_ZU(length, sizeof(*lp), "LLAP length");
+       ND_ICHECKMSG_ZU("LLAP length", length, <, sizeof(*lp));
        lp = (const struct LAP *)bp;
        bp += sizeof(*lp);
        length -= sizeof(*lp);
@@ -175,7 +175,7 @@ llap_print(netdissect_options *ndo,
 
        case lapShortDDP:
                ndo->ndo_protocol = "sddp";
-               ND_LCHECKMSG_U(length, ddpSSize, "SDDP length");
+               ND_ICHECKMSG_U("SDDP length", length, <, ddpSSize);
                sdp = (const struct atShortDDP *)bp;
                ND_PRINT("%s.%s",
                    ataddr_string(ndo, 0, GET_U_1(lp->src)),
@@ -192,7 +192,7 @@ llap_print(netdissect_options *ndo,
 
        case lapDDP:
                ndo->ndo_protocol = "ddp";
-               ND_LCHECKMSG_U(length, ddpSize, "DDP length");
+               ND_ICHECKMSG_U("DDP length", length, <, ddpSize);
                dp = (const struct atDDP *)bp;
                snet = GET_BE_U_2(dp->srcNet);
                ND_PRINT("%s.%s",
@@ -236,7 +236,7 @@ atalk_print(netdissect_options *ndo,
         if(!ndo->ndo_eflag)
             ND_PRINT("AT ");
 
-       ND_LCHECK_U(length, ddpSize);
+       ND_ICHECK_U(length, <, ddpSize);
        dp = (const struct atDDP *)bp;
        snet = GET_BE_U_2(dp->srcNet);
        ND_PRINT("%s.%s", ataddr_string(ndo, snet, GET_U_1(dp->srcNode)),
@@ -267,7 +267,7 @@ aarp_print(netdissect_options *ndo,
        ndo->ndo_protocol = "aarp";
        ND_PRINT("aarp ");
        ap = (const struct aarp *)bp;
-       ND_LCHECK_ZU(length, sizeof(*ap));
+       ND_ICHECK_ZU(length, <, sizeof(*ap));
        ND_TCHECK_SIZE(ap);
        if (GET_BE_U_2(ap->htype) == 1 &&
            GET_BE_U_2(ap->ptype) == ETHERTYPE_ATALK &&
@@ -331,7 +331,7 @@ atp_print(netdissect_options *ndo,
        uint32_t data;
 
        ndo->ndo_protocol = "atp";
-       ND_LCHECKMSG_ZU(length, sizeof(*ap), "ATP length");
+       ND_ICHECKMSG_ZU("ATP length", length, <, sizeof(*ap));
        length -= sizeof(*ap);
        control = GET_U_1(ap->control);
        switch (control & 0xc0) {
@@ -459,7 +459,7 @@ nbp_print(netdissect_options *ndo,
        u_int i;
 
        /* must be room for at least one tuple */
-       ND_LCHECKMSG_U(length, nbpHeaderSize + 8, "undersized-nbp");
+       ND_ICHECKMSG_U("undersized-nbp", length, <, nbpHeaderSize + 8);
        length -= nbpHeaderSize;
        control = GET_U_1(np->control);
        ND_PRINT(" nbp-%s", tok2str(nbp_str, "0x%x", control & 0xf0));
index bf9578db9bffc247760dd1abb385ae5e58c592d6..04007b971874fa8498287bc3e0dba06b03657ec7 100644 (file)
@@ -265,7 +265,7 @@ egp_print(netdissect_options *ndo,
 
        ndo->ndo_protocol = "egp";
        egp = (const struct egp_packet *)bp;
-       ND_LCHECKMSG_ZU(length, sizeof(*egp), "packet length");
+       ND_ICHECKMSG_ZU("packet length", length, <, sizeof(*egp));
        ND_TCHECK_SIZE(egp);
 
        version = GET_U_1(egp->egp_version);
index c47749c309033373700dfffdc8adc58ea8d77910..d20addbf91c5aad5bdf601aa90e5b9d2a428df2f 100644 (file)
@@ -238,7 +238,7 @@ recurse:
                         */
                        length_type = GET_BE_U_2(p);
 
-                       ND_LCHECK_U(caplen, 2);
+                       ND_ICHECK_U(caplen, <, 2);
                        length -= 2;
                        caplen -= 2;
                        p += 2;
index 4d5dda6b5a61e5ca820a29aadac2da4f8f61279e..7b77e191b4b70a1d84f99c32f82c347c169d2a4e 100644 (file)
@@ -117,7 +117,7 @@ geneve_opts_print(netdissect_options *ndo, const u_char *bp, u_int len)
         uint8_t opt_type;
         uint8_t opt_len;
 
-        ND_LCHECKMSG_U(len, 4, "remaining options length");
+        ND_ICHECKMSG_U("remaining options length", len, <, 4);
         ND_PRINT("%s", sep);
         sep = ", ";
 
@@ -169,7 +169,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
     ndo->ndo_protocol = "geneve";
     ND_PRINT("Geneve");
 
-    ND_LCHECK_U(len, 8);
+    ND_ICHECK_U(len, <, 8);
 
     ver_opt = GET_U_1(bp);
     bp += 1;
index a28edf5cd4b4fcd794df1598c9ddb29d7cc4b150..136fb69d1b3ed6dba14babcf4d51d2bef3b5f668 100644 (file)
@@ -83,7 +83,7 @@ gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
        ndo->ndo_protocol = "gre";
        nd_print_protocol_caps(ndo);
-       ND_LCHECK_U(length, 2);
+       ND_ICHECK_U(length, <, 2);
        vers = GET_BE_U_2(bp) & GRE_VERS_MASK;
        ND_PRINT("v%u",vers);
 
@@ -110,7 +110,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
        u_int len = length;
        uint16_t flags, prot;
 
-       ND_LCHECK_U(len, 2);
+       ND_ICHECK_U(len, <, 2);
        flags = GET_BE_U_2(bp);
        if (ndo->ndo_vflag)
                ND_PRINT(", Flags [%s]",
@@ -119,7 +119,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
        len -= 2;
        bp += 2;
 
-       ND_LCHECK_U(len, 2);
+       ND_ICHECK_U(len, <, 2);
        prot = GET_BE_U_2(bp);
        len -= 2;
        bp += 2;
@@ -127,28 +127,28 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
        if ((flags & GRE_CP) | (flags & GRE_RP)) {
                uint16_t sum;
 
-               ND_LCHECK_U(len, 2);
+               ND_ICHECK_U(len, <, 2);
                sum =  GET_BE_U_2(bp);
                if (ndo->ndo_vflag)
                        ND_PRINT(", sum 0x%x", sum);
                bp += 2;
                len -= 2;
 
-               ND_LCHECK_U(len, 2);
+               ND_ICHECK_U(len, <, 2);
                ND_PRINT(", off 0x%x", GET_BE_U_2(bp));
                bp += 2;
                len -= 2;
        }
 
        if (flags & GRE_KP) {
-               ND_LCHECK_U(len, 4);
+               ND_ICHECK_U(len, <, 4);
                ND_PRINT(", key=0x%x", GET_BE_U_4(bp));
                bp += 4;
                len -= 4;
        }
 
        if (flags & GRE_SP) {
-               ND_LCHECK_U(len, 4);
+               ND_ICHECK_U(len, <, 4);
                ND_PRINT(", seq %u", GET_BE_U_4(bp));
                bp += 4;
                len -= 4;
@@ -160,7 +160,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
                        uint8_t sreoff;
                        uint8_t srelen;
 
-                       ND_LCHECK_U(len, 4);
+                       ND_ICHECK_U(len, <, 4);
                        af = GET_BE_U_2(bp);
                        sreoff = GET_U_1(bp + 2);
                        srelen = GET_U_1(bp + 3);
@@ -173,7 +173,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
                        if (!gre_sre_print(ndo, af, sreoff, srelen, bp, len))
                                goto invalid;
 
-                       ND_LCHECK_U(len, srelen);
+                       ND_ICHECK_U(len, <, srelen);
                        bp += srelen;
                        len -= srelen;
                }
@@ -227,7 +227,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
        u_int len = length;
        uint16_t flags, prot;
 
-       ND_LCHECK_U(len, 2);
+       ND_ICHECK_U(len, <, 2);
        flags = GET_BE_U_2(bp);
        len -= 2;
        bp += 2;
@@ -236,7 +236,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
                ND_PRINT(", Flags [%s]",
                         bittok2str(gre_flag_values,"none",flags));
 
-       ND_LCHECK_U(len, 2);
+       ND_ICHECK_U(len, <, 2);
        prot = GET_BE_U_2(bp);
        len -= 2;
        bp += 2;
@@ -245,7 +245,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
        if (flags & GRE_KP) {
                uint32_t k;
 
-               ND_LCHECK_U(len, 4);
+               ND_ICHECK_U(len, <, 4);
                k = GET_BE_U_4(bp);
                ND_PRINT(", call %u", k & 0xffff);
                len -= 4;
@@ -253,14 +253,14 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
        }
 
        if (flags & GRE_SP) {
-               ND_LCHECK_U(len, 4);
+               ND_ICHECK_U(len, <, 4);
                ND_PRINT(", seq %u", GET_BE_U_4(bp));
                bp += 4;
                len -= 4;
        }
 
        if (flags & GRE_AP) {
-               ND_LCHECK_U(len, 4);
+               ND_ICHECK_U(len, <, 4);
                ND_PRINT(", ack %u", GET_BE_U_4(bp));
                bp += 4;
                len -= 4;
@@ -342,7 +342,7 @@ gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
        }
 
        while (srelen != 0) {
-               ND_LCHECK_U(len, 4);
+               ND_ICHECK_U(len, <, 4);
 
                ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
                addrtostr(bp, buf, sizeof(buf));
@@ -379,7 +379,7 @@ gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
        }
 
        while (srelen != 0) {
-               ND_LCHECK_U(len, 2);
+               ND_ICHECK_U(len, <, 2);
 
                ND_PRINT(" %s%x",
                         ((bp - up) == sreoff) ? "*" : "", GET_BE_U_2(bp));
index f8c0ce7c221340cf8fc2e2a2d4b3cf6fbe1f63d8..73a79aab3aab89f85d7e7417e5970c6c49a48fbe 100644 (file)
@@ -156,7 +156,7 @@ ipx_sap_print(netdissect_options *ndo, const u_char *ipx, u_int length)
     int command, i;
 
     command = GET_BE_U_2(ipx);
-    ND_LCHECK_U(length, 2);
+    ND_ICHECK_U(length, <, 2);
     ipx += 2;
     length -= 2;
 
@@ -230,7 +230,7 @@ ipx_rip_print(netdissect_options *ndo, const u_char *ipx, u_int length)
     int command, i;
 
     command = GET_BE_U_2(ipx);
-    ND_LCHECK_U(length, 2);
+    ND_ICHECK_U(length, <, 2);
     ipx += 2;
     length -= 2;
 
index a068a6bf392c0c36985cc63f759b4a64a199d3bd..13d8f837a10912511cfafc3abcacb526f55201d7 100644 (file)
@@ -1331,7 +1331,8 @@ juniper_parse_header(netdissect_options *ndo,
             /* sanity checks */
             if (tlv_type == 0 || tlv_len == 0)
                 break;
-            ND_LCHECK_U(extension_length, tlv_len + JUNIPER_EXT_TLV_OVERHEAD);
+            ND_ICHECK_U(extension_length, <,
+                        tlv_len + JUNIPER_EXT_TLV_OVERHEAD);
 
             if (ndo->ndo_vflag > 1)
                 ND_PRINT("\n\t  %s Extension TLV #%u, length %u, value ",
index 024705f821ba5e1e25299bcb169a921f3f6355b4..892155058a97449cdda760aba21850cfe887d798 100644 (file)
@@ -577,7 +577,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
        len = GET_BE_U_2(dat) & L2TP_AVP_HDR_LEN_MASK;
 
        /* If it is not long enough to contain the header, we'll give up. */
-       ND_LCHECKMSG_U(len, 6, "AVP length");
+       ND_ICHECKMSG_U("AVP length", len, <, 6);
 
        /* If it goes past the end of the remaining length of the packet,
           we'll give up. */
index df796d955d6aa42d9393701e1880ecc3cf7b8680..dca323f672d6e659bfb218fc3d980991812520ec 100644 (file)
@@ -325,7 +325,7 @@ olsr_print(netdissect_options *ndo,
     nd_print_protocol_caps(ndo);
     ND_PRINT("v%u", (is_ipv6) ? 6 : 4);
 
-    ND_LCHECKMSG_ZU(length, sizeof(struct olsr_common), "packet length");
+    ND_ICHECKMSG_ZU("packet length", length, <, sizeof(struct olsr_common));
 
     ptr.common = (const struct olsr_common *)tptr;
     length = ND_MIN(length, GET_BE_U_2(ptr.common->packet_len));
@@ -417,7 +417,8 @@ olsr_print(netdissect_options *ndo,
         switch (msg_type) {
         case OLSR_HELLO_MSG:
         case OLSR_HELLO_LQ_MSG:
-            ND_LCHECKMSG_ZU(msg_tlen, sizeof(struct olsr_hello), "message length");
+            ND_ICHECKMSG_ZU("message length", msg_tlen, <,
+                            sizeof(struct olsr_hello));
 
             ptr.hello = (const struct olsr_hello *)msg_data;
             ND_PRINT("\n\t  hello-time %.3fs, MPR willingness %u",
@@ -475,7 +476,8 @@ olsr_print(netdissect_options *ndo,
 
         case OLSR_TC_MSG:
         case OLSR_TC_LQ_MSG:
-            ND_LCHECKMSG_ZU(msg_tlen, sizeof(struct olsr_tc), "message length");
+            ND_ICHECKMSG_ZU("message length", msg_tlen, <,
+                            sizeof(struct olsr_tc));
             ND_TCHECK_LEN(msg_data, sizeof(struct olsr_tc));
 
             ptr.tc = (const struct olsr_tc *)msg_data;
@@ -605,7 +607,7 @@ olsr_print(netdissect_options *ndo,
             int name_entries_valid;
             u_int i;
 
-            ND_LCHECKMSG_U(msg_tlen, 4, "message length");
+            ND_ICHECKMSG_U("message length", msg_tlen, <, 4);
 
             name_entries = GET_BE_U_2(msg_data + 2);
             addr_size = 4;
@@ -654,8 +656,8 @@ olsr_print(netdissect_options *ndo,
                 if (name_entry_len%4 != 0)
                     name_entry_padding = 4-(name_entry_len%4);
 
-                ND_LCHECKMSG_U(msg_tlen, addr_size + name_entry_len + name_entry_padding,
-                               "name entry length");
+                ND_ICHECKMSG_U("name entry length", msg_tlen, <,
+                               addr_size + name_entry_len + name_entry_padding);
 
                 ND_TCHECK_LEN(msg_data,
                               addr_size + name_entry_len + name_entry_padding);
index f4ccbe9d03a0d3198d06a8ce4ea5f33366c88179..c4ff02042e4ef2e480908aa20f1521fa38e6fce2 100644 (file)
@@ -436,7 +436,7 @@ ptp_print(netdissect_options *ndo, const u_char *bp, u_int length)
     u_int vers;
 
     ndo->ndo_protocol = "ptp";
-    ND_LCHECK_U(length, PTP_HDR_LEN);
+    ND_ICHECK_U(length, <, PTP_HDR_LEN);
     vers = GET_BE_U_2(bp) & PTP_VERS_MASK;
     ND_PRINT("PTPv%u",vers);
     switch(vers) {
index 8aea1f8aaba44f88fccf9785df9e9d871e6f3f12..265222a19fe52d9b8fe3a5da16f5ec5a844e168e 100644 (file)
@@ -195,7 +195,7 @@ rip_entry_print_v1(netdissect_options *ndo, const u_char *p,
        const struct rip_netinfo_v1 *ni = (const struct rip_netinfo_v1 *)p;
 
        /* RFC 1058 */
-       ND_LCHECKMSG_U(remaining, RIP_ROUTELEN, "remaining data length");
+       ND_ICHECKMSG_U("remaining data length", remaining, <, RIP_ROUTELEN);
        ND_TCHECK_SIZE(ni);
        family = GET_BE_U_2(ni->rip_family);
        if (family != BSD_AFNUM_INET && family != 0) {
@@ -232,7 +232,7 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
        u_short family;
        const struct rip_netinfo_v2 *ni;
 
-       ND_LCHECKMSG_ZU(remaining, sizeof(*eh), "remaining data length");
+       ND_ICHECKMSG_ZU("remaining data length", remaining, <, sizeof(*eh));
        ND_TCHECK_SIZE(eh);
        family = GET_BE_U_2(eh->rip_family);
        if (family == 0xFFFF) { /* variable-sized authentication structures */
@@ -247,7 +247,8 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
                        const struct rip_auth_crypto_v2 *ch;
 
                        ch = (const struct rip_auth_crypto_v2 *)p;
-                       ND_LCHECKMSG_ZU(remaining, sizeof(*ch), "remaining data length");
+                       ND_ICHECKMSG_ZU("remaining data length", remaining,
+                                       <, sizeof(*ch));
                        ND_PRINT("\n\t  Auth header:");
                        ND_PRINT(" Packet Len %u,",
                                 GET_BE_U_2(ch->rip_packet_len));
@@ -272,7 +273,8 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
                print_unknown_data(ndo, p + sizeof(*eh), "\n\t  ", RIP_ROUTELEN - sizeof(*eh));
        } else { /* BSD_AFNUM_INET or AFI 0 */
                ni = (const struct rip_netinfo_v2 *)p;
-               ND_LCHECKMSG_ZU(remaining, sizeof(*ni), "remaining data length");
+               ND_ICHECKMSG_ZU("remaining data length", remaining, <,
+                               sizeof(*ni));
                ND_PRINT("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
                         tok2str(bsd_af_values, "%u", family),
                         GET_IPADDR_STRING(ni->rip_dest),
@@ -298,7 +300,7 @@ rip_print(netdissect_options *ndo,
        unsigned entry_size;
 
        ndo->ndo_protocol = "rip";
-       ND_LCHECKMSG_ZU(len, sizeof(*rp), "packet length");
+       ND_ICHECKMSG_ZU("packet length", len, <, sizeof(*rp));
 
        rp = (const struct rip *)p;
 
@@ -333,7 +335,8 @@ rip_print(netdissect_options *ndo,
                                        /* Error */
                                        goto invalid;
                                }
-                               ND_LCHECKMSG_U(len, entry_size, "remaining entries length");
+                               ND_ICHECKMSG_U("remaining entries length",
+                                              len, <, entry_size);
                                p += entry_size;
                                len -= entry_size;
                        }
@@ -347,7 +350,8 @@ rip_print(netdissect_options *ndo,
                                        /* Error */
                                        goto invalid;
                                }
-                               ND_LCHECKMSG_U(len, entry_size, "remaining entries length");
+                               ND_ICHECKMSG_U("remaining entries length",
+                                              len, <, entry_size);
                                p += entry_size;
                                len -= entry_size;
                        }
index 86744e063b9cb54ebdc2eb23dd8842125cb70c5e..df9edc6cd25c9820759091d32fb9476c63a75b4d 100644 (file)
@@ -519,7 +519,7 @@ rsvp_intserv_print(netdissect_options *ndo,
        uint32_t i;
     } bw;
 
-    ND_LCHECK_U(obj_tlen, 4);
+    ND_ICHECK_U(obj_tlen, <, 4);
     parameter_id = GET_U_1(tptr);
     parameter_length = GET_BE_U_2(tptr + 2)<<2; /* convert wordcount to bytecount */
 
@@ -529,7 +529,7 @@ rsvp_intserv_print(netdissect_options *ndo,
            parameter_length,
            GET_U_1(tptr + 1));
 
-    ND_LCHECK_U(obj_tlen, parameter_length + 4);
+    ND_ICHECK_U(obj_tlen, <, parameter_length + 4);
     switch(parameter_id) { /* parameter_id */
 
     case 4:
@@ -1252,7 +1252,7 @@ rsvp_obj_print(netdissect_options *ndo,
                      * each iteration subobj_len may happen to be a multiple of 1
                      * and test it and total_subobj_len respectively.
                      */
-                    ND_LCHECK_U(total_subobj_len, 4);
+                    ND_ICHECK_U(total_subobj_len, <, 4);
                     subobj_len  = GET_BE_U_2(obj_tptr);
                     subobj_type = (GET_BE_U_2(obj_tptr + 2))>>8;
                     af = (GET_BE_U_2(obj_tptr + 2))&0x00FF;
index ecf3caa7bfcf0ca5b7616c4a51771b6ff3cc721e..ff50c5557f5e76b5bed35c6d9bccb15158de7561 100644 (file)
@@ -891,7 +891,7 @@ sflow_print(netdissect_options *ndo,
                len);
 
         /* skip Common header */
-        ND_LCHECK_ZU(tlen, sizeof(struct sflow_v6_datagram_t));
+        ND_ICHECK_ZU(tlen, <, sizeof(struct sflow_v6_datagram_t));
         tptr += sizeof(struct sflow_v6_datagram_t);
         tlen -= sizeof(struct sflow_v6_datagram_t);
     }
index d5891de654b669c611d3608264550a9faa961c76..aa132678c6371d5676e2394aa7234d9ffbf1c77a 100644 (file)
@@ -369,7 +369,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
        if (ndo->ndo_packettype != PT_RPC)
                udpipaddr_print(ndo, ip, sport, dport);
 
-       ND_LCHECKMSG_ZU(length, sizeof(struct udphdr), "undersized-udp");
+       ND_ICHECKMSG_ZU("undersized-udp", length, <, sizeof(struct udphdr));
        ulen = GET_BE_U_2(up->uh_ulen);
        udp_sum = GET_BE_U_2(up->uh_sum);
        /*
@@ -379,7 +379,8 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
         */
        if (ulen == 0 && length > 65535)
                ulen = length;
-       ND_LCHECKMSG_ZU(ulen, sizeof(struct udphdr), "undersized-udplength");
+       ND_ICHECKMSG_ZU("undersized-udplength", ulen, <,
+                       sizeof(struct udphdr));
        ulen -= sizeof(struct udphdr);
        length -= sizeof(struct udphdr);
        if (ulen < length)
index fd74368ceb3b74f1217f049d2abd276ca8f147e9..7186f74aaaf48f9d752df3cedf9423de08f53ef7 100644 (file)
@@ -123,7 +123,7 @@ zep_print(netdissect_options *ndo,
 
        if (version == 1) {
                /* ZEP v1 packet. */
-               ND_LCHECK_U(len, 16);
+               ND_ICHECK_U(len, <, 16);
                ND_PRINT("Channel ID %u, Device ID 0x%04x, ",
                         GET_U_1(bp + 3), GET_BE_U_2(bp + 4));
                if (GET_U_1(bp + 6))
@@ -139,7 +139,7 @@ zep_print(netdissect_options *ndo,
                /* ZEP v2 packet. */
                if (GET_U_1(bp + 3) == 2) {
                        /* ZEP v2 ack. */
-                       ND_LCHECK_U(len, 8);
+                       ND_ICHECK_U(len, <, 8);
                        seq_no = GET_BE_U_4(bp + 4);
                        ND_PRINT("ACK, seq# = %u", seq_no);
                        inner_len = 0;
@@ -147,7 +147,7 @@ zep_print(netdissect_options *ndo,
                        len -= 8;
                } else {
                        /* ZEP v2 data, or some other. */
-                       ND_LCHECK_U(len, 32);
+                       ND_ICHECK_U(len, <, 32);
                        ND_PRINT("Type %u, Channel ID %u, Device ID 0x%04x, ",
                                 GET_U_1(bp + 3), GET_U_1(bp + 4),
                                 GET_BE_U_2(bp + 5));