]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sll.c
When checking for pcap_if_t, add $V_INCLS to CFLAGS, so we look at the
[tcpdump] / print-sll.c
index c6cd93dd2e5dfcb9e2c27b0ad975960f94ccb06f..8c3d4b3da491a2084238703e53b8503b34f8a065 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.7 2002-06-01 23:50:33 guy Exp $ (LBL)";
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.15 2004-03-17 23:24:38 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
+#include <tcpdump-stdinc.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -91,25 +87,20 @@ sll_print(register const struct sll_header *sllp, u_int length)
 }
 
 /*
- * This is the top level routine of the printer.  'p' is the points
- * to the ether header of the packet, 'h->tv' is the timestamp,
- * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * This is the top level routine of the printer.  'p' points to the
+ * Linux "cooked capture" header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
-void
-sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+u_int
+sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int caplen = h->caplen;
        u_int length = h->len;
        register const struct sll_header *sllp;
-       u_short pkttype;
-       struct ether_header ehdr;
        u_short ether_type;
        u_short extracted_ethertype;
 
-       ++infodelay;
-       ts_print(&h->ts);
-
        if (caplen < SLL_HDR_LEN) {
                /*
                 * XXX - this "can't happen" because "pcap-linux.c" always
@@ -117,67 +108,17 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                 * cooked socket capture.
                 */
                printf("[|sll]");
-               goto out;
+               return (caplen);
        }
 
        sllp = (const struct sll_header *)p;
 
-       /*
-        * Fake up an Ethernet header for the benefit of printers that
-        * insist on "packetp" pointing to an Ethernet header.
-        */
-       pkttype = ntohs(sllp->sll_pkttype);
-
-       /* The source address is in the packet header */
-       memcpy(ehdr.ether_shost, sllp->sll_addr, ETHER_ADDR_LEN);
-
-       if (pkttype != LINUX_SLL_OUTGOING) {
-               /*
-                * We received this packet.
-                *
-                * We don't know the destination address, so
-                * we fake it - all 0's except that the
-                * bottommost bit of the bottommost octet
-                * is set for a unicast packet, all 0's except
-                * that the bottommost bit of the uppermost
-                * octet is set for a multicast packet, all
-                * 1's for a broadcast packet.
-                */
-               if (pkttype == LINUX_SLL_BROADCAST)
-                       memset(ehdr.ether_dhost, 0xFF, ETHER_ADDR_LEN);
-               else {
-                       memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN);
-                       if (pkttype == LINUX_SLL_MULTICAST)
-                               ehdr.ether_dhost[0] = 1;
-                       else
-                               ehdr.ether_dhost[ETHER_ADDR_LEN-1] = 1;
-               }
-       } else {
-               /*
-                * We sent this packet; we don't know whether it's
-                * broadcast, multicast, or unicast, so just make
-                * the destination address all 0's.
-                */
-               memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN);
-       }
-
        if (eflag)
                sll_print(sllp, length);
 
        /*
-        * Some printers want to get back at the ethernet addresses,
-        * and/or check that they're not walking off the end of the packet.
-        * Rather than pass them all the way down, we set these globals.
+        * Go past the cooked-mode header.
         */
-       snapend = p + caplen;
-       /*
-        * Actually, the only printers that use packetp are print-arp.c
-        * and print-bootp.c, and they assume that packetp points to an
-        * Ethernet header.  The right thing to do is to fix them to know
-        * which link type is in use when they excavate. XXX
-        */
-       packetp = (u_char *)&ehdr;
-
        length -= SLL_HDR_LEN;
        caplen -= SLL_HDR_LEN;
        p += SLL_HDR_LEN;
@@ -207,8 +148,8 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                         * 802.2.
                         * Try to print the LLC-layer header & higher layers.
                         */
-                       if (llc_print(p, length, caplen, ESRC(&ehdr),
-                           EDST(&ehdr), &extracted_ethertype) == 0)
+                       if (llc_print(p, length, caplen, NULL, NULL,
+                           &extracted_ethertype) == 0)
                                goto unknown;   /* unknown LLC type */
                        break;
 
@@ -233,11 +174,6 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
-       if (xflag)
-               default_print(p, caplen);
- out:
-       putchar('\n');
-       --infodelay;
-       if (infoprint)
-               info(0);
+
+       return (SLL_HDR_LEN);
 }