diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2020-06-21 05:00:19 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2020-06-21 05:00:19 +0000 |
commit | 226f9283cc54188550a295eb784aa699ae65d699 (patch) | |
tree | 2c3ad1784edcc34bc6f723b58445d21e6570660a /usr.sbin | |
parent | 708df011895c466572519abe7cb5ba2a62b9b91f (diff) |
wire the wireguard packet printer into tcpdump.
from Matt Dunwoodie and Jason A. Donenfeld
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/tcpdump/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/tcpdump/interface.h | 8 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-udp.c | 7 | ||||
-rw-r--r-- | usr.sbin/tcpdump/tcpdump.8 | 6 | ||||
-rw-r--r-- | usr.sbin/tcpdump/tcpdump.c | 4 |
5 files changed, 21 insertions, 8 deletions
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile index d566d3ab653..76119942c25 100644 --- a/usr.sbin/tcpdump/Makefile +++ b/usr.sbin/tcpdump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.65 2020/04/15 20:19:25 remi Exp $ +# $OpenBSD: Makefile,v 1.66 2020/06/21 05:00:17 dlg Exp $ # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 # The Regents of the University of California. All rights reserved. @@ -48,7 +48,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-lldp.c print-cdp.c print-pflog.c \ print-pfsync.c pf_print_state.c print-ofp.c ofp_map.c \ - print-udpencap.c print-carp.c print-nhrp.c \ + print-udpencap.c print-carp.c print-nhrp.c print-wg.c \ print-802_11.c print-iapp.c print-mpls.c print-slow.c print-usbpcap.c \ gmt2local.c savestr.c setsignal.c in_cksum.c diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index 5836e64ce12..2a68beddf51 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.h,v 1.84 2020/04/15 20:19:25 remi Exp $ */ +/* $OpenBSD: interface.h,v 1.85 2020/06/21 05:00:17 dlg 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. * - * @(#) $Id: interface.h,v 1.84 2020/04/15 20:19:25 remi Exp $ (LBL) + * @(#) $Id: interface.h,v 1.85 2020/06/21 05:00:17 dlg Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -65,6 +65,7 @@ extern char *device; /* as specified by -i */ #define PT_TFTP 11 /* Trivial File Transfer Protocol */ #define PT_VXLAN 12 /* Virtual eXtensible Local Area Network */ #define PT_ERSPAN 13 /* GRE ERSPAN Type I or II */ +#define PT_WIREGUARD 14 /* WireGuard tunnel */ #ifndef min #define min(a,b) ((a)>(b)?(b):(a)) @@ -266,6 +267,7 @@ extern void sunrpcrequest_print(const u_char *, u_int, const u_char *); extern void cnfp_print(const u_char *, u_int); extern void tcp_print(const u_char *, u_int, const u_char *); extern void tftp_print(const u_char *, u_int); +extern void wg_print(const u_char *, u_int); extern void timed_print(const u_char *, u_int); extern void udp_print(const u_char *, u_int, const void *); extern void wb_print(const void *, u_int); @@ -304,3 +306,5 @@ extern uint32_t in_cksum_add(const void *, size_t, uint32_t); extern uint16_t in_cksum_fini(uint32_t); extern uint16_t in_cksum(const void *, size_t, uint32_t); extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t); + +extern uint32_t wg_match(const u_char *, u_int); diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index 81eb57283c4..d581c924ba2 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.54 2020/01/24 22:46:37 procter Exp $ */ +/* $OpenBSD: print-udp.c,v 1.55 2020/06/21 05:00:18 dlg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 @@ -472,6 +472,9 @@ udp_print(const u_char *bp, u_int length, const void *iph) case PT_TFTP: tftp_print(cp, length); break; + case PT_WIREGUARD: + wg_print(cp, length); + break; } return; } @@ -573,6 +576,8 @@ udp_print(const u_char *bp, u_int length, const void *iph) wb_print(cp, length); else if (dport == HSRP_PORT) hsrp_print(cp, length); + else if (wg_match(cp, length)) + wg_print(cp, length); else printf("udp %u", length); #undef ISPORT diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8 index e17012bba36..c0eaea3c676 100644 --- a/usr.sbin/tcpdump/tcpdump.8 +++ b/usr.sbin/tcpdump/tcpdump.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tcpdump.8,v 1.109 2019/11/06 12:49:50 sthen Exp $ +.\" $OpenBSD: tcpdump.8,v 1.110 2020/06/21 05:00:18 dlg Exp $ .\" .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996 .\" The Regents of the University of California. All rights reserved. @@ -19,7 +19,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.Dd $Mdocdate: November 6 2019 $ +.Dd $Mdocdate: June 21 2020 $ .Dt TCPDUMP 8 .Os .Sh NAME @@ -262,6 +262,8 @@ Virtual Router Redundancy protocol Virtual eXtensible Local Area Network .It Cm wb distributed White Board +.It Cm wg +WireGuard tunnel .El .It Fl t Do not print a timestamp on each dump line. diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c index 34d7de738ad..02661758e39 100644 --- a/usr.sbin/tcpdump/tcpdump.c +++ b/usr.sbin/tcpdump/tcpdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpdump.c,v 1.92 2020/01/24 22:46:37 procter Exp $ */ +/* $OpenBSD: tcpdump.c,v 1.93 2020/06/21 05:00:18 dlg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -371,6 +371,8 @@ main(int argc, char **argv) packettype = PT_MPLS; else if (strcasecmp(optarg, "tftp") == 0) packettype = PT_TFTP; + else if (strcasecmp(optarg, "wg") == 0) + packettype = PT_WIREGUARD; else if (strcasecmp(optarg, "sack") == 0) /* * kept for compatibility; DEFAULT_SNAPLEN |