Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / isc-dhcp / includes / minires / minires.h
1 /*
2  * Copyright (c) 2001 by Internet Software Consortium.
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
9  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
10  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
11  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
13  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
15  * SOFTWARE.
16  */
17
18 #include "cdefs.h"
19 #include "osdep.h"
20
21 #define _ns_flagdata MR_ns_flagdata
22
23 #include "minires/resolv.h"
24 #include "minires/res_update.h"
25 #include "isc-dhcp/result.h"
26
27 /*
28  * Based on the Dynamic DNS reference implementation by Viraj Bais
29  * <viraj_bais@ccm.fm.intel.com>
30  */
31
32 int minires_mkupdate (ns_updrec *, unsigned char *, unsigned);
33 int minires_update (ns_updrec *);
34 ns_updrec *minires_mkupdrec (int, const char *, unsigned int,
35                              unsigned int, unsigned long);
36 void minires_freeupdrec (ns_updrec *);
37 int minires_nmkupdate (res_state, ns_updrec *, double *, unsigned *);
38 isc_result_t minires_nupdate (res_state, ns_updrec *);
39 int minires_ninit (res_state);
40 ns_rcode isc_rcode_to_ns (isc_result_t);
41
42 #if defined (MINIRES_LIB)
43 #define res_update minires_update
44 #define res_mkupdate minires_mkupdate
45 #define res_mkupdrec minires_mkupdrec
46 #define res_freeupdrec minires_freeupdrec
47 #define res_nmkupdate minires_nmkupdate
48 #define res_nupdate minires_nupdate
49 #define __p_type_syms MR__p_type_syms
50 #define dn_comp MRdn_comp
51 #define loc_aton MRloc_aton
52 #define sym_ston MRsym_ston
53 #define res_buildservicelist MRres_buildservicelist
54 #define res_destroyservicelist MRres_destroyservicelist
55 #define res_buildprotolist MRres_buildprotolist
56 #define res_destroyprotolist MRres_destroyprotolist
57 #define res_servicenumber MRres_servicenumber
58 #define res_protocolnumber MRres_protocolnumber
59 #define res_protocolname MRres_protocolname
60 #define res_servicename MRres_servicename
61 #define ns_datetosecs MRns_datetosecs
62 #define b64_pton MRb64_pton
63 #define res_ninit minires_ninit
64 #define res_randomid MRres_randomid
65 #define res_findzonecut MRres_findzonecut
66 #define res_nsend MRres_nsend
67 #define res_nsendsigned MRres_nsendsigned
68 #define ns_samename MRns_samename
69 #define res_nameinquery MRres_nameinquery
70 #define res_queriesmatch MRres_queriesmatch
71 #define dn_expand MRdn_expand
72 #define ns_get16 MRns_get16
73 #define res_close MRres_close
74 #define res_nclose MRres_nclose
75 #define res_ourserver_p MRres_ourserver_p
76 #define ns_sign MRns_sign
77 #define p_class MRp_class
78 #define p_section MRp_section
79 #define ns_makecanon MRns_makecanon
80 #define ns_parserr MRns_parserr
81 #define ns_samedomain MRns_samedomain
82 #define ns_name_uncompress MRns_name_uncompress
83 #define res_nmkquery MRres_nmkquery
84 #define ns_initparse MRns_initparse
85 #define res_nquery MRres_nquery
86 #define res_nsearch MRres_nsearch
87 #define res_hostalias MRres_hostalias
88 #define res_nquerydomain MRres_nquerydomain
89 #define ns_skiprr MRns_skiprr
90 #define dn_skipname MRdn_skipname
91 #define ns_name_ntol MRns_name_ntol
92 #define ns_sign_tcp_init MRns_sign_tcp_init
93 #define ns_sign_tcp MRns_sign_tcp
94 #define ns_name_ntop MRns_name_ntop
95 #define ns_name_pton MRns_name_pton
96 #define ns_name_unpack MRns_name_unpack
97 #define ns_name_pack MRns_name_pack
98 #define ns_name_compress MRns_name_compress
99 #define ns_name_skip MRns_name_skip
100 #define ns_subdomain MRns_subdomain
101 #define ns_find_tsig MRns_find_tsig
102 #define ns_verify MRns_verify
103 #define ns_verify_tcp_init MRns_verify_tcp_init
104 #define ns_verify_tcp MRns_verify_tcp
105 #define b64_ntop MRb64_ntop
106
107 extern const struct res_sym __p_type_syms[];
108 extern time_t cur_time;
109
110 int dn_comp (const char *,
111              unsigned char *, unsigned, unsigned char **, unsigned char **);
112 int loc_aton (const char *, u_char *);
113 int sym_ston (const struct res_sym *, const char *, int *);
114 void  res_buildservicelist (void);
115 void res_destroyservicelist (void);
116 void res_buildprotolist(void);
117 void res_destroyprotolist(void);
118 int res_servicenumber(const char *);
119 int res_protocolnumber(const char *);
120 const char *res_protocolname(int);
121 const char *res_servicename(u_int16_t, const char *);
122 u_int32_t ns_datetosecs (const char *cp, int *errp);
123 int b64_pton (char const *, unsigned char *, size_t);
124 unsigned int res_randomid (void);
125 isc_result_t res_findzonecut (res_state, const char *, ns_class, int, char *,
126                               size_t, struct in_addr *, int, int *, void *);
127 isc_result_t res_nsend (res_state,
128                         double *, unsigned, double *, unsigned, unsigned *);
129 isc_result_t res_nsendsigned (res_state, double *, unsigned, ns_tsig_key *,
130                               double *, unsigned, unsigned *);
131 int ns_samename (const char *, const char *);
132 int res_nameinquery (const char *, int, int,
133                      const unsigned char *, const unsigned char *);
134 int res_queriesmatch (const unsigned char *, const unsigned char *,
135                       const unsigned char *, const unsigned char *);
136 int dn_expand (const unsigned char *,
137                const unsigned char *, const unsigned char *, char *, unsigned);
138 unsigned int ns_get16 (const unsigned char *);
139 void res_close (void);
140 void res_nclose (res_state);
141 int res_ourserver_p (const res_state, const struct sockaddr_in *);
142 isc_result_t ns_sign (unsigned char *, unsigned *,
143                       unsigned, int, void *, const unsigned char *,
144                       unsigned, unsigned char *, unsigned *, time_t);
145 const char *p_class (int);
146 const char *p_section (int section, int opcode);
147 isc_result_t ns_makecanon (const char *, char *, size_t);
148 isc_result_t ns_parserr (ns_msg *, ns_sect, int, ns_rr *);
149 int ns_samedomain (const char *, const char *);
150 int ns_name_uncompress (const u_char *, const u_char *,
151                             const u_char *, char *, size_t);
152 isc_result_t res_nmkquery (res_state, int, const char *, ns_class, ns_type,
153                            const unsigned char *, unsigned,
154                            const unsigned char *, double *,
155                            unsigned, unsigned *);
156 isc_result_t ns_initparse (const unsigned char *, unsigned, ns_msg *);
157 isc_result_t res_nquery(res_state, const char *,
158                         ns_class, ns_type, double *, unsigned, unsigned *);
159 isc_result_t res_nsearch(res_state, const char *,
160                          ns_class, ns_type, double *, unsigned, unsigned *);
161 const char *res_hostalias (const res_state, const char *, char *, size_t);
162 isc_result_t res_nquerydomain(res_state, const char *, const char *,
163                               ns_class class, ns_type type,
164                               double *, unsigned, unsigned *);
165
166 isc_result_t ns_skiprr(const unsigned char *,
167                        const unsigned char *, ns_sect, int, int *);
168 int dn_skipname (const unsigned char *, const unsigned char *);
169 u_int32_t getULong (const unsigned char *);
170 int32_t getLong (const unsigned char *);
171 u_int32_t getUShort (const unsigned char *);
172 int32_t getShort (const unsigned char *);
173 u_int32_t getUChar (const unsigned char *);
174 void putULong (unsigned char *, u_int32_t);
175 void putLong (unsigned char *, int32_t);
176 void putUShort (unsigned char *, u_int32_t);
177 void putShort (unsigned char *, int32_t);
178 void putUChar (unsigned char *, u_int32_t);
179 int ns_name_ntol (const unsigned char *, unsigned char *, size_t);
180 isc_result_t ns_sign_tcp_init (void *, const unsigned char *,
181                                unsigned, ns_tcp_tsig_state *);
182 isc_result_t ns_sign_tcp (unsigned char *,
183                           unsigned *, unsigned, int, ns_tcp_tsig_state *, int);
184 int ns_name_ntop (const unsigned char *, char *, size_t);
185 int ns_name_pton (const char *, unsigned char *, size_t);
186 int ns_name_unpack (const unsigned char *, const unsigned char *,
187                     const unsigned char *, unsigned char *, size_t);
188 int ns_name_pack (const unsigned char *, unsigned char *,
189                   unsigned, const unsigned char **, const unsigned char **);
190 int ns_name_compress (const char *, unsigned char *,
191                       size_t, const unsigned char **, const unsigned char **);
192 int ns_name_skip (const unsigned char **, const unsigned char *);
193 int ns_subdomain (const char *, const char *);
194 unsigned char *ns_find_tsig (unsigned char *, unsigned char *);
195 isc_result_t ns_verify (unsigned char *, unsigned *, void *,
196                         const unsigned char *,
197                         unsigned, unsigned char *, unsigned *, time_t *, int);
198 isc_result_t ns_verify_tcp_init (void *, const unsigned char *, unsigned,
199                                  ns_tcp_tsig_state *);
200 isc_result_t ns_verify_tcp (unsigned char *, unsigned *,
201                             ns_tcp_tsig_state *, int);
202 int b64_ntop (unsigned char const *, size_t, char *, size_t);
203
204 ns_rcode find_cached_zone (const char *, ns_class, char *,
205                            size_t, struct in_addr *, int, int *, void *);
206 int find_tsig_key (ns_tsig_key **, const char *, void *);
207 int forget_zone (void *);
208 int repudiate_zone (void *);
209 void cache_found_zone (ns_class, char *, struct in_addr *, int);
210 isc_result_t uerr2isc (int);
211 isc_result_t ns_rcode_to_isc (int);
212
213 #define DprintQ(a,b,c,d)
214 #define Dprint(a,b)
215 #define Perror(a, b, c, d)
216 #define Aerror(a, b, c, d, e)
217 #define DPRINTF(x)
218
219 #define USE_MD5
220 #endif
221
222 #if defined (TRACING)
223 void trace_mr_statp_setup (res_state);
224 #endif