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