1: /* omapi.c
2:
3: OMAPI object interfaces for the DHCP server. */
4:
5: /*
6: * Copyright (c) 2012 Internet Systems Consortium, Inc. ("ISC")
7: * Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
8: * Copyright (c) 1999-2003 by Internet Software Consortium
9: *
10: * Permission to use, copy, modify, and distribute this software for any
11: * purpose with or without fee is hereby granted, provided that the above
12: * copyright notice and this permission notice appear in all copies.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20: * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21: *
22: * Internet Systems Consortium, Inc.
23: * 950 Charter Street
24: * Redwood City, CA 94063
25: * <info@isc.org>
26: * https://www.isc.org/
27: *
28: * This software has been written for Internet Systems Consortium
29: * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
30: * To learn more about Internet Systems Consortium, see
31: * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
32: * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
33: * ``http://www.nominum.com''.
34: */
35:
36: /* Many, many thanks to Brian Murrell and BCtel for this code - BCtel
37: provided the funding that resulted in this code and the entire
38: OMAPI support library being written, and Brian helped brainstorm
39: and refine the requirements. To the extent that this code is
40: useful, you have Brian and BCtel to thank. Any limitations in the
41: code are a result of mistakes on my part. -- Ted Lemon */
42:
43: #include "dhcpd.h"
44: #include <omapip/omapip_p.h>
45:
46: OMAPI_OBJECT_ALLOC (subnet, struct subnet, dhcp_type_subnet)
47: OMAPI_OBJECT_ALLOC (shared_network, struct shared_network,
48: dhcp_type_shared_network)
49: OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
50: OMAPI_OBJECT_ALLOC (dhcp_control, dhcp_control_object_t, dhcp_type_control)
51:
52: omapi_object_type_t *dhcp_type_interface;
53: omapi_object_type_t *dhcp_type_group;
54: omapi_object_type_t *dhcp_type_shared_network;
55: omapi_object_type_t *dhcp_type_subnet;
56: omapi_object_type_t *dhcp_type_control;
57: dhcp_control_object_t *dhcp_control_object;
58:
59: void dhcp_common_objects_setup ()
60: {
61: isc_result_t status;
62:
63: status = omapi_object_type_register (&dhcp_type_control,
64: "control",
65: dhcp_control_set_value,
66: dhcp_control_get_value,
67: dhcp_control_destroy,
68: dhcp_control_signal_handler,
69: dhcp_control_stuff_values,
70: dhcp_control_lookup,
71: dhcp_control_create,
72: dhcp_control_remove, 0, 0, 0,
73: sizeof (dhcp_control_object_t),
74: 0, RC_MISC);
75: if (status != ISC_R_SUCCESS)
76: log_fatal ("Can't register control object type: %s",
77: isc_result_totext (status));
78: status = dhcp_control_allocate (&dhcp_control_object, MDL);
79: if (status != ISC_R_SUCCESS)
80: log_fatal ("Can't make initial control object: %s",
81: isc_result_totext (status));
82: dhcp_control_object -> state = server_startup;
83:
84: status = omapi_object_type_register (&dhcp_type_group,
85: "group",
86: dhcp_group_set_value,
87: dhcp_group_get_value,
88: dhcp_group_destroy,
89: dhcp_group_signal_handler,
90: dhcp_group_stuff_values,
91: dhcp_group_lookup,
92: dhcp_group_create,
93: dhcp_group_remove, 0, 0, 0,
94: sizeof (struct group_object), 0,
95: RC_MISC);
96: if (status != ISC_R_SUCCESS)
97: log_fatal ("Can't register group object type: %s",
98: isc_result_totext (status));
99:
100: status = omapi_object_type_register (&dhcp_type_subnet,
101: "subnet",
102: dhcp_subnet_set_value,
103: dhcp_subnet_get_value,
104: dhcp_subnet_destroy,
105: dhcp_subnet_signal_handler,
106: dhcp_subnet_stuff_values,
107: dhcp_subnet_lookup,
108: dhcp_subnet_create,
109: dhcp_subnet_remove, 0, 0, 0,
110: sizeof (struct subnet), 0,
111: RC_MISC);
112: if (status != ISC_R_SUCCESS)
113: log_fatal ("Can't register subnet object type: %s",
114: isc_result_totext (status));
115:
116: status = omapi_object_type_register
117: (&dhcp_type_shared_network,
118: "shared-network",
119: dhcp_shared_network_set_value,
120: dhcp_shared_network_get_value,
121: dhcp_shared_network_destroy,
122: dhcp_shared_network_signal_handler,
123: dhcp_shared_network_stuff_values,
124: dhcp_shared_network_lookup,
125: dhcp_shared_network_create,
126: dhcp_shared_network_remove, 0, 0, 0,
127: sizeof (struct shared_network), 0, RC_MISC);
128: if (status != ISC_R_SUCCESS)
129: log_fatal ("Can't register shared network object type: %s",
130: isc_result_totext (status));
131:
132: interface_setup ();
133: }
134:
135: isc_result_t dhcp_group_set_value (omapi_object_t *h,
136: omapi_object_t *id,
137: omapi_data_string_t *name,
138: omapi_typed_data_t *value)
139: {
140: struct group_object *group;
141: isc_result_t status;
142:
143: if (h -> type != dhcp_type_group)
144: return ISC_R_INVALIDARG;
145: group = (struct group_object *)h;
146:
147: /* XXX For now, we can only set these values on new group objects.
148: XXX Soon, we need to be able to update group objects. */
149: if (!omapi_ds_strcmp (name, "name")) {
150: if (group -> name)
151: return ISC_R_EXISTS;
152: if (value -> type == omapi_datatype_data ||
153: value -> type == omapi_datatype_string) {
154: group -> name = dmalloc (value -> u.buffer.len + 1,
155: MDL);
156: if (!group -> name)
157: return ISC_R_NOMEMORY;
158: memcpy (group -> name,
159: value -> u.buffer.value,
160: value -> u.buffer.len);
161: group -> name [value -> u.buffer.len] = 0;
162: } else
163: return ISC_R_INVALIDARG;
164: return ISC_R_SUCCESS;
165: }
166:
167: if (!omapi_ds_strcmp (name, "statements")) {
168: if (group -> group && group -> group -> statements)
169: return ISC_R_EXISTS;
170: if (!group -> group) {
171: if (!clone_group (&group -> group, root_group, MDL))
172: return ISC_R_NOMEMORY;
173: }
174: if (value -> type == omapi_datatype_data ||
175: value -> type == omapi_datatype_string) {
176: struct parse *parse;
177: int lose = 0;
178: parse = NULL;
179: status = new_parse(&parse, -1,
180: (char *) value->u.buffer.value,
181: value->u.buffer.len,
182: "network client", 0);
183: if (status != ISC_R_SUCCESS || parse == NULL)
184: return status;
185: if (!(parse_executable_statements
186: (&group -> group -> statements, parse, &lose,
187: context_any))) {
188: end_parse (&parse);
189: return ISC_R_BADPARSE;
190: }
191: end_parse (&parse);
192: return ISC_R_SUCCESS;
193: } else
194: return ISC_R_INVALIDARG;
195: }
196:
197: /* Try to find some inner object that can take the value. */
198: if (h -> inner && h -> inner -> type -> set_value) {
199: status = ((*(h -> inner -> type -> set_value))
200: (h -> inner, id, name, value));
201: if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
202: return status;
203: }
204:
205: return ISC_R_NOTFOUND;
206: }
207:
208:
209: isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
210: omapi_data_string_t *name,
211: omapi_value_t **value)
212: {
213: struct group_object *group;
214: isc_result_t status;
215:
216: if (h -> type != dhcp_type_group)
217: return ISC_R_INVALIDARG;
218: group = (struct group_object *)h;
219:
220: if (!omapi_ds_strcmp (name, "name"))
221: return omapi_make_string_value (value,
222: name, group -> name, MDL);
223:
224: /* Try to find some inner object that can take the value. */
225: if (h -> inner && h -> inner -> type -> get_value) {
226: status = ((*(h -> inner -> type -> get_value))
227: (h -> inner, id, name, value));
228: if (status == ISC_R_SUCCESS)
229: return status;
230: }
231: return ISC_R_NOTFOUND;
232: }
233:
234: isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
235: {
236: struct group_object *group, *t;
237:
238: if (h -> type != dhcp_type_group)
239: return ISC_R_INVALIDARG;
240: group = (struct group_object *)h;
241:
242: if (group -> name) {
243: if (group_name_hash) {
244: t = (struct group_object *)0;
245: if (group_hash_lookup (&t, group_name_hash,
246: group -> name,
247: strlen (group -> name), MDL)) {
248: group_hash_delete (group_name_hash,
249: group -> name,
250: strlen (group -> name),
251: MDL);
252: group_object_dereference (&t, MDL);
253: }
254: }
255: dfree (group -> name, file, line);
256: group -> name = (char *)0;
257: }
258: if (group -> group)
259: group_dereference (&group -> group, MDL);
260:
261: return ISC_R_SUCCESS;
262: }
263:
264: isc_result_t dhcp_group_signal_handler (omapi_object_t *h,
265: const char *name, va_list ap)
266: {
267: struct group_object *group;
268: isc_result_t status;
269: int updatep = 0;
270:
271: if (h -> type != dhcp_type_group)
272: return ISC_R_INVALIDARG;
273: group = (struct group_object *)h;
274:
275: if (!strcmp (name, "updated")) {
276: /* A group object isn't valid if a subgroup hasn't yet been
277: associated with it. */
278: if (!group -> group)
279: return ISC_R_INVALIDARG;
280:
281: /* Group objects always have to have names. */
282: if (!group -> name) {
283: char hnbuf [64];
284: sprintf (hnbuf, "ng%08lx%08lx",
285: (unsigned long)cur_time,
286: (unsigned long)group);
287: group -> name = dmalloc (strlen (hnbuf) + 1, MDL);
288: if (!group -> name)
289: return ISC_R_NOMEMORY;
290: strcpy (group -> name, hnbuf);
291: }
292:
293: supersede_group (group, 1);
294: updatep = 1;
295: }
296:
297: /* Try to find some inner object that can take the value. */
298: if (h -> inner && h -> inner -> type -> get_value) {
299: status = ((*(h -> inner -> type -> signal_handler))
300: (h -> inner, name, ap));
301: if (status == ISC_R_SUCCESS)
302: return status;
303: }
304: if (updatep)
305: return ISC_R_SUCCESS;
306: return ISC_R_NOTFOUND;
307: }
308:
309: isc_result_t dhcp_group_stuff_values (omapi_object_t *c,
310: omapi_object_t *id,
311: omapi_object_t *h)
312: {
313: struct group_object *group;
314: isc_result_t status;
315:
316: if (h -> type != dhcp_type_group)
317: return ISC_R_INVALIDARG;
318: group = (struct group_object *)h;
319:
320: /* Write out all the values. */
321: if (group -> name) {
322: status = omapi_connection_put_name (c, "name");
323: if (status != ISC_R_SUCCESS)
324: return status;
325: status = omapi_connection_put_string (c, group -> name);
326: if (status != ISC_R_SUCCESS)
327: return status;
328: }
329:
330: /* Write out the inner object, if any. */
331: if (h -> inner && h -> inner -> type -> stuff_values) {
332: status = ((*(h -> inner -> type -> stuff_values))
333: (c, id, h -> inner));
334: if (status == ISC_R_SUCCESS)
335: return status;
336: }
337:
338: return ISC_R_SUCCESS;
339: }
340:
341: isc_result_t dhcp_group_lookup (omapi_object_t **lp,
342: omapi_object_t *id, omapi_object_t *ref)
343: {
344: omapi_value_t *tv = (omapi_value_t *)0;
345: isc_result_t status;
346: struct group_object *group;
347:
348: if (!ref)
349: return ISC_R_NOKEYS;
350:
351: /* First see if we were sent a handle. */
352: status = omapi_get_value_str (ref, id, "handle", &tv);
353: if (status == ISC_R_SUCCESS) {
354: status = omapi_handle_td_lookup (lp, tv -> value);
355:
356: omapi_value_dereference (&tv, MDL);
357: if (status != ISC_R_SUCCESS)
358: return status;
359:
360: /* Don't return the object if the type is wrong. */
361: if ((*lp) -> type != dhcp_type_group) {
362: omapi_object_dereference (lp, MDL);
363: return ISC_R_INVALIDARG;
364: }
365: }
366:
367: /* Now look for a name. */
368: status = omapi_get_value_str (ref, id, "name", &tv);
369: if (status == ISC_R_SUCCESS) {
370: group = (struct group_object *)0;
371: if (group_name_hash &&
372: group_hash_lookup (&group, group_name_hash,
373: (const char *)
374: tv -> value -> u.buffer.value,
375: tv -> value -> u.buffer.len, MDL)) {
376: omapi_value_dereference (&tv, MDL);
377:
378: if (*lp && *lp != (omapi_object_t *)group) {
379: group_object_dereference (&group, MDL);
380: omapi_object_dereference (lp, MDL);
381: return ISC_R_KEYCONFLICT;
382: } else if (!*lp) {
383: /* XXX fix so that hash lookup itself creates
384: XXX the reference. */
385: omapi_object_reference (lp,
386: (omapi_object_t *)group,
387: MDL);
388: group_object_dereference (&group, MDL);
389: }
390: } else if (!*lp)
391: return ISC_R_NOTFOUND;
392: }
393:
394: /* If we get to here without finding a group, no valid key was
395: specified. */
396: if (!*lp)
397: return ISC_R_NOKEYS;
398:
399: if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) {
400: omapi_object_dereference (lp, MDL);
401: return ISC_R_NOTFOUND;
402: }
403: return ISC_R_SUCCESS;
404: }
405:
406: isc_result_t dhcp_group_create (omapi_object_t **lp,
407: omapi_object_t *id)
408: {
409: struct group_object *group;
410: isc_result_t status;
411: group = (struct group_object *)0;
412:
413: status = group_object_allocate (&group, MDL);
414: if (status != ISC_R_SUCCESS)
415: return status;
416: group -> flags = GROUP_OBJECT_DYNAMIC;
417: status = omapi_object_reference (lp, (omapi_object_t *)group, MDL);
418: group_object_dereference (&group, MDL);
419: return status;
420: }
421:
422: isc_result_t dhcp_group_remove (omapi_object_t *lp,
423: omapi_object_t *id)
424: {
425: struct group_object *group;
426: isc_result_t status;
427: if (lp -> type != dhcp_type_group)
428: return ISC_R_INVALIDARG;
429: group = (struct group_object *)lp;
430:
431: group -> flags |= GROUP_OBJECT_DELETED;
432: if (group_write_hook) {
433: if (!(*group_write_hook) (group))
434: return ISC_R_IOERROR;
435: }
436:
437: status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
438:
439: return status;
440: }
441:
442: isc_result_t dhcp_control_set_value (omapi_object_t *h,
443: omapi_object_t *id,
444: omapi_data_string_t *name,
445: omapi_typed_data_t *value)
446: {
447: dhcp_control_object_t *control;
448: isc_result_t status;
449: unsigned long newstate;
450:
451: if (h -> type != dhcp_type_control)
452: return ISC_R_INVALIDARG;
453: control = (dhcp_control_object_t *)h;
454:
455: if (!omapi_ds_strcmp (name, "state")) {
456: status = omapi_get_int_value (&newstate, value);
457: if (status != ISC_R_SUCCESS)
458: return status;
459: status = dhcp_set_control_state (control -> state, newstate);
460: if (status == ISC_R_SUCCESS)
461: control -> state = value -> u.integer;
462: return status;
463: }
464:
465: /* Try to find some inner object that can take the value. */
466: if (h -> inner && h -> inner -> type -> set_value) {
467: status = ((*(h -> inner -> type -> set_value))
468: (h -> inner, id, name, value));
469: if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
470: return status;
471: }
472:
473: return ISC_R_NOTFOUND;
474: }
475:
476:
477: isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,
478: omapi_data_string_t *name,
479: omapi_value_t **value)
480: {
481: dhcp_control_object_t *control;
482: isc_result_t status;
483:
484: if (h -> type != dhcp_type_control)
485: return ISC_R_INVALIDARG;
486: control = (dhcp_control_object_t *)h;
487:
488: if (!omapi_ds_strcmp (name, "state"))
489: return omapi_make_int_value (value,
490: name, (int)control -> state, MDL);
491:
492: /* Try to find some inner object that can take the value. */
493: if (h -> inner && h -> inner -> type -> get_value) {
494: status = ((*(h -> inner -> type -> get_value))
495: (h -> inner, id, name, value));
496: if (status == ISC_R_SUCCESS)
497: return status;
498: }
499: return ISC_R_NOTFOUND;
500: }
501:
502: isc_result_t dhcp_control_destroy (omapi_object_t *h,
503: const char *file, int line)
504: {
505: if (h -> type != dhcp_type_control)
506: return ISC_R_INVALIDARG;
507:
508: /* Can't destroy the control object. */
509: return ISC_R_NOPERM;
510: }
511:
512: isc_result_t dhcp_control_signal_handler (omapi_object_t *h,
513: const char *name, va_list ap)
514: {
515: /* In this function h should be a (dhcp_control_object_t *) */
516: isc_result_t status;
517:
518: if (h -> type != dhcp_type_control)
519: return ISC_R_INVALIDARG;
520:
521: /* Try to find some inner object that can take the value. */
522: if (h -> inner && h -> inner -> type -> get_value) {
523: status = ((*(h -> inner -> type -> signal_handler))
524: (h -> inner, name, ap));
525: if (status == ISC_R_SUCCESS)
526: return status;
527: }
528: return ISC_R_NOTFOUND;
529: }
530:
531: isc_result_t dhcp_control_stuff_values (omapi_object_t *c,
532: omapi_object_t *id,
533: omapi_object_t *h)
534: {
535: dhcp_control_object_t *control;
536: isc_result_t status;
537:
538: if (h -> type != dhcp_type_control)
539: return ISC_R_INVALIDARG;
540: control = (dhcp_control_object_t *)h;
541:
542: /* Write out all the values. */
543: status = omapi_connection_put_name (c, "state");
544: if (status != ISC_R_SUCCESS)
545: return status;
546: status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));
547: if (status != ISC_R_SUCCESS)
548: return status;
549: status = omapi_connection_put_uint32 (c, control -> state);
550: if (status != ISC_R_SUCCESS)
551: return status;
552:
553: /* Write out the inner object, if any. */
554: if (h -> inner && h -> inner -> type -> stuff_values) {
555: status = ((*(h -> inner -> type -> stuff_values))
556: (c, id, h -> inner));
557: if (status == ISC_R_SUCCESS)
558: return status;
559: }
560:
561: return ISC_R_SUCCESS;
562: }
563:
564: isc_result_t dhcp_control_lookup (omapi_object_t **lp,
565: omapi_object_t *id, omapi_object_t *ref)
566: {
567: omapi_value_t *tv = (omapi_value_t *)0;
568: isc_result_t status;
569:
570: /* First see if we were sent a handle. */
571: if (ref) {
572: status = omapi_get_value_str (ref, id, "handle", &tv);
573: if (status == ISC_R_SUCCESS) {
574: status = omapi_handle_td_lookup (lp, tv -> value);
575:
576: omapi_value_dereference (&tv, MDL);
577: if (status != ISC_R_SUCCESS)
578: return status;
579:
580: /* Don't return the object if the type is wrong. */
581: if ((*lp) -> type != dhcp_type_control) {
582: omapi_object_dereference (lp, MDL);
583: return ISC_R_INVALIDARG;
584: }
585: }
586: }
587:
588: /* Otherwise, stop playing coy - there's only one control object,
589: so we can just return it. */
590: dhcp_control_reference ((dhcp_control_object_t **)lp,
591: dhcp_control_object, MDL);
592: return ISC_R_SUCCESS;
593: }
594:
595: isc_result_t dhcp_control_create (omapi_object_t **lp,
596: omapi_object_t *id)
597: {
598: /* Can't create a control object - there can be only one. */
599: return ISC_R_NOPERM;
600: }
601:
602: isc_result_t dhcp_control_remove (omapi_object_t *lp,
603: omapi_object_t *id)
604: {
605: /* Form is emptiness; emptiness form. The control object
606: cannot go out of existance. */
607: return ISC_R_NOPERM;
608: }
609:
610: isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
611: omapi_object_t *id,
612: omapi_data_string_t *name,
613: omapi_typed_data_t *value)
614: {
615: /* In this function h should be a (struct subnet *) */
616: isc_result_t status;
617:
618: if (h -> type != dhcp_type_subnet)
619: return ISC_R_INVALIDARG;
620:
621: /* No values to set yet. */
622:
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 == ISC_R_UNCHANGED)
628: return status;
629: }
630:
631: return ISC_R_NOTFOUND;
632: }
633:
634:
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)
638: {
639: /* In this function h should be a (struct subnet *) */
640: isc_result_t status;
641:
642: if (h -> type != dhcp_type_subnet)
643: return ISC_R_INVALIDARG;
644:
645: /* No values to get yet. */
646:
647: /* Try to find some inner object that can provide the value. */
648: if (h -> inner && h -> inner -> type -> get_value) {
649: status = ((*(h -> inner -> type -> get_value))
650: (h -> inner, id, name, value));
651: if (status == ISC_R_SUCCESS)
652: return status;
653: }
654: return ISC_R_NOTFOUND;
655: }
656:
657: isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
658: {
659:
660: if (h -> type != dhcp_type_subnet)
661: return ISC_R_INVALIDARG;
662:
663: #if defined (DEBUG_MEMORY_LEAKAGE) || \
664: defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
665: struct subnet *subnet = (struct subnet *)h;
666:
667: if (subnet -> next_subnet)
668: subnet_dereference (&subnet -> next_subnet, file, line);
669: if (subnet -> next_sibling)
670: subnet_dereference (&subnet -> next_sibling, file, line);
671: if (subnet -> shared_network)
672: shared_network_dereference (&subnet -> shared_network,
673: file, line);
674: if (subnet -> interface)
675: interface_dereference (&subnet -> interface, file, line);
676: if (subnet -> group)
677: group_dereference (&subnet -> group, file, line);
678: #endif
679:
680: return ISC_R_SUCCESS;
681: }
682:
683: isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h,
684: const char *name, va_list ap)
685: {
686: /* In this function h should be a (struct subnet *) */
687: isc_result_t status;
688: int updatep = 0;
689:
690: if (h -> type != dhcp_type_subnet)
691: return ISC_R_INVALIDARG;
692:
693: /* Can't write subnets yet. */
694:
695: /* Try to find some inner object that can take the value. */
696: if (h -> inner && h -> inner -> type -> get_value) {
697: status = ((*(h -> inner -> type -> signal_handler))
698: (h -> inner, name, ap));
699: if (status == ISC_R_SUCCESS)
700: return status;
701: }
702: if (updatep)
703: return ISC_R_SUCCESS;
704: return ISC_R_NOTFOUND;
705: }
706:
707: isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c,
708: omapi_object_t *id,
709: omapi_object_t *h)
710: {
711: /* In this function h should be a (struct subnet *) */
712: isc_result_t status;
713:
714: if (h -> type != dhcp_type_subnet)
715: return ISC_R_INVALIDARG;
716:
717: /* Can't stuff subnet values yet. */
718:
719: /* Write out the inner object, if any. */
720: if (h -> inner && h -> inner -> type -> stuff_values) {
721: status = ((*(h -> inner -> type -> stuff_values))
722: (c, id, h -> inner));
723: if (status == ISC_R_SUCCESS)
724: return status;
725: }
726:
727: return ISC_R_SUCCESS;
728: }
729:
730: isc_result_t dhcp_subnet_lookup (omapi_object_t **lp,
731: omapi_object_t *id,
732: omapi_object_t *ref)
733: {
734: /* Can't look up subnets yet. */
735:
736: /* If we get to here without finding a subnet, no valid key was
737: specified. */
738: if (!*lp)
739: return ISC_R_NOKEYS;
740: return ISC_R_SUCCESS;
741: }
742:
743: isc_result_t dhcp_subnet_create (omapi_object_t **lp,
744: omapi_object_t *id)
745: {
746: return ISC_R_NOTIMPLEMENTED;
747: }
748:
749: isc_result_t dhcp_subnet_remove (omapi_object_t *lp,
750: omapi_object_t *id)
751: {
752: return ISC_R_NOTIMPLEMENTED;
753: }
754:
755: isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
756: omapi_object_t *id,
757: omapi_data_string_t *name,
758: omapi_typed_data_t *value)
759: {
760: /* In this function h should be a (struct shared_network *) */
761: isc_result_t status;
762:
763: if (h -> type != dhcp_type_shared_network)
764: return ISC_R_INVALIDARG;
765:
766: /* No values to set yet. */
767:
768: /* Try to find some inner object that can take the value. */
769: if (h -> inner && h -> inner -> type -> set_value) {
770: status = ((*(h -> inner -> type -> set_value))
771: (h -> inner, id, name, value));
772: if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
773: return status;
774: }
775:
776: return ISC_R_NOTFOUND;
777: }
778:
779:
780: isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
781: omapi_object_t *id,
782: omapi_data_string_t *name,
783: omapi_value_t **value)
784: {
785: /* In this function h should be a (struct shared_network *) */
786: isc_result_t status;
787:
788: if (h -> type != dhcp_type_shared_network)
789: return ISC_R_INVALIDARG;
790:
791: /* No values to get yet. */
792:
793: /* Try to find some inner object that can provide the value. */
794: if (h -> inner && h -> inner -> type -> get_value) {
795: status = ((*(h -> inner -> type -> get_value))
796: (h -> inner, id, name, value));
797: if (status == ISC_R_SUCCESS)
798: return status;
799: }
800: return ISC_R_NOTFOUND;
801: }
802:
803: isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
804: const char *file, int line)
805: {
806: /* In this function h should be a (struct shared_network *) */
807:
808: if (h -> type != dhcp_type_shared_network)
809: return ISC_R_INVALIDARG;
810:
811: #if defined (DEBUG_MEMORY_LEAKAGE) || \
812: defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
813: struct shared_network *shared_network = (struct shared_network *)h;
814: if (shared_network -> next)
815: shared_network_dereference (&shared_network -> next,
816: file, line);
817: if (shared_network -> name) {
818: dfree (shared_network -> name, file, line);
819: shared_network -> name = 0;
820: }
821: if (shared_network -> subnets)
822: subnet_dereference (&shared_network -> subnets, file, line);
823: if (shared_network -> interface)
824: interface_dereference (&shared_network -> interface,
825: file, line);
826: if (shared_network -> pools)
827: omapi_object_dereference ((omapi_object_t **)
828: &shared_network -> pools, file, line);
829: if (shared_network -> group)
830: group_dereference (&shared_network -> group, file, line);
831: #if defined (FAILOVER_PROTOCOL)
832: if (shared_network -> failover_peer)
833: omapi_object_dereference ((omapi_object_t **)
834: &shared_network -> failover_peer,
835: file, line);
836: #endif
837: #endif /* DEBUG_MEMORY_LEAKAGE */
838:
839: return ISC_R_SUCCESS;
840: }
841:
842: isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h,
843: const char *name,
844: va_list ap)
845: {
846: /* In this function h should be a (struct shared_network *) */
847: isc_result_t status;
848: int updatep = 0;
849:
850: if (h -> type != dhcp_type_shared_network)
851: return ISC_R_INVALIDARG;
852:
853: /* Can't write shared_networks yet. */
854:
855: /* Try to find some inner object that can take the value. */
856: if (h -> inner && h -> inner -> type -> get_value) {
857: status = ((*(h -> inner -> type -> signal_handler))
858: (h -> inner, name, ap));
859: if (status == ISC_R_SUCCESS)
860: return status;
861: }
862: if (updatep)
863: return ISC_R_SUCCESS;
864: return ISC_R_NOTFOUND;
865: }
866:
867: isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c,
868: omapi_object_t *id,
869: omapi_object_t *h)
870: {
871: /* In this function h should be a (struct shared_network *) */
872: isc_result_t status;
873:
874: if (h -> type != dhcp_type_shared_network)
875: return ISC_R_INVALIDARG;
876:
877: /* Can't stuff shared_network values yet. */
878:
879: /* Write out the inner object, if any. */
880: if (h -> inner && h -> inner -> type -> stuff_values) {
881: status = ((*(h -> inner -> type -> stuff_values))
882: (c, id, h -> inner));
883: if (status == ISC_R_SUCCESS)
884: return status;
885: }
886:
887: return ISC_R_SUCCESS;
888: }
889:
890: isc_result_t dhcp_shared_network_lookup (omapi_object_t **lp,
891: omapi_object_t *id,
892: omapi_object_t *ref)
893: {
894: /* Can't look up shared_networks yet. */
895:
896: /* If we get to here without finding a shared_network, no valid key was
897: specified. */
898: if (!*lp)
899: return ISC_R_NOKEYS;
900: return ISC_R_SUCCESS;
901: }
902:
903: isc_result_t dhcp_shared_network_create (omapi_object_t **lp,
904: omapi_object_t *id)
905: {
906: return ISC_R_NOTIMPLEMENTED;
907: }
908:
909: isc_result_t dhcp_shared_network_remove (omapi_object_t *lp,
910: omapi_object_t *id)
911: {
912: return ISC_R_NOTIMPLEMENTED;
913: }
914:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>