123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- #ifndef NETD_RESOLV_PRIVATE_H
- #define NETD_RESOLV_PRIVATE_H
- #include <android-base/logging.h>
- #include <net/if.h>
- #include <resolv.h>
- #include <time.h>
- #include <string>
- #include "netd_resolv/params.h"
- #include "netd_resolv/resolv.h"
- #include "netd_resolv/stats.h"
- #include "resolv_static.h"
- #include "stats.pb.h"
- #ifdef MAXHOSTNAMELEN
- #undef MAXHOSTNAMELEN
- #endif
- #define MAXHOSTNAMELEN 256
- #define MAXDFLSRCH 3
- #define LOCALDOMAINPARTS 2
- #define RES_TIMEOUT 5000
- #define MAXRESOLVSORT 10
- #define RES_MAXNDOTS 15
- #define RES_DFLRETRY 2
- #define RES_MAXTIME 65535
- struct res_state_ext;
- struct __res_state {
- unsigned netid;
- u_long options;
- int nscount;
- struct sockaddr_in nsaddr_list[MAXNS];
- #define nsaddr nsaddr_list[0]
- u_short id;
- char* dnsrch[MAXDNSRCH + 1];
- char defdname[256];
- unsigned ndots : 4;
- unsigned nsort : 4;
- char unused[3];
- struct {
- struct in_addr addr;
- uint32_t mask;
- } sort_list[MAXRESOLVSORT];
- unsigned _mark;
- int _vcsock;
- u_int _flags;
- u_int _pad;
- union {
-
- char pad[72 - 4 * sizeof(int) - 2 * sizeof(void*)];
- struct {
- uint16_t nscount;
- uint16_t nstimes[MAXNS];
- int nssocks[MAXNS];
- struct res_state_ext* ext;
- } _ext;
- } _u;
- struct res_static rstatic[1];
- bool use_local_nameserver;
- android::net::NetworkDnsEventReported* event;
- };
- typedef struct __res_state* res_state;
- int resolv_cache_get_resolver_stats(unsigned netid, res_params* params, res_stats stats[MAXNS]);
- void _resolv_cache_add_resolver_stats_sample(unsigned netid, int revision_id, int ns,
- const res_sample* sample, int max_samples);
- int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0);
- void _res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt);
- #define RES_F_VC 0x00000001
- #define RES_F_EDNS0ERR 0x00000004
- #define RES_INIT 0x00000001
- #define RES_DEBUG 0x00000002
- #define RES_AAONLY 0x00000004
- #define RES_USEVC 0x00000008
- #define RES_PRIMARY 0x00000010
- #define RES_IGNTC 0x00000020
- #define RES_RECURSE 0x00000040
- #define RES_DEFNAMES 0x00000080
- #define RES_STAYOPEN 0x00000100
- #define RES_DNSRCH 0x00000200
- #define RES_INSECURE1 0x00000400
- #define RES_INSECURE2 0x00000800
- #define RES_USE_INET6 0x00002000
- #define RES_ROTATE 0x00004000
- #define RES_NOCHECKNAME 0x00008000
- #define RES_KEEPTSIG 0x00010000
- #define RES_BLAST 0x00020000
- #define RES_NOTLDQUERY 0x00100000
- #define RES_USE_DNSSEC 0x00200000
-
- #define RES_USE_DNAME 0x10000000
- #define RES_USE_EDNS0 0x40000000
- #define RES_NO_NIBBLE2 0x80000000
- #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH | RES_NO_NIBBLE2)
- #define NETD_RESOLV_H_ERRNO_EXT_TIMEOUT RCODE_TIMEOUT
- extern const char* const _res_opcodes[];
- struct __res_state* res_get_state(void);
- int res_hnok(const char*);
- int res_ownok(const char*);
- int res_mailok(const char*);
- int res_dnok(const char*);
- int dn_skipname(const u_char*, const u_char*);
- void putlong(uint32_t, u_char*);
- void putshort(uint16_t, u_char*);
- const char* p_class(int);
- const char* p_type(int);
- const char* p_rcode(int);
- const char* p_section(int, int);
- int res_nameinquery(const char*, int, int, const u_char*, const u_char*);
- int res_queriesmatch(const u_char*, const u_char*, const u_char*, const u_char*);
- int res_ninit(res_state);
- void res_pquery(const u_char*, int);
- int res_nquery(res_state, const char*, int, int, u_char*, int, int*);
- int res_nsearch(res_state, const char*, int, int, u_char*, int, int*);
- int res_nquerydomain(res_state, const char*, const char*, int, int, u_char*, int, int*);
- int res_nmkquery(res_state, int, const char*, int, int, const u_char*, int, const u_char*, u_char*,
- int);
- int res_nsend(res_state, const u_char*, int, u_char*, int, int*, uint32_t);
- void res_nclose(res_state);
- int res_nopt(res_state, int, u_char*, int, int);
- int res_vinit(res_state, int);
- void res_ndestroy(res_state);
- void res_setservers(res_state, const sockaddr_union*, int);
- int res_getservers(res_state, sockaddr_union*, int);
- struct android_net_context;
- void res_setnetcontext(res_state, const struct android_net_context*,
- android::net::NetworkDnsEventReported* event);
- int getaddrinfo_numeric(const char* hostname, const char* servname, addrinfo hints,
- addrinfo** result);
- int herrnoToAiErrno(int herrno);
- android::base::LogSeverity logSeverityStrToEnum(const std::string& logSeverityStr);
- template <typename Dest>
- Dest saturate_cast(int64_t x) {
- using DestLimits = std::numeric_limits<Dest>;
- if (x > DestLimits::max()) return DestLimits::max();
- if (x < DestLimits::min()) return DestLimits::min();
- return static_cast<Dest>(x);
- }
- android::net::NsType getQueryType(const uint8_t* msg, size_t msgLen);
- android::net::IpVersion ipFamilyToIPVersion(int ipFamily);
- #endif
|