1 #ifndef _RESOLV_H 2 #define _RESOLV_H 3 4 #include <stdint.h> 5 #include <arpa/nameser.h> 6 #include <netinet/in.h> 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #define MAXNS 3 13 #define MAXDFLSRCH 3 14 #define MAXDNSRCH 6 15 #define LOCALDOMAINPARTS 2 16 17 #define RES_TIMEOUT 5 18 #define MAXRESOLVSORT 10 19 #define RES_MAXNDOTS 15 20 #define RES_MAXRETRANS 30 21 #define RES_MAXRETRY 5 22 #define RES_DFLRETRY 2 23 #define RES_MAXTIME 65535 24 25 /* unused; purely for broken apps */ 26 typedef struct __res_state { 27 int retrans; 28 int retry; 29 unsigned long options; 30 int nscount; 31 struct sockaddr_in nsaddr_list[MAXNS]; 32 # define nsaddr nsaddr_list[0] 33 unsigned short id; 34 char *dnsrch[MAXDNSRCH+1]; 35 char defdname[256]; 36 unsigned long pfcode; 37 unsigned ndots:4; 38 unsigned nsort:4; 39 unsigned ipv6_unavail:1; 40 unsigned unused:23; 41 struct { 42 struct in_addr addr; 43 uint32_t mask; 44 } sort_list[MAXRESOLVSORT]; 45 void *qhook; 46 void *rhook; 47 int res_h_errno; 48 int _vcsock; 49 unsigned _flags; 50 union { 51 char pad[52]; 52 struct { 53 uint16_t nscount; 54 uint16_t nsmap[MAXNS]; 55 int nssocks[MAXNS]; 56 uint16_t nscount6; 57 uint16_t nsinit; 58 struct sockaddr_in6 *nsaddrs[MAXNS]; 59 unsigned int _initstamp[2]; 60 } _ext; 61 } _u; 62 } *res_state; 63 64 #define __RES 19960801 65 66 #ifndef _PATH_RESCONF 67 #define _PATH_RESCONF "/etc/resolv.conf" 68 #endif 69 70 struct res_sym { 71 int number; 72 char *name; 73 char *humanname; 74 }; 75 76 #define RES_F_VC 0x00000001 77 #define RES_F_CONN 0x00000002 78 #define RES_F_EDNS0ERR 0x00000004 79 80 #define RES_EXHAUSTIVE 0x00000001 81 82 #define RES_INIT 0x00000001 83 #define RES_DEBUG 0x00000002 84 #define RES_AAONLY 0x00000004 85 #define RES_USEVC 0x00000008 86 #define RES_PRIMARY 0x00000010 87 #define RES_IGNTC 0x00000020 88 #define RES_RECURSE 0x00000040 89 #define RES_DEFNAMES 0x00000080 90 #define RES_STAYOPEN 0x00000100 91 #define RES_DNSRCH 0x00000200 92 #define RES_INSECURE1 0x00000400 93 #define RES_INSECURE2 0x00000800 94 #define RES_NOALIASES 0x00001000 95 #define RES_USE_INET6 0x00002000 96 #define RES_ROTATE 0x00004000 97 #define RES_NOCHECKNAME 0x00008000 98 #define RES_KEEPTSIG 0x00010000 99 #define RES_BLAST 0x00020000 100 #define RES_USEBSTRING 0x00040000 101 #define RES_NOIP6DOTINT 0x00080000 102 #define RES_USE_EDNS0 0x00100000 103 #define RES_SNGLKUP 0x00200000 104 #define RES_SNGLKUPREOP 0x00400000 105 #define RES_USE_DNSSEC 0x00800000 106 107 #define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT) 108 109 #define RES_PRF_STATS 0x00000001 110 #define RES_PRF_UPDATE 0x00000002 111 #define RES_PRF_CLASS 0x00000004 112 #define RES_PRF_CMD 0x00000008 113 #define RES_PRF_QUES 0x00000010 114 #define RES_PRF_ANS 0x00000020 115 #define RES_PRF_AUTH 0x00000040 116 #define RES_PRF_ADD 0x00000080 117 #define RES_PRF_HEAD1 0x00000100 118 #define RES_PRF_HEAD2 0x00000200 119 #define RES_PRF_TTLID 0x00000400 120 #define RES_PRF_HEADX 0x00000800 121 #define RES_PRF_QUERY 0x00001000 122 #define RES_PRF_REPLY 0x00002000 123 #define RES_PRF_INIT 0x00004000 124 125 struct __res_state *__res_state(void); 126 #define _res (*__res_state()) 127 128 int res_init(void); 129 int res_query(const char *, int, int, unsigned char *, int); 130 int res_querydomain(const char *, const char *, int, int, unsigned char *, int); 131 int res_search(const char *, int, int, unsigned char *, int); 132 int res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int); 133 int res_send(const unsigned char *, int, unsigned char *, int); 134 int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **); 135 int dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); 136 int dn_skipname(const unsigned char *, const unsigned char *); 137 138 #ifdef __cplusplus 139 } 140 #endif 141 142 #endif 143