]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add support for OpenBSD DLT_ENC.
authorguy <guy>
Sat, 8 Mar 2003 08:55:32 +0000 (08:55 +0000)
committerguy <guy>
Sat, 8 Mar 2003 08:55:32 +0000 (08:55 +0000)
FILES
INSTALL
Makefile.in
enc.h [new file with mode: 0644]
interface.h
print-enc.c [new file with mode: 0644]
tcpdump.c

diff --git a/FILES b/FILES
index 31592ba813bde48a4cbec67b7783b66a5c956453..948cd5e94d769d7a33d2e63091c3e70737475add 100644 (file)
--- a/FILES
+++ b/FILES
@@ -25,6 +25,7 @@ config.sub
 configure
 configure.in
 decnet.h
+enc.h
 esp.h
 ether.h
 ethertype.h
diff --git a/INSTALL b/INSTALL
index e289e98b95f1798acbace0162ef888521ebeb2ab..574cd098955aaf42a042faed7483485206ee788b 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
-@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.52 2002-12-19 09:27:55 guy Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.53 2003-03-08 08:55:33 guy Exp $ (LBL)
 
 If you have not built libpcap, do so first.  See the README
 file in this directory for the ftp location.
@@ -67,6 +67,7 @@ config.sub    - autoconf support
 configure      - configure script (run this first)
 configure.in   - configure script source
 decnet.h       - DECnet definitions
+enc.h          - OpenBSD IPsec encapsulation BPF layer definitions
 esp.h          - IPSEC Encapsulating Security Payload definitions
 ether.h                - Ethernet definitions
 ethertype.h    - Ethernet type value definitions
@@ -124,6 +125,7 @@ print-decnet.c      - DECnet printer routines
 print-dhcp6.c  - IPv6 DHCP printer routines
 print-domain.c - Domain Name System printer routines
 print-dvmrp.c  - Distance Vector Multicast Routing Protocol printer routines
+print-enc.c    - OpenBSD IPsec encapsulation BPF layer printer routines
 print-egp.c    - External Gateway Protocol printer routines
 print-esp.c    - IPSEC Encapsulating Security Payload printer routines
 print-ether.c  - Ethernet printer routines
index 58c609b26aa10438eb5721048d9056aaed8b1291..a21f020de182cd12c82b2bbc63b288c41dd9dbfb 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.271 2002-12-22 21:46:54 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.272 2003-03-08 08:55:33 guy Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -70,17 +70,17 @@ CSRC =      addrtoname.c gmt2local.c machdep.c parsenfsfh.c \
        print-ascii.c print-atalk.c print-atm.c print-beep.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-egp.c print-esp.c print-ether.c \
-       print-fddi.c print-fr.c print-gre.c print-hsrp.c \
-       print-icmp.c print-igmp.c print-igrp.c print-ip.c \
-       print-ipcomp.c print-ipfc.c print-ipx.c print-isakmp.c \
-       print-isoclns.c print-krb.c print-l2tp.c print-lane.c \
-       print-ldp.c print-llc.c print-lwres.c print-mobile.c \
-       print-mpls.c print-msdp.c print-nfs.c print-ntp.c \
-       print-null.c print-ospf.c print-pflog.c print-pim.c \
-       print-ppp.c print-pppoe.c print-pptp.c print-radius.c \
-       print-raw.c print-rip.c print-rsvp.c print-rx.c \
-       print-sctp.c print-sl.c print-sll.c print-snmp.c \
+       print-dvmrp.c print-enc.c print-egp.c print-esp.c \
+       print-ether.c print-fddi.c print-fr.c print-gre.c \
+       print-hsrp.c print-icmp.c print-igmp.c print-igrp.c \
+       print-ip.c print-ipcomp.c print-ipfc.c print-ipx.c \
+       print-isakmp.c print-isoclns.c print-krb.c print-l2tp.c \
+       print-lane.c print-ldp.c print-llc.c print-lwres.c \
+       print-mobile.c print-mpls.c print-msdp.c print-nfs.c \
+       print-ntp.c print-null.c print-ospf.c print-pflog.c \
+       print-pim.c print-ppp.c print-pppoe.c print-pptp.c \
+       print-radius.c print-raw.c print-rip.c print-rsvp.c \
+       print-rx.c print-sctp.c print-sl.c print-sll.c print-snmp.c \
        print-stp.c print-sunatm.c print-sunrpc.c print-tcp.c \
        print-telnet.c print-tftp.c print-timed.c print-token.c \
        print-udp.c print-vjc.c print-vrrp.c print-wb.c \
