ISC DHCP  4.3.2
A reference DHCPv4 and DHCPv6 implementation
comapi.c
Go to the documentation of this file.
1 /* omapi.c
2 
3  OMAPI object interfaces for the DHCP server. */
4 
5 /*
6  * Copyright (c) 2012,2014 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  */
29 
30 /* Many, many thanks to Brian Murrell and BCtel for this code - BCtel
31  provided the funding that resulted in this code and the entire
32  OMAPI support library being written, and Brian helped brainstorm
33  and refine the requirements. To the extent that this code is
34  useful, you have Brian and BCtel to thank. Any limitations in the
35  code are a result of mistakes on my part. -- Ted Lemon */
36 
37 #include "dhcpd.h"
38 #include <omapip/omapip_p.h>
39 
41 OMAPI_OBJECT_ALLOC (shared_network, struct shared_network,
43 OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
45 
51 dhcp_control_object_t *dhcp_control_object;
52 
54 {
55  isc_result_t status;
56 
57  status = omapi_object_type_register (&dhcp_type_control,
58  "control",
66  dhcp_control_remove, 0, 0, 0,
67  sizeof (dhcp_control_object_t),
68  0, RC_MISC);
69  if (status != ISC_R_SUCCESS)
70  log_fatal ("Can't register control object type: %s",
71  isc_result_totext (status));
72  status = dhcp_control_allocate (&dhcp_control_object, MDL);
73  if (status != ISC_R_SUCCESS)
74  log_fatal ("Can't make initial control object: %s",
75  isc_result_totext (status));
76  dhcp_control_object -> state = server_startup;
77 
78  status = omapi_object_type_register (&dhcp_type_group,
79  "group",
87  dhcp_group_remove, 0, 0, 0,
88  sizeof (struct group_object), 0,
89  RC_MISC);
90  if (status != ISC_R_SUCCESS)
91  log_fatal ("Can't register group object type: %s",
92  isc_result_totext (status));
93 
94  status = omapi_object_type_register (&dhcp_type_subnet,
95  "subnet",
103  dhcp_subnet_remove, 0, 0, 0,
104  sizeof (struct subnet), 0,
105  RC_MISC);
106  if (status != ISC_R_SUCCESS)
107  log_fatal ("Can't register subnet object type: %s",
108  isc_result_totext (status));
109 
111  (&dhcp_type_shared_network,
112  "shared-network",
121  sizeof (struct shared_network), 0, RC_MISC);
122  if (status != ISC_R_SUCCESS)
123  log_fatal ("Can't register shared network object type: %s",
124  isc_result_totext (status));
125 
126  interface_setup ();
127 }
128 
130  omapi_object_t *id,
131  omapi_data_string_t *name,
132  omapi_typed_data_t *value)
133 {
134  struct group_object *group;
135  isc_result_t status;
136 
137  if (h -> type != dhcp_type_group)
138  return DHCP_R_INVALIDARG;
139  group = (struct group_object *)h;
140 
141  /* XXX For now, we can only set these values on new group objects.
142  XXX Soon, we need to be able to update group objects. */
143  if (!omapi_ds_strcmp (name, "name")) {
144  if (group -> name)
145  return ISC_R_EXISTS;
146  if (value -> type == omapi_datatype_data ||
147  value -> type == omapi_datatype_string) {
148  group -> name = dmalloc (value -> u.buffer.len + 1,
149  MDL);
150  if (!group -> name)
151  return ISC_R_NOMEMORY;
152  memcpy (group -> name,
153  value -> u.buffer.value,
154  value -> u.buffer.len);
155  group -> name [value -> u.buffer.len] = 0;
156  } else
157  return DHCP_R_INVALIDARG;
158  return ISC_R_SUCCESS;
159  }
160 
161  if (!omapi_ds_strcmp (name, "statements")) {
162  if (group -> group && group -> group -> statements)
163  return ISC_R_EXISTS;
164  if (!group -> group) {
165  if (!clone_group (&group -> group, root_group, MDL))
166  return ISC_R_NOMEMORY;
167  }
168  if (value -> type == omapi_datatype_data ||
169  value -> type == omapi_datatype_string) {
170  struct parse *parse;
171  int lose = 0;
172  parse = NULL;
173  status = new_parse(&parse, -1,
174  (char *) value->u.buffer.value,
175  value->u.buffer.len,
176  "network client", 0);
177  if (status != ISC_R_SUCCESS || parse == NULL)
178  return status;
180  (&group -> group -> statements, parse, &lose,
181  context_any))) {
182  end_parse (&parse);
183  return DHCP_R_BADPARSE;
184  }
185  end_parse (&parse);
186  return ISC_R_SUCCESS;
187  } else
188  return DHCP_R_INVALIDARG;
189  }
190 
191  /* Try to find some inner object that can take the value. */
192  if (h -> inner && h -> inner -> type -> set_value) {
193  status = ((*(h -> inner -> type -> set_value))
194  (h -> inner, id, name, value));
195  if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
196  return status;
197  }
198 
199  return ISC_R_NOTFOUND;
200 }
201 
202 
204  omapi_data_string_t *name,
205  omapi_value_t **value)
206 {
207  struct group_object *group;
208  isc_result_t status;
209 
210  if (h -> type != dhcp_type_group)
211  return DHCP_R_INVALIDARG;
212  group = (struct group_object *)h;
213 
214  if (!omapi_ds_strcmp (name, "name"))
215  return omapi_make_string_value (value,
216  name, group -> name, MDL);
217 
218  /* Try to find some inner object that can take the value. */
219  if (h -> inner && h -> inner -> type -> get_value) {
220  status = ((*(h -> inner -> type -> get_value))
221  (h -> inner, id, name, value));
222  if (status == ISC_R_SUCCESS)
223  return status;
224  }
225  return ISC_R_NOTFOUND;
226 }
227 
228 isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
229 {
230  struct group_object *group, *t;
231 
232  if (h -> type != dhcp_type_group)
233  return DHCP_R_INVALIDARG;
234  group = (struct group_object *)h;
235 
236  if (group -> name) {
237  if (group_name_hash) {
238  t = (struct group_object *)0;
239  if (group_hash_lookup (&t, group_name_hash,
240  group -> name,
241  strlen (group -> name), MDL)) {
242  group_hash_delete (group_name_hash,
243  group -> name,
244  strlen (group -> name),
245  MDL);
246  group_object_dereference (&t, MDL);
247  }
248  }
249  dfree (group -> name, file, line);
250  group -> name = (char *)0;
251  }
252  if (group -> group)
253  group_dereference (&group -> group, MDL);
254 
255  return ISC_R_SUCCESS;
256 }
257 
259  const char *name, va_list ap)
260 {
261  struct group_object *group;
262  isc_result_t status;
263  int updatep = 0;
264 
265  if (h -> type != dhcp_type_group)
266  return DHCP_R_INVALIDARG;
267  group = (struct group_object *)h;
268 
269  if (!strcmp (name, "updated")) {
270  /* A group object isn't valid if a subgroup hasn't yet been
271  associated with it. */
272  if (!group -> group)
273  return DHCP_R_INVALIDARG;
274 
275  /* Group objects always have to have names. */
276  if (!group -> name) {
277  char hnbuf [64];
278  sprintf (hnbuf, "ng%08lx%08lx",
279  (unsigned long)cur_time,
280  (unsigned long)group);
281  group -> name = dmalloc (strlen (hnbuf) + 1, MDL);
282  if (!group -> name)
283  return ISC_R_NOMEMORY;
284  strcpy (group -> name, hnbuf);
285  }
286 
287  supersede_group (group, 1);
288  updatep = 1;
289  }
290 
291  /* Try to find some inner object that can take the value. */
292  if (h -> inner && h -> inner -> type -> get_value) {
293  status = ((*(h -> inner -> type -> signal_handler))
294  (h -> inner, name, ap));
295  if (status == ISC_R_SUCCESS)
296  return status;
297  }
298  if (updatep)
299  return ISC_R_SUCCESS;
300  return ISC_R_NOTFOUND;
301 }
302 
304  omapi_object_t *id,
305  omapi_object_t *h)
306 {
307  struct group_object *group;
308  isc_result_t status;
309 
310  if (h -> type != dhcp_type_group)
311  return DHCP_R_INVALIDARG;
312  group = (struct group_object *)h;
313 
314  /* Write out all the values. */
315  if (group -> name) {
316  status = omapi_connection_put_name (c, "name");
317  if (status != ISC_R_SUCCESS)
318  return status;
319  status = omapi_connection_put_string (c, group -> name);
320  if (status != ISC_R_SUCCESS)
321  return status;
322  }
323 
324  /* Write out the inner object, if any. */
325  if (h -> inner && h -> inner -> type -> stuff_values) {
326  status = ((*(h -> inner -> type -> stuff_values))
327  (c, id, h -> inner));
328  if (status == ISC_R_SUCCESS)
329  return status;
330  }
331 
332  return ISC_R_SUCCESS;
333 }
334 
336  omapi_object_t *id, omapi_object_t *ref)
337 {
338  omapi_value_t *tv = (omapi_value_t *)0;
339  isc_result_t status;
340  struct group_object *group;
341 
342  if (!ref)
343  return DHCP_R_NOKEYS;
344 
345  /* First see if we were sent a handle. */
346  status = omapi_get_value_str (ref, id, "handle", &tv);
347  if (status == ISC_R_SUCCESS) {
348  status = omapi_handle_td_lookup (lp, tv -> value);
349 
351  if (status != ISC_R_SUCCESS)
352  return status;
353 
354  /* Don't return the object if the type is wrong. */
355  if ((*lp) -> type != dhcp_type_group) {
357  return DHCP_R_INVALIDARG;
358  }
359  }
360 
361  /* Now look for a name. */
362  status = omapi_get_value_str (ref, id, "name", &tv);
363  if (status == ISC_R_SUCCESS) {
364  group = (struct group_object *)0;
365  if (group_name_hash &&
366  group_hash_lookup (&group, group_name_hash,
367  (const char *)
368  tv -> value -> u.buffer.value,
369  tv -> value -> u.buffer.len, MDL)) {
371 
372  if (*lp && *lp != (omapi_object_t *)group) {
373  group_object_dereference (&group, MDL);
375  return DHCP_R_KEYCONFLICT;
376  } else if (!*lp) {
377  /* XXX fix so that hash lookup itself creates
378  XXX the reference. */
380  (omapi_object_t *)group,
381  MDL);
382  group_object_dereference (&group, MDL);
383  }
384  } else if (!*lp)
385  return ISC_R_NOTFOUND;
386  }
387 
388  /* If we get to here without finding a group, no valid key was
389  specified. */
390  if (!*lp)
391  return DHCP_R_NOKEYS;
392 
393  if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) {
395  return ISC_R_NOTFOUND;
396  }
397  return ISC_R_SUCCESS;
398 }
399 
401  omapi_object_t *id)
402 {
403  struct group_object *group;
404  isc_result_t status;
405  group = (struct group_object *)0;
406 
407  status = group_object_allocate (&group, MDL);
408  if (status != ISC_R_SUCCESS)
409  return status;
410  group -> flags = GROUP_OBJECT_DYNAMIC;
411  status = omapi_object_reference (lp, (omapi_object_t *)group, MDL);
412  group_object_dereference (&group, MDL);
413  return status;
414 }
415 
417  omapi_object_t *id)
418 {
419  struct group_object *group;
420  isc_result_t status;
421  if (lp -> type != dhcp_type_group)
422  return DHCP_R_INVALIDARG;
423  group = (struct group_object *)lp;
424 
425  group -> flags |= GROUP_OBJECT_DELETED;
426  if (group_write_hook) {
427  if (!(*group_write_hook) (group))
428  return ISC_R_IOERROR;
429  }
430 
431  status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
432 
433  return status;
434 }
435 
437  omapi_object_t *id,
439  omapi_typed_data_t *value)
440 {
441  dhcp_control_object_t *control;
442  isc_result_t status;
443  unsigned long newstate;
444 
445  if (h -> type != dhcp_type_control)
446  return DHCP_R_INVALIDARG;
447  control = (dhcp_control_object_t *)h;
448 
449  if (!omapi_ds_strcmp (name, "state")) {
450  status = omapi_get_int_value (&newstate, value);
451  if (status != ISC_R_SUCCESS)
452  return status;
453  status = dhcp_set_control_state (control -> state, newstate);
454  if (status == ISC_R_SUCCESS)
455  control -> state = value -> u.integer;
456  return status;
457  }
458 
459  /* Try to find some inner object that can take the value. */
460  if (h -> inner && h -> inner -> type -> set_value) {
461  status = ((*(h -> inner -> type -> set_value))
462  (h -> inner, id, name, value));
463  if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
464  return status;
465  }
466 
467  return ISC_R_NOTFOUND;
468 }
469 
470 
473  omapi_value_t **value)
474 {
475  dhcp_control_object_t *control;
476  isc_result_t status;
477 
478  if (h -> type != dhcp_type_control)
479  return DHCP_R_INVALIDARG;
480  control = (dhcp_control_object_t *)h;
481 
482  if (!omapi_ds_strcmp (name, "state"))
483  return omapi_make_int_value (value,
484  name, (int)control -> state, MDL);
485 
486  /* Try to find some inner object that can take the value. */
487  if (h -> inner && h -> inner -> type -> get_value) {
488  status = ((*(h -> inner -> type -> get_value))
489  (h -> inner, id, name, value));
490  if (status == ISC_R_SUCCESS)
491  return status;
492  }
493  return ISC_R_NOTFOUND;
494 }
495 
497  const char *file, int line)
498 {
499  if (h -> type != dhcp_type_control)
500  return DHCP_R_INVALIDARG;
501 
502  /* Can't destroy the control object. */
503  return ISC_R_NOPERM;
504 }
505 
507  const char *name, va_list ap)
508 {
509  /* In this function h should be a (dhcp_control_object_t *) */
510 
511  isc_result_t status;
512 
513  if (h -> type != dhcp_type_control)
514  return DHCP_R_INVALIDARG;
515 
516  /* Try to find some inner object that can take the value. */
517  if (h -> inner && h -> inner -> type -> get_value) {
518  status = ((*(h -> inner -> type -> signal_handler))
519  (h -> inner, name, ap));
520  if (status == ISC_R_SUCCESS)
521  return status;
522  }
523  return ISC_R_NOTFOUND;
524 }
525 
527  omapi_object_t *id,
528  omapi_object_t *h)
529 {
530  dhcp_control_object_t *control;
531  isc_result_t status;
532 
533  if (h -> type != dhcp_type_control)
534  return DHCP_R_INVALIDARG;
535  control = (dhcp_control_object_t *)h;
536 
537  /* Write out all the values. */
538  status = omapi_connection_put_name (c, "state");
539  if (status != ISC_R_SUCCESS)
540  return status;
541  status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));
542  if (status != ISC_R_SUCCESS)
543  return status;
544  status = omapi_connection_put_uint32 (c, control -> state);
545  if (status != ISC_R_SUCCESS)
546  return status;
547 
548  /* Write out the inner object, if any. */
549  if (h -> inner && h -> inner -> type -> stuff_values) {
550  status = ((*(h -> inner -> type -> stuff_values))
551  (c, id, h -> inner));
552  if (status == ISC_R_SUCCESS)
553  return status;
554  }
555 
556  return ISC_R_SUCCESS;
557 }
558 
560  omapi_object_t *id, omapi_object_t *ref)
561 {
562  omapi_value_t *tv = (omapi_value_t *)0;
563  isc_result_t status;
564 
565  /* First see if we were sent a handle. */
566  if (ref) {
567  status = omapi_get_value_str (ref, id, "handle", &tv);
568  if (status == ISC_R_SUCCESS) {
569  status = omapi_handle_td_lookup (lp, tv -> value);
570 
572  if (status != ISC_R_SUCCESS)
573  return status;
574 
575  /* Don't return the object if the type is wrong. */
576  if ((*lp) -> type != dhcp_type_control) {
578  return DHCP_R_INVALIDARG;
579  }
580  }
581  }
582 
583  /* Otherwise, stop playing coy - there's only one control object,
584  so we can just return it. */
585  dhcp_control_reference ((dhcp_control_object_t **)lp,
587  return ISC_R_SUCCESS;
588 }
589 
591  omapi_object_t *id)
592 {
593  /* Can't create a control object - there can be only one. */
594  return ISC_R_NOPERM;
595 }
596 
598  omapi_object_t *id)
599 {
600  /* Form is emptiness; emptiness form. The control object
601  cannot go out of existance. */
602  return ISC_R_NOPERM;
603 }
604 
606  omapi_object_t *id,
608  omapi_typed_data_t *value)
609 {
610  /* In this function h should be a (struct subnet *) */
611 
612  isc_result_t status;
613 
614  if (h -> type != dhcp_type_subnet)
615  return DHCP_R_INVALIDARG;
616 
617  /* No values to set yet. */
618 
619  /* Try to find some inner object that can take the value. */
620  if (h -> inner && h -> inner -> type -> set_value) {
621  status = ((*(h -> inner -> type -> set_value))
622  (h -> inner, id, name, value));
623  if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
624  return status;
625  }
626 
627  return ISC_R_NOTFOUND;
628 }
629 
630 
633  omapi_value_t **value)
634 {
635  /* In this function h should be a (struct subnet *) */
636 
637  isc_result_t status;
638 
639  if (h -> type != dhcp_type_subnet)
640  return DHCP_R_INVALIDARG;
641 
642  /* No values to get yet. */
643 
644  /* Try to find some inner object that can provide the value. */
645  if (h -> inner && h -> inner -> type -> get_value) {
646  status = ((*(h -> inner -> type -> get_value))
647  (h -> inner, id, name, value));
648  if (status == ISC_R_SUCCESS)
649  return status;
650  }
651  return ISC_R_NOTFOUND;
652 }
653 
654 isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
655 {
656 #if defined (DEBUG_MEMORY_LEAKAGE) || \
657  defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
658  struct subnet *subnet;
659 #endif
660 
661  if (h -> type != dhcp_type_subnet)
662  return DHCP_R_INVALIDARG;
663 
664 #if defined (DEBUG_MEMORY_LEAKAGE) || \
665  defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
666  subnet = (struct subnet *)h;
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 
684  const char *name, va_list ap)
685 {
686  /* In this function h should be a (struct subnet *) */
687 
688  isc_result_t status;
689 
690  if (h -> type != dhcp_type_subnet)
691  return DHCP_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 
703  return ISC_R_NOTFOUND;
704 }
705 
707  omapi_object_t *id,
708  omapi_object_t *h)
709 {
710  /* In this function h should be a (struct subnet *) */
711 
712  isc_result_t status;
713 
714  if (h -> type != dhcp_type_subnet)
715  return DHCP_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 
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 DHCP_R_NOKEYS;
740  return ISC_R_SUCCESS;
741 }
742 
744  omapi_object_t *id)
745 {
746  return ISC_R_NOTIMPLEMENTED;
747 }
748 
750  omapi_object_t *id)
751 {
752  return ISC_R_NOTIMPLEMENTED;
753 }
754 
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 
762  isc_result_t status;
763 
764  if (h -> type != dhcp_type_shared_network)
765  return DHCP_R_INVALIDARG;
766 
767  /* No values to set yet. */
768 
769  /* Try to find some inner object that can take the value. */
770  if (h -> inner && h -> inner -> type -> set_value) {
771  status = ((*(h -> inner -> type -> set_value))
772  (h -> inner, id, name, value));
773  if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
774  return status;
775  }
776 
777  return ISC_R_NOTFOUND;
778 }
779 
780 
782  omapi_object_t *id,
783  omapi_data_string_t *name,
784  omapi_value_t **value)
785 {
786  /* In this function h should be a (struct shared_network *) */
787 
788  isc_result_t status;
789 
790  if (h -> type != dhcp_type_shared_network)
791  return DHCP_R_INVALIDARG;
792 
793  /* No values to get yet. */
794 
795  /* Try to find some inner object that can provide the value. */
796  if (h -> inner && h -> inner -> type -> get_value) {
797  status = ((*(h -> inner -> type -> get_value))
798  (h -> inner, id, name, value));
799  if (status == ISC_R_SUCCESS)
800  return status;
801  }
802  return ISC_R_NOTFOUND;
803 }
804 
806  const char *file, int line)
807 {
808  /* In this function h should be a (struct shared_network *) */
809 
810 #if defined (DEBUG_MEMORY_LEAKAGE) || \
811  defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
813 #endif
814 
815  if (h -> type != dhcp_type_shared_network)
816  return DHCP_R_INVALIDARG;
817 
818 #if defined (DEBUG_MEMORY_LEAKAGE) || \
819  defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
820  shared_network = (struct shared_network *)h;
821  if (shared_network -> next)
822  shared_network_dereference (&shared_network -> next,
823  file, line);
824  if (shared_network -> name) {
825  dfree (shared_network -> name, file, line);
826  shared_network -> name = 0;
827  }
828  if (shared_network -> subnets)
829  subnet_dereference (&shared_network -> subnets, file, line);
830  if (shared_network -> interface)
831  interface_dereference (&shared_network -> interface,
832  file, line);
833  if (shared_network -> pools)
835  &shared_network -> pools, file, line);
836  if (shared_network -> group)
837  group_dereference (&shared_network -> group, file, line);
838 #if defined (FAILOVER_PROTOCOL)
839  if (shared_network -> failover_peer)
841  &shared_network -> failover_peer,
842  file, line);
843 #endif
844 #endif /* DEBUG_MEMORY_LEAKAGE */
845 
846  return ISC_R_SUCCESS;
847 }
848 
850  const char *name,
851  va_list ap)
852 {
853  /* In this function h should be a (struct shared_network *) */
854 
855  isc_result_t status;
856 
857  if (h -> type != dhcp_type_shared_network)
858  return DHCP_R_INVALIDARG;
859 
860  /* Can't write shared_networks yet. */
861 
862  /* Try to find some inner object that can take the value. */
863  if (h -> inner && h -> inner -> type -> get_value) {
864  status = ((*(h -> inner -> type -> signal_handler))
865  (h -> inner, name, ap));
866  if (status == ISC_R_SUCCESS)
867  return status;
868  }
869 
870  return ISC_R_NOTFOUND;
871 }
872 
874  omapi_object_t *id,
875  omapi_object_t *h)
876 {
877  /* In this function h should be a (struct shared_network *) */
878 
879  isc_result_t status;
880 
881  if (h -> type != dhcp_type_shared_network)
882  return DHCP_R_INVALIDARG;
883 
884  /* Can't stuff shared_network values yet. */
885 
886  /* Write out the inner object, if any. */
887  if (h -> inner && h -> inner -> type -> stuff_values) {
888  status = ((*(h -> inner -> type -> stuff_values))
889  (c, id, h -> inner));
890  if (status == ISC_R_SUCCESS)
891  return status;
892  }
893 
894  return ISC_R_SUCCESS;
895 }
896 
898  omapi_object_t *id,
899  omapi_object_t *ref)
900 {
901  /* Can't look up shared_networks yet. */
902 
903  /* If we get to here without finding a shared_network, no valid key was
904  specified. */
905  if (!*lp)
906  return DHCP_R_NOKEYS;
907  return ISC_R_SUCCESS;
908 }
909 
911  omapi_object_t *id)
912 {
913  return ISC_R_NOTIMPLEMENTED;
914 }
915 
917  omapi_object_t *id)
918 {
919  return ISC_R_NOTIMPLEMENTED;
920 }
921 
#define GROUP_OBJECT_DYNAMIC
Definition: dhcpd.h:879
const char int line
Definition: dhcpd.h:3615
omapi_object_type_t * dhcp_type_shared_network
isc_result_t dhcp_control_remove(omapi_object_t *lp, omapi_object_t *id)
Definition: comapi.c:597
isc_result_t omapi_make_int_value(omapi_value_t **, omapi_data_string_t *, int, const char *, int)
Definition: support.c:710
isc_result_t omapi_object_reference(omapi_object_t **, omapi_object_t *, const char *, int)
Definition: alloc.c:557
isc_result_t end_parse(struct parse **cfile)
Definition: conflex.c:103
void * dmalloc(unsigned, const char *, int)
Definition: alloc.c:56
Definition: dhcpd.h:985
isc_result_t dhcp_control_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
Definition: comapi.c:436
isc_result_t dhcp_control_lookup(omapi_object_t **lp, omapi_object_t *id, omapi_object_t *ref)
Definition: comapi.c:559
#define MDL
Definition: omapip.h:568
#define DHCP_R_INVALIDARG
Definition: result.h:48
omapi_typed_data_t * value
Definition: omapip.h:91
struct group * root_group
Definition: memory.c:31
dhcp_failover_state_t * failover_peer
Definition: dhcpd.h:981
struct subnet * subnets
Definition: mdb.c:33
isc_result_t dhcp_shared_network_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
Definition: comapi.c:755
#define DHCP_R_KEYCONFLICT
Definition: result.h:52
Definition: dhcpd.h:259
void log_fatal(const char *,...) __attribute__((__format__(__printf__
#define DHCP_R_BADPARSE
Definition: result.h:53
struct omapi_typed_data_t::@3::@4 buffer
isc_result_t dhcp_group_create(omapi_object_t **lp, omapi_object_t *id)
Definition: comapi.c:400
isc_result_t dhcp_group_lookup(omapi_object_t **lp, omapi_object_t *id, omapi_object_t *ref)
Definition: comapi.c:335
isc_result_t dhcp_group_destroy(omapi_object_t *h, const char *file, int line)
Definition: comapi.c:228
isc_result_t dhcp_group_remove(omapi_object_t *lp, omapi_object_t *id)
Definition: comapi.c:416
isc_result_t omapi_connection_put_uint32(omapi_object_t *, u_int32_t)
Definition: buffer.c:587
isc_result_t dhcp_control_create(omapi_object_t **lp, omapi_object_t *id)
Definition: comapi.c:590
isc_result_t dhcp_group_signal_handler(omapi_object_t *h, const char *name, va_list ap)
Definition: comapi.c:258
isc_result_t omapi_get_value_str(omapi_object_t *, omapi_object_t *, const char *, omapi_value_t **)
Definition: support.c:483
isc_result_t dhcp_group_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
Definition: comapi.c:129
omapi_object_type_t * dhcp_type_control
int group_dereference(struct group **ptr, const char *file, int line)
Definition: alloc.c:206
isc_result_t dhcp_subnet_create(omapi_object_t **lp, omapi_object_t *id)
Definition: comapi.c:743
int(* group_write_hook)(struct group_object *)
Definition: memory.c:33
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
Definition: alloc.c:579
isc_result_t dhcp_subnet_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
Definition: comapi.c:605
#define cur_time
Definition: dhcpd.h:1988
isc_result_t dhcp_subnet_signal_handler(omapi_object_t *h, const char *name, va_list ap)
Definition: comapi.c:683
isc_result_t omapi_get_int_value(unsigned long *, omapi_typed_data_t *)
Definition: support.c:836
void dfree(void *, const char *, int)
Definition: alloc.c:131
union omapi_typed_data_t::@3 u
isc_result_t dhcp_control_destroy(omapi_object_t *h, const char *file, int line)
Definition: comapi.c:496
isc_result_t dhcp_control_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *h)
Definition: comapi.c:526
omapi_object_type_t * dhcp_type_interface
Definition: discover.c:71
isc_result_t omapi_handle_td_lookup(omapi_object_t **, omapi_typed_data_t *)
Definition: handle.c:283
isc_result_t dhcp_group_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *h)
Definition: comapi.c:303
isc_result_t dhcp_shared_network_destroy(omapi_object_t *h, const char *file, int line)
Definition: comapi.c:805
isc_result_t dhcp_control_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
Definition: comapi.c:471
#define GROUP_OBJECT_DELETED
Definition: dhcpd.h:878
isc_result_t dhcp_shared_network_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
Definition: comapi.c:781
isc_result_t dhcp_subnet_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
Definition: comapi.c:631
isc_result_t omapi_connection_put_string(omapi_object_t *, const char *)
Definition: buffer.c:681
struct subnet * next_subnet
Definition: dhcpd.h:987
char * name
Definition: dhcpd.h:876
omapi_object_type_t * dhcp_type_group
dhcp_control_object_t * dhcp_control_object
isc_result_t dhcp_subnet_destroy(omapi_object_t *h, const char *file, int line)
Definition: comapi.c:654
isc_result_t omapi_value_dereference(omapi_value_t **, const char *, int)
Definition: alloc.c:1046
isc_result_t omapi_object_type_register(omapi_object_type_t **, const char *, isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *), isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **), isc_result_t(*)(omapi_object_t *, const char *, int), isc_result_t(*)(omapi_object_t *, const char *, va_list), isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t **, omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t **, omapi_object_t *), isc_result_t(*)(omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t *, const char *, int), isc_result_t(*)(omapi_object_t **, const char *, int), isc_result_t(*)(size_t), size_t, isc_result_t(*)(omapi_object_t *, const char *, int), int)
Definition: support.c:194
isc_result_t dhcp_shared_network_remove(omapi_object_t *lp, omapi_object_t *id)
Definition: comapi.c:916
isc_result_t dhcp_subnet_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *h)
Definition: comapi.c:706
#define DHCP_R_NOKEYS
Definition: result.h:54
isc_result_t dhcp_subnet_remove(omapi_object_t *lp, omapi_object_t *id)
Definition: comapi.c:749
Definition: dhcpd.h:884
#define DHCP_R_UNCHANGED
Definition: result.h:50
isc_result_t dhcp_subnet_lookup(omapi_object_t **lp, omapi_object_t *id, omapi_object_t *ref)
Definition: comapi.c:730
int omapi_ds_strcmp(omapi_data_string_t *, const char *)
Definition: support.c:582
isc_result_t supersede_group(struct group_object *group, int writep)
Definition: memory.c:74
struct subnet * next_sibling
Definition: dhcpd.h:988
isc_result_t dhcp_shared_network_signal_handler(omapi_object_t *h, const char *name, va_list ap)
Definition: comapi.c:849
struct interface_info * interface
Definition: dhcpd.h:976
int flags
Definition: dhcpd.h:877
isc_result_t interface_setup()
Definition: discover.c:83
isc_result_t dhcp_group_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
Definition: comapi.c:203
group_hash_t * group_name_hash
Definition: memory.c:32
isc_result_t dhcp_shared_network_create(omapi_object_t **lp, omapi_object_t *id)
Definition: comapi.c:910
isc_result_t dhcp_shared_network_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *h)
Definition: comapi.c:873
struct ipv6_pool ** pools
struct shared_network * next
Definition: dhcpd.h:969
const char * file
Definition: dhcpd.h:3615
char * name
Definition: dhcpd.h:970
isc_result_t omapi_connection_put_name(omapi_object_t *, const char *)
Definition: buffer.c:670
isc_result_t dhcp_set_control_state(control_object_state_t oldstate, control_object_state_t newstate)
Definition: dhclient.c:4482
int parse_executable_statements(struct executable_statement **statements, struct parse *cfile, int *lose, enum expression_context case_context)
Definition: parse.c:2105
void dhcp_common_objects_setup(void)
isc_result_t dhcp_shared_network_lookup(omapi_object_t **lp, omapi_object_t *id, omapi_object_t *ref)
Definition: comapi.c:897
struct group * group
Definition: dhcpd.h:875
#define RC_MISC
Definition: alloc.h:56
int clone_group(struct group **gp, struct group *group, const char *file, int line)
Definition: memory.c:130
OMAPI_OBJECT_ALLOC(shared_network, struct shared_network, omapi_object_type_t *dhcp_type_shared_network)
Definition: comapi.c:41
struct interface_info * interface
Definition: dhcpd.h:990
isc_result_t new_parse(struct parse **cfile, int file, char *inbuf, unsigned buflen, const char *name, int eolp)
Definition: conflex.c:41
omapi_object_type_t * dhcp_type_subnet
isc_result_t dhcp_control_signal_handler(omapi_object_t *h, const char *name, va_list ap)
Definition: comapi.c:506
isc_result_t omapi_make_string_value(omapi_value_t **, omapi_data_string_t *, const char *, const char *, int)
Definition: support.c:808