simplify
[heimdal.git] / lib / roken / resolve.h
blob91b2afefe7ed0c1d1c731d998f4d2c26f469fc08
1 /*
2 * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
34 /* $Id$ */
36 #ifndef __RESOLVE_H__
37 #define __RESOLVE_H__
39 #ifndef ROKEN_LIB_FUNCTION
40 #ifdef _WIN32
41 #define ROKEN_LIB_FUNCTION _stdcall
42 #else
43 #define ROKEN_LIB_FUNCTION
44 #endif
45 #endif
47 enum {
48 rk_ns_c_in = 1
51 enum {
52 rk_ns_t_invalid = 0, /* Cookie. */
53 rk_ns_t_a = 1, /* Host address. */
54 rk_ns_t_ns = 2, /* Authoritative server. */
55 rk_ns_t_md = 3, /* Mail destination. */
56 rk_ns_t_mf = 4, /* Mail forwarder. */
57 rk_ns_t_cname = 5, /* Canonical name. */
58 rk_ns_t_soa = 6, /* Start of authority zone. */
59 rk_ns_t_mb = 7, /* Mailbox domain name. */
60 rk_ns_t_mg = 8, /* Mail group member. */
61 rk_ns_t_mr = 9, /* Mail rename name. */
62 rk_ns_t_null = 10, /* Null resource record. */
63 rk_ns_t_wks = 11, /* Well known service. */
64 rk_ns_t_ptr = 12, /* Domain name pointer. */
65 rk_ns_t_hinfo = 13, /* Host information. */
66 rk_ns_t_minfo = 14, /* Mailbox information. */
67 rk_ns_t_mx = 15, /* Mail routing information. */
68 rk_ns_t_txt = 16, /* Text strings. */
69 rk_ns_t_rp = 17, /* Responsible person. */
70 rk_ns_t_afsdb = 18, /* AFS cell database. */
71 rk_ns_t_x25 = 19, /* X_25 calling address. */
72 rk_ns_t_isdn = 20, /* ISDN calling address. */
73 rk_ns_t_rt = 21, /* Router. */
74 rk_ns_t_nsap = 22, /* NSAP address. */
75 rk_ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
76 rk_ns_t_sig = 24, /* Security signature. */
77 rk_ns_t_key = 25, /* Security key. */
78 rk_ns_t_px = 26, /* X.400 mail mapping. */
79 rk_ns_t_gpos = 27, /* Geographical position (withdrawn). */
80 rk_ns_t_aaaa = 28, /* Ip6 Address. */
81 rk_ns_t_loc = 29, /* Location Information. */
82 rk_ns_t_nxt = 30, /* Next domain (security). */
83 rk_ns_t_eid = 31, /* Endpoint identifier. */
84 rk_ns_t_nimloc = 32, /* Nimrod Locator. */
85 rk_ns_t_srv = 33, /* Server Selection. */
86 rk_ns_t_atma = 34, /* ATM Address */
87 rk_ns_t_naptr = 35, /* Naming Authority PoinTeR */
88 rk_ns_t_kx = 36, /* Key Exchange */
89 rk_ns_t_cert = 37, /* Certification record */
90 rk_ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
91 rk_ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
92 rk_ns_t_sink = 40, /* Kitchen sink (experimentatl) */
93 rk_ns_t_opt = 41, /* EDNS0 option (meta-RR) */
94 rk_ns_t_apl = 42, /* Address prefix list (RFC 3123) */
95 rk_ns_t_ds = 43, /* Delegation Signer (RFC 3658) */
96 rk_ns_t_sshfp = 44, /* SSH fingerprint */
97 rk_ns_t_tkey = 249, /* Transaction key */
98 rk_ns_t_tsig = 250, /* Transaction signature. */
99 rk_ns_t_ixfr = 251, /* Incremental zone transfer. */
100 rk_ns_t_axfr = 252, /* Transfer zone of authority. */
101 rk_ns_t_mailb = 253, /* Transfer mailbox records. */
102 rk_ns_t_maila = 254, /* Transfer mail agent records. */
103 rk_ns_t_any = 255, /* Wildcard match. */
104 rk_ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
105 rk_ns_t_max = 65536
108 #ifndef MAXDNAME
109 #define MAXDNAME 1025
110 #endif
112 #define mx_record rk_mx_record
113 #define srv_record rk_srv_record
114 #define key_record rk_key_record
115 #define sig_record rk_sig_record
116 #define cert_record rk_cert_record
117 #define sshfp_record rk_sshfp_record
119 struct rk_dns_query{
120 char *domain;
121 unsigned type;
122 unsigned class;
125 struct rk_mx_record{
126 unsigned preference;
127 char domain[1];
130 struct rk_srv_record{
131 unsigned priority;
132 unsigned weight;
133 unsigned port;
134 char target[1];
137 struct rk_key_record {
138 unsigned flags;
139 unsigned protocol;
140 unsigned algorithm;
141 size_t key_len;
142 u_char key_data[1];
145 struct rk_sig_record {
146 unsigned type;
147 unsigned algorithm;
148 unsigned labels;
149 unsigned orig_ttl;
150 unsigned sig_expiration;
151 unsigned sig_inception;
152 unsigned key_tag;
153 char *signer;
154 unsigned sig_len;
155 char sig_data[1]; /* also includes signer */
158 struct rk_cert_record {
159 unsigned type;
160 unsigned tag;
161 unsigned algorithm;
162 size_t cert_len;
163 u_char cert_data[1];
166 struct rk_sshfp_record {
167 unsigned algorithm;
168 unsigned type;
169 size_t sshfp_len;
170 u_char sshfp_data[1];
173 struct rk_ds_record {
174 unsigned key_tag;
175 unsigned algorithm;
176 unsigned digest_type;
177 unsigned digest_len;
178 u_char digest_data[1];
181 struct rk_resource_record{
182 char *domain;
183 unsigned type;
184 unsigned class;
185 unsigned ttl;
186 unsigned size;
187 union {
188 void *data;
189 struct rk_mx_record *mx;
190 struct rk_mx_record *afsdb; /* mx and afsdb are identical */
191 struct rk_srv_record *srv;
192 struct in_addr *a;
193 char *txt;
194 struct rk_key_record *key;
195 struct rk_cert_record *cert;
196 struct rk_sig_record *sig;
197 struct rk_sshfp_record *sshfp;
198 struct rk_ds_record *ds;
200 struct rk_resource_record *next;
203 #define rk_DNS_MAX_PACKET_SIZE 0xffff
205 struct rk_dns_header {
206 unsigned id;
207 unsigned flags;
208 #define rk_DNS_HEADER_RESPONSE_FLAG 1
209 #define rk_DNS_HEADER_AUTHORITIVE_ANSWER 2
210 #define rk_DNS_HEADER_TRUNCATED_MESSAGE 4
211 #define rk_DNS_HEADER_RECURSION_DESIRED 8
212 #define rk_DNS_HEADER_RECURSION_AVAILABLE 16
213 #define rk_DNS_HEADER_AUTHENTIC_DATA 32
214 #define rk_DNS_HEADER_CHECKING_DISABLED 64
215 unsigned opcode;
216 unsigned response_code;
217 unsigned qdcount;
218 unsigned ancount;
219 unsigned nscount;
220 unsigned arcount;
223 struct rk_dns_reply{
224 struct rk_dns_header h;
225 struct rk_dns_query q;
226 struct rk_resource_record *head;
230 #ifdef __cplusplus
231 extern "C" {
232 #endif
234 struct rk_dns_reply* ROKEN_LIB_FUNCTION
235 rk_dns_lookup(const char *, const char *);
236 void ROKEN_LIB_FUNCTION
237 rk_dns_free_data(struct rk_dns_reply *);
238 int ROKEN_LIB_FUNCTION
239 rk_dns_string_to_type(const char *name);
240 const char *ROKEN_LIB_FUNCTION
241 rk_dns_type_to_string(int type);
242 void ROKEN_LIB_FUNCTION
243 rk_dns_srv_order(struct rk_dns_reply*);
245 #ifdef __cplusplus
247 #endif
249 #endif /* __RESOLVE_H__ */