]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add support for Apple's IP-over-IEEE 1394 encapsulation.
authorguy <guy>
Wed, 17 Mar 2004 19:40:41 +0000 (19:40 +0000)
committerguy <guy>
Wed, 17 Mar 2004 19:40:41 +0000 (19:40 +0000)
FILES
INSTALL
Makefile.in
interface.h
print-ap1394.c [new file with mode: 0644]
tcpdump.c

diff --git a/FILES b/FILES
index a23f7e5b7dde46aac0b2c964e42e55b006ee236f..bc1a671f4fc6d61d3ef6fec42278f8600e7d8949 100644 (file)
--- a/FILES
+++ b/FILES
@@ -94,6 +94,7 @@ parsenfsfh.c
 pcap-missing.h
 ppp.h
 print-802_11.c
 pcap-missing.h
 ppp.h
 print-802_11.c
+print-ap1394.c
 print-ah.c
 print-aodv.c
 print-arcnet.c
 print-ah.c
 print-aodv.c
 print-arcnet.c
diff --git a/INSTALL b/INSTALL
index f8edb41ab73b8ac00de1e6da33406bb43cd8a988..341244ba6002e0cd73bcced066e91209a9cbf71a 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
-@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.59 2004-03-11 09:36:15 guy Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.60 2004-03-17 19:40:41 guy Exp $ (LBL)
 
 If you have not built libpcap, do so first.  See the README
 file in this directory for the ftp location.
 
 If you have not built libpcap, do so first.  See the README
 file in this directory for the ftp location.
@@ -114,6 +114,7 @@ parsenfsfh.c        - Network File System file parser routines
 pcap-missing.h - declarations of functions possibly missing from libpcap
 ppp.h          - Point to Point Protocol definitions
 print-802_11.c - IEEE 802.11 printer routines
 pcap-missing.h - declarations of functions possibly missing from libpcap
 ppp.h          - Point to Point Protocol definitions
 print-802_11.c - IEEE 802.11 printer routines
+print-ap1394.c - Apple IP-over-IEEE 1394 printer routines
 print-ah.c     - IPSEC Authentication Header printer routines
 print-aodv.c   - AODV printer routines
 print-arcnet.c - ARCNET printer routines
 print-ah.c     - IPSEC Authentication Header printer routines
 print-aodv.c   - AODV printer routines
 print-arcnet.c - ARCNET printer routines
index 7d7394ea6c56a589ef81ee786c8261b78fa6490c..c6a33a182ead0aab72e93adeab6f2e9fcbccda44 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.280 2004-03-11 09:36:15 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.281 2004-03-17 19:40:41 guy Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -66,8 +66,8 @@ INSTALL_DATA = @INSTALL_DATA@
        $(CC) $(CFLAGS) -c $(srcdir)/$*.c
 
 CSRC = addrtoname.c gmpls.c oui.c gmt2local.c machdep.c parsenfsfh.c \
        $(CC) $(CFLAGS) -c $(srcdir)/$*.c
 
 CSRC = addrtoname.c gmpls.c oui.c gmt2local.c machdep.c parsenfsfh.c \
-       print-802_11.c print-ah.c print-arcnet.c print-aodv.c \
-       print-arp.c print-ascii.c print-atalk.c print-atm.c \
+       print-802_11.c print-ap1394.c print-ah.c print-arcnet.c \
+       print-aodv.c print-arp.c print-ascii.c print-atalk.c print-atm.c \
        print-beep.c print-bfd.c print-bgp.c print-bootp.c print-cdp.c \
        print-chdlc.c print-cip.c print-cnfp.c print-decnet.c \
        print-domain.c print-dvmrp.c print-enc.c print-egp.c \
        print-beep.c print-bfd.c print-bgp.c print-bootp.c print-cdp.c \
        print-chdlc.c print-cip.c print-cnfp.c print-decnet.c \
        print-domain.c print-dvmrp.c print-enc.c print-egp.c \
