Lines Matching +full:ipv4 +full:- +full:single +full:- +full:target
8 * http://www.apache.org/licenses/LICENSE-2.0
16 * clatd.c - tun interface setup and main event loop
54 // reads IPv6 packet from AF_PACKET socket, translates to IPv4, writes to tun
56 // ethernet header is 14 bytes, plus 4 for a normal VLAN tag or 8 for Q-in-Q in process_packet_6_to_4()
57 // we don't really support vlans (or especially Q-in-Q)... in process_packet_6_to_4()
75 ssize_t readlen = recvmsg(tunnel->read_fd6, &msgh, /*flags*/ 0); in process_packet_6_to_4()
87 logmsg(ANDROID_LOG_WARN, "%s: read truncation - ignoring pkt", __func__); in process_packet_6_to_4()
95 if (cmsg->cmsg_level == SOL_PACKET && cmsg->cmsg_type == PACKET_AUXDATA) { in process_packet_6_to_4()
97 tp_status = aux->tp_status; in process_packet_6_to_4()
98 tp_net = aux->tp_net; in process_packet_6_to_4()
110 const int pkt_len = readlen - payload_offset; in process_packet_6_to_4()
112 // This will detect a skb->ip_summed == CHECKSUM_PARTIAL packet with non-final L4 checksum in process_packet_6_to_4()
120 // These are non-negative by virtue of csum_start/offset being u16 in process_packet_6_to_4()
124 logmsg(ANDROID_LOG_ERROR, "%s: out of range - checksum start %d > %d", in process_packet_6_to_4()
127 logmsg(ANDROID_LOG_ERROR, "%s: out of range - checksum offset %d + 1 >= %d", in process_packet_6_to_4()
130 uint16_t csum = ip_checksum(buf.payload + cs_start, pkt_len - cs_start); in process_packet_6_to_4()
137 translate_packet(tunnel->fd4, 0 /* to_ipv6 */, buf.payload + tp_net, pkt_len - tp_net); in process_packet_6_to_4()
140 // reads TUN_PI + L3 IPv4 packet from tun, translates to IPv6, writes to AF_INET6/RAW socket
147 ssize_t readlen = read(tunnel->fd4, &buf, sizeof(buf)); in process_packet_4_to_6()
159 logmsg(ANDROID_LOG_WARN, "%s: read truncation - ignoring pkt", __func__); in process_packet_4_to_6()
170 const int pkt_len = readlen - payload_offset; in process_packet_4_to_6()
182 translate_packet(tunnel->write_fd6, 1 /* to_ipv6 */, buf.payload, pkt_len); in process_packet_4_to_6()
189 // be32 0x60000000 - ipv6, tclass 0, flowlabel 0
209 .ip6_plen = htons(sizeof(dad_pkt) - sizeof(struct ip6_hdr)), // payload length, ie. 32 in send_dad()
217 0xFF, tgt->s6_addr[13], tgt->s6_addr[14], tgt->s6_addr[15], in send_dad()
218 }, // ff02::1:ffXX:XXXX - multicast group address derived from bottom 24-bits of tgt in send_dad()
229 .ns_opt_nonce = {}, // opt_len *8 - sizeof u8(opt_nr) - sizeof u8(opt_len) = 6 ranodmized bytes in send_dad()
233 // 40 byte IPv6 header + 8 byte ICMPv6 header + 16 byte ipv6 target address + 8 byte nonce option in send_dad()
236 // IPv6 header checksum is standard negated 16-bit one's complement sum over the icmpv6 pseudo in send_dad()
246 // ip6_plen is already in network order, while ip6_nxt is a single byte and thus needs htons(). in send_dad()
248 csum = ip_checksum_add(csum, &dad_pkt.ip6h.ip6_src, sizeof(dad_pkt) - 8); in send_dad()
262 * tunnel - tun device data
266 // this would then result in an ipv6-only network with working native ipv6, working in event_loop()
267 // IPv4 via DNS64, but non-functioning IPv4 via CLAT (ie. IPv4 literals + IPv4 only apps). in event_loop()
270 // case of failure pick a different IP. Seeing as 48-bits of the IP are utterly random in event_loop()
274 send_dad(tunnel->write_fd6, &Global_Clatd_Config.ipv6_local_subnet); in event_loop()
277 { tunnel->read_fd6, POLLIN, 0 }, in event_loop()
278 { tunnel->fd4, POLLIN, 0 }, in event_loop()
282 if (poll(wait_fd, ARRAY_SIZE(wait_fd), -1) == -1) { in event_loop()