3 OMAPI object interfaces for the DHCP server. */
6 * Copyright (c) 1999-2002 Internet Software Consortium.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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
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''.
44 /* Many, many thanks to Brian Murrell and BCtel for this code - BCtel
45 provided the funding that resulted in this code and the entire
46 OMAPI support library being written, and Brian helped brainstorm
47 and refine the requirements. To the extent that this code is
48 useful, you have Brian and BCtel to thank. Any limitations in the
49 code are a result of mistakes on my part. -- Ted Lemon */
52 static char copyright[] =
53 "$Id: comapi.c,v 1.9.2.6 2002/11/17 02:26:56 dhankins Exp $ Copyright (c) 1999-2002 The Internet Software Consortium. All rights reserved.\n";
57 #include <omapip/omapip_p.h>
59 OMAPI_OBJECT_ALLOC (subnet, struct subnet, dhcp_type_subnet)
60 OMAPI_OBJECT_ALLOC (shared_network, struct shared_network,
61 dhcp_type_shared_network)
62 OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
63 OMAPI_OBJECT_ALLOC (dhcp_control, dhcp_control_object_t, dhcp_type_control)
65 omapi_object_type_t *dhcp_type_interface;
66 omapi_object_type_t *dhcp_type_group;
67 omapi_object_type_t *dhcp_type_shared_network;
68 omapi_object_type_t *dhcp_type_subnet;
69 omapi_object_type_t *dhcp_type_control;
70 dhcp_control_object_t *dhcp_control_object;
72 void dhcp_common_objects_setup ()
76 status = omapi_object_type_register (&dhcp_type_control,
78 dhcp_control_set_value,
79 dhcp_control_get_value,
81 dhcp_control_signal_handler,
82 dhcp_control_stuff_values,
85 dhcp_control_remove, 0, 0, 0,
86 sizeof (dhcp_control_object_t),
88 if (status != ISC_R_SUCCESS)
89 log_fatal ("Can't register control object type: %s",
90 isc_result_totext (status));
91 status = dhcp_control_allocate (&dhcp_control_object, MDL);
92 if (status != ISC_R_SUCCESS)
93 log_fatal ("Can't make initial control object: %s",
94 isc_result_totext (status));
95 dhcp_control_object -> state = server_startup;
97 status = omapi_object_type_register (&dhcp_type_group,
100 dhcp_group_get_value,
102 dhcp_group_signal_handler,
103 dhcp_group_stuff_values,
106 dhcp_group_remove, 0, 0, 0,
107 sizeof (struct group_object), 0,
109 if (status != ISC_R_SUCCESS)
110 log_fatal ("Can't register group object type: %s",
111 isc_result_totext (status));
113 status = omapi_object_type_register (&dhcp_type_subnet,
115 dhcp_subnet_set_value,
116 dhcp_subnet_get_value,
118 dhcp_subnet_signal_handler,
119 dhcp_subnet_stuff_values,
122 dhcp_subnet_remove, 0, 0, 0,
123 sizeof (struct subnet), 0,
125 if (status != ISC_R_SUCCESS)
126 log_fatal ("Can't register subnet object type: %s",
127 isc_result_totext (status));
129 status = omapi_object_type_register
130 (&dhcp_type_shared_network,
132 dhcp_shared_network_set_value,
133 dhcp_shared_network_get_value,
134 dhcp_shared_network_destroy,
135 dhcp_shared_network_signal_handler,
136 dhcp_shared_network_stuff_values,
137 dhcp_shared_network_lookup,
138 dhcp_shared_network_create,
139 dhcp_shared_network_remove, 0, 0, 0,
140 sizeof (struct shared_network), 0, RC_MISC);
141 if (status != ISC_R_SUCCESS)
142 log_fatal ("Can't register shared network object type: %s",
143 isc_result_totext (status));
148 isc_result_t dhcp_group_set_value (omapi_object_t *h,
150 omapi_data_string_t *name,
151 omapi_typed_data_t *value)
153 struct group_object *group;
157 if (h -> type != dhcp_type_group)
158 return ISC_R_INVALIDARG;
159 group = (struct group_object *)h;
161 /* XXX For now, we can only set these values on new group objects.
162 XXX Soon, we need to be able to update group objects. */
163 if (!omapi_ds_strcmp (name, "name")) {
166 if (value -> type == omapi_datatype_data ||
167 value -> type == omapi_datatype_string) {
168 group -> name = dmalloc (value -> u.buffer.len + 1,
171 return ISC_R_NOMEMORY;
172 memcpy (group -> name,
173 value -> u.buffer.value,
174 value -> u.buffer.len);
175 group -> name [value -> u.buffer.len] = 0;
177 return ISC_R_INVALIDARG;
178 return ISC_R_SUCCESS;
181 if (!omapi_ds_strcmp (name, "statements")) {
182 if (group -> group && group -> group -> statements)
184 if (!group -> group) {
185 if (!clone_group (&group -> group, root_group, MDL))
186 return ISC_R_NOMEMORY;
188 if (value -> type == omapi_datatype_data ||
189 value -> type == omapi_datatype_string) {
192 parse = (struct parse *)0;
193 status = new_parse (&parse, -1,
194 (char *)value -> u.buffer.value,
195 value -> u.buffer.len,
196 "network client", 0);
197 if (status != ISC_R_SUCCESS)
199 if (!(parse_executable_statements
200 (&group -> group -> statements, parse, &lose,
203 return ISC_R_BADPARSE;
206 return ISC_R_SUCCESS;
208 return ISC_R_INVALIDARG;
211 /* Try to find some inner object that can take the value. */
212 if (h -> inner && h -> inner -> type -> set_value) {
213 status = ((*(h -> inner -> type -> set_value))
214 (h -> inner, id, name, value));
215 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
219 return ISC_R_NOTFOUND;
223 isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
224 omapi_data_string_t *name,
225 omapi_value_t **value)
227 struct group_object *group;
229 struct data_string ip_addrs;
231 if (h -> type != dhcp_type_group)
232 return ISC_R_INVALIDARG;
233 group = (struct group_object *)h;
235 if (!omapi_ds_strcmp (name, "name"))
236 return omapi_make_string_value (value,
237 name, group -> name, MDL);
239 /* Try to find some inner object that can take the value. */
240 if (h -> inner && h -> inner -> type -> get_value) {
241 status = ((*(h -> inner -> type -> get_value))
242 (h -> inner, id, name, value));
243 if (status == ISC_R_SUCCESS)
246 return ISC_R_NOTFOUND;
249 isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
251 struct group_object *group, *t;
254 if (h -> type != dhcp_type_group)
255 return ISC_R_INVALIDARG;
256 group = (struct group_object *)h;
259 if (group_name_hash) {
260 t = (struct group_object *)0;
261 if (group_hash_lookup (&t, group_name_hash,
263 strlen (group -> name), MDL)) {
264 group_hash_delete (group_name_hash,
266 strlen (group -> name),
268 group_object_dereference (&t, MDL);
271 dfree (group -> name, file, line);
272 group -> name = (char *)0;
275 group_dereference (&group -> group, MDL);
277 return ISC_R_SUCCESS;
280 isc_result_t dhcp_group_signal_handler (omapi_object_t *h,
281 const char *name, va_list ap)
283 struct group_object *group, *t;
287 if (h -> type != dhcp_type_group)
288 return ISC_R_INVALIDARG;
289 group = (struct group_object *)h;
291 if (!strcmp (name, "updated")) {
292 /* A group object isn't valid if a subgroup hasn't yet been
293 associated with it. */
295 return ISC_R_INVALIDARG;
297 /* Group objects always have to have names. */
298 if (!group -> name) {
300 sprintf (hnbuf, "ng%08lx%08lx",
301 (unsigned long)cur_time,
302 (unsigned long)group);
303 group -> name = dmalloc (strlen (hnbuf) + 1, MDL);
305 return ISC_R_NOMEMORY;
306 strcpy (group -> name, hnbuf);
309 supersede_group (group, 1);
313 /* Try to find some inner object that can take the value. */
314 if (h -> inner && h -> inner -> type -> get_value) {
315 status = ((*(h -> inner -> type -> signal_handler))
316 (h -> inner, name, ap));
317 if (status == ISC_R_SUCCESS)
321 return ISC_R_SUCCESS;
322 return ISC_R_NOTFOUND;
325 isc_result_t dhcp_group_stuff_values (omapi_object_t *c,
329 struct group_object *group;
332 if (h -> type != dhcp_type_group)
333 return ISC_R_INVALIDARG;
334 group = (struct group_object *)h;
336 /* Write out all the values. */
338 status = omapi_connection_put_name (c, "name");
339 if (status != ISC_R_SUCCESS)
341 status = omapi_connection_put_string (c, group -> name);
342 if (status != ISC_R_SUCCESS)
346 /* Write out the inner object, if any. */
347 if (h -> inner && h -> inner -> type -> stuff_values) {
348 status = ((*(h -> inner -> type -> stuff_values))
349 (c, id, h -> inner));
350 if (status == ISC_R_SUCCESS)
354 return ISC_R_SUCCESS;
357 isc_result_t dhcp_group_lookup (omapi_object_t **lp,
358 omapi_object_t *id, omapi_object_t *ref)
360 omapi_value_t *tv = (omapi_value_t *)0;
362 struct group_object *group;
367 /* First see if we were sent a handle. */
368 status = omapi_get_value_str (ref, id, "handle", &tv);
369 if (status == ISC_R_SUCCESS) {
370 status = omapi_handle_td_lookup (lp, tv -> value);
372 omapi_value_dereference (&tv, MDL);
373 if (status != ISC_R_SUCCESS)
376 /* Don't return the object if the type is wrong. */
377 if ((*lp) -> type != dhcp_type_group) {
378 omapi_object_dereference (lp, MDL);
379 return ISC_R_INVALIDARG;
383 /* Now look for a name. */
384 status = omapi_get_value_str (ref, id, "name", &tv);
385 if (status == ISC_R_SUCCESS) {
386 group = (struct group_object *)0;
387 if (group_name_hash &&
388 group_hash_lookup (&group, group_name_hash,
390 tv -> value -> u.buffer.value,
391 tv -> value -> u.buffer.len, MDL)) {
392 omapi_value_dereference (&tv, MDL);
394 if (*lp && *lp != (omapi_object_t *)group) {
395 group_object_dereference (&group, MDL);
396 omapi_object_dereference (lp, MDL);
397 return ISC_R_KEYCONFLICT;
399 /* XXX fix so that hash lookup itself creates
400 XXX the reference. */
401 omapi_object_reference (lp,
402 (omapi_object_t *)group,
404 group_object_dereference (&group, MDL);
407 return ISC_R_NOTFOUND;
410 /* If we get to here without finding a group, no valid key was
415 if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) {
416 omapi_object_dereference (lp, MDL);
417 return ISC_R_NOTFOUND;
419 return ISC_R_SUCCESS;
422 isc_result_t dhcp_group_create (omapi_object_t **lp,
425 struct group_object *group;
427 group = (struct group_object *)0;
429 status = group_object_allocate (&group, MDL);
430 if (status != ISC_R_SUCCESS)
432 group -> flags = GROUP_OBJECT_DYNAMIC;
433 status = omapi_object_reference (lp, (omapi_object_t *)group, MDL);
434 group_object_dereference (&group, MDL);
438 isc_result_t dhcp_group_remove (omapi_object_t *lp,
441 struct group_object *group;
443 if (lp -> type != dhcp_type_group)
444 return ISC_R_INVALIDARG;
445 group = (struct group_object *)lp;
447 group -> flags |= GROUP_OBJECT_DELETED;
448 if (group_write_hook) {
449 if (!(*group_write_hook) (group))
450 return ISC_R_IOERROR;
453 status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
455 return ISC_R_SUCCESS;
458 isc_result_t dhcp_control_set_value (omapi_object_t *h,
460 omapi_data_string_t *name,
461 omapi_typed_data_t *value)
463 dhcp_control_object_t *control;
466 unsigned long newstate;
468 if (h -> type != dhcp_type_control)
469 return ISC_R_INVALIDARG;
470 control = (dhcp_control_object_t *)h;
472 if (!omapi_ds_strcmp (name, "state")) {
473 status = omapi_get_int_value (&newstate, value);
474 if (status != ISC_R_SUCCESS)
476 status = dhcp_set_control_state (control -> state, newstate);
477 if (status == ISC_R_SUCCESS)
478 control -> state = value -> u.integer;
482 /* Try to find some inner object that can take the value. */
483 if (h -> inner && h -> inner -> type -> set_value) {
484 status = ((*(h -> inner -> type -> set_value))
485 (h -> inner, id, name, value));
486 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
490 return ISC_R_NOTFOUND;
494 isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,
495 omapi_data_string_t *name,
496 omapi_value_t **value)
498 dhcp_control_object_t *control;
500 struct data_string ip_addrs;
502 if (h -> type != dhcp_type_control)
503 return ISC_R_INVALIDARG;
504 control = (dhcp_control_object_t *)h;
506 if (!omapi_ds_strcmp (name, "state"))
507 return omapi_make_int_value (value,
508 name, (int)control -> state, MDL);
510 /* Try to find some inner object that can take the value. */
511 if (h -> inner && h -> inner -> type -> get_value) {
512 status = ((*(h -> inner -> type -> get_value))
513 (h -> inner, id, name, value));
514 if (status == ISC_R_SUCCESS)
517 return ISC_R_NOTFOUND;
520 isc_result_t dhcp_control_destroy (omapi_object_t *h,
521 const char *file, int line)
523 dhcp_control_object_t *control, *t;
526 if (h -> type != dhcp_type_control)
527 return ISC_R_INVALIDARG;
529 /* Can't destroy the control object. */
533 isc_result_t dhcp_control_signal_handler (omapi_object_t *h,
534 const char *name, va_list ap)
536 dhcp_control_object_t *control, *t;
540 if (h -> type != dhcp_type_control)
541 return ISC_R_INVALIDARG;
542 control = (dhcp_control_object_t *)h;
544 /* Try to find some inner object that can take the value. */
545 if (h -> inner && h -> inner -> type -> get_value) {
546 status = ((*(h -> inner -> type -> signal_handler))
547 (h -> inner, name, ap));
548 if (status == ISC_R_SUCCESS)
551 return ISC_R_NOTFOUND;
554 isc_result_t dhcp_control_stuff_values (omapi_object_t *c,
558 dhcp_control_object_t *control;
561 if (h -> type != dhcp_type_control)
562 return ISC_R_INVALIDARG;
563 control = (dhcp_control_object_t *)h;
565 /* Write out all the values. */
566 status = omapi_connection_put_name (c, "state");
567 if (status != ISC_R_SUCCESS)
569 status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));
570 if (status != ISC_R_SUCCESS)
572 status = omapi_connection_put_uint32 (c, control -> state);
573 if (status != ISC_R_SUCCESS)
576 /* Write out the inner object, if any. */
577 if (h -> inner && h -> inner -> type -> stuff_values) {
578 status = ((*(h -> inner -> type -> stuff_values))
579 (c, id, h -> inner));
580 if (status == ISC_R_SUCCESS)
584 return ISC_R_SUCCESS;
587 isc_result_t dhcp_control_lookup (omapi_object_t **lp,
588 omapi_object_t *id, omapi_object_t *ref)
590 omapi_value_t *tv = (omapi_value_t *)0;
592 dhcp_control_object_t *control;
594 /* First see if we were sent a handle. */
596 status = omapi_get_value_str (ref, id, "handle", &tv);
597 if (status == ISC_R_SUCCESS) {
598 status = omapi_handle_td_lookup (lp, tv -> value);
600 omapi_value_dereference (&tv, MDL);
601 if (status != ISC_R_SUCCESS)
604 /* Don't return the object if the type is wrong. */
605 if ((*lp) -> type != dhcp_type_control) {
606 omapi_object_dereference (lp, MDL);
607 return ISC_R_INVALIDARG;
612 /* Otherwise, stop playing coy - there's only one control object,
613 so we can just return it. */
614 dhcp_control_reference ((dhcp_control_object_t **)lp,
615 dhcp_control_object, MDL);
616 return ISC_R_SUCCESS;
619 isc_result_t dhcp_control_create (omapi_object_t **lp,
622 /* Can't create a control object - there can be only one. */
626 isc_result_t dhcp_control_remove (omapi_object_t *lp,
629 /* Form is emptiness; emptiness form. The control object
630 cannot go out of existance. */
634 isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
636 omapi_data_string_t *name,
637 omapi_typed_data_t *value)
639 struct subnet *subnet;
643 if (h -> type != dhcp_type_subnet)
644 return ISC_R_INVALIDARG;
645 subnet = (struct subnet *)h;
647 /* No values to set yet. */
649 /* Try to find some inner object that can take the value. */
650 if (h -> inner && h -> inner -> type -> set_value) {
651 status = ((*(h -> inner -> type -> set_value))
652 (h -> inner, id, name, value));
653 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
657 return ISC_R_NOTFOUND;
661 isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
662 omapi_data_string_t *name,
663 omapi_value_t **value)
665 struct subnet *subnet;
668 if (h -> type != dhcp_type_subnet)
669 return ISC_R_INVALIDARG;
670 subnet = (struct subnet *)h;
672 /* No values to get yet. */
674 /* Try to find some inner object that can provide the value. */
675 if (h -> inner && h -> inner -> type -> get_value) {
676 status = ((*(h -> inner -> type -> get_value))
677 (h -> inner, id, name, value));
678 if (status == ISC_R_SUCCESS)
681 return ISC_R_NOTFOUND;
684 isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
686 struct subnet *subnet;
689 if (h -> type != dhcp_type_subnet)
690 return ISC_R_INVALIDARG;
691 subnet = (struct subnet *)h;
693 #if defined (DEBUG_MEMORY_LEAKAGE) || \
694 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
695 if (subnet -> next_subnet)
696 subnet_dereference (&subnet -> next_subnet, file, line);
697 if (subnet -> next_sibling)
698 subnet_dereference (&subnet -> next_sibling, file, line);
699 if (subnet -> shared_network)
700 shared_network_dereference (&subnet -> shared_network,
702 if (subnet -> interface)
703 interface_dereference (&subnet -> interface, file, line);
705 group_dereference (&subnet -> group, file, line);
708 return ISC_R_SUCCESS;
711 isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h,
712 const char *name, va_list ap)
714 struct subnet *subnet;
718 if (h -> type != dhcp_type_subnet)
719 return ISC_R_INVALIDARG;
720 subnet = (struct subnet *)h;
722 /* Can't write subnets yet. */
724 /* Try to find some inner object that can take the value. */
725 if (h -> inner && h -> inner -> type -> get_value) {
726 status = ((*(h -> inner -> type -> signal_handler))
727 (h -> inner, name, ap));
728 if (status == ISC_R_SUCCESS)
732 return ISC_R_SUCCESS;
733 return ISC_R_NOTFOUND;
736 isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c,
740 struct subnet *subnet;
743 if (h -> type != dhcp_type_subnet)
744 return ISC_R_INVALIDARG;
745 subnet = (struct subnet *)h;
747 /* Can't stuff subnet values yet. */
749 /* Write out the inner object, if any. */
750 if (h -> inner && h -> inner -> type -> stuff_values) {
751 status = ((*(h -> inner -> type -> stuff_values))
752 (c, id, h -> inner));
753 if (status == ISC_R_SUCCESS)
757 return ISC_R_SUCCESS;
760 isc_result_t dhcp_subnet_lookup (omapi_object_t **lp,
764 omapi_value_t *tv = (omapi_value_t *)0;
766 struct subnet *subnet;
768 /* Can't look up subnets yet. */
770 /* If we get to here without finding a subnet, no valid key was
774 return ISC_R_SUCCESS;
777 isc_result_t dhcp_subnet_create (omapi_object_t **lp,
780 return ISC_R_NOTIMPLEMENTED;
783 isc_result_t dhcp_subnet_remove (omapi_object_t *lp,
786 return ISC_R_NOTIMPLEMENTED;
789 isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
791 omapi_data_string_t *name,
792 omapi_typed_data_t *value)
794 struct shared_network *shared_network;
798 if (h -> type != dhcp_type_shared_network)
799 return ISC_R_INVALIDARG;
800 shared_network = (struct shared_network *)h;
802 /* No values to set yet. */
804 /* Try to find some inner object that can take the value. */
805 if (h -> inner && h -> inner -> type -> set_value) {
806 status = ((*(h -> inner -> type -> set_value))
807 (h -> inner, id, name, value));
808 if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
812 return ISC_R_NOTFOUND;
816 isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
818 omapi_data_string_t *name,
819 omapi_value_t **value)
821 struct shared_network *shared_network;
824 if (h -> type != dhcp_type_shared_network)
825 return ISC_R_INVALIDARG;
826 shared_network = (struct shared_network *)h;
828 /* No values to get yet. */
830 /* Try to find some inner object that can provide the value. */
831 if (h -> inner && h -> inner -> type -> get_value) {
832 status = ((*(h -> inner -> type -> get_value))
833 (h -> inner, id, name, value));
834 if (status == ISC_R_SUCCESS)
837 return ISC_R_NOTFOUND;
840 isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
841 const char *file, int line)
843 struct shared_network *shared_network;
846 if (h -> type != dhcp_type_shared_network)
847 return ISC_R_INVALIDARG;
848 shared_network = (struct shared_network *)h;
850 #if defined (DEBUG_MEMORY_LEAKAGE) || \
851 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
852 if (shared_network -> next)
853 shared_network_dereference (&shared_network -> next,
855 if (shared_network -> name) {
856 dfree (shared_network -> name, file, line);
857 shared_network -> name = 0;
859 if (shared_network -> subnets)
860 subnet_dereference (&shared_network -> subnets, file, line);
861 if (shared_network -> interface)
862 interface_dereference (&shared_network -> interface,
864 if (shared_network -> pools)
865 omapi_object_dereference ((omapi_object_t **)
866 &shared_network -> pools, file, line);
867 if (shared_network -> group)
868 group_dereference (&shared_network -> group, file, line);
869 #if defined (FAILOVER_PROTOCOL)
870 if (shared_network -> failover_peer)
871 omapi_object_dereference ((omapi_object_t **)
872 &shared_network -> failover_peer,
875 #endif /* DEBUG_MEMORY_LEAKAGE */
877 return ISC_R_SUCCESS;
880 isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h,
884 struct shared_network *shared_network;
888 if (h -> type != dhcp_type_shared_network)
889 return ISC_R_INVALIDARG;
890 shared_network = (struct shared_network *)h;
892 /* Can't write shared_networks yet. */
894 /* Try to find some inner object that can take the value. */
895 if (h -> inner && h -> inner -> type -> get_value) {
896 status = ((*(h -> inner -> type -> signal_handler))
897 (h -> inner, name, ap));
898 if (status == ISC_R_SUCCESS)
902 return ISC_R_SUCCESS;
903 return ISC_R_NOTFOUND;
906 isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c,
910 struct shared_network *shared_network;
913 if (h -> type != dhcp_type_shared_network)
914 return ISC_R_INVALIDARG;
915 shared_network = (struct shared_network *)h;
917 /* Can't stuff shared_network values yet. */
919 /* Write out the inner object, if any. */
920 if (h -> inner && h -> inner -> type -> stuff_values) {
921 status = ((*(h -> inner -> type -> stuff_values))
922 (c, id, h -> inner));
923 if (status == ISC_R_SUCCESS)
927 return ISC_R_SUCCESS;
930 isc_result_t dhcp_shared_network_lookup (omapi_object_t **lp,
934 omapi_value_t *tv = (omapi_value_t *)0;
936 struct shared_network *shared_network;
938 /* Can't look up shared_networks yet. */
940 /* If we get to here without finding a shared_network, no valid key was
944 return ISC_R_SUCCESS;
947 isc_result_t dhcp_shared_network_create (omapi_object_t **lp,
950 return ISC_R_NOTIMPLEMENTED;
953 isc_result_t dhcp_shared_network_remove (omapi_object_t *lp,
956 return ISC_R_NOTIMPLEMENTED;