index 69158efc0097736c969bd718ddb2bdac5acaed47..99079453792d2dde99c3dc9ee8212d079c6d47aa 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.223 2004-03-11 09:36:15 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.224 2004-03-17 19:40:41 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
  */
 
 #ifndef tcpdump_interface_h
@@ -222,8 +222,7 @@ extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void ether_print(const u_char *, u_int, u_int);
 extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void ether_print(const u_char *, u_int, u_int);
-extern u_int ether_if_print(const struct pcap_pkthdr *,
-       const u_char *);
+extern u_int ether_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int token_print(const u_char *, u_int, u_int);
 extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void fddi_print(const u_char *, u_int, u_int);
 extern u_int token_print(const u_char *, u_int, u_int);
 extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void fddi_print(const u_char *, u_int, u_int);
@@ -232,6 +231,7 @@ extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
        const u_char *);
 extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
        const u_char *);
+extern u_int ap1394_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void gre_print(const u_char *, u_int);
 extern void icmp_print(const u_char *, u_int, const u_char *, int);
 extern void igmp_print(const u_char *, u_int);
 extern void gre_print(const u_char *, u_int);
 extern void icmp_print(const u_char *, u_int, const u_char *, int);
 extern void igmp_print(const u_char *, u_int);
diff --git a/print-ap1394.c b/print-ap1394.c
new file mode 100644 (file)
index 0000000..49a704e
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.1 2004-03-17 19:40:42 guy Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <pcap.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "ethertype.h"
+
+/*
+ * Structure of a header for Apple's IP-over-IEEE 1384 BPF header.
+ */
+#define FIREWIRE_EUI64_LEN     8
+struct firewire_header {
+       u_char  firewire_dhost[FIREWIRE_EUI64_LEN];
+       u_char  firewire_shost[FIREWIRE_EUI64_LEN];
+       u_short firewire_type;
+};
+
+/*
+ * Length of that header; note that some compilers may pad
+ * "struct firewire_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct firewire_header)" may not give the right answer.
+ */
+#define FIREWIRE_HDRLEN                18
+
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
+{
+       u_int length = h->len;
+       u_int caplen = h->caplen;
+       struct firewire_header *fp;
+       u_short ether_type;
+       u_short extracted_ether_type;
+
+       if (caplen < FIREWIRE_HDRLEN) {
+               printf("[|ap1394]");
+               return FIREWIRE_HDRLEN;
+       }
+
+       length -= FIREWIRE_HDRLEN;
+       caplen -= FIREWIRE_HDRLEN;
+       fp = (struct firewire_header *)p;
+       p += FIREWIRE_HDRLEN;
+
+       ether_type = ntohs(fp->firewire_type);
+
+       extracted_ether_type = 0;
+       if (ether_encap_print(ether_type, p, length, caplen,
+           &extracted_ether_type) == 0) {
+               /* ether_type not known, print raw packet */
+               if (!xflag && !qflag)
+                       default_print(p, caplen);
+       } 
+
+       return FIREWIRE_HDRLEN;
+}
index 2fedb9fa664a1b0cc5586a675dff8e28cf1ade9b..4dc2fe0aa39e4569d758982eb0de21518f71a555 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.234 2004-03-11 09:36:16 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.235 2004-03-17 19:40:42 guy Exp $ (LBL)";
 #endif
 
 /*
 #endif
 
 /*
@@ -234,6 +234,9 @@ static struct printer printers[] = {
 #endif
 #ifdef DLT_SYMANTEC_FIREWALL
        { symantec_if_print,    DLT_SYMANTEC_FIREWALL },
 #endif
 #ifdef DLT_SYMANTEC_FIREWALL
        { symantec_if_print,    DLT_SYMANTEC_FIREWALL },
+#endif
+#ifdef DLT_APPLE_IP_OVER_IEEE1394
+       { ap1394_if_print,      DLT_APPLE_IP_OVER_IEEE1394 },
 #endif
        { NULL,                 0 },
 };
 #endif
        { NULL,                 0 },
 };