3 Private master include file for the OMAPI library. */
6 * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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.
21 * Internet Systems Consortium, Inc.
23 * Redwood City, CA 94063
25 * https://www.isc.org/
29 #ifndef __OMAPIP_OMAPIP_P_H__
30 #define __OMAPIP_OMAPIP_P_H__
33 #include <sys/types.h>
34 #include <netinet/in.h>
35 #include <sys/socket.h>
37 #include <arpa/inet.h>
41 #define fd_set cygwin_fd_set
42 #include <sys/types.h>
55 * XXX: I'm not sure why these were here.
63 #include <omapip/convert.h>
64 #include <omapip/hash.h>
65 #include <omapip/omapip.h>
66 #include <omapip/trace.h>
68 /* DST_API control flags */
69 /* These are used in functions dst_sign_data and dst_verify_data */
70 #define SIG_MODE_INIT 1 /* initalize digest */
71 #define SIG_MODE_UPDATE 2 /* add data to digest */
72 #define SIG_MODE_FINAL 4 /* generate/verify signature */
73 #define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
75 /* OMAPI protocol header, version 1.00 */
77 u_int32_t authlen
; /* Length of authenticator. */
78 u_int32_t authid
; /* Authenticator object ID. */
79 u_int32_t op
; /* Opcode. */
80 omapi_handle_t handle
; /* Handle of object being operated on,
82 u_int32_t id
; /* Transaction ID. */
83 u_int32_t rid
; /* ID of transaction to which this is a response. */
84 } omapi_protocol_header_t
;
86 #define OMAPI_PROTOCOL_VERSION 100
88 #define OMAPI_OP_OPEN 1
89 #define OMAPI_OP_REFRESH 2
90 #define OMAPI_OP_UPDATE 3
91 #define OMAPI_OP_NOTIFY 4
92 #define OMAPI_OP_STATUS 5
93 #define OMAPI_OP_DELETE 6
96 omapi_connection_unconnected
,
97 omapi_connection_connecting
,
98 omapi_connection_connected
,
99 omapi_connection_disconnecting
,
100 omapi_connection_closed
101 } omapi_connection_state_t
;
104 omapi_protocol_intro_wait
,
105 omapi_protocol_header_wait
,
106 omapi_protocol_signature_wait
,
107 omapi_protocol_name_wait
,
108 omapi_protocol_name_length_wait
,
109 omapi_protocol_value_wait
,
110 omapi_protocol_value_length_wait
111 } omapi_protocol_state_t
;
113 typedef struct __omapi_message_object
{
114 OMAPI_OBJECT_PREAMBLE
;
115 struct __omapi_message_object
*next
, *prev
;
116 omapi_object_t
*object
;
117 omapi_object_t
*notify_object
;
118 struct __omapi_protocol_object
*protocol_object
;
120 omapi_typed_data_t
*authenticator
;
122 omapi_object_t
*id_object
;
127 } omapi_message_object_t
;
129 typedef struct __omapi_remote_auth
{
130 struct __omapi_remote_auth
*next
;
131 omapi_handle_t remote_handle
;
133 } omapi_remote_auth_t
;
135 typedef struct __omapi_protocol_object
{
136 OMAPI_OBJECT_PREAMBLE
;
137 u_int32_t header_size
;
138 u_int32_t protocol_version
;
141 omapi_protocol_state_t state
; /* Input state. */
142 int reading_message_values
; /* True if reading message-specific
144 omapi_message_object_t
*message
; /* Incoming message. */
145 omapi_data_string_t
*name
; /* Incoming name. */
146 omapi_typed_data_t
*value
; /* Incoming value. */
147 isc_result_t verify_result
;
148 omapi_remote_auth_t
*default_auth
; /* Default authinfo to use. */
149 omapi_remote_auth_t
*remote_auth_list
; /* Authenticators active on
152 isc_boolean_t insecure
; /* Set to allow unauthenticated
155 isc_result_t (*verify_auth
) (omapi_object_t
*, omapi_auth_key_t
*);
156 } omapi_protocol_object_t
;
159 OMAPI_OBJECT_PREAMBLE
;
161 isc_boolean_t insecure
; /* Set to allow unauthenticated
164 isc_result_t (*verify_auth
) (omapi_object_t
*, omapi_auth_key_t
*);
165 } omapi_protocol_listener_object_t
;
167 #include <omapip/buffer.h>
169 typedef struct __omapi_listener_object
{
170 OMAPI_OBJECT_PREAMBLE
;
171 int socket
; /* Connection socket. */
173 struct sockaddr_in address
;
174 isc_result_t (*verify_addr
) (omapi_object_t
*, omapi_addr_t
*);
175 } omapi_listener_object_t
;
177 typedef struct __omapi_connection_object
{
178 OMAPI_OBJECT_PREAMBLE
;
179 int socket
; /* Connection socket. */
181 omapi_connection_state_t state
;
182 struct sockaddr_in remote_addr
;
183 struct sockaddr_in local_addr
;
184 omapi_addr_list_t
*connect_list
; /* List of addresses to which
186 int cptr
; /* Current element we are connecting to. */
187 u_int32_t bytes_needed
; /* Bytes of input needed before wakeup. */
188 u_int32_t in_bytes
; /* Bytes of input already buffered. */
189 omapi_buffer_t
*inbufs
;
190 u_int32_t out_bytes
; /* Bytes of output in buffers. */
191 omapi_buffer_t
*outbufs
;
192 omapi_listener_object_t
*listener
; /* Listener that accepted this
193 connection, if any. */
194 dst_key_t
*in_key
; /* Authenticator signing incoming
196 void *in_context
; /* Input hash context. */
197 dst_key_t
*out_key
; /* Authenticator signing outgoing
199 void *out_context
; /* Output hash context. */
200 } omapi_connection_object_t
;
202 typedef struct __omapi_io_object
{
203 OMAPI_OBJECT_PREAMBLE
;
204 struct __omapi_io_object
*next
;
205 int (*readfd
) (omapi_object_t
*);
206 int (*writefd
) (omapi_object_t
*);
207 isc_result_t (*reader
) (omapi_object_t
*);
208 isc_result_t (*writer
) (omapi_object_t
*);
209 isc_result_t (*reaper
) (omapi_object_t
*);
211 isc_boolean_t closed
; /* ISC_TRUE = closed, do not use */
214 typedef struct __omapi_generic_object
{
215 OMAPI_OBJECT_PREAMBLE
;
216 omapi_value_t
**values
;
219 } omapi_generic_object_t
;
221 typedef struct __omapi_waiter_object
{
222 OMAPI_OBJECT_PREAMBLE
;
224 isc_result_t waitstatus
;
225 struct __omapi_waiter_object
*next
;
226 } omapi_waiter_object_t
;
228 #define OMAPI_HANDLE_TABLE_SIZE 120
230 typedef struct __omapi_handle_table
{
231 omapi_handle_t first
, limit
;
235 omapi_object_t
*object
;
236 struct __omapi_handle_table
*table
;
237 } children
[OMAPI_HANDLE_TABLE_SIZE
];
238 } omapi_handle_table_t
;
240 #include <omapip/alloc.h>
242 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol
, omapi_protocol_object_t
,
244 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener
,
245 omapi_protocol_listener_object_t
,
246 omapi_type_protocol_listener
)
247 OMAPI_OBJECT_ALLOC_DECL (omapi_connection
,
248 omapi_connection_object_t
, omapi_type_connection
)
249 OMAPI_OBJECT_ALLOC_DECL (omapi_listener
,
250 omapi_listener_object_t
, omapi_type_listener
)
251 OMAPI_OBJECT_ALLOC_DECL (omapi_io
,
252 omapi_io_object_t
, omapi_type_io_object
)
253 OMAPI_OBJECT_ALLOC_DECL (omapi_waiter
,
254 omapi_waiter_object_t
, omapi_type_waiter
)
255 OMAPI_OBJECT_ALLOC_DECL (omapi_generic
,
256 omapi_generic_object_t
, omapi_type_generic
)
257 OMAPI_OBJECT_ALLOC_DECL (omapi_message
,
258 omapi_message_object_t
, omapi_type_message
)
260 isc_result_t
omapi_connection_sign_data (int mode
,
263 const unsigned char *data
,
265 omapi_typed_data_t
**result
);
266 isc_result_t
omapi_listener_connect (omapi_connection_object_t
**obj
,
267 omapi_listener_object_t
*listener
,
269 struct sockaddr_in
*remote_addr
);
270 void omapi_listener_trace_setup (void);
271 void omapi_connection_trace_setup (void);
272 void omapi_buffer_trace_setup (void);
273 void omapi_connection_register (omapi_connection_object_t
*,
275 OMAPI_ARRAY_TYPE_DECL(omapi_listener
, omapi_listener_object_t
);
276 OMAPI_ARRAY_TYPE_DECL(omapi_connection
, omapi_connection_object_t
);
278 isc_result_t
omapi_handle_clear(omapi_handle_t
);
280 extern int log_perror
;
281 extern void (*log_cleanup
) (void);
283 void log_fatal (const char *, ...)
284 __attribute__((__format__(__printf__
,1,2))) ISC_DHCP_NORETURN
;
285 int log_error (const char *, ...)
286 __attribute__((__format__(__printf__
,1,2)));
287 int log_info (const char *, ...)
288 __attribute__((__format__(__printf__
,1,2)));
289 int log_debug (const char *, ...)
290 __attribute__((__format__(__printf__
,1,2)));
292 void do_percentm (char *obuf
, size_t obufsize
, const char *ibuf
);
294 isc_result_t
uerr2isc (int);
295 isc_result_t
ns_rcode_to_isc (int);
297 extern omapi_message_object_t
*omapi_registered_messages
;
299 #endif /* __OMAPIP_OMAPIP_P_H__ */