]>
The Tcpdump Group git mirrors - tcpdump/blob - print-ip6.c
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 static const char rcsid
[] =
24 "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.27 2002-10-18 04:40:03 itojun Exp $";
33 #include <tcpdump-stdinc.h>
39 #include "interface.h"
40 #include "addrtoname.h"
45 * print an IP6 datagram.
48 ip6_print(register const u_char
*bp
, register u_int length
)
50 register const struct ip6_hdr
*ip6
;
53 register const u_char
*cp
;
58 ip6
= (const struct ip6_hdr
*)bp
;
61 if (length
< sizeof (struct ip6_hdr
)) {
62 (void)printf("truncated-ip6 %d", length
);
65 advance
= sizeof(struct ip6_hdr
);
67 len
= ntohs(ip6
->ip6_plen
);
68 if (length
< len
+ advance
)
69 (void)printf("truncated-ip6 - %d bytes missing!",
70 len
+ advance
- length
);
72 cp
= (const u_char
*)ip6
;
74 while (cp
< snapend
) {
77 if (cp
== (const u_char
*)(ip6
+ 1)
78 && nh
!= IPPROTO_TCP
&& nh
!= IPPROTO_UDP
) {
79 (void)printf("%s > %s: ", ip6addr_string(&ip6
->ip6_src
),
80 ip6addr_string(&ip6
->ip6_dst
));
85 advance
= hbhopt_print(cp
);
89 advance
= dstopt_print(cp
);
92 case IPPROTO_FRAGMENT
:
93 advance
= frag6_print(cp
, (const u_char
*)ip6
);
94 if (snapend
<= cp
+ advance
)
99 #ifndef IPPROTO_MOBILITY
100 #define IPPROTO_MOBILITY 62
102 case IPPROTO_MOBILITY
:
104 * XXX - we don't use "advance"; is this
105 * header always a final header?
107 advance
= mobility_print(cp
, (const u_char
*)ip6
);
110 case IPPROTO_ROUTING
:
111 advance
= rt6_print(cp
, (const u_char
*)ip6
);
115 tcp_print(cp
, len
+ sizeof(struct ip6_hdr
) - (cp
- bp
),
116 (const u_char
*)ip6
, fragmented
);
119 udp_print(cp
, len
+ sizeof(struct ip6_hdr
) - (cp
- bp
),
120 (const u_char
*)ip6
, fragmented
);
123 icmp6_print(cp
, (const u_char
*)ip6
);
126 advance
= ah_print(cp
);
132 advance
= esp_print(cp
, (const u_char
*)ip6
, &enh
, &padlen
);
139 #ifndef IPPROTO_IPCOMP
140 #define IPPROTO_IPCOMP 108
145 advance
= ipcomp_print(cp
, &enh
);
153 #define IPPROTO_PIM 103
159 #define IPPROTO_OSPF 89
162 ospf6_print(cp
, len
);
168 #define IPPROTO_IPV4 4
174 (void)printf("no next header");
178 (void)printf("ip-proto-%d %d", ip6
->ip6_nxt
, len
);
185 flow
= ntohl(ip6
->ip6_flow
);
188 if (flow
& 0x0f000000)
189 (void)printf(" [pri 0x%x]", (flow
& 0x0f000000) >> 24);
190 if (flow
& 0x00ffffff)
191 (void)printf(" [flowlabel 0x%x]", flow
& 0x00ffffff);
194 if (flow
& 0x0ff00000)
195 (void)printf(" [class 0x%x]", (flow
& 0x0ff00000) >> 20);
196 if (flow
& 0x000fffff)
197 (void)printf(" [flowlabel 0x%x]", flow
& 0x000fffff);
200 if (ip6
->ip6_hlim
<= 1)
201 (void)printf(" [hlim %d]", (int)ip6
->ip6_hlim
);
205 (void)printf("len %d", len
);
206 if (ip6
->ip6_hlim
> 1)
207 (void)printf(", hlim %d", (int)ip6
->ip6_hlim
);
212 (void)printf("[|ip6]");