]> git.ipfire.org Git - thirdparty/dhcp.git/blame - includes/omapip/omapip.h
Go back to the BSD license.
[thirdparty/dhcp.git] / includes / omapip / omapip.h
CommitLineData
a40cbc2b
TL
1/* omapip.h
2
3 Definitions for the object management API and protocol... */
4
5/*
6 * Copyright (c) 1996-1999 Internet Software Consortium.
49733f31 7 * All rights reserved.
a40cbc2b 8 *
49733f31
TL
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
a40cbc2b 12 *
49733f31
TL
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.
a40cbc2b 21 *
49733f31
TL
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
34 * SUCH DAMAGE.
35 *
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''.
a40cbc2b
TL
42 */
43
89a93f8b
TL
44#ifndef _OMAPIP_H_
45#define _OMAPIP_H_
444dcb2b 46#include <isc/result.h>
89a93f8b 47
6a4c4be8 48typedef unsigned int omapi_handle_t;
a40cbc2b
TL
49
50struct __omapi_object;
51typedef struct __omapi_object omapi_object_t;
52
53typedef enum {
54 omapi_datatype_int,
55 omapi_datatype_string,
56 omapi_datatype_data,
c859d3b8 57 omapi_datatype_object
a40cbc2b
TL
58} omapi_datatype_t;
59
60typedef struct {
61 int refcnt;
62 omapi_datatype_t type;
63 union {
64 struct {
b1b7b521 65 unsigned len;
a40cbc2b
TL
66#define OMAPI_TYPED_DATA_NOBUFFER_LEN (sizeof (int) + \
67 sizeof (omapi_datatype_t) + \
68 sizeof (int))
6a4c4be8 69 unsigned char value [1];
a40cbc2b
TL
70 } buffer;
71#define OMAPI_TYPED_DATA_OBJECT_LEN (sizeof (int) + \
72 sizeof (omapi_datatype_t) + \
73 sizeof (omapi_object_t *))
74 omapi_object_t *object;
75#define OMAPI_TYPED_DATA_REF_LEN (sizeof (int) + \
76 sizeof (omapi_datatype_t) + \
77 3 * sizeof (void *))
78 struct {
79 void *ptr;
80 isc_result_t (*reference) (void *,
4bd8800e
TL
81 void *, const char *, int);
82 isc_result_t (*dereference) (void *,
83 const char *, int);
a40cbc2b
TL
84 } ref;
85#define OMAPI_TYPED_DATA_INT_LEN (sizeof (int) + \
86 sizeof (omapi_datatype_t) + \
87 sizeof (int))
88 int integer;
89 } u;
90} omapi_typed_data_t;
91
92typedef struct {
93 int refcnt;
b1b7b521 94 unsigned len;
a40cbc2b 95#define OMAPI_DATA_STRING_EMPTY_SIZE (2 * sizeof (int))
6a4c4be8 96 unsigned char value [1];
a40cbc2b
TL
97} omapi_data_string_t;
98
99typedef struct {
100 int refcnt;
101 omapi_data_string_t *name;
102 omapi_typed_data_t *value;
103} omapi_value_t;
104
8ec6b426 105typedef struct __omapi_object_type_t {
b1b7b521 106 const char *name;
8ec6b426 107 struct __omapi_object_type_t *next;
a40cbc2b
TL
108
109 isc_result_t (*set_value) (omapi_object_t *, omapi_object_t *,
110 omapi_data_string_t *,
111 omapi_typed_data_t *);
112 isc_result_t (*get_value) (omapi_object_t *,
113 omapi_object_t *,
114 omapi_data_string_t *, omapi_value_t **);
4bd8800e 115 isc_result_t (*destroy) (omapi_object_t *, const char *, int);
b1b7b521
TL
116 isc_result_t (*signal_handler) (omapi_object_t *,
117 const char *, va_list);
a40cbc2b
TL
118 isc_result_t (*stuff_values) (omapi_object_t *,
119 omapi_object_t *, omapi_object_t *);
8ec6b426
TL
120 isc_result_t (*lookup) (omapi_object_t **, omapi_object_t *,
121 omapi_object_t *);
122 isc_result_t (*create) (omapi_object_t **, omapi_object_t *);
ccce1cc6 123 isc_result_t (*remove) (omapi_object_t *, omapi_object_t *);
a40cbc2b
TL
124} omapi_object_type_t;
125
126#define OMAPI_OBJECT_PREAMBLE \
127 omapi_object_type_t *type; \
128 int refcnt; \
129 omapi_handle_t handle; \
130 omapi_object_t *outer, *inner
131
132/* The omapi handle structure. */
133struct __omapi_object {
134 OMAPI_OBJECT_PREAMBLE;
135};
136
6a4c4be8 137/* The port on which applications should listen for OMAPI connections. */
a40cbc2b 138#define OMAPI_PROTOCOL_PORT 7911
a40cbc2b
TL
139
140isc_result_t omapi_protocol_connect (omapi_object_t *,
d9eefc5d
TL
141 const char *, unsigned, omapi_object_t *);
142isc_result_t omapi_protocol_listen (omapi_object_t *, unsigned, int);
a40cbc2b 143isc_result_t omapi_protocol_accept (omapi_object_t *);
b1b7b521 144isc_result_t omapi_protocol_send_intro (omapi_object_t *, unsigned, unsigned);
a40cbc2b
TL
145isc_result_t omapi_protocol_ready (omapi_object_t *);
146isc_result_t omapi_protocol_set_value (omapi_object_t *, omapi_object_t *,
147 omapi_data_string_t *,
148 omapi_typed_data_t *);
149isc_result_t omapi_protocol_get_value (omapi_object_t *, omapi_object_t *,
150 omapi_data_string_t *,
151 omapi_value_t **);
152isc_result_t omapi_protocol_stuff_values (omapi_object_t *,
153 omapi_object_t *,
154 omapi_object_t *);
155
4bd8800e 156isc_result_t omapi_protocol_destroy (omapi_object_t *, const char *, int);
8ec6b426
TL
157isc_result_t omapi_protocol_send_message (omapi_object_t *,
158 omapi_object_t *,
159 omapi_object_t *,
160 omapi_object_t *);
b1b7b521
TL
161isc_result_t omapi_protocol_signal_handler (omapi_object_t *,
162 const char *, va_list);
a40cbc2b
TL
163isc_result_t omapi_protocol_listener_set_value (omapi_object_t *,
164 omapi_object_t *,
165 omapi_data_string_t *,
166 omapi_typed_data_t *);
167isc_result_t omapi_protocol_listener_get_value (omapi_object_t *,
168 omapi_object_t *,
169 omapi_data_string_t *,
170 omapi_value_t **);
4bd8800e
TL
171isc_result_t omapi_protocol_listener_destroy (omapi_object_t *,
172 const char *, int);
a40cbc2b 173isc_result_t omapi_protocol_listener_signal (omapi_object_t *,
b1b7b521 174 const char *, va_list);
a40cbc2b
TL
175isc_result_t omapi_protocol_listener_stuff (omapi_object_t *,
176 omapi_object_t *,
177 omapi_object_t *);
8ec6b426 178isc_result_t omapi_protocol_send_status (omapi_object_t *, omapi_object_t *,
b1b7b521 179 isc_result_t, unsigned, const char *);
8ec6b426 180isc_result_t omapi_protocol_send_update (omapi_object_t *, omapi_object_t *,
b1b7b521 181 unsigned, omapi_object_t *);
a40cbc2b 182
d9eefc5d 183isc_result_t omapi_connect (omapi_object_t *, const char *, unsigned);
a40cbc2b
TL
184isc_result_t omapi_disconnect (omapi_object_t *, int);
185int omapi_connection_readfd (omapi_object_t *);
186int omapi_connection_writefd (omapi_object_t *);
187isc_result_t omapi_connection_reader (omapi_object_t *);
188isc_result_t omapi_connection_writer (omapi_object_t *);
189isc_result_t omapi_connection_reaper (omapi_object_t *);
190isc_result_t omapi_connection_set_value (omapi_object_t *, omapi_object_t *,
191 omapi_data_string_t *,
192 omapi_typed_data_t *);
193isc_result_t omapi_connection_get_value (omapi_object_t *, omapi_object_t *,
194 omapi_data_string_t *,
195 omapi_value_t **);
4bd8800e 196isc_result_t omapi_connection_destroy (omapi_object_t *, const char *, int);
a40cbc2b 197isc_result_t omapi_connection_signal_handler (omapi_object_t *,
b1b7b521 198 const char *, va_list);
a40cbc2b
TL
199isc_result_t omapi_connection_stuff_values (omapi_object_t *,
200 omapi_object_t *,
201 omapi_object_t *);
8ec6b426
TL
202isc_result_t omapi_connection_write_typed_data (omapi_object_t *,
203 omapi_typed_data_t *);
b1b7b521
TL
204isc_result_t omapi_connection_put_name (omapi_object_t *, const char *);
205isc_result_t omapi_connection_put_string (omapi_object_t *, const char *);
8ec6b426
TL
206isc_result_t omapi_connection_put_handle (omapi_object_t *c,
207 omapi_object_t *h);
a40cbc2b
TL
208
209
d9eefc5d 210isc_result_t omapi_listen (omapi_object_t *, unsigned, int);
a40cbc2b
TL
211isc_result_t omapi_listener_accept (omapi_object_t *);
212int omapi_listener_readfd (omapi_object_t *);
213isc_result_t omapi_accept (omapi_object_t *);
214isc_result_t omapi_listener_set_value (omapi_object_t *, omapi_object_t *,
215 omapi_data_string_t *,
216 omapi_typed_data_t *);
217isc_result_t omapi_listener_get_value (omapi_object_t *, omapi_object_t *,
218 omapi_data_string_t *,
219 omapi_value_t **);
4bd8800e 220isc_result_t omapi_listener_destroy (omapi_object_t *, const char *, int);
b1b7b521
TL
221isc_result_t omapi_listener_signal_handler (omapi_object_t *,
222 const char *, va_list);
a40cbc2b
TL
223isc_result_t omapi_listener_stuff_values (omapi_object_t *,
224 omapi_object_t *,
225 omapi_object_t *);
226
227isc_result_t omapi_register_io_object (omapi_object_t *,
228 int (*)(omapi_object_t *),
229 int (*)(omapi_object_t *),
230 isc_result_t (*)(omapi_object_t *),
231 isc_result_t (*)(omapi_object_t *),
232 isc_result_t (*)(omapi_object_t *));
233isc_result_t omapi_dispatch (struct timeval *);
234isc_result_t omapi_wait_for_completion (omapi_object_t *, struct timeval *);
6a4c4be8 235isc_result_t omapi_one_dispatch (omapi_object_t *, struct timeval *);
a40cbc2b
TL
236isc_result_t omapi_io_set_value (omapi_object_t *, omapi_object_t *,
237 omapi_data_string_t *,
238 omapi_typed_data_t *);
239isc_result_t omapi_io_get_value (omapi_object_t *, omapi_object_t *,
240 omapi_data_string_t *, omapi_value_t **);
4bd8800e 241isc_result_t omapi_io_destroy (omapi_object_t *, const char *, int);
b1b7b521 242isc_result_t omapi_io_signal_handler (omapi_object_t *, const char *, va_list);
a40cbc2b
TL
243isc_result_t omapi_io_stuff_values (omapi_object_t *,
244 omapi_object_t *,
245 omapi_object_t *);
b1b7b521
TL
246isc_result_t omapi_waiter_signal_handler (omapi_object_t *,
247 const char *, va_list);
a40cbc2b 248
4bd8800e 249isc_result_t omapi_generic_new (omapi_object_t **, const char *, int);
a40cbc2b
TL
250isc_result_t omapi_generic_set_value (omapi_object_t *, omapi_object_t *,
251 omapi_data_string_t *,
252 omapi_typed_data_t *);
253isc_result_t omapi_generic_get_value (omapi_object_t *, omapi_object_t *,
254 omapi_data_string_t *,
255 omapi_value_t **);
4bd8800e 256isc_result_t omapi_generic_destroy (omapi_object_t *, const char *, int);
b1b7b521
TL
257isc_result_t omapi_generic_signal_handler (omapi_object_t *,
258 const char *, va_list);
a40cbc2b
TL
259isc_result_t omapi_generic_stuff_values (omapi_object_t *,
260 omapi_object_t *,
261 omapi_object_t *);
262
4bd8800e 263isc_result_t omapi_message_new (omapi_object_t **, const char *, int);
a40cbc2b
TL
264isc_result_t omapi_message_set_value (omapi_object_t *, omapi_object_t *,
265 omapi_data_string_t *,
266 omapi_typed_data_t *);
267isc_result_t omapi_message_get_value (omapi_object_t *, omapi_object_t *,
268 omapi_data_string_t *,
269 omapi_value_t **);
4bd8800e 270isc_result_t omapi_message_destroy (omapi_object_t *, const char *, int);
b1b7b521
TL
271isc_result_t omapi_message_signal_handler (omapi_object_t *,
272 const char *, va_list);
a40cbc2b
TL
273isc_result_t omapi_message_stuff_values (omapi_object_t *,
274 omapi_object_t *,
275 omapi_object_t *);
276isc_result_t omapi_message_register (omapi_object_t *);
277isc_result_t omapi_message_unregister (omapi_object_t *);
8ec6b426 278isc_result_t omapi_message_process (omapi_object_t *, omapi_object_t *);
a40cbc2b
TL
279
280extern omapi_object_type_t *omapi_type_connection;
281extern omapi_object_type_t *omapi_type_listener;
282extern omapi_object_type_t *omapi_type_io_object;
283extern omapi_object_type_t *omapi_type_generic;
284extern omapi_object_type_t *omapi_type_protocol;
285extern omapi_object_type_t *omapi_type_protocol_listener;
286extern omapi_object_type_t *omapi_type_waiter;
287extern omapi_object_type_t *omapi_type_remote;
288extern omapi_object_type_t *omapi_type_message;
289
8ec6b426
TL
290extern omapi_object_type_t *omapi_object_types;
291
a40cbc2b
TL
292isc_result_t omapi_init (void);
293isc_result_t omapi_object_type_register (omapi_object_type_t **,
b1b7b521 294 const char *,
a40cbc2b
TL
295 isc_result_t (*)
296 (omapi_object_t *,
297 omapi_object_t *,
298 omapi_data_string_t *,
299 omapi_typed_data_t *),
300 isc_result_t (*)
301 (omapi_object_t *,
302 omapi_object_t *,
303 omapi_data_string_t *,
304 omapi_value_t **),
305 isc_result_t (*) (omapi_object_t *,
4bd8800e 306 const char *, int),
a40cbc2b 307 isc_result_t (*) (omapi_object_t *,
b1b7b521
TL
308 const char *,
309 va_list),
a40cbc2b
TL
310 isc_result_t (*) (omapi_object_t *,
311 omapi_object_t *,
8ec6b426
TL
312 omapi_object_t *),
313 isc_result_t (*) (omapi_object_t **,
314 omapi_object_t *,
315 omapi_object_t *),
316 isc_result_t (*) (omapi_object_t **,
47e746b7
TL
317 omapi_object_t *),
318 isc_result_t (*) (omapi_object_t *,
a40cbc2b 319 omapi_object_t *));
b1b7b521
TL
320isc_result_t omapi_signal (omapi_object_t *, const char *, ...);
321isc_result_t omapi_signal_in (omapi_object_t *, const char *, ...);
a40cbc2b
TL
322isc_result_t omapi_set_value (omapi_object_t *, omapi_object_t *,
323 omapi_data_string_t *,
324 omapi_typed_data_t *);
8ec6b426 325isc_result_t omapi_set_value_str (omapi_object_t *, omapi_object_t *,
b1b7b521 326 const char *, omapi_typed_data_t *);
8ec6b426 327isc_result_t omapi_set_boolean_value (omapi_object_t *, omapi_object_t *,
b1b7b521 328 const char *, int);
8ec6b426 329isc_result_t omapi_set_int_value (omapi_object_t *, omapi_object_t *,
b1b7b521 330 const char *, int);
8ec6b426 331isc_result_t omapi_set_object_value (omapi_object_t *, omapi_object_t *,
b1b7b521 332 const char *, omapi_object_t *);
8ec6b426 333isc_result_t omapi_set_string_value (omapi_object_t *, omapi_object_t *,
b1b7b521 334 const char *, const char *);
a40cbc2b
TL
335isc_result_t omapi_get_value (omapi_object_t *, omapi_object_t *,
336 omapi_data_string_t *,
337 omapi_value_t **);
8ec6b426 338isc_result_t omapi_get_value_str (omapi_object_t *, omapi_object_t *,
b1b7b521 339 const char *, omapi_value_t **);
a40cbc2b
TL
340isc_result_t omapi_stuff_values (omapi_object_t *,
341 omapi_object_t *,
342 omapi_object_t *);
8ec6b426
TL
343isc_result_t omapi_object_create (omapi_object_t **, omapi_object_t *,
344 omapi_object_type_t *);
345isc_result_t omapi_object_update (omapi_object_t *, omapi_object_t *,
47e746b7 346 omapi_object_t *, omapi_handle_t);
a40cbc2b 347int omapi_data_string_cmp (omapi_data_string_t *, omapi_data_string_t *);
b1b7b521
TL
348int omapi_ds_strcmp (omapi_data_string_t *, const char *);
349int omapi_td_strcmp (omapi_typed_data_t *, const char *);
a40cbc2b 350isc_result_t omapi_make_value (omapi_value_t **, omapi_data_string_t *,
4bd8800e 351 omapi_typed_data_t *, const char *, int);
a40cbc2b 352isc_result_t omapi_make_const_value (omapi_value_t **, omapi_data_string_t *,
a804d24e 353 const unsigned char *,
4bd8800e 354 unsigned, const char *, int);
a40cbc2b 355isc_result_t omapi_make_int_value (omapi_value_t **, omapi_data_string_t *,
4bd8800e 356 int, const char *, int);
8ec6b426 357isc_result_t omapi_make_handle_value (omapi_value_t **, omapi_data_string_t *,
4bd8800e 358 omapi_object_t *, const char *, int);
8ec6b426 359isc_result_t omapi_make_string_value (omapi_value_t **, omapi_data_string_t *,
4bd8800e 360 const char *, const char *, int);
a804d24e 361isc_result_t omapi_get_int_value (unsigned long *, omapi_typed_data_t *);
a40cbc2b
TL
362
363isc_result_t omapi_object_handle (omapi_handle_t *, omapi_object_t *);
364isc_result_t omapi_handle_lookup (omapi_object_t **, omapi_handle_t);
8ec6b426 365isc_result_t omapi_handle_td_lookup (omapi_object_t **, omapi_typed_data_t *);
89a93f8b 366
6a4c4be8 367isc_result_t omapi_object_reference (omapi_object_t **,
4bd8800e
TL
368 omapi_object_t *, const char *, int);
369isc_result_t omapi_object_dereference (omapi_object_t **, const char *, int);
370isc_result_t omapi_typed_data_new (const char *, int, omapi_typed_data_t **,
6a4c4be8
TL
371 omapi_datatype_t, ...);
372isc_result_t omapi_typed_data_reference (omapi_typed_data_t **,
4bd8800e
TL
373 omapi_typed_data_t *,
374 const char *, int);
6a4c4be8 375isc_result_t omapi_typed_data_dereference (omapi_typed_data_t **,
4bd8800e 376 const char *, int);
6a4c4be8 377isc_result_t omapi_data_string_new (omapi_data_string_t **,
4bd8800e 378 unsigned, const char *, int);
6a4c4be8 379isc_result_t omapi_data_string_reference (omapi_data_string_t **,
4bd8800e
TL
380 omapi_data_string_t *,
381 const char *, int);
6a4c4be8 382isc_result_t omapi_data_string_dereference (omapi_data_string_t **,
4bd8800e
TL
383 const char *, int);
384isc_result_t omapi_value_new (omapi_value_t **, const char *, int);
6a4c4be8 385isc_result_t omapi_value_reference (omapi_value_t **,
4bd8800e
TL
386 omapi_value_t *, const char *, int);
387isc_result_t omapi_value_dereference (omapi_value_t **, const char *, int);
6a4c4be8 388
4bd8800e
TL
389void * dmalloc (unsigned, const char *, int);
390void dfree (void *, const char *, int);
391#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)
392void dmalloc_reuse (void *, const char *, int, int);
393void dmalloc_dump_outstanding (void);
394#define MDL __FILE__, __LINE__
395#else
396#define dmalloc_reuse(x,y,l,z)
397#define MDL (char *)0, __LINE__
398#endif
399#if defined (DEBUG_RC_HISTORY)
400void dump_rc_history (void);
401#endif
c859d3b8 402#endif /* _OMAPIP_H_ */