diff options
author | 2006-09-19 14:25:04 +0000 | |
---|---|---|
committer | 2006-09-19 14:25:04 +0000 | |
commit | f2e0284a2783885fb19d5ad283c876c0030c7b01 (patch) | |
tree | 3a8ddf3414fbcc1ea56217c3e84c9d3360ffff55 | |
parent | sync (diff) | |
download | wireguard-openbsd-f2e0284a2783885fb19d5ad283c876c0030c7b01.tar.xz wireguard-openbsd-f2e0284a2783885fb19d5ad283c876c0030c7b01.zip |
enable ESP and AH dissectors over IPv6; ok mpf@ (at k2k6)
-rw-r--r-- | usr.sbin/tcpdump/print-ip6.c | 15 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-ipsec.c | 42 |
2 files changed, 46 insertions, 11 deletions
diff --git a/usr.sbin/tcpdump/print-ip6.c b/usr.sbin/tcpdump/print-ip6.c index c05cabeb840..d7465fba090 100644 --- a/usr.sbin/tcpdump/print-ip6.c +++ b/usr.sbin/tcpdump/print-ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip6.c,v 1.6 2005/10/08 19:24:03 canacar Exp $ */ +/* $OpenBSD: print-ip6.c,v 1.7 2006/09/19 14:25:04 naddy Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -116,8 +116,9 @@ ip6_print(register const u_char *bp, register int length) while (cp < snapend) { cp += hlen; - if (cp == (u_char *)(ip6 + 1) - && nh != IPPROTO_TCP && nh != IPPROTO_UDP) { + if (cp == (u_char *)(ip6 + 1) && + nh != IPPROTO_TCP && nh != IPPROTO_UDP && + nh != IPPROTO_ESP && nh != IPPROTO_AH) { (void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src), ip6addr_string(&ip6->ip6_dst)); } @@ -149,6 +150,14 @@ ip6_print(register const u_char *bp, register int length) udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp), (const u_char *)ip6); goto end; + case IPPROTO_ESP: + esp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp), + (const u_char *)ip6); + goto end; + case IPPROTO_AH: + ah_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp), + (const u_char *)ip6); + goto end; case IPPROTO_ICMPV6: icmp6_print(cp, (const u_char *)ip6); goto end; diff --git a/usr.sbin/tcpdump/print-ipsec.c b/usr.sbin/tcpdump/print-ipsec.c index 0534637df37..4fefcefb9c2 100644 --- a/usr.sbin/tcpdump/print-ipsec.c +++ b/usr.sbin/tcpdump/print-ipsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ipsec.c,v 1.8 2003/07/17 08:45:37 markus Exp $ */ +/* $OpenBSD: print-ipsec.c,v 1.9 2006/09/19 14:25:04 naddy Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -28,7 +28,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-ipsec.c,v 1.8 2003/07/17 08:45:37 markus Exp $ (XXX)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-ipsec.c,v 1.9 2006/09/19 14:25:04 naddy Exp $ (XXX)"; #endif #include <sys/param.h> @@ -49,6 +49,10 @@ static const char rcsid[] = #include <string.h> #include <unistd.h> +#ifdef INET6 +#include <netinet/ip6.h> +#endif + #include "addrtoname.h" #include "interface.h" #include "extract.h" /* must come after interface.h */ @@ -203,11 +207,22 @@ esp_print (register const u_char *bp, register u_int len, const struct ip *ip; const struct esp_hdr *esp; u_int plen = len; +#ifdef INET6 + const struct ip6_hdr *ip6; +#endif ip = (const struct ip *)bp2; - - printf("esp %s > %s", - ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); +#ifdef INET6 + if (ip->ip_v == 6) { + ip6 = (const struct ip6_hdr *)bp2; + printf("esp %s > %s", ip6addr_string(&ip6->ip6_src), + ip6addr_string(&ip6->ip6_dst)); + } else +#endif + { + printf("esp %s > %s", + ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); + } if (plen < sizeof(struct esp_hdr)) { printf("[|esp]"); @@ -240,11 +255,22 @@ ah_print (register const u_char *bp, register u_int len, const struct ip *ip; const struct ah_hdr *ah; u_int pl_len = len; +#ifdef INET6 + const struct ip6_hdr *ip6; +#endif ip = (const struct ip *)bp2; - - printf("ah %s > %s", - ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); +#ifdef INET6 + if (ip->ip_v == 6) { + ip6 = (const struct ip6_hdr *)bp2; + printf("ah %s > %s", ip6addr_string(&ip6->ip6_src), + ip6addr_string(&ip6->ip6_dst)); + } else +#endif + { + printf("ah %s > %s", + ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); + } if (pl_len < sizeof(struct ah_hdr)) { printf("[|ah]"); |