1 // Copyright (C) 2022 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 #include <netinet/in.h> 17 #include <netinet/in6.h> 18 19 namespace android { 20 namespace net { 21 namespace clat { 22 23 bool isIpv4AddressFree(const in_addr_t addr); 24 in_addr_t selectIpv4Address(const in_addr ip, const int16_t prefixlen); 25 void makeChecksumNeutral(in6_addr* const v6, const in_addr v4, const in6_addr& nat64Prefix); 26 int generateIpv6Address(const char* const iface, const in_addr v4, const in6_addr& nat64Prefix, 27 in6_addr* const v6, const uint32_t mark); 28 int detect_mtu(const struct in6_addr* const plat_subnet, const uint32_t plat_suffix, 29 const uint32_t mark); 30 int configure_packet_socket(const int sock, const in6_addr* const addr, const int ifindex); 31 32 // For testing 33 typedef bool (*isIpv4AddrFreeFn)(const in_addr_t); 34 in_addr_t selectIpv4AddressInternal(const in_addr ip, const int16_t prefixlen, 35 const isIpv4AddrFreeFn fn); 36 37 } // namespace clat 38 } // namespace net 39 } // namespace android 40