1 #ifndef RESOLV_FUZZER_UTILS_H_ 2 #define RESOLV_FUZZER_UTILS_H_ 3 4 #include <arpa/inet.h> // for inet_pton 5 #include <fuzzer/FuzzedDataProvider.h> 6 7 #include "DnsResolver.h" 8 #include "Experiments.h" // for update property 9 #include "ResolverController.h" 10 #include "dns_responder/dns_responder_client_ndk.h" 11 #include "dns_responder/dns_tls_frontend.h" 12 #include "doh.h" // for DOH_LOG_LEVEL_DEBUG 13 #include "doh_frontend.h" 14 #include "getaddrinfo.h" 15 #include "gethnamaddr.h" 16 #include "res_debug.h" // for resolv_set_log_severity 17 #include "resolv_cache.h" 18 #include "resolv_test_utils.h" 19 20 namespace android::net { 21 22 // TODO: Consider moving to packages/modules/DnsResolver/tests/resolv_test_utils.h. 23 constexpr int MAXPACKET = 8 * 1024; 24 25 // Tests A/AAAA/CNAME type and CNAME chain. 26 const std::vector<DnsRecord> records = { 27 {kHelloExampleCom, ns_type::ns_t_a, kHelloExampleComAddrV4}, 28 {kHelloExampleCom, ns_type::ns_t_aaaa, kHelloExampleComAddrV6}, 29 {kCnameA, ns_type::ns_t_cname, kCnameB}, 30 {kCnameB, ns_type::ns_t_a, kHelloExampleComAddrV4}, 31 {kCnameC, ns_type::ns_t_cname, kCnameD}, 32 }; 33 34 const android_net_context mNetContext = { 35 .app_netid = TEST_NETID, 36 .app_mark = MARK_UNSET, 37 .dns_netid = TEST_NETID, 38 .dns_mark = MARK_UNSET, 39 .uid = TEST_UID, 40 }; 41 42 extern test::DnsTlsFrontend dot; 43 extern ResolverController resolverCtrl; 44 45 void StartDns(test::DNSResponder& dns, const std::vector<DnsRecord>& records); 46 int RandomSocketType(FuzzedDataProvider& fdp); 47 void InitDnsResolverCallbacks(); 48 void InitServers(); 49 void CleanServers(); 50 bool DoInit(); 51 void CleanUp(); 52 53 } // namespace android::net 54 55 #endif // RESOLV_FUZZER_UTILS_H_ 56