1 #ifndef EL__NETWORK_DNS_H
2 #define EL__NETWORK_DNS_H
5 #ifdef HAVE_SYS_SOCKET_H
6 #include <sys/socket.h>
10 DNS_ERROR
= -1, /* DNS lookup failed. */
11 DNS_SUCCESS
= 0, /* DNS lookup was successful. */
12 DNS_ASYNC
= 1, /* An async lookup was started. */
15 typedef void (*dns_callback_T
)(void *, struct sockaddr_storage
*, int);
17 /* Look up the specified @host using synchronious querying. An array of found
18 * addresses will be allocated in @addr with the array length stored in
19 * @addrlen. The boolean @called_from_thread is a hack used internally to get
20 * the correct allocation method. */
21 /* Returns non-zero on error and zero on success. */
23 do_real_lookup(unsigned char *host
, struct sockaddr_storage
**addr
, int *addrlen
,
24 int called_from_thread
);
26 /* Look up the specified @host storing private query information in struct
27 * pointed to by @queryref. When the query is done the @done callback will be
28 * called with @data, an array of found addresses (or NULL on error) and the
29 * address array length. If the boolean @no_cache is non-zero cached DNS queries
31 /* Returns whether the query is asynchronious. */
32 enum dns_result
find_host(unsigned char *name
, void **queryref
,
33 dns_callback_T done
, void *data
, int no_cache
);
35 /* Stop the DNS request pointed to by the @queryref reference. */
36 void kill_dns_request(void **queryref
);
38 /* Manage the cache of DNS lookups. If the boolean @whole is non-zero all DNS
39 * cache entries will be removed. */
40 void shrink_dns_cache(int whole
);