1 #ifndef DNS_RESPONDER_CLIENT_H 2 #define DNS_RESPONDER_CLIENT_H 3 4 #include <cutils/sockets.h> 5 6 #include <private/android_filesystem_config.h> 7 #include <utils/StrongPointer.h> 8 9 #include "android/net/INetd.h" 10 #include "binder/IServiceManager.h" 11 #include "NetdClient.h" 12 #include "dns_responder.h" 13 #include "resolv_params.h" 14 15 class DnsResponderClient { 16 public: 17 struct Mapping { 18 std::string host; 19 std::string entry; 20 std::string ip4; 21 std::string ip6; 22 }; 23 24 virtual ~DnsResponderClient() = default; 25 26 void SetupMappings(unsigned num_hosts, const std::vector<std::string>& domains, 27 std::vector<Mapping>* mappings); 28 29 bool SetResolversForNetwork(const std::vector<std::string>& servers, 30 const std::vector<std::string>& domains, const std::vector<int>& params); 31 32 bool SetResolversForNetwork(const std::vector<std::string>& searchDomains, 33 const std::vector<std::string>& servers, const std::string& params); 34 35 static void SetupDNSServers(unsigned num_servers, const std::vector<Mapping>& mappings, 36 std::vector<std::unique_ptr<test::DNSResponder>>* dns, 37 std::vector<std::string>* servers); 38 39 static void ShutdownDNSServers(std::vector<std::unique_ptr<test::DNSResponder>>* dns); 40 41 static int SetupOemNetwork(); 42 43 static void TearDownOemNetwork(int oemNetId); 44 45 virtual void SetUp(); 46 47 virtual void TearDown(); 48 49 public: 50 android::sp<android::net::INetd> mNetdSrv = nullptr; 51 int mOemNetId = -1; 52 }; 53 54 #endif // DNS_RESPONDER_CLIENT_H 55