blob: 9ee954eea74edcb2bff77afb1355ac83b8410c4d [file] [log] [blame]
Viet-Trung Luu96b05c12016-01-11 11:26:36 -08001#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
9extern "C" {
10#endif
11
George Kulakowski17e3b042016-02-18 15:59:50 -080012#define MAXNS 3
13#define MAXDFLSRCH 3
14#define MAXDNSRCH 6
15#define LOCALDOMAINPARTS 2
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080016
George Kulakowski17e3b042016-02-18 15:59:50 -080017#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
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080024
25/* unused; purely for broken apps */
26typedef struct __res_state {
George Kulakowski17e3b042016-02-18 15:59:50 -080027 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;
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080063
George Kulakowski17e3b042016-02-18 15:59:50 -080064#define __RES 19991006
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080065
66#ifndef _PATH_RESCONF
George Kulakowski17e3b042016-02-18 15:59:50 -080067#define _PATH_RESCONF "/etc/resolv.conf"
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080068#endif
69
70struct res_sym {
George Kulakowski17e3b042016-02-18 15:59:50 -080071 int number;
72 char* name;
73 char* humanname;
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080074};
75
George Kulakowski17e3b042016-02-18 15:59:50 -080076#define RES_F_VC 0x00000001
77#define RES_F_CONN 0x00000002
78#define RES_F_EDNS0ERR 0x00000004
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080079
George Kulakowski17e3b042016-02-18 15:59:50 -080080#define RES_EXHAUSTIVE 0x00000001
Viet-Trung Luu96b05c12016-01-11 11:26:36 -080081
George Kulakowski17e3b042016-02-18 15:59:50 -080082#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
Viet-Trung Luu96b05c12016-01-11 11:26:36 -0800106
George Kulakowski17e3b042016-02-18 15:59:50 -0800107#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH | RES_NOIP6DOTINT)
Viet-Trung Luu96b05c12016-01-11 11:26:36 -0800108
George Kulakowski17e3b042016-02-18 15:59:50 -0800109#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
Viet-Trung Luu96b05c12016-01-11 11:26:36 -0800124
George Kulakowski17e3b042016-02-18 15:59:50 -0800125struct __res_state* __res_state(void);
Viet-Trung Luu96b05c12016-01-11 11:26:36 -0800126#define _res (*__res_state())
127
128int res_init(void);
George Kulakowski17e3b042016-02-18 15:59:50 -0800129int res_query(const char*, int, int, unsigned char*, int);
130int res_querydomain(const char*, const char*, int, int, unsigned char*, int);
131int res_search(const char*, int, int, unsigned char*, int);
132int res_mkquery(int,
133 const char*,
134 int,
135 int,
136 const unsigned char*,
137 int,
138 const unsigned char*,
139 unsigned char*,
140 int);
141int res_send(const unsigned char*, int, unsigned char*, int);
142int dn_comp(const char*, unsigned char*, int, unsigned char**, unsigned char**);
143int dn_expand(const unsigned char*,
144 const unsigned char*,
145 const unsigned char*,
146 char*,
147 int);
148int dn_skipname(const unsigned char*, const unsigned char*);
Viet-Trung Luu96b05c12016-01-11 11:26:36 -0800149
150#ifdef __cplusplus
151}
152#endif
153
154#endif