]>
The Tcpdump Group git mirrors - tcpdump/blob - print-ip6.c
eae094a65ac0109ace011ecc47ba056e76153524
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
[] _U_
=
24 "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.38 2003-11-19 06:17:10 guy Exp $";
33 #include <tcpdump-stdinc.h>
39 #include "interface.h"
40 #include "addrtoname.h"
47 * print an IP6 datagram.
50 ip6_print(register const u_char
*bp
, register u_int length
)
52 register const struct ip6_hdr
*ip6
;
56 register const u_char
*cp
;
57 register u_int payload_len
;
62 ip6
= (const struct ip6_hdr
*)bp
;
65 if (length
< sizeof (struct ip6_hdr
)) {
66 (void)printf("truncated-ip6 %d", length
);
70 len
= EXTRACT_16BITS(&ip6
->ip6_plen
) + sizeof(struct ip6_hdr
);
72 (void)printf("truncated-ip6 - %d bytes missing!",
76 * Cut off the snapshot length to the end of the IP payload.
82 cp
= (const u_char
*)ip6
;
84 advance
= sizeof(struct ip6_hdr
);
86 while (cp
< snapend
&& advance
> 0) {
88 payload_len
-= advance
;
90 if (cp
== (const u_char
*)(ip6
+ 1) &&
91 nh
!= IPPROTO_TCP
&& nh
!= IPPROTO_UDP
&&
93 (void)printf("%s > %s: ", ip6addr_string(&ip6
->ip6_src
),
94 ip6addr_string(&ip6
->ip6_dst
));
99 advance
= hbhopt_print(cp
);
102 case IPPROTO_DSTOPTS
:
103 advance
= dstopt_print(cp
);
106 case IPPROTO_FRAGMENT
:
107 advance
= frag6_print(cp
, (const u_char
*)ip6
);
108 if (snapend
<= cp
+ advance
)
114 case IPPROTO_MOBILITY
:
116 * XXX - we don't use "advance"; is this
117 * header always a final header?
119 advance
= mobility_print(cp
, (const u_char
*)ip6
);
122 case IPPROTO_ROUTING
:
123 advance
= rt6_print(cp
, (const u_char
*)ip6
);
127 sctp_print(cp
, (const u_char
*)ip6
, payload_len
);
130 tcp_print(cp
, payload_len
, (const u_char
*)ip6
,
134 udp_print(cp
, payload_len
, (const u_char
*)ip6
,
138 icmp6_print(cp
, payload_len
, (const u_char
*)ip6
,
142 advance
= ah_print(cp
);
148 advance
= esp_print(cp
, (const u_char
*)ip6
, &enh
, &padlen
);
156 advance
= ipcomp_print(cp
, &enh
);
162 pim_print(cp
, payload_len
);
165 ospf6_print(cp
, payload_len
);
169 ip6_print(cp
, payload_len
);
173 ip_print(cp
, payload_len
);
177 (void)printf("no next header");
181 (void)printf("ip-proto-%d %d", ip6
->ip6_nxt
,
189 flow
= EXTRACT_32BITS(&ip6
->ip6_flow
);
192 if (flow
& 0x0f000000)
193 (void)printf(" [pri 0x%x]", (flow
& 0x0f000000) >> 24);
194 if (flow
& 0x00ffffff)
195 (void)printf(" [flowlabel 0x%x]", flow
& 0x00ffffff);
198 if (flow
& 0x0ff00000)
199 (void)printf(" [class 0x%x]", (flow
& 0x0ff00000) >> 20);
200 if (flow
& 0x000fffff)
201 (void)printf(" [flowlabel 0x%x]", flow
& 0x000fffff);
204 if (ip6
->ip6_hlim
<= 1)
205 (void)printf(" [hlim %d]", (int)ip6
->ip6_hlim
);
209 (void)printf("len %d", len
);
210 if (ip6
->ip6_hlim
> 1)
211 (void)printf(", hlim %d", (int)ip6
->ip6_hlim
);
216 (void)printf("[|ip6]");