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$ 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
;
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")) {
157 if (value
-> type
== omapi_datatype_data
||
158 value
-> type
== omapi_datatype_string
) {
159 group
-> name
= dmalloc (value
-> u
.buffer
.len
+ 1,
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;
168 return ISC_R_INVALIDARG
;
169 return ISC_R_SUCCESS
;
172 if (!omapi_ds_strcmp (name
, "statements")) {
173 if (group
-> group
&& group
-> group
-> statements
)
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
) {
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
)
190 if (!(parse_executable_statements
191 (&group
-> group
-> statements
, parse
, &lose
,
194 return ISC_R_BADPARSE
;
197 return ISC_R_SUCCESS
;
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
)
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
;
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
)
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
;
245 if (h
-> type
!= dhcp_type_group
)
246 return ISC_R_INVALIDARG
;
247 group
= (struct group_object
*)h
;
250 if (group_name_hash
) {
251 t
= (struct group_object
*)0;
252 if (group_hash_lookup (&t
, group_name_hash
,
254 strlen (group
-> name
), MDL
)) {
255 group_hash_delete (group_name_hash
,
257 strlen (group
-> name
),
259 group_object_dereference (&t
, MDL
);
262 dfree (group
-> name
, file
, line
);
263 group
-> name
= (char *)0;
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
, *t
;
278 if (h
-> type
!= dhcp_type_group
)
279 return ISC_R_INVALIDARG
;
280 group
= (struct group_object
*)h
;
282 if (!strcmp (name
, "updated")) {
283 /* A group object isn't valid if a subgroup hasn't yet been
284 associated with it. */
286 return ISC_R_INVALIDARG
;
288 /* Group objects always have to have names. */
289 if (!group
-> name
) {
291 sprintf (hnbuf
, "ng%08lx%08lx",
292 (unsigned long)cur_time
,
293 (unsigned long)group
);
294 group
-> name
= dmalloc (strlen (hnbuf
) + 1, MDL
);
296 return ISC_R_NOMEMORY
;
297 strcpy (group
-> name
, hnbuf
);
300 supersede_group (group
, 1);
304 /* Try to find some inner object that can take the value. */
305 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
306 status
= ((*(h
-> inner
-> type
-> signal_handler
))
307 (h
-> inner
, name
, ap
));
308 if (status
== ISC_R_SUCCESS
)
312 return ISC_R_SUCCESS
;
313 return ISC_R_NOTFOUND
;
316 isc_result_t
dhcp_group_stuff_values (omapi_object_t
*c
,
320 struct group_object
*group
;
323 if (h
-> type
!= dhcp_type_group
)
324 return ISC_R_INVALIDARG
;
325 group
= (struct group_object
*)h
;
327 /* Write out all the values. */
329 status
= omapi_connection_put_name (c
, "name");
330 if (status
!= ISC_R_SUCCESS
)
332 status
= omapi_connection_put_string (c
, group
-> name
);
333 if (status
!= ISC_R_SUCCESS
)
337 /* Write out the inner object, if any. */
338 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
339 status
= ((*(h
-> inner
-> type
-> stuff_values
))
340 (c
, id
, h
-> inner
));
341 if (status
== ISC_R_SUCCESS
)
345 return ISC_R_SUCCESS
;
348 isc_result_t
dhcp_group_lookup (omapi_object_t
**lp
,
349 omapi_object_t
*id
, omapi_object_t
*ref
)
351 omapi_value_t
*tv
= (omapi_value_t
*)0;
353 struct group_object
*group
;
358 /* First see if we were sent a handle. */
359 status
= omapi_get_value_str (ref
, id
, "handle", &tv
);
360 if (status
== ISC_R_SUCCESS
) {
361 status
= omapi_handle_td_lookup (lp
, tv
-> value
);
363 omapi_value_dereference (&tv
, MDL
);
364 if (status
!= ISC_R_SUCCESS
)
367 /* Don't return the object if the type is wrong. */
368 if ((*lp
) -> type
!= dhcp_type_group
) {
369 omapi_object_dereference (lp
, MDL
);
370 return ISC_R_INVALIDARG
;
374 /* Now look for a name. */
375 status
= omapi_get_value_str (ref
, id
, "name", &tv
);
376 if (status
== ISC_R_SUCCESS
) {
377 group
= (struct group_object
*)0;
378 if (group_name_hash
&&
379 group_hash_lookup (&group
, group_name_hash
,
381 tv
-> value
-> u
.buffer
.value
,
382 tv
-> value
-> u
.buffer
.len
, MDL
)) {
383 omapi_value_dereference (&tv
, MDL
);
385 if (*lp
&& *lp
!= (omapi_object_t
*)group
) {
386 group_object_dereference (&group
, MDL
);
387 omapi_object_dereference (lp
, MDL
);
388 return ISC_R_KEYCONFLICT
;
390 /* XXX fix so that hash lookup itself creates
391 XXX the reference. */
392 omapi_object_reference (lp
,
393 (omapi_object_t
*)group
,
395 group_object_dereference (&group
, MDL
);
398 return ISC_R_NOTFOUND
;
401 /* If we get to here without finding a group, no valid key was
406 if (((struct group_object
*)(*lp
)) -> flags
& GROUP_OBJECT_DELETED
) {
407 omapi_object_dereference (lp
, MDL
);
408 return ISC_R_NOTFOUND
;
410 return ISC_R_SUCCESS
;
413 isc_result_t
dhcp_group_create (omapi_object_t
**lp
,
416 struct group_object
*group
;
418 group
= (struct group_object
*)0;
420 status
= group_object_allocate (&group
, MDL
);
421 if (status
!= ISC_R_SUCCESS
)
423 group
-> flags
= GROUP_OBJECT_DYNAMIC
;
424 status
= omapi_object_reference (lp
, (omapi_object_t
*)group
, MDL
);
425 group_object_dereference (&group
, MDL
);
429 isc_result_t
dhcp_group_remove (omapi_object_t
*lp
,
432 struct group_object
*group
;
434 if (lp
-> type
!= dhcp_type_group
)
435 return ISC_R_INVALIDARG
;
436 group
= (struct group_object
*)lp
;
438 group
-> flags
|= GROUP_OBJECT_DELETED
;
439 if (group_write_hook
) {
440 if (!(*group_write_hook
) (group
))
441 return ISC_R_IOERROR
;
444 status
= dhcp_group_destroy ((omapi_object_t
*)group
, MDL
);
446 return ISC_R_SUCCESS
;
449 isc_result_t
dhcp_control_set_value (omapi_object_t
*h
,
451 omapi_data_string_t
*name
,
452 omapi_typed_data_t
*value
)
454 dhcp_control_object_t
*control
;
457 unsigned long newstate
;
459 if (h
-> type
!= dhcp_type_control
)
460 return ISC_R_INVALIDARG
;
461 control
= (dhcp_control_object_t
*)h
;
463 if (!omapi_ds_strcmp (name
, "state")) {
464 status
= omapi_get_int_value (&newstate
, value
);
465 if (status
!= ISC_R_SUCCESS
)
467 status
= dhcp_set_control_state (control
-> state
, newstate
);
468 if (status
== ISC_R_SUCCESS
)
469 control
-> state
= value
-> u
.integer
;
473 /* Try to find some inner object that can take the value. */
474 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
475 status
= ((*(h
-> inner
-> type
-> set_value
))
476 (h
-> inner
, id
, name
, value
));
477 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
481 return ISC_R_NOTFOUND
;
485 isc_result_t
dhcp_control_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
486 omapi_data_string_t
*name
,
487 omapi_value_t
**value
)
489 dhcp_control_object_t
*control
;
491 struct data_string ip_addrs
;
493 if (h
-> type
!= dhcp_type_control
)
494 return ISC_R_INVALIDARG
;
495 control
= (dhcp_control_object_t
*)h
;
497 if (!omapi_ds_strcmp (name
, "state"))
498 return omapi_make_int_value (value
,
499 name
, (int)control
-> state
, MDL
);
501 /* Try to find some inner object that can take the value. */
502 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
503 status
= ((*(h
-> inner
-> type
-> get_value
))
504 (h
-> inner
, id
, name
, value
));
505 if (status
== ISC_R_SUCCESS
)
508 return ISC_R_NOTFOUND
;
511 isc_result_t
dhcp_control_destroy (omapi_object_t
*h
,
512 const char *file
, int line
)
514 dhcp_control_object_t
*control
, *t
;
517 if (h
-> type
!= dhcp_type_control
)
518 return ISC_R_INVALIDARG
;
520 /* Can't destroy the control object. */
524 isc_result_t
dhcp_control_signal_handler (omapi_object_t
*h
,
525 const char *name
, va_list ap
)
527 dhcp_control_object_t
*control
, *t
;
531 if (h
-> type
!= dhcp_type_control
)
532 return ISC_R_INVALIDARG
;
533 control
= (dhcp_control_object_t
*)h
;
535 /* Try to find some inner object that can take the value. */
536 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
537 status
= ((*(h
-> inner
-> type
-> signal_handler
))
538 (h
-> inner
, name
, ap
));
539 if (status
== ISC_R_SUCCESS
)
542 return ISC_R_NOTFOUND
;
545 isc_result_t
dhcp_control_stuff_values (omapi_object_t
*c
,
549 dhcp_control_object_t
*control
;
552 if (h
-> type
!= dhcp_type_control
)
553 return ISC_R_INVALIDARG
;
554 control
= (dhcp_control_object_t
*)h
;
556 /* Write out all the values. */
557 status
= omapi_connection_put_name (c
, "state");
558 if (status
!= ISC_R_SUCCESS
)
560 status
= omapi_connection_put_uint32 (c
, sizeof (u_int32_t
));
561 if (status
!= ISC_R_SUCCESS
)
563 status
= omapi_connection_put_uint32 (c
, control
-> state
);
564 if (status
!= ISC_R_SUCCESS
)
567 /* Write out the inner object, if any. */
568 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
569 status
= ((*(h
-> inner
-> type
-> stuff_values
))
570 (c
, id
, h
-> inner
));
571 if (status
== ISC_R_SUCCESS
)
575 return ISC_R_SUCCESS
;
578 isc_result_t
dhcp_control_lookup (omapi_object_t
**lp
,
579 omapi_object_t
*id
, omapi_object_t
*ref
)
581 omapi_value_t
*tv
= (omapi_value_t
*)0;
583 dhcp_control_object_t
*control
;
585 /* First see if we were sent a handle. */
587 status
= omapi_get_value_str (ref
, id
, "handle", &tv
);
588 if (status
== ISC_R_SUCCESS
) {
589 status
= omapi_handle_td_lookup (lp
, tv
-> value
);
591 omapi_value_dereference (&tv
, MDL
);
592 if (status
!= ISC_R_SUCCESS
)
595 /* Don't return the object if the type is wrong. */
596 if ((*lp
) -> type
!= dhcp_type_control
) {
597 omapi_object_dereference (lp
, MDL
);
598 return ISC_R_INVALIDARG
;
603 /* Otherwise, stop playing coy - there's only one control object,
604 so we can just return it. */
605 dhcp_control_reference ((dhcp_control_object_t
**)lp
,
606 dhcp_control_object
, MDL
);
607 return ISC_R_SUCCESS
;
610 isc_result_t
dhcp_control_create (omapi_object_t
**lp
,
613 /* Can't create a control object - there can be only one. */
617 isc_result_t
dhcp_control_remove (omapi_object_t
*lp
,
620 /* Form is emptiness; emptiness form. The control object
621 cannot go out of existance. */
625 isc_result_t
dhcp_subnet_set_value (omapi_object_t
*h
,
627 omapi_data_string_t
*name
,
628 omapi_typed_data_t
*value
)
630 struct subnet
*subnet
;
634 if (h
-> type
!= dhcp_type_subnet
)
635 return ISC_R_INVALIDARG
;
636 subnet
= (struct subnet
*)h
;
638 /* No values to set yet. */
640 /* Try to find some inner object that can take the value. */
641 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
642 status
= ((*(h
-> inner
-> type
-> set_value
))
643 (h
-> inner
, id
, name
, value
));
644 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
648 return ISC_R_NOTFOUND
;
652 isc_result_t
dhcp_subnet_get_value (omapi_object_t
*h
, omapi_object_t
*id
,
653 omapi_data_string_t
*name
,
654 omapi_value_t
**value
)
656 struct subnet
*subnet
;
659 if (h
-> type
!= dhcp_type_subnet
)
660 return ISC_R_INVALIDARG
;
661 subnet
= (struct subnet
*)h
;
663 /* No values to get yet. */
665 /* Try to find some inner object that can provide the value. */
666 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
667 status
= ((*(h
-> inner
-> type
-> get_value
))
668 (h
-> inner
, id
, name
, value
));
669 if (status
== ISC_R_SUCCESS
)
672 return ISC_R_NOTFOUND
;
675 isc_result_t
dhcp_subnet_destroy (omapi_object_t
*h
, const char *file
, int line
)
677 struct subnet
*subnet
;
680 if (h
-> type
!= dhcp_type_subnet
)
681 return ISC_R_INVALIDARG
;
682 subnet
= (struct subnet
*)h
;
684 #if defined (DEBUG_MEMORY_LEAKAGE) || \
685 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
686 if (subnet
-> next_subnet
)
687 subnet_dereference (&subnet
-> next_subnet
, file
, line
);
688 if (subnet
-> next_sibling
)
689 subnet_dereference (&subnet
-> next_sibling
, file
, line
);
690 if (subnet
-> shared_network
)
691 shared_network_dereference (&subnet
-> shared_network
,
693 if (subnet
-> interface
)
694 interface_dereference (&subnet
-> interface
, file
, line
);
696 group_dereference (&subnet
-> group
, file
, line
);
699 return ISC_R_SUCCESS
;
702 isc_result_t
dhcp_subnet_signal_handler (omapi_object_t
*h
,
703 const char *name
, va_list ap
)
705 struct subnet
*subnet
;
709 if (h
-> type
!= dhcp_type_subnet
)
710 return ISC_R_INVALIDARG
;
711 subnet
= (struct subnet
*)h
;
713 /* Can't write subnets yet. */
715 /* Try to find some inner object that can take the value. */
716 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
717 status
= ((*(h
-> inner
-> type
-> signal_handler
))
718 (h
-> inner
, name
, ap
));
719 if (status
== ISC_R_SUCCESS
)
723 return ISC_R_SUCCESS
;
724 return ISC_R_NOTFOUND
;
727 isc_result_t
dhcp_subnet_stuff_values (omapi_object_t
*c
,
731 struct subnet
*subnet
;
734 if (h
-> type
!= dhcp_type_subnet
)
735 return ISC_R_INVALIDARG
;
736 subnet
= (struct subnet
*)h
;
738 /* Can't stuff subnet values yet. */
740 /* Write out the inner object, if any. */
741 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
742 status
= ((*(h
-> inner
-> type
-> stuff_values
))
743 (c
, id
, h
-> inner
));
744 if (status
== ISC_R_SUCCESS
)
748 return ISC_R_SUCCESS
;
751 isc_result_t
dhcp_subnet_lookup (omapi_object_t
**lp
,
755 omapi_value_t
*tv
= (omapi_value_t
*)0;
757 struct subnet
*subnet
;
759 /* Can't look up subnets yet. */
761 /* If we get to here without finding a subnet, no valid key was
765 return ISC_R_SUCCESS
;
768 isc_result_t
dhcp_subnet_create (omapi_object_t
**lp
,
771 return ISC_R_NOTIMPLEMENTED
;
774 isc_result_t
dhcp_subnet_remove (omapi_object_t
*lp
,
777 return ISC_R_NOTIMPLEMENTED
;
780 isc_result_t
dhcp_shared_network_set_value (omapi_object_t
*h
,
782 omapi_data_string_t
*name
,
783 omapi_typed_data_t
*value
)
785 struct shared_network
*shared_network
;
789 if (h
-> type
!= dhcp_type_shared_network
)
790 return ISC_R_INVALIDARG
;
791 shared_network
= (struct shared_network
*)h
;
793 /* No values to set yet. */
795 /* Try to find some inner object that can take the value. */
796 if (h
-> inner
&& h
-> inner
-> type
-> set_value
) {
797 status
= ((*(h
-> inner
-> type
-> set_value
))
798 (h
-> inner
, id
, name
, value
));
799 if (status
== ISC_R_SUCCESS
|| status
== ISC_R_UNCHANGED
)
803 return ISC_R_NOTFOUND
;
807 isc_result_t
dhcp_shared_network_get_value (omapi_object_t
*h
,
809 omapi_data_string_t
*name
,
810 omapi_value_t
**value
)
812 struct shared_network
*shared_network
;
815 if (h
-> type
!= dhcp_type_shared_network
)
816 return ISC_R_INVALIDARG
;
817 shared_network
= (struct shared_network
*)h
;
819 /* No values to get yet. */
821 /* Try to find some inner object that can provide the value. */
822 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
823 status
= ((*(h
-> inner
-> type
-> get_value
))
824 (h
-> inner
, id
, name
, value
));
825 if (status
== ISC_R_SUCCESS
)
828 return ISC_R_NOTFOUND
;
831 isc_result_t
dhcp_shared_network_destroy (omapi_object_t
*h
,
832 const char *file
, int line
)
834 struct shared_network
*shared_network
;
837 if (h
-> type
!= dhcp_type_shared_network
)
838 return ISC_R_INVALIDARG
;
839 shared_network
= (struct shared_network
*)h
;
841 #if defined (DEBUG_MEMORY_LEAKAGE) || \
842 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
843 if (shared_network
-> next
)
844 shared_network_dereference (&shared_network
-> next
,
846 if (shared_network
-> name
) {
847 dfree (shared_network
-> name
, file
, line
);
848 shared_network
-> name
= 0;
850 if (shared_network
-> subnets
)
851 subnet_dereference (&shared_network
-> subnets
, file
, line
);
852 if (shared_network
-> interface
)
853 interface_dereference (&shared_network
-> interface
,
855 if (shared_network
-> pools
)
856 omapi_object_dereference ((omapi_object_t
**)
857 &shared_network
-> pools
, file
, line
);
858 if (shared_network
-> group
)
859 group_dereference (&shared_network
-> group
, file
, line
);
860 #if defined (FAILOVER_PROTOCOL)
861 if (shared_network
-> failover_peer
)
862 omapi_object_dereference ((omapi_object_t
**)
863 &shared_network
-> failover_peer
,
866 #endif /* DEBUG_MEMORY_LEAKAGE */
868 return ISC_R_SUCCESS
;
871 isc_result_t
dhcp_shared_network_signal_handler (omapi_object_t
*h
,
875 struct shared_network
*shared_network
;
879 if (h
-> type
!= dhcp_type_shared_network
)
880 return ISC_R_INVALIDARG
;
881 shared_network
= (struct shared_network
*)h
;
883 /* Can't write shared_networks yet. */
885 /* Try to find some inner object that can take the value. */
886 if (h
-> inner
&& h
-> inner
-> type
-> get_value
) {
887 status
= ((*(h
-> inner
-> type
-> signal_handler
))
888 (h
-> inner
, name
, ap
));
889 if (status
== ISC_R_SUCCESS
)
893 return ISC_R_SUCCESS
;
894 return ISC_R_NOTFOUND
;
897 isc_result_t
dhcp_shared_network_stuff_values (omapi_object_t
*c
,
901 struct shared_network
*shared_network
;
904 if (h
-> type
!= dhcp_type_shared_network
)
905 return ISC_R_INVALIDARG
;
906 shared_network
= (struct shared_network
*)h
;
908 /* Can't stuff shared_network values yet. */
910 /* Write out the inner object, if any. */
911 if (h
-> inner
&& h
-> inner
-> type
-> stuff_values
) {
912 status
= ((*(h
-> inner
-> type
-> stuff_values
))
913 (c
, id
, h
-> inner
));
914 if (status
== ISC_R_SUCCESS
)
918 return ISC_R_SUCCESS
;
921 isc_result_t
dhcp_shared_network_lookup (omapi_object_t
**lp
,
925 omapi_value_t
*tv
= (omapi_value_t
*)0;
927 struct shared_network
*shared_network
;
929 /* Can't look up shared_networks yet. */
931 /* If we get to here without finding a shared_network, no valid key was
935 return ISC_R_SUCCESS
;
938 isc_result_t
dhcp_shared_network_create (omapi_object_t
**lp
,
941 return ISC_R_NOTIMPLEMENTED
;
944 isc_result_t
dhcp_shared_network_remove (omapi_object_t
*lp
,
947 return ISC_R_NOTIMPLEMENTED
;