3 OMAPI object interfaces for the DHCP server. */
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.
23 * Redwood City, CA 94063
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 */
43 static char copyright
[] =
44 "$Id: comapi.c,v 1.6 2005/08/11 17:13:21 drochner Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
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 ()
67 status
= omapi_object_type_register (&dhcp_type_control
,
69 dhcp_control_set_value
,
70 dhcp_control_get_value
,
72 dhcp_control_signal_handler
,
73 dhcp_control_stuff_values
,
76 dhcp_control_remove
, 0, 0, 0,
77 sizeof (dhcp_control_object_t
),
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
,
93 dhcp_group_signal_handler
,
94 dhcp_group_stuff_values
,
97 dhcp_group_remove
, 0, 0, 0,
98 sizeof (struct group_object
), 0,
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
,
106 dhcp_subnet_set_value
,
107 dhcp_subnet_get_value
,
109 dhcp_subnet_signal_handler
,
110 dhcp_subnet_stuff_values
,
113 dhcp_subnet_remove
, 0, 0, 0,
114 sizeof (struct subnet
), 0,
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
,
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
));
139 isc_result_t
dhcp_group_set_value (omapi_object_t
*h
,
141 omapi_data_string_t
*name
,
142 omapi_typed_data_t
*value
)
144 struct group_object
*group
;
147 if (h
-> type
!= dhcp_type_group
)
148 return ISC_R_INVALIDARG
;
149 group
= (struct group_object
*)h
;
151 /* XXX For now, we can only set these values on new group objects.
152 XXX Soon, we need to be able to update group objects. */
153 if (!omapi_ds_strcmp (name
, "name")) {
156 if (value
-> type
== omapi_datatype_data
||
157 value
-> type
== omapi_datatype_string
) {
158 group
-> name
= dmalloc (value
-> u
.buffer
.len
+ 1,
161 return ISC_R_NOMEMORY
;
162 memcpy (group
-> name
,
163 value
-> u
.buffer
.value
,
164 value
-> u
.buffer
.len
);
165 group
-> name
[value
-> u
.buffer
.len
] = 0;
167 return ISC_R_INVALIDARG
;
168 return ISC_R_SUCCESS
;
171 if (!omapi_ds_strcmp (name
, "statements")) {
172 if (group
-> group
&& group
-> group
-> statements
)
174 if (!group
-> group
) {
175 if (!clone_group (&group
-> group
, root_group
, MDL
))
176 return ISC_R_NOMEMORY
;
178 if (value
-> type
== omapi_datatype_data
||
179 value
-> type
== omapi_datatype_string
) {
182 parse
= (struct parse
*)0;
183 status
= new_parse (&parse
, -1,
184 (char *)value
-> u
.buffer
.value
,
185 value
-> u
.buffer
.len
,
186 "network client", 0);
187 if (status
!= ISC_R_SUCCESS
)
189 if (!(parse_executable_statements
190 (&group
-> group
-> statements
, parse
, &lose
,
193 return ISC_R_BADPARSE
;
196 return ISC_R_SUCCESS
;
198 return ISC_R_INVALIDARG
;
201 /* Try to find some inner object that can take the value. */
202 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
203 status
= ((*(h
-> inner
-> type
-> set_value
))
204 (h
-> inner
, id
, name
, value
));
205 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
209 return ISC_R_NOTFOUND
;
213 isc_result_t
dhcp_group_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
214 omapi_data_string_t
*name
,
215 omapi_value_t
**value
)
217 struct group_object
*group
;
220 if (h
-> type
!= dhcp_type_group
)
221 return ISC_R_INVALIDARG
;
222 group
= (struct group_object
*)h
;
224 if (!omapi_ds_strcmp (name
, "name"))
225 return omapi_make_string_value (value
,
226 name
, group
-> name
, MDL
);
228 /* Try to find some inner object that can take the value. */
229 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
230 status
= ((*(h
-> inner
-> type
-> get_value
))
231 (h
-> inner
, id
, name
, value
));
232 if (status
== ISC_R_SUCCESS
)
235 return ISC_R_NOTFOUND
;
238 isc_result_t
dhcp_group_destroy (omapi_object_t
*h
, const char *file
, int line
)
240 struct group_object
*group
, *t
;
242 if (h
-> type
!= dhcp_type_group
)
243 return ISC_R_INVALIDARG
;
244 group
= (struct group_object
*)h
;
247 if (group_name_hash
) {
248 t
= (struct group_object
*)0;
249 if (group_hash_lookup (&t
, group_name_hash
,
251 strlen (group
-> name
), MDL
)) {
252 group_hash_delete (group_name_hash
,
254 strlen (group
-> name
),
256 group_object_dereference (&t
, MDL
);
259 dfree (group
-> name
, file
, line
);
260 group
-> name
= (char *)0;
263 group_dereference (&group
-> group
, MDL
);
265 return ISC_R_SUCCESS
;
268 isc_result_t
dhcp_group_signal_handler (omapi_object_t
*h
,
269 const char *name
, va_list ap
)
271 struct group_object
*group
;
275 if (h
-> type
!= dhcp_type_group
)
276 return ISC_R_INVALIDARG
;
277 group
= (struct group_object
*)h
;
279 if (!strcmp (name
, "updated")) {
280 /* A group object isn't valid if a subgroup hasn't yet been
281 associated with it. */
283 return ISC_R_INVALIDARG
;
285 /* Group objects always have to have names. */
286 if (!group
-> name
) {
288 sprintf (hnbuf
, "ng%08lx%08lx",
289 (unsigned long)cur_time
,
290 (unsigned long)group
);
291 group
-> name
= dmalloc (strlen (hnbuf
) + 1, MDL
);
293 return ISC_R_NOMEMORY
;
294 strcpy (group
-> name
, hnbuf
);
297 supersede_group (group
, 1);
301 /* Try to find some inner object that can take the value. */
302 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
303 status
= ((*(h
-> inner
-> type
-> signal_handler
))
304 (h
-> inner
, name
, ap
));
305 if (status
== ISC_R_SUCCESS
)
309 return ISC_R_SUCCESS
;
310 return ISC_R_NOTFOUND
;
313 isc_result_t
dhcp_group_stuff_values (omapi_object_t
*c
,
317 struct group_object
*group
;
320 if (h
-> type
!= dhcp_type_group
)
321 return ISC_R_INVALIDARG
;
322 group
= (struct group_object
*)h
;
325 /* Write out all the values. */
327 status
= omapi_connection_put_name (c
, "name");
328 if (status
!= ISC_R_SUCCESS
)
330 status
= omapi_connection_put_string (c
, group
-> name
);
331 if (status
!= ISC_R_SUCCESS
)
336 /* Write out the inner object, if any. */
337 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
338 status
= ((*(h
-> inner
-> type
-> stuff_values
))
339 (c
, id
, h
-> inner
));
340 if (status
== ISC_R_SUCCESS
)
344 return ISC_R_SUCCESS
;
347 isc_result_t
dhcp_group_lookup (omapi_object_t
**lp
,
348 omapi_object_t
*id
, omapi_object_t
*ref
)
350 omapi_value_t
*tv
= (omapi_value_t
*)0;
352 struct group_object
*group
;
357 /* First see if we were sent a handle. */
358 status
= omapi_get_value_str (ref
, id
, "handle", &tv
);
359 if (status
== ISC_R_SUCCESS
) {
360 status
= omapi_handle_td_lookup (lp
, tv
-> value
);
362 omapi_value_dereference (&tv
, MDL
);
363 if (status
!= ISC_R_SUCCESS
)
366 /* Don't return the object if the type is wrong. */
367 if ((*lp
) -> type
!= dhcp_type_group
) {
368 omapi_object_dereference (lp
, MDL
);
369 return ISC_R_INVALIDARG
;
373 /* Now look for a name. */
374 status
= omapi_get_value_str (ref
, id
, "name", &tv
);
375 if (status
== ISC_R_SUCCESS
) {
376 group
= (struct group_object
*)0;
377 if (group_name_hash
&&
378 group_hash_lookup (&group
, group_name_hash
,
380 tv
-> value
-> u
.buffer
.value
,
381 tv
-> value
-> u
.buffer
.len
, MDL
)) {
382 omapi_value_dereference (&tv
, MDL
);
384 if (*lp
&& *lp
!= (omapi_object_t
*)group
) {
385 group_object_dereference (&group
, MDL
);
386 omapi_object_dereference (lp
, MDL
);
387 return ISC_R_KEYCONFLICT
;
389 /* XXX fix so that hash lookup itself creates
390 XXX the reference. */
391 omapi_object_reference (lp
,
392 (omapi_object_t
*)group
,
394 group_object_dereference (&group
, MDL
);
397 return ISC_R_NOTFOUND
;
400 /* If we get to here without finding a group, no valid key was
405 if (((struct group_object
*)(*lp
)) -> flags
& GROUP_OBJECT_DELETED
) {
406 omapi_object_dereference (lp
, MDL
);
407 return ISC_R_NOTFOUND
;
409 return ISC_R_SUCCESS
;
412 isc_result_t
dhcp_group_create (omapi_object_t
**lp
,
415 struct group_object
*group
;
417 group
= (struct group_object
*)0;
419 status
= group_object_allocate (&group
, MDL
);
420 if (status
!= ISC_R_SUCCESS
)
422 group
-> flags
= GROUP_OBJECT_DYNAMIC
;
423 status
= omapi_object_reference (lp
, (omapi_object_t
*)group
, MDL
);
424 group_object_dereference (&group
, MDL
);
428 isc_result_t
dhcp_group_remove (omapi_object_t
*lp
,
431 struct group_object
*group
;
433 if (lp
-> type
!= dhcp_type_group
)
434 return ISC_R_INVALIDARG
;
435 group
= (struct group_object
*)lp
;
437 group
-> flags
|= GROUP_OBJECT_DELETED
;
438 if (group_write_hook
) {
439 if (!(*group_write_hook
) (group
))
440 return ISC_R_IOERROR
;
443 status
= dhcp_group_destroy ((omapi_object_t
*)group
, MDL
);
445 return ISC_R_SUCCESS
;
448 isc_result_t
dhcp_control_set_value (omapi_object_t
*h
,
450 omapi_data_string_t
*name
,
451 omapi_typed_data_t
*value
)
453 dhcp_control_object_t
*control
;
455 unsigned long newstate
;
457 if (h
-> type
!= dhcp_type_control
)
458 return ISC_R_INVALIDARG
;
459 control
= (dhcp_control_object_t
*)h
;
461 if (!omapi_ds_strcmp (name
, "state")) {
462 status
= omapi_get_int_value (&newstate
, value
);
463 if (status
!= ISC_R_SUCCESS
)
465 status
= dhcp_set_control_state (control
-> state
, newstate
);
466 if (status
== ISC_R_SUCCESS
)
467 control
-> state
= value
-> u
.integer
;
471 /* Try to find some inner object that can take the value. */
472 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
473 status
= ((*(h
-> inner
-> type
-> set_value
))
474 (h
-> inner
, id
, name
, value
));
475 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
479 return ISC_R_NOTFOUND
;
483 isc_result_t
dhcp_control_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
484 omapi_data_string_t
*name
,
485 omapi_value_t
**value
)
487 dhcp_control_object_t
*control
;
490 if (h
-> type
!= dhcp_type_control
)
491 return ISC_R_INVALIDARG
;
492 control
= (dhcp_control_object_t
*)h
;
494 if (!omapi_ds_strcmp (name
, "state"))
495 return omapi_make_int_value (value
,
496 name
, (int)control
-> state
, MDL
);
498 /* Try to find some inner object that can take the value. */
499 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
500 status
= ((*(h
-> inner
-> type
-> get_value
))
501 (h
-> inner
, id
, name
, value
));
502 if (status
== ISC_R_SUCCESS
)
505 return ISC_R_NOTFOUND
;
508 isc_result_t
dhcp_control_destroy (omapi_object_t
*h
,
509 const char *file
, int line
)
512 if (h
-> type
!= dhcp_type_control
)
513 return ISC_R_INVALIDARG
;
515 /* Can't destroy the control object. */
519 isc_result_t
dhcp_control_signal_handler (omapi_object_t
*h
,
520 const char *name
, va_list ap
)
522 dhcp_control_object_t
*control
;
525 if (h
-> type
!= dhcp_type_control
)
526 return ISC_R_INVALIDARG
;
527 control
= (dhcp_control_object_t
*)h
;
529 /* Try to find some inner object that can take the value. */
530 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
531 status
= ((*(h
-> inner
-> type
-> signal_handler
))
532 (h
-> inner
, name
, ap
));
533 if (status
== ISC_R_SUCCESS
)
536 return ISC_R_NOTFOUND
;
539 isc_result_t
dhcp_control_stuff_values (omapi_object_t
*c
,
543 dhcp_control_object_t
*control
;
546 if (h
-> type
!= dhcp_type_control
)
547 return ISC_R_INVALIDARG
;
548 control
= (dhcp_control_object_t
*)h
;
551 /* Write out all the values. */
552 status
= omapi_connection_put_name (c
, "state");
553 if (status
!= ISC_R_SUCCESS
)
555 status
= omapi_connection_put_uint32 (c
, sizeof (u_int32_t
));
556 if (status
!= ISC_R_SUCCESS
)
558 status
= omapi_connection_put_uint32 (c
, control
-> state
);
559 if (status
!= ISC_R_SUCCESS
)
563 /* Write out the inner object, if any. */
564 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
565 status
= ((*(h
-> inner
-> type
-> stuff_values
))
566 (c
, id
, h
-> inner
));
567 if (status
== ISC_R_SUCCESS
)
571 return ISC_R_SUCCESS
;
574 isc_result_t
dhcp_control_lookup (omapi_object_t
**lp
,
575 omapi_object_t
*id
, omapi_object_t
*ref
)
577 omapi_value_t
*tv
= (omapi_value_t
*)0;
580 /* First see if we were sent a handle. */
582 status
= omapi_get_value_str (ref
, id
, "handle", &tv
);
583 if (status
== ISC_R_SUCCESS
) {
584 status
= omapi_handle_td_lookup (lp
, tv
-> value
);
586 omapi_value_dereference (&tv
, MDL
);
587 if (status
!= ISC_R_SUCCESS
)
590 /* Don't return the object if the type is wrong. */
591 if ((*lp
) -> type
!= dhcp_type_control
) {
592 omapi_object_dereference (lp
, MDL
);
593 return ISC_R_INVALIDARG
;
598 /* Otherwise, stop playing coy - there's only one control object,
599 so we can just return it. */
600 dhcp_control_reference ((dhcp_control_object_t
**)lp
,
601 dhcp_control_object
, MDL
);
602 return ISC_R_SUCCESS
;
605 isc_result_t
dhcp_control_create (omapi_object_t
**lp
,
608 /* Can't create a control object - there can be only one. */
612 isc_result_t
dhcp_control_remove (omapi_object_t
*lp
,
615 /* Form is emptiness; emptiness form. The control object
616 cannot go out of existance. */
620 isc_result_t
dhcp_subnet_set_value (omapi_object_t
*h
,
622 omapi_data_string_t
*name
,
623 omapi_typed_data_t
*value
)
625 struct subnet
*subnet
;
628 if (h
-> type
!= dhcp_type_subnet
)
629 return ISC_R_INVALIDARG
;
630 subnet
= (struct subnet
*)h
;
632 /* No values to set yet. */
634 /* Try to find some inner object that can take the value. */
635 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
636 status
= ((*(h
-> inner
-> type
-> set_value
))
637 (h
-> inner
, id
, name
, value
));
638 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
642 return ISC_R_NOTFOUND
;
646 isc_result_t
dhcp_subnet_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
647 omapi_data_string_t
*name
,
648 omapi_value_t
**value
)
650 struct subnet
*subnet
;
653 if (h
-> type
!= dhcp_type_subnet
)
654 return ISC_R_INVALIDARG
;
655 subnet
= (struct subnet
*)h
;
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
)
666 return ISC_R_NOTFOUND
;
669 isc_result_t
dhcp_subnet_destroy (omapi_object_t
*h
, const char *file
, int line
)
671 struct subnet
*subnet
;
673 if (h
-> type
!= dhcp_type_subnet
)
674 return ISC_R_INVALIDARG
;
675 subnet
= (struct subnet
*)h
;
677 #if defined (DEBUG_MEMORY_LEAKAGE) || \
678 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
679 if (subnet
-> next_subnet
)
680 subnet_dereference (&subnet
-> next_subnet
, file
, line
);
681 if (subnet
-> next_sibling
)
682 subnet_dereference (&subnet
-> next_sibling
, file
, line
);
683 if (subnet
-> shared_network
)
684 shared_network_dereference (&subnet
-> shared_network
,
686 if (subnet
-> interface
)
687 interface_dereference (&subnet
-> interface
, file
, line
);
689 group_dereference (&subnet
-> group
, file
, line
);
692 return ISC_R_SUCCESS
;
695 isc_result_t
dhcp_subnet_signal_handler (omapi_object_t
*h
,
696 const char *name
, va_list ap
)
698 struct subnet
*subnet
;
702 if (h
-> type
!= dhcp_type_subnet
)
703 return ISC_R_INVALIDARG
;
704 subnet
= (struct subnet
*)h
;
706 /* Can't write subnets yet. */
708 /* Try to find some inner object that can take the value. */
709 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
710 status
= ((*(h
-> inner
-> type
-> signal_handler
))
711 (h
-> inner
, name
, ap
));
712 if (status
== ISC_R_SUCCESS
)
716 return ISC_R_SUCCESS
;
717 return ISC_R_NOTFOUND
;
720 isc_result_t
dhcp_subnet_stuff_values (omapi_object_t
*c
,
724 struct subnet
*subnet
;
727 if (h
-> type
!= dhcp_type_subnet
)
728 return ISC_R_INVALIDARG
;
729 subnet
= (struct subnet
*)h
;
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
)
741 return ISC_R_SUCCESS
;
744 isc_result_t
dhcp_subnet_lookup (omapi_object_t
**lp
,
749 /* Can't look up subnets yet. */
751 /* If we get to here without finding a subnet, no valid key was
755 return ISC_R_SUCCESS
;
758 isc_result_t
dhcp_subnet_create (omapi_object_t
**lp
,
761 return ISC_R_NOTIMPLEMENTED
;
764 isc_result_t
dhcp_subnet_remove (omapi_object_t
*lp
,
767 return ISC_R_NOTIMPLEMENTED
;
770 isc_result_t
dhcp_shared_network_set_value (omapi_object_t
*h
,
772 omapi_data_string_t
*name
,
773 omapi_typed_data_t
*value
)
775 struct shared_network
*shared_network
;
778 if (h
-> type
!= dhcp_type_shared_network
)
779 return ISC_R_INVALIDARG
;
780 shared_network
= (struct shared_network
*)h
;
782 /* No values to set yet. */
784 /* Try to find some inner object that can take the value. */
785 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
786 status
= ((*(h
-> inner
-> type
-> set_value
))
787 (h
-> inner
, id
, name
, value
));
788 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
792 return ISC_R_NOTFOUND
;
796 isc_result_t
dhcp_shared_network_get_value (omapi_object_t
*h
,
798 omapi_data_string_t
*name
,
799 omapi_value_t
**value
)
801 struct shared_network
*shared_network
;
804 if (h
-> type
!= dhcp_type_shared_network
)
805 return ISC_R_INVALIDARG
;
806 shared_network
= (struct shared_network
*)h
;
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
)
817 return ISC_R_NOTFOUND
;
820 isc_result_t
dhcp_shared_network_destroy (omapi_object_t
*h
,
821 const char *file
, int line
)
823 struct shared_network
*shared_network
;
825 if (h
-> type
!= dhcp_type_shared_network
)
826 return ISC_R_INVALIDARG
;
827 shared_network
= (struct shared_network
*)h
;
829 #if defined (DEBUG_MEMORY_LEAKAGE) || \
830 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
831 if (shared_network
-> next
)
832 shared_network_dereference (&shared_network
-> next
,
834 if (shared_network
-> name
) {
835 dfree (shared_network
-> name
, file
, line
);
836 shared_network
-> name
= 0;
838 if (shared_network
-> subnets
)
839 subnet_dereference (&shared_network
-> subnets
, file
, line
);
840 if (shared_network
-> interface
)
841 interface_dereference (&shared_network
-> interface
,
843 if (shared_network
-> pools
)
844 omapi_object_dereference ((omapi_object_t
**)
845 &shared_network
-> pools
, file
, line
);
846 if (shared_network
-> group
)
847 group_dereference (&shared_network
-> group
, file
, line
);
848 #if defined (FAILOVER_PROTOCOL)
849 if (shared_network
-> failover_peer
)
850 omapi_object_dereference ((omapi_object_t
**)
851 &shared_network
-> failover_peer
,
854 #endif /* DEBUG_MEMORY_LEAKAGE */
856 return ISC_R_SUCCESS
;
859 isc_result_t
dhcp_shared_network_signal_handler (omapi_object_t
*h
,
863 struct shared_network
*shared_network
;
867 if (h
-> type
!= dhcp_type_shared_network
)
868 return ISC_R_INVALIDARG
;
869 shared_network
= (struct shared_network
*)h
;
871 /* Can't write shared_networks yet. */
873 /* Try to find some inner object that can take the value. */
874 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
875 status
= ((*(h
-> inner
-> type
-> signal_handler
))
876 (h
-> inner
, name
, ap
));
877 if (status
== ISC_R_SUCCESS
)
881 return ISC_R_SUCCESS
;
882 return ISC_R_NOTFOUND
;
885 isc_result_t
dhcp_shared_network_stuff_values (omapi_object_t
*c
,
889 struct shared_network
*shared_network
;
892 if (h
-> type
!= dhcp_type_shared_network
)
893 return ISC_R_INVALIDARG
;
894 shared_network
= (struct shared_network
*)h
;
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
)
906 return ISC_R_SUCCESS
;
909 isc_result_t
dhcp_shared_network_lookup (omapi_object_t
**lp
,
914 /* Can't look up shared_networks yet. */
916 /* If we get to here without finding a shared_network, no valid key was
920 return ISC_R_SUCCESS
;
923 isc_result_t
dhcp_shared_network_create (omapi_object_t
**lp
,
926 return ISC_R_NOTIMPLEMENTED
;
929 isc_result_t
dhcp_shared_network_remove (omapi_object_t
*lp
,
932 return ISC_R_NOTIMPLEMENTED
;