we shouldn't use "(ip + 1)" to detect intermediate headers (AH/ESP).

we should use ip_p == IPPROTO_TCP/UDP.
This commit is contained in:
itojun 2000-08-01 17:39:46 +00:00
parent bec9b9854d
commit 058e85bfc6
2 changed files with 8 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: print-tcp.c,v 1.18 2000/08/01 17:34:00 itojun Exp $ */ /* $NetBSD: print-tcp.c,v 1.19 2000/08/01 17:39:46 itojun Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@ -27,7 +27,7 @@
static const char rcsid[] = static const char rcsid[] =
"@(#) Header: print-tcp.c,v 1.55 97/06/15 13:20:28 leres Exp (LBL)"; "@(#) Header: print-tcp.c,v 1.55 97/06/15 13:20:28 leres Exp (LBL)";
#else #else
__RCSID("$NetBSD: print-tcp.c,v 1.18 2000/08/01 17:34:00 itojun Exp $"); __RCSID("$NetBSD: print-tcp.c,v 1.19 2000/08/01 17:39:46 itojun Exp $");
#endif #endif
#endif #endif
@ -266,10 +266,9 @@ tcp_print(register const u_char *bp, register u_int length,
return; return;
} }
} }
#ifdef INET6 #ifdef INET6
if (ip6) { if (ip6) {
if (bp == (u_char *)(ip6 + 1)) { if (ip6->ip6_nxt == IPPROTO_TCP) {
(void)printf("%s.%s > %s.%s: ", (void)printf("%s.%s > %s.%s: ",
ip6addr_string(&ip6->ip6_src), ip6addr_string(&ip6->ip6_src),
tcpport_string(sport), tcpport_string(sport),
@ -282,7 +281,7 @@ tcp_print(register const u_char *bp, register u_int length,
} else } else
#endif /*INET6*/ #endif /*INET6*/
{ {
if (bp == (u_char *)(ip + 1)) { if (ip->ip_p == IPPROTO_TCP) {
(void)printf("%s.%s > %s.%s: ", (void)printf("%s.%s > %s.%s: ",
ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_src),
tcpport_string(sport), tcpport_string(sport),

View File

@ -1,4 +1,4 @@
/* $NetBSD: print-udp.c,v 1.14 2000/08/01 17:35:18 itojun Exp $ */ /* $NetBSD: print-udp.c,v 1.15 2000/08/01 17:39:46 itojun Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@ -27,7 +27,7 @@
static const char rcsid[] = static const char rcsid[] =
"@(#) Header: print-udp.c,v 1.60 97/07/27 21:58:48 leres Exp (LBL)"; "@(#) Header: print-udp.c,v 1.60 97/07/27 21:58:48 leres Exp (LBL)";
#else #else
__RCSID("$NetBSD: print-udp.c,v 1.14 2000/08/01 17:35:18 itojun Exp $"); __RCSID("$NetBSD: print-udp.c,v 1.15 2000/08/01 17:39:46 itojun Exp $");
#endif #endif
#endif #endif
@ -541,7 +541,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
#else #else
#ifdef INET6 #ifdef INET6
if (ip6) { if (ip6) {
if (bp == (u_char *)(ip6 + 1)) { if (ip6->ip6_nxt == IPPROTO_UDP) {
(void)printf("%s.%s > %s.%s: ", (void)printf("%s.%s > %s.%s: ",
ip6addr_string(&ip6->ip6_src), ip6addr_string(&ip6->ip6_src),
udpport_string(sport), udpport_string(sport),
@ -554,7 +554,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
} else } else
#endif /*INET6*/ #endif /*INET6*/
{ {
if (bp == (u_char *)(ip + 1)) { if (ip->ip_p == IPPROTO_UDP) {
(void)printf("%s.%s > %s.%s: ", (void)printf("%s.%s > %s.%s: ",
ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_src),
udpport_string(sport), udpport_string(sport),