Deleted Added
full compact
21c21
< * $FreeBSD: head/contrib/tcpdump/print-ip6.c 98527 2002-06-21 00:49:02Z fenner $
---
> * $FreeBSD: head/contrib/tcpdump/print-ip6.c 127675 2004-03-31 14:57:24Z bms $
25,26c25,26
< static const char rcsid[] =
< "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.21 2001/11/16 02:17:36 itojun Exp $";
---
> static const char rcsid[] _U_ =
> "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.8 2003/11/24 20:31:22 guy Exp $";
35,38c35
< #include <sys/param.h>
< #include <sys/time.h>
< #include <sys/types.h>
< #include <sys/socket.h>
---
> #include <tcpdump-stdinc.h>
40,41d36
< #include <netinet/in.h>
<
44d38
< #include <unistd.h>
48a43
> #include "extract.h"
50a46
> #include "ipproto.h"
60c56,57
< register u_int len;
---
> u_int len;
> const u_char *ipend;
61a59
> register u_int payload_len;
65c63
<
---
>
68,86d65
< #ifdef LBL_ALIGN
< /*
< * The IP6 header is not 16-byte aligned, so copy into abuf.
< */
< if ((u_long)ip6 & 15) {
< static u_char *abuf;
<
< if (abuf == NULL) {
< abuf = malloc(snaplen);
< if (abuf == NULL)
< error("ip6_print: malloc");
< }
< memcpy(abuf, ip6, min(length, snaplen));
< snapend += abuf - (u_char *)ip6;
< packetp = abuf;
< ip6 = (struct ip6_hdr *)abuf;
< bp = abuf;
< }
< #endif
92d70
< advance = sizeof(struct ip6_hdr);
94,95c72,74
< len = ntohs(ip6->ip6_plen);
< if (length < len + advance)
---
> payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
> len = payload_len + sizeof(struct ip6_hdr);
> if (length < len)
97c76
< len + advance - length);
---
> len - length);
98a78,84
> /*
> * Cut off the snapshot length to the end of the IP payload.
> */
> ipend = bp + len;
> if (ipend < snapend)
> snapend = ipend;
>
99a86
> advance = sizeof(struct ip6_hdr);
101c88
< while (cp < snapend) {
---
> while (cp < snapend && advance > 0) {
102a90
> len -= advance;
104,105c92,94
< if (cp == (const u_char *)(ip6 + 1)
< && nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
---
> if (cp == (const u_char *)(ip6 + 1) &&
> nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
> nh != IPPROTO_SCTP) {
125a115,130
>
> case IPPROTO_MOBILITY_OLD:
> case IPPROTO_MOBILITY:
> /*
> * XXX - we don't use "advance"; the current
> * "Mobility Support in IPv6" draft
> * (draft-ietf-mobileip-ipv6-24) says that
> * the next header field in a mobility header
> * should be IPPROTO_NONE, but speaks of
> * the possiblity of a future extension in
> * which payload can be piggybacked atop a
> * mobility header.
> */
> advance = mobility_print(cp, (const u_char *)ip6);
> nh = *cp;
> goto end;
129a135,137
> case IPPROTO_SCTP:
> sctp_print(cp, (const u_char *)ip6, len);
> goto end;
131,132c139
< tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
< (const u_char *)ip6, fragmented);
---
> tcp_print(cp, len, (const u_char *)ip6, fragmented);
135,136c142
< udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
< (const u_char *)ip6, fragmented);
---
> udp_print(cp, len, (const u_char *)ip6, fragmented);
139c145
< icmp6_print(cp, (const u_char *)ip6);
---
> icmp6_print(cp, len, (const u_char *)ip6, fragmented);
142c148
< advance = ah_print(cp, (const u_char *)ip6);
---
> advance = ah_print(cp);
149,150d154
< if (enh < 0)
< goto end;
155,157d158
< #ifndef IPPROTO_IPCOMP
< #define IPPROTO_IPCOMP 108
< #endif
161,163c162
< advance = ipcomp_print(cp, (const u_char *)ip6, &enh);
< if (enh < 0)
< goto end;
---
> advance = ipcomp_print(cp, &enh);
168,170d166
< #ifndef IPPROTO_PIM
< #define IPPROTO_PIM 103
< #endif
174,176d169
< #ifndef IPPROTO_OSPF
< #define IPPROTO_OSPF 89
< #endif
179a173
>
183,185c177
< #ifndef IPPROTO_IPV4
< #define IPPROTO_IPV4 4
< #endif
---
>
188a181
>
200,201c193,194
<
< flow = ntohl(ip6->ip6_flow);
---
>
> flow = EXTRACT_32BITS(&ip6->ip6_flow);
217c210
< (void)printf(" [hlim %d]", (int)ip6->ip6_hlim);
---
> (void)printf(" [hlim %u]", ip6->ip6_hlim);
221c214
< (void)printf("len %d", len);
---
> (void)printf("len %u", payload_len);