Lines Matching refs:ip6

57 #include <netinet/ip6.h>
153 struct ip6_hdr *ip6;
171 ip6 = mtod(m, struct ip6_hdr *);
172 dst6.sin6_addr = ip6->ip6_dst;
318 * Embed @ia IPv4 address into @ip6 IPv6 address.
322 nat64_embed_ip4(struct in6_addr *ip6, int plen, in_addr_t ia)
328 ip6->s6_addr32[plen / 32] = ia;
338 ip6->s6_addr32[1] &= 0xffffffff << (32 - plen % 32);
340 ip6->s6_addr32[1] |= ia >> (plen % 32);
341 ip6->s6_addr32[2] = ia << (24 - plen % 32);
343 ip6->s6_addr32[1] |= ia << (plen % 32);
344 ip6->s6_addr32[2] = ia >> (24 - plen % 32);
349 ip6->s6_addr32[2] = ia >> 8;
350 ip6->s6_addr32[3] = ia << 24;
352 ip6->s6_addr32[2] = ia << 8;
353 ip6->s6_addr32[3] = ia >> 24;
364 ip6->s6_addr8[8] = 0;
368 nat64_extract_ip4(const struct in6_addr *ip6, int plen)
381 if (ip6->s6_addr32[3] != 0 || ip6->s6_addr32[2] != 0)
385 if (ip6->s6_addr32[3] != 0 ||
386 (ip6->s6_addr32[2] & htonl(0xff00ffff)) != 0)
390 if (ip6->s6_addr32[3] != 0 ||
391 (ip6->s6_addr32[2] & htonl(0xff0000ff)) != 0)
395 if (ip6->s6_addr32[3] != 0 || ip6->s6_addr8[8] != 0)
399 if (ip6->s6_addr8[8] != 0 ||
400 (ip6->s6_addr32[3] & htonl(0x00ffffff)) != 0)
406 ia = ip6->s6_addr32[plen / 32];
412 ia = (ip6->s6_addr32[1] << (plen % 32)) |
413 (ip6->s6_addr32[2] >> (24 - plen % 32));
415 ia = (ip6->s6_addr32[1] >> (plen % 32)) |
416 (ip6->s6_addr32[2] << (24 - plen % 32));
421 ia = (ip6->s6_addr32[2] << 8) | (ip6->s6_addr32[3] >> 24);
423 ia = (ip6->s6_addr32[2] >> 8) | (ip6->s6_addr32[3] << 24);
459 nat64_cksum_convert(struct ip6_hdr *ip6, struct ip *ip)
469 for (p = (uint16_t *)&ip6->ip6_src;
470 p < (uint16_t *)(&ip6->ip6_src + 2); p++)
479 nat64_init_ip4hdr(const struct ip6_hdr *ip6, const struct ip6_frag *frag,
486 ip->ip_tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
488 ip->ip_ttl = ip6->ip6_hlim;
507 nat64_fragment6(struct nat64_counters *stats, struct ip6_hdr *ip6,
516 plen = ntohs(ip6->ip6_plen);
526 bcopy(ip6, mtod(m, void *), hlen);
538 ip6f.ip6f_nxt = ip6->ip6_nxt;
539 ip6->ip6_nxt = IPPROTO_FRAGMENT;
558 ip6->ip6_plen = htons(len + sizeof(ip6f));
572 bcopy(ip6, mtod(m, void *), sizeof(struct ip6_hdr));
624 struct ip6_hdr *ip6, *oip6;
651 if (icmp6_ratelimit(&ip6->ip6_src, type, code))
654 ip6 = mtod(m, struct ip6_hdr *);
690 oip6->ip6_src = ip6->ip6_dst;
691 oip6->ip6_dst = ip6->ip6_src;
821 nat64_icmp_handle_echo(struct ip6_hdr *ip6, struct icmp6_hdr *icmp6,
839 icmp6->icmp6_cksum = ~in6_cksum_pseudo(ip6, ntohs(ip6->ip6_plen),
844 nat64_icmp_translate(struct mbuf *m, struct ip6_hdr *ip6, uint16_t icmpid,
973 nat64_icmp_handle_echo(ip6, ICMP6(icmp), icmpid, type);
1017 if (ip.ip_src.s_addr != nat64_get_ip4(&ip6->ip6_dst)) {
1020 nat64_get_ip4(&ip6->ip6_dst));
1044 ip6->ip6_plen = htons(plen);
1047 eip6->ip6_src = ip6->ip6_dst;
1050 eip6->ip6_dst = ip6->ip6_src;
1117 ~in6_cksum_pseudo(ip6, plen, IPPROTO_ICMPV6, 0),
1129 struct ip6_hdr *ip6;
1138 if (m->m_len < hlen + sizeof(*ip6))
1141 ip6 = mtodo(m, hlen);
1142 hlen += sizeof(*ip6);
1143 proto = ip6->ip6_nxt;
1158 if (proto == IPPROTO_HOPOPTS && ip6->ip6_plen == 0)
1174 struct ip6_hdr ip6;
1191 ip6.ip6_dst = *daddr;
1192 ip6.ip6_src = *saddr;
1215 dst.sin6_addr = ip6.ip6_dst;
1222 if (nh.nh_mtu < plen + sizeof(ip6) &&
1229 ip6.ip6_flow = htonl(ip->ip_tos << 20);
1230 ip6.ip6_vfc |= IPV6_VERSION;
1231 ip6.ip6_hlim = ip->ip_ttl;
1234 ip6.ip6_hlim -= IPTTLDEC;
1235 ip6.ip6_plen = htons(plen);
1236 ip6.ip6_nxt = (proto == IPPROTO_ICMP) ? IPPROTO_ICMPV6: proto;
1252 *csum = cksum_add(*csum, ~nat64_cksum_convert(&ip6, ip));
1261 *csum = cksum_add(*csum, ~nat64_cksum_convert(&ip6, ip));
1264 m = nat64_icmp_translate(m, &ip6, lport, hlen, cfg);
1271 nat64_fragment6(&cfg->stats, &ip6, &mq, m, nh.nh_mtu, ip_id, ip_off);
1289 struct ip6_hdr *ip6, *ip6i;
1295 ip6 = mtod(m, struct ip6_hdr *);
1296 if (nat64_check_ip6(&ip6->ip6_src) != 0 ||
1297 nat64_check_ip6(&ip6->ip6_dst) != 0)
1445 ip6 = mtod(m, struct ip6_hdr *);
1474 if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &ip6i->ip6_src)) {
1511 struct ip6_hdr *ip6;
1521 ip6 = mtod(m, struct ip6_hdr *);
1522 if (nat64_check_ip6(&ip6->ip6_src) != 0 ||
1523 nat64_check_ip6(&ip6->ip6_dst) != 0) {
1536 ip.ip_dst.s_addr = nat64_extract_ip4(&ip6->ip6_dst, cfg->plat_plen);
1542 if (ip6->ip6_hlim <= IPV6_HLIMDEC) {
1549 plen = ntohs(ip6->ip6_plen);
1612 nat64_init_ip4hdr(ip6, frag, plen, proto, &ip);
1628 *csum = cksum_add(*csum, nat64_cksum_convert(ip6, &ip));
1637 *csum = cksum_add(*csum, nat64_cksum_convert(ip6, &ip));
1642 *csum = cksum_add(*csum, in6_cksum_pseudo(ip6, plen,