* calculation.
*/
static void
-ip6_finddst(netdissect_options *ndo, struct in6_addr *dst,
+ip6_finddst(netdissect_options *ndo, nd_ipv6 *dst,
const struct ip6_hdr *ip6)
{
const u_char *cp;
* the header, in units of 8 octets, excluding
* the first 8 octets.
*/
- ND_TCHECK_2(cp);
advance = (GET_U_1(cp + 1) + 1) << 3;
nh = GET_U_1(cp);
break;
* marked as reserved, and the header is always
* the same size.
*/
- ND_TCHECK_1(cp);
advance = sizeof(struct ip6_frag);
nh = GET_U_1(cp);
break;
done:
trunc:
- UNALIGNED_MEMCPY(dst, dst_addr, sizeof(nd_ipv6));
+ GET_CPY_BYTES(dst, dst_addr, sizeof(nd_ipv6));
}
/*
u_int len, u_int covlen, uint8_t next_proto)
{
struct {
- struct in6_addr ph_src;
- struct in6_addr ph_dst;
+ nd_ipv6 ph_src;
+ nd_ipv6 ph_dst;
uint32_t ph_len;
uint8_t ph_zero[3];
uint8_t ph_nxt;
/* pseudo-header */
memset(&ph, 0, sizeof(ph));
- UNALIGNED_MEMCPY(&ph.ph_src, ip6->ip6_src, sizeof (struct in6_addr));
+ GET_CPY_BYTES(&ph.ph_src, ip6->ip6_src, sizeof(nd_ipv6));
nh = GET_U_1(ip6->ip6_nxt);
switch (nh) {
break;
default:
- UNALIGNED_MEMCPY(&ph.ph_dst, ip6->ip6_dst,
- sizeof (struct in6_addr));
+ GET_CPY_BYTES(&ph.ph_dst, ip6->ip6_dst, sizeof(nd_ipv6));
break;
}
ph.ph_len = htonl(len);
if (cp == (const u_char *)(ip6 + 1) &&
nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
- ND_PRINT("%s > %s: ", ip6addr_string(ndo, ip6->ip6_src),
- ip6addr_string(ndo, ip6->ip6_dst));
+ ND_PRINT("%s > %s: ", GET_IP6ADDR_STRING(ip6->ip6_src),
+ GET_IP6ADDR_STRING(ip6->ip6_dst));
}
switch (nh) {
* XXX - we don't use "advance"; RFC 3775 says that
* the next header field in a mobility header
* should be IPPROTO_NONE, but speaks of
- * the possiblity of a future extension in
+ * the possibility of a future extension in
* which payload can be piggybacked atop a
* mobility header.
*/
* Set the length to the payload length
* plus the IPv6 header length, and
* change the snapshot length accordingly.
+ *
+ * But make sure it's not shorter than
+ * the total number of bytes we've
+ * processed so far.
*/
len = payload_len + sizeof(struct ip6_hdr);
+ if (len < total_advance)
+ goto trunc;
if (length < len)
ND_PRINT("truncated-ip6 - %u bytes missing!",
len - length);
len -= total_advance;
}
}
- ip_print_demux(ndo, cp, len, 6, fragmented,
- GET_U_1(ip6->ip6_hlim), nh, bp);
+ ip_demux_print(ndo, cp, len, 6, fragmented,
+ GET_U_1(ip6->ip6_hlim), nh, bp);
nd_pop_packet_info(ndo);
return;
}