tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / dhcp / common / comapi.c
blob5a3b883f29132034f02e0066272d74070f46c2c5
1 /* omapi.c
3 OMAPI object interfaces for the DHCP server. */
5 /*
6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1999-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 /* Many, many thanks to Brian Murrell and BCtel for this code - BCtel
36 provided the funding that resulted in this code and the entire
37 OMAPI support library being written, and Brian helped brainstorm
38 and refine the requirements. To the extent that this code is
39 useful, you have Brian and BCtel to thank. Any limitations in the
40 code are a result of mistakes on my part. -- Ted Lemon */
42 #if 0
43 static char copyright[] =
44 "$Id$ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
45 #endif
47 #include "dhcpd.h"
48 #include <omapip/omapip_p.h>
50 OMAPI_OBJECT_ALLOC (subnet, struct subnet, dhcp_type_subnet)
51 OMAPI_OBJECT_ALLOC (shared_network, struct shared_network,
52 dhcp_type_shared_network)
53 OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
54 OMAPI_OBJECT_ALLOC (dhcp_control, dhcp_control_object_t, dhcp_type_control)
56 omapi_object_type_t *dhcp_type_interface;
57 omapi_object_type_t *dhcp_type_group;
58 omapi_object_type_t *dhcp_type_shared_network;
59 omapi_object_type_t *dhcp_type_subnet;
60 omapi_object_type_t *dhcp_type_control;
61 dhcp_control_object_t *dhcp_control_object;
63 void dhcp_common_objects_setup ()
65 isc_result_t status;
67 status = omapi_object_type_register (&dhcp_type_control,
68 "control",
69 dhcp_control_set_value,
70 dhcp_control_get_value,
71 dhcp_control_destroy,
72 dhcp_control_signal_handler,
73 dhcp_control_stuff_values,
74 dhcp_control_lookup,
75 dhcp_control_create,
76 dhcp_control_remove, 0, 0, 0,
77 sizeof (dhcp_control_object_t),
78 0, RC_MISC);
79 if (status != ISC_R_SUCCESS)
80 log_fatal ("Can't register control object type: %s",
81 isc_result_totext (status));
82 status = dhcp_control_allocate (&dhcp_control_object, MDL);
83 if (status != ISC_R_SUCCESS)
84 log_fatal ("Can't make initial control object: %s",
85 isc_result_totext (status));
86 dhcp_control_object -> state = server_startup;
88 status = omapi_object_type_register (&dhcp_type_group,
89 "group",
90 dhcp_group_set_value,
91 dhcp_group_get_value,
92 dhcp_group_destroy,
93 dhcp_group_signal_handler,
94 dhcp_group_stuff_values,
95 dhcp_group_lookup,
96 dhcp_group_create,
97 dhcp_group_remove, 0, 0, 0,
98 sizeof (struct group_object), 0,
99 RC_MISC);
100 if (status != ISC_R_SUCCESS)
101 log_fatal ("Can't register group object type: %s",
102 isc_result_totext (status));
104 status = omapi_object_type_register (&dhcp_type_subnet,
105 "subnet",
106 dhcp_subnet_set_value,
107 dhcp_subnet_get_value,
108 dhcp_subnet_destroy,
109 dhcp_subnet_signal_handler,
110 dhcp_subnet_stuff_values,
111 dhcp_subnet_lookup,
112 dhcp_subnet_create,
113 dhcp_subnet_remove, 0, 0, 0,
114 sizeof (struct subnet), 0,
115 RC_MISC);
116 if (status != ISC_R_SUCCESS)
117 log_fatal ("Can't register subnet object type: %s",
118 isc_result_totext (status));
120 status = omapi_object_type_register
121 (&dhcp_type_shared_network,
122 "shared-network",
123 dhcp_shared_network_set_value,
124 dhcp_shared_network_get_value,
125 dhcp_shared_network_destroy,
126 dhcp_shared_network_signal_handler,
127 dhcp_shared_network_stuff_values,
128 dhcp_shared_network_lookup,
129 dhcp_shared_network_create,
130 dhcp_shared_network_remove, 0, 0, 0,
131 sizeof (struct shared_network), 0, RC_MISC);
132 if (status != ISC_R_SUCCESS)
133 log_fatal ("Can't register shared network object type: %s",
134 isc_result_totext (status));
136 interface_setup ();
139 isc_result_t dhcp_group_set_value (omapi_object_t *h,
140 omapi_object_t *id,
141 omapi_data_string_t *name,
142 omapi_typed_data_t *value)
144 struct group_object *group;
145 isc_result_t status;
146 // int foo;
148 if (h -> type != dhcp_type_group)
149 return ISC_R_INVALIDARG;
150 group = (struct group_object *)h;
152 /* XXX For now, we can only set these values on new group objects.
153 XXX Soon, we need to be able to update group objects. */
154 if (!omapi_ds_strcmp (name, "name")) {
155 if (group -> name)
156 return ISC_R_EXISTS;
157 if (value -> type == omapi_datatype_data ||
158 value -> type == omapi_datatype_string) {
159 group -> name = dmalloc (value -> u.buffer.len + 1,
160 MDL);
161 if (!group -> name)
162 return ISC_R_NOMEMORY;
163 memcpy (group -> name,
164 value -> u.buffer.value,
165 value -> u.buffer.len);
166 group -> name [value -> u.buffer.len] = 0;
167 } else
168 return ISC_R_INVALIDARG;
169 return ISC_R_SUCCESS;
172 if (!omapi_ds_strcmp (name, "statements")) {
173 if (group -> group && group -> group -> statements)
174 return ISC_R_EXISTS;
175 if (!group -> group) {
176 if (!clone_group (&group -> group, root_group, MDL))
177 return ISC_R_NOMEMORY;
179 if (value -> type == omapi_datatype_data ||
180 value -> type == omapi_datatype_string) {
181 struct parse *parse;
182 int lose = 0;
183 parse = (struct parse *)0;
184 status = new_parse (&parse, -1,
185 (char *)value -> u.buffer.value,
186 value -> u.buffer.len,
187 "network client", 0);
188 if (status != ISC_R_SUCCESS)
189 return status;
190 if (!(parse_executable_statements
191 (&group -> group -> statements, parse, &lose,
192 context_any))) {
193 end_parse (&parse);
194 return ISC_R_BADPARSE;
196 end_parse (&parse);
197 return ISC_R_SUCCESS;
198 } else
199 return ISC_R_INVALIDARG;
202 /* Try to find some inner object that can take the value. */
203 if (h -> inner && h -> inner -> type -> set_value) {
204 status = ((*(h -> inner -> type -> set_value))
205 (h -> inner, id, name, value));
206 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
207 return status;
210 return ISC_R_NOTFOUND;
214 isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
215 omapi_data_string_t *name,
216 omapi_value_t **value)
218 struct group_object *group;
219 isc_result_t status;
220 // struct data_string ip_addrs;
222 if (h -> type != dhcp_type_group)
223 return ISC_R_INVALIDARG;
224 group = (struct group_object *)h;
226 if (!omapi_ds_strcmp (name, "name"))
227 return omapi_make_string_value (value,
228 name, group -> name, MDL);
230 /* Try to find some inner object that can take the value. */
231 if (h -> inner && h -> inner -> type -> get_value) {
232 status = ((*(h -> inner -> type -> get_value))
233 (h -> inner, id, name, value));
234 if (status == ISC_R_SUCCESS)
235 return status;
237 return ISC_R_NOTFOUND;
240 isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
242 struct group_object *group, *t;
243 // isc_result_t status;
245 if (h -> type != dhcp_type_group)
246 return ISC_R_INVALIDARG;
247 group = (struct group_object *)h;
249 if (group -> name) {
250 if (group_name_hash) {
251 t = (struct group_object *)0;
252 if (group_hash_lookup (&t, group_name_hash,
253 group -> name,
254 strlen (group -> name), MDL)) {
255 group_hash_delete (group_name_hash,
256 group -> name,
257 strlen (group -> name),
258 MDL);
259 group_object_dereference (&t, MDL);
262 dfree (group -> name, file, line);
263 group -> name = (char *)0;
265 if (group -> group)
266 group_dereference (&group -> group, MDL);
268 return ISC_R_SUCCESS;
271 isc_result_t dhcp_group_signal_handler (omapi_object_t *h,
272 const char *name, va_list ap)
274 struct group_object *group;
275 // struct group_object *t;
276 isc_result_t status;
277 int updatep = 0;
279 if (h -> type != dhcp_type_group)
280 return ISC_R_INVALIDARG;
281 group = (struct group_object *)h;
283 if (!strcmp (name, "updated")) {
284 /* A group object isn't valid if a subgroup hasn't yet been
285 associated with it. */
286 if (!group -> group)
287 return ISC_R_INVALIDARG;
289 /* Group objects always have to have names. */
290 if (!group -> name) {
291 char hnbuf [64];
292 sprintf (hnbuf, "ng%08lx%08lx",
293 (unsigned long)cur_time,
294 (unsigned long)group);
295 group -> name = dmalloc (strlen (hnbuf) + 1, MDL);
296 if (!group -> name)
297 return ISC_R_NOMEMORY;
298 strcpy (group -> name, hnbuf);
301 supersede_group (group, 1);
302 updatep = 1;
305 /* Try to find some inner object that can take the value. */
306 if (h -> inner && h -> inner -> type -> get_value) {
307 status = ((*(h -> inner -> type -> signal_handler))
308 (h -> inner, name, ap));
309 if (status == ISC_R_SUCCESS)
310 return status;
312 if (updatep)
313 return ISC_R_SUCCESS;
314 return ISC_R_NOTFOUND;
317 isc_result_t dhcp_group_stuff_values (omapi_object_t *c,
318 omapi_object_t *id,
319 omapi_object_t *h)
321 struct group_object *group;
322 isc_result_t status;
324 if (h -> type != dhcp_type_group)
325 return ISC_R_INVALIDARG;
326 group = (struct group_object *)h;
328 /* Write out all the values. */
329 if (group -> name) {
330 status = omapi_connection_put_name (c, "name");
331 if (status != ISC_R_SUCCESS)
332 return status;
333 status = omapi_connection_put_string (c, group -> name);
334 if (status != ISC_R_SUCCESS)
335 return status;
338 /* Write out the inner object, if any. */
339 if (h -> inner && h -> inner -> type -> stuff_values) {
340 status = ((*(h -> inner -> type -> stuff_values))
341 (c, id, h -> inner));
342 if (status == ISC_R_SUCCESS)
343 return status;
346 return ISC_R_SUCCESS;
349 isc_result_t dhcp_group_lookup (omapi_object_t **lp,
350 omapi_object_t *id, omapi_object_t *ref)
352 omapi_value_t *tv = (omapi_value_t *)0;
353 isc_result_t status;
354 struct group_object *group;
356 if (!ref)
357 return ISC_R_NOKEYS;
359 /* First see if we were sent a handle. */
360 status = omapi_get_value_str (ref, id, "handle", &tv);
361 if (status == ISC_R_SUCCESS) {
362 status = omapi_handle_td_lookup (lp, tv -> value);
364 omapi_value_dereference (&tv, MDL);
365 if (status != ISC_R_SUCCESS)
366 return status;
368 /* Don't return the object if the type is wrong. */
369 if ((*lp) -> type != dhcp_type_group) {
370 omapi_object_dereference (lp, MDL);
371 return ISC_R_INVALIDARG;
375 /* Now look for a name. */
376 status = omapi_get_value_str (ref, id, "name", &tv);
377 if (status == ISC_R_SUCCESS) {
378 group = (struct group_object *)0;
379 if (group_name_hash &&
380 group_hash_lookup (&group, group_name_hash,
381 (const char *)
382 tv -> value -> u.buffer.value,
383 tv -> value -> u.buffer.len, MDL)) {
384 omapi_value_dereference (&tv, MDL);
386 if (*lp && *lp != (omapi_object_t *)group) {
387 group_object_dereference (&group, MDL);
388 omapi_object_dereference (lp, MDL);
389 return ISC_R_KEYCONFLICT;
390 } else if (!*lp) {
391 /* XXX fix so that hash lookup itself creates
392 XXX the reference. */
393 omapi_object_reference (lp,
394 (omapi_object_t *)group,
395 MDL);
396 group_object_dereference (&group, MDL);
398 } else if (!*lp)
399 return ISC_R_NOTFOUND;
402 /* If we get to here without finding a group, no valid key was
403 specified. */
404 if (!*lp)
405 return ISC_R_NOKEYS;
407 if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) {
408 omapi_object_dereference (lp, MDL);
409 return ISC_R_NOTFOUND;
411 return ISC_R_SUCCESS;
414 isc_result_t dhcp_group_create (omapi_object_t **lp,
415 omapi_object_t *id)
417 struct group_object *group;
418 isc_result_t status;
419 group = (struct group_object *)0;
421 status = group_object_allocate (&group, MDL);
422 if (status != ISC_R_SUCCESS)
423 return status;
424 group -> flags = GROUP_OBJECT_DYNAMIC;
425 status = omapi_object_reference (lp, (omapi_object_t *)group, MDL);
426 group_object_dereference (&group, MDL);
427 return status;
430 isc_result_t dhcp_group_remove (omapi_object_t *lp,
431 omapi_object_t *id)
433 struct group_object *group;
434 isc_result_t status;
435 if (lp -> type != dhcp_type_group)
436 return ISC_R_INVALIDARG;
437 group = (struct group_object *)lp;
439 group -> flags |= GROUP_OBJECT_DELETED;
440 if (group_write_hook) {
441 if (!(*group_write_hook) (group))
442 return ISC_R_IOERROR;
445 status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
447 return status;
450 isc_result_t dhcp_control_set_value (omapi_object_t *h,
451 omapi_object_t *id,
452 omapi_data_string_t *name,
453 omapi_typed_data_t *value)
455 dhcp_control_object_t *control;
456 isc_result_t status;
457 // int foo;
458 unsigned long newstate;
460 if (h -> type != dhcp_type_control)
461 return ISC_R_INVALIDARG;
462 control = (dhcp_control_object_t *)h;
464 if (!omapi_ds_strcmp (name, "state")) {
465 status = omapi_get_int_value (&newstate, value);
466 if (status != ISC_R_SUCCESS)
467 return status;
468 status = dhcp_set_control_state (control -> state, newstate);
469 if (status == ISC_R_SUCCESS)
470 control -> state = value -> u.integer;
471 return status;
474 /* Try to find some inner object that can take the value. */
475 if (h -> inner && h -> inner -> type -> set_value) {
476 status = ((*(h -> inner -> type -> set_value))
477 (h -> inner, id, name, value));
478 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
479 return status;
482 return ISC_R_NOTFOUND;
486 isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,
487 omapi_data_string_t *name,
488 omapi_value_t **value)
490 dhcp_control_object_t *control;
491 isc_result_t status;
492 // struct data_string ip_addrs;
494 if (h -> type != dhcp_type_control)
495 return ISC_R_INVALIDARG;
496 control = (dhcp_control_object_t *)h;
498 if (!omapi_ds_strcmp (name, "state"))
499 return omapi_make_int_value (value,
500 name, (int)control -> state, MDL);
502 /* Try to find some inner object that can take the value. */
503 if (h -> inner && h -> inner -> type -> get_value) {
504 status = ((*(h -> inner -> type -> get_value))
505 (h -> inner, id, name, value));
506 if (status == ISC_R_SUCCESS)
507 return status;
509 return ISC_R_NOTFOUND;
512 isc_result_t dhcp_control_destroy (omapi_object_t *h,
513 const char *file, int line)
515 // dhcp_control_object_t *control, *t;
516 // isc_result_t status;
518 if (h -> type != dhcp_type_control)
519 return ISC_R_INVALIDARG;
521 /* Can't destroy the control object. */
522 return ISC_R_NOPERM;
525 isc_result_t dhcp_control_signal_handler (omapi_object_t *h,
526 const char *name, va_list ap)
528 isc_result_t status;
530 if (h -> type != dhcp_type_control)
531 return ISC_R_INVALIDARG;
533 /* Try to find some inner object that can take the value. */
534 if (h -> inner && h -> inner -> type -> get_value) {
535 status = ((*(h -> inner -> type -> signal_handler))
536 (h -> inner, name, ap));
537 if (status == ISC_R_SUCCESS)
538 return status;
540 return ISC_R_NOTFOUND;
543 isc_result_t dhcp_control_stuff_values (omapi_object_t *c,
544 omapi_object_t *id,
545 omapi_object_t *h)
547 dhcp_control_object_t *control;
548 isc_result_t status;
550 if (h -> type != dhcp_type_control)
551 return ISC_R_INVALIDARG;
552 control = (dhcp_control_object_t *)h;
554 /* Write out all the values. */
555 status = omapi_connection_put_name (c, "state");
556 if (status != ISC_R_SUCCESS)
557 return status;
558 status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));
559 if (status != ISC_R_SUCCESS)
560 return status;
561 status = omapi_connection_put_uint32 (c, control -> state);
562 if (status != ISC_R_SUCCESS)
563 return status;
565 /* Write out the inner object, if any. */
566 if (h -> inner && h -> inner -> type -> stuff_values) {
567 status = ((*(h -> inner -> type -> stuff_values))
568 (c, id, h -> inner));
569 if (status == ISC_R_SUCCESS)
570 return status;
573 return ISC_R_SUCCESS;
576 isc_result_t dhcp_control_lookup (omapi_object_t **lp,
577 omapi_object_t *id, omapi_object_t *ref)
579 omapi_value_t *tv = (omapi_value_t *)0;
580 isc_result_t status;
581 // dhcp_control_object_t *control;
583 /* First see if we were sent a handle. */
584 if (ref) {
585 status = omapi_get_value_str (ref, id, "handle", &tv);
586 if (status == ISC_R_SUCCESS) {
587 status = omapi_handle_td_lookup (lp, tv -> value);
589 omapi_value_dereference (&tv, MDL);
590 if (status != ISC_R_SUCCESS)
591 return status;
593 /* Don't return the object if the type is wrong. */
594 if ((*lp) -> type != dhcp_type_control) {
595 omapi_object_dereference (lp, MDL);
596 return ISC_R_INVALIDARG;
601 /* Otherwise, stop playing coy - there's only one control object,
602 so we can just return it. */
603 dhcp_control_reference ((dhcp_control_object_t **)lp,
604 dhcp_control_object, MDL);
605 return ISC_R_SUCCESS;
608 isc_result_t dhcp_control_create (omapi_object_t **lp,
609 omapi_object_t *id)
611 /* Can't create a control object - there can be only one. */
612 return ISC_R_NOPERM;
615 isc_result_t dhcp_control_remove (omapi_object_t *lp,
616 omapi_object_t *id)
618 /* Form is emptiness; emptiness form. The control object
619 cannot go out of existance. */
620 return ISC_R_NOPERM;
623 isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
624 omapi_object_t *id,
625 omapi_data_string_t *name,
626 omapi_typed_data_t *value)
628 isc_result_t status;
629 // int foo;
631 if (h -> type != dhcp_type_subnet)
632 return ISC_R_INVALIDARG;
634 /* No values to set yet. */
636 /* Try to find some inner object that can take the value. */
637 if (h -> inner && h -> inner -> type -> set_value) {
638 status = ((*(h -> inner -> type -> set_value))
639 (h -> inner, id, name, value));
640 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
641 return status;
644 return ISC_R_NOTFOUND;
648 isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
649 omapi_data_string_t *name,
650 omapi_value_t **value)
652 isc_result_t status;
654 if (h -> type != dhcp_type_subnet)
655 return ISC_R_INVALIDARG;
657 /* No values to get yet. */
659 /* Try to find some inner object that can provide the value. */
660 if (h -> inner && h -> inner -> type -> get_value) {
661 status = ((*(h -> inner -> type -> get_value))
662 (h -> inner, id, name, value));
663 if (status == ISC_R_SUCCESS)
664 return status;
666 return ISC_R_NOTFOUND;
669 isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
671 #if defined (DEBUG_MEMORY_LEAKAGE) || \
672 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
673 struct subnet *subnet;
674 #endif
675 // isc_result_t status;
677 if (h -> type != dhcp_type_subnet)
678 return ISC_R_INVALIDARG;
679 #if defined (DEBUG_MEMORY_LEAKAGE) || \
680 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
681 subnet = (struct subnet *)h;
683 if (subnet -> next_subnet)
684 subnet_dereference (&subnet -> next_subnet, file, line);
685 if (subnet -> next_sibling)
686 subnet_dereference (&subnet -> next_sibling, file, line);
687 if (subnet -> shared_network)
688 shared_network_dereference (&subnet -> shared_network,
689 file, line);
690 if (subnet -> interface)
691 interface_dereference (&subnet -> interface, file, line);
692 if (subnet -> group)
693 group_dereference (&subnet -> group, file, line);
694 #endif
696 return ISC_R_SUCCESS;
699 isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h,
700 const char *name, va_list ap)
702 isc_result_t status;
703 int updatep = 0;
705 if (h -> type != dhcp_type_subnet)
706 return ISC_R_INVALIDARG;
708 /* Can't write subnets yet. */
710 /* Try to find some inner object that can take the value. */
711 if (h -> inner && h -> inner -> type -> get_value) {
712 status = ((*(h -> inner -> type -> signal_handler))
713 (h -> inner, name, ap));
714 if (status == ISC_R_SUCCESS)
715 return status;
717 if (updatep)
718 return ISC_R_SUCCESS;
719 return ISC_R_NOTFOUND;
722 isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c,
723 omapi_object_t *id,
724 omapi_object_t *h)
726 isc_result_t status;
728 if (h -> type != dhcp_type_subnet)
729 return ISC_R_INVALIDARG;
731 /* Can't stuff subnet values yet. */
733 /* Write out the inner object, if any. */
734 if (h -> inner && h -> inner -> type -> stuff_values) {
735 status = ((*(h -> inner -> type -> stuff_values))
736 (c, id, h -> inner));
737 if (status == ISC_R_SUCCESS)
738 return status;
741 return ISC_R_SUCCESS;
744 isc_result_t dhcp_subnet_lookup (omapi_object_t **lp,
745 omapi_object_t *id,
746 omapi_object_t *ref)
748 // omapi_value_t *tv = (omapi_value_t *)0;
749 // isc_result_t status;
750 // struct subnet *subnet;
752 /* Can't look up subnets yet. */
754 /* If we get to here without finding a subnet, no valid key was
755 specified. */
756 if (!*lp)
757 return ISC_R_NOKEYS;
758 return ISC_R_SUCCESS;
761 isc_result_t dhcp_subnet_create (omapi_object_t **lp,
762 omapi_object_t *id)
764 return ISC_R_NOTIMPLEMENTED;
767 isc_result_t dhcp_subnet_remove (omapi_object_t *lp,
768 omapi_object_t *id)
770 return ISC_R_NOTIMPLEMENTED;
773 isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
774 omapi_object_t *id,
775 omapi_data_string_t *name,
776 omapi_typed_data_t *value)
778 isc_result_t status;
779 // int foo;
781 if (h -> type != dhcp_type_shared_network)
782 return ISC_R_INVALIDARG;
784 /* No values to set yet. */
786 /* Try to find some inner object that can take the value. */
787 if (h -> inner && h -> inner -> type -> set_value) {
788 status = ((*(h -> inner -> type -> set_value))
789 (h -> inner, id, name, value));
790 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
791 return status;
794 return ISC_R_NOTFOUND;
798 isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
799 omapi_object_t *id,
800 omapi_data_string_t *name,
801 omapi_value_t **value)
803 isc_result_t status;
805 if (h -> type != dhcp_type_shared_network)
806 return ISC_R_INVALIDARG;
808 /* No values to get yet. */
810 /* Try to find some inner object that can provide the value. */
811 if (h -> inner && h -> inner -> type -> get_value) {
812 status = ((*(h -> inner -> type -> get_value))
813 (h -> inner, id, name, value));
814 if (status == ISC_R_SUCCESS)
815 return status;
817 return ISC_R_NOTFOUND;
820 isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
821 const char *file, int line)
823 #if defined (DEBUG_MEMORY_LEAKAGE) || \
824 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
825 struct shared_network *shared_network;
826 #endif
827 // isc_result_t status;
829 if (h -> type != dhcp_type_shared_network)
830 return ISC_R_INVALIDARG;
831 #if defined (DEBUG_MEMORY_LEAKAGE) || \
832 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
833 shared_network = (struct shared_network *)h;
835 if (shared_network -> next)
836 shared_network_dereference (&shared_network -> next,
837 file, line);
838 if (shared_network -> name) {
839 dfree (shared_network -> name, file, line);
840 shared_network -> name = 0;
842 if (shared_network -> subnets)
843 subnet_dereference (&shared_network -> subnets, file, line);
844 if (shared_network -> interface)
845 interface_dereference (&shared_network -> interface,
846 file, line);
847 if (shared_network -> pools)
848 omapi_object_dereference ((omapi_object_t **)
849 &shared_network -> pools, file, line);
850 if (shared_network -> group)
851 group_dereference (&shared_network -> group, file, line);
852 #if defined (FAILOVER_PROTOCOL)
853 if (shared_network -> failover_peer)
854 omapi_object_dereference ((omapi_object_t **)
855 &shared_network -> failover_peer,
856 file, line);
857 #endif
858 #endif /* DEBUG_MEMORY_LEAKAGE */
860 return ISC_R_SUCCESS;
863 isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h,
864 const char *name,
865 va_list ap)
867 isc_result_t status;
868 int updatep = 0;
870 if (h -> type != dhcp_type_shared_network)
871 return ISC_R_INVALIDARG;
873 /* Can't write shared_networks yet. */
875 /* Try to find some inner object that can take the value. */
876 if (h -> inner && h -> inner -> type -> get_value) {
877 status = ((*(h -> inner -> type -> signal_handler))
878 (h -> inner, name, ap));
879 if (status == ISC_R_SUCCESS)
880 return status;
882 if (updatep)
883 return ISC_R_SUCCESS;
884 return ISC_R_NOTFOUND;
887 isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c,
888 omapi_object_t *id,
889 omapi_object_t *h)
891 isc_result_t status;
893 if (h -> type != dhcp_type_shared_network)
894 return ISC_R_INVALIDARG;
896 /* Can't stuff shared_network values yet. */
898 /* Write out the inner object, if any. */
899 if (h -> inner && h -> inner -> type -> stuff_values) {
900 status = ((*(h -> inner -> type -> stuff_values))
901 (c, id, h -> inner));
902 if (status == ISC_R_SUCCESS)
903 return status;
906 return ISC_R_SUCCESS;
909 isc_result_t dhcp_shared_network_lookup (omapi_object_t **lp,
910 omapi_object_t *id,
911 omapi_object_t *ref)
913 // omapi_value_t *tv = (omapi_value_t *)0;
914 // isc_result_t status;
915 // struct shared_network *shared_network;
917 /* Can't look up shared_networks yet. */
919 /* If we get to here without finding a shared_network, no valid key was
920 specified. */
921 if (!*lp)
922 return ISC_R_NOKEYS;
923 return ISC_R_SUCCESS;
926 isc_result_t dhcp_shared_network_create (omapi_object_t **lp,
927 omapi_object_t *id)
929 return ISC_R_NOTIMPLEMENTED;
932 isc_result_t dhcp_shared_network_remove (omapi_object_t *lp,
933 omapi_object_t *id)
935 return ISC_R_NOTIMPLEMENTED;