diff --git a/enc.h b/enc.h
new file mode 100644 (file)
index 0000000..2d57e2b
--- /dev/null
+++ b/enc.h
@@ -0,0 +1,47 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/enc.h,v 1.1 2003-03-08 08:55:33 guy Exp $ (LBL) */
+/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
+/*
+ * The authors of this code are John Ioannidis ([email protected]),
+ * Angelos D. Keromytis ([email protected]) and 
+ * Niels Provos ([email protected]).
+ *
+ * This code was written by John Ioannidis for BSD/OS in Athens, Greece, 
+ * in November 1995.
+ *
+ * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
+ * by Angelos D. Keromytis.
+ *
+ * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
+ * and Niels Provos.
+ *
+ * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
+ * and Niels Provos.
+ * Copyright (c) 2001, Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software with or without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software. 
+ * You may use this code under the GNU public license if you so wish. Please
+ * contribute changes back to the authors under this freer than GPL license
+ * so that we may further the use of strong encryption without limitations to
+ * all.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#define ENC_HDRLEN     12
+
+/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $  */
+#define M_CONF         0x0400  /* packet was encrypted (ESP-transport) */
+#define M_AUTH         0x0800  /* packet was authenticated (AH) */
+
+struct enchdr {
+       u_int32_t af;
+       u_int32_t spi;
+       u_int32_t flags;
+};
index 5a16403284f81a2e1e2fe2e2bce89dbf3ca8274b..73b650adb00bfef31a958cbd7dd4dd03dd5d418f 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.205 2003-01-23 09:05:38 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.206 2003-03-08 08:55:34 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -212,6 +212,7 @@ extern void default_print(const u_char *, u_int);
 extern void default_print_unaligned(const u_char *, u_int);
 extern void dvmrp_print(const u_char *, u_int);
 extern void egp_print(const u_char *);
+extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
 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 *);
diff --git a/print-enc.c b/print-enc.c
new file mode 100644 (file)
index 0000000..061d691
--- /dev/null
@@ -0,0 +1,78 @@
+/*     $OpenBSD: print-enc.c,v 1.7 2002/02/19 19:39:40 millert Exp $   */
+
+/*
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
+ *     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[] =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.1 2003-03-08 08:55:34 guy Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <pcap.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+#include "enc.h"
+
+#define ENC_PRINT_TYPE(wh, xf, nam) \
+       if ((wh) & (xf)) { \
+               printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \
+               (wh) &= ~(xf); \
+       }
+
+u_int
+enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+{
+       register u_int length = h->len;
+       register u_int caplen = h->caplen;
+       int flags;
+       const struct enchdr *hdr;
+
+       if (caplen < ENC_HDRLEN) {
+               printf("[|enc]");
+               goto out;
+       }
+
+       hdr = (struct enchdr *)p;
+       flags = hdr->flags;
+       if (flags == 0)
+               printf("(unprotected): ");
+       else
+               printf("(");
+       ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
+       ENC_PRINT_TYPE(flags, M_CONF, "confidential");
+       /* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
+       printf("SPI 0x%08x: ", (u_int32_t)ntohl(hdr->spi));
+
+       length -= ENC_HDRLEN;
+       /* XXX - use the address family */
+       ip_print(p + ENC_HDRLEN, length);
+
+out:
+       return (ENC_HDRLEN);
+}
index ef3edc9ee134949b75a5cadd319f7c7e44d58907..c560bff162e247ef734b139d948e1e19f20f2212 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] =
     "@(#) 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[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.203 2003-02-11 08:04:18 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.204 2003-03-08 08:55:34 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -198,6 +198,9 @@ static struct printer printers[] = {
 #endif
 #ifdef DLT_IEEE802_11_RADIO
        { ieee802_11_radio_if_print,    DLT_IEEE802_11_RADIO },
+#endif
+#ifdef DLT_ENC
+       { enc_if_print,         DLT_ENC },
 #endif
        { NULL,                 0 },
 };