]> git.saurik.com Git - apple/libresolv.git/blob - res_private.h
libresolv-19.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 /*
8 * status codes from dns_res_xxx SPIs
9 * positive numbers are ns_rcode values.
10 */
11 #define DNS_RES_STATUS_TIMEOUT -1001
12 #define DNS_RES_STATUS_CANCELLED -1002
13 #define DNS_RES_STATUS_INVALID_QUERY -1003
14 #define DNS_RES_STATUS_INVALID_ARGUMENT -1004
15 #define DNS_RES_STATUS_INVALID_RES_STATE -1005
16 #define DNS_RES_STATUS_INVALID_REPLY -1006
17 #define DNS_RES_STATUS_CONNECTION_REFUSED -1007
18 #define DNS_RES_STATUS_SEND_FAILED -1008
19 #define DNS_RES_STATUS_CONNECTION_FAILED -1009
20 #define DNS_RES_STATUS_SYSTEM_ERROR -1010
21
22 #define RES_EXT_SUFFIX_LEN 64
23
24 typedef struct {
25 unsigned id :16; /* query identification number */
26 #if BYTE_ORDER == BIG_ENDIAN
27 /* fields in third byte */
28 unsigned qr: 1; /* response flag */
29 unsigned opcode: 4; /* purpose of message */
30 unsigned aa: 1; /* authoritive answer */
31 unsigned tc: 1; /* truncated message */
32 unsigned rd: 1; /* recursion desired */
33 /* fields in fourth byte */
34 unsigned ra: 1; /* recursion available */
35 unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
36 unsigned rcode :4; /* response code */
37 #endif
38 #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
39 /* fields in third byte */
40 unsigned rd :1; /* recursion desired */
41 unsigned tc :1; /* truncated message */
42 unsigned aa :1; /* authoritive answer */
43 unsigned opcode :4; /* purpose of message */
44 unsigned qr :1; /* response flag */
45 /* fields in fourth byte */
46 unsigned rcode :4; /* response code */
47 unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
48 unsigned ra :1; /* recursion available */
49 #endif
50 /* remaining bytes */
51 unsigned qdcount :16; /* number of question entries */
52 unsigned ancount :16; /* number of answer entries */
53 unsigned nscount :16; /* number of authority entries */
54 unsigned arcount :16; /* number of resource entries */
55 } HEADER;
56
57 #ifndef __res_state_ext
58 #define __res_state_ext __res_9_res_state_ext
59 #endif
60
61 struct __res_state_ext {
62 union res_sockaddr_union nsaddrs[MAXNS];
63 struct sort_list {
64 int af;
65 union {
66 struct in_addr ina;
67 struct in6_addr in6a;
68 } addr, mask;
69 } sort_list[MAXRESOLVSORT];
70 char nsuffix[64];
71 char bsuffix[64];
72 char nsuffix2[64];
73 };
74
75 #define get_nsaddr res_9_get_nsaddr
76 struct sockaddr *get_nsaddr __P((res_state, size_t));
77
78 #define res_nsend_2 res_9_nsend_2
79 int res_nsend_2(res_state, const u_char *, int, u_char *, int, struct sockaddr *, int *);
80
81 #define res_ourserver_p res_9_ourserver_p
82 int res_ourserver_p(const res_state, const struct sockaddr *);
83
84 res_state res_state_new();
85 void res_client_close(res_state res);
86
87 /*
88 * From lookupd Thread.h. We use this to signal threads to quit, since pthread_cancel() doesn't work.
89 */
90 #define ThreadStateExitRequested 4
91
92 /*
93 * notification SPI
94 */
95 extern uint32_t notify_register_plain(const char *name, int *out_token);
96
97 __private_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);
98
99 int dns_res_once(struct sockaddr *server, struct timeval *timeout, int options, const char *name, int class, int type, u_char *res, int *reslen);
100
101 #endif