diff options
author | Lawrence Teo <lteo@cvs.openbsd.org> | 2014-01-11 04:35:53 +0000 |
---|---|---|
committer | Lawrence Teo <lteo@cvs.openbsd.org> | 2014-01-11 04:35:53 +0000 |
commit | 17a396dd4e2d5d4a1387a44bc71c59d327388ef4 (patch) | |
tree | 763836fb6baf38870513df9ee59ce1091216b159 | |
parent | 336694595eb1eac6eab1032bb56d749eb98866ce (diff) |
Make icmp_print() accept the length variable, which is the length of the
packet without the IP header. This is needed by the next commit that
will allow tcpdump to detect bad ICMP checksums.
Related functions like {tcp,udp,icmp6}_print() already accept this
length variable, so this change makes icmp_print() consistent with
them as well.
This commit makes no functional change to tcpdump itself.
OK florian@
-rw-r--r-- | usr.sbin/tcpdump/interface.h | 6 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-icmp.c | 4 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-ip.c | 4 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-ipsec.c | 7 |
4 files changed, 11 insertions, 10 deletions
diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index 202b427e3c7..7525dd91700 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.h,v 1.61 2010/04/06 16:01:57 jsg Exp $ */ +/* $OpenBSD: interface.h,v 1.62 2014/01/11 04:35:52 lteo 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.61 2010/04/06 16:01:57 jsg Exp $ (LBL) + * @(#) $Id: interface.h,v 1.62 2014/01/11 04:35:52 lteo Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -210,7 +210,7 @@ extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ppp_ether_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void gre_print(const u_char *, u_int); -extern void icmp_print(const u_char *, const u_char *); +extern void icmp_print(const u_char *, u_int, const u_char *); extern void ieee802_11_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ieee802_11_radio_if_print(u_char *, const struct pcap_pkthdr *, diff --git a/usr.sbin/tcpdump/print-icmp.c b/usr.sbin/tcpdump/print-icmp.c index 6348b76affb..a554c0a434f 100644 --- a/usr.sbin/tcpdump/print-icmp.c +++ b/usr.sbin/tcpdump/print-icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-icmp.c,v 1.20 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-icmp.c,v 1.21 2014/01/11 04:35:52 lteo Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 @@ -165,7 +165,7 @@ struct id_rdiscovery { }; void -icmp_print(const u_char *bp, const u_char *bp2) +icmp_print(const u_char *bp, u_int length, const u_char *bp2) { const struct icmp *dp; const struct ip *ip; diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index dacbeef78e5..c3324980fef 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.36 2010/01/12 06:10:33 naddy Exp $ */ +/* $OpenBSD: print-ip.c,v 1.37 2014/01/11 04:35:52 lteo Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -427,7 +427,7 @@ ip_print(register const u_char *bp, register u_int length) break; case IPPROTO_ICMP: - icmp_print(cp, (const u_char *)ip); + icmp_print(cp, len, (const u_char *)ip); break; #ifndef IPPROTO_IGRP diff --git a/usr.sbin/tcpdump/print-ipsec.c b/usr.sbin/tcpdump/print-ipsec.c index a4d1ed45eb8..8be8eb42c74 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.17 2012/05/03 10:17:23 mikeb Exp $ */ +/* $OpenBSD: print-ipsec.c,v 1.18 2014/01/11 04:35:52 lteo Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -187,7 +187,7 @@ esp_decrypt (const u_char *bp, u_int len, const u_char *bp2) ip_print(data, len); break; case IPPROTO_ICMP: - icmp_print(data, bp2); + icmp_print(data, len, bp2); break; case IPPROTO_ICMPV6: icmp6_print(data, len, bp2); @@ -298,7 +298,8 @@ ah_print (register const u_char *bp, register u_int len, break; case IPPROTO_ICMP: /* From here and down; Transport mode */ - icmp_print(bp + pl_len, (const u_char *) ip); + icmp_print(bp + pl_len, len - pl_len, + (const u_char *) ip); break; case IPPROTO_ICMPV6: |