1 /* $NetBSD: comapi.c,v 1.1.1.3 2014/07/12 11:57:39 spz Exp $ */
4 OMAPI object interfaces for the DHCP server. */
7 * Copyright (c) 2012,2014 Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
9 * Copyright (c) 1999-2003 by Internet Software Consortium
11 * Permission to use, copy, modify, and distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Internet Systems Consortium, Inc.
25 * Redwood City, CA 94063
27 * https://www.isc.org/
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: comapi.c,v 1.1.1.3 2014/07/12 11:57:39 spz Exp $");
34 /* Many, many thanks to Brian Murrell and BCtel for this code - BCtel
35 provided the funding that resulted in this code and the entire
36 OMAPI support library being written, and Brian helped brainstorm
37 and refine the requirements. To the extent that this code is
38 useful, you have Brian and BCtel to thank. Any limitations in the
39 code are a result of mistakes on my part. -- Ted Lemon */
42 #include <omapip/omapip_p.h>
44 OMAPI_OBJECT_ALLOC (subnet
, struct subnet
, dhcp_type_subnet
)
45 OMAPI_OBJECT_ALLOC (shared_network
, struct shared_network
,
46 dhcp_type_shared_network
)
47 OMAPI_OBJECT_ALLOC (group_object
, struct group_object
, dhcp_type_group
)
48 OMAPI_OBJECT_ALLOC (dhcp_control
, dhcp_control_object_t
, dhcp_type_control
)
50 omapi_object_type_t
*dhcp_type_interface
;
51 omapi_object_type_t
*dhcp_type_group
;
52 omapi_object_type_t
*dhcp_type_shared_network
;
53 omapi_object_type_t
*dhcp_type_subnet
;
54 omapi_object_type_t
*dhcp_type_control
;
55 dhcp_control_object_t
*dhcp_control_object
;
57 void dhcp_common_objects_setup ()
61 status
= omapi_object_type_register (&dhcp_type_control
,
63 dhcp_control_set_value
,
64 dhcp_control_get_value
,
66 dhcp_control_signal_handler
,
67 dhcp_control_stuff_values
,
70 dhcp_control_remove
, 0, 0, 0,
71 sizeof (dhcp_control_object_t
),
73 if (status
!= ISC_R_SUCCESS
)
74 log_fatal ("Can't register control object type: %s",
75 isc_result_totext (status
));
76 status
= dhcp_control_allocate (&dhcp_control_object
, MDL
);
77 if (status
!= ISC_R_SUCCESS
)
78 log_fatal ("Can't make initial control object: %s",
79 isc_result_totext (status
));
80 dhcp_control_object
-> state
= server_startup
;
82 status
= omapi_object_type_register (&dhcp_type_group
,
87 dhcp_group_signal_handler
,
88 dhcp_group_stuff_values
,
91 dhcp_group_remove
, 0, 0, 0,
92 sizeof (struct group_object
), 0,
94 if (status
!= ISC_R_SUCCESS
)
95 log_fatal ("Can't register group object type: %s",
96 isc_result_totext (status
));
98 status
= omapi_object_type_register (&dhcp_type_subnet
,
100 dhcp_subnet_set_value
,
101 dhcp_subnet_get_value
,
103 dhcp_subnet_signal_handler
,
104 dhcp_subnet_stuff_values
,
107 dhcp_subnet_remove
, 0, 0, 0,
108 sizeof (struct subnet
), 0,
110 if (status
!= ISC_R_SUCCESS
)
111 log_fatal ("Can't register subnet object type: %s",
112 isc_result_totext (status
));
114 status
= omapi_object_type_register
115 (&dhcp_type_shared_network
,
117 dhcp_shared_network_set_value
,
118 dhcp_shared_network_get_value
,
119 dhcp_shared_network_destroy
,
120 dhcp_shared_network_signal_handler
,
121 dhcp_shared_network_stuff_values
,
122 dhcp_shared_network_lookup
,
123 dhcp_shared_network_create
,
124 dhcp_shared_network_remove
, 0, 0, 0,
125 sizeof (struct shared_network
), 0, RC_MISC
);
126 if (status
!= ISC_R_SUCCESS
)
127 log_fatal ("Can't register shared network object type: %s",
128 isc_result_totext (status
));
133 isc_result_t
dhcp_group_set_value (omapi_object_t
*h
,
135 omapi_data_string_t
*name
,
136 omapi_typed_data_t
*value
)
138 struct group_object
*group
;
141 if (h
-> type
!= dhcp_type_group
)
142 return DHCP_R_INVALIDARG
;
143 group
= (struct group_object
*)h
;
145 /* XXX For now, we can only set these values on new group objects.
146 XXX Soon, we need to be able to update group objects. */
147 if (!omapi_ds_strcmp (name
, "name")) {
150 if (value
-> type
== omapi_datatype_data
||
151 value
-> type
== omapi_datatype_string
) {
152 group
-> name
= dmalloc (value
-> u
.buffer
.len
+ 1,
155 return ISC_R_NOMEMORY
;
156 memcpy (group
-> name
,
157 value
-> u
.buffer
.value
,
158 value
-> u
.buffer
.len
);
159 group
-> name
[value
-> u
.buffer
.len
] = 0;
161 return DHCP_R_INVALIDARG
;
162 return ISC_R_SUCCESS
;
165 if (!omapi_ds_strcmp (name
, "statements")) {
166 if (group
-> group
&& group
-> group
-> statements
)
168 if (!group
-> group
) {
169 if (!clone_group (&group
-> group
, root_group
, MDL
))
170 return ISC_R_NOMEMORY
;
172 if (value
-> type
== omapi_datatype_data
||
173 value
-> type
== omapi_datatype_string
) {
177 status
= new_parse(&parse
, -1,
178 (char *) value
->u
.buffer
.value
,
180 "network client", 0);
181 if (status
!= ISC_R_SUCCESS
|| parse
== NULL
)
183 if (!(parse_executable_statements
184 (&group
-> group
-> statements
, parse
, &lose
,
187 return DHCP_R_BADPARSE
;
190 return ISC_R_SUCCESS
;
192 return DHCP_R_INVALIDARG
;
195 /* Try to find some inner object that can take the value. */
196 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
197 status
= ((*(h
-> inner
-> type
-> set_value
))
198 (h
-> inner
, id
, name
, value
));
199 if (status
== ISC_R_SUCCESS
|| status
== DHCP_R_UNCHANGED
)
203 return ISC_R_NOTFOUND
;
207 isc_result_t
dhcp_group_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
208 omapi_data_string_t
*name
,
209 omapi_value_t
**value
)
211 struct group_object
*group
;
214 if (h
-> type
!= dhcp_type_group
)
215 return DHCP_R_INVALIDARG
;
216 group
= (struct group_object
*)h
;
218 if (!omapi_ds_strcmp (name
, "name"))
219 return omapi_make_string_value (value
,
220 name
, group
-> name
, MDL
);
222 /* Try to find some inner object that can take the value. */
223 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
224 status
= ((*(h
-> inner
-> type
-> get_value
))
225 (h
-> inner
, id
, name
, value
));
226 if (status
== ISC_R_SUCCESS
)
229 return ISC_R_NOTFOUND
;
232 isc_result_t
dhcp_group_destroy (omapi_object_t
*h
, const char *file
, int line
)
234 struct group_object
*group
, *t
;
236 if (h
-> type
!= dhcp_type_group
)
237 return DHCP_R_INVALIDARG
;
238 group
= (struct group_object
*)h
;
241 if (group_name_hash
) {
242 t
= (struct group_object
*)0;
243 if (group_hash_lookup (&t
, group_name_hash
,
245 strlen (group
-> name
), MDL
)) {
246 group_hash_delete (group_name_hash
,
248 strlen (group
-> name
),
250 group_object_dereference (&t
, MDL
);
253 dfree (group
-> name
, file
, line
);
254 group
-> name
= (char *)0;
257 group_dereference (&group
-> group
, MDL
);
259 return ISC_R_SUCCESS
;
262 isc_result_t
dhcp_group_signal_handler (omapi_object_t
*h
,
263 const char *name
, va_list ap
)
265 struct group_object
*group
;
269 if (h
-> type
!= dhcp_type_group
)
270 return DHCP_R_INVALIDARG
;
271 group
= (struct group_object
*)h
;
273 if (!strcmp (name
, "updated")) {
274 /* A group object isn't valid if a subgroup hasn't yet been
275 associated with it. */
277 return DHCP_R_INVALIDARG
;
279 /* Group objects always have to have names. */
280 if (!group
-> name
) {
282 sprintf (hnbuf
, "ng%08lx%08lx",
283 (unsigned long)cur_time
,
284 (unsigned long)group
);
285 group
-> name
= dmalloc (strlen (hnbuf
) + 1, MDL
);
287 return ISC_R_NOMEMORY
;
288 strcpy (group
-> name
, hnbuf
);
291 supersede_group (group
, 1);
295 /* Try to find some inner object that can take the value. */
296 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
297 status
= ((*(h
-> inner
-> type
-> signal_handler
))
298 (h
-> inner
, name
, ap
));
299 if (status
== ISC_R_SUCCESS
)
303 return ISC_R_SUCCESS
;
304 return ISC_R_NOTFOUND
;
307 isc_result_t
dhcp_group_stuff_values (omapi_object_t
*c
,
311 struct group_object
*group
;
314 if (h
-> type
!= dhcp_type_group
)
315 return DHCP_R_INVALIDARG
;
316 group
= (struct group_object
*)h
;
318 /* Write out all the values. */
320 status
= omapi_connection_put_name (c
, "name");
321 if (status
!= ISC_R_SUCCESS
)
323 status
= omapi_connection_put_string (c
, group
-> name
);
324 if (status
!= ISC_R_SUCCESS
)
328 /* Write out the inner object, if any. */
329 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
330 status
= ((*(h
-> inner
-> type
-> stuff_values
))
331 (c
, id
, h
-> inner
));
332 if (status
== ISC_R_SUCCESS
)
336 return ISC_R_SUCCESS
;
339 isc_result_t
dhcp_group_lookup (omapi_object_t
**lp
,
340 omapi_object_t
*id
, omapi_object_t
*ref
)
342 omapi_value_t
*tv
= (omapi_value_t
*)0;
344 struct group_object
*group
;
347 return DHCP_R_NOKEYS
;
349 /* First see if we were sent a handle. */
350 status
= omapi_get_value_str (ref
, id
, "handle", &tv
);
351 if (status
== ISC_R_SUCCESS
) {
352 status
= omapi_handle_td_lookup (lp
, tv
-> value
);
354 omapi_value_dereference (&tv
, MDL
);
355 if (status
!= ISC_R_SUCCESS
)
358 /* Don't return the object if the type is wrong. */
359 if ((*lp
) -> type
!= dhcp_type_group
) {
360 omapi_object_dereference (lp
, MDL
);
361 return DHCP_R_INVALIDARG
;
365 /* Now look for a name. */
366 status
= omapi_get_value_str (ref
, id
, "name", &tv
);
367 if (status
== ISC_R_SUCCESS
) {
368 group
= (struct group_object
*)0;
369 if (group_name_hash
&&
370 group_hash_lookup (&group
, group_name_hash
,
372 tv
-> value
-> u
.buffer
.value
,
373 tv
-> value
-> u
.buffer
.len
, MDL
)) {
374 omapi_value_dereference (&tv
, MDL
);
376 if (*lp
&& *lp
!= (omapi_object_t
*)group
) {
377 group_object_dereference (&group
, MDL
);
378 omapi_object_dereference (lp
, MDL
);
379 return DHCP_R_KEYCONFLICT
;
381 /* XXX fix so that hash lookup itself creates
382 XXX the reference. */
383 omapi_object_reference (lp
,
384 (omapi_object_t
*)group
,
386 group_object_dereference (&group
, MDL
);
389 return ISC_R_NOTFOUND
;
392 /* If we get to here without finding a group, no valid key was
395 return DHCP_R_NOKEYS
;
397 if (((struct group_object
*)(*lp
)) -> flags
& GROUP_OBJECT_DELETED
) {
398 omapi_object_dereference (lp
, MDL
);
399 return ISC_R_NOTFOUND
;
401 return ISC_R_SUCCESS
;
404 isc_result_t
dhcp_group_create (omapi_object_t
**lp
,
407 struct group_object
*group
;
409 group
= (struct group_object
*)0;
411 status
= group_object_allocate (&group
, MDL
);
412 if (status
!= ISC_R_SUCCESS
)
414 group
-> flags
= GROUP_OBJECT_DYNAMIC
;
415 status
= omapi_object_reference (lp
, (omapi_object_t
*)group
, MDL
);
416 group_object_dereference (&group
, MDL
);
420 isc_result_t
dhcp_group_remove (omapi_object_t
*lp
,
423 struct group_object
*group
;
425 if (lp
-> type
!= dhcp_type_group
)
426 return DHCP_R_INVALIDARG
;
427 group
= (struct group_object
*)lp
;
429 group
-> flags
|= GROUP_OBJECT_DELETED
;
430 if (group_write_hook
) {
431 if (!(*group_write_hook
) (group
))
432 return ISC_R_IOERROR
;
435 status
= dhcp_group_destroy ((omapi_object_t
*)group
, MDL
);
440 isc_result_t
dhcp_control_set_value (omapi_object_t
*h
,
442 omapi_data_string_t
*name
,
443 omapi_typed_data_t
*value
)
445 dhcp_control_object_t
*control
;
447 unsigned long newstate
;
449 if (h
-> type
!= dhcp_type_control
)
450 return DHCP_R_INVALIDARG
;
451 control
= (dhcp_control_object_t
*)h
;
453 if (!omapi_ds_strcmp (name
, "state")) {
454 status
= omapi_get_int_value (&newstate
, value
);
455 if (status
!= ISC_R_SUCCESS
)
457 status
= dhcp_set_control_state (control
-> state
, newstate
);
458 if (status
== ISC_R_SUCCESS
)
459 control
-> state
= value
-> u
.integer
;
463 /* Try to find some inner object that can take the value. */
464 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
465 status
= ((*(h
-> inner
-> type
-> set_value
))
466 (h
-> inner
, id
, name
, value
));
467 if (status
== ISC_R_SUCCESS
|| status
== DHCP_R_UNCHANGED
)
471 return ISC_R_NOTFOUND
;
475 isc_result_t
dhcp_control_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
476 omapi_data_string_t
*name
,
477 omapi_value_t
**value
)
479 dhcp_control_object_t
*control
;
482 if (h
-> type
!= dhcp_type_control
)
483 return DHCP_R_INVALIDARG
;
484 control
= (dhcp_control_object_t
*)h
;
486 if (!omapi_ds_strcmp (name
, "state"))
487 return omapi_make_int_value (value
,
488 name
, (int)control
-> state
, MDL
);
490 /* Try to find some inner object that can take the value. */
491 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
492 status
= ((*(h
-> inner
-> type
-> get_value
))
493 (h
-> inner
, id
, name
, value
));
494 if (status
== ISC_R_SUCCESS
)
497 return ISC_R_NOTFOUND
;
500 isc_result_t
dhcp_control_destroy (omapi_object_t
*h
,
501 const char *file
, int line
)
503 if (h
-> type
!= dhcp_type_control
)
504 return DHCP_R_INVALIDARG
;
506 /* Can't destroy the control object. */
510 isc_result_t
dhcp_control_signal_handler (omapi_object_t
*h
,
511 const char *name
, va_list ap
)
513 /* In this function h should be a (dhcp_control_object_t *) */
517 if (h
-> type
!= dhcp_type_control
)
518 return DHCP_R_INVALIDARG
;
520 /* Try to find some inner object that can take the value. */
521 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
522 status
= ((*(h
-> inner
-> type
-> signal_handler
))
523 (h
-> inner
, name
, ap
));
524 if (status
== ISC_R_SUCCESS
)
527 return ISC_R_NOTFOUND
;
530 isc_result_t
dhcp_control_stuff_values (omapi_object_t
*c
,
534 dhcp_control_object_t
*control
;
537 if (h
-> type
!= dhcp_type_control
)
538 return DHCP_R_INVALIDARG
;
539 control
= (dhcp_control_object_t
*)h
;
541 /* Write out all the values. */
542 status
= omapi_connection_put_name (c
, "state");
543 if (status
!= ISC_R_SUCCESS
)
545 status
= omapi_connection_put_uint32 (c
, sizeof (u_int32_t
));
546 if (status
!= ISC_R_SUCCESS
)
548 status
= omapi_connection_put_uint32 (c
, control
-> state
);
549 if (status
!= ISC_R_SUCCESS
)
552 /* Write out the inner object, if any. */
553 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
554 status
= ((*(h
-> inner
-> type
-> stuff_values
))
555 (c
, id
, h
-> inner
));
556 if (status
== ISC_R_SUCCESS
)
560 return ISC_R_SUCCESS
;
563 isc_result_t
dhcp_control_lookup (omapi_object_t
**lp
,
564 omapi_object_t
*id
, omapi_object_t
*ref
)
566 omapi_value_t
*tv
= (omapi_value_t
*)0;
569 /* First see if we were sent a handle. */
571 status
= omapi_get_value_str (ref
, id
, "handle", &tv
);
572 if (status
== ISC_R_SUCCESS
) {
573 status
= omapi_handle_td_lookup (lp
, tv
-> value
);
575 omapi_value_dereference (&tv
, MDL
);
576 if (status
!= ISC_R_SUCCESS
)
579 /* Don't return the object if the type is wrong. */
580 if ((*lp
) -> type
!= dhcp_type_control
) {
581 omapi_object_dereference (lp
, MDL
);
582 return DHCP_R_INVALIDARG
;
587 /* Otherwise, stop playing coy - there's only one control object,
588 so we can just return it. */
589 dhcp_control_reference ((dhcp_control_object_t
**)lp
,
590 dhcp_control_object
, MDL
);
591 return ISC_R_SUCCESS
;
594 isc_result_t
dhcp_control_create (omapi_object_t
**lp
,
597 /* Can't create a control object - there can be only one. */
601 isc_result_t
dhcp_control_remove (omapi_object_t
*lp
,
604 /* Form is emptiness; emptiness form. The control object
605 cannot go out of existance. */
609 isc_result_t
dhcp_subnet_set_value (omapi_object_t
*h
,
611 omapi_data_string_t
*name
,
612 omapi_typed_data_t
*value
)
614 /* In this function h should be a (struct subnet *) */
618 if (h
-> type
!= dhcp_type_subnet
)
619 return DHCP_R_INVALIDARG
;
621 /* No values to set yet. */
623 /* Try to find some inner object that can take the value. */
624 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
625 status
= ((*(h
-> inner
-> type
-> set_value
))
626 (h
-> inner
, id
, name
, value
));
627 if (status
== ISC_R_SUCCESS
|| status
== DHCP_R_UNCHANGED
)
631 return ISC_R_NOTFOUND
;
635 isc_result_t
dhcp_subnet_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
636 omapi_data_string_t
*name
,
637 omapi_value_t
**value
)
639 /* In this function h should be a (struct subnet *) */
643 if (h
-> type
!= dhcp_type_subnet
)
644 return DHCP_R_INVALIDARG
;
646 /* No values to get yet. */
648 /* Try to find some inner object that can provide the value. */
649 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
650 status
= ((*(h
-> inner
-> type
-> get_value
))
651 (h
-> inner
, id
, name
, value
));
652 if (status
== ISC_R_SUCCESS
)
655 return ISC_R_NOTFOUND
;
658 isc_result_t
dhcp_subnet_destroy (omapi_object_t
*h
, const char *file
, int line
)
660 #if defined (DEBUG_MEMORY_LEAKAGE) || \
661 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
662 struct subnet
*subnet
;
665 if (h
-> type
!= dhcp_type_subnet
)
666 return DHCP_R_INVALIDARG
;
668 #if defined (DEBUG_MEMORY_LEAKAGE) || \
669 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
670 subnet
= (struct subnet
*)h
;
671 if (subnet
-> next_subnet
)
672 subnet_dereference (&subnet
-> next_subnet
, file
, line
);
673 if (subnet
-> next_sibling
)
674 subnet_dereference (&subnet
-> next_sibling
, file
, line
);
675 if (subnet
-> shared_network
)
676 shared_network_dereference (&subnet
-> shared_network
,
678 if (subnet
-> interface
)
679 interface_dereference (&subnet
-> interface
, file
, line
);
681 group_dereference (&subnet
-> group
, file
, line
);
684 return ISC_R_SUCCESS
;
687 isc_result_t
dhcp_subnet_signal_handler (omapi_object_t
*h
,
688 const char *name
, va_list ap
)
690 /* In this function h should be a (struct subnet *) */
694 if (h
-> type
!= dhcp_type_subnet
)
695 return DHCP_R_INVALIDARG
;
697 /* Can't write subnets yet. */
699 /* Try to find some inner object that can take the value. */
700 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
701 status
= ((*(h
-> inner
-> type
-> signal_handler
))
702 (h
-> inner
, name
, ap
));
703 if (status
== ISC_R_SUCCESS
)
707 return ISC_R_NOTFOUND
;
710 isc_result_t
dhcp_subnet_stuff_values (omapi_object_t
*c
,
714 /* In this function h should be a (struct subnet *) */
718 if (h
-> type
!= dhcp_type_subnet
)
719 return DHCP_R_INVALIDARG
;
721 /* Can't stuff subnet values yet. */
723 /* Write out the inner object, if any. */
724 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
725 status
= ((*(h
-> inner
-> type
-> stuff_values
))
726 (c
, id
, h
-> inner
));
727 if (status
== ISC_R_SUCCESS
)
731 return ISC_R_SUCCESS
;
734 isc_result_t
dhcp_subnet_lookup (omapi_object_t
**lp
,
738 /* Can't look up subnets yet. */
740 /* If we get to here without finding a subnet, no valid key was
743 return DHCP_R_NOKEYS
;
744 return ISC_R_SUCCESS
;
747 isc_result_t
dhcp_subnet_create (omapi_object_t
**lp
,
750 return ISC_R_NOTIMPLEMENTED
;
753 isc_result_t
dhcp_subnet_remove (omapi_object_t
*lp
,
756 return ISC_R_NOTIMPLEMENTED
;
759 isc_result_t
dhcp_shared_network_set_value (omapi_object_t
*h
,
761 omapi_data_string_t
*name
,
762 omapi_typed_data_t
*value
)
764 /* In this function h should be a (struct shared_network *) */
768 if (h
-> type
!= dhcp_type_shared_network
)
769 return DHCP_R_INVALIDARG
;
771 /* No values to set yet. */
773 /* Try to find some inner object that can take the value. */
774 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
775 status
= ((*(h
-> inner
-> type
-> set_value
))
776 (h
-> inner
, id
, name
, value
));
777 if (status
== ISC_R_SUCCESS
|| status
== DHCP_R_UNCHANGED
)
781 return ISC_R_NOTFOUND
;
785 isc_result_t
dhcp_shared_network_get_value (omapi_object_t
*h
,
787 omapi_data_string_t
*name
,
788 omapi_value_t
**value
)
790 /* In this function h should be a (struct shared_network *) */
794 if (h
-> type
!= dhcp_type_shared_network
)
795 return DHCP_R_INVALIDARG
;
797 /* No values to get yet. */
799 /* Try to find some inner object that can provide the value. */
800 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
801 status
= ((*(h
-> inner
-> type
-> get_value
))
802 (h
-> inner
, id
, name
, value
));
803 if (status
== ISC_R_SUCCESS
)
806 return ISC_R_NOTFOUND
;
809 isc_result_t
dhcp_shared_network_destroy (omapi_object_t
*h
,
810 const char *file
, int line
)
812 /* In this function h should be a (struct shared_network *) */
814 #if defined (DEBUG_MEMORY_LEAKAGE) || \
815 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
816 struct shared_network
*shared_network
;
819 if (h
-> type
!= dhcp_type_shared_network
)
820 return DHCP_R_INVALIDARG
;
822 #if defined (DEBUG_MEMORY_LEAKAGE) || \
823 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
824 shared_network
= (struct shared_network
*)h
;
825 if (shared_network
-> next
)
826 shared_network_dereference (&shared_network
-> next
,
828 if (shared_network
-> name
) {
829 dfree (shared_network
-> name
, file
, line
);
830 shared_network
-> name
= 0;
832 if (shared_network
-> subnets
)
833 subnet_dereference (&shared_network
-> subnets
, file
, line
);
834 if (shared_network
-> interface
)
835 interface_dereference (&shared_network
-> interface
,
837 if (shared_network
-> pools
)
838 omapi_object_dereference ((omapi_object_t
**)
839 &shared_network
-> pools
, file
, line
);
840 if (shared_network
-> group
)
841 group_dereference (&shared_network
-> group
, file
, line
);
842 #if defined (FAILOVER_PROTOCOL)
843 if (shared_network
-> failover_peer
)
844 omapi_object_dereference ((omapi_object_t
**)
845 &shared_network
-> failover_peer
,
848 #endif /* DEBUG_MEMORY_LEAKAGE */
850 return ISC_R_SUCCESS
;
853 isc_result_t
dhcp_shared_network_signal_handler (omapi_object_t
*h
,
857 /* In this function h should be a (struct shared_network *) */
861 if (h
-> type
!= dhcp_type_shared_network
)
862 return DHCP_R_INVALIDARG
;
864 /* Can't write shared_networks yet. */
866 /* Try to find some inner object that can take the value. */
867 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
868 status
= ((*(h
-> inner
-> type
-> signal_handler
))
869 (h
-> inner
, name
, ap
));
870 if (status
== ISC_R_SUCCESS
)
874 return ISC_R_NOTFOUND
;
877 isc_result_t
dhcp_shared_network_stuff_values (omapi_object_t
*c
,
881 /* In this function h should be a (struct shared_network *) */
885 if (h
-> type
!= dhcp_type_shared_network
)
886 return DHCP_R_INVALIDARG
;
888 /* Can't stuff shared_network values yet. */
890 /* Write out the inner object, if any. */
891 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
892 status
= ((*(h
-> inner
-> type
-> stuff_values
))
893 (c
, id
, h
-> inner
));
894 if (status
== ISC_R_SUCCESS
)
898 return ISC_R_SUCCESS
;
901 isc_result_t
dhcp_shared_network_lookup (omapi_object_t
**lp
,
905 /* Can't look up shared_networks yet. */
907 /* If we get to here without finding a shared_network, no valid key was
910 return DHCP_R_NOKEYS
;
911 return ISC_R_SUCCESS
;
914 isc_result_t
dhcp_shared_network_create (omapi_object_t
**lp
,
917 return ISC_R_NOTIMPLEMENTED
;
920 isc_result_t
dhcp_shared_network_remove (omapi_object_t
*lp
,
923 return ISC_R_NOTIMPLEMENTED
;