]> git.saurik.com Git - apple/libresolv.git/blob - res_private.h
libresolv-65.200.2.tar.gz
[apple/libresolv.git] / res_private.h
1 #ifndef res_9_private_h
2 #define res_9_private_h
3 #include <arpa/inet.h>
4 #include <sys/time.h>
5 #include <stdint.h>
6
7 #pragma GCC visibility push(hidden)
8
9 /*
10 * status codes from dns_res_xxx SPIs
11 * positive numbers are ns_rcode values.
12 */
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
23
24 #define RES_EXT_SUFFIX_LEN 64
25
26 typedef struct {
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 */
39 #endif
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 */
51 #endif
52 /* remaining bytes */
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 */
57 } HEADER;
58
59 #ifndef __res_state_ext
60 #define __res_state_ext __res_9_res_state_ext
61 #endif
62
63 struct __res_state_ext {
64 union res_sockaddr_union nsaddrs[MAXNS];
65 struct sort_list {
66 int af;
67 union {
68 struct in_addr ina;
69 struct in6_addr in6a;
70 } addr, mask;
71 } sort_list[MAXRESOLVSORT];
72 char nsuffix[64];
73 char bsuffix[64];
74 char nsuffix2[64];
75 };
76
77 #define get_nsaddr res_9_get_nsaddr
78 struct sockaddr *get_nsaddr __P((res_state, size_t));
79
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 *);
82
83 #define res_ourserver_p res_9_ourserver_p
84 int res_ourserver_p(const res_state, const struct sockaddr *);
85
86 res_state res_state_new();
87 void res_client_close(res_state res);
88
89 /*
90 * From lookupd Thread.h. We use this to signal threads to quit, since pthread_cancel() doesn't work.
91 */
92 #define ThreadStateExitRequested 4
93
94 /*
95 * notification SPI
96 */
97 extern uint32_t notify_register_plain(const char *name, int *out_token);
98
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);
100
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);
102
103 /*
104 * Interrupt a thread blocked in select()
105 */
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);
111
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);
115
116 #pragma GCC visibility pop
117
118 #endif