3 #ifndef ADNS_H_INCLUDED
4 #define ADNS_H_INCLUDED
6 typedef struct adns__state adns_state
;
7 typedef struct adns__query adns_query
;
10 adns_if_noenv
= 0x0001, /* do not look at environment */
11 adns_if_noerrprint
= 0x0002, /* never print output to stderr */
12 adns_if_debug
= 0x0004, /* print debugging output to stderr */
16 adns_f_search
= 0x0001, /* use the searchlist */
17 adns_f_usevc
= 0x0002, /* use a virtual circuit (TCP connection) */
21 adns_rrttype_mask
= 0x0fff,
22 adns_qtf_deref
= 0x1000,
23 adns_qtf_mailconv
= 0x2000,
27 adns_r_ns
= adns_r_ns_raw
|adns_qtf_deref
,
30 adns_r_soa
= adns_r_soa_raw
|adns_qtf_mailconv
,
33 adns_r_ptr
= adns_r_ptr_raw
|adns_rf_deref
,
36 adns_r_mx
= adns_r_mx_raw
|adns_qtf_deref
,
39 adns_r_rp
= adns_r_rp_raw
|adns_qtf_mailconv
48 adns_s_max_tempfail
= 99,
54 /* In dereferenced answers, multiple addresses show up as multiple
55 * answers with all the dm pointers being the same. If no
56 * address is available (permanent failure) then INADDR_NONE is
61 char *cname
; /* always NULL if query was for CNAME records */
65 struct in_addr inaddr
[1]; /* a */
66 char (*str
)[1]; /* ns_raw, cname, ptr, ptr_raw, txt */
67 struct { char *dm
; struct in_addr addr
; } dmaddr
; /* ns */
68 struct { char *a
, *b
; } strpair
[1]; /* hinfo, rp, rp_raw */
69 struct { int pref
; char *dm
; struct in_addr addr
; } intdmaddr
[1]; /* mx */
70 struct { int pref
; char *str
; } intstr
[1]; /* mx_raw */
73 unsigned long serial
, refresh
, retry
, expire
, minimum
;
74 } soa
[1]; /* soa, soa_raw */
80 * adns_state and adns_query are actually pointers to malloc'd state;
81 * On submission questions are copied, including the owner domain;
82 * Answers are malloc'd as a single piece of memory.
84 * Must always be non-null pointer;
85 * If *query_io is 0 to start with then any query may be returned;
86 * If *query_io is !0 adns_query then only that query may be returned.
88 * Return values are 0 or an errno value;
89 * Seriously fatal system errors (eg, failure to create sockets,
90 * malloc failure, etc.) return errno values;
91 * Other errors (nameserver failure, timed out connections, &c)
92 * are returned in the status field of the answer. If status is
93 * nonzero then nrrs will be 0, otherwise it will be >0.
94 * type will always be the type requested;
95 * If no (appropriate) requests are done adns_query returns EWOULDBLOCK;
96 * If no requests are outstanding adns_query and adns_wait return ESRCH;
97 * If malloc failure occurs during internal allocation or processing
98 * ands_query, _wait and _answer set *answer to 0.
101 int adns_init(adns_state
*newstate_r
);
103 int adns_synchronous(adns_state ads
,
107 struct adns_answer
*answer
);
109 int adns_submit(adns_state ads
,
114 const struct adns_query
*query_r
);
116 int adns_query(adns_state ads
,
117 adns_query
*query_io
,
118 struct adns_answer
*answer
,
121 int adns_wait(adns_state ads
,
122 adns_query
*query_io
,
123 struct adns_answer
*answer
,
126 int adns_cancel(adns_state ads
, adns_query query
);
128 int adns_finish(adns_state
);
130 void adns_event(adns_state
, fd_set
*readfds_mod
,
131 fd_set
*writefds_mod
, fd_set
*exceptfds_mod
,
132 int *maxfd_mod
, struct timeval
*tv_mod
);
133 /* You may call this with *_mod=0 to have a simple callback,
134 or with *fds_mod=*maxfd_mod=0 but tv_mod!=0 if you are
135 not going to sleep, or with all !=0 if you are going to sleep. */
137 /* Example expected/legal calling sequences:
143 * adns_query 3 -> EWOULDBLOCK