]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ether.c
Ethernet: Remove two useless tests
[tcpdump] / print-ether.c
index 0a331d188b8f10c344379b8bc0626a091be6ecd4..1158b7945efa67c46fc5419993807ea9aa25b08f 100644 (file)
@@ -148,7 +148,8 @@ ether_hdr_print(netdissect_options *ndo,
 u_int
 ether_print(netdissect_options *ndo,
             const u_char *p, u_int length, u_int caplen,
-            void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
+            void (*print_encap_header)(netdissect_options *ndo, const u_char *),
+            const u_char *encap_header_arg)
 {
        const struct ether_header *ehp;
        u_int orig_length;
@@ -157,14 +158,11 @@ ether_print(netdissect_options *ndo,
        int llc_hdrlen;
        struct lladdr_info src, dst;
 
+       ndo->ndo_protocol = "ether";
        if (caplen < ETHER_HDRLEN) {
-               ND_PRINT("[|ether]");
+               nd_print_trunc(ndo);
                return (caplen);
        }
-       if (length < ETHER_HDRLEN) {
-               ND_PRINT("[|ether]");
-               return (length);
-       }
 
        if (ndo->ndo_eflag) {
                if (print_encap_header != NULL)
@@ -211,10 +209,6 @@ recurse:
                        ND_PRINT("[|vlan]");
                        return (hdrlen + caplen);
                }
-               if (length < 4) {
-                       ND_PRINT("[|vlan]");
-                       return (hdrlen + length);
-               }
                if (ndo->ndo_eflag) {
                        uint16_t tag = EXTRACT_BE_U_2(p);
 
@@ -274,6 +268,7 @@ u_int
 ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
                const u_char *p)
 {
+       ndo->ndo_protocol = "ether_if";
        return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
 }
 
@@ -293,8 +288,9 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
        /*
         * Fail if we don't have enough data for the Hilscher pseudo-header.
         */
-       if (h->len < 4 || h->caplen < 4) {
-               ND_PRINT("[|netanalyzer]");
+       ndo->ndo_protocol = "netanalyzer_if";
+       if (h->caplen < 4) {
+               nd_print_trunc(ndo);
                return (h->caplen);
        }
 
@@ -321,8 +317,9 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
         * Fail if we don't have enough data for the Hilscher pseudo-header,
         * preamble, and SOF.
         */
-       if (h->len < 12 || h->caplen < 12) {
-               ND_PRINT("[|netanalyzer-transparent]");
+       ndo->ndo_protocol = "netanalyzer_transparent_if";
+       if (h->caplen < 12) {
+               nd_print_trunc(ndo);
                return (h->caplen);
        }
 
@@ -472,12 +469,3 @@ ethertype_print(netdissect_options *ndo,
                return (0);
        }
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-