]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sll.c
CHANGES: Add/move change(s) backported to 4.99
[tcpdump] / print-sll.c
index 38db4520fb8fe1daa2a6a0139fbb72bb06be2ac6..de767781e016c4a87bb94ac80853e66341524371 100644 (file)
 
 /* \summary: Linux cooked sockets capture printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #ifdef HAVE_NET_IF_H
+/*
+ * Include diag-control.h before <net/if.h>, which too defines a macro
+ * named ND_UNREACHABLE.
+ */
+#include "diag-control.h"
 #include <net/if.h>
 #endif
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "ethertype.h"
@@ -162,7 +166,7 @@ sll_print(netdissect_options *ndo, const struct sll_header *sllp, u_int length)
         * For now, we just assume 6 means Ethernet.
         * XXX - print others as strings of hex?
         */
-       if (GET_BE_U_2(sllp->sll_halen) == 6)
+       if (GET_BE_U_2(sllp->sll_halen) == MAC_ADDR_LEN)
                ND_PRINT("%s ", GET_ETHERADDR_STRING(sllp->sll_addr));
 
        if (!ndo->ndo_qflag) {
@@ -223,16 +227,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        u_int hdrlen;
 
        ndo->ndo_protocol = "sll";
-       if (caplen < SLL_HDR_LEN) {
-               /*
-                * XXX - this "can't happen" because "pcap-linux.c" always
-                * adds this many bytes of header to every packet in a
-                * cooked socket capture.
-                */
-               nd_print_trunc(ndo);
-               ndo->ndo_ll_hdr_len += caplen;
-               return;
-       }
+       ND_TCHECK_LEN(p, SLL_HDR_LEN);
 
        sllp = (const struct sll_header *)p;
 
@@ -354,7 +349,7 @@ sll2_print(netdissect_options *ndo, const struct sll2_header *sllp, u_int length
         * For now, we just assume 6 means Ethernet.
         * XXX - print others as strings of hex?
         */
-       if (GET_U_1(sllp->sll2_halen) == 6)
+       if (GET_U_1(sllp->sll2_halen) == MAC_ADDR_LEN)
                ND_PRINT("%s ", GET_ETHERADDR_STRING(sllp->sll2_addr));
 
        if (!ndo->ndo_qflag) {
@@ -419,16 +414,7 @@ sll2_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
 #endif
 
        ndo->ndo_protocol = "sll2";
-       if (caplen < SLL2_HDR_LEN) {
-               /*
-                * XXX - this "can't happen" because "pcap-linux.c" always
-                * adds this many bytes of header to every packet in a
-                * cooked socket capture.
-                */
-               nd_print_trunc(ndo);
-               ndo->ndo_ll_hdr_len += caplen;
-               return;
-       }
+       ND_TCHECK_LEN(p, SLL2_HDR_LEN);
 
        sllp = (const struct sll2_header *)p;
 #ifdef HAVE_NET_IF_H