3 Private master include file for the OMAPI library. */
6 * Copyright (c) 1996-2001 Internet Software Consortium.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
38 * To learn more about the Internet Software Consortium, see
39 * ``http://www.isc.org/''. To learn more about Vixie Enterprises,
40 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
41 * ``http://www.nominum.com''.
44 #ifndef __OMAPIP_OMAPIP_P_H__
45 #define __OMAPIP_OMAPIP_P_H__
48 #include <sys/types.h>
49 #include <netinet/in.h>
50 #include <sys/socket.h>
52 #include <arpa/inet.h>
56 #define fd_set cygwin_fd_set
57 #include <sys/types.h>
72 #include <isc-dhcp/dst.h>
73 #include <isc-dhcp/result.h>
75 #include <omapip/convert.h>
76 #include <omapip/hash.h>
77 #include <omapip/omapip.h>
78 #include <omapip/trace.h>
80 /* OMAPI protocol header, version 1.00 */
82 u_int32_t authlen; /* Length of authenticator. */
83 u_int32_t authid; /* Authenticator object ID. */
84 u_int32_t op; /* Opcode. */
85 omapi_handle_t handle; /* Handle of object being operated on,
87 u_int32_t id; /* Transaction ID. */
88 u_int32_t rid; /* ID of transaction to which this is a response. */
89 } omapi_protocol_header_t;
91 #define OMAPI_PROTOCOL_VERSION 100
93 #define OMAPI_OP_OPEN 1
94 #define OMAPI_OP_REFRESH 2
95 #define OMAPI_OP_UPDATE 3
96 #define OMAPI_OP_NOTIFY 4
97 #define OMAPI_OP_STATUS 5
98 #define OMAPI_OP_DELETE 6
101 omapi_connection_unconnected,
102 omapi_connection_connecting,
103 omapi_connection_connected,
104 omapi_connection_disconnecting,
105 omapi_connection_closed
106 } omapi_connection_state_t;
109 omapi_protocol_intro_wait,
110 omapi_protocol_header_wait,
111 omapi_protocol_signature_wait,
112 omapi_protocol_name_wait,
113 omapi_protocol_name_length_wait,
114 omapi_protocol_value_wait,
115 omapi_protocol_value_length_wait
116 } omapi_protocol_state_t;
118 typedef struct __omapi_message_object {
119 OMAPI_OBJECT_PREAMBLE;
120 struct __omapi_message_object *next, *prev;
121 omapi_object_t *object;
122 omapi_object_t *notify_object;
123 struct __omapi_protocol_object *protocol_object;
125 omapi_typed_data_t *authenticator;
127 omapi_object_t *id_object;
132 } omapi_message_object_t;
134 typedef struct __omapi_remote_auth {
135 struct __omapi_remote_auth *next;
136 omapi_handle_t remote_handle;
138 } omapi_remote_auth_t;
140 typedef struct __omapi_protocol_object {
141 OMAPI_OBJECT_PREAMBLE;
142 u_int32_t header_size;
143 u_int32_t protocol_version;
146 omapi_protocol_state_t state; /* Input state. */
147 int reading_message_values; /* True if reading message-specific
149 omapi_message_object_t *message; /* Incoming message. */
150 omapi_data_string_t *name; /* Incoming name. */
151 omapi_typed_data_t *value; /* Incoming value. */
152 isc_result_t verify_result;
153 omapi_remote_auth_t *default_auth; /* Default authinfo to use. */
154 omapi_remote_auth_t *remote_auth_list; /* Authenticators active on
157 isc_boolean_t insecure; /* Set to allow unauthenticated
160 isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
161 } omapi_protocol_object_t;
164 OMAPI_OBJECT_PREAMBLE;
166 isc_boolean_t insecure; /* Set to allow unauthenticated
169 isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
170 } omapi_protocol_listener_object_t;
172 #include <omapip/buffer.h>
174 typedef struct __omapi_listener_object {
175 OMAPI_OBJECT_PREAMBLE;
176 int socket; /* Connection socket. */
178 struct sockaddr_in address;
179 isc_result_t (*verify_addr) (omapi_object_t *, omapi_addr_t *);
180 } omapi_listener_object_t;
182 typedef struct __omapi_connection_object {
183 OMAPI_OBJECT_PREAMBLE;
184 int socket; /* Connection socket. */
186 omapi_connection_state_t state;
187 struct sockaddr_in remote_addr;
188 struct sockaddr_in local_addr;
189 omapi_addr_list_t *connect_list; /* List of addresses to which
191 int cptr; /* Current element we are connecting to. */
192 u_int32_t bytes_needed; /* Bytes of input needed before wakeup. */
193 u_int32_t in_bytes; /* Bytes of input already buffered. */
194 omapi_buffer_t *inbufs;
195 u_int32_t out_bytes; /* Bytes of output in buffers. */
196 omapi_buffer_t *outbufs;
197 omapi_listener_object_t *listener; /* Listener that accepted this
198 connection, if any. */
199 DST_KEY *in_key; /* Authenticator signing incoming
201 void *in_context; /* Input hash context. */
202 DST_KEY *out_key; /* Authenticator signing outgoing
204 void *out_context; /* Output hash context. */
205 } omapi_connection_object_t;
207 typedef struct __omapi_io_object {
208 OMAPI_OBJECT_PREAMBLE;
209 struct __omapi_io_object *next;
210 int (*readfd) (omapi_object_t *);
211 int (*writefd) (omapi_object_t *);
212 isc_result_t (*reader) (omapi_object_t *);
213 isc_result_t (*writer) (omapi_object_t *);
214 isc_result_t (*reaper) (omapi_object_t *);
217 typedef struct __omapi_generic_object {
218 OMAPI_OBJECT_PREAMBLE;
219 omapi_value_t **values;
222 } omapi_generic_object_t;
224 typedef struct __omapi_waiter_object {
225 OMAPI_OBJECT_PREAMBLE;
227 isc_result_t waitstatus;
228 struct __omapi_waiter_object *next;
229 } omapi_waiter_object_t;
231 #define OMAPI_HANDLE_TABLE_SIZE 120
233 typedef struct __omapi_handle_table {
234 omapi_handle_t first, limit;
238 omapi_object_t *object;
239 struct __omapi_handle_table *table;
240 } children [OMAPI_HANDLE_TABLE_SIZE];
241 } omapi_handle_table_t;
243 #include <omapip/alloc.h>
245 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol, omapi_protocol_object_t,
247 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
248 omapi_protocol_listener_object_t,
249 omapi_type_protocol_listener)
250 OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
251 omapi_connection_object_t, omapi_type_connection)
252 OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
253 omapi_listener_object_t, omapi_type_listener)
254 OMAPI_OBJECT_ALLOC_DECL (omapi_io,
255 omapi_io_object_t, omapi_type_io_object)
256 OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
257 omapi_waiter_object_t, omapi_type_waiter)
258 OMAPI_OBJECT_ALLOC_DECL (omapi_generic,
259 omapi_generic_object_t, omapi_type_generic)
260 OMAPI_OBJECT_ALLOC_DECL (omapi_message,
261 omapi_message_object_t, omapi_type_message)
263 isc_result_t omapi_connection_sign_data (int mode,
266 const unsigned char *data,
268 omapi_typed_data_t **result);
269 isc_result_t omapi_listener_connect (omapi_connection_object_t **obj,
270 omapi_listener_object_t *listener,
272 struct sockaddr_in *remote_addr);
273 void omapi_listener_trace_setup (void);
274 void omapi_connection_trace_setup (void);
275 void omapi_buffer_trace_setup (void);
276 void omapi_connection_register (omapi_connection_object_t *,
278 void trace_mr_init (void);
280 OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t);
281 OMAPI_ARRAY_TYPE_DECL(omapi_connection, omapi_connection_object_t);
283 extern int log_priority;
284 extern int log_perror;
285 extern void (*log_cleanup) (void);
287 void log_fatal (const char *, ...)
288 __attribute__((__format__(__printf__,1,2)));
289 int log_error (const char *, ...)
290 __attribute__((__format__(__printf__,1,2)));
291 int log_info (const char *, ...)
292 __attribute__((__format__(__printf__,1,2)));
293 int log_debug (const char *, ...)
294 __attribute__((__format__(__printf__,1,2)));
295 void do_percentm (char *obuf, const char *ibuf);
297 isc_result_t uerr2isc (int);
298 isc_result_t ns_rcode_to_isc (int);
300 extern omapi_message_object_t *omapi_registered_messages;
302 #endif /* __OMAPIP_OMAPIP_P_H__ */