1 #ifndef res_9_private_h
2 #define res_9_private_h
7 #pragma GCC visibility push(hidden)
10 * status codes from dns_res_xxx SPIs
11 * positive numbers are ns_rcode values.
13 #define DNS_RES_STATUS_TIMEOUT -1001
14 #define DNS_RES_STATUS_CANCELLED -1002
15 #define DNS_RES_STATUS_INVALID_QUERY -1003
16 #define DNS_RES_STATUS_INVALID_ARGUMENT -1004
17 #define DNS_RES_STATUS_INVALID_RES_STATE -1005
18 #define DNS_RES_STATUS_INVALID_REPLY -1006
19 #define DNS_RES_STATUS_CONNECTION_REFUSED -1007
20 #define DNS_RES_STATUS_SEND_FAILED -1008
21 #define DNS_RES_STATUS_CONNECTION_FAILED -1009
22 #define DNS_RES_STATUS_SYSTEM_ERROR -1010
24 #define RES_EXT_SUFFIX_LEN 64
27 unsigned id
:16; /* query identification number */
28 #if BYTE_ORDER == BIG_ENDIAN
29 /* fields in third byte */
30 unsigned qr
: 1; /* response flag */
31 unsigned opcode
: 4; /* purpose of message */
32 unsigned aa
: 1; /* authoritive answer */
33 unsigned tc
: 1; /* truncated message */
34 unsigned rd
: 1; /* recursion desired */
35 /* fields in fourth byte */
36 unsigned ra
: 1; /* recursion available */
37 unsigned unused
:3; /* unused bits (MBZ as of 4.9.3a3) */
38 unsigned rcode
:4; /* response code */
40 #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
41 /* fields in third byte */
42 unsigned rd
:1; /* recursion desired */
43 unsigned tc
:1; /* truncated message */
44 unsigned aa
:1; /* authoritive answer */
45 unsigned opcode
:4; /* purpose of message */
46 unsigned qr
:1; /* response flag */
47 /* fields in fourth byte */
48 unsigned rcode
:4; /* response code */
49 unsigned unused
:3; /* unused bits (MBZ as of 4.9.3a3) */
50 unsigned ra
:1; /* recursion available */
53 unsigned qdcount
:16; /* number of question entries */
54 unsigned ancount
:16; /* number of answer entries */
55 unsigned nscount
:16; /* number of authority entries */
56 unsigned arcount
:16; /* number of resource entries */
59 #ifndef __res_state_ext
60 #define __res_state_ext __res_9_res_state_ext
63 struct __res_state_ext
{
64 union res_sockaddr_union nsaddrs
[MAXNS
];
71 } sort_list
[MAXRESOLVSORT
];
77 #define get_nsaddr res_9_get_nsaddr
78 struct sockaddr
*get_nsaddr
__P((res_state
, size_t));
80 #define res_nsend_2 res_9_nsend_2
81 int res_nsend_2(res_state
, const u_char
*, int, u_char
*, int, struct sockaddr
*, int *);
83 #define res_ourserver_p res_9_ourserver_p
84 int res_ourserver_p(const res_state
, const struct sockaddr
*);
86 res_state
res_state_new();
87 void res_client_close(res_state res
);
90 * From lookupd Thread.h. We use this to signal threads to quit, since pthread_cancel() doesn't work.
92 #define ThreadStateExitRequested 4
97 extern uint32_t notify_register_plain(const char *name
, int *out_token
);
99 extern int res_query_mDNSResponder(res_state statp
, const char *name
, int class, int type
, u_char
*answer
, int anslen
, struct sockaddr
*from
, uint32_t *fromlen
);
101 int dns_res_once(struct sockaddr
*server
, struct timeval
*timeout
, int options
, const char *name
, int class, int type
, u_char
*res
, int *reslen
);
104 * Interrupt a thread blocked in select()
106 void res_interrupt_requests_enable(void);
107 void res_interrupt_requests_disable(void);
108 void res_interrupt_request(void *token
);
109 void *res_init_interrupt_token(void);
110 void res_delete_interrupt_token(void *token
);
112 extern void res_client_close(res_state res
);
113 extern int __res_nquery(res_state statp
, const char *name
, int class, int type
, u_char
*answer
, int anslen
);
114 extern int dns_res_send(res_state statp
, const u_char
*buf
, int buflen
, u_char
*ans
, int *anssiz
, struct sockaddr
*from
, int *fromlen
);
116 #pragma GCC visibility pop