diff options
-rw-r--r-- | usr.sbin/tcpdump/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/tcpdump/interface.h | 5 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-udp.c | 7 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-udpencap.c | 54 |
4 files changed, 64 insertions, 5 deletions
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile index 6b4c7da6bb2..d852531c605 100644 --- a/usr.sbin/tcpdump/Makefile +++ b/usr.sbin/tcpdump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.39 2003/05/22 21:15:17 pvalchev Exp $ +# $OpenBSD: Makefile,v 1.40 2003/06/11 20:58:45 markus Exp $ # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 # The Regents of the University of California. All rights reserved. @@ -50,6 +50,7 @@ SRCS= tcpdump.c addrtoname.c \ print-bgp.c print-ospf6.c print-ripng.c print-rt6.c print-stp.c \ print-etherip.c print-lwres.c print-cdp.c print-pflog.c \ print-pfsync.c pf_print_state.c \ + print-udpencap.c \ gmt2local.c savestr.c setsignal.c #SRCS+= smbutil.c print-smb.c diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index 4f1b4ce745e..cb79efa17e7 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.h,v 1.37 2003/05/14 08:50:37 canacar Exp $ */ +/* $OpenBSD: interface.h,v 1.38 2003/06/11 20:58:45 markus Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -20,7 +20,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.37 2003/05/14 08:50:37 canacar Exp $ (LBL) + * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.38 2003/06/11 20:58:45 markus Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -244,6 +244,7 @@ extern void timed_print(const u_char *, u_int); extern void udp_print(const u_char *, u_int, const u_char *); extern void wb_print(const void *, u_int); extern void ike_print(const u_char *, u_int); +extern void udpencap_print(const u_char *, u_int, const u_char *); extern void ah_print(const u_char *, u_int, const u_char *); extern void esp_print(const u_char *, u_int, const u_char *); extern void cdp_print(const u_char *, u_int, u_int, const u_char *, diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index c87dd554787..16c7f38b511 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-udp.c,v 1.21 2002/01/22 18:33:07 mickey Exp $ */ +/* $OpenBSD: print-udp.c,v 1.22 2003/06/11 20:58:45 markus Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udp.c,v 1.21 2002/01/22 18:33:07 mickey Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udp.c,v 1.22 2003/06/11 20:58:45 markus Exp $ (LBL)"; #endif #include <sys/param.h> @@ -349,6 +349,7 @@ static int udp_cksum(register const struct ip *ip, #define KERBEROS_SEC_PORT 750 /*XXX*/ #define L2TP_PORT 1701 /*XXX*/ #define ISAKMP_PORT 500 /*XXX*/ +#define UDPENCAP_PORT 4500 /*XXX*/ #define TIMED_PORT 525 /*XXX*/ #define NETBIOS_NS_PORT 137 /*XXX*/ #define NETBIOS_DGRAM_PORT 138 /*XXX*/ @@ -585,6 +586,8 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) l2tp_print((const u_char *)(up + 1), length); else if (ISPORT(ISAKMP_PORT)) ike_print((const u_char *)(up + 1), length); + else if (ISPORT(UDPENCAP_PORT)) + udpencap_print((const u_char *)(up + 1), length, bp2); #if 0 else if (ISPORT(NETBIOS_NS_PORT)) nbt_udp137_print((const u_char *)(up + 1), length); diff --git a/usr.sbin/tcpdump/print-udpencap.c b/usr.sbin/tcpdump/print-udpencap.c new file mode 100644 index 00000000000..e6c3900fa7e --- /dev/null +++ b/usr.sbin/tcpdump/print-udpencap.c @@ -0,0 +1,54 @@ +/* $OpenBSD: print-udpencap.c,v 1.1 2003/06/11 20:58:45 markus Exp $ */ + +/* + * Copyright (c) 2003 Markus Friedl. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] = + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udpencap.c,v 1.1 2003/06/11 20:58:45 markus Exp $ (XXX)"; +#endif + +#include <sys/types.h> +#include <stdio.h> + +#include "interface.h" + +void +udpencap_print(const u_char *bp, u_int len, const u_char *bp2) +{ + u_int32_t *spi; + + if (len < sizeof(u_int32_t)) { + fputs(" [|udpencap]", stdout); + return; + } + if (vflag) + (void)printf(" "); + (void)printf("udpencap: "); + spi = (u_int32_t *)(bp); + if (*spi == 0) + ike_print(bp + sizeof(u_int32_t), len - sizeof(u_int32_t)); + else + esp_print(bp, len, bp2); +} |