• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(in_addr_t addr);
24 in_addr_t selectIpv4Address(const in_addr ip, int16_t prefixlen);
25 void makeChecksumNeutral(in6_addr* v6, const in_addr v4, const in6_addr& nat64Prefix);
26 int generateIpv6Address(const char* iface, const in_addr v4, const in6_addr& nat64Prefix,
27                         in6_addr* v6);
28 int detect_mtu(const struct in6_addr* plat_subnet, uint32_t plat_suffix, uint32_t mark);
29 int configure_packet_socket(int sock, in6_addr* addr, int ifindex);
30 
31 // For testing
32 typedef bool (*isIpv4AddrFreeFn)(in_addr_t);
33 in_addr_t selectIpv4AddressInternal(const in_addr ip, int16_t prefixlen, isIpv4AddrFreeFn fn);
34 
35 }  // namespace clat
36 }  // namespace net
37 }  // namespace android
38