48
48
* Compute a V6-style checksum by building a pseudoheader.
51
nextproto6_cksum(const struct ip6_hdr *ip6, const u_short *data,
51
nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
52
52
u_int len, u_int next_proto)
56
union ip6_pseudo_hdr phu;
55
struct in6_addr ph_src;
56
struct in6_addr ph_dst;
61
struct cksum_vec vec[2];
58
63
/* pseudo-header */
59
memset(&phu, 0, sizeof(phu));
60
phu.ph.ph_src = ip6->ip6_src;
61
phu.ph.ph_dst = ip6->ip6_dst;
62
phu.ph.ph_len = htonl(len);
63
phu.ph.ph_nxt = next_proto;
65
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) {
69
return in_cksum(data, len, sum);
64
memset(&ph, 0, sizeof(ph));
65
ph.ph_src = ip6->ip6_src;
66
ph.ph_dst = ip6->ip6_dst;
67
ph.ph_len = htonl(len);
68
ph.ph_nxt = next_proto;
70
vec[0].ptr = (const u_int8_t *)(void *)&ph;
71
vec[0].len = sizeof(ph);
75
return in_cksum(vec, 2);
73
79
* print an IP6 datagram.
76
ip6_print(register const u_char *bp, register u_int length)
82
ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
78
84
register const struct ip6_hdr *ip6;
79
85
register int advance;
91
97
if (length < sizeof (struct ip6_hdr)) {
92
(void)printf("truncated-ip6 %u", length);
98
(void)ND_PRINT((ndo, "truncated-ip6 %u", length));
103
ND_PRINT((ndo, "IP6 "));
99
105
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
100
106
len = payload_len + sizeof(struct ip6_hdr);
101
107
if (length < len)
102
(void)printf("truncated-ip6 - %u bytes missing!",
108
(void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
111
if (ndo->ndo_vflag) {
106
112
flow = EXTRACT_32BITS(&ip6->ip6_flow);
113
ND_PRINT((ndo, "("));
110
116
if (flow & 0x0f000000)
111
(void)printf("pri 0x%02x, ", (flow & 0x0f000000) >> 24);
117
(void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
112
118
if (flow & 0x00ffffff)
113
(void)printf("flowlabel 0x%06x, ", flow & 0x00ffffff);
119
(void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
116
122
if (flow & 0x0ff00000)
117
(void)printf("class 0x%02x, ", (flow & 0x0ff00000) >> 20);
123
(void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
118
124
if (flow & 0x000fffff)
119
(void)printf("flowlabel 0x%05x, ", flow & 0x000fffff);
125
(void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
122
(void)printf("hlim %u, next-header %s (%u) payload length: %u) ",
128
(void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
124
130
tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
130
136
* Cut off the snapshot length to the end of the IP payload.
132
138
ipend = bp + len;
139
if (ipend < ndo->ndo_snapend)
140
ndo->ndo_snapend = ipend;
136
142
cp = (const u_char *)ip6;
137
143
advance = sizeof(struct ip6_hdr);
138
144
nh = ip6->ip6_nxt;
139
while (cp < snapend && advance > 0) {
145
while (cp < ndo->ndo_snapend && advance > 0) {
143
149
if (cp == (const u_char *)(ip6 + 1) &&
144
150
nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
145
151
nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
146
(void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
147
ip6addr_string(&ip6->ip6_dst));
152
(void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
153
ip6addr_string(&ip6->ip6_dst)));
196
202
udp_print(cp, len, (const u_char *)ip6, fragmented);
198
204
case IPPROTO_ICMPV6:
199
icmp6_print(gndo, cp, len, (const u_char *)ip6, fragmented);
205
icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
202
208
advance = ah_print(cp);
250
256
case IPPROTO_NONE:
251
(void)printf("no next header");
257
(void)ND_PRINT((ndo, "no next header"));
255
(void)printf("ip-proto-%d %d", nh, len);
261
(void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
262
(void)printf("[|ip6]");
268
(void)ND_PRINT((ndo, "[|ip6]"));
265
271
#endif /* INET6 */