]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sll.c
Regenerate config files.
[tcpdump] / print-sll.c
index 1f5f60084a20441ce34f6add5e65c2e915aa2b89..6148569ec160802ca48001223953ff1a16716b1e 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: Linux cooked sockets capture printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "extract.h"
@@ -198,7 +199,8 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        u_int length = h->len;
        register const struct sll_header *sllp;
        u_short ether_type;
-       u_short extracted_ethertype;
+       int llc_hdrlen;
+       u_int hdrlen;
 
        if (caplen < SLL_HDR_LEN) {
                /*
@@ -221,6 +223,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        length -= SLL_HDR_LEN;
        caplen -= SLL_HDR_LEN;
        p += SLL_HDR_LEN;
+       hdrlen = SLL_HDR_LEN;
 
        ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
 
@@ -247,23 +250,17 @@ recurse:
                         * 802.2.
                         * Try to print the LLC-layer header & higher layers.
                         */
-                       if (llc_print(ndo, p, length, caplen, NULL, NULL,
-                           &extracted_ethertype) == 0)
+                       llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+                       if (llc_hdrlen < 0)
                                goto unknown;   /* unknown LLC type */
+                       hdrlen += llc_hdrlen;
                        break;
 
                default:
-                       extracted_ethertype = 0;
                        /*FALLTHROUGH*/
 
                unknown:
-                       /* ether_type not known, print raw packet */
-                       if (!ndo->ndo_eflag)
-                               sll_print(ndo, sllp, length + SLL_HDR_LEN);
-                       if (extracted_ethertype) {
-                               ND_PRINT((ndo, "(LLC %s) ",
-                              etherproto_string(htons(extracted_ethertype))));
-                       }
+                       /* packet type not known, print raw packet */
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
                        break;
@@ -273,9 +270,13 @@ recurse:
                 * Print VLAN information, and then go back and process
                 * the enclosed type field.
                 */
-               if (caplen < 4 || length < 4) {
+               if (caplen < 4) {
+                       ND_PRINT((ndo, "[|vlan]"));
+                       return (hdrlen + caplen);
+               }
+               if (length < 4) {
                        ND_PRINT((ndo, "[|vlan]"));
-                       return (SLL_HDR_LEN);
+                       return (hdrlen + length);
                }
                if (ndo->ndo_eflag) {
                        uint16_t tag = EXTRACT_16BITS(p);
@@ -293,9 +294,10 @@ recurse:
                p += 4;
                length -= 4;
                caplen -= 4;
+               hdrlen += 4;
                goto recurse;
        } else {
-               if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
+               if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!ndo->ndo_eflag)
                                sll_print(ndo, sllp, length + SLL_HDR_LEN);
@@ -304,5 +306,5 @@ recurse:
                }
        }
 
-       return (SLL_HDR_LEN);
+       return (hdrlen);
 }