tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / dhcp / includes / omapip / omapip_p.h
blob27bfee3782a3d4b7090a49952255de7e94ea5d99
1 /* omapip_p.h
3 Private master include file for the OMAPI library. */
5 /*
6 * Copyright (c) 2004 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.
22 * 950 Charter Street
23 * Redwood City, CA 94063
24 * <info@isc.org>
25 * http://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 * ``http://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__
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>
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>
60 #include "cdefs.h"
61 #include "dhcp_osdep.h"
63 #include <isc-dhcp/dst.h>
64 #include <isc-dhcp/result.h>
66 #include <omapip/convert.h>
67 #include <omapip/hash.h>
68 #include <omapip/omapip.h>
69 #include <omapip/trace.h>
71 /* OMAPI protocol header, version 1.00 */
72 typedef struct {
73 u_int32_t authlen; /* Length of authenticator. */
74 u_int32_t authid; /* Authenticator object ID. */
75 u_int32_t op; /* Opcode. */
76 omapi_handle_t handle; /* Handle of object being operated on,
77 or zero. */
78 u_int32_t id; /* Transaction ID. */
79 u_int32_t rid; /* ID of transaction to which this is a response. */
80 } omapi_protocol_header_t;
82 #define OMAPI_PROTOCOL_VERSION 100
84 #define OMAPI_OP_OPEN 1
85 #define OMAPI_OP_REFRESH 2
86 #define OMAPI_OP_UPDATE 3
87 #define OMAPI_OP_NOTIFY 4
88 #define OMAPI_OP_STATUS 5
89 #define OMAPI_OP_DELETE 6
91 typedef enum {
92 omapi_connection_unconnected,
93 omapi_connection_connecting,
94 omapi_connection_connected,
95 omapi_connection_disconnecting,
96 omapi_connection_closed
97 } omapi_connection_state_t;
99 typedef enum {
100 omapi_protocol_intro_wait,
101 omapi_protocol_header_wait,
102 omapi_protocol_signature_wait,
103 omapi_protocol_name_wait,
104 omapi_protocol_name_length_wait,
105 omapi_protocol_value_wait,
106 omapi_protocol_value_length_wait
107 } omapi_protocol_state_t;
109 typedef struct __omapi_message_object {
110 OMAPI_OBJECT_PREAMBLE;
111 struct __omapi_message_object *next, *prev;
112 omapi_object_t *object;
113 omapi_object_t *notify_object;
114 struct __omapi_protocol_object *protocol_object;
115 u_int32_t authlen;
116 omapi_typed_data_t *authenticator;
117 u_int32_t authid;
118 omapi_object_t *id_object;
119 u_int32_t op;
120 u_int32_t h;
121 u_int32_t id;
122 u_int32_t rid;
123 } omapi_message_object_t;
125 typedef struct __omapi_remote_auth {
126 struct __omapi_remote_auth *next;
127 omapi_handle_t remote_handle;
128 omapi_object_t *a;
129 } omapi_remote_auth_t;
131 typedef struct __omapi_protocol_object {
132 OMAPI_OBJECT_PREAMBLE;
133 u_int32_t header_size;
134 u_int32_t protocol_version;
135 u_int32_t next_xid;
137 omapi_protocol_state_t state; /* Input state. */
138 int reading_message_values; /* True if reading message-specific
139 values. */
140 omapi_message_object_t *message; /* Incoming message. */
141 omapi_data_string_t *name; /* Incoming name. */
142 omapi_typed_data_t *value; /* Incoming value. */
143 isc_result_t verify_result;
144 omapi_remote_auth_t *default_auth; /* Default authinfo to use. */
145 omapi_remote_auth_t *remote_auth_list; /* Authenticators active on
146 this connection. */
148 isc_boolean_t insecure; /* Set to allow unauthenticated
149 messages. */
151 isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
152 } omapi_protocol_object_t;
154 typedef struct {
155 OMAPI_OBJECT_PREAMBLE;
157 isc_boolean_t insecure; /* Set to allow unauthenticated
158 messages. */
160 isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
161 } omapi_protocol_listener_object_t;
163 #include <omapip/buffer.h>
165 typedef struct __omapi_listener_object {
166 OMAPI_OBJECT_PREAMBLE;
167 int socket; /* Connection socket. */
168 int index;
169 struct sockaddr_in address;
170 isc_result_t (*verify_addr) (omapi_object_t *, omapi_addr_t *);
171 } omapi_listener_object_t;
173 typedef struct __omapi_connection_object {
174 OMAPI_OBJECT_PREAMBLE;
175 int socket; /* Connection socket. */
176 int32_t index;
177 omapi_connection_state_t state;
178 struct sockaddr_in remote_addr;
179 struct sockaddr_in local_addr;
180 omapi_addr_list_t *connect_list; /* List of addresses to which
181 to connect. */
182 int cptr; /* Current element we are connecting to. */
183 u_int32_t bytes_needed; /* Bytes of input needed before wakeup. */
184 u_int32_t in_bytes; /* Bytes of input already buffered. */
185 omapi_buffer_t *inbufs;
186 u_int32_t out_bytes; /* Bytes of output in buffers. */
187 omapi_buffer_t *outbufs;
188 omapi_listener_object_t *listener; /* Listener that accepted this
189 connection, if any. */
190 DST_KEY *in_key; /* Authenticator signing incoming
191 data. */
192 void *in_context; /* Input hash context. */
193 DST_KEY *out_key; /* Authenticator signing outgoing
194 data. */
195 void *out_context; /* Output hash context. */
196 } omapi_connection_object_t;
198 typedef struct __omapi_io_object {
199 OMAPI_OBJECT_PREAMBLE;
200 struct __omapi_io_object *next;
201 int (*readfd) (omapi_object_t *);
202 int (*writefd) (omapi_object_t *);
203 isc_result_t (*reader) (omapi_object_t *);
204 isc_result_t (*writer) (omapi_object_t *);
205 isc_result_t (*reaper) (omapi_object_t *);
206 } omapi_io_object_t;
208 typedef struct __omapi_generic_object {
209 OMAPI_OBJECT_PREAMBLE;
210 omapi_value_t **values;
211 u_int8_t *changed;
212 int nvalues, va_max;
213 } omapi_generic_object_t;
215 typedef struct __omapi_waiter_object {
216 OMAPI_OBJECT_PREAMBLE;
217 int ready;
218 isc_result_t waitstatus;
219 struct __omapi_waiter_object *next;
220 } omapi_waiter_object_t;
222 #define OMAPI_HANDLE_TABLE_SIZE 120
224 typedef struct __omapi_handle_table {
225 omapi_handle_t first, limit;
226 omapi_handle_t next;
227 int leafp;
228 union {
229 omapi_object_t *object;
230 struct __omapi_handle_table *table;
231 } children [OMAPI_HANDLE_TABLE_SIZE];
232 } omapi_handle_table_t;
234 #include <omapip/alloc.h>
236 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol, omapi_protocol_object_t,
237 omapi_type_protocol)
238 OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
239 omapi_protocol_listener_object_t,
240 omapi_type_protocol_listener)
241 OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
242 omapi_connection_object_t, omapi_type_connection)
243 OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
244 omapi_listener_object_t, omapi_type_listener)
245 OMAPI_OBJECT_ALLOC_DECL (omapi_io,
246 omapi_io_object_t, omapi_type_io_object)
247 OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
248 omapi_waiter_object_t, omapi_type_waiter)
249 OMAPI_OBJECT_ALLOC_DECL (omapi_generic,
250 omapi_generic_object_t, omapi_type_generic)
251 OMAPI_OBJECT_ALLOC_DECL (omapi_message,
252 omapi_message_object_t, omapi_type_message)
254 isc_result_t omapi_connection_sign_data (int mode,
255 DST_KEY *key,
256 void **context,
257 const unsigned char *data,
258 const unsigned len,
259 omapi_typed_data_t **result);
260 isc_result_t omapi_listener_connect (omapi_connection_object_t **obj,
261 omapi_listener_object_t *listener,
262 int socket,
263 struct sockaddr_in *remote_addr);
264 void omapi_listener_trace_setup (void);
265 void omapi_connection_trace_setup (void);
266 void omapi_buffer_trace_setup (void);
267 void omapi_connection_register (omapi_connection_object_t *,
268 const char *, int);
269 void trace_mr_init (void);
271 OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t);
272 OMAPI_ARRAY_TYPE_DECL(omapi_connection, omapi_connection_object_t);
274 extern int log_priority;
275 extern int log_perror;
276 extern void (*log_cleanup) (void);
278 void log_fatal (const char *, ...)
279 __attribute__((__format__(__printf__,1,2)));
280 int log_error (const char *, ...)
281 __attribute__((__format__(__printf__,1,2)));
282 int log_info (const char *, ...)
283 __attribute__((__format__(__printf__,1,2)));
284 int log_debug (const char *, ...)
285 __attribute__((__format__(__printf__,1,2)));
286 void do_percentm (char *obuf, const char *ibuf);
288 isc_result_t uerr2isc (int);
289 isc_result_t ns_rcode_to_isc (int);
291 extern omapi_message_object_t *omapi_registered_messages;
293 #endif /* __OMAPIP_OMAPIP_P_H__ */