1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _RESOLVER_CONTROLLER_H_ 18 #define _RESOLVER_CONTROLLER_H_ 19 20 #include <list> 21 #include <set> 22 #include <vector> 23 24 #include <aidl/android/net/ResolverParamsParcel.h> 25 #include "Dns64Configuration.h" 26 #include "netd_resolv/resolv.h" 27 #include "netdutils/DumpWriter.h" 28 29 struct res_params; 30 31 namespace android { 32 namespace net { 33 34 class ResolverController { 35 public: 36 ResolverController(); 37 ~ResolverController() = default; 38 39 void destroyNetworkCache(unsigned netid); 40 int createNetworkCache(unsigned netid); 41 int flushNetworkCache(unsigned netid); 42 43 // Binder specific functions, which convert between the ResolverParamsParcel and the 44 // actual data structures. 45 int setResolverConfiguration(const aidl::android::net::ResolverParamsParcel& resolverParams); 46 47 int getResolverInfo(int32_t netId, std::vector<std::string>* servers, 48 std::vector<std::string>* domains, std::vector<std::string>* tlsServers, 49 std::vector<int32_t>* params, std::vector<int32_t>* stats, 50 std::vector<int32_t>* wait_for_pending_req_timeout_count); 51 52 // Start or stop NAT64 prefix discovery. 53 void startPrefix64Discovery(int32_t netId); 54 void stopPrefix64Discovery(int32_t netId); 55 56 // Set or clear a NAT64 prefix discovered by other sources (e.g., RA). setPrefix64(unsigned netId,const netdutils::IPPrefix & prefix)57 int setPrefix64(unsigned netId, const netdutils::IPPrefix& prefix) { 58 return mDns64Configuration.setPrefix64(netId, prefix); 59 } 60 clearPrefix64(unsigned netId)61 int clearPrefix64(unsigned netId) { return mDns64Configuration.clearPrefix64(netId); } 62 63 // Return the current NAT64 prefix network, regardless of how it was discovered. 64 int getPrefix64(unsigned netId, netdutils::IPPrefix* prefix); 65 66 void dump(netdutils::DumpWriter& dw, unsigned netId); 67 68 private: 69 Dns64Configuration mDns64Configuration; 70 }; 71 } // namespace net 72 } // namespace android 73 74 #endif /* _RESOLVER_CONTROLLER_H_ */ 75