]> git.ipfire.org Git - thirdparty/dhcp.git/blob - includes/omapip/omapip_p.h
Support for asynchronous ddns per ticket 19216 - convert to using isclib and
[thirdparty/dhcp.git] / includes / omapip / omapip_p.h
1 /* omapip_p.h
2
3 Private master include file for the OMAPI library. */
4
5 /*
6 * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
8 *
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 *
21 * Internet Systems Consortium, Inc.
22 * 950 Charter Street
23 * Redwood City, CA 94063
24 * <info@isc.org>
25 * https://www.isc.org/
26 *
27 * This software has been written for Internet Systems Consortium
28 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29 * To learn more about Internet Systems Consortium, see
30 * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
31 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32 * ``http://www.nominum.com''.
33 */
34
35 #ifndef __OMAPIP_OMAPIP_P_H__
36 #define __OMAPIP_OMAPIP_P_H__
37
38 #ifndef __CYGWIN32__
39 #include <sys/types.h>
40 #include <netinet/in.h>
41 #include <sys/socket.h>
42 #include <sys/un.h>
43 #include <arpa/inet.h>
44
45 #include <netdb.h>
46 #else
47 #define fd_set cygwin_fd_set
48 #include <sys/types.h>
49 #endif
50 #include <fcntl.h>
51 #include <stdio.h>
52 #include <unistd.h>
53 #include <string.h>
54 #include <memory.h>
55 #include <stdlib.h>
56 #include <sys/stat.h>
57 #include <ctype.h>
58 #include <time.h>
59
60 /*
61 * XXX: I'm not sure why these were here.
62 #include "cdefs.h"
63 #include "osdep.h"
64 */
65
66 #include <dst/dst.h>
67 #include "result.h"
68
69 #include <omapip/convert.h>
70 #include <omapip/hash.h>
71 #include <omapip/omapip.h>
72 #include <omapip/trace.h>
73
74 /* DST_API control flags */
75 /* These are used in functions dst_sign_data and dst_verify_data */
76 #define SIG_MODE_INIT 1 /* initalize digest */
77 #define SIG_MODE_UPDATE 2 /* add data to digest */
78 #define SIG_MODE_FINAL 4 /* generate/verify signature */
79 #define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
80
81 /* OMAPI protocol header, version 1.00 */
82 typedef struct {
83 u_int32_t authlen; /* Length of authenticator. */
84 u_int32_t authid; /* Authenticator object ID. */
85 u_int32_t op; /* Opcode. */
86 omapi_handle_t handle; /* Handle of object being operated on,
87 or zero. */
88 u_int32_t id; /* Transaction ID. */
89 u_int32_t rid; /* ID of transaction to which this is a response. */
90 } omapi_protocol_header_t;
91
92 #define OMAPI_PROTOCOL_VERSION 100
93
94 #define OMAPI_OP_OPEN 1
95 #define OMAPI_OP_REFRESH 2
96 #define OMAPI_OP_UPDATE 3
97 #define OMAPI_OP_NOTIFY 4
98 #define OMAPI_OP_STATUS 5
99 #define OMAPI_OP_DELETE 6
100
101 typedef enum {
102 omapi_connection_unconnected,
103 omapi_connection_connecting,
104 omapi_connection_connected,
105 omapi_connection_disconnecting,
106 omapi_connection_closed
107 } omapi_connection_state_t;
108
109 typedef enum {
110 omapi_protocol_intro_wait,
111 omapi_protocol_header_wait,
112 omapi_protocol_signature_wait,
113 omapi_protocol_name_wait,
114 omapi_protocol_name_length_wait,
115 omapi_protocol_value_wait,
116 omapi_protocol_value_length_wait
117 } omapi_protocol_state_t;
118
119 typedef struct __omapi_message_object {
120 OMAPI_OBJECT_PREAMBLE;
121 struct __omapi_message_object *next, *prev;
122 omapi_object_t *object;
123 omapi_object_t *notify_object;
124 struct __omapi_protocol_object *protocol_object;
125 u_int32_t authlen;
126 omapi_typed_data_t *authenticator;
127 u_int32_t authid;
128 omapi_object_t *id_object;
129 u_int32_t op;
130 u_int32_t h;
131 u_int32_t id;
132 u_int32_t rid;
133 } omapi_message_object_t;
134
135 typedef struct __omapi_remote_auth {
136 struct __omapi_remote_auth *next;
137 omapi_handle_t remote_handle;
138 omapi_object_t *a;
139 } omapi_remote_auth_t;
140
141 typedef struct __omapi_protocol_object {
142 OMAPI_OBJECT_PREAMBLE;
143 u_int32_t header_size;
144 u_int32_t protocol_version;
145 u_int32_t next_xid;
146
147 omapi_protocol_state_t state; /* Input state. */
148 int reading_message_values; /* True if reading message-specific
149 values. */
150 omapi_message_object_t *message; /* Incoming message. */
151 omapi_data_string_t *name; /* Incoming name. */
152 omapi_typed_data_t *value; /* Incoming value. */
153 isc_result_t verify_result;
154 omapi_remote_auth_t *default_auth; /* Default authinfo to use. */
155 omapi_remote_auth_t *remote_auth_list; /* Authenticators active on
156 this connection. */
157
158 isc_boolean_t insecure; /* Set to allow unauthenticated
159 messages. */
160
161 isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
162 } omapi_protocol_object_t;
163
164 typedef struct {
165 OMAPI_OBJECT_PREAMBLE;
166
167 isc_boolean_t insecure; /* Set to allow unauthenticated
168 messages. */
169
170 isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
171 } omapi_protocol_listener_object_t;
172
173 #include <omapip/buffer.h>
174
175 typedef struct __omapi_listener_object {
176 OMAPI_OBJECT_PREAMBLE;
177 int socket; /* Connection socket. */
178 int index;
179 struct sockaddr_in address;
180 isc_result_t (*verify_addr) (omapi_object_t *, omapi_addr_t *);
181 } omapi_listener_object_t;
182
183 typedef struct __omapi_connection_object {
184 OMAPI_OBJECT_PREAMBLE;
185 int socket; /* Connection socket. */
186 int32_t index;
187 omapi_connection_state_t state;
188 struct sockaddr_in remote_addr;
189 struct sockaddr_in local_addr;
190 omapi_addr_list_t *connect_list; /* List of addresses to which
191 to connect. */
192 int cptr; /* Current element we are connecting to. */
193 u_int32_t bytes_needed; /* Bytes of input needed before wakeup. */
194 u_int32_t in_bytes; /* Bytes of input already buffered. */
195 omapi_buffer_t *inbufs;
196 u_int32_t out_bytes; /* Bytes of output in buffers. */
197 omapi_buffer_t *outbufs;
198 omapi_listener_object_t *listener; /* Listener that accepted this
199 connection, if any. */
200 dst_key_t *in_key; /* Authenticator signing incoming
201 data. */
202 void *in_context; /* Input hash context. */
203 dst_key_t *out_key; /* Authenticator signing outgoing
204 data. */
205 void *out_context; /* Output hash context. */
206 } omapi_connection_object_t;
207
208 typedef struct __omapi_io_object {
209 OMAPI_OBJECT_PREAMBLE;
210 struct __omapi_io_object *next;
211 int (*readfd) (omapi_object_t *);
212 int (*writefd) (omapi_object_t *);
213 isc_result_t (*reader) (omapi_object_t *);
214 isc_result_t (*writer) (omapi_object_t *);
215 isc_result_t (*reaper) (omapi_object_t *);
216 isc_socket_t *fd;
217 } omapi_io_object_t;
218
219 typedef struct __omapi_generic_object {
220 OMAPI_OBJECT_PREAMBLE;
221 omapi_value_t **values;
222 u_int8_t *changed;
223 int nvalues, va_max;
224 } omapi_generic_object_t;
225
226 typedef struct __omapi_waiter_object {
227 OMAPI_OBJECT_PREAMBLE;
228 int ready;
229 isc_result_t waitstatus;
230 struct __omapi_waiter_object *next;
231 } omapi_waiter_object_t;
232
233 #define OMAPI_HANDLE_TABLE_SIZE 120
234
235 typedef struct __omapi_handle_table {
236 omapi_handle_t first, limit;
237 omapi_handle_t next;
238 int leafp;
239 union {
240 omapi_object_t *object;
241 struct __omapi_handle_table *table;
242 } children [OMAPI_HANDLE_TABLE_SIZE];
243 } omapi_handle_table_t;
244
245 #include <omapip/alloc.h>
246
247 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol, omapi_protocol_object_t,
248 omapi_type_protocol)
249 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
250 omapi_protocol_listener_object_t,
251 omapi_type_protocol_listener)
252 OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
253 omapi_connection_object_t, omapi_type_connection)
254 OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
255 omapi_listener_object_t, omapi_type_listener)
256 OMAPI_OBJECT_ALLOC_DECL (omapi_io,
257 omapi_io_object_t, omapi_type_io_object)
258 OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
259 omapi_waiter_object_t, omapi_type_waiter)
260 OMAPI_OBJECT_ALLOC_DECL (omapi_generic,
261 omapi_generic_object_t, omapi_type_generic)
262 OMAPI_OBJECT_ALLOC_DECL (omapi_message,
263 omapi_message_object_t, omapi_type_message)
264
265 isc_result_t omapi_connection_sign_data (int mode,
266 dst_key_t *key,
267 void **context,
268 const unsigned char *data,
269 const unsigned len,
270 omapi_typed_data_t **result);
271 isc_result_t omapi_listener_connect (omapi_connection_object_t **obj,
272 omapi_listener_object_t *listener,
273 int socket,
274 struct sockaddr_in *remote_addr);
275 void omapi_listener_trace_setup (void);
276 void omapi_connection_trace_setup (void);
277 void omapi_buffer_trace_setup (void);
278 void omapi_connection_register (omapi_connection_object_t *,
279 const char *, int);
280 void trace_mr_init (void);
281
282 OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t);
283 OMAPI_ARRAY_TYPE_DECL(omapi_connection, omapi_connection_object_t);
284
285 extern int log_priority;
286 extern int log_perror;
287 extern void (*log_cleanup) (void);
288
289 void log_fatal (const char *, ...)
290 __attribute__((__format__(__printf__,1,2)));
291 int log_error (const char *, ...)
292 __attribute__((__format__(__printf__,1,2)));
293 int log_info (const char *, ...)
294 __attribute__((__format__(__printf__,1,2)));
295 int log_debug (const char *, ...)
296 __attribute__((__format__(__printf__,1,2)));
297 void do_percentm (char *obuf, const char *ibuf);
298
299 isc_result_t uerr2isc (int);
300 isc_result_t ns_rcode_to_isc (int);
301
302 extern omapi_message_object_t *omapi_registered_messages;
303
304 #endif /* __OMAPIP_OMAPIP_P_H__ */