summaryrefslogtreecommitdiff
path: root/usr.sbin/tcpdump
diff options
context:
space:
mode:
authorRyan Thomas McBride <mcbride@cvs.openbsd.org>2004-04-28 02:17:04 +0000
committerRyan Thomas McBride <mcbride@cvs.openbsd.org>2004-04-28 02:17:04 +0000
commitd43f1ae6983caef2bca69f007df44cee540a7e55 (patch)
treea070360c4b40c94217fdc456d0dca1c0f5aea038 /usr.sbin/tcpdump
parent9626e4bf453e82f99cdd57d1a22669fa8df0ebfc (diff)
Make tcpdump print carp as carp. Printing vrrp can be forced with -T vrrp.
ok markus@ pb@
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r--usr.sbin/tcpdump/Makefile4
-rw-r--r--usr.sbin/tcpdump/interface.h6
-rw-r--r--usr.sbin/tcpdump/print-carp.c83
-rw-r--r--usr.sbin/tcpdump/print-ip.c24
-rw-r--r--usr.sbin/tcpdump/tcpdump.84
-rw-r--r--usr.sbin/tcpdump/tcpdump.c6
6 files changed, 112 insertions, 15 deletions
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile
index 50bc705e4b1..4ba390f2b92 100644
--- a/usr.sbin/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.45 2004/02/02 09:43:27 otto Exp $
+# $OpenBSD: Makefile,v 1.46 2004/04/28 02:17:03 mcbride Exp $
#
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
# The Regents of the University of California. All rights reserved.
@@ -45,7 +45,7 @@ SRCS= tcpdump.c addrtoname.c privsep.c privsep_fdpass.c privsep_pcap.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 \
+ print-udpencap.c print-carp.c \
gmt2local.c savestr.c setsignal.c
# TCP OS Fingerprinting
diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h
index ec369060653..f779ad9433d 100644
--- a/usr.sbin/tcpdump/interface.h
+++ b/usr.sbin/tcpdump/interface.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.h,v 1.43 2004/01/28 19:44:55 canacar Exp $ */
+/* $OpenBSD: interface.h,v 1.44 2004/04/28 02:17:03 mcbride 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.43 2004/01/28 19:44:55 canacar Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.44 2004/04/28 02:17:03 mcbride Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -57,6 +57,7 @@ extern int packettype; /* as specified by -T */
#define PT_RTP 4 /* Real-Time Applications protocol */
#define PT_RTCP 5 /* Real-Time Applications control protocol */
#define PT_CNFP 6 /* Cisco NetFlow protocol */
+#define PT_VRRP 7 /* Virtual Router Redundancy protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@@ -221,6 +222,7 @@ extern char *smb_errstr(int, int);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *dat, u_int length);
extern void vrrp_print(const u_char *bp, u_int len, int ttl);
+extern void carp_print(const u_char *bp, u_int len, int ttl);
extern void hsrp_print(const u_char *, u_int);
extern void nfsreply_print(const u_char *, u_int, const u_char *);
extern void nfsreq_print(const u_char *, u_int, const u_char *);
diff --git a/usr.sbin/tcpdump/print-carp.c b/usr.sbin/tcpdump/print-carp.c
new file mode 100644
index 00000000000..dd56f78b505
--- /dev/null
+++ b/usr.sbin/tcpdump/print-carp.c
@@ -0,0 +1,83 @@
+/* $OpenBSD: print-carp.c,v 1.1 2004/04/28 02:17:03 mcbride Exp $ */
+
+/*
+ * Copyright (c) 2000 William C. Fenner.
+ * All rights reserved.
+ *
+ * Kevin Steves <ks@hp.se> July 2000
+ * Modified to:
+ * - print version, type string and packet length
+ * - print IP address count if > 1 (-v)
+ * - verify checksum (-v)
+ * - print authentication string (-v)
+ *
+ * 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, and (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.
+ * The name of William C. Fenner may not 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.
+ *
+ * from tcpdump.org:
+ * Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.3 2000/10/10 05:05:08 guy Exp
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-carp.c,v 1.1 2004/04/28 02:17:03 mcbride Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <netinet/in.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+void
+carp_print(register const u_char *bp, register u_int len, int ttl)
+{
+ int version, type, auth_type;
+ char *type_s;
+
+ TCHECK(bp[0]);
+ version = (bp[0] & 0xf0) >> 4;
+ type = bp[0] & 0x0f;
+ if (type == 1)
+ type_s = "advertise";
+ else
+ type_s = "unknown";
+ printf("CARPv%d-%s %d: ", version, type_s, len);
+ if (ttl != 255)
+ printf("[ttl=%d!] ", ttl);
+ if (version != 2 || type != 1)
+ return;
+ TCHECK(bp[2]);
+ TCHECK(bp[5]);
+ printf("vhid=%d advbase=%d advskew=%d", bp[5], bp[1], bp[2]);
+ if (vflag) {
+ int naddrs = bp[3];
+ int i;
+ char c;
+
+ if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0))
+ printf(" (bad carp cksum %x!)",
+ EXTRACT_16BITS(&bp[6]));
+ }
+ return;
+trunc:
+ printf("[|carp]");
+}
diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c
index 3542cd6439b..09f38d32353 100644
--- a/usr.sbin/tcpdump/print-ip.c
+++ b/usr.sbin/tcpdump/print-ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-ip.c,v 1.24 2004/02/04 08:35:12 otto Exp $ */
+/* $OpenBSD: print-ip.c,v 1.25 2004/04/28 02:17:03 mcbride Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.24 2004/02/04 08:35:12 otto Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.25 2004/04/28 02:17:03 mcbride Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -546,15 +546,23 @@ ip_print(register const u_char *bp, register u_int length)
ipcomp_print(cp, len, (const u_char *)ip);
break;
-#ifndef IPPROTO_VRRP
-#define IPPROTO_VRRP 112
+#ifndef IPPROTO_CARP
+#define IPPROTO_CARP 112
#endif
- case IPPROTO_VRRP:
- if (vflag)
- (void)printf("vrrp %s > %s: ",
+ case IPPROTO_CARP:
+ if (packettype == PT_VRRP) {
+ if (vflag)
+ (void)printf("vrrp %s > %s: ",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ vrrp_print(cp, len, ip->ip_ttl);
+ } else {
+ if (vflag)
+ (void)printf("carp %s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
- vrrp_print(cp, len, ip->ip_ttl);
+ carp_print(cp, len, ip->ip_ttl);
+ }
break;
#ifndef IPPROTO_PFSYNC
diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8
index 4536141a6b4..d5cd43fdf64 100644
--- a/usr.sbin/tcpdump/tcpdump.8
+++ b/usr.sbin/tcpdump/tcpdump.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tcpdump.8,v 1.43 2003/10/12 10:59:47 dhartmei Exp $
+.\" $OpenBSD: tcpdump.8,v 1.44 2004/04/28 02:17:03 mcbride Exp $
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
.\" The Regents of the University of California. All rights reserved.
@@ -199,6 +199,8 @@ Force packets selected by
to be interpreted as the specified
.Ar type .
Currently known types are
+.Cm vrrp
+.Pq Virtual Router Redundancy protocol ,
.Cm cnfp
.Pq Cisco NetFlow protocol ,
.Cm rpc
diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c
index ac3fb064849..38768b88fb5 100644
--- a/usr.sbin/tcpdump/tcpdump.c
+++ b/usr.sbin/tcpdump/tcpdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcpdump.c,v 1.35 2004/01/28 19:44:55 canacar Exp $ */
+/* $OpenBSD: tcpdump.c,v 1.36 2004/04/28 02:17:03 mcbride Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -26,7 +26,7 @@ static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.35 2004/01/28 19:44:55 canacar Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.36 2004/04/28 02:17:03 mcbride Exp $ (LBL)";
#endif
/*
@@ -281,6 +281,8 @@ main(int argc, char **argv)
packettype = PT_RTCP;
else if (strcasecmp(optarg, "cnfp") == 0)
packettype = PT_CNFP;
+ else if (strcasecmp(optarg, "vrrp") == 0)
+ packettype = PT_VRRP;
else if (strcasecmp(optarg, "sack") == 0)
snaplen = SACK_SNAPLEN;
else