3 Private master include file for the OMAPI library. */
6 * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
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.
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/
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''.
35 #ifndef __OMAPIP_OMAPIP_P_H__
36 #define __OMAPIP_OMAPIP_P_H__
39 #include <sys/types.h>
40 #include <netinet/in.h>
41 #include <sys/socket.h>
43 #include <arpa/inet.h>
47 #define fd_set cygwin_fd_set
48 #include <sys/types.h>
61 * XXX: I'm not sure why these were here.
69 #include <omapip/convert.h>
70 #include <omapip/hash.h>
71 #include <omapip/omapip.h>
72 #include <omapip/trace.h>
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)
81 /* OMAPI protocol header, version 1.00 */
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,
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
;
92 #define OMAPI_PROTOCOL_VERSION 100
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
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
;
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
;
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
;
126 omapi_typed_data_t
*authenticator
;
128 omapi_object_t
*id_object
;
133 } omapi_message_object_t
;
135 typedef struct __omapi_remote_auth
{
136 struct __omapi_remote_auth
*next
;
137 omapi_handle_t remote_handle
;
139 } omapi_remote_auth_t
;
141 typedef struct __omapi_protocol_object
{
142 OMAPI_OBJECT_PREAMBLE
;
143 u_int32_t header_size
;
144 u_int32_t protocol_version
;
147 omapi_protocol_state_t state
; /* Input state. */
148 int reading_message_values
; /* True if reading message-specific
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
158 isc_boolean_t insecure
; /* Set to allow unauthenticated
161 isc_result_t (*verify_auth
) (omapi_object_t
*, omapi_auth_key_t
*);
162 } omapi_protocol_object_t
;
165 OMAPI_OBJECT_PREAMBLE
;
167 isc_boolean_t insecure
; /* Set to allow unauthenticated
170 isc_result_t (*verify_auth
) (omapi_object_t
*, omapi_auth_key_t
*);
171 } omapi_protocol_listener_object_t
;
173 #include <omapip/buffer.h>
175 typedef struct __omapi_listener_object
{
176 OMAPI_OBJECT_PREAMBLE
;
177 int socket
; /* Connection socket. */
179 struct sockaddr_in address
;
180 isc_result_t (*verify_addr
) (omapi_object_t
*, omapi_addr_t
*);
181 } omapi_listener_object_t
;
183 typedef struct __omapi_connection_object
{
184 OMAPI_OBJECT_PREAMBLE
;
185 int socket
; /* Connection socket. */
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
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
202 void *in_context
; /* Input hash context. */
203 dst_key_t
*out_key
; /* Authenticator signing outgoing
205 void *out_context
; /* Output hash context. */
206 } omapi_connection_object_t
;
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
*);
219 typedef struct __omapi_generic_object
{
220 OMAPI_OBJECT_PREAMBLE
;
221 omapi_value_t
**values
;
224 } omapi_generic_object_t
;
226 typedef struct __omapi_waiter_object
{
227 OMAPI_OBJECT_PREAMBLE
;
229 isc_result_t waitstatus
;
230 struct __omapi_waiter_object
*next
;
231 } omapi_waiter_object_t
;
233 #define OMAPI_HANDLE_TABLE_SIZE 120
235 typedef struct __omapi_handle_table
{
236 omapi_handle_t first
, limit
;
240 omapi_object_t
*object
;
241 struct __omapi_handle_table
*table
;
242 } children
[OMAPI_HANDLE_TABLE_SIZE
];
243 } omapi_handle_table_t
;
245 #include <omapip/alloc.h>
247 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol
, omapi_protocol_object_t
,
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
)
265 isc_result_t
omapi_connection_sign_data (int mode
,
268 const unsigned char *data
,
270 omapi_typed_data_t
**result
);
271 isc_result_t
omapi_listener_connect (omapi_connection_object_t
**obj
,
272 omapi_listener_object_t
*listener
,
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
*,
280 void trace_mr_init (void);
282 OMAPI_ARRAY_TYPE_DECL(omapi_listener
, omapi_listener_object_t
);
283 OMAPI_ARRAY_TYPE_DECL(omapi_connection
, omapi_connection_object_t
);
285 extern int log_priority
;
286 extern int log_perror
;
287 extern void (*log_cleanup
) (void);
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
);
299 isc_result_t
uerr2isc (int);
300 isc_result_t
ns_rcode_to_isc (int);
302 extern omapi_message_object_t
*omapi_registered_messages
;
304 #endif /* __OMAPIP_OMAPIP_P_H__ */