From 4bd8800e89dd8760f16a4c5e3bcae3d2b3a2373c Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Wed, 26 Jan 2000 14:56:18 +0000 Subject: [PATCH] Fix compilation errors introduced in the last set of checkins. --- client/clparse.c | 7 +- client/dhclient.8 | 2 +- client/dhclient.c | 11 +- client/dhclient.cat8 | 2 +- client/dhclient.conf.5 | 2 +- client/dhclient.conf.cat5 | 2 +- common/Makefile.dist | 4 +- common/alloc.c | 368 ++-------- common/bpf.c | 4 +- common/conflex.c | 12 +- common/dhcp-options.cat5 | 1154 ++++++++++++++++++++------------ common/discover.c | 21 +- common/dispatch.c | 5 +- common/dns.c | 22 +- common/execute.c | 123 ++-- common/hash.c | 8 +- common/icmp.c | 4 +- common/memory.c | 11 +- common/options.c | 10 +- common/parse.c | 352 +++++----- common/print.c | 18 +- common/resolv.c | 9 +- common/tables.c | 5 +- common/tree.c | 138 ++-- dhcpctl/callback.c | 20 +- dhcpctl/dhcpctl.c | 104 ++- dhcpctl/dhcpctl.h | 6 +- dhcpctl/remote.c | 71 +- dhcpctl/test.c | 10 +- includes/arpa/nameser.h | 657 +++++++++++++----- includes/arpa/nameser_compat.h | 229 +++++++ includes/dhcpd.h | 135 +--- includes/omapip/alloc.h | 65 +- includes/omapip/omapip.h | 88 ++- includes/site.h | 6 +- omapip/Makefile.dist | 4 +- omapip/alloc.c | 309 ++++++++- omapip/buffer.c | 49 +- omapip/connection.c | 42 +- omapip/dispatch.c | 60 +- omapip/errwarn.c | 79 +-- omapip/generic.c | 56 +- omapip/handle.c | 12 +- omapip/listener.c | 52 +- omapip/message.c | 37 +- omapip/protocol.c | 125 ++-- omapip/support.c | 131 ++-- omapip/test.c | 4 +- relay/dhcrelay.c | 16 +- server/confpars.c | 7 +- server/db.c | 4 +- server/dhcp.c | 244 +++---- server/dhcpd.c | 48 +- server/dhcpd.conf.cat5 | 1046 ++++++++++++++--------------- server/failover.c | 167 ++--- server/mdb.c | 60 +- server/omapi.c | 282 ++++---- 57 files changed, 3514 insertions(+), 3005 deletions(-) create mode 100644 includes/arpa/nameser_compat.h diff --git a/client/clparse.c b/client/clparse.c index 71f766023..f827dc196 100644 --- a/client/clparse.c +++ b/client/clparse.c @@ -3,7 +3,7 @@ Parser for dhclient config and lease files... */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: clparse.c,v 1.40 2000/01/25 00:58:02 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: clparse.c,v 1.41 2000/01/26 14:55:26 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -302,8 +302,7 @@ void parse_client_statement (cfile, ip, config) return; for (; *p; p = &((*p) -> next)) ; - executable_statement_reference (p, stmt, - "parse_client_statement"); + executable_statement_reference (p, stmt, MDL); stmt -> next = (struct executable_statement *)0; return; diff --git a/client/dhclient.8 b/client/dhclient.8 index 09f24b4a2..277fb379d 100644 --- a/client/dhclient.8 +++ b/client/dhclient.8 @@ -92,7 +92,7 @@ dhclient.leases file. In order to prevent the file from becoming arbitrarily large, from time to time dhclient creates a new dhclient.leases file from its in-core lease database. The old version of the dhclient.leases file is retained under the name -.IR dhcpd.leases~ +.IR dhclient.leases~ until the next time dhclient rewrites the database. .PP Old leases are kept around in case the DHCP server is unavailable when diff --git a/client/dhclient.c b/client/dhclient.c index 1035146e5..7764e6fb1 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -3,7 +3,7 @@ DHCP Client. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -29,7 +29,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhclient.c,v 1.92 2000/01/25 00:58:57 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhclient.c,v 1.93 2000/01/26 14:55:26 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -47,8 +47,6 @@ int dhcp_max_agent_option_packet_length = 0; int interfaces_requested = 0; -int log_perror = 1; - struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } }; struct iaddr iaddr_any = { 4, { 0, 0, 0, 0 } }; struct in_addr inaddr_any; @@ -70,7 +68,6 @@ static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.htm u_int16_t local_port; u_int16_t remote_port; -int log_priority; int no_daemon; int save_scripts; @@ -325,10 +322,6 @@ static void usage () "[-cf config-file] [interface]"); } -void cleanup () -{ -} - struct class *find_class (s) const char *s; { diff --git a/client/dhclient.cat8 b/client/dhclient.cat8 index 76f388e92..a58bbb603 100644 --- a/client/dhclient.cat8 +++ b/client/dhclient.cat8 @@ -49,7 +49,7 @@ OOPPEERRAATTIIOONN dhclient creates a new dhclient.leases file from its in- core lease database. The old version of the dhclient.leases file is retained under the name - _d_h_c_p_d_._l_e_a_s_e_s_~ until the next time dhclient rewrites the + _d_h_c_l_i_e_n_t_._l_e_a_s_e_s_~ until the next time dhclient rewrites the database. Old leases are kept around in case the DHCP server is diff --git a/client/dhclient.conf.5 b/client/dhclient.conf.5 index 263ce7b26..505c5434b 100644 --- a/client/dhclient.conf.5 +++ b/client/dhclient.conf.5 @@ -366,7 +366,7 @@ interface's final configuration once a lease has been acquired. If no lease is acquired, the script is used to test predefined leases, if any, and also called once if no valid lease can be identified. For more information, see -.B dhclient-lease(8). +.B dhclient-script(8). .PP \fBmedium "\fImedia setup\fB";\fR .PP diff --git a/client/dhclient.conf.cat5 b/client/dhclient.conf.cat5 index 9988a627b..66d525d21 100644 --- a/client/dhclient.conf.cat5 +++ b/client/dhclient.conf.cat5 @@ -375,7 +375,7 @@ dhclient.conf(5) dhclient.conf(5) If no lease is acquired, the script is used to test prede­ fined leases, if any, and also called once if no valid lease can be identified. For more information, see - ddhhcclliieenntt--lleeaassee((88)).. + ddhhcclliieenntt--ssccrriipptt((88)).. mmeeddiiuumm ""_m_e_d_i_a _s_e_t_u_p"";; diff --git a/common/Makefile.dist b/common/Makefile.dist index 0b32778a5..0e2bc6826 100644 --- a/common/Makefile.dist +++ b/common/Makefile.dist @@ -21,11 +21,11 @@ CATMANPAGES = dhcp-options.cat5 dhcp-contrib.cat5 dhcp-eval.cat5 SEDMANPAGES = dhcp-options.man5 dhcp-contrib.man5 dhcp-eval.man5 SRC = raw.c parse.c nit.c icmp.c dispatch.c conflex.c upf.c bpf.c socket.c \ lpf.c dlpi.c packet.c tr.c ethernet.c memory.c print.c options.c \ - inet.c convert.c tree.c tables.c hash.c alloc.c errwarn.c \ + inet.c convert.c tree.c tables.c hash.c alloc.c \ inet_addr.c dns.c resolv.c execute.c discover.c auth.c OBJ = raw.o parse.o nit.o icmp.o dispatch.o conflex.o upf.o bpf.o socket.o \ lpf.o dlpi.o packet.o tr.o ethernet.o memory.o print.o options.o \ - inet.o convert.o tree.o tables.o hash.o alloc.o errwarn.o \ + inet.o convert.o tree.o tables.o hash.o alloc.o \ inet_addr.o dns.o resolv.o execute.o discover.o auth.o MAN = dhcp-options.5 dhcp-contrib.5 dhcp-eval.5 diff --git a/common/alloc.c b/common/alloc.c index b09daab8e..da897bc73 100644 --- a/common/alloc.c +++ b/common/alloc.c @@ -22,280 +22,15 @@ #ifndef lint static char copyright[] = -"$Id: alloc.c,v 1.37 2000/01/25 01:02:26 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: alloc.c,v 1.38 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" +#include struct dhcp_packet *dhcp_free_list; struct packet *packet_free_list; -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) -struct dmalloc_preamble *dmalloc_list; -unsigned long dmalloc_outstanding; -unsigned long dmalloc_longterm; -unsigned long dmalloc_generation; -unsigned long dmalloc_cutoff_generation; -#endif - -#if defined (DEBUG_RC_HISTORY) -struct rc_history_entry rc_history [RC_HISTORY_MAX]; -int rc_history_index; -#endif - -VOIDPTR dmalloc (size, file, line) - unsigned size; - const char *file; - int line; -{ - unsigned char *foo = malloc (size + DMDSIZE); - int i; - VOIDPTR *bar; -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) - struct dmalloc_preamble *dp; -#endif - if (!foo) { - log_error ("No memory for %s.", name); - return (VOIDPTR)0; - } - bar = (VOIDPTR)(foo + DMDOFFSET); - memset (bar, 0, size); - -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) - dp = (struct dmalloc_preamble *)foo; - dp -> prev = dmalloc_list; - if (dmalloc_list) - dmalloc_list -> next = dp; - dmalloc_list = dp; - dp -> next = (struct dmalloc_preamble *)0; - dp -> size = size; - dp -> file = file; - dp -> line = line; - dp -> generation = dmalloc_generation++; - dmalloc_outstanding += size; - for (i = 0; i < DMLFSIZE; i++) - dp -> low_fence [i] = - (((unsigned long) - (&dp -> low_fence [i])) % 143) + 113; - for (i = DMDOFFSET; i < DMDSIZE; i++) - foo [i + size] = - (((unsigned long) - (&foo [i + size])) % 143) + 113; -#if defined (DEBUG_MALLOC_POOL_EXHAUSTIVELY) - /* Check _every_ entry in the pool! Very expensive. */ - for (dp = dmalloc_list; dp; dp = dp -> prev) { - for (i = 0; i < DMLFSIZE; i++) { - if (dp -> low_fence [i] != - (((unsigned long) - (&dp -> low_fence [i])) % 143) + 113) - { - log_error ("malloc fence modified: %s(%d)", - dp -> file, dp -> line); - abort (); - } - } - foo = (unsigned char *)dp; - for (i = DMDOFFSET; i < DMDSIZE; i++) { - if (foo [i + dp -> size] != - (((unsigned long) - (&foo [i + dp -> size])) % 143) + 113) { - log_error ("malloc fence modified: %s(%d)", - dp -> file, dp -> line); - abort (); - } - } - } -#endif -#endif - return bar; -} - -void dfree (ptr, file, line) - VOIDPTR ptr; - const char *file; - int line; -{ - if (!ptr) { - log_error ("dfree %s(%d): free on null pointer.", file, line); - return; - } -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) - { - unsigned char *bar = ptr; - struct dmalloc_preamble *dp, *cur; - int i; - bar -= DMDOFFSET; - cur = (struct dmalloc_preamble *)bar; - for (dp = dmalloc_list; dp; dp = dp -> prev) - if (dp == cur) - break; - if (!dp) { - log_error ("%s(%d): freeing unknown memory: %lx", - dp -> file, dp -> line, (unsigned long)cur); - abort (); - } - if (dp -> prev) - dp -> prev -> next = dp -> next; - if (dp -> next) - dp -> next -> prev = dp -> prev; - if (dp == dmalloc_list) - dmalloc_list = dp -> prev; - if (dp -> generation >= dmalloc_cutoff_generation) - dmalloc_outstanding -= dp -> size; - else - dmalloc_longterm -= dp -> size; - - for (i = 0; i < DMLFSIZE; i++) { - if (dp -> low_fence [i] != - (((unsigned long) - (&dp -> low_fence [i])) % 143) + 113) - { - log_error ("malloc fence modified: %s(%d)", - dp -> file, dp -> line); - abort (); - } - } - for (i = DMDOFFSET; i < DMDSIZE; i++) { - if (bar [i + dp -> size] != - (((unsigned long) - (&bar [i + dp -> size])) % 143) + 113) { - log_error ("malloc fence modified: %s(%d)", - dp -> file, dp -> line); - abort (); - } - } - ptr = bar; - } -#endif - free (ptr); -} - -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) -/* For allocation functions that keep their own free lists, we want to - account for the reuse of the memory. */ - -void dmalloc_reuse (foo, file, line, justref) - VOIDPTR foo; - const char *file; - int line; - int justref; -{ - struct dmalloc_preamble *dp; - - /* Get the pointer to the dmalloc header. */ - dp = foo; - dp--; - - /* If we just allocated this and are now referencing it, this - function would almost be a no-op, except that it would - increment the generation count needlessly. So just return - in this case. */ - if (dp -> generation == dmalloc_generation) - return; - - /* If this is longterm data, and we just made reference to it, - don't put it on the short-term list or change its name - - we don't need to know about this. */ - if (dp -> generation < dmalloc_cutoff_generation && justref) - return; - - /* Take it out of the place in the allocated list where it was. */ - if (dp -> prev) - dp -> prev -> next = dp -> next; - if (dp -> next) - dp -> next -> prev = dp -> prev; - if (dp == dmalloc_list) - dmalloc_list = dp -> prev; - - /* Account for its removal. */ - if (dp -> generation >= dmalloc_cutoff_generation) - dmalloc_outstanding -= dp -> size; - else - dmalloc_longterm -= dp -> size; - - /* Now put it at the head of the list. */ - dp -> prev = dmalloc_list; - if (dmalloc_list) - dmalloc_list -> next = dp; - dmalloc_list = dp; - dp -> next = (struct dmalloc_preamble *)0; - - /* Change the reference location information. */ - dp -> file = file; - dp -> line = line; - - /* Increment the generation. */ - dp -> generation = dmalloc_generation++; - - /* Account for it. */ - dmalloc_outstanding += dp -> size; -} - -void dmalloc_dump_outstanding () -{ - static unsigned long dmalloc_cutoff_point; - struct dmalloc_preamble *dp; - unsigned char *foo; - int i; - - if (!dmalloc_cutoff_point) - dmalloc_cutoff_point = dmalloc_cutoff_generation; - for (dp = dmalloc_list; dp; dp = dp -> prev) { - if (dp -> generation <= dmalloc_cutoff_point) - break; -#if defined (DEBUG_MALLOC_POOL) - for (i = 0; i < DMLFSIZE; i++) { - if (dp -> low_fence [i] != - (((unsigned long) - (&dp -> low_fence [i])) % 143) + 113) - { - log_error ("malloc fence modified: %s(%d)", - dp -> file, dp -> line); - abort (); - } - } - foo = (unsigned char *)dp; - for (i = DMDOFFSET; i < DMDSIZE; i++) { - if (foo [i + dp -> size] != - (((unsigned long) - (&foo [i + dp -> size])) % 143) + 113) { - log_error ("malloc fence modified: %s(%d)", - dp -> file, dp -> line); - abort (); - } - } -#endif -#if defined (DEBUG_MEMORY_LEAKAGE) - /* Don't count data that's actually on a free list - somewhere. */ - if (dp -> file) - log_info (" %s(%d): %d", - dp -> file, dp -> line, dp -> size); -#endif - } - if (dmalloc_list) - dmalloc_cutoff_point = dmalloc_list -> generation; -} -#endif /* DEBUG_MEMORY_LEAKAGE || DEBUG_MALLOC_POOL */ - -#if defined (DEBUG_RC_HISTORY) -void dump_rc_history () -{ - int i; - - i = rc_history_index; - do { - log_info (" referenced by %s(%d): addr = %lx refcnt = %x\n", - rc_history [i].file, rc_history [i].line, - (unsigned long)rc_history [i].addr, - rc_history [i].refcnt); - ++i; - if (i == RC_HISTORY_MAX) - i = 0; - } while (i != rc_history_index && rc_history [i].file); -} -#endif - struct dhcp_packet *new_dhcp_packet (file, line) const char *file; int line; @@ -501,9 +236,9 @@ void free_lease_state (ptr, file, line) option_state_dereference (&ptr -> options, file, line); if (ptr -> packet) packet_dereference (&ptr -> packet, file, line); - data_string_forget (&state -> parameter_request_list, file, line); - data_string_forget (&state -> filename, file, line); - data_string_forget (&state -> server_name, file, line); + data_string_forget (&ptr -> parameter_request_list, file, line); + data_string_forget (&ptr -> filename, file, line); + data_string_forget (&ptr -> server_name, file, line); ptr -> next = free_lease_states; free_lease_states = ptr; dmalloc_reuse (free_lease_states, (char *)0, 0, 0); @@ -690,7 +425,7 @@ void free_pair (foo, file, line) { foo -> cdr = free_pairs; free_pairs = foo; - dmalloc_reuse (free_expressions, (char *)0, 0, 0); + dmalloc_reuse (free_pairs, (char *)0, 0, 0); } struct expression *free_expressions; @@ -721,8 +456,7 @@ int expression_reference (ptr, src, file, line) int line; { if (!ptr) { - log_error ("Null pointer in expression_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -730,8 +464,7 @@ int expression_reference (ptr, src, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in expression_reference (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -786,8 +519,7 @@ int option_cache_reference (ptr, src, file, line) int line; { if (!ptr) { - log_error ("Null pointer in option_cache_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -795,8 +527,7 @@ int option_cache_reference (ptr, src, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in option_cache_reference (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -833,8 +564,7 @@ int buffer_reference (ptr, bp, file, line) int line; { if (!ptr) { - log_error ("Null pointer passed to buffer_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -842,8 +572,7 @@ int buffer_reference (ptr, bp, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in buffer_reference (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -865,8 +594,7 @@ int buffer_dereference (ptr, file, line) struct buffer *bp; if (!ptr) { - log_error ("Null pointer passed to buffer_dereference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -875,8 +603,7 @@ int buffer_dereference (ptr, file, line) } if (!*ptr) { - log_error ("Null pointer in buffer_dereference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -885,11 +612,11 @@ int buffer_dereference (ptr, file, line) } (*ptr) -> refcnt--; - rc_register (name, line, *ptr, (*ptr) -> refcnt); + rc_register (file, line, *ptr, (*ptr) -> refcnt); if (!(*ptr) -> refcnt) dfree ((*ptr), file, line); if ((*ptr) -> refcnt < 0) { - log_error ("buffer_dereference: negative refcnt!"); + log_error ("%s(%d): negative refcnt!", file, line); #if defined (DEBUG_RC_HISTORY) dump_rc_history (); #endif @@ -927,8 +654,7 @@ int dns_host_entry_reference (ptr, bp, file, line) int line; { if (!ptr) { - log_error ("Null pointer in dns_host_entry_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -936,8 +662,7 @@ int dns_host_entry_reference (ptr, bp, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in dns_host_entry_reference (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -959,8 +684,7 @@ int dns_host_entry_dereference (ptr, file, line) struct dns_host_entry *bp; if (!ptr || !*ptr) { - log_error ("Null pointer in dns_host_entry_dereference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -973,7 +697,7 @@ int dns_host_entry_dereference (ptr, file, line) if (!(*ptr) -> refcnt) dfree ((*ptr), file, line); if ((*ptr) -> refcnt < 0) { - log_error ("dns_host_entry_dereference: negative refcnt!"); + log_error ("%s(%d): negative refcnt!", file, line); #if defined (DEBUG_RC_HISTORY) dump_rc_history (); #endif @@ -995,8 +719,7 @@ int option_state_allocate (ptr, file, line) unsigned size; if (!ptr) { - log_error ("Null pointer passed to option_state_allocate: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1004,8 +727,7 @@ int option_state_allocate (ptr, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in option_state_allocate (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1032,8 +754,7 @@ int option_state_reference (ptr, bp, file, line) int line; { if (!ptr) { - log_error ("Null pointer in option_state_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1041,8 +762,7 @@ int option_state_reference (ptr, bp, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in option_state_reference (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1065,8 +785,7 @@ int option_state_dereference (ptr, file, line) struct option_state *options; if (!ptr || !*ptr) { - log_error ("Null pointer in option_state_dereference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1082,7 +801,7 @@ int option_state_dereference (ptr, file, line) return 1; if (options -> refcnt < 0) { - log_error ("option_state_dereference: negative refcnt!"); + log_error ("%s(%d): negative refcnt!", file, line); #if defined (DEBUG_RC_HISTORY) dump_rc_history (); #endif @@ -1125,8 +844,7 @@ int executable_statement_reference (ptr, bp, file, line) int line; { if (!ptr) { - log_error ("Null ptr in executable_statement_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1134,8 +852,7 @@ int executable_statement_reference (ptr, bp, file, line) #endif } if (*ptr) { - log_error ("Nonnull ptr in executable_statement_reference: %s", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1159,8 +876,7 @@ int packet_allocate (ptr, file, line) int size; if (!ptr) { - log_error ("Null pointer passed to packet_allocate: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1168,8 +884,7 @@ int packet_allocate (ptr, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in packet_allocate (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1193,8 +908,7 @@ int packet_reference (ptr, bp, file, line) int line; { if (!ptr) { - log_error ("Null pointer in packet_reference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1202,8 +916,7 @@ int packet_reference (ptr, bp, file, line) #endif } if (*ptr) { - log_error ("Non-null pointer in packet_reference (%s)", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1226,8 +939,7 @@ int packet_dereference (ptr, file, line) struct packet *packet; if (!ptr || !*ptr) { - log_error ("Null pointer in packet_dereference: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1243,7 +955,7 @@ int packet_dereference (ptr, file, line) return 1; if (packet -> refcnt < 0) { - log_error ("option_state_dereference: negative refcnt!"); + log_error ("%s(%d): negative refcnt!", file, line); #if defined (DEBUG_RC_HISTORY) dump_rc_history (); #endif @@ -1258,7 +970,7 @@ int packet_dereference (ptr, file, line) option_state_dereference (&packet -> options, file, line); packet -> raw = (struct dhcp_packet *)free_packets; free_packets = packet; - dmalloc_reuse (free_packets, (char *)0, 0); + dmalloc_reuse (free_packets, (char *)0, 0, 0); return 1; } @@ -1270,8 +982,7 @@ int binding_scope_allocate (ptr, file, line) struct binding_scope *bp; if (!ptr) { - log_error ("Null pointer in binding_scope_allocate: %s", - file, line); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1280,8 +991,7 @@ int binding_scope_allocate (ptr, file, line) } if (*ptr) { - log_error ("Non-null pointer in binding_scope_allocate: %s", - file, line); + log_error ("%s(%d): non-null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -1303,7 +1013,7 @@ int binding_scope_allocate (ptr, file, line) void data_string_copy (dest, src, file, line) struct data_string *dest; struct data_string *src; - const char *name; + const char *file; int line; { if (src -> buffer) @@ -1316,7 +1026,7 @@ void data_string_copy (dest, src, file, line) /* Release the reference count to a data string's buffer (if any) and zero out the other information, yielding the null data string. */ -void data_string_forget (data, name) +void data_string_forget (data, file, line) struct data_string *data; const char *file; int line; diff --git a/common/bpf.c b/common/bpf.c index d29af00c1..150a89471 100644 --- a/common/bpf.c +++ b/common/bpf.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: bpf.c,v 1.32 2000/01/05 17:57:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: bpf.c,v 1.33 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -225,7 +225,7 @@ void if_register_receive (info) /* Get the required BPF buffer length from the kernel. */ if (ioctl (info -> rfdesc, BIOCGBLEN, &info -> rbuf_max) < 0) log_fatal ("Can't get bpf buffer length: %m"); - info -> rbuf = malloc (info -> rbuf_max); + info -> rbuf = dmalloc (info -> rbuf_max, MDL); if (!info -> rbuf) log_fatal ("Can't allocate %d bytes for bpf input buffer.", info -> rbuf_max); diff --git a/common/conflex.c b/common/conflex.c index d577c153c..9057249c6 100644 --- a/common/conflex.c +++ b/common/conflex.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: conflex.c,v 1.65 2000/01/25 01:03:36 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: conflex.c,v 1.66 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -45,7 +45,7 @@ isc_result_t new_parse (cfile, file, inbuf, buflen, name) { struct parse *tmp; - tmp = dmalloc (sizeof (struct parse), "new_parse"); + tmp = dmalloc (sizeof (struct parse), MDL); if (!tmp) return ISC_R_NOMEMORY; memset (tmp, 0, sizeof *tmp); @@ -66,9 +66,9 @@ isc_result_t new_parse (cfile, file, inbuf, buflen, name) tmp -> bufsiz = 0; tmp -> inbuf = inbuf; } else { - tmp -> inbuf = dmalloc (8192, "new_parse"); + tmp -> inbuf = dmalloc (8192, MDL); if (!tmp -> inbuf) { - dfree (tmp, "new_parse"); + dfree (tmp, MDL); return ISC_R_NOMEMORY; } tmp -> bufsiz = 8192; @@ -82,8 +82,8 @@ isc_result_t end_parse (cfile) struct parse **cfile; { if ((*cfile) -> bufsiz) - dfree ((*cfile) -> inbuf, "end_parse"); - dfree (*cfile, "end_parse"); + dfree ((*cfile) -> inbuf, MDL); + dfree (*cfile, MDL); *cfile = (struct parse *)0; return ISC_R_SUCCESS; } diff --git a/common/dhcp-options.cat5 b/common/dhcp-options.cat5 index 08b4297f1..f45205c2b 100644 --- a/common/dhcp-options.cat5 +++ b/common/dhcp-options.cat5 @@ -40,11 +40,11 @@ RREEFFEERREENNCCEE:: OOPPTTIIOONN SSTTAATTEEMMEENNTTSS specify signed and unsigned 8-bit integers. Unsigned 8-bit integers are also sometimes referred to as octets. - The ssttrriinngg data type specifies an NVT ASCII string, which + The tteexxtt data type specifies an NVT ASCII string, which must be enclosed in double quotes - for example, to spec­ ify a domain-name option, the syntax would be - option domain-name "isc.org"; + option domain-name "isc.org"; The ffllaagg data type specifies a boolean value. Booleans can be either true or false (or on or off, if that makes @@ -54,9 +54,9 @@ RREEFFEERREENNCCEE:: OOPPTTIIOONN SSTTAATTEEMMEENNTTSS enclosed in double quotes, or a series of octets specified in hexadecimal, seperated by colons. For example: - option dhcp-client-identifier "CLIENT-FOO"; + option dhcp-client-identifier "CLIENT-FOO"; or - option dhcp-client-identifier 43:4c:49:45:54:2d:46:4f:4f; + option dhcp-client-identifier 43:4c:49:45:54:2d:46:4f:4f; @@ -73,14 +73,14 @@ dhcpd-options(5) dhcpd-options(5) The documentation for the various options mentioned below is taken from the latest IETF draft document on DHCP options. Options which are not listed by name may be - defined by the name option-_n_n_n, where _n_n_n _i_s _t_h_e _d_e_c_i_m_a_l - _n_u_m_b_e_r _o_f _t_h_e _o_p_t_i_o_n _c_o_d_e_. _T_h_e_s_e _o_p_t_i_o_n_s _m_a_y _b_e _f_o_l_l_o_w_e_d - _e_i_t_h_e_r _b_y _a _s_t_r_i_n_g_, _e_n_c_l_o_s_e_d _i_n _q_u_o_t_e_s_, _o_r _b_y _a _s_e_r_i_e_s _o_f - _o_c_t_e_t_s_, _e_x_p_r_e_s_s_e_d _a_s _t_w_o_-_d_i_g_i_t _h_e_x_a_d_e_c_i_m_a_l _n_u_m_b_e_r_s _s_e_p_e_r_­ - _a_t_e_d _b_y _c_o_l_o_n_s_. _F_o_r _e_x_a_m_p_l_e_: + defined by the name option-_n_n_n, where _n_n_n is the decimal + number of the option code. These options may be followed + either by a string, enclosed in quotes, or by a series of + octets, expressed as two-digit hexadecimal numbers seper­ + ated by colons. For example: - option option-133 "my-option-133-text"; - option option-129 1:54:c9:2b:47; + option option-133 "my-option-133-text"; + option option-129 1:54:c9:2b:47; Because dhcpd does not know the format of these undefined option codes, no checking is done to ensure the correct­ @@ -88,42 +88,42 @@ dhcpd-options(5) dhcpd-options(5) The standard options are: - ooppttiioonn ssuubbnneett--mmaasskk _i_p_-_a_d_d_r_e_s_s;; + ooppttiioonn aallll--ssuubbnneettss--llooccaall _f_l_a_g;; - The subnet mask option specifies the client's subnet - mask as per RFC 950. If no subnet mask option is pro­ - vided anywhere in scope, as a last resort dhcpd will - use the subnet mask from the subnet declaration for the - network on which an address is being assigned. How­ - ever, _a_n_y subnet-mask option declaration that is in - scope for the address being assigned will override the - subnet mask specified in the subnet declaration. + This option specifies whether or not the client may + assume that all subnets of the IP network to which the + client is connected use the same MTU as the subnet of + that network to which the client is directly connected. + A value of 1 indicates that all subnets share the same + MTU. A value of 0 means that the client should assume + that some subnets of the directly connected network may + have smaller MTUs. - ooppttiioonn ttiimmee--ooffffsseett _i_n_t_3_2;; + ooppttiioonn aarrpp--ccaacchhee--ttiimmeeoouutt _u_i_n_t_3_2;; - The time-offset option specifies the offset of the - client's subnet in seconds from Coordinated Universal - Time (UTC). + This option specifies the timeout in seconds for ARP + cache entries. - ooppttiioonn rroouutteerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn bboooottffiillee--nnaammee _t_e_x_t;; - The routers option specifies a list of IP addresses for - routers on the client's subnet. Routers should be - listed in order of preference. + This option is used to identify a bootstrap file. If + supported by the client, it should have the same effect + as the ffiilleennaammee declaration. BOOTP clients are + unlikely to support this option. Some DHCP clients + will support it, and others actually require it. - ooppttiioonn ttiimmee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn bboooott--ssiizzee _u_i_n_t_1_6;; - The time-server option specifies a list of RFC 868 time - servers available to the client. Servers should be - listed in order of preference. + This option specifies the length in 512-octet blocks of + the default boot image for the client. - ooppttiioonn iieenn111166--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ]; + ooppttiioonn bbrrooaaddccaasstt--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;; - The ien116-name-servers option specifies a list of IEN - 116 name servers available to the client. Servers - should be listed in order of preference. + This option specifies the broadcast address in use on + the client's subnet. Legal values for broadcast + addresses are specified in section 3.2.1.3 of STD 3 + (RFC1122). - ooppttiioonn ddoommaaiinn--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; @@ -136,41 +136,96 @@ dhcpd-options(5) dhcpd-options(5) dhcpd-options(5) dhcpd-options(5) - The domain-name-servers option specifies a list of - Domain Name System (STD 13, RFC 1035) name servers - available to the client. Servers should be listed in - order of preference. - - ooppttiioonn lloogg--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - - The log-server option specifies a list of MIT-LCS UDP - log servers available to the client. Servers should be - listed in order of preference. - ooppttiioonn ccooookkiiee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; The cookie server option specifies a list of RFC 865 cookie servers available to the client. Servers should be listed in order of preference. - ooppttiioonn llpprr--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn ddeeffaauulltt--iipp--ttttll _u_i_n_t_8_; - The LPR server option specifies a list of RFC 1179 line - printer servers available to the client. Servers - should be listed in order of preference. + This option specifies the default time-to-live that the + client should use on outgoing datagrams. - ooppttiioonn iimmpprreessss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn ddeeffaauulltt--ttccpp--ttttll _u_i_n_t_8;; - The impress-server option specifies a list of Imagen - Impress servers available to the client. Servers - should be listed in order of preference. + This option specifies the default TTL that the client + should use when sending TCP segments. The minimum + value is 1. - ooppttiioonn rreessoouurrccee--llooccaattiioonn--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_- - _a_d_d_r_e_s_s... ];; + ooppttiioonn ddhhccpp--cclliieenntt--iiddeennttiiffiieerr _s_t_r_i_n_g;; - This option specifies a list of RFC 887 Resource Loca­ - tion servers available to the client. Servers should - be listed in order of preference. + This option can be used to specify the a DHCP client + identifier in a host declaration, so that dhcpd can + find the host record by matching against the client + identifier. + + ooppttiioonn ddhhccpp--mmaaxx--mmeessssaaggee--ssiizzee _u_i_n_t_1_6;; + + This option, when sent by the client, specifies the + maximum size of any response that the server sends to + the client. When specified on the server, if the + client did not send a dhcp-max-message-size option, the + size specified on the server is used. This works for + BOOTP as well as DHCP responses. + + ooppttiioonn ddhhccpp--ppaarraammeetteerr--rreeqquueesstt--lliisstt _u_i_n_t_1_6;; + + This option, when sent by the client, specifies which + options the client wishes the server to return. Nor­ + mally, in the ISC DHCP client, this is done using the + _r_e_q_u_e_s_t statement. If this option is not specified by + the client, the DHCP server will normally return every + option that is valid in scope and that fits into the + reply. When this option is specified on the server, + the server returns the specified options. This can be + used to force a client to take options that it hasn't + requested, and it can also be used to tailor the + response of the DHCP server for clients that may need a + more limited set of options than those the server would + normally return. + + ooppttiioonn ddoommaaiinn--nnaammee _t_e_x_t;; + + This option specifies the domain name that client + should use when resolving hostnames via the Domain Name + System. + + + + 3 + + + + + +dhcpd-options(5) dhcpd-options(5) + + + ooppttiioonn ddoommaaiinn--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + The domain-name-servers option specifies a list of + Domain Name System (STD 13, RFC 1035) name servers + available to the client. Servers should be listed in + order of preference. + + ooppttiioonn eexxtteennssiioonnss--ppaatthh--nnaammee _t_e_x_t;; + + This option specifies the name of a file containing + additional options to be interpreted according to the + DHCP option format as specified in RFC2132. + + ooppttiioonn ffiinnggeerr--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + The Finger server option specifies a list of Finger + available to the client. Servers should be listed in + order of preference. + + ooppttiioonn ffoonntt--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + This option specifies a list of X Window System Font + servers available to the client. Servers should be + listed in order of preference. ooppttiioonn hhoosstt--nnaammee _s_t_r_i_n_g;; @@ -180,48 +235,43 @@ dhcpd-options(5) dhcpd-options(5) specify the domain name). See RFC 1035 for character set restrictions. - ooppttiioonn bboooott--ssiizzee _u_i_n_t_1_6;; - - This option specifies the length in 512-octet blocks of - the default boot image for the client. - - ooppttiioonn mmeerriitt--dduummpp _s_t_r_i_n_g;; + ooppttiioonn iieeeeee880022--33--eennccaappssuullaattiioonn _f_l_a_g;; - This option specifies the path-name of a file to which - the client's core image should be dumped in the event - the client crashes. The path is formatted as a + This option specifies whether or not the client should + use Ethernet Version 2 (RFC 894) or IEEE 802.3 (RFC + 1042) encapsulation if the interface is an Ethernet. A + value of 0 indicates that the client should use RFC 894 + encapsulation. A value of 1 means that the client + should use RFC 1042 encapsulation. + ooppttiioonn iieenn111166--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ]; + The ien116-name-servers option specifies a list of IEN + 116 name servers available to the client. Servers + should be listed in order of preference. - 3 + ooppttiioonn iimmpprreessss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + The impress-server option specifies a list of Imagen + Impress servers available to the client. Servers + should be listed in order of preference. -dhcpd-options(5) dhcpd-options(5) + 4 - character string consisting of characters from the NVT - ASCII character set. - ooppttiioonn ddoommaaiinn--nnaammee _s_t_r_i_n_g;; - This option specifies the domain name that client - should use when resolving hostnames via the Domain Name - System. - ooppttiioonn sswwaapp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s;; +dhcpd-options(5) dhcpd-options(5) - This specifies the IP address of the client's swap - server. - ooppttiioonn rroooott--ppaatthh _s_t_r_i_n_g;; + ooppttiioonn iinntteerrffaaccee--mmttuu _u_i_n_t_1_6;; - This option specifies the path-name that contains the - client's root disk. The path is formatted as a charac­ - ter string consisting of characters from the NVT ASCII - character set. + This option specifies the MTU to use on this interface. + The minimum legal value for the MTU is 68. ooppttiioonn iipp--ffoorrwwaarrddiinngg _f_l_a_g;; @@ -230,216 +280,194 @@ dhcpd-options(5) dhcpd-options(5) means disable IP forwarding, and a value of 1 means enable IP forwarding. - ooppttiioonn nnoonn--llooccaall--ssoouurrccee--rroouuttiinngg _f_l_a_g;; + ooppttiioonn iirrcc--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - This option specifies whether the client should config­ - ure its IP layer to allow forwarding of datagrams with - non-local source routes (see Section 3.3.5 of [4] for a - discussion of this topic). A value of 0 means disallow - forwarding of such datagrams, and a value of 1 means - allow forwarding. + The IRC server option specifies a list of IRC available + to the client. Servers should be listed in order of + preference. - ooppttiioonn ppoolliiccyy--ffiilltteerr _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s - _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn lloogg--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - This option specifies policy filters for non-local - source routing. The filters consist of a list of IP - addresses and masks which specify destination/mask - pairs with which to filter incoming source routes. + The log-server option specifies a list of MIT-LCS UDP + log servers available to the client. Servers should be + listed in order of preference. - Any source routed datagram whose next-hop address does - not match one of the filters should be discarded by the - client. + ooppttiioonn llpprr--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - See STD 3 (RFC1122) for further information. + The LPR server option specifies a list of RFC 1179 line + printer servers available to the client. Servers + should be listed in order of preference. + + ooppttiioonn mmaasskk--ssuupppplliieerr _f_l_a_g;; + + This option specifies whether or not the client should + respond to subnet mask requests using ICMP. A value of + 0 indicates that the client should not respond. A + value of 1 means that the client should respond. ooppttiioonn mmaaxx--ddggrraamm--rreeaasssseemmbbllyy _u_i_n_t_1_6;; This option specifies the maximum size datagram that + the client should be prepared to reassemble. The mini­ + mum value legal value is 576. + ooppttiioonn mmeerriitt--dduummpp _t_e_x_t;; + This option specifies the path-name of a file to which + the client's core image should be dumped in the event + the client crashes. The path is formatted as a charac­ + ter string consisting of characters from the NVT ASCII + character set. - 4 + ooppttiioonn mmoobbiillee--iipp--hhoommee--aaggeenntt _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + This option specifies a list of IP addresses indicating + 5 -dhcpd-options(5) dhcpd-options(5) - the client should be prepared to reassemble. The mini­ - mum value legal value is 576. - ooppttiioonn ddeeffaauulltt--iipp--ttttll _u_i_n_t_8_; - This option specifies the default time-to-live that the - client should use on outgoing datagrams. +dhcpd-options(5) dhcpd-options(5) - ooppttiioonn ppaatthh--mmttuu--aaggiinngg--ttiimmeeoouutt _u_i_n_t_3_2;; - This option specifies the timeout (in seconds) to use - when aging Path MTU values discovered by the mechanism - defined in RFC 1191. + mobile IP home agents available to the client. Agents + should be listed in order of preference, although nor­ + mally there will be only one such agent. - ooppttiioonn ppaatthh--mmttuu--ppllaatteeaauu--ttaabbllee _u_i_n_t_1_6 [,, _u_i_n_t_1_6... ];; + ooppttiioonn nnddss--ccoonntteexxtt _s_t_r_i_n_g;; - This option specifies a table of MTU sizes to use when - performing Path MTU Discovery as defined in RFC 1191. - The table is formatted as a list of 16-bit unsigned - integers, ordered from smallest to largest. The mini­ - mum MTU value cannot be smaller than 68. + The nds-context option specifies the name of the ini­ + tial Netware Directory Service for an NDS client. - ooppttiioonn iinntteerrffaaccee--mmttuu _u_i_n_t_1_6;; + ooppttiioonn nnddss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - This option specifies the MTU to use on this interface. - The minimum legal value for the MTU is 68. + The nds-servers option specifies a list of IP addresses + of NDS servers. - ooppttiioonn aallll--ssuubbnneettss--llooccaall _f_l_a_g;; + ooppttiioonn nnddss--ttrreeee--nnaammee _s_t_r_i_n_g;; - This option specifies whether or not the client may - assume that all subnets of the IP network to which the - client is connected use the same MTU as the subnet of - that network to which the client is directly connected. - A value of 1 indicates that all subnets share the same - MTU. A value of 0 means that the client should assume - that some subnets of the directly connected network may - have smaller MTUs. + The nds-context option specifies NDS tree name that the + NDS client should use. - ooppttiioonn bbrrooaaddccaasstt--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;; + ooppttiioonn nneettbbiiooss--dddd--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - This option specifies the broadcast address in use on - the client's subnet. Legal values for broadcast - addresses are specified in section 3.2.1.3 of STD 3 - (RFC1122). + The NetBIOS datagram distribution server (NBDD) option + specifies a list of RFC 1001/1002 NBDD servers listed + in order of preference. - ooppttiioonn ppeerrffoorrmm--mmaasskk--ddiissccoovveerryy _f_l_a_g;; + ooppttiioonn nneettbbiiooss--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s...];; - This option specifies whether or not the client should - perform subnet mask discovery using ICMP. A value of 0 - indicates that the client should not perform mask dis­ - covery. A value of 1 means that the client should per­ - form mask discovery. + The NetBIOS name server (NBNS) option specifies a list + of RFC 1001/1002 NBNS name servers listed in order of + preference. NetBIOS Name Service is currently more + commonly referred to as WINS. WINS servers can be + specified using the netbios-name-servers option. - ooppttiioonn mmaasskk--ssuupppplliieerr _f_l_a_g;; + ooppttiioonn nneettbbiiooss--nnooddee--ttyyppee _u_i_n_t_8;; + The NetBIOS node type option allows NetBIOS over TCP/IP + clients which are configurable to be configured as + described in RFC 1001/1002. The value is specified as + a single octet which identifies the client type. + Possible node types are: - 5 + _1 B-node: Broadcast - no WINS + _2 P-node: Peer - WINS only. + _4 M-node: Mixed - broadcast, then WINS + _8 H-node: Hybrid - WINS, then broadcast -dhcpd-options(5) dhcpd-options(5) + ooppttiioonn nneettbbiiooss--ssccooppee _s_t_r_i_n_g;; + The NetBIOS scope option specifies the NetBIOS over - This option specifies whether or not the client should - respond to subnet mask requests using ICMP. A value of - 0 indicates that the client should not respond. A - value of 1 means that the client should respond. - ooppttiioonn rroouutteerr--ddiissccoovveerryy _f_l_a_g;; - This option specifies whether or not the client should - solicit routers using the Router Discovery mechanism - defined in RFC 1256. A value of 0 indicates that the - client should not perform router discovery. A value of - 1 means that the client should perform router discov­ - ery. + 6 - ooppttiioonn rroouutteerr--ssoolliicciittaattiioonn--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;; - This option specifies the address to which the client - should transmit router solicitation requests. - ooppttiioonn ssttaattiicc--rroouutteess _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s - _i_p_-_a_d_d_r_e_s_s... ];; - This option specifies a list of static routes that the - client should install in its routing cache. If multi­ - ple routes to the same destination are specified, they - are listed in descending order of priority. - The routes consist of a list of IP address pairs. The - first address is the destination address, and the sec­ - ond address is the router for the destination. +dhcpd-options(5) dhcpd-options(5) - The default route (0.0.0.0) is an illegal destination - for a static route. To specify the default route, use - the rroouutteerrss option. - ooppttiioonn ttrraaiilleerr--eennccaappssuullaattiioonn _f_l_a_g;; + TCP/IP scope parameter for the client as specified in + RFC 1001/1002. See RFC1001, RFC1002, and RFC1035 for + character-set restrictions. - This option specifies whether or not the client should - negotiate the use of trailers (RFC 893 [14]) when using - the ARP protocol. A value of 0 indicates that the - client should not attempt to use trailers. A value of - 1 means that the client should attempt to use trailers. + ooppttiioonn nnwwiipp--ddoommaaiinn _s_t_r_i_n_g;; - ooppttiioonn aarrpp--ccaacchhee--ttiimmeeoouutt _u_i_n_t_3_2;; + The name of the NetWare/IP domain that a NetWare/IP + client should use. - This option specifies the timeout in seconds for ARP - cache entries. + ooppttiioonn nnwwiipp--ssuubbooppttiioonnss _s_t_r_i_n_g;; - ooppttiioonn iieeeeee880022--33--eennccaappssuullaattiioonn _f_l_a_g;; + A sequence of suboptions for NetWare/IP clients - see + RFC2242 for details. Normally this option is set by + specifying specific NetWare/IP suboptions - see the + NETWARE/IP SUBOPTIONS section for more information. - This option specifies whether or not the client should - use Ethernet Version 2 (RFC 894) or IEEE 802.3 (RFC - 1042) encapsulation if the interface is an Ethernet. A - value of 0 indicates that the client should use RFC 894 + ooppttiioonn nniiss--ddoommaaiinn _t_e_x_t;; + This option specifies the name of the client's NIS (Sun + Network Information Services) domain. The domain is + formatted as a character string consisting of charac­ + ters from the NVT ASCII character set. + ooppttiioonn nniiss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - 6 + This option specifies a list of IP addresses indicating + NIS servers available to the client. Servers should be + listed in order of preference. + ooppttiioonn nniisspplluuss--ddoommaaiinn _t_e_x_t;; + This option specifies the name of the client's NIS+ + domain. The domain is formatted as a character string + consisting of characters from the NVT ASCII character + set. + ooppttiioonn nniisspplluuss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + This option specifies a list of IP addresses indicating + NIS+ servers available to the client. Servers should + be listed in order of preference. -dhcpd-options(5) dhcpd-options(5) + ooppttiioonn nnnnttpp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + The NNTP server option specifies a list of NNTP avail­ + able to the client. Servers should be listed in order + of preference. - encapsulation. A value of 1 means that the client - should use RFC 1042 encapsulation. + ooppttiioonn nnoonn--llooccaall--ssoouurrccee--rroouuttiinngg _f_l_a_g;; - ooppttiioonn ddeeffaauulltt--ttccpp--ttttll _u_i_n_t_8;; + This option specifies whether the client should config­ + ure its IP layer to allow forwarding of datagrams with + non-local source routes (see Section 3.3.5 of [4] for a + discussion of this topic). A value of 0 means disallow - This option specifies the default TTL that the client - should use when sending TCP segments. The minimum - value is 1. - ooppttiioonn ttccpp--kkeeeeppaalliivvee--iinntteerrvvaall _u_i_n_t_3_2;; - This option specifies the interval (in seconds) that - the client TCP should wait before sending a keepalive - message on a TCP connection. The time is specified as - a 32-bit unsigned integer. A value of zero indicates - that the client should not generate keepalive messages - on connections unless specifically requested by an - application. + 7 - ooppttiioonn ttccpp--kkeeeeppaalliivvee--ggaarrbbaaggee _f_l_a_g;; - This option specifies the whether or not the client - should send TCP keepalive messages with a octet of - garbage for compatibility with older implementations. - A value of 0 indicates that a garbage octet should not - be sent. A value of 1 indicates that a garbage octet - should be sent. - ooppttiioonn nniiss--ddoommaaiinn _s_t_r_i_n_g;; - This option specifies the name of the client's NIS (Sun - Network Information Services) domain. The domain is - formatted as a character string consisting of charac­ - ters from the NVT ASCII character set. - ooppttiioonn nniiss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; +dhcpd-options(5) dhcpd-options(5) - This option specifies a list of IP addresses indicating - NIS servers available to the client. Servers should be - listed in order of preference. + + forwarding of such datagrams, and a value of 1 means + allow forwarding. ooppttiioonn nnttpp--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; @@ -447,17 +475,55 @@ dhcpd-options(5) dhcpd-options(5) NTP (RFC 1035) servers available to the client. Servers should be listed in order of preference. - ooppttiioonn nneettbbiiooss--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... - ];; + ooppttiioonn ppaatthh--mmttuu--aaggiinngg--ttiimmeeoouutt _u_i_n_t_3_2;; - The NetBIOS name server (NBNS) option specifies a list - of RFC 1001/1002 NBNS name servers listed in order of - preference. NetBIOS Name Service is currently more - commonly referred to as WINS. WINS servers can be + This option specifies the timeout (in seconds) to use + when aging Path MTU values discovered by the mechanism + defined in RFC 1191. + ooppttiioonn ppaatthh--mmttuu--ppllaatteeaauu--ttaabbllee _u_i_n_t_1_6 [,, _u_i_n_t_1_6... ];; + This option specifies a table of MTU sizes to use when + performing Path MTU Discovery as defined in RFC 1191. + The table is formatted as a list of 16-bit unsigned + integers, ordered from smallest to largest. The mini­ + mum MTU value cannot be smaller than 68. - 7 + ooppttiioonn ppeerrffoorrmm--mmaasskk--ddiissccoovveerryy _f_l_a_g;; + + This option specifies whether or not the client should + perform subnet mask discovery using ICMP. A value of 0 + indicates that the client should not perform mask dis­ + covery. A value of 1 means that the client should per­ + form mask discovery. + + ooppttiioonn ppoolliiccyy--ffiilltteerr _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s + [,, _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s...];; + + This option specifies policy filters for non-local + source routing. The filters consist of a list of IP + addresses and masks which specify destination/mask + pairs with which to filter incoming source routes. + + Any source routed datagram whose next-hop address does + not match one of the filters should be discarded by the + client. + + See STD 3 (RFC1122) for further information. + + ooppttiioonn ppoopp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + The POP3 server option specifies a list of POP3 avail­ + able to the client. Servers should be listed in order + of preference. + + ooppttiioonn rreessoouurrccee--llooccaattiioonn--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s + [,, _i_p_-_a_d_d_r_e_s_s...];; + + + + + 8 @@ -466,64 +532,130 @@ dhcpd-options(5) dhcpd-options(5) dhcpd-options(5) dhcpd-options(5) - specified using the netbios-name-servers option. + This option specifies a list of RFC 887 Resource Loca­ + tion servers available to the client. Servers should + be listed in order of preference. - ooppttiioonn nneettbbiiooss--dddd--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn rroooott--ppaatthh _t_e_x_t;; - The NetBIOS datagram distribution server (NBDD) option - specifies a list of RFC 1001/1002 NBDD servers listed - in order of preference. + This option specifies the path-name that contains the + client's root disk. The path is formatted as a charac­ + ter string consisting of characters from the NVT ASCII + character set. - ooppttiioonn nneettbbiiooss--nnooddee--ttyyppee _u_i_n_t_8;; + ooppttiioonn rroouutteerr--ddiissccoovveerryy _f_l_a_g;; - The NetBIOS node type option allows NetBIOS over TCP/IP - clients which are configurable to be configured as - described in RFC 1001/1002. The value is specified as - a single octet which identifies the client type. + This option specifies whether or not the client should + solicit routers using the Router Discovery mechanism + defined in RFC 1256. A value of 0 indicates that the + client should not perform router discovery. A value of + 1 means that the client should perform router discov­ + ery. - Possible node types are: + ooppttiioonn rroouutteerr--ssoolliicciittaattiioonn--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;; + + <<<<<<< dhcp-options.5 This option specifies a list of + IP addresses indicating NTP (RFC 1305) servers avail­ + able to the client. Servers should be listed in order + of preference. ======= This option specifies the + address to which the client should transmit router + solicitation requests. >>>>>>> 1.9 + + ooppttiioonn rroouutteerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + The routers option specifies a list of IP addresses for + routers on the client's subnet. Routers should be + listed in order of preference. + + ooppttiioonn ssmmttpp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + The SMTP server option specifies a list of SMTP servers + available to the client. Servers should be listed in + order of preference. + + ooppttiioonn ssttaattiicc--rroouutteess _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s + [,, _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s...];; + + This option specifies a list of static routes that the + client should install in its routing cache. If multi­ + ple routes to the same destination are specified, they + are listed in descending order of priority. + + The routes consist of a list of IP address pairs. The + first address is the destination address, and the sec­ + ond address is the router for the destination. + + The default route (0.0.0.0) is an illegal destination + + + + 9 + + + + + +dhcpd-options(5) dhcpd-options(5) - _1 B-node: Broadcast - no WINS + for a static route. To specify the default route, use + the rroouutteerrss option. Also, please note that this + option is not intended for classless IP routing - it + does not include a subnet mask. Since classless IP + routing is now the most widely deployed routing stan­ + dard, this option is virtually useless, and is not + implemented by any of the popular DHCP clients, for + example the Microsoft DHCP client. - _2 P-node: Peer - WINS only. + ooppttiioonn ssttrreeeettttaallkk--ddiirreeccttoorryy--aassssiissttaannccee--sseerrvveerr _i_p_-_a_d_d_r_e_s_s + [,, _i_p_-_a_d_d_r_e_s_s...];; - _4 M-node: Mixed - broadcast, then WINS + The StreetTalk Directory Assistance (STDA) server + option specifies a list of STDA servers available to + the client. Servers should be listed in order of pref­ + erence. - _8 H-node: Hybrid - WINS, then broadcast + ooppttiioonn ssttrreeeettttaallkk--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - ooppttiioonn nneettbbiiooss--ssccooppee _s_t_r_i_n_g;; + The StreetTalk server option specifies a list of + StreetTalk servers available to the client. Servers + should be listed in order of preference. - The NetBIOS scope option specifies the NetBIOS over - TCP/IP scope parameter for the client as specified in - RFC 1001/1002. See RFC1001, RFC1002, and RFC1035 for - character-set restrictions. + ooppttiioonn ssuubbnneett--mmaasskk _i_p_-_a_d_d_r_e_s_s;; - ooppttiioonn ffoonntt--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + The subnet mask option specifies the client's subnet + mask as per RFC 950. If no subnet mask option is pro­ + vided anywhere in scope, as a last resort dhcpd will + use the subnet mask from the subnet declaration for the + network on which an address is being assigned. How­ + ever, _a_n_y subnet-mask option declaration that is in + scope for the address being assigned will override the + subnet mask specified in the subnet declaration. - This option specifies a list of X Window System Font - servers available to the client. Servers should be - listed in order of preference. + ooppttiioonn sswwaapp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s;; - ooppttiioonn xx--ddiissppllaayy--mmaannaaggeerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + This specifies the IP address of the client's swap + server. - This option specifies a list of systems that are run­ - ning the X Window System Display Manager and are avail­ - able to the client. Addresses should be listed in - order of preference. + ooppttiioonn ttccpp--kkeeeeppaalliivvee--ggaarrbbaaggee _f_l_a_g;; - ooppttiioonn ddhhccpp--cclliieenntt--iiddeennttiiffiieerr _s_t_r_i_n_g;; + This option specifies the whether or not the client + should send TCP keepalive messages with a octet of + garbage for compatibility with older implementations. + A value of 0 indicates that a garbage octet should not + be sent. A value of 1 indicates that a garbage octet + should be sent. - This option can be used to specify the a DHCP client - identifier in a host declaration, so that dhcpd can - find the host record by matching against the client - identifier. - ooppttiioonn nniisspplluuss--ddoommaaiinn _s_t_r_i_n_g;; + ooppttiioonn ttccpp--kkeeeeppaalliivvee--iinntteerrvvaall _u_i_n_t_3_2;; + This option specifies the interval (in seconds) that + the client TCP should wait before sending a keepalive + message on a TCP connection. The time is specified as + a 32-bit unsigned integer. A value of zero indicates - 8 + 10 @@ -532,100 +664,119 @@ dhcpd-options(5) dhcpd-options(5) dhcpd-options(5) dhcpd-options(5) - This option specifies the name of the client's NIS+ - domain. The domain is formatted as a character string - consisting of characters from the NVT ASCII character - set. - ooppttiioonn nniisspplluuss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - - This option specifies a list of IP addresses indicating - NIS+ servers available to the client. Servers should - be listed in order of preference. + that the client should not generate keepalive messages + on connections unless specifically requested by an + application. - ooppttiioonn ttffttpp--sseerrvveerr--nnaammee _s_t_r_i_n_g;; + ooppttiioonn ttffttpp--sseerrvveerr--nnaammee _t_e_x_t;; - This option is used to identify a TFTP server and, if + This option is used to identify a TFTP server and, if supported by the client, should have the same effect as - the sseerrvveerr--nnaammee declaration. BOOTP clients are - unlikely to support this option. Some DHCP clients + the sseerrvveerr--nnaammee declaration. BOOTP clients are + unlikely to support this option. Some DHCP clients will support it, and others actually require it. - ooppttiioonn bboooottffiillee--nnaammee _s_t_r_i_n_g;; + ooppttiioonn ttiimmee--ooffffsseett _i_n_t_3_2;; - This option is used to identify a bootstrap file. If - supported by the client, it should have the same effect - as the ffiilleennaammee declaration. BOOTP clients are - unlikely to support this option. Some DHCP clients - will support it, and others actually require it. + The time-offset option specifies the offset of the + client's subnet in seconds from Coordinated Universal + Time (UTC). - ooppttiioonn mmoobbiillee--iipp--hhoommee--aaggeenntt _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn ttiimmee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [, _i_p_-_a_d_d_r_e_s_s... ];; - This option specifies a list of IP addresses indicating - mobile IP home agents available to the client. Agents - should be listed in order of preference, although nor­ - mally there will be only one such agent. + The time-server option specifies a list of RFC 868 time + servers available to the client. Servers should be + listed in order of preference. - ooppttiioonn ssmmttpp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn ttrraaiilleerr--eennccaappssuullaattiioonn _f_l_a_g;; - The SMTP server option specifies a list of SMTP servers - available to the client. Servers should be listed in - order of preference. + This option specifies whether or not the client should + negotiate the use of trailers (RFC 893 [14]) when using + the ARP protocol. A value of 0 indicates that the + client should not attempt to use trailers. A value of + 1 means that the client should attempt to use trailers. - ooppttiioonn ppoopp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn uuaapp--sseerrvveerrss _t_e_x_t;; - The POP3 server option specifies a list of POP3 avail­ - able to the client. Servers should be listed in order - of preference. + This option specifies a list of URLs, each pointing to + a user authentication service that is capable of pro­ + cessing authentication requests encapsulated in the + User Authentication Protocol (UAP). UAP servers can + accept either HTTP 1.1 or SSLv3 connections. If the + list includes a URL that does not contain a port compo­ + nent, the normal default port is assumed (i.e., port 80 + for http and port 443 for https). If the list includes + a URL that does not contain a path component, the path + /uap is assumed. If more than one URL is specified in + this list, the URLs are seperated by spaces. - ooppttiioonn nnnnttpp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn vveennddoorr--ccllaassss--iiddeennttiiffiieerr _s_t_r_i_n_g;; - The NNTP server option specifies a list of NNTP avail­ - able to the client. Servers should be listed in order - of preference. + This option is used by some DHCP clients to identify + the vendor type and possibly the configuration of a + DHCP client. The information is a string of bytes + whose contents are specific to the vendor and are not + specified in a standard. To see what vendor class + identifier a clients are sending, you can write the - ooppttiioonn wwwwww--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - The WWW server option specifies a list of WWW available + 11 - 9 +dhcpd-options(5) dhcpd-options(5) -dhcpd-options(5) dhcpd-options(5) + following in your DHCP server configuration file: + set vendor-class option vendor-class-identifier; - to the client. Servers should be listed in order of - preference. + This will result in all entries in the DHCP server + lease database file for clients that sent vendor-class- + identifier options having a set statement that looks + something like this: - ooppttiioonn ffiinnggeerr--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + set vendor-class "SUNW.Ultra-5_10"; - The Finger server option specifies a list of Finger - available to the client. Servers should be listed in - order of preference. + The vendor-class-identifier option is normally used by + the DHCP server to determine the options that are + returned in the vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option. + Please see the VENDOR ENCAPSULATED OPTIONS section of + the dhcpd.conf manual page for further information. - ooppttiioonn iirrcc--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + ooppttiioonn vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss _s_t_r_i_n_g;; - The IRC server option specifies a list of IRC available - to the client. Servers should be listed in order of - preference. + The vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option can contain + either a single vendor-specific value or one or more + vendor-specific suboptions. This option is not nor­ + mally specified in the DHCP server configuration file - + instead, a vendor class is defined for each vendor, + vendor class suboptions are defined, values for those + suboptions are defined, and the DHCP server makes up a + response on that basis. - ooppttiioonn ssttrreeeettttaallkk--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + Some default behaviours for well-known DHCP client ven­ + dors (currently, the Microsoft Windows 2000 DHCP + client) are configured automatically, but otherwise + this must be configured manually - see the VENDOR + ENCAPSULATED OPTIONS section of the _d_h_c_p_d_._c_o_n_f _m_a_n_u_a_l + _p_a_g_e _f_o_r _d_e_t_a_i_l_s_. - The StreetTalk server option specifies a list of - StreetTalk servers available to the client. Servers - should be listed in order of preference. + ooppttiioonn xx--ddiissppllaayy--mmaannaaggeerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; - ooppttiioonn ssttrreeeettaallkk--ddiirreeccttoorryy--aassssiissttaannccee--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, - _i_p_-_a_d_d_r_e_s_s... ];; + This option specifies a list of systems that are run­ + ning the X Window System Display Manager and are avail­ + able to the client. Addresses should be listed in + order of preference. - The StreetTalk Directory Assistance (STDA) server - option specifies a list of STDA servers available to - the client. Servers should be listed in order of pref­ - erence. + ooppttiioonn wwwwww--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + The WWW server option specifies a list of WWW available + to the client. Servers should be listed in order of + preference. RREELLAAYY AAGGEENNTT IINNFFOORRMMAATTIIOONN OOPPTTIIOONN An IETF draft, draft-ietf-dhc-agent-options-03.txt, @@ -633,6 +784,18 @@ RREELLAAYY AAGGEENNTT IINNFFOORRMMAATTIIOONN OOPPTTIIO agent can add to a DHCP packet when relaying it to the DHCP server. The server can then make address allocation decisions (or whatever other decisions it wants) based on + + + + 12 + + + + + +dhcpd-options(5) dhcpd-options(5) + + these options. The server also returns these options in any replies it sends through the relay agent, so that the relay agent can use the information in these options for @@ -652,18 +815,6 @@ RREELLAAYY AAGGEENNTT IINNFFOORRMMAATTIIOONN OOPPTTIIO packet was received. It is intended for use by agents in relaying DHCP responses back to the proper circuit. The format of this option is currently defined to be - - - - 10 - - - - - -dhcpd-options(5) dhcpd-options(5) - - vendor-dependent, and will probably remain that way, although the current draft allows for for the possibil­ ity of standardizing the format in the future. @@ -679,65 +830,130 @@ dhcpd-options(5) dhcpd-options(5) be an opaque object that is administratively guaranteed to be unique to a particular remote end of a circuit. +TTHHEE NNEETTWWAARREE//IIPP SSUUBBOOPPTTIIOONNSS + RFC2242 defines a set of encapsulated options for Novell + NetWare/IP clients. To use these options in the dhcp + server, specify the option space name, "nwip", followed by + a period, followed by the option name. The following + options can be specified: + + ooppttiioonn nnwwiipp..nnssqq--bbrrooaaddccaasstt _f_l_a_g;; + + If true, the client should use the NetWare Nearest + Server Query to locate a NetWare/IP server. The + behaviour of the Novell client if this suboption is + false, or is not present, is not specified. + + ooppttiioonn nnwwiipp..pprreeffeerrrreedd--ddssss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s... ];; + + This suboption specifies a list of up to five IP + addresses, each of which should be the IP address of a + NetWare Domain SAP/RIP server (DSS). + + + + + 13 + + + + + +dhcpd-options(5) dhcpd-options(5) + + + ooppttiioonn nnwwiipp..nneeaarreesstt--nnwwiipp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s + [,, _i_p_-_a_d_d_r_e_s_s...];; + + This suboption specifies a list of up to five IP + addresses, each of which should be the IP address of a + Nearest NetWare IP server. + + ooppttiioonn nnwwiipp..aauuttoorreettrriieess _u_i_n_t_8;; + + Specifies the number of times that a NetWare/IP client + should attempt to communicate with a given DSS server + at startup. + + ooppttiioonn nnwwiipp..aauuttoorreettrryy--sseeccss _u_i_n_t_8;; + + Specifies the number of seconds that a Netware/IP + client should wait between retries when attempting to + establish communications with a DSS server at startup. + + ooppttiioonn nnwwiipp..nnwwiipp--11--11 _u_i_n_t_8;; + + If true, the NetWare/IP client should support Net­ + Ware/IP version 1.1 compatibility. This is only + needed if the client will be contacting Netware/IP ver­ + sion 1.1 servers. + + ooppttiioonn nnwwiipp..pprriimmaarryy--ddssss _i_p_-_a_d_d_r_e_s_s;; + + Specifies the IP address of the Primary Domain SAP/RIP + Service server (DSS) for this NetWare/IP domain. The + NetWare/IP administration utility uses this value as + Primary DSS server when configuring a secondary DSS + server. + DDEEFFIINNIINNGG NNEEWW OOPPTTIIOONNSS - The Internet Software Consortium DHCP client and server - provide the capability to define new options. Each DHCP - option has a name, a code, and a structure. The name is - used by you to refer to the option. The code is a num­ - ber, used by the DHCP server and client to refer to an - option. The structure describes what the contents of an + The Internet Software Consortium DHCP client and server + provide the capability to define new options. Each DHCP + option has a name, a code, and a structure. The name is + used by you to refer to the option. The code is a num­ + ber, used by the DHCP server and client to refer to an + option. The structure describes what the contents of an option looks like. - To define a new option, you need to choose a name for it - that is not in use for some other option - for example, + To define a new option, you need to choose a name for it + that is not in use for some other option - for example, you can't use "host-name" because the DHCP protocol - already defines a host-name option, which is documented - earlier in this manual page. If an option name doesn't + already defines a host-name option, which is documented + earlier in this manual page. If an option name doesn't appear in this manual page, you can use it, but it's prob­ - ably a good idea to put some kind of unique string at the - beginning so you can be sure that future options don't + ably a good idea to put some kind of unique string at the + beginning so you can be sure that future options don't take your name. For example, you might define an option, - "local-host-name", feeling some confidence that no offi­ + "local-host-name", feeling some confidence that no offi­ cial DHCP option name will ever start with "local". - Once you have chosen a name, you must choose a code. For - site-local options, all codes between 128 and 254 are - reserved for DHCP options, so you can pick any one of - these. In practice, some vendors have interpreted the - protocol rather loosely and have used option code values - greater than 128 themselves. There's no real way to - avoid this problem, but it's not likely to cause too much - trouble in practice. - - The structure of an option is simply the format in which - the option data appears. The ISC DHCP server currently - supports a few simple types, like integers, booleans, - strings and IP addresses, and it also supports the ability - to define arrays of single types or arrays of fixed - sequences of types. - New options are declared as follows: + 14 - 11 +dhcpd-options(5) dhcpd-options(5) + Once you have chosen a name, you must choose a code. For + site-local options, all codes between 128 and 254 are + reserved for DHCP options, so you can pick any one of + these. In practice, some vendors have interpreted the + protocol rather loosely and have used option code values + greater than 128 themselves. There's no real way to + avoid this problem, but it's not likely to cause too much + trouble in practice. -dhcpd-options(5) dhcpd-options(5) + The structure of an option is simply the format in which + the option data appears. The ISC DHCP server currently + supports a few simple types, like integers, booleans, + strings and IP addresses, and it also supports the ability + to define arrays of single types or arrays of fixed + sequences of types. + New options are declared as follows: ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == _d_e_f_i_n_i_t_i_o_n ;; The values of _n_e_w_-_n_a_m_e and _n_e_w_-_c_o_d_e should be the name you - have chosen for the new option and the code you have cho­ - sen. The _d_e_f_i_n_i_t_i_o_n should be the definition of the + have chosen for the new option and the code you have cho­ + sen. The _d_e_f_i_n_i_t_i_o_n should be the definition of the structure of the option. - The following simple option type definitions are sup­ + The following simple option type definitions are sup­ ported: BBOOOOLLEEAANN @@ -745,115 +961,97 @@ dhcpd-options(5) dhcpd-options(5) ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == bboooolleeaann ;; An option of type boolean is a flag with a value of either - on or off (or true or false). So an example use of the + on or off (or true or false). So an example use of the boolean type would be: - option use-zephyr code 180 = boolean; - option use-zephyr on; + option use-zephyr code 180 = boolean; + option use-zephyr on; IINNTTEEGGEERR ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == _s_i_g_n iinntteeggeerr _w_i_d_t_h ;; The _s_i_g_n token should either be blank, _u_n_s_i_g_n_e_d or _s_i_g_n_e_d. - The width can be either 8, 16 or 32, and refers to the - number of bits in the integer. So for example, the fol­ - lowing two lines show a definition of the sql-connection- + The width can be either 8, 16 or 32, and refers to the + number of bits in the integer. So for example, the fol­ + lowing two lines show a definition of the sql-connection- max option and its use: - option sql-connection-max code 192 = unsigned integer 16; - option sql-connection-max 1536; + option sql-connection-max code 192 = unsigned integer 16; + option sql-connection-max 1536; IIPP--AADDDDRREESSSS - ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == iipp--aaddddrreessss ;; - An option whose structure is an IP address can be - expressed either as a domain name or as a dotted quad. So - the following is an example use of the ip-address type: - option sql-server-address code 193 = ip-address; - option sql-server-address sql.example.com; + 15 - TTEEXXTT - ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == tteexxtt ;; - An option whose type is text will encode an ASCII text - string. For example: - option sql-default-connection-name code 194 = text; +dhcpd-options(5) dhcpd-options(5) - 12 + ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == iipp--aaddddrreessss ;; + An option whose structure is an IP address can be + expressed either as a domain name or as a dotted quad. So + the following is an example use of the ip-address type: + option sql-server-address code 193 = ip-address; + option sql-server-address sql.example.com; + TTEEXXTT -dhcpd-options(5) dhcpd-options(5) + ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == tteexxtt ;; + An option whose type is text will encode an ASCII text + string. For example: - option sql-default-connection-name "PRODZA"; + option sql-default-connection-name code 194 = text; + option sql-default-connection-name "PRODZA"; DDAATTAA SSTTRRIINNGG ooppttiioonn _n_e_w_-_n_a_m_e ccooddee _n_e_w_-_c_o_d_e == ssttrriinngg ;; - An option whose type is a data string is essentially just - a collection of bytes, and can be specified either as + An option whose type is a data string is essentially just + a collection of bytes, and can be specified either as quoted text, like the text type, or as a list of hexadeci­ - mal contents seperated by colons whose values must be + mal contents seperated by colons whose values must be between 0 and FF. For example: - option sql-identification-token code 195 = string; - option sql-identification-token 17:23:19:a6:42:ea:99:7c:22; + option sql-identification-token code 195 = string; + option sql-identification-token 17:23:19:a6:42:ea:99:7c:22; AARRRRAAYYSS - Options can contain arrays of any of the above types - except for the text and data string types, which aren't - currently supported in arrays. An example of an array + Options can contain arrays of any of the above types + except for the text and data string types, which aren't + currently supported in arrays. An example of an array definition is as follows: - option kerberos-servers code 200 = array of ip-address; - option kerberos-servers 10.20.10.1, 10.20.11.1; + option kerberos-servers code 200 = array of ip-address; + option kerberos-servers 10.20.10.1, 10.20.11.1; RREECCOORRDDSS - Options can also contain data structures consisting of a + Options can also contain data structures consisting of a sequence of data types, which is sometimes called a record type. For example: - option contrived-001 code 201 = { boolean, integer 32, text }; - option contrived-001 on 1772 "contrivance"; - - It's also possible to have options that are arrays of - records, for example: - - option new-static-routes code 201 = array of { - ip-address, ip-address, ip-address, integer 8 }; - option static-routes - 10.0.0.0 255.255.255.0 net-0-rtr.example.com 1, - 10.0.1.0 255.255.255.0 net-1-rtr.example.com 1, - 10.2.0.0 255.255.224.0 net-2-0-rtr.example.com 3; - - -SSEEEE AALLSSOO - dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcp- - eval(5), dhcpd(8), dhclient(8), RFC2132, RFC2131, draft- - ietf-dhc-agent-options-??.txt. + option contrived-001 code 201 = { boolean, integer 32, text }; + option contrived-001 on 1772 "contrivance"; -AAUUTTHHOORR - The Internet Software Consortium DHCP Distribution was - 13 + 16 @@ -862,52 +1060,118 @@ AAUUTTHHOORR dhcpd-options(5) dhcpd-options(5) - written by Ted Lemon under a contract - with Vixie Labs. Funding for this project was provided - through the Internet Software Consortium. Information - about the Internet Software Consortium can be found at - hhttttpp::////wwwwww..iisscc..oorrgg//iisscc.. - - - - - - - - - - - - - - - - - - + It's also possible to have options that are arrays of + records, for example: + option new-static-routes code 201 = array of { + ip-address, ip-address, ip-address, integer 8 }; + option static-routes + 10.0.0.0 255.255.255.0 net-0-rtr.example.com 1, + 10.0.1.0 255.255.255.0 net-1-rtr.example.com 1, + 10.2.0.0 255.255.224.0 net-2-0-rtr.example.com 3; +VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD OOPPTTIIOONNSS + The DHCP protocol defines the vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss + option, which allows vendors to define their own options + that will be sent encapsulated in a standard DHCP option. + The format of the vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option is + either a series of bytes whose format is not specified, or + a sequence of options, each of which consists of a single- + byte vendor-specific option code, followed by a single- + byte length, followed by as many bytes of data as are + specified in the length (the length does not include + itself or the option code). + The value of this option can be set in one of two ways. + The first way is to simply specify the data directly, + using a text string or a colon-seperated list of hexadeci­ + mal values. For example: + option vendor-encapsulated-options + 2:4:AC:11:41:1: + 3:12:73:75:6e:64:68:63:70:2d:73:65:72:76:65:72:31:37:2d:31: + 4:12:2f:65:78:70:6f:72:74:2f:72:6f:6f:74:2f:69:38:36:70:63; + The second way of setting the value of this option is to + have the DHCP server generate a vendor-specific option + buffer. To do this, you must do four things: define an + option space, define some options in that option space, + provide values for them, and specify that that option + space should be used to generate the vveennddoorr--eennccaappssuullaatteedd-- + ooppttiioonnss option. + To define a new option space in which vendor options can + be stored, use the option space statement: + ooppttiioonn ssppaaccee _n_a_m_e ;; + The name can then be used in option definitions, as + described earlier in this document. For example: + option space SUNW; + option SUNW.server-address code 2 = ip-address; + option SUNW.server-name code 3 = text; + option SUNW.root-path code 4 = text; + 17 +dhcpd-options(5) dhcpd-options(5) + Once you have defined an option space and the format of + some options, you can set up scopes that define values for + those options, and you can say when to use them. For + example, suppose you want to handle two different classes + of clients. Using the option space definition shown in + the previous example, you can send different option values + to different clients based on the vendor-class-identifier + option that the clients send, as follows: + + class "vendor-classes" { + match option vendor-class-identifier; + } + + option SUNW.server-address 172.17.65.1; + option SUNW.server-name "sundhcp-server17-1"; + + subclass "vendor-classes" "SUNW.Ultra-5_10" { + vendor-option-space SUNW; + option SUNW.root-path "/export/root/sparc"; + } + + subclass "vendor-classes" "SUNW.i86pc" { + vendor-option-space SUNW; + option SUNW.root-path "/export/root/i86pc"; + } + + As you can see in the preceding example, regular scoping + rules apply, so you can define values that are global in + the global scope, and only define values that are specific + to a particular class in the local scope. The vveennddoorr-- + ooppttiioonn--ssppaaccee declaration tells the DHCP server to use + options in the SUNW option space to construct the vveennddoorr-- + eennccaappssuullaatteedd--ooppttiioonnss option. +SSEEEE AALLSSOO + dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcp- + eval(5), dhcpd(8), dhclient(8), RFC2132, RFC2131, draft- + ietf-dhc-agent-options-??.txt. +AAUUTTHHOORR + The Internet Software Consortium DHCP Distribution was + written by Ted Lemon under a contract + with Vixie Labs. Funding for this project was provided + through the Internet Software Consortium. Information + about the Internet Software Consortium can be found at + hhttttpp::////wwwwww..iisscc..oorrgg//iisscc.. @@ -919,6 +1183,6 @@ dhcpd-options(5) dhcpd-options(5) - 14 + 18 diff --git a/common/discover.c b/common/discover.c index fb0f87c5f..acb780a2e 100644 --- a/common/discover.c +++ b/common/discover.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: discover.c,v 1.19 2000/01/25 01:04:21 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: discover.c,v 1.20 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -145,8 +145,8 @@ void discover_interfaces (state) /* If there isn't already an interface by this name, allocate one. */ if (!tmp) { - tmp = ((struct interface_info *) - dmalloc (sizeof *tmp, "discover_interfaces")); + tmp = ((struct interface_info *) dmalloc (sizeof *tmp, + MDL)); if (!tmp) log_fatal ("Insufficient memory to %s %s", "record interface", ifp -> ifr_name); @@ -203,7 +203,7 @@ void discover_interfaces (state) #else unsigned len = sizeof *ifp; #endif - tif = (struct ifreq *)malloc (len); + tif = (struct ifreq *)dmalloc (len, MDL); if (!tif) log_fatal ("no space for ifp."); memcpy (tif, ifp, len); @@ -338,7 +338,8 @@ void discover_interfaces (state) if (!tmp -> ifp) { /* Make up an ifreq structure. */ - tif = (struct ifreq *)malloc (sizeof (struct ifreq)); + tif = (struct ifreq *)dmalloc (sizeof (struct ifreq), + MDL); if (!tif) log_fatal ("no space to remember ifp."); memset (tif, 0, sizeof (struct ifreq)); @@ -535,15 +536,13 @@ int if_readsocket (h) struct interface_info *setup_fallback () { - fallback_interface = - ((struct interface_info *) - dmalloc (sizeof *fallback_interface, "discover_interfaces")); + fallback_interface = ((struct interface_info *) + dmalloc (sizeof *fallback_interface, MDL)); if (!fallback_interface) log_fatal ("No memory to record fallback interface."); memset (fallback_interface, 0, sizeof *fallback_interface); strcpy (fallback_interface -> name, "fallback"); - fallback_interface -> shared_network = - new_shared_network ("parse_statement"); + fallback_interface -> shared_network = new_shared_network (MDL); if (!fallback_interface -> shared_network) log_fatal ("No memory for shared subnet"); memset (fallback_interface -> shared_network, 0, @@ -653,7 +652,7 @@ isc_result_t interface_stuff_values (omapi_object_t *c, return ISC_R_NOTFOUND; } -isc_result_t interface_destroy (omapi_object_t *h, const char *name) +isc_result_t interface_destroy (omapi_object_t *h, const char *file, int line) { int i; diff --git a/common/dispatch.c b/common/dispatch.c index c7ff66688..7f29f9572 100644 --- a/common/dispatch.c +++ b/common/dispatch.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.58 1999/10/04 23:46:30 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.59 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -103,7 +103,8 @@ void add_timeout (when, where, what) q -> func = where; q -> what = what; } else { - q = (struct timeout *)malloc (sizeof (struct timeout)); + q = ((struct timeout *) + dmalloc (sizeof (struct timeout), MDL)); if (!q) log_fatal ("add_timeout: no memory!"); q -> func = where; diff --git a/common/dns.c b/common/dns.c index 97e9af47b..22389baa6 100644 --- a/common/dns.c +++ b/common/dns.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: dns.c,v 1.13 2000/01/05 18:00:51 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dns.c,v 1.14 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -197,12 +197,12 @@ struct dns_query *find_dns_query (question, new) } if (q || !new) { if (new) - free (question); + dfree (question, MDL); return q; } /* Allocate and zap a new query. */ - q = (struct dns_query *)malloc (sizeof (struct dns_query)); + q = (struct dns_query *)dmalloc (sizeof (struct dns_query), MDL); memset (q, 0, sizeof *q); /* All we need to set up is the question and the hash. */ @@ -223,11 +223,11 @@ void destroy_dns_query (query) /* Free up attached free data. */ if (query -> question) - free (query -> question); + dfree (query -> question, MDL); if (query -> answer) - free (query -> answer); + dfree (query -> answer, MDL); if (query -> query) - free (query -> query); + dfree (query -> query, MDL); /* Remove query from hash table. */ if (dns_query_hash [query -> hash] == query) @@ -241,7 +241,7 @@ void destroy_dns_query (query) } /* Free the query structure. */ - free (query); + dfree (query, MDL); } /* ns_inaddr_lookup constructs a PTR lookup query for an internet address - @@ -264,8 +264,8 @@ struct dns_query *ns_inaddr_lookup (inaddr, wakeup) inaddr.iabuf [0], inaddr.iabuf [1], inaddr.iabuf [2], inaddr.iabuf [3]); - question = (struct dns_question *)malloc (strlen ((char *)query) + - sizeof *question); + question = (struct dns_question *)dmalloc (strlen ((char *)query) + + sizeof *question, MDL); if (!question) return (struct dns_query *)-1; question -> type = T_PTR; @@ -318,7 +318,7 @@ struct dns_query *ns_query (question, formatted_query, len, wakeup) /* If the query won't fit, don't bother setting it up. */ if (len > 255) { - free (question); + dfree (question, MDL); return (struct dns_query *)-1; } @@ -363,7 +363,7 @@ struct dns_query *ns_query (question, formatted_query, len, wakeup) query -> len = s - buf; /* Save the raw query data. */ - query -> query = malloc (len); + query -> query = dmalloc (len, MDL); if (!query -> query) { destroy_dns_query (query); return (struct dns_query *)-1; diff --git a/common/execute.c b/common/execute.c index cb35bf8c4..d8fb80fb1 100644 --- a/common/execute.c +++ b/common/execute.c @@ -22,10 +22,11 @@ #ifndef lint static char copyright[] = -"$Id: execute.c,v 1.23 2000/01/25 01:07:00 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: execute.c,v 1.24 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" +#include int execute_statements (packet, lease, in_options, out_options, scope, statements) @@ -69,35 +70,29 @@ int execute_statements (packet, lease, in_options, out_options, scope, if (r -> data.on.evtypes & ON_EXPIRY) { if (lease -> on_expiry) executable_statement_dereference - (&lease -> on_expiry, - "execute_statements"); + (&lease -> on_expiry, MDL); if (r -> data.on.statements) executable_statement_reference (&lease -> on_expiry, - r -> data.on.statements, - "execute_statements"); + r -> data.on.statements, MDL); } if (r -> data.on.evtypes & ON_RELEASE) { if (lease -> on_release) executable_statement_dereference - (&lease -> on_release, - "execute_statements"); + (&lease -> on_release, MDL); if (r -> data.on.statements) executable_statement_reference (&lease -> on_release, - r -> data.on.statements, - "execute_statements"); + r -> data.on.statements, MDL); } if (r -> data.on.evtypes & ON_COMMIT) { if (lease -> on_commit) executable_statement_dereference - (&lease -> on_commit, - "execute_statements"); + (&lease -> on_commit, MDL); if (r -> data.on.statements) executable_statement_reference (&lease -> on_commit, - r -> data.on.statements, - "execute_statements"); + r -> data.on.statements, MDL); } } break; @@ -154,9 +149,9 @@ int execute_statements (packet, lease, in_options, out_options, scope, out_options, scope, r -> data.eval)); if (status && ds.data) - data_string_forget - (&ds, "execute_statements"); + data_string_forget (&ds, MDL); } else if (is_dns_expression (r -> data.eval)) { +#if defined (NSUPDATE) ns_updrec *nut; nut = 0; status = (evaluate_dns_expression @@ -165,17 +160,16 @@ int execute_statements (packet, lease, in_options, out_options, scope, r -> data.eval)); if (status) { if (nut -> r_data) { - dfree (nut -> r_data, - "execute_statements"); + dfree (nut -> r_data, MDL); nut -> r_data = (char *)0; } if (nut -> r_dname) { - dfree (nut -> r_dname, - "execute_statements"); + dfree (nut -> r_dname, MDL); nut -> r_dname = (char *)0; } res_freeupdrec (nut); } +#endif } else { log_error ("%s: invalid expression type: %d", "execute_statements", @@ -247,13 +241,12 @@ int execute_statements (packet, lease, in_options, out_options, scope, binding = find_binding (scope, r -> data.set.name); if (!binding && status) { - binding = dmalloc (sizeof *binding, - "execute_statements"); + binding = dmalloc (sizeof *binding, MDL); if (binding) { binding -> name = dmalloc (strlen (r -> data.set.name + 1), - "execute_statements"); + MDL); if (binding -> name) { strcpy (binding -> name, r -> data.set.name); @@ -268,7 +261,7 @@ int execute_statements (packet, lease, in_options, out_options, scope, } } else { badalloc: - dfree (binding, "execute_statements"); + dfree (binding, MDL); binding = (struct binding *)0; } } @@ -276,13 +269,13 @@ int execute_statements (packet, lease, in_options, out_options, scope, if (binding) { if (binding -> value.data) data_string_forget (&binding -> value, - "execute_statements"); + MDL); if (status) data_string_copy (&binding -> value, &ds, - "execute_statements"); + MDL); } if (status) - data_string_forget (&ds, "execute_statements"); + data_string_forget (&ds, MDL); #if defined (DEBUG_EXPRESSIONS) log_debug ("exec: set %s = %s", r -> data.set.name, (status && binding @@ -296,9 +289,8 @@ int execute_statements (packet, lease, in_options, out_options, scope, binding = find_binding (scope, r -> data.unset); if (binding) { if (binding -> value.data) - data_string_forget - (&binding -> value, - "execute_statements"); + data_string_forget (&binding -> value, + MDL); status = 1; } else status = 0; @@ -315,40 +307,37 @@ int execute_statements (packet, lease, in_options, out_options, scope, scope, r -> data.let.expr)); ns = (struct binding_scope *)0; - binding_scope_allocate (&ns, "execute_statements"); + binding_scope_allocate (&ns, MDL); next_let: if (ns) { - binding = dmalloc (sizeof *binding, - "execute_statements"); + binding = dmalloc (sizeof *binding, MDL); if (!binding) { blb: - binding_scope_dereference - (&ns, "execute_statements"); + binding_scope_dereference (&ns, MDL); } else { binding -> name = dmalloc (strlen (r -> data.let.name + 1), - "execute_statements"); + MDL); if (binding -> name) strcpy (binding -> name, r -> data.let.name); else { - dfree (binding, "execute_statements"); + dfree (binding, MDL); binding = (struct binding *)0; goto blb; } } } if (ns && binding && status) { - data_string_copy (&binding -> value, &ds, - "execute_statements"); + data_string_copy (&binding -> value, &ds, MDL); binding -> next = ns -> bindings; ns -> bindings = binding; } if (status) - data_string_forget (&ds, "execute_statements"); + data_string_forget (&ds, MDL); #if defined (DEBUG_EXPRESSIONS) log_debug ("exec: let %s = %s", r -> data.let.name, (status && binding @@ -368,8 +357,7 @@ int execute_statements (packet, lease, in_options, out_options, scope, ns, r -> data.let.statements); } if (ns) - binding_scope_dereference - (&ns, "execute_statements"); + binding_scope_dereference (&ns, MDL); break; default: @@ -441,15 +429,15 @@ void execute_statements_in_scope (packet, lease, in_options, out_options, /* Dereference or free any subexpressions of a statement being freed. */ -int executable_statement_dereference (ptr, name) +int executable_statement_dereference (ptr, file, line) struct executable_statement **ptr; - const char *name; + const char *file; + int line; { struct executable_statement *bp; if (!ptr || !*ptr) { - log_error ("Null ptr in executable_statement_dereference: %s", - name); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -465,7 +453,7 @@ int executable_statement_dereference (ptr, name) } if ((*ptr) -> refcnt < 0) { - log_error ("option_state_dereference: negative refcnt!"); + log_error ("%s(%d): negative refcnt!", file, line); #if defined (DEBUG_RC_HISTORY) dump_rc_history (); #endif @@ -477,64 +465,65 @@ int executable_statement_dereference (ptr, name) } if ((*ptr) -> next) - executable_statement_dereference - (&(*ptr) -> next, name); + executable_statement_dereference (&(*ptr) -> next, file, line); switch ((*ptr) -> op) { case statements_statement: if ((*ptr) -> data.statements) executable_statement_dereference - (&(*ptr) -> data.statements, name); + (&(*ptr) -> data.statements, file, line); break; case on_statement: if ((*ptr) -> data.on.statements) executable_statement_dereference - (&(*ptr) -> data.on.statements, name); + (&(*ptr) -> data.on.statements, file, line); break; case switch_statement: if ((*ptr) -> data.s_switch.statements) executable_statement_dereference - (&(*ptr) -> data.on.statements, name); + (&(*ptr) -> data.on.statements, file, line); if ((*ptr) -> data.s_switch.expr) expression_dereference (&(*ptr) -> data.s_switch.expr, - name); + file, line); break; case case_statement: if ((*ptr) -> data.s_switch.expr) expression_dereference (&(*ptr) -> data.c_case, - name); + file, line); break; case if_statement: if ((*ptr) -> data.ie.expr) - expression_dereference (&(*ptr) -> data.ie.expr, name); + expression_dereference (&(*ptr) -> data.ie.expr, + file, line); if ((*ptr) -> data.ie.true) executable_statement_dereference - (&(*ptr) -> data.ie.true, name); + (&(*ptr) -> data.ie.true, file, line); if ((*ptr) -> data.ie.false) executable_statement_dereference - (&(*ptr) -> data.ie.false, name); + (&(*ptr) -> data.ie.false, file, line); break; case eval_statement: if ((*ptr) -> data.eval) - expression_dereference (&(*ptr) -> data.eval, name); + expression_dereference (&(*ptr) -> data.eval, + file, line); break; case set_statement: if ((*ptr)->data.set.name) - dfree ((*ptr)->data.set.name, name); + dfree ((*ptr)->data.set.name, file, line); if ((*ptr)->data.set.expr) expression_dereference (&(*ptr) -> data.set.expr, - name); + file, line); break; case unset_statement: if ((*ptr)->data.unset) - dfree ((*ptr)->data.unset, name); + dfree ((*ptr)->data.unset, file, line); break; case supersede_option_statement: @@ -543,7 +532,7 @@ int executable_statement_dereference (ptr, name) case prepend_option_statement: if ((*ptr) -> data.option) option_cache_dereference (&(*ptr) -> data.option, - name); + file, line); break; default: @@ -551,7 +540,7 @@ int executable_statement_dereference (ptr, name) break; } - dfree ((*ptr), name); + dfree ((*ptr), file, line); *ptr = (struct executable_statement *)0; return 1; } @@ -800,16 +789,14 @@ struct executable_statement *find_matching_case (packet, lease, in_options, if (sub && cd.len == ds.len && !memcmp (cd.data, ds.data, cd.len)) { - data_string_forget - (&cd, "execute_statements"); - data_string_forget - (&ds, "execute_statements"); + data_string_forget (&cd, MDL); + data_string_forget (&ds, MDL); return s -> next; } - data_string_forget (&cd, "execute_statements"); + data_string_forget (&cd, MDL); } } - data_string_forget (&ds, "execute_statements"); + data_string_forget (&ds, MDL); } } else { unsigned long n, c; diff --git a/common/hash.c b/common/hash.c index 916869147..4d5f33229 100644 --- a/common/hash.c +++ b/common/hash.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: hash.c,v 1.15 1999/10/07 06:35:42 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: hash.c,v 1.16 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -31,7 +31,7 @@ static INLINE int do_hash PROTO ((const unsigned char *, unsigned, unsigned)); struct hash_table *new_hash () { - struct hash_table *rv = new_hash_table (DEFAULT_HASH_SIZE, "new_hash"); + struct hash_table *rv = new_hash_table (DEFAULT_HASH_SIZE, MDL); if (!rv) return rv; memset (&rv -> buckets [0], 0, @@ -74,7 +74,7 @@ void add_hash (table, name, len, pointer) len = strlen ((const char *)name); hashno = do_hash (name, len, table -> hash_count); - bp = new_hash_bucket ("add_hash"); + bp = new_hash_bucket (MDL); if (!bp) { log_error ("Can't add %s to hash table.", name); @@ -115,7 +115,7 @@ void delete_hash_entry (table, name, len) } else { table -> buckets [hashno] = bp -> next; } - free_hash_bucket (bp, "delete_hash_entry"); + free_hash_bucket (bp, MDL); break; } pbp = bp; /* jwg, 9/6/96 - nice catch! */ diff --git a/common/icmp.c b/common/icmp.c index 8265460bb..77dd12655 100644 --- a/common/icmp.c +++ b/common/icmp.c @@ -23,7 +23,7 @@ #ifndef lint static char copyright[] = -"$Id: icmp.c,v 1.16 2000/01/05 18:01:41 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: icmp.c,v 1.17 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -65,7 +65,7 @@ void icmp_startup (routep, handler) log_fatal ("Can't register icmp object type: %s", isc_result_totext (result)); - new = (struct icmp_state *)dmalloc (sizeof *new, "icmp_startup"); + new = (struct icmp_state *)dmalloc (sizeof *new, MDL); if (!new) log_fatal ("Unable to allocate state for icmp protocol"); memset (new, 0, sizeof *new); diff --git a/common/memory.c b/common/memory.c index ea1314c8a..61f971dfc 100644 --- a/common/memory.c +++ b/common/memory.c @@ -22,18 +22,19 @@ #ifndef lint static char copyright[] = -"$Id: memory.c,v 1.63 1999/10/07 06:35:42 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: memory.c,v 1.64 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" -struct group *clone_group (group, caller) +struct group *clone_group (group, file, line) struct group *group; - const char *caller; + const char *file; + int line; { - struct group *g = new_group (caller); + struct group *g = new_group (file, line); if (!g) - log_fatal ("%s: can't allocate new group", caller); + log_fatal ("%s(%d): can't allocate new group", file, line); *g = *group; g -> statements = (struct executable_statement *)0; g -> next = group; diff --git a/common/options.c b/common/options.c index b5c102b90..41e38034e 100644 --- a/common/options.c +++ b/common/options.c @@ -3,7 +3,7 @@ DHCP options parsing and reassembly. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -22,11 +22,12 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.51 2000/01/25 01:09:06 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.52 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA #include "dhcpd.h" +#include static void do_option_set PROTO ((pair *, struct option_cache *, @@ -1027,9 +1028,10 @@ int option_cache_dereference (ptr, file, line) rc_register (file, line, *ptr, (*ptr) -> refcnt); if (!(*ptr) -> refcnt) { if ((*ptr) -> data.buffer) - data_string_forget (&(*ptr) -> data, name); + data_string_forget (&(*ptr) -> data, file, line); if ((*ptr) -> expression) - expression_dereference (&(*ptr) -> expression, name); + expression_dereference (&(*ptr) -> expression, + file, line); /* Put it back on the free list... */ (*ptr) -> expression = (struct expression *)free_option_caches; free_option_caches = *ptr; diff --git a/common/parse.c b/common/parse.c index 742f4ceff..6747ed263 100644 --- a/common/parse.c +++ b/common/parse.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.59 2000/01/25 01:13:21 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.60 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -208,8 +208,7 @@ int parse_ip_addr_or_hostname (expr, cfile, uniform) if (!uniform) { if (!make_limit (&x, *expr, 4)) return 0; - expression_dereference (expr, - "parse_ip_addr_or_hostname"); + expression_dereference (expr, MDL); *expr = x; } } else if (token == NUMBER) { @@ -798,7 +797,7 @@ struct option *parse_option_name (cfile, allocate, known) (might) be an option code definition, so we'll create an option structure just in case. */ if (allocate) { - option = new_option ("parse_option_name"); + option = new_option (MDL); if (val == uname) option -> name = val; else { @@ -847,7 +846,7 @@ void parse_option_space_decl (cfile) skip_to_semi (cfile); return; } - nu = new_universe ("parse_option_space_decl"); + nu = new_universe (MDL); if (!nu) log_fatal ("No memory for new option space."); @@ -1150,7 +1149,7 @@ int parse_cshl (data, cfile) token = next_token (&val, cfile); } while (1); - if (!buffer_allocate (&data -> buffer, tlen + ilen, "parse_cshl")) + if (!buffer_allocate (&data -> buffer, tlen + ilen, MDL)) log_fatal ("no memory to store octet data."); data -> data = &data -> buffer -> data [0]; data -> len = tlen + ilen; @@ -1240,8 +1239,7 @@ int parse_executable_statement (result, cfile, lose, case_context) *lose = 1; return 0; } - if (!executable_statement_allocate - (result, "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for new statement."); (*result) -> op = add_statement; (*result) -> data.add = cta; @@ -1253,8 +1251,7 @@ int parse_executable_statement (result, cfile, lose, case_context) *lose = 1; return 0; } - if (!executable_statement_allocate - (result, "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for new statement."); (*result) -> op = break_statement; break; @@ -1290,8 +1287,7 @@ int parse_executable_statement (result, cfile, lose, case_context) cache = (struct option_cache *)0; if (!parse_allow_deny (&cache, cfile, flag)) return 0; - if (!executable_statement_allocate - (result, "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for new statement."); (*result) -> op = supersede_option_statement; (*result) -> data.option = cache; @@ -1362,9 +1358,7 @@ int parse_executable_statement (result, cfile, lose, case_context) *lose = 1; return 0; } else { - if (!executable_statement_allocate - (result, - "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for default statement."); (*result) -> op = default_statement; return 1; @@ -1383,9 +1377,7 @@ int parse_executable_statement (result, cfile, lose, case_context) return 0; } - if (!executable_statement_allocate - (result, - "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for set statement."); (*result) -> op = set_statement; (*result) -> data.set.name = dmalloc (strlen (val) + 1, MDL); @@ -1407,8 +1399,7 @@ int parse_executable_statement (result, cfile, lose, case_context) else *lose = 1; skip_to_semi (cfile); - executable_statement_dereference - (result, "parse_executable_statement"); + executable_statement_dereference (result, MDL); return 0; } parse_semi (cfile); @@ -1427,9 +1418,7 @@ int parse_executable_statement (result, cfile, lose, case_context) return 0; } - if (!executable_statement_allocate - (result, - "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for set statement."); (*result) -> op = unset_statement; (*result) -> data.unset = dmalloc (strlen (val) + 1, MDL); @@ -1442,9 +1431,7 @@ int parse_executable_statement (result, cfile, lose, case_context) case EVAL: token = next_token (&val, cfile); - if (!executable_statement_allocate - (result, - "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for eval statement."); (*result) -> op = eval_statement; @@ -1457,8 +1444,7 @@ int parse_executable_statement (result, cfile, lose, case_context) else *lose = 1; skip_to_semi (cfile); - executable_statement_dereference - (result, "parse_executable_statement"); + executable_statement_dereference (result, MDL); return 0; } parse_semi (cfile); @@ -1487,8 +1473,7 @@ int parse_on_statement (result, cfile, lose) enum dhcp_token token; const char *val; - if (!executable_statement_allocate (result, - "parse_executable_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for new statement."); (*result) -> op = on_statement; @@ -1511,8 +1496,7 @@ int parse_on_statement (result, cfile, lose) parse_warn (cfile, "expecting a lease event type"); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference - (result, "parse_on_statement"); + executable_statement_dereference (result, MDL); return 0; } token = next_token (&val, cfile); @@ -1526,8 +1510,7 @@ int parse_on_statement (result, cfile, lose) parse_warn (cfile, "left brace expected."); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference (result, - "parse_on_statement"); + executable_statement_dereference (result, MDL); return 0; } if (!parse_executable_statements (&(*result) -> data.on.statements, @@ -1537,8 +1520,7 @@ int parse_on_statement (result, cfile, lose) do { token = next_token (&val, cfile); } while (token != EOF && token != RBRACE); - executable_statement_dereference - (result, "parse_on_statement"); + executable_statement_dereference (result, MDL); return 0; } } @@ -1547,8 +1529,7 @@ int parse_on_statement (result, cfile, lose) parse_warn (cfile, "right brace expected."); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference - (result, "parse_on_statement"); + executable_statement_dereference (result, MDL); return 0; } return 1; @@ -1567,8 +1548,7 @@ int parse_switch_statement (result, cfile, lose) enum dhcp_token token; const char *val; - if (!executable_statement_allocate (result, - "parse_switch_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for new statement."); (*result) -> op = switch_statement; @@ -1579,8 +1559,7 @@ int parse_switch_statement (result, cfile, lose) *lose = 1; skip_to_semi (cfile); gnorf: - executable_statement_dereference (result, - "parse_switch_statement"); + executable_statement_dereference (result, MDL); return 0; } @@ -1612,8 +1591,7 @@ int parse_switch_statement (result, cfile, lose) ? context_data : context_numeric)))) { if (*lose) { skip_to_rbrace (cfile, 1); - executable_statement_dereference - (result, "parse_switch_statement"); + executable_statement_dereference (result, MDL); return 0; } } @@ -1639,8 +1617,7 @@ int parse_case_statement (result, cfile, lose, case_context) enum dhcp_token token; const char *val; - if (!executable_statement_allocate (result, - "parse_switch_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for new statement."); (*result) -> op = case_statement; @@ -1656,8 +1633,7 @@ int parse_case_statement (result, cfile, lose, case_context) pfui: *lose = 1; skip_to_semi (cfile); - executable_statement_dereference (result, - "parse_switch_statement"); + executable_statement_dereference (result, MDL); return 0; } @@ -1688,7 +1664,7 @@ int parse_if_statement (result, cfile, lose) const char *val; int parenp; - if (!executable_statement_allocate (result, "parse_if_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for if statement."); (*result) -> op = if_statement; @@ -1705,8 +1681,7 @@ int parse_if_statement (result, cfile, lose) cfile, lose)) { if (!*lose) parse_warn (cfile, "boolean expression expected."); - executable_statement_dereference (result, - "parse_if_statement"); + executable_statement_dereference (result, MDL); *lose = 1; return 0; } @@ -1718,8 +1693,7 @@ int parse_if_statement (result, cfile, lose) if (token != RPAREN) { parse_warn (cfile, "expecting right paren."); *lose = 1; - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } } @@ -1728,8 +1702,7 @@ int parse_if_statement (result, cfile, lose) parse_warn (cfile, "left brace expected."); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference (result, - "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } if (!parse_executable_statements (&(*result) -> data.ie.true, @@ -1739,8 +1712,7 @@ int parse_if_statement (result, cfile, lose) do { token = next_token (&val, cfile); } while (token != EOF && token != RBRACE); - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } } @@ -1749,8 +1721,7 @@ int parse_if_statement (result, cfile, lose) parse_warn (cfile, "right brace expected."); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } token = peek_token (&val, cfile); @@ -1763,9 +1734,8 @@ int parse_if_statement (result, cfile, lose) cfile, lose)) { if (!*lose) parse_warn (cfile, - "expecting conditional."); - executable_statement_dereference - (result, "parse_if_statement"); + "expecting if statement"); + executable_statement_dereference (result, MDL); *lose = 1; return 0; } @@ -1773,16 +1743,14 @@ int parse_if_statement (result, cfile, lose) parse_warn (cfile, "left brace or if expected."); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } else { token = next_token (&val, cfile); if (!(parse_executable_statements (&(*result) -> data.ie.false, cfile, lose, context_any))) { - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } token = next_token (&val, cfile); @@ -1790,8 +1758,7 @@ int parse_if_statement (result, cfile, lose) parse_warn (cfile, "right brace expected."); skip_to_semi (cfile); *lose = 1; - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); return 0; } } @@ -1802,8 +1769,7 @@ int parse_if_statement (result, cfile, lose) if (!*lose) parse_warn (cfile, "expecting conditional."); - executable_statement_dereference - (result, "parse_if_statement"); + executable_statement_dereference (result, MDL); *lose = 1; return 0; } @@ -1836,7 +1802,7 @@ int parse_boolean_expression (expr, cfile, lose) if (!is_boolean_expression (*expr)) { parse_warn (cfile, "Expecting a boolean expression."); *lose = 1; - expression_dereference (expr, "parse_boolean_expression"); + expression_dereference (expr, MDL); return 0; } return 1; @@ -1972,7 +1938,7 @@ int parse_non_binary (expr, cfile, lose, context) *lose = 1; return 0; } - if (!expression_allocate (expr, "parse_expression: CHECK")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_check; (*expr) -> data.check = col; @@ -1984,7 +1950,7 @@ int parse_non_binary (expr, cfile, lose, context) token = peek_token (&val, cfile); goto not_exists; } - if (!expression_allocate (expr, "parse_expression: NOT")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_not; if (!parse_non_binary (&(*expr) -> data.not, @@ -1994,7 +1960,7 @@ int parse_non_binary (expr, cfile, lose, context) skip_to_semi (cfile); } *lose = 1; - expression_dereference (expr, "parse_expression: NOT"); + expression_dereference (expr, MDL); return 0; } break; @@ -2003,44 +1969,42 @@ int parse_non_binary (expr, cfile, lose, context) if (context == context_dns) goto ns_exists; token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: EXISTS")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_exists; known = 0; (*expr) -> data.option = parse_option_name (cfile, 0, &known); if (!(*expr) -> data.option) { *lose = 1; - expression_dereference (expr, - "parse_expression: EXISTS"); + expression_dereference (expr, MDL); return 0; } break; case STATIC: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: STATIC")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_static; break; case KNOWN: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: KNOWN")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_known; break; case SUBSTRING: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: SUBSTRING")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_substring; token = next_token (&val, cfile); if (token != LPAREN) { nolparen: - expression_dereference (expr, - "parse_expression: nolparen"); + expression_dereference (expr, MDL); parse_warn (cfile, "left parenthesis expected."); *lose = 1; return 0; @@ -2049,8 +2013,7 @@ int parse_non_binary (expr, cfile, lose, context) if (!parse_data_expression (&(*expr) -> data.substring.expr, cfile, lose)) { nodata: - expression_dereference (expr, - "parse_expression: nodata"); + expression_dereference (expr, MDL); parse_warn (cfile, "expecting data expression."); skip_to_semi (cfile); *lose = 1; @@ -2060,8 +2023,7 @@ int parse_non_binary (expr, cfile, lose, context) token = next_token (&val, cfile); if (token != COMMA) { nocomma: - expression_dereference (expr, - "parse_expression: nocomma1"); + expression_dereference (expr, MDL); parse_warn (cfile, "comma expected."); *lose = 1; @@ -2077,8 +2039,7 @@ int parse_non_binary (expr, cfile, lose, context) skip_to_semi (cfile); *lose = 1; } - expression_dereference (expr, - "parse_expression: nonum"); + expression_dereference (expr, MDL); return 0; } @@ -2095,15 +2056,14 @@ int parse_non_binary (expr, cfile, lose, context) norparen: parse_warn (cfile, "right parenthesis expected."); *lose = 1; - expression_dereference (expr, - "parse_expression: norparen"); + expression_dereference (expr, MDL); return 0; } break; case SUFFIX: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: SUFFIX")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_suffix; @@ -2130,7 +2090,7 @@ int parse_non_binary (expr, cfile, lose, context) case CONCAT: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: CONCAT")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_concat; @@ -2155,16 +2115,13 @@ int parse_non_binary (expr, cfile, lose, context) if (token == COMMA) { nexp = (struct expression *)0; - if (!expression_allocate (&nexp, - "parse_expression: CONCAT2")) + if (!expression_allocate (&nexp, MDL)) log_fatal ("can't allocate at CONCAT2"); nexp -> op = expr_concat; - expression_reference (&nexp -> data.concat [0], *expr, - "parse_expression: CONCAT2"); - expression_dereference (expr, - "parse_expression: CONCAT2"); - expression_reference (expr, nexp, - "parse_expression: CONCAT2"); + expression_reference (&nexp -> data.concat [0], + *expr, MDL); + expression_dereference (expr, MDL); + expression_reference (expr, nexp, MDL); goto concat_another; } @@ -2174,7 +2131,7 @@ int parse_non_binary (expr, cfile, lose, context) case BINARY_TO_ASCII: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: B2A")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_binary_to_ascii; @@ -2217,7 +2174,7 @@ int parse_non_binary (expr, cfile, lose, context) case REVERSE: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: REVERSE")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_reverse; @@ -2246,8 +2203,7 @@ int parse_non_binary (expr, cfile, lose, context) /* pick (a, b, c) actually produces an internal representation that looks like pick (a, pick (b, pick (c, nil))). */ token = next_token (&val, cfile); - if (!(expression_allocate - (expr, "parse_expression: PICK_FIRST_VALUE"))) + if (!(expression_allocate (expr, MDL))) log_fatal ("can't allocate expression"); token = next_token (&val, cfile); @@ -2266,7 +2222,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token == COMMA) { if (!(expression_allocate (&nexp -> data.pick_first_value.cdr, - "parse_expression: PICK_FIRST_VALUE"))) + MDL))) log_fatal ("can't allocate expr"); nexp = nexp -> data.pick_first_value.cdr; } @@ -2321,8 +2277,7 @@ int parse_non_binary (expr, cfile, lose, context) goto badnsupdate; } - if (!expression_allocate (expr, - "parse_expression: DNS_UPDATE")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); #if 0 (*expr) -> op = expr_funcall; @@ -2385,8 +2340,7 @@ int parse_non_binary (expr, cfile, lose, context) "Please rebuild dhcpd with --with-nsupdate."); #endif token = next_token (&val, cfile); - if (!expression_allocate (expr, - "parse_expression: NS_UPDATE")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); token = next_token (&val, cfile); @@ -2405,8 +2359,7 @@ int parse_non_binary (expr, cfile, lose, context) (cfile, "expecting dns expression."); badnstrans: - expression_dereference (expr, - "parse_expression"); + expression_dereference (expr, MDL); *lose = 1; return 0; } @@ -2416,7 +2369,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token == COMMA) { if (!(expression_allocate (&nexp -> data.dns_transaction.cdr, - "parse_expression"))) + MDL))) log_fatal ("can't allocate expression"); nexp = nexp -> data.dns_transaction.cdr; @@ -2452,7 +2405,7 @@ int parse_non_binary (expr, cfile, lose, context) parse_warn (cfile, "Please rebuild dhcpd with --with-nsupdate."); #endif - if (!expression_allocate (expr, "parse_expression")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = opcode; @@ -2464,7 +2417,7 @@ int parse_non_binary (expr, cfile, lose, context) if (!is_identifier (token) && token != NUMBER) { parse_warn (cfile, "expecting identifier or number."); badnsop: - expression_dereference (expr, "parse_expression"); + expression_dereference (expr, MDL); skip_to_semi (cfile); *lose = 1; return 0; @@ -2547,7 +2500,7 @@ int parse_non_binary (expr, cfile, lose, context) case OPTION: case CONFIG_OPTION: - if (!expression_allocate (expr, "parse_expression: OPTION")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = (token == OPTION ? expr_option @@ -2557,62 +2510,56 @@ int parse_non_binary (expr, cfile, lose, context) (*expr) -> data.option = parse_option_name (cfile, 0, &known); if (!(*expr) -> data.option) { *lose = 1; - expression_dereference (expr, - "parse_expression: OPTION"); + expression_dereference (expr, MDL); return 0; } break; case HARDWARE: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: HARDWARE")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_hardware; break; case LEASED_ADDRESS: token = next_token (&val, cfile); - if (!expression_allocate (expr, - "parse_expression: LEASED_ADDRESS")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_leased_address; break; case FILENAME: token = next_token (&val, cfile); - if (!expression_allocate (expr, - "parse_expression: FILENAME")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_filename; break; case SERVER_NAME: token = next_token (&val, cfile); - if (!expression_allocate (expr, - "parse_expression: SERVER_NAME")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_sname; break; case LEASE_TIME: token = next_token (&val, cfile); - if (!expression_allocate (expr, - "parse_expression: LEASED_LEASE_TIME")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_lease_time; break; case TOKEN_NULL: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_null; break; case HOST_DECL_NAME: token = next_token (&val, cfile); - if (!expression_allocate (expr, - "parse_expression: HOST_DECL_NAME")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_host_decl_name; break; @@ -2644,7 +2591,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != RPAREN) goto norparen; - if (!expression_allocate (expr, "parse_expression")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_variable_reference; (*expr) -> data.variable = @@ -2656,7 +2603,7 @@ int parse_non_binary (expr, cfile, lose, context) case PACKET: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: PACKET")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_packet; @@ -2697,8 +2644,7 @@ int parse_non_binary (expr, cfile, lose, context) return 0; } - if (!expression_allocate (expr, - "parse_expression: EXTRACT_INT")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); if (!parse_data_expression (&(*expr) -> data.extract_int, @@ -2706,8 +2652,7 @@ int parse_non_binary (expr, cfile, lose, context) parse_warn (cfile, "expecting data expression."); skip_to_semi (cfile); *lose = 1; - expression_dereference - (expr, "parse_expression: EXTRACT_INT"); + expression_dereference (expr, MDL); return 0; } @@ -2715,8 +2660,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != COMMA) { parse_warn (cfile, "comma expected."); *lose = 1; - expression_dereference - (expr, "parse_expression: EXTRACT_INT"); + expression_dereference (expr, MDL); return 0; } @@ -2724,8 +2668,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != NUMBER) { parse_warn (cfile, "number expected."); *lose = 1; - expression_dereference - (expr, "parse_expression: EXTRACT_INT"); + expression_dereference (expr, MDL); return 0; } switch (atoi (val)) { @@ -2746,8 +2689,7 @@ int parse_non_binary (expr, cfile, lose, context) "unsupported integer size %d", atoi (val)); *lose = 1; skip_to_semi (cfile); - expression_dereference - (expr, "parse_expression: EXTRACT_INT"); + expression_dereference (expr, MDL); return 0; } @@ -2755,8 +2697,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != RPAREN) { parse_warn (cfile, "right parenthesis expected."); *lose = 1; - expression_dereference - (expr, "parse_expression: EXTRACT_INT"); + expression_dereference (expr, MDL); return 0; } break; @@ -2770,8 +2711,7 @@ int parse_non_binary (expr, cfile, lose, context) return 0; } - if (!expression_allocate (expr, - "parse_expression: ENCODE_INT")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); if (!parse_numeric_expression (&(*expr) -> data.encode_int, @@ -2779,8 +2719,7 @@ int parse_non_binary (expr, cfile, lose, context) parse_warn (cfile, "expecting numeric expression."); skip_to_semi (cfile); *lose = 1; - expression_dereference - (expr, "parse_expression: ENCODE_INT"); + expression_dereference (expr, MDL); return 0; } @@ -2788,8 +2727,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != COMMA) { parse_warn (cfile, "comma expected."); *lose = 1; - expression_dereference - (expr, "parse_expression: ENCODE_INT"); + expression_dereference (expr, MDL); return 0; } @@ -2797,8 +2735,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != NUMBER) { parse_warn (cfile, "number expected."); *lose = 1; - expression_dereference - (expr, "parse_expression: ENCODE_INT"); + expression_dereference (expr, MDL); return 0; } switch (atoi (val)) { @@ -2819,8 +2756,7 @@ int parse_non_binary (expr, cfile, lose, context) "unsupported integer size %d", atoi (val)); *lose = 1; skip_to_semi (cfile); - expression_dereference - (expr, "parse_expression: ENCODE_INT"); + expression_dereference (expr, MDL); return 0; } @@ -2828,8 +2764,7 @@ int parse_non_binary (expr, cfile, lose, context) if (token != RPAREN) { parse_warn (cfile, "right parenthesis expected."); *lose = 1; - expression_dereference - (expr, "parse_expression: ENCODE_INT"); + expression_dereference (expr, MDL); return 0; } break; @@ -2840,8 +2775,7 @@ int parse_non_binary (expr, cfile, lose, context) if (context == context_numeric || context == context_data_or_numeric) { next_token (&val, cfile); /* Eat the number. */ - if (!expression_allocate (expr, - "parse_expression: NUMBER")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_const_int; (*expr) -> data.const_int = atoi (val); @@ -2849,14 +2783,12 @@ int parse_non_binary (expr, cfile, lose, context) } case NUMBER_OR_NAME: - if (!expression_allocate (expr, - "parse_expression: NUMBER_OR_NAME")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_const_data; if (!parse_cshl (&(*expr) -> data.const_data, cfile)) { - expression_dereference (expr, - "parse_expression: cshl"); + expression_dereference (expr, MDL); return 0; } break; @@ -2865,7 +2797,7 @@ int parse_non_binary (expr, cfile, lose, context) known = FORMERR; ns_const: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_const_int; (*expr) -> data.const_int = known; @@ -2925,7 +2857,7 @@ int parse_non_binary (expr, cfile, lose, context) return 0; } - if (!expression_allocate (expr, "parse_expression")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_variable_exists; (*expr) -> data.variable = dmalloc (strlen (val) + 1, MDL); @@ -2943,7 +2875,7 @@ int parse_non_binary (expr, cfile, lose, context) return 0; token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression")) + if (!expression_allocate (expr, MDL)) log_fatal ("can't allocate expression"); (*expr) -> op = expr_variable_reference; (*expr) -> data.variable = dmalloc (strlen (val) + 1, MDL); @@ -2990,7 +2922,7 @@ int parse_expression (expr, cfile, lose, context, plhs, binop) *lose = 1; skip_to_semi (cfile); } - expression_dereference (&lhs, "parse_expression"); + expression_dereference (&lhs, MDL); } return 0; } @@ -3009,8 +2941,7 @@ int parse_expression (expr, cfile, lose, context, plhs, binop) *lose = 1; skip_to_semi (cfile); if (lhs) - expression_dereference (&lhs, - "parse_expression"); + expression_dereference (&lhs, MDL); return 0; } next_op = expr_not_equal; @@ -3051,8 +2982,7 @@ int parse_expression (expr, cfile, lose, context, plhs, binop) this subexpression, so combine it with the preceding binary operator and return the result. */ if (next_op == expr_none) { - if (!expression_allocate (expr, - "parse_expression: COMBINE")) + if (!expression_allocate (expr, MDL)) log_fatal ("Can't allocate expression!"); (*expr) -> op = binop; @@ -3090,7 +3020,7 @@ int parse_expression (expr, cfile, lose, context, plhs, binop) /* Now combine the LHS and the RHS using binop. */ tmp = (struct expression *)0; - if (!expression_allocate (&tmp, "parse_expression: COMBINE2")) + if (!expression_allocate (&tmp, MDL)) log_fatal ("No memory for equal precedence combination."); /* Store the LHS and RHS. */ @@ -3180,13 +3110,11 @@ int parse_option_statement (result, cfile, lookups, option, op) if (!parse_option_token (&expr, cfile, fmt, tmp, uniform, lookups)) { if (tmp) - expression_dereference - (&tmp, "parse_option_statement"); + expression_dereference (&tmp, MDL); return 0; } if (tmp) - expression_dereference - (&tmp, "parse_option_statement"); + expression_dereference (&tmp, MDL); } if (*fmt == 'A') { token = peek_token (&val, cfile); @@ -3201,7 +3129,7 @@ int parse_option_statement (result, cfile, lookups, option, op) done: if (!parse_semi (cfile)) return 0; - if (!executable_statement_allocate (result, "parse_option_statement")) + if (!executable_statement_allocate (result, MDL)) log_fatal ("no memory for option statement."); (*result) -> op = op; if (expr && !option_cache (&(*result) -> data.option, @@ -3243,11 +3171,10 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups) case 'X': token = peek_token (&val, cfile); if (token == NUMBER_OR_NAME || token == NUMBER) { - if (!expression_allocate (&t, "parse_option_token")) + if (!expression_allocate (&t, MDL)) return 0; if (!parse_cshl (&t -> data.const_data, cfile)) { - expression_dereference - (&t, "parse_option_token: X"); + expression_dereference (&t, MDL); return 0; } t -> op = expr_const_data; @@ -3368,7 +3295,7 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups) if (expr) { if (!make_concat (rv, expr, t)) return 0; - expression_dereference (&t, "parse_option_token"); + expression_dereference (&t, MDL); } else *rv = t; return 1; @@ -3398,7 +3325,7 @@ int parse_auth_key (key_id, cfile) print_hex_1 (key_id -> len, key_id -> data, key_id -> len)); - data_string_forget (key_id, "parse_auth_key"); + data_string_forget (key_id, MDL); } else { if (!parse_cshl (&key_data, cfile)) return 0; @@ -3409,7 +3336,7 @@ int parse_auth_key (key_id, cfile) key_id -> len)); old_key = key; } - new_key = new_auth_key (key_data.len, "parse_auth_key"); + new_key = new_auth_key (key_data.len, MDL); if (!new_key) log_fatal ("No memory for key %s", print_hex_1 (key_id -> len, @@ -3418,9 +3345,70 @@ int parse_auth_key (key_id, cfile) new_key -> length = key_data.len; memcpy (new_key -> data, key_data.data, key_data.len); enter_auth_key (key_id, new_key); - data_string_forget (&key_data, "parse_auth_key"); + data_string_forget (&key_data, MDL); } parse_semi (cfile); return key_id -> len ? 1 : 0; } + +int parse_warn (ANSI_DECL (struct parse *)cfile, + ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) + KandR (struct parse *cfile;) + KandR (char *fmt;) + va_dcl +{ + va_list list; + static char spaces [] = " "; + char lexbuf [256]; + char mbuf [1024]; + char fbuf [1024]; + unsigned i, lix; + + do_percentm (mbuf, fmt); +#ifndef NO_SNPRINTF + snprintf (fbuf, sizeof fbuf, "%s line %d: %s", + cfile -> tlname, cfile -> lexline, mbuf); +#else + sprintf (fbuf, "%s line %d: %s", + cfile -> tlname, cfile -> lexline, mbuf); +#endif + + VA_start (list, fmt); + vsnprintf (mbuf, sizeof mbuf, fbuf, list); + va_end (list); + + lix = 0; + for (i = 0; + cfile -> token_line [i] && i < (cfile -> lexchar - 1); i++) { + if (lix < (sizeof lexbuf) - 1) + lexbuf [lix++] = ' '; + if (cfile -> token_line [i] == '\t') { + for (lix; + lix < (sizeof lexbuf) - 1 && (lix & 7); lix++) + lexbuf [lix] = ' '; + } + } + lexbuf [lix] = 0; + +#ifndef DEBUG + syslog (log_priority | LOG_ERR, mbuf); + syslog (log_priority | LOG_ERR, cfile -> token_line); + if (cfile -> lexchar < 81) + syslog (log_priority | LOG_ERR, "%s^", lexbuf); +#endif + + if (log_perror) { + write (2, mbuf, strlen (mbuf)); + write (2, "\n", 1); + write (2, cfile -> token_line, strlen (cfile -> token_line)); + write (2, "\n", 1); + if (cfile -> lexchar < 81) + write (2, lexbuf, lix); + write (2, "^\n", 2); + } + + cfile -> warnings_occurred = 1; + + return 0; +} diff --git a/common/print.c b/common/print.c index 533ffe8da..c0ba9cc8c 100644 --- a/common/print.c +++ b/common/print.c @@ -3,7 +3,7 @@ Turn data structures into printable text. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: print.c,v 1.32 2000/01/25 01:14:26 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: print.c,v 1.33 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -367,8 +367,8 @@ static unsigned print_subexpression (expr, buf, len) break; case expr_pick_first_value: - if (len > 11) { - rv = 9; + if (len > 8) { + rv = 6; strcpy (buf, "(pick1st "); rv += print_subexpression (expr -> data.pick_first_value.car, @@ -436,7 +436,7 @@ static unsigned print_subexpression (expr, buf, len) case expr_config_option: s = "cfg-option"; - break; + goto dooption; case expr_option: s = "option"; @@ -629,6 +629,14 @@ static unsigned print_subexpression (expr, buf, len) s = "static"; goto astring; + case expr_filename: + s = "filename"; + goto astring; + + case expr_sname: + s = "server-name"; + goto astring; + case expr_reverse: if (len > 11) { rv = 13; diff --git a/common/resolv.c b/common/resolv.c index 9bc696b2b..d5a051717 100644 --- a/common/resolv.c +++ b/common/resolv.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: resolv.c,v 1.11 1999/10/21 12:32:16 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: resolv.c,v 1.12 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -74,8 +74,7 @@ void read_resolv_conf (parse_time) break; } if (!nd) { - nd = new_domain_search_list - ("read_resolv_conf"); + nd = new_domain_search_list (MDL); if (!nd) log_fatal ("No memory for %s", dn); @@ -108,7 +107,7 @@ void read_resolv_conf (parse_time) break; } if (!ns) { - ns = new_name_server ("read_resolv_conf"); + ns = new_name_server (MDL); if (!ns) log_fatal ("No memory for nameserver %s", piaddr (iaddr)); @@ -157,7 +156,7 @@ void read_resolv_conf (parse_time) dl -> next = dp -> next; else domains = dp -> next; - free_domain_search_list (dp, "pick_name_server"); + free_domain_search_list (dp, MDL); } else dl = dp; } diff --git a/common/tables.c b/common/tables.c index 59ff276f8..e70bf0875 100644 --- a/common/tables.c +++ b/common/tables.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: tables.c,v 1.34 2000/01/08 01:38:04 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: tables.c,v 1.35 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -835,8 +835,7 @@ void initialize_common_option_spaces() universe_max = 10; universes = ((struct universe **) - dmalloc (universe_max * sizeof (struct universe *), - "initialize_universes")); + dmalloc (universe_max * sizeof (struct universe *), MDL)); if (!universes) log_fatal ("Can't allocate option space table."); memset (universes, 0, universe_max * sizeof (struct universe *)); diff --git a/common/tree.c b/common/tree.c index de7945c8b..6945c0794 100644 --- a/common/tree.c +++ b/common/tree.c @@ -22,10 +22,13 @@ #ifndef lint static char copyright[] = -"$Id: tree.c,v 1.68 2000/01/25 01:16:14 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: tree.c,v 1.69 2000/01/26 14:55:35 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" +#include + +struct binding_scope global_scope; static int do_host_lookup PROTO ((struct data_string *, struct dns_host_entry *)); @@ -42,13 +45,14 @@ pair cons (car, cdr) return foo; } -int make_const_option_cache (oc, buffer, data, len, option, name) +int make_const_option_cache (oc, buffer, data, len, option, file, line) struct option_cache **oc; struct buffer **buffer; u_int8_t *data; unsigned len; struct option *option; - const char *name; + const char *file; + int line; { struct buffer *bp; @@ -57,15 +61,16 @@ int make_const_option_cache (oc, buffer, data, len, option, name) *buffer = 0; } else { bp = (struct buffer *)0; - if (!buffer_allocate (&bp, len, name)) { - log_error ("%s: can't allocate buffer.", name); + if (!buffer_allocate (&bp, len, file, line)) { + log_error ("%s(%d): can't allocate buffer.", + file, line); return 0; } } - if (!option_cache_allocate (oc, name)) { - log_error ("%s: can't allocate option cache.", name); - buffer_dereference (&bp, name); + if (!option_cache_allocate (oc, file, line)) { + log_error ("%s(%d): can't allocate option cache.", file, line); + buffer_dereference (&bp, file, line); return 0; } @@ -397,6 +402,7 @@ static int do_host_lookup (result, dns) return 1; } +#if defined (NSUPDATE) int evaluate_dns_expression (result, packet, lease, in_options, cfg_options, scope, expr) ns_updrec **result; @@ -611,6 +617,7 @@ int evaluate_dns_expression (result, packet, lease, in_options, expr -> op); return 0; } +#endif /* defined (NSUPDATE) */ int evaluate_boolean_expression (result, packet, lease, in_options, cfg_options, scope, expr) @@ -802,7 +809,7 @@ int evaluate_boolean_expression (result, packet, lease, in_options, *result = 0; #if defined (DEBUG_EXPRESSIONS) log_debug ("boolean: %s? = %s", expr -> variable, - s0 ? "true" : "false"; + s0 ? "true" : "false"); #endif return 1; @@ -828,6 +835,8 @@ int evaluate_boolean_expression (result, packet, lease, in_options, case expr_leased_address: case expr_null: case expr_variable_reference: + case expr_filename: + case expr_sname: log_error ("Data opcode in evaluate_boolean_expression: %d", expr -> op); return 0; @@ -1630,10 +1639,12 @@ int evaluate_numeric_expression (result, packet, lease, { struct data_string data; int status; +#if defined (NSUPDATE) ns_updrec *nut; static struct __res_state res; ns_updque uq; static int inited; +#endif struct expression *cur, *next; switch (expr -> op) { @@ -1868,8 +1879,8 @@ int evaluate_boolean_option_cache (ignorep, packet, lease, in_options, return 0; memset (&ds, 0, sizeof ds); - if (!evaluate_option_cache (&ds, packet, lease, - in_options, cfg_options, scope, oc)) + if (!evaluate_option_cache (&ds, packet, lease, in_options, + cfg_options, scope, oc, file, line)) return 0; if (ds.len) { @@ -1889,7 +1900,7 @@ int evaluate_boolean_option_cache (ignorep, packet, lease, in_options, or FALSE if it failed. */ int evaluate_boolean_expression_result (ignorep, packet, lease, in_options, - cfg_options, scope, expr, file, line) + cfg_options, scope, expr) int *ignorep; struct packet *packet; struct lease *lease; @@ -1897,8 +1908,6 @@ int evaluate_boolean_expression_result (ignorep, packet, lease, in_options, struct option_state *cfg_options; struct binding_scope *scope; struct expression *expr; - const char *file; - int line; { int result; @@ -1908,7 +1917,7 @@ int evaluate_boolean_expression_result (ignorep, packet, lease, in_options, if (!evaluate_boolean_expression (&result, packet, lease, in_options, cfg_options, - scope, expr, file, line)) + scope, expr)) return 0; if (result == 2) { @@ -1922,9 +1931,10 @@ int evaluate_boolean_expression_result (ignorep, packet, lease, in_options, /* Dereference an expression node, and if the reference count goes to zero, dereference any data it refers to, and then free it. */ -void expression_dereference (eptr, name) +void expression_dereference (eptr, file, line) struct expression **eptr; - const char *name; + const char *file; + int line; { struct expression *expr = *eptr; @@ -1938,7 +1948,7 @@ void expression_dereference (eptr, name) if (expr -> refcnt > 0) return; if (expr -> refcnt < 0) { - log_error ("expression_dereference: negative refcnt!"); + log_error ("%s(%d): negative refcnt!", file, line); #if defined (DEBUG_RC_HISTORY) dump_rc_history (); #endif @@ -1958,44 +1968,46 @@ void expression_dereference (eptr, name) case expr_and: case expr_or: if (expr -> data.equal [0]) - expression_dereference (&expr -> data.equal [0], name); + expression_dereference (&expr -> data.equal [0], + file, line); if (expr -> data.equal [1]) - expression_dereference (&expr -> data.equal [1], name); + expression_dereference (&expr -> data.equal [1], + file, line); break; case expr_substring: if (expr -> data.substring.expr) expression_dereference (&expr -> data.substring.expr, - name); + file, line); if (expr -> data.substring.offset) expression_dereference (&expr -> data.substring.offset, - name); + file, line); if (expr -> data.substring.len) expression_dereference (&expr -> data.substring.len, - name); + file, line); break; case expr_suffix: if (expr -> data.suffix.expr) expression_dereference (&expr -> data.suffix.expr, - name); + file, line); if (expr -> data.suffix.len) expression_dereference (&expr -> data.suffix.len, - name); + file, line); break; case expr_not: if (expr -> data.not) - expression_dereference (&expr -> data.not, name); + expression_dereference (&expr -> data.not, file, line); break; case expr_packet: if (expr -> data.packet.offset) expression_dereference (&expr -> data.packet.offset, - name); + file, line); if (expr -> data.packet.len) expression_dereference (&expr -> data.packet.len, - name); + file, line); break; case expr_extract_int8: @@ -2003,7 +2015,7 @@ void expression_dereference (eptr, name) case expr_extract_int32: if (expr -> data.extract_int) expression_dereference (&expr -> data.extract_int, - name); + file, line); break; case expr_encode_int8: @@ -2011,70 +2023,72 @@ void expression_dereference (eptr, name) case expr_encode_int32: if (expr -> data.encode_int) expression_dereference (&expr -> data.encode_int, - name); + file, line); break; case expr_encapsulate: case expr_const_data: - data_string_forget (&expr -> data.const_data, name); + data_string_forget (&expr -> data.const_data, file, line); break; case expr_host_lookup: if (expr -> data.host_lookup) dns_host_entry_dereference (&expr -> data.host_lookup, - name); + file, line); break; case expr_binary_to_ascii: if (expr -> data.b2a.base) - expression_dereference (&expr -> data.b2a.base, name); + expression_dereference (&expr -> data.b2a.base, + file, line); if (expr -> data.b2a.width) - expression_dereference (&expr -> data.b2a.width, name); + expression_dereference (&expr -> data.b2a.width, + file, line); if (expr -> data.b2a.seperator) expression_dereference (&expr -> data.b2a.seperator, - name); + file, line); if (expr -> data.b2a.buffer) expression_dereference (&expr -> data.b2a.buffer, - name); + file, line); break; case expr_pick_first_value: if (expr -> data.pick_first_value.car) - expression_dereference - (&expr -> data.pick_first_value.car, name); + expression_dereference (&expr -> data.pick_first_value.car, + file, line); if (expr -> data.pick_first_value.cdr) - expression_dereference - (&expr -> data.pick_first_value.cdr, name); + expression_dereference (&expr -> data.pick_first_value.cdr, + file, line); break; case expr_reverse: if (expr -> data.reverse.width) expression_dereference (&expr -> data.reverse.width, - name); + file, line); if (expr -> data.reverse.buffer) expression_dereference - (&expr -> data.reverse.buffer, name); + (&expr -> data.reverse.buffer, file, line); break; case expr_dns_transaction: if (expr -> data.dns_transaction.car) - expression_dereference - (&expr -> data.dns_transaction.car, name); + expression_dereference (&expr -> data.dns_transaction.car, + file, line); if (expr -> data.dns_transaction.cdr) - expression_dereference - (&expr -> data.dns_transaction.cdr, name); + expression_dereference (&expr -> data.dns_transaction.cdr, + file, line); break; case expr_ns_add: if (expr -> data.ns_add.rrname) expression_dereference (&expr -> data.ns_add.rrname, - name); + file, line); if (expr -> data.ns_add.rrdata) expression_dereference (&expr -> data.ns_add.rrdata, - name); + file, line); if (expr -> data.ns_add.ttl) expression_dereference (&expr -> data.ns_add.ttl, - name); + file, line); break; case expr_ns_delete: @@ -2082,16 +2096,16 @@ void expression_dereference (eptr, name) case expr_ns_not_exists: if (expr -> data.ns_delete.rrname) expression_dereference (&expr -> data.ns_delete.rrname, - name); + file, line); if (expr -> data.ns_delete.rrdata) expression_dereference (&expr -> data.ns_delete.rrdata, - name); + file, line); break; case expr_variable_reference: case expr_variable_exists: if (expr -> data.variable) - dfree (expr -> data.variable, name); + dfree (expr -> data.variable, file, line); break; /* No subexpressions. */ @@ -2794,31 +2808,31 @@ struct binding *find_binding (struct binding_scope *scope, const char *name) return (struct binding *)0; } -int free_bindings (struct binding_scope *scope, const char *name) +int free_bindings (struct binding_scope *scope, const char *file, int line) { struct binding *bp, *next; for (bp = scope -> bindings; bp; bp = next) { next = bp -> next; if (bp -> name) - dfree (bp -> name, name); + dfree (bp -> name, file, line); if (bp -> value.data) - data_string_forget (&bp -> value, name); - dfree (bp, name); + data_string_forget (&bp -> value, file, line); + dfree (bp, file, line); } scope -> bindings = (struct binding *)0; return 1; } -int binding_scope_dereference (ptr, name) +int binding_scope_dereference (ptr, file, line) struct binding_scope **ptr; - const char *name; + const char *file; + int line; { struct binding_scope *bp; if (!ptr || !*ptr) { - log_error ("Null pointer in binding_scope_dereference: %s", - name); + log_error ("%s(%d): null pointer", file, line); #if defined (POINTER_DEBUG) abort (); #else @@ -2827,8 +2841,8 @@ int binding_scope_dereference (ptr, name) } if ((*ptr) -> bindings) - free_bindings (*ptr, name); - dfree ((*ptr), name); + free_bindings (*ptr, file, line); + dfree ((*ptr), file, line); *ptr = (struct binding_scope *)0; return 1; } diff --git a/dhcpctl/callback.c b/dhcpctl/callback.c index ca6628488..4834d9614 100644 --- a/dhcpctl/callback.c +++ b/dhcpctl/callback.c @@ -3,7 +3,7 @@ The dhcpctl callback object. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -44,21 +44,20 @@ dhcpctl_status dhcpctl_set_callback (dhcpctl_handle h, void *data, omapi_object_t *inner; isc_result_t status; - callback = malloc (sizeof *callback); + callback = dmalloc (sizeof *callback, MDL); if (!callback) return ISC_R_NOMEMORY; /* Tie the callback object to the innermost object in the chain. */ for (inner = h; inner -> inner; inner = inner -> inner) ; - omapi_object_reference (&inner -> inner, (omapi_object_t *)callback, - "dhcpctl_set_callback"); - omapi_object_reference ((omapi_object_t **)&callback -> outer, inner, - "dhcpctl_set_callback"); + omapi_object_reference (&inner -> inner, + (omapi_object_t *)callback, MDL); + omapi_object_reference ((omapi_object_t **)&callback -> outer, + inner, MDL); /* Save the actual handle pointer we were passed for the callback. */ - omapi_object_reference (&callback -> object, h, - "dhcpctl_set_callback"); + omapi_object_reference (&callback -> object, h, MDL); callback -> data = data; callback -> callback = func; @@ -126,7 +125,8 @@ isc_result_t dhcpctl_callback_signal_handler (omapi_object_t *o, return ISC_R_SUCCESS; } -isc_result_t dhcpctl_callback_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcpctl_callback_destroy (omapi_object_t *h, + const char *file, int line) { dhcpctl_callback_object_t *p; if (h -> type != dhcpctl_callback_type) @@ -134,7 +134,7 @@ isc_result_t dhcpctl_callback_destroy (omapi_object_t *h, const char *name) p = (dhcpctl_callback_object_t *)h; if (p -> handle) omapi_object_dereference ((omapi_object_t **)&p -> handle, - name); + file, line); return ISC_R_SUCCESS; } diff --git a/dhcpctl/dhcpctl.c b/dhcpctl/dhcpctl.c index c9ae40048..4138c94bc 100644 --- a/dhcpctl/dhcpctl.c +++ b/dhcpctl/dhcpctl.c @@ -3,7 +3,7 @@ Subroutines providing general support for objects. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -67,7 +67,7 @@ dhcpctl_status dhcpctl_connect (dhcpctl_handle *connection, { isc_result_t status; - status = omapi_generic_new (connection, "dhcpctl_connect"); + status = omapi_generic_new (connection, MDL); if (status != ISC_R_SUCCESS) { return status; } @@ -75,13 +75,13 @@ dhcpctl_status dhcpctl_connect (dhcpctl_handle *connection, status = omapi_protocol_connect (*connection, server_name, (unsigned)port, authinfo); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (connection, "dhcpctl_connect"); + omapi_object_dereference (connection, MDL); return status; } status = omapi_wait_for_completion (*connection, 0); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (connection, "dhcpctl_connect"); + omapi_object_dereference (connection, MDL); return status; } @@ -156,15 +156,13 @@ dhcpctl_status dhcpctl_get_value (dhcpctl_data_string *result, break; default: - omapi_typed_data_dereference (&tv -> value, - "dhcpctl_get_value"); + omapi_typed_data_dereference (&tv -> value, MDL); return ISC_R_UNEXPECTED; } - status = omapi_data_string_new (result, len, "dhcpctl_get_value"); + status = omapi_data_string_new (result, len, MDL); if (status != ISC_R_SUCCESS) { - omapi_typed_data_dereference (&tv -> value, - "dhcpctl_get_value"); + omapi_typed_data_dereference (&tv -> value, MDL); return status; } @@ -187,7 +185,7 @@ dhcpctl_status dhcpctl_get_value (dhcpctl_data_string *result, break; } - omapi_value_dereference (&tv, "dhcpctl_get_value"); + omapi_value_dereference (&tv, MDL); return ISC_R_SUCCESS; } @@ -207,7 +205,7 @@ dhcpctl_status dhcpctl_get_boolean (int *result, if (status != ISC_R_SUCCESS) return status; if (data -> len != sizeof rv) { - omapi_data_string_dereference (&data, "dhcpctl_get_boolean"); + omapi_data_string_dereference (&data, MDL); return ISC_R_UNEXPECTED; } memcpy (&rv, data -> value, sizeof rv); @@ -230,23 +228,22 @@ dhcpctl_status dhcpctl_set_value (dhcpctl_handle h, dhcpctl_data_string value, int len; int ip; - status = omapi_data_string_new (&name, strlen (value_name), - "dhcpctl_set_value"); + status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (name -> value, value_name, strlen (value_name)); - status = omapi_typed_data_new (&tv, omapi_datatype_data, + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_data, value -> len); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&name, "dhcpctl_set_value"); + omapi_data_string_dereference (&name, MDL); return status; } memcpy (tv -> u.buffer.value, value -> value, value -> len); status = omapi_set_value (h, (omapi_object_t *)0, name, tv); - omapi_data_string_dereference (&name, "dhcpctl_set_value"); - omapi_typed_data_dereference (&tv, "dhcpctl_set_value"); + omapi_data_string_dereference (&name, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -266,22 +263,20 @@ dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle h, const char *value, int len; int ip; - status = omapi_data_string_new (&name, strlen (value_name), - "dhcpctl_set_string_value"); + status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (name -> value, value_name, strlen (value_name)); - status = omapi_typed_data_new (&tv, omapi_datatype_string, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_string, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&name, - "dhcpctl_set_string_value"); + omapi_data_string_dereference (&name, MDL); return status; } status = omapi_set_value (h, (omapi_object_t *)0, name, tv); - omapi_data_string_dereference (&name, "dhcpctl_set_string_value"); - omapi_typed_data_dereference (&tv, "dhcpctl_set_string_value"); + omapi_data_string_dereference (&name, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -299,22 +294,20 @@ dhcpctl_status dhcpctl_set_boolean_value (dhcpctl_handle h, int value, int len; int ip; - status = omapi_data_string_new (&name, strlen (value_name), - "dhcpctl_set_boolean_value"); + status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (name -> value, value_name, strlen (value_name)); - status = omapi_typed_data_new (&tv, omapi_datatype_int, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_int, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&name, - "dhcpctl_set_boolean_value"); + omapi_data_string_dereference (&name, MDL); return status; } status = omapi_set_value (h, (omapi_object_t *)0, name, tv); - omapi_data_string_dereference (&name, "dhcpctl_set_boolean_value"); - omapi_typed_data_dereference (&tv, "dhcpctl_set_boolean_value"); + omapi_data_string_dereference (&name, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -332,22 +325,20 @@ dhcpctl_status dhcpctl_set_int_value (dhcpctl_handle h, int value, int len; int ip; - status = omapi_data_string_new (&name, strlen (value_name), - "dhcpctl_set_boolean_value"); + status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (name -> value, value_name, strlen (value_name)); - status = omapi_typed_data_new (&tv, omapi_datatype_int, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_int, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&name, - "dhcpctl_set_boolean_value"); + omapi_data_string_dereference (&name, MDL); return status; } status = omapi_set_value (h, (omapi_object_t *)0, name, tv); - omapi_data_string_dereference (&name, "dhcpctl_set_boolean_value"); - omapi_typed_data_dereference (&tv, "dhcpctl_set_boolean_value"); + omapi_data_string_dereference (&name, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -363,21 +354,21 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection, isc_result_t status; omapi_object_t *message = (omapi_object_t *)0; - status = omapi_message_new (&message, "dhcpctl_object_update"); + status = omapi_message_new (&message, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_update"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "op", OMAPI_OP_UPDATE); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_update"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_object_value (message, (omapi_object_t *)0, "object", h); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_update"); + omapi_object_dereference (&message, MDL); return status; } @@ -385,7 +376,7 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection, status = omapi_protocol_send_message (connection -> outer, (omapi_object_t *)0, message, (omapi_object_t *)0); - omapi_object_dereference (&message, "dhcpctl_object_update"); + omapi_object_dereference (&message, MDL); return status; } @@ -399,21 +390,21 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection, isc_result_t status; omapi_object_t *message = (omapi_object_t *)0; - status = omapi_message_new (&message, "dhcpctl_object_refresh"); + status = omapi_message_new (&message, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_refresh"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "op", OMAPI_OP_REFRESH); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_refresh"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "handle", (int)(h -> handle)); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_refresh"); + omapi_object_dereference (&message, MDL); return status; } @@ -421,7 +412,7 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection, status = omapi_protocol_send_message (connection -> outer, (omapi_object_t *)0, message, (omapi_object_t *)0); - omapi_object_dereference (&message, "dhcpctl_object_update"); + omapi_object_dereference (&message, MDL); return status; } @@ -441,30 +432,29 @@ dhcpctl_status dhcpctl_object_remove (dhcpctl_handle connection, return ISC_R_INVALIDARG; ro = (dhcpctl_remote_object_t *)h; - status = omapi_message_new (&message, "dhcpctl_object_delete"); + status = omapi_message_new (&message, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_delete"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "op", OMAPI_OP_DELETE); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_delete"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "handle", (int)(ro -> remote_handle)); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "dhcpctl_object_delete"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_object_value (message, (omapi_object_t *)0, "notify-object", h); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_object_delete"); + omapi_object_dereference (&message, MDL); return status; } @@ -472,12 +462,12 @@ dhcpctl_status dhcpctl_object_remove (dhcpctl_handle connection, status = omapi_protocol_send_message (connection -> outer, (omapi_object_t *)0, message, (omapi_object_t *)0); - omapi_object_dereference (&message, "dhcpctl_object_update"); + omapi_object_dereference (&message, MDL); return status; } isc_result_t dhcpctl_data_string_dereference (dhcpctl_data_string *vp, - const char *name) + const char *file, int line) { - return omapi_data_string_dereference (vp, name); + return omapi_data_string_dereference (vp, file, line); } diff --git a/dhcpctl/dhcpctl.h b/dhcpctl/dhcpctl.h index 7090a6532..200d21e9d 100644 --- a/dhcpctl/dhcpctl.h +++ b/dhcpctl/dhcpctl.h @@ -80,7 +80,7 @@ isc_result_t dhcpctl_callback_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcpctl_callback_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcpctl_callback_destroy (omapi_object_t *, const char *); +isc_result_t dhcpctl_callback_destroy (omapi_object_t *, const char *, int); isc_result_t dhcpctl_callback_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcpctl_callback_stuff_values (omapi_object_t *, @@ -96,12 +96,12 @@ isc_result_t dhcpctl_remote_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcpctl_remote_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcpctl_remote_destroy (omapi_object_t *, const char *); +isc_result_t dhcpctl_remote_destroy (omapi_object_t *, const char *, int); isc_result_t dhcpctl_remote_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcpctl_remote_stuff_values (omapi_object_t *, omapi_object_t *, omapi_object_t *); isc_result_t dhcpctl_data_string_dereference (dhcpctl_data_string *, - const char *); + const char *, int); #endif /* _DHCPCTL_H_ */ diff --git a/dhcpctl/remote.c b/dhcpctl/remote.c index 194c7820b..919f67a5d 100644 --- a/dhcpctl/remote.c +++ b/dhcpctl/remote.c @@ -40,51 +40,47 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h, omapi_object_t *g; isc_result_t status; - m = malloc (sizeof *m); + m = dmalloc (sizeof *m, MDL); if (!m) return ISC_R_NOMEMORY; memset (m, 0, sizeof *m); m -> type = dhcpctl_remote_type; m -> refcnt = 1; + rc_register_mdl (m, m -> refcnt); g = (omapi_object_t *)0; - status = omapi_generic_new (&g, "dhcpctl_new_object"); + status = omapi_generic_new (&g, MDL); if (status != ISC_R_SUCCESS) { - free (m); + dfree (m, MDL); return status; } - status = omapi_object_reference (&m -> inner, g, "dhcpctl_new_object"); + status = omapi_object_reference (&m -> inner, g, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&m, - "dhcpctl_new_object"); - omapi_object_dereference (&g, "dhcpctl_new_object"); + omapi_object_dereference ((omapi_object_t **)&m, MDL); + omapi_object_dereference (&g, MDL); return status; } status = omapi_object_reference (&g -> outer, - (omapi_object_t *)m, - "dhcpctl_new_object"); + (omapi_object_t *)m, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&m, - "dhcpctl_new_object"); - omapi_object_dereference (&g, "dhcpctl_new_object"); + omapi_object_dereference ((omapi_object_t **)&m, MDL); + omapi_object_dereference (&g, MDL); return status; } - status = omapi_typed_data_new (&m -> rtype, + status = omapi_typed_data_new (MDL, &m -> rtype, omapi_datatype_string, - object_type, "dhcpctl_new_object"); + object_type); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&m, - "dhcpctl_new_object"); - omapi_object_dereference (&g, "dhcpctl_new_object"); + omapi_object_dereference ((omapi_object_t **)&m, MDL); + omapi_object_dereference (&g, MDL); return status; } - status = omapi_object_reference (h, (omapi_object_t *)m, - "dhcpctl_new_object"); - omapi_object_dereference ((omapi_object_t **)&m, "dhcpctl_new_object"); - omapi_object_dereference (&g, "dhcpctl_new_object"); + status = omapi_object_reference (h, (omapi_object_t *)m, MDL); + omapi_object_dereference ((omapi_object_t **)&m, MDL); + omapi_object_dereference (&g, MDL); if (status != ISC_R_SUCCESS) return status; @@ -115,27 +111,26 @@ dhcpctl_status dhcpctl_open_object (dhcpctl_handle h, return ISC_R_INVALIDARG; remote = (dhcpctl_remote_object_t *)h; - status = omapi_message_new (&message, "dhcpctl_open_object"); + status = omapi_message_new (&message, MDL); if (status != ISC_R_SUCCESS) return status; status = omapi_set_int_value (message, (omapi_object_t *)0, "op", OMAPI_OP_OPEN); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_object_value (message, (omapi_object_t *)0, "object", h); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } if (flags & DHCPCTL_CREATE) { status = omapi_set_boolean_value (message, (omapi_object_t *)0, "create", 1); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } } @@ -143,8 +138,7 @@ dhcpctl_status dhcpctl_open_object (dhcpctl_handle h, status = omapi_set_boolean_value (message, (omapi_object_t *)0, "update", 1); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } } @@ -152,8 +146,7 @@ dhcpctl_status dhcpctl_open_object (dhcpctl_handle h, status = omapi_set_boolean_value (message, (omapi_object_t *)0, "exclusive", 1); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } } @@ -162,15 +155,14 @@ dhcpctl_status dhcpctl_open_object (dhcpctl_handle h, status = omapi_set_value_str (message, (omapi_object_t *)0, "type", remote -> rtype); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } } status = omapi_message_register (message); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } return omapi_protocol_send_message (connection -> outer, @@ -237,14 +229,10 @@ isc_result_t dhcpctl_remote_signal_handler (omapi_object_t *o, if (!strcmp (name, "status")) { p -> waitstatus = va_arg (ap, isc_result_t); if (p -> message) - omapi_typed_data_dereference - (&p -> message, - "dhcpctl_remote_signal_handler"); + omapi_typed_data_dereference (&p -> message, MDL); tv = va_arg (ap, omapi_typed_data_t *); if (tv) - omapi_typed_data_reference - (&p -> message, tv, - "dhcpctl_remote_signal_handler"); + omapi_typed_data_reference (&p -> message, tv, MDL); return omapi_signal_in (o -> inner, "ready"); } @@ -255,7 +243,8 @@ isc_result_t dhcpctl_remote_signal_handler (omapi_object_t *o, return ISC_R_SUCCESS; } -isc_result_t dhcpctl_remote_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcpctl_remote_destroy (omapi_object_t *h, + const char *file, int line) { dhcpctl_remote_object_t *p; if (h -> type != dhcpctl_remote_type) @@ -263,7 +252,7 @@ isc_result_t dhcpctl_remote_destroy (omapi_object_t *h, const char *name) p = (dhcpctl_remote_object_t *)h; if (p -> handle) omapi_object_dereference ((omapi_object_t **)&p -> handle, - name); + file, line); return ISC_R_SUCCESS; } diff --git a/dhcpctl/test.c b/dhcpctl/test.c index e620f0c6c..42a347995 100644 --- a/dhcpctl/test.c +++ b/dhcpctl/test.c @@ -116,7 +116,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;", #if 1 memset (&cid, 0, sizeof cid); - status = omapi_data_string_new (&cid, 6, "main"); + status = omapi_data_string_new (&cid, 6, MDL); if (status != ISC_R_SUCCESS) { fprintf (stderr, "omapi_data_string_new: %s\n", isc_result_totext (status)); @@ -148,7 +148,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;", #if 0 memset (&ip_addr, 0, sizeof ip_addr); - status = omapi_data_string_new (&ip_addr, 4, "main"); + status = omapi_data_string_new (&ip_addr, 4, MDL); if (status != ISC_R_SUCCESS) { fprintf (stderr, "omapi_data_string_new: %s\n", isc_result_totext (status)); @@ -262,7 +262,7 @@ option smtp-server 10.0.0.1;", } memset (&ip_addr, 0, sizeof ip_addr); - status = omapi_data_string_new (&ip_addr, 4, "main"); + status = omapi_data_string_new (&ip_addr, 4, MDL); if (status != ISC_R_SUCCESS) { fprintf (stderr, "omapi_data_string_new: %s\n", isc_result_totext (status)); @@ -318,14 +318,14 @@ option smtp-server 10.0.0.1;", printf (":%02x", identifier -> value [i]); } putchar ('\n'); - dhcpctl_data_string_dereference (&identifier, "main"); + dhcpctl_data_string_dereference (&identifier, MDL); status = dhcpctl_get_value (&identifier, lease_handle, "hardware-type"); if (status == ISC_R_SUCCESS) { printf ("lease hardware type = %d\n", identifier -> value [0]); dhcpctl_data_string_dereference (&identifier, - "main"); + MDL); } } else { printf ("Unable to find identifier for lease.\n"); diff --git a/includes/arpa/nameser.h b/includes/arpa/nameser.h index 5b38997ab..96c7a8462 100644 --- a/includes/arpa/nameser.h +++ b/includes/arpa/nameser.h @@ -1,6 +1,4 @@ /* - * ++Copyright++ 1983, 1989, 1993 - * - * Copyright (c) 1983, 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -31,207 +29,528 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + */ + +/* + * Copyright (c) 1996-1999 by Internet Software Consortium. + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. - * - - * --Copyright-- */ /* - * @(#)nameser.h 8.1 (Berkeley) 6/2/93 - * $Id: nameser.h,v 8.3 1995/08/21 01:27:12 vixie Exp + * $Id: nameser.h,v 1.2 2000/01/26 14:55:58 mellon Exp $ */ -#ifndef _NAMESER_H_ -#define _NAMESER_H_ +#ifndef _ARPA_NAMESER_H_ +#define _ARPA_NAMESER_H_ + +#define BIND_4_COMPAT + +#include +#if (!defined(BSD)) || (BSD < 199306) +# include +#else +# include +#endif +#include /* - * Define constants based on rfc883 + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not + * compare for equality; rather, use it to determine whether your libbind.a + * contains a new enough lib/nameser/ to support the feature you need. */ -#define PACKETSZ 512 /* maximum packet size */ -#define MAXDNAME 256 /* maximum domain name */ -#define MAXCDNAME 255 /* maximum compressed domain name */ -#define MAXLABEL 63 /* maximum length of domain label */ -#define HFIXEDSZ 12 /* #/bytes of fixed data in header */ -#define QFIXEDSZ 4 /* #/bytes of fixed data in query */ -#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ -#define INT32SZ 4 /* for systems without 32-bit ints */ -#define INT16SZ 2 /* for systems without 16-bit ints */ -#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */ + +#define __NAMESER 19991006 /* New interface version stamp. */ /* - * Internet nameserver port number + * Define constants based on RFC 883, RFC 1034, RFC 1035 */ -#define NAMESERVER_PORT 53 +#define NS_PACKETSZ 512 /* maximum packet size */ +#define NS_MAXDNAME 1025 /* maximum domain name */ +#define NS_MAXCDNAME 255 /* maximum compressed domain name */ +#define NS_MAXLABEL 63 /* maximum length of domain label */ +#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ +#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ +#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ +#define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ +#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ +#define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ +#define NS_INADDRSZ 4 /* IPv4 T_A */ +#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ +#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ +#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ /* - * Currently defined opcodes + * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() + * in synch with it. */ -#define QUERY 0x0 /* standard query */ -#define IQUERY 0x1 /* inverse query */ -#define STATUS 0x2 /* nameserver status query */ -/*#define xxx 0x3*/ /* 0x3 reserved */ -#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */ -#ifdef ALLOW_UPDATES - /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */ -# define UPDATEA 0x9 /* add resource record */ -# define UPDATED 0xa /* delete a specific resource record */ -# define UPDATEDA 0xb /* delete all named resource record */ -# define UPDATEM 0xc /* modify a specific resource record */ -# define UPDATEMA 0xd /* modify all named resource record */ -# define ZONEINIT 0xe /* initial zone transfer */ -# define ZONEREF 0xf /* incremental zone referesh */ -#endif +typedef enum __ns_sect { + ns_s_qd = 0, /* Query: Question. */ + ns_s_zn = 0, /* Update: Zone. */ + ns_s_an = 1, /* Query: Answer. */ + ns_s_pr = 1, /* Update: Prerequisites. */ + ns_s_ns = 2, /* Query: Name servers. */ + ns_s_ud = 2, /* Update: Update. */ + ns_s_ar = 3, /* Query|Update: Additional records. */ + ns_s_max = 4 +} ns_sect; /* - * Currently defined response codes + * This is a message handle. It is caller allocated and has no dynamic data. + * This structure is intended to be opaque to all but ns_parse.c, thus the + * leading _'s on the member names. Use the accessor functions, not the _'s. */ -#define NOERROR 0 /* no error */ -#define FORMERR 1 /* format error */ -#define SERVFAIL 2 /* server failure */ -#define NXDOMAIN 3 /* non existent domain */ -#define NOTIMP 4 /* not implemented */ -#define REFUSED 5 /* query refused */ -#ifdef ALLOW_UPDATES - /* non standard */ -# define NOCHANGE 0xf /* update failed to change db */ -#endif +typedef struct __ns_msg { + const u_char *_msg, *_eom; + u_int16_t _id, _flags, _counts[ns_s_max]; + const u_char *_sections[ns_s_max]; + ns_sect _sect; + int _rrnum; + const u_char *_ptr; +} ns_msg; + +/* Private data structure - do not use from outside library. */ +struct _ns_flagdata { int mask, shift; }; +extern struct _ns_flagdata _ns_flagdata[]; + +/* Accessor macros - this is part of the public interface. */ +#define ns_msg_getflag(handle, flag) ( \ + ((handle)._flags & _ns_flagdata[flag].mask) \ + >> _ns_flagdata[flag].shift \ + ) +#define ns_msg_id(handle) ((handle)._id + 0) +#define ns_msg_base(handle) ((handle)._msg + 0) +#define ns_msg_end(handle) ((handle)._eom + 0) +#define ns_msg_size(handle) ((handle)._eom - (handle)._msg) +#define ns_msg_count(handle, section) ((handle)._counts[section] + 0) + +/* + * This is a parsed record. It is caller allocated and has no dynamic data. + */ +typedef struct __ns_rr { + char name[NS_MAXDNAME]; + u_int16_t type; + u_int16_t rr_class; + u_int32_t ttl; + u_int16_t rdlength; + const u_char * rdata; +} ns_rr; + +/* Accessor macros - this is part of the public interface. */ +#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") +#define ns_rr_type(rr) ((ns_type)((rr).type + 0)) +#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) +#define ns_rr_ttl(rr) ((rr).ttl + 0) +#define ns_rr_rdlen(rr) ((rr).rdlength + 0) +#define ns_rr_rdata(rr) ((rr).rdata + 0) /* - * Type values for resources and queries - */ -#define T_A 1 /* host address */ -#define T_NS 2 /* authoritative server */ -#define T_MD 3 /* mail destination */ -#define T_MF 4 /* mail forwarder */ -#define T_CNAME 5 /* canonical name */ -#define T_SOA 6 /* start of authority zone */ -#define T_MB 7 /* mailbox domain name */ -#define T_MG 8 /* mail group member */ -#define T_MR 9 /* mail rename name */ -#define T_NULL 10 /* null resource record */ -#define T_WKS 11 /* well known service */ -#define T_PTR 12 /* domain name pointer */ -#define T_HINFO 13 /* host information */ -#define T_MINFO 14 /* mailbox information */ -#define T_MX 15 /* mail routing information */ -#define T_TXT 16 /* text strings */ -#define T_RP 17 /* responsible person */ -#define T_AFSDB 18 /* AFS cell database */ -#define T_X25 19 /* X_25 calling address */ -#define T_ISDN 20 /* ISDN calling address */ -#define T_RT 21 /* router */ -#define T_NSAP 22 /* NSAP address */ -#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */ -#define T_SIG 24 /* security signature */ -#define T_KEY 25 /* security key */ -#define T_PX 26 /* X.400 mail mapping */ -#define T_GPOS 27 /* geographical position (withdrawn) */ -#define T_AAAA 28 /* IP6 Address */ -#define T_LOC 29 /* Location Information */ - /* non standard */ -#define T_UINFO 100 /* user (finger) information */ -#define T_UID 101 /* user ID */ -#define T_GID 102 /* group ID */ -#define T_UNSPEC 103 /* Unspecified format (binary data) */ - /* Query type values which do not appear in resource records */ -#define T_AXFR 252 /* transfer zone of authority */ -#define T_MAILB 253 /* transfer mailbox records */ -#define T_MAILA 254 /* transfer mail agent records */ -#define T_ANY 255 /* wildcard match */ + * These don't have to be in the same order as in the packet flags word, + * and they can even overlap in some cases, but they will need to be kept + * in synch with ns_parse.c:ns_flagdata[]. + */ +typedef enum __ns_flag { + ns_f_qr, /* Question/Response. */ + ns_f_opcode, /* Operation code. */ + ns_f_aa, /* Authoritative Answer. */ + ns_f_tc, /* Truncation occurred. */ + ns_f_rd, /* Recursion Desired. */ + ns_f_ra, /* Recursion Available. */ + ns_f_z, /* MBZ. */ + ns_f_ad, /* Authentic Data (DNSSEC). */ + ns_f_cd, /* Checking Disabled (DNSSEC). */ + ns_f_rcode, /* Response code. */ + ns_f_max +} ns_flag; /* - * Values for class field + * Currently defined opcodes. */ +typedef enum __ns_opcode { + ns_o_query = 0, /* Standard query. */ + ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ + ns_o_status = 2, /* Name server status query (unsupported). */ + /* Opcode 3 is undefined/reserved. */ + ns_o_notify = 4, /* Zone change notification. */ + ns_o_update = 5, /* Zone update message. */ + ns_o_max = 6 +} ns_opcode; -#define C_IN 1 /* the arpa internet */ -#define C_CHAOS 3 /* for chaos net (MIT) */ -#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ - /* Query class values which do not appear in resource records */ -#define C_ANY 255 /* wildcard match */ - -/* - * Status return codes for T_UNSPEC conversion routines - */ -#define CONV_SUCCESS 0 -#define CONV_OVERFLOW (-1) -#define CONV_BADFMT (-2) -#define CONV_BADCKSUM (-3) -#define CONV_BADBUFLEN (-4) - -/* - * Structure for query header. The order of the fields is machine- and - * compiler-dependent, depending on the byte/bit order and the layout - * of bit fields. We use bit fields only in int variables, as this - * is all ANSI requires. This requires a somewhat confusing rearrangement. - */ - -typedef struct { - unsigned id :16; /* query identification number */ -#if BYTE_ORDER == BIG_ENDIAN - /* fields in third byte */ - unsigned qr: 1; /* response flag */ - unsigned opcode: 4; /* purpose of message */ - unsigned aa: 1; /* authoritive answer */ - unsigned tc: 1; /* truncated message */ - unsigned rd: 1; /* recursion desired */ - /* fields in fourth byte */ - unsigned ra: 1; /* recursion available */ - unsigned pr:1; /* primary server required (non standard) */ - unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */ - unsigned rcode :4; /* response code */ -#endif -#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN - /* fields in third byte */ - unsigned rd :1; /* recursion desired */ - unsigned tc :1; /* truncated message */ - unsigned aa :1; /* authoritive answer */ - unsigned opcode :4; /* purpose of message */ - unsigned qr :1; /* response flag */ - /* fields in fourth byte */ - unsigned rcode :4; /* response code */ - unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */ - unsigned pr:1; /* primary server required (non standard) */ - unsigned ra :1; /* recursion available */ -#endif - /* remaining bytes */ - unsigned qdcount :16; /* number of question entries */ - unsigned ancount :16; /* number of answer entries */ - unsigned nscount :16; /* number of authority entries */ - unsigned arcount :16; /* number of resource entries */ -} HEADER; +/* + * Currently defined response codes. + */ +typedef enum __ns_rcode { + ns_r_noerror = 0, /* No error occurred. */ + ns_r_formerr = 1, /* Format error. */ + ns_r_servfail = 2, /* Server failure. */ + ns_r_nxdomain = 3, /* Name error. */ + ns_r_notimpl = 4, /* Unimplemented. */ + ns_r_refused = 5, /* Operation refused. */ + /* these are for BIND_UPDATE */ + ns_r_yxdomain = 6, /* Name exists */ + ns_r_yxrrset = 7, /* RRset exists */ + ns_r_nxrrset = 8, /* RRset does not exist */ + ns_r_notauth = 9, /* Not authoritative for zone */ + ns_r_notzone = 10, /* Zone of record different from zone section */ + ns_r_max = 11, + /* The following are TSIG extended errors */ + ns_r_badsig = 16, + ns_r_badkey = 17, + ns_r_badtime = 18 +} ns_rcode; + +/* BIND_UPDATE */ +typedef enum __ns_update_operation { + ns_uop_delete = 0, + ns_uop_add = 1, + ns_uop_max = 2 +} ns_update_operation; /* - * Defines for handling compressed domain names + * This structure is used for TSIG authenticated messages */ -#define INDIR_MASK 0xc0 +struct ns_tsig_key { + char name[NS_MAXDNAME], alg[NS_MAXDNAME]; + unsigned char *data; + int len; +}; +typedef struct ns_tsig_key ns_tsig_key; /* - * Structure for passing resource records around. + * This structure is used for TSIG authenticated TCP messages */ -struct rrec { - int16_t r_zone; /* zone number */ - int16_t r_class; /* class number */ - int16_t r_type; /* type number */ - u_int32_t r_ttl; /* time to live */ - int r_size; /* size of data area */ - char *r_data; /* pointer to data */ +struct ns_tcp_tsig_state { + int counter; + struct dst_key *key; + void *ctx; + unsigned char sig[NS_PACKETSZ]; + int siglen; }; +typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; + +#define NS_TSIG_FUDGE 300 +#define NS_TSIG_TCP_COUNT 100 +#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" + +#define NS_TSIG_ERROR_NO_TSIG -10 +#define NS_TSIG_ERROR_NO_SPACE -11 +#define NS_TSIG_ERROR_FORMERR -12 + +/* + * Currently defined type values for resources and queries. + */ +typedef enum __ns_type { + ns_t_invalid = 0, /* Cookie. */ + ns_t_a = 1, /* Host address. */ + ns_t_ns = 2, /* Authoritative server. */ + ns_t_md = 3, /* Mail destination. */ + ns_t_mf = 4, /* Mail forwarder. */ + ns_t_cname = 5, /* Canonical name. */ + ns_t_soa = 6, /* Start of authority zone. */ + ns_t_mb = 7, /* Mailbox domain name. */ + ns_t_mg = 8, /* Mail group member. */ + ns_t_mr = 9, /* Mail rename name. */ + ns_t_null = 10, /* Null resource record. */ + ns_t_wks = 11, /* Well known service. */ + ns_t_ptr = 12, /* Domain name pointer. */ + ns_t_hinfo = 13, /* Host information. */ + ns_t_minfo = 14, /* Mailbox information. */ + ns_t_mx = 15, /* Mail routing information. */ + ns_t_txt = 16, /* Text strings. */ + ns_t_rp = 17, /* Responsible person. */ + ns_t_afsdb = 18, /* AFS cell database. */ + ns_t_x25 = 19, /* X_25 calling address. */ + ns_t_isdn = 20, /* ISDN calling address. */ + ns_t_rt = 21, /* Router. */ + ns_t_nsap = 22, /* NSAP address. */ + ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ + ns_t_sig = 24, /* Security signature. */ + ns_t_key = 25, /* Security key. */ + ns_t_px = 26, /* X.400 mail mapping. */ + ns_t_gpos = 27, /* Geographical position (withdrawn). */ + ns_t_aaaa = 28, /* Ip6 Address. */ + ns_t_loc = 29, /* Location Information. */ + ns_t_nxt = 30, /* Next domain (security). */ + ns_t_eid = 31, /* Endpoint identifier. */ + ns_t_nimloc = 32, /* Nimrod Locator. */ + ns_t_srv = 33, /* Server Selection. */ + ns_t_atma = 34, /* ATM Address */ + ns_t_naptr = 35, /* Naming Authority PoinTeR */ + ns_t_kx = 36, /* Key Exchange */ + ns_t_cert = 37, /* Certification record */ + ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ + ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ + ns_t_sink = 40, /* Kitchen sink (experimentatl) */ + ns_t_opt = 41, /* EDNS0 option (meta-RR) */ + ns_t_tsig = 250, /* Transaction signature. */ + ns_t_ixfr = 251, /* Incremental zone transfer. */ + ns_t_axfr = 252, /* Transfer zone of authority. */ + ns_t_mailb = 253, /* Transfer mailbox records. */ + ns_t_maila = 254, /* Transfer mail agent records. */ + ns_t_any = 255, /* Wildcard match. */ + ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ + ns_t_max = 65536 +} ns_type; + +/* Exclusively a QTYPE? (not also an RTYPE) */ +#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ + (t) == ns_t_mailb || (t) == ns_t_maila) +/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ +#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) +/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ +#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) +#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) +#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ + (t) == ns_t_zxfr) + +/* + * Values for class field + */ +typedef enum __ns_class { + ns_c_invalid = 0, /* Cookie. */ + ns_c_in = 1, /* Internet. */ + ns_c_2 = 2, /* unallocated/unsupported. */ + ns_c_chaos = 3, /* MIT Chaos-net. */ + ns_c_hs = 4, /* MIT Hesiod. */ + /* Query class values which do not appear in resource records */ + ns_c_none = 254, /* for prereq. sections in update requests */ + ns_c_any = 255, /* Wildcard match. */ + ns_c_max = 65536 +} ns_class; + +/* DNSSEC constants. */ + +typedef enum __ns_key_types { + ns_kt_rsa = 1, /* key type RSA/MD5 */ + ns_kt_dh = 2, /* Diffie Hellman */ + ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */ + ns_kt_private = 254 /* Private key type starts with OID */ +} ns_key_types; + +typedef enum __ns_cert_types { + cert_t_pkix = 1, /* PKIX (X.509v3) */ + cert_t_spki = 2, /* SPKI */ + cert_t_pgp = 3, /* PGP */ + cert_t_url = 253, /* URL private type */ + cert_t_oid = 254 /* OID private type */ +} ns_cert_types; + +/* Flags field of the KEY RR rdata. */ +#define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */ +#define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ +#define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ +#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ +#define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ +/* The type bits can also be interpreted independently, as single bits: */ +#define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */ +#define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */ +#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ +#define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */ +#define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */ +#define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */ +#define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */ +#define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */ +#define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */ +#define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */ +#define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */ +#define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */ +#define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */ +#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */ +#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */ +#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */ +#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \ + NS_KEY_RESERVED4 | \ + NS_KEY_RESERVED5 | \ + NS_KEY_RESERVED8 | \ + NS_KEY_RESERVED9 | \ + NS_KEY_RESERVED10 | \ + NS_KEY_RESERVED11 ) +#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */ + +/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ +#define NS_ALG_MD5RSA 1 /* MD5 with RSA */ +#define NS_ALG_DH 2 /* Diffie Hellman KEY */ +#define NS_ALG_DSA 3 /* DSA KEY */ +#define NS_ALG_DSS NS_ALG_DSA +#define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */ +#define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */ + +/* Protocol values */ +/* value 0 is reserved */ +#define NS_KEY_PROT_TLS 1 +#define NS_KEY_PROT_EMAIL 2 +#define NS_KEY_PROT_DNSSEC 3 +#define NS_KEY_PROT_IPSEC 4 +#define NS_KEY_PROT_ANY 255 + +/* Signatures */ +#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */ +#define NS_MD5RSA_MAX_BITS 2552 + /* Total of binary mod and exp */ +#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) + /* Max length of text sig block */ +#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) +#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) +#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) + +#define NS_DSA_SIG_SIZE 41 +#define NS_DSA_MIN_SIZE 213 +#define NS_DSA_MAX_BYTES 405 + +/* Offsets into SIG record rdata to find various values */ +#define NS_SIG_TYPE 0 /* Type flags */ +#define NS_SIG_ALG 2 /* Algorithm */ +#define NS_SIG_LABELS 3 /* How many labels in name */ +#define NS_SIG_OTTL 4 /* Original TTL */ +#define NS_SIG_EXPIR 8 /* Expiration time */ +#define NS_SIG_SIGNED 12 /* Signature time */ +#define NS_SIG_FOOT 16 /* Key footprint */ +#define NS_SIG_SIGNER 18 /* Domain name of who signed it */ + +/* How RR types are represented as bit-flags in NXT records */ +#define NS_NXT_BITS 8 +#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_MAX 127 + +/* + * Inline versions of get/put short/long. Pointer is advanced. + */ +#define NS_GET16(s, cp) do { \ + register u_char *t_cp = (u_char *)(cp); \ + (s) = ((u_int16_t)t_cp[0] << 8) \ + | ((u_int16_t)t_cp[1]) \ + ; \ + (cp) += NS_INT16SZ; \ +} while (0) + +#define NS_GET32(l, cp) do { \ + register u_char *t_cp = (u_char *)(cp); \ + (l) = ((u_int32_t)t_cp[0] << 24) \ + | ((u_int32_t)t_cp[1] << 16) \ + | ((u_int32_t)t_cp[2] << 8) \ + | ((u_int32_t)t_cp[3]) \ + ; \ + (cp) += NS_INT32SZ; \ +} while (0) + +#define NS_PUT16(s, cp) do { \ + register u_int16_t t_s = (u_int16_t)(s); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += NS_INT16SZ; \ +} while (0) + +#define NS_PUT32(l, cp) do { \ + register u_int32_t t_l = (u_int32_t)(l); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += NS_INT32SZ; \ +} while (0) + +/* + * ANSI C identifier hiding for bind's lib/nameser. + */ +#define ns_get16 __ns_get16 +#define ns_get32 __ns_get32 +#define ns_put16 __ns_put16 +#define ns_put32 __ns_put32 +#define ns_initparse __ns_initparse +#define ns_skiprr __ns_skiprr +#define ns_parserr __ns_parserr +#define ns_sprintrr __ns_sprintrr +#define ns_sprintrrf __ns_sprintrrf +#define ns_format_ttl __ns_format_ttl +#define ns_parse_ttl __ns_parse_ttl +#define ns_datetosecs __ns_datetosecs +#define ns_name_ntol __ns_name_ntol +#define ns_name_ntop __ns_name_ntop +#define ns_name_pton __ns_name_pton +#define ns_name_unpack __ns_name_unpack +#define ns_name_pack __ns_name_pack +#define ns_name_compress __ns_name_compress +#define ns_name_uncompress __ns_name_uncompress +#define ns_name_skip __ns_name_skip +#define ns_sign __ns_sign +#define ns_sign_tcp __ns_sign_tcp +#define ns_sign_tcp_init __ns_sign_tcp_init +#define ns_find_tsig __ns_find_tsig +#define ns_verify __ns_verify +#define ns_verify_tcp __ns_verify_tcp +#define ns_verify_tcp_init __ns_verify_tcp_init +#define ns_samedomain __ns_samedomain +#define ns_subdomain __ns_subdomain +#define ns_makecanon __ns_makecanon +#define ns_samename __ns_samename + +__BEGIN_DECLS +u_int ns_get16 __P((const u_char *)); +u_long ns_get32 __P((const u_char *)); +void ns_put16 __P((u_int, u_char *)); +void ns_put32 __P((u_long, u_char *)); +int ns_initparse __P((const u_char *, int, ns_msg *)); +int ns_skiprr __P((const u_char *, const u_char *, ns_sect, int)); +int ns_parserr __P((ns_msg *, ns_sect, int, ns_rr *)); +int ns_sprintrr __P((const ns_msg *, const ns_rr *, + const char *, const char *, char *, size_t)); +int ns_sprintrrf __P((const u_char *, size_t, const char *, + ns_class, ns_type, u_long, const u_char *, + size_t, const char *, const char *, + char *, size_t)); +int ns_format_ttl __P((u_long, char *, size_t)); +int ns_parse_ttl __P((const char *, u_long *)); +u_int32_t ns_datetosecs __P((const char *cp, int *errp)); +int ns_name_ntol __P((const u_char *, u_char *, size_t)); +int ns_name_ntop __P((const u_char *, char *, size_t)); +int ns_name_pton __P((const char *, u_char *, size_t)); +int ns_name_unpack __P((const u_char *, const u_char *, + const u_char *, u_char *, size_t)); +int ns_name_pack __P((const u_char *, u_char *, int, + const u_char **, const u_char **)); +int ns_name_uncompress __P((const u_char *, const u_char *, + const u_char *, char *, size_t)); +int ns_name_compress __P((const char *, u_char *, size_t, + const u_char **, const u_char **)); +int ns_name_skip __P((const u_char **, const u_char *)); +int ns_sign __P((u_char *, int *, int, int, void *, + const u_char *, int, u_char *, int *, time_t)); +int ns_sign_tcp __P((u_char *, int *, int, int, + ns_tcp_tsig_state *, int)); +int ns_sign_tcp_init __P((void *, const u_char *, int, + ns_tcp_tsig_state *)); +u_char *ns_find_tsig __P((u_char *, u_char *)); +int ns_verify __P((u_char *, int *, void *, + const u_char *, int, u_char *, int *, + time_t *, int)); +int ns_verify_tcp __P((u_char *, int *, ns_tcp_tsig_state *, int)); +int ns_verify_tcp_init __P((void *, const u_char *, int, + ns_tcp_tsig_state *)); +int ns_samedomain __P((const char *, const char *)); +int ns_subdomain __P((const char *, const char *)); +int ns_makecanon __P((const char *, char *, size_t)); +int ns_samename __P((const char *, const char *)); +__END_DECLS + +#ifdef BIND_4_COMPAT +#include +#endif -#endif /* !_NAMESER_H_ */ +#endif /* !_ARPA_NAMESER_H_ */ diff --git a/includes/arpa/nameser_compat.h b/includes/arpa/nameser_compat.h new file mode 100644 index 000000000..55c36431b --- /dev/null +++ b/includes/arpa/nameser_compat.h @@ -0,0 +1,229 @@ +/* Copyright (c) 1983, 1989 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * from nameser.h 8.1 (Berkeley) 6/2/93 + * $Id: nameser_compat.h,v 1.1 2000/01/26 14:55:58 mellon Exp $ + */ + +#ifndef _ARPA_NAMESER_COMPAT_ +#define _ARPA_NAMESER_COMPAT_ + +#define __BIND 19950621 /* (DEAD) interface version stamp. */ + +#ifndef BYTE_ORDER +#if (BSD >= 199103) +# include +#else +#ifdef linux +# include +#else +#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ +#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/ + +#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ + defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ + defined(__alpha__) || defined(__alpha) || \ + (defined(__Lynx__) && defined(__x86__)) +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ + defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ + defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ + defined(apollo) || defined(__convex__) || defined(_CRAY) || \ + defined(__hppa) || defined(__hp9000) || \ + defined(__hp9000s300) || defined(__hp9000s700) || \ + defined (BIT_ZERO_ON_LEFT) || defined(m68k) || \ + (defined(__Lynx__) && \ + (defined(__68k__) || defined(__sparc__) || defined(__powerpc__))) +#define BYTE_ORDER BIG_ENDIAN +#endif +#endif /* linux */ +#endif /* BSD */ +#endif /* BYTE_ORDER */ + +#if !defined(BYTE_ORDER) || \ + (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \ + BYTE_ORDER != PDP_ENDIAN) + /* you must determine what the correct bit order is for + * your compiler - the next line is an intentional error + * which will force your compiles to bomb until you fix + * the above macros. + */ + error "Undefined or invalid BYTE_ORDER"; +#endif + +/* + * Structure for query header. The order of the fields is machine- and + * compiler-dependent, depending on the byte/bit order and the layout + * of bit fields. We use bit fields only in int variables, as this + * is all ANSI requires. This requires a somewhat confusing rearrangement. + */ + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone +/*#define BADSIG ns_r_badsig*/ +/*#define BADKEY ns_r_badkey*/ +/*#define BADTIME ns_r_badtime*/ + + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +/* BIND_UPDATE */ +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#define GETSHORT NS_GET16 +#define GETLONG NS_GET32 +#define PUTSHORT NS_PUT16 +#define PUTLONG NS_PUT32 + +#endif /* _ARPA_NAMESER_COMPAT_ */ diff --git a/includes/dhcpd.h b/includes/dhcpd.h index e5f36b3b7..e1614b145 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -3,7 +3,7 @@ Definitions for dhcpd... */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -27,8 +27,8 @@ #include #include +#include "arpa/nameser.h" #if defined (NSUPDATE) -# include # include # include #endif @@ -748,48 +748,6 @@ struct dns_query { int backoff; /* Current backoff, in seconds. */ }; -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) -#define DMDOFFSET (sizeof (struct dmalloc_preamble)) -#define DMLFSIZE 16 -#define DMUFSIZE 16 -#define DMDSIZE (DMDOFFSET + DMLFSIZE + DMUFSIZE) - -struct dmalloc_preamble { - struct dmalloc_preamble *prev, *next; - size_t size; - const char *file; - int line; - unsigned long generation; - unsigned char low_fence [DMLFSIZE]; -}; -#else -#define DMDOFFSET 0 -#define DMDSIZE 0 -#endif - -#if defined (DEBUG_RC_HISTORY) -#if !defined (RC_HISTORY_MAX) -# define RC_HISTORY_MAX 256 -#endif - -struct rc_history_entry { - char *name; - VOIDPTR addr; - int refcnt; -}; - -#define rc_register(x, l, y, z) do { \ - rc_history [rc_history_index].file = (x); \ - rc_history [rc_history_index].line = (l); \ - rc_history [rc_history_index].addr = (y); \ - rc_history [rc_history_index].refcnt = (z); \ - if (++rc_history_index == RC_HISTORY_MAX) \ - rc_history_index = 0;\ - } while (0) -#else -#define rc_register(name, addr, refcnt) -#endif - /* Bitmask of dhcp option codes. */ typedef unsigned char option_mask [16]; @@ -895,7 +853,8 @@ void save_hashed_option PROTO ((struct universe *, void delete_option PROTO ((struct universe *, struct option_state *, int)); void delete_hashed_option PROTO ((struct universe *, struct option_state *, int)); -int option_cache_dereference PROTO ((struct option_cache **, const char *)); +int option_cache_dereference PROTO ((struct option_cache **, + const char *, int)); int hashed_option_state_dereference PROTO ((struct universe *, struct option_state *)); int agent_option_state_dereference PROTO ((struct universe *, @@ -923,28 +882,13 @@ int nwip_option_space_encapsulate PROTO ((struct data_string *, struct binding_scope *, struct universe *)); -/* errwarn.c */ -void log_fatal PROTO ((const char *, ...)) - __attribute__((__format__(__printf__,1,2))); -int log_error PROTO ((const char *, ...)) - __attribute__((__format__(__printf__,1,2))); -int log_info PROTO ((const char *, ...)) - __attribute__((__format__(__printf__,1,2))); -int log_debug PROTO ((const char *, ...)) - __attribute__((__format__(__printf__,1,2))); -int parse_warn PROTO ((struct parse *, const char *, ...)) - __attribute__((__format__(__printf__,2,3))); - /* dhcpd.c */ extern TIME cur_time; extern struct group root_group; -extern struct binding_scope global_scope; extern struct in_addr limited_broadcast; extern u_int16_t local_port; extern u_int16_t remote_port; -extern int log_priority; -extern int log_perror; extern const char *path_dhcpd_conf; extern const char *path_dhcpd_db; @@ -1042,12 +986,15 @@ int parse_option_token PROTO ((struct expression **, struct parse *, const char *, struct expression *, int, int)); int parse_allow_deny PROTO ((struct option_cache **, struct parse *, int)); int parse_auth_key PROTO ((struct data_string *, struct parse *)); +int parse_warn PROTO ((struct parse *, const char *, ...)) + __attribute__((__format__(__printf__,2,3))); /* tree.c */ +extern struct binding_scope global_scope; pair cons PROTO ((caddr_t, pair)); int make_const_option_cache PROTO ((struct option_cache **, struct buffer **, u_int8_t *, unsigned, struct option *, - const char *)); + const char *, int)); int make_host_lookup PROTO ((struct expression **, const char *)); int enter_dns_host PROTO ((struct dns_host_entry **, const char *)); int make_const_data PROTO ((struct expression **, @@ -1062,11 +1009,13 @@ int make_limit PROTO ((struct expression **, struct expression *, int)); int make_let PROTO ((struct executable_statement **, const char *)); int option_cache PROTO ((struct option_cache **, struct data_string *, struct expression *, struct option *)); +#if defined (NSUPDATE) int evaluate_dns_expression PROTO ((ns_updrec **, struct packet *, struct lease *, struct option_state *, struct option_state *, struct binding_scope *, struct expression *)); +#endif int evaluate_boolean_expression PROTO ((int *, struct packet *, struct lease *, struct option_state *, @@ -1087,7 +1036,8 @@ int evaluate_option_cache PROTO ((struct data_string *, struct packet *, struct lease *, struct option_state *, struct option_state *, struct binding_scope *, - struct option_cache *)); + struct option_cache *, + const char *, int)); int evaluate_boolean_option_cache PROTO ((int *, struct packet *, struct lease *, struct option_state *, @@ -1100,9 +1050,8 @@ int evaluate_boolean_expression_result PROTO ((int *, struct option_state *, struct option_state *, struct binding_scope *, - struct expression *, - const char *, int)); -void expression_dereference PROTO ((struct expression **, const char *)); + struct expression *)); +void expression_dereference PROTO ((struct expression **, const char *, int)); int is_dns_expression PROTO ((struct expression *)); int is_boolean_expression PROTO ((struct expression *)); int is_data_expression PROTO ((struct expression *)); @@ -1112,8 +1061,9 @@ int op_precedence PROTO ((enum expr_op, enum expr_op)); enum expression_context op_context PROTO ((enum expr_op)); int write_expression PROTO ((FILE *, struct expression *, int, int, int)); struct binding *find_binding PROTO ((struct binding_scope *, const char *)); -int free_bindings PROTO ((struct binding_scope *, const char *)); -int binding_scope_dereference PROTO ((struct binding_scope **, const char *)); +int free_bindings PROTO ((struct binding_scope *, const char *, int)); +int binding_scope_dereference PROTO ((struct binding_scope **, + const char *, int)); /* dhcp.c */ extern int outstanding_pings; @@ -1133,7 +1083,7 @@ struct lease *find_lease PROTO ((struct packet *, struct lease *mockup_lease PROTO ((struct packet *, struct shared_network *, struct host_decl *)); -void static_lease_dereference PROTO ((struct lease *, const char *)); +void static_lease_dereference PROTO ((struct lease *, const char *, int)); struct lease *allocate_lease PROTO ((struct packet *, struct pool *, int)); int permitted PROTO ((struct packet *, struct permit *)); @@ -1147,32 +1097,9 @@ unsigned cons_agent_information_options PROTO ((struct option_state *, void bootp PROTO ((struct packet *)); /* memory.c */ -struct group *clone_group PROTO ((struct group *, const char *)); +struct group *clone_group PROTO ((struct group *, const char *, int)); /* alloc.c */ -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) -extern struct dmalloc_preamble *dmalloc_list; -extern unsigned long dmalloc_outstanding; -extern unsigned long dmalloc_longterm; -extern unsigned long dmalloc_generation; -extern unsigned long dmalloc_cutoff_generation; -#endif - -#if defined (DEBUG_RC_HISTORY) -extern struct rc_history_entry rc_history [RC_HISTORY_MAX]; -extern int rc_history_index; -#endif -VOIDPTR dmalloc PROTO ((unsigned, const char *, int)); -void dfree PROTO ((VOIDPTR, const char *, int)); -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) -void dmalloc_reuse PROTO ((VOIDPTR, const char *, int, int)); -void dmalloc_dump_outstanding PROTO ((void)); -#else -#define dmalloc_reuse(x,y,z) -#endif -#if defined (DEBUG_RC_HISTORY) -void dump_rc_history PROTO ((void)); -#endif struct dhcp_packet *new_dhcp_packet PROTO ((const char *, int)); struct hash_table *new_hash_table PROTO ((int, const char *, int)); struct hash_bucket *new_hash_bucket PROTO ((const char *, int)); @@ -1449,7 +1376,7 @@ isc_result_t interface_set_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *); isc_result_t interface_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t interface_destroy (omapi_object_t *, const char *); +isc_result_t interface_destroy (omapi_object_t *, const char *, int); isc_result_t interface_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t interface_stuff_values (omapi_object_t *, @@ -1784,7 +1711,7 @@ isc_result_t dhcp_lease_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcp_lease_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_lease_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_lease_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_lease_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_lease_stuff_values (omapi_object_t *, @@ -1802,7 +1729,7 @@ isc_result_t dhcp_group_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcp_group_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_group_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_group_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_group_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_group_stuff_values (omapi_object_t *, @@ -1820,7 +1747,7 @@ isc_result_t dhcp_host_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcp_host_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_host_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_host_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_host_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_host_stuff_values (omapi_object_t *, @@ -1838,7 +1765,7 @@ isc_result_t dhcp_pool_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcp_pool_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_pool_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_pool_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_pool_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_pool_stuff_values (omapi_object_t *, @@ -1857,7 +1784,7 @@ isc_result_t dhcp_shared_network_set_value (omapi_object_t *, isc_result_t dhcp_shared_network_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *, @@ -1873,7 +1800,7 @@ isc_result_t dhcp_subnet_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcp_subnet_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_subnet_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_subnet_stuff_values (omapi_object_t *, @@ -1889,7 +1816,7 @@ isc_result_t dhcp_class_set_value (omapi_object_t *, omapi_object_t *, isc_result_t dhcp_class_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t dhcp_class_destroy (omapi_object_t *, const char *); +isc_result_t dhcp_class_destroy (omapi_object_t *, const char *, int); isc_result_t dhcp_class_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t dhcp_class_stuff_values (omapi_object_t *, @@ -1931,7 +1858,7 @@ extern struct subnet *find_subnet PROTO ((struct iaddr)); void enter_shared_network PROTO ((struct shared_network *)); void new_shared_network_interface PROTO ((struct parse *, struct shared_network *, - const char *, int)); + const char *)); int subnet_inner_than PROTO ((struct subnet *, struct subnet *, int)); void enter_subnet PROTO ((struct subnet *)); void enter_lease PROTO ((struct lease *)); @@ -1982,7 +1909,7 @@ isc_result_t dhcp_failover_link_get_value PROTO ((omapi_object_t *, omapi_data_string_t *, omapi_value_t **)); isc_result_t dhcp_failover_link_destroy PROTO ((omapi_object_t *, - const char *)); + const char *, int)); isc_result_t dhcp_failover_link_stuff_values PROTO ((omapi_object_t *, omapi_object_t *, omapi_object_t *)); @@ -2000,7 +1927,7 @@ isc_result_t dhcp_failover_listener_get_value PROTO ((omapi_object_t *, omapi_data_string_t *, omapi_value_t **)); isc_result_t dhcp_failover_listener_destroy PROTO ((omapi_object_t *, - const char *)); + const char *, int)); isc_result_t dhcp_failover_listener_stuff PROTO ((omapi_object_t *, omapi_object_t *, omapi_object_t *)); @@ -2016,7 +1943,7 @@ isc_result_t dhcp_failover_state_get_value PROTO ((omapi_object_t *, omapi_data_string_t *, omapi_value_t **)); isc_result_t dhcp_failover_state_destroy PROTO ((omapi_object_t *, - const char *)); + const char *, int)); isc_result_t dhcp_failover_state_stuff PROTO ((omapi_object_t *, omapi_object_t *, omapi_object_t *)); diff --git a/includes/omapip/alloc.h b/includes/omapip/alloc.h index 162ea41a0..b5a9bf2d0 100644 --- a/includes/omapip/alloc.h +++ b/includes/omapip/alloc.h @@ -20,7 +20,66 @@ * http://www.isc.org for more information. */ -isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *); +isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *, int); isc_result_t omapi_buffer_reference (omapi_buffer_t **, - omapi_buffer_t *, const char *); -isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *); + omapi_buffer_t *, const char *, int); +isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *, int); + +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) +#define DMDOFFSET (sizeof (struct dmalloc_preamble)) +#define DMLFSIZE 16 +#define DMUFSIZE 16 +#define DMDSIZE (DMDOFFSET + DMLFSIZE + DMUFSIZE) + +struct dmalloc_preamble { + struct dmalloc_preamble *prev, *next; + const char *file; + int line; + size_t size; + unsigned long generation; + unsigned char low_fence [DMLFSIZE]; +}; +#else +#define DMDOFFSET 0 +#define DMDSIZE 0 +#endif + +#if defined (DEBUG_RC_HISTORY) +#if !defined (RC_HISTORY_MAX) +# define RC_HISTORY_MAX 256 +#endif + +struct rc_history_entry { + const char *file; + int line; + VOIDPTR addr; + int refcnt; +}; + +#define rc_register(x, l, y, z) do { \ + rc_history [rc_history_index].file = (x); \ + rc_history [rc_history_index].line = (l); \ + rc_history [rc_history_index].addr = (y); \ + rc_history [rc_history_index].refcnt = (z); \ + if (++rc_history_index == RC_HISTORY_MAX) \ + rc_history_index = 0;\ + } while (0) +#define rc_register_mdl(y, z) \ + rc_register (__FILE__, __LINE__, y, z) +#else +#define rc_register(file, line, addr, refcnt) +#define rc_register_mdl(addr, refcnt) +#endif + +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) +extern struct dmalloc_preamble *dmalloc_list; +extern unsigned long dmalloc_outstanding; +extern unsigned long dmalloc_longterm; +extern unsigned long dmalloc_generation; +extern unsigned long dmalloc_cutoff_generation; +#endif + +#if defined (DEBUG_RC_HISTORY) +extern struct rc_history_entry rc_history [RC_HISTORY_MAX]; +extern int rc_history_index; +#endif diff --git a/includes/omapip/omapip.h b/includes/omapip/omapip.h index 233db8e7c..d875f8a1d 100644 --- a/includes/omapip/omapip.h +++ b/includes/omapip/omapip.h @@ -57,8 +57,9 @@ typedef struct { struct { void *ptr; isc_result_t (*reference) (void *, - void *, char *); - isc_result_t (*dereference) (void *, char *); + void *, const char *, int); + isc_result_t (*dereference) (void *, + const char *, int); } ref; #define OMAPI_TYPED_DATA_INT_LEN (sizeof (int) + \ sizeof (omapi_datatype_t) + \ @@ -90,7 +91,7 @@ typedef struct __omapi_object_type_t { isc_result_t (*get_value) (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); - isc_result_t (*destroy) (omapi_object_t *, const char *); + isc_result_t (*destroy) (omapi_object_t *, const char *, int); isc_result_t (*signal_handler) (omapi_object_t *, const char *, va_list); isc_result_t (*stuff_values) (omapi_object_t *, @@ -131,7 +132,7 @@ isc_result_t omapi_protocol_stuff_values (omapi_object_t *, omapi_object_t *, omapi_object_t *); -isc_result_t omapi_protocol_destroy (omapi_object_t *, const char *); +isc_result_t omapi_protocol_destroy (omapi_object_t *, const char *, int); isc_result_t omapi_protocol_send_message (omapi_object_t *, omapi_object_t *, omapi_object_t *, @@ -146,7 +147,8 @@ isc_result_t omapi_protocol_listener_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t omapi_protocol_listener_destroy (omapi_object_t *, const char *); +isc_result_t omapi_protocol_listener_destroy (omapi_object_t *, + const char *, int); isc_result_t omapi_protocol_listener_signal (omapi_object_t *, const char *, va_list); isc_result_t omapi_protocol_listener_stuff (omapi_object_t *, @@ -170,7 +172,7 @@ isc_result_t omapi_connection_set_value (omapi_object_t *, omapi_object_t *, isc_result_t omapi_connection_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t omapi_connection_destroy (omapi_object_t *, const char *); +isc_result_t omapi_connection_destroy (omapi_object_t *, const char *, int); isc_result_t omapi_connection_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t omapi_connection_stuff_values (omapi_object_t *, @@ -194,7 +196,7 @@ isc_result_t omapi_listener_set_value (omapi_object_t *, omapi_object_t *, isc_result_t omapi_listener_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t omapi_listener_destroy (omapi_object_t *, const char *); +isc_result_t omapi_listener_destroy (omapi_object_t *, const char *, int); isc_result_t omapi_listener_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t omapi_listener_stuff_values (omapi_object_t *, @@ -215,7 +217,7 @@ isc_result_t omapi_io_set_value (omapi_object_t *, omapi_object_t *, omapi_typed_data_t *); isc_result_t omapi_io_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t omapi_io_destroy (omapi_object_t *, const char *); +isc_result_t omapi_io_destroy (omapi_object_t *, const char *, int); isc_result_t omapi_io_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t omapi_io_stuff_values (omapi_object_t *, omapi_object_t *, @@ -223,28 +225,28 @@ isc_result_t omapi_io_stuff_values (omapi_object_t *, isc_result_t omapi_waiter_signal_handler (omapi_object_t *, const char *, va_list); -isc_result_t omapi_generic_new (omapi_object_t **, const char *); +isc_result_t omapi_generic_new (omapi_object_t **, const char *, int); isc_result_t omapi_generic_set_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *); isc_result_t omapi_generic_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t omapi_generic_destroy (omapi_object_t *, const char *); +isc_result_t omapi_generic_destroy (omapi_object_t *, const char *, int); isc_result_t omapi_generic_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t omapi_generic_stuff_values (omapi_object_t *, omapi_object_t *, omapi_object_t *); -isc_result_t omapi_message_new (omapi_object_t **, const char *); +isc_result_t omapi_message_new (omapi_object_t **, const char *, int); isc_result_t omapi_message_set_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *); isc_result_t omapi_message_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **); -isc_result_t omapi_message_destroy (omapi_object_t *, const char *); +isc_result_t omapi_message_destroy (omapi_object_t *, const char *, int); isc_result_t omapi_message_signal_handler (omapi_object_t *, const char *, va_list); isc_result_t omapi_message_stuff_values (omapi_object_t *, @@ -280,7 +282,7 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **, omapi_data_string_t *, omapi_value_t **), isc_result_t (*) (omapi_object_t *, - const char *), + const char *, int), isc_result_t (*) (omapi_object_t *, const char *, va_list), @@ -325,16 +327,16 @@ int omapi_data_string_cmp (omapi_data_string_t *, omapi_data_string_t *); int omapi_ds_strcmp (omapi_data_string_t *, const char *); int omapi_td_strcmp (omapi_typed_data_t *, const char *); isc_result_t omapi_make_value (omapi_value_t **, omapi_data_string_t *, - omapi_typed_data_t *, const char *); + omapi_typed_data_t *, const char *, int); isc_result_t omapi_make_const_value (omapi_value_t **, omapi_data_string_t *, const unsigned char *, - unsigned, const char *); + unsigned, const char *, int); isc_result_t omapi_make_int_value (omapi_value_t **, omapi_data_string_t *, - int, const char *); + int, const char *, int); isc_result_t omapi_make_handle_value (omapi_value_t **, omapi_data_string_t *, - omapi_object_t *, const char *); + omapi_object_t *, const char *, int); isc_result_t omapi_make_string_value (omapi_value_t **, omapi_data_string_t *, - const char *, const char *); + const char *, const char *, int); isc_result_t omapi_get_int_value (unsigned long *, omapi_typed_data_t *); isc_result_t omapi_object_handle (omapi_handle_t *, omapi_object_t *); @@ -342,24 +344,52 @@ isc_result_t omapi_handle_lookup (omapi_object_t **, omapi_handle_t); isc_result_t omapi_handle_td_lookup (omapi_object_t **, omapi_typed_data_t *); isc_result_t omapi_object_reference (omapi_object_t **, - omapi_object_t *, const char *); -isc_result_t omapi_object_dereference (omapi_object_t **, const char *); -isc_result_t omapi_typed_data_new (omapi_typed_data_t **, + omapi_object_t *, const char *, int); +isc_result_t omapi_object_dereference (omapi_object_t **, const char *, int); +isc_result_t omapi_typed_data_new (const char *, int, omapi_typed_data_t **, omapi_datatype_t, ...); isc_result_t omapi_typed_data_reference (omapi_typed_data_t **, - omapi_typed_data_t *, const char *); + omapi_typed_data_t *, + const char *, int); isc_result_t omapi_typed_data_dereference (omapi_typed_data_t **, - const char *); + const char *, int); isc_result_t omapi_data_string_new (omapi_data_string_t **, - unsigned, const char *); + unsigned, const char *, int); isc_result_t omapi_data_string_reference (omapi_data_string_t **, - omapi_data_string_t *, const char *); + omapi_data_string_t *, + const char *, int); isc_result_t omapi_data_string_dereference (omapi_data_string_t **, - const char *); -isc_result_t omapi_value_new (omapi_value_t **, const char *); + const char *, int); +isc_result_t omapi_value_new (omapi_value_t **, const char *, int); isc_result_t omapi_value_reference (omapi_value_t **, - omapi_value_t *, const char *); -isc_result_t omapi_value_dereference (omapi_value_t **, const char *); + omapi_value_t *, const char *, int); +isc_result_t omapi_value_dereference (omapi_value_t **, const char *, int); +void * dmalloc (unsigned, const char *, int); +void dfree (void *, const char *, int); +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) +void dmalloc_reuse (void *, const char *, int, int); +void dmalloc_dump_outstanding (void); +#define MDL __FILE__, __LINE__ +#else +#define dmalloc_reuse(x,y,l,z) +#define MDL (char *)0, __LINE__ +#endif +#if defined (DEBUG_RC_HISTORY) +void dump_rc_history (void); +#endif +extern int log_priority; +extern int log_perror; +extern void (*log_cleanup) (void); + +void log_fatal (const char *, ...) + __attribute__((__format__(__printf__,1,2))); +int log_error (const char *, ...) + __attribute__((__format__(__printf__,1,2))); +int log_info (const char *, ...) + __attribute__((__format__(__printf__,1,2))); +int log_debug (const char *, ...) + __attribute__((__format__(__printf__,1,2))); +void do_percentm (char *obuf, const char *ibuf); #endif /* _OMAPIP_H_ */ diff --git a/includes/site.h b/includes/site.h index 7c6e2d1fb..b2fd32863 100644 --- a/includes/site.h +++ b/includes/site.h @@ -71,17 +71,17 @@ /* Define this if you want debugging output for DHCP failover protocol messages. */ -/* #define DEBUG_FAILOVER_MESSAGES */ +#define DEBUG_FAILOVER_MESSAGES /* Define this if you want debugging output for DHCP failover protocol lease assignment timing. */ -/* #define DEBUG_FAILOVER_TIMING */ +#define DEBUG_FAILOVER_TIMING /* Define this if you want DHCP failover protocol support in the DHCP server. */ -/* #define FAILOVER_PROTOCOL */ +#define FAILOVER_PROTOCOL /* Define this if you want the dhcpd.pid file to go somewhere other than the default (which varies from system to system, but is usually either diff --git a/omapip/Makefile.dist b/omapip/Makefile.dist index 72b3b7a60..5b386ac50 100644 --- a/omapip/Makefile.dist +++ b/omapip/Makefile.dist @@ -19,9 +19,9 @@ CATMANPAGES = omapi.cat3 SEDMANPAGES = omapi.man3 -SRC = protocol.c buffer.c alloc.c result.c connection.c \ +SRC = protocol.c buffer.c alloc.c result.c connection.c errwarn.c \ listener.c dispatch.c generic.c support.c handle.c message.c -OBJ = protocol.o buffer.o alloc.o result.o connection.o \ +OBJ = protocol.o buffer.o alloc.o result.o connection.o errwarn.o \ listener.o dispatch.o generic.o support.o handle.o message.o MAN = omapi.3 diff --git a/omapip/alloc.c b/omapip/alloc.c index d40287bf0..dfa55b679 100644 --- a/omapip/alloc.c +++ b/omapip/alloc.c @@ -4,7 +4,7 @@ protocol... */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -23,6 +23,270 @@ #include +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) +struct dmalloc_preamble *dmalloc_list; +unsigned long dmalloc_outstanding; +unsigned long dmalloc_longterm; +unsigned long dmalloc_generation; +unsigned long dmalloc_cutoff_generation; +#endif + +#if defined (DEBUG_RC_HISTORY) +struct rc_history_entry rc_history [RC_HISTORY_MAX]; +int rc_history_index; +#endif + +VOIDPTR dmalloc (size, file, line) + unsigned size; + const char *file; + int line; +{ + unsigned char *foo = dmalloc (size + DMDSIZE, file, line); + int i; + VOIDPTR *bar; +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) + struct dmalloc_preamble *dp; +#endif + if (!foo) + return (VOIDPTR)0; + bar = (VOIDPTR)(foo + DMDOFFSET); + memset (bar, 0, size); + +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) + dp = (struct dmalloc_preamble *)foo; + dp -> prev = dmalloc_list; + if (dmalloc_list) + dmalloc_list -> next = dp; + dmalloc_list = dp; + dp -> next = (struct dmalloc_preamble *)0; + dp -> size = size; + dp -> file = file; + dp -> line = line; + dp -> generation = dmalloc_generation++; + dmalloc_outstanding += size; + for (i = 0; i < DMLFSIZE; i++) + dp -> low_fence [i] = + (((unsigned long) + (&dp -> low_fence [i])) % 143) + 113; + for (i = DMDOFFSET; i < DMDSIZE; i++) + foo [i + size] = + (((unsigned long) + (&foo [i + size])) % 143) + 113; +#if defined (DEBUG_MALLOC_POOL_EXHAUSTIVELY) + /* Check _every_ entry in the pool! Very expensive. */ + for (dp = dmalloc_list; dp; dp = dp -> prev) { + for (i = 0; i < DMLFSIZE; i++) { + if (dp -> low_fence [i] != + (((unsigned long) + (&dp -> low_fence [i])) % 143) + 113) + { + log_error ("malloc fence modified: %s(%d)", + dp -> file, dp -> line); + abort (); + } + } + foo = (unsigned char *)dp; + for (i = DMDOFFSET; i < DMDSIZE; i++) { + if (foo [i + dp -> size] != + (((unsigned long) + (&foo [i + dp -> size])) % 143) + 113) { + log_error ("malloc fence modified: %s(%d)", + dp -> file, dp -> line); + abort (); + } + } + } +#endif +#endif + return bar; +} + +void dfree (ptr, file, line) + VOIDPTR ptr; + const char *file; + int line; +{ + if (!ptr) { + log_error ("dfree %s(%d): free on null pointer.", file, line); + return; + } +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) + { + unsigned char *bar = ptr; + struct dmalloc_preamble *dp, *cur; + int i; + bar -= DMDOFFSET; + cur = (struct dmalloc_preamble *)bar; + for (dp = dmalloc_list; dp; dp = dp -> prev) + if (dp == cur) + break; + if (!dp) { + log_error ("%s(%d): freeing unknown memory: %lx", + dp -> file, dp -> line, (unsigned long)cur); + abort (); + } + if (dp -> prev) + dp -> prev -> next = dp -> next; + if (dp -> next) + dp -> next -> prev = dp -> prev; + if (dp == dmalloc_list) + dmalloc_list = dp -> prev; + if (dp -> generation >= dmalloc_cutoff_generation) + dmalloc_outstanding -= dp -> size; + else + dmalloc_longterm -= dp -> size; + + for (i = 0; i < DMLFSIZE; i++) { + if (dp -> low_fence [i] != + (((unsigned long) + (&dp -> low_fence [i])) % 143) + 113) + { + log_error ("malloc fence modified: %s(%d)", + dp -> file, dp -> line); + abort (); + } + } + for (i = DMDOFFSET; i < DMDSIZE; i++) { + if (bar [i + dp -> size] != + (((unsigned long) + (&bar [i + dp -> size])) % 143) + 113) { + log_error ("malloc fence modified: %s(%d)", + dp -> file, dp -> line); + abort (); + } + } + ptr = bar; + } +#endif + free (ptr); +} + +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) +/* For allocation functions that keep their own free lists, we want to + account for the reuse of the memory. */ + +void dmalloc_reuse (foo, file, line, justref) + VOIDPTR foo; + const char *file; + int line; + int justref; +{ + struct dmalloc_preamble *dp; + + /* Get the pointer to the dmalloc header. */ + dp = foo; + dp--; + + /* If we just allocated this and are now referencing it, this + function would almost be a no-op, except that it would + increment the generation count needlessly. So just return + in this case. */ + if (dp -> generation == dmalloc_generation) + return; + + /* If this is longterm data, and we just made reference to it, + don't put it on the short-term list or change its name - + we don't need to know about this. */ + if (dp -> generation < dmalloc_cutoff_generation && justref) + return; + + /* Take it out of the place in the allocated list where it was. */ + if (dp -> prev) + dp -> prev -> next = dp -> next; + if (dp -> next) + dp -> next -> prev = dp -> prev; + if (dp == dmalloc_list) + dmalloc_list = dp -> prev; + + /* Account for its removal. */ + if (dp -> generation >= dmalloc_cutoff_generation) + dmalloc_outstanding -= dp -> size; + else + dmalloc_longterm -= dp -> size; + + /* Now put it at the head of the list. */ + dp -> prev = dmalloc_list; + if (dmalloc_list) + dmalloc_list -> next = dp; + dmalloc_list = dp; + dp -> next = (struct dmalloc_preamble *)0; + + /* Change the reference location information. */ + dp -> file = file; + dp -> line = line; + + /* Increment the generation. */ + dp -> generation = dmalloc_generation++; + + /* Account for it. */ + dmalloc_outstanding += dp -> size; +} + +void dmalloc_dump_outstanding () +{ + static unsigned long dmalloc_cutoff_point; + struct dmalloc_preamble *dp; + unsigned char *foo; + int i; + + if (!dmalloc_cutoff_point) + dmalloc_cutoff_point = dmalloc_cutoff_generation; + for (dp = dmalloc_list; dp; dp = dp -> prev) { + if (dp -> generation <= dmalloc_cutoff_point) + break; +#if defined (DEBUG_MALLOC_POOL) + for (i = 0; i < DMLFSIZE; i++) { + if (dp -> low_fence [i] != + (((unsigned long) + (&dp -> low_fence [i])) % 143) + 113) + { + log_error ("malloc fence modified: %s(%d)", + dp -> file, dp -> line); + abort (); + } + } + foo = (unsigned char *)dp; + for (i = DMDOFFSET; i < DMDSIZE; i++) { + if (foo [i + dp -> size] != + (((unsigned long) + (&foo [i + dp -> size])) % 143) + 113) { + log_error ("malloc fence modified: %s(%d)", + dp -> file, dp -> line); + abort (); + } + } +#endif +#if defined (DEBUG_MEMORY_LEAKAGE) + /* Don't count data that's actually on a free list + somewhere. */ + if (dp -> file) + log_info (" %s(%d): %d", + dp -> file, dp -> line, dp -> size); +#endif + } + if (dmalloc_list) + dmalloc_cutoff_point = dmalloc_list -> generation; +} +#endif /* DEBUG_MEMORY_LEAKAGE || DEBUG_MALLOC_POOL */ + +#if defined (DEBUG_RC_HISTORY) +void dump_rc_history () +{ + int i; + + i = rc_history_index; + do { + log_info (" referenced by %s(%d): addr = %lx refcnt = %x\n", + rc_history [i].file, rc_history [i].line, + (unsigned long)rc_history [i].addr, + rc_history [i].refcnt); + ++i; + if (i == RC_HISTORY_MAX) + i = 0; + } while (i != rc_history_index && rc_history [i].file); +} +#endif + isc_result_t omapi_object_reference (omapi_object_t **r, omapi_object_t *h, const char *file, int line) @@ -46,7 +310,7 @@ isc_result_t omapi_object_reference (omapi_object_t **r, } isc_result_t omapi_object_dereference (omapi_object_t **h, - const char *name) + const char *file, int line) { int outer_reference = 0; int inner_reference = 0; @@ -59,7 +323,7 @@ isc_result_t omapi_object_dereference (omapi_object_t **h, if (!*h) { #if defined (ALLOCATION_DEBUGGING) - abort ("%s: dereference of null pointer!", name); + abort ("%s(%d): dereference of null pointer!", file, line); #else return ISC_R_INVALIDARG; #endif @@ -67,7 +331,8 @@ isc_result_t omapi_object_dereference (omapi_object_t **h, if ((*h) -> refcnt <= 0) { #if defined (ALLOCATION_DEBUGGING) - abort ("dereference of pointer with refcnt of zero!"); + abort ("%s(%d): dereference of pointer with refcnt of zero!", + file, line); #else return ISC_R_INVALIDARG; #endif @@ -184,7 +449,7 @@ isc_result_t omapi_buffer_reference (omapi_buffer_t **r, } isc_result_t omapi_buffer_dereference (omapi_buffer_t **h, - const char *name) + const char *file, int line) { if (!h) return ISC_R_INVALIDARG; @@ -213,7 +478,8 @@ isc_result_t omapi_buffer_dereference (omapi_buffer_t **h, return ISC_R_SUCCESS; } -isc_result_t omapi_typed_data_new (omapi_typed_data_t **t, +isc_result_t omapi_typed_data_new (const char *file, int line, + omapi_typed_data_t **t, omapi_datatype_t type, ...) { va_list l; @@ -223,8 +489,6 @@ isc_result_t omapi_typed_data_new (omapi_typed_data_t **t, int intval; char *s; isc_result_t status; - const char *file; - int line; omapi_object_t *obj; va_start (l, type); @@ -251,10 +515,6 @@ isc_result_t omapi_typed_data_new (omapi_typed_data_t **t, return ISC_R_INVALIDARG; } - /* XXX not necessary if not doing malloc debugging. */ - file = va_arg (l, const char *); - line = va_arg (l, int); - new = dmalloc (len, file, line); if (!new) return ISC_R_NOMEMORY; @@ -307,14 +567,14 @@ isc_result_t omapi_typed_data_reference (omapi_typed_data_t **r, } isc_result_t omapi_typed_data_dereference (omapi_typed_data_t **h, - const char *file, line) + const char *file, int line) { if (!h) return ISC_R_INVALIDARG; if (!*h) { #if defined (ALLOCATION_DEBUGGING) - abort ("%s: dereference of null pointer!", name); + abort ("%s(%d): dereference of null pointer!", file, line); #else return ISC_R_INVALIDARG; #endif @@ -322,7 +582,8 @@ isc_result_t omapi_typed_data_dereference (omapi_typed_data_t **h, if ((*h) -> refcnt <= 0) { #if defined (ALLOCATION_DEBUGGING) - abort ("dereference of pointer with refcnt of zero!"); + abort ("%s(%d): dereference of pointer with refcnt of zero!", + file, line); #else return ISC_R_INVALIDARG; #endif @@ -363,7 +624,7 @@ isc_result_t omapi_data_string_new (omapi_data_string_t **d, unsigned len, isc_result_t omapi_data_string_reference (omapi_data_string_t **r, omapi_data_string_t *h, - const char *file, line) + const char *file, int line) { if (!h || !r) return ISC_R_INVALIDARG; @@ -383,7 +644,7 @@ isc_result_t omapi_data_string_reference (omapi_data_string_t **r, } isc_result_t omapi_data_string_dereference (omapi_data_string_t **h, - const char *file, line) + const char *file, int line) { if (!h) return ISC_R_INVALIDARG; @@ -406,7 +667,7 @@ isc_result_t omapi_data_string_dereference (omapi_data_string_t **h, } --((*h) -> refcnt); - rc_register (file, line, h, h -> refcnt); + rc_register (file, line, h, (*h) -> refcnt); if ((*h) -> refcnt <= 0 ) { dfree (*h, file, line); } @@ -428,7 +689,7 @@ isc_result_t omapi_value_new (omapi_value_t **d, isc_result_t omapi_value_reference (omapi_value_t **r, omapi_value_t *h, - const char *file, line) + const char *file, int line) { if (!h || !r) return ISC_R_INVALIDARG; @@ -449,7 +710,7 @@ isc_result_t omapi_value_reference (omapi_value_t **r, } isc_result_t omapi_value_dereference (omapi_value_t **h, - const char *name) + const char *file, int line) { if (!h) return ISC_R_INVALIDARG; @@ -472,12 +733,14 @@ isc_result_t omapi_value_dereference (omapi_value_t **h, } --((*h) -> refcnt); - rc_register (file, line, h, h -> refcnt); + rc_register (file, line, h, (*h) -> refcnt); if ((*h) -> refcnt <= 0 ) { if ((*h) -> name) - omapi_data_string_dereference (&(*h) -> name, name); + omapi_data_string_dereference (&(*h) -> name, + file, line); if ((*h) -> value) - omapi_typed_data_dereference (&(*h) -> value, name); + omapi_typed_data_dereference (&(*h) -> value, + file, line); dfree (*h, file, line); } *h = 0; diff --git a/omapip/buffer.c b/omapip/buffer.c index 80e60e56b..3ca60daf0 100644 --- a/omapip/buffer.c +++ b/omapip/buffer.c @@ -52,15 +52,13 @@ isc_result_t omapi_connection_reader (omapi_object_t *h) buffer = buffer -> next) ; if (!BUFFER_BYTES_FREE (buffer)) { - status = omapi_buffer_new (&buffer -> next, - "omapi_private_read"); + status = omapi_buffer_new (&buffer -> next, MDL); if (status != ISC_R_SUCCESS) return status; buffer = buffer -> next; } } else { - status = omapi_buffer_new (&c -> inbufs, - "omapi_private_read"); + status = omapi_buffer_new (&c -> inbufs, MDL); if (status != ISC_R_SUCCESS) return status; buffer = c -> inbufs; @@ -134,8 +132,7 @@ isc_result_t omapi_connection_copyin (omapi_object_t *h, buffer -> next; buffer = buffer -> next) ; } else { - status = omapi_buffer_new (&c -> outbufs, - "omapi_private_buffer_copyin"); + status = omapi_buffer_new (&c -> outbufs, MDL); if (status != ISC_R_SUCCESS) return status; buffer = c -> outbufs; @@ -145,9 +142,7 @@ isc_result_t omapi_connection_copyin (omapi_object_t *h, /* If there is no space available in this buffer, allocate a new one. */ if (!BUFFER_BYTES_FREE (buffer)) { - status = (omapi_buffer_new - (&buffer -> next, - "omapi_private_buffer_copyin")); + status = (omapi_buffer_new (&buffer -> next, MDL)); if (status != ISC_R_SUCCESS) return status; buffer = buffer -> next; @@ -233,22 +228,15 @@ isc_result_t omapi_connection_copyout (unsigned char *buf, while (c -> inbufs && !BYTES_IN_BUFFER (c -> inbufs)) { if (c -> inbufs -> next) { - omapi_buffer_reference - (&buffer, - c -> inbufs -> next, - "omapi_private_buffer_copyout"); - omapi_buffer_dereference - (&c -> inbufs -> next, - "omapi_private_buffer_copyout"); + omapi_buffer_reference (&buffer, + c -> inbufs -> next, MDL); + omapi_buffer_dereference (&c -> inbufs -> next, MDL); } - omapi_buffer_dereference (&c -> inbufs, - "omapi_private_buffer_copyout"); + omapi_buffer_dereference (&c -> inbufs, MDL); if (buffer) { omapi_buffer_reference - (&c -> inbufs, buffer, - "omapi_private_buffer_copyout"); - omapi_buffer_dereference - (&buffer, "omapi_private_buffer_copyout"); + (&c -> inbufs, buffer, MDL); + omapi_buffer_dereference (&buffer, MDL); } } return ISC_R_SUCCESS; @@ -336,19 +324,14 @@ isc_result_t omapi_connection_writer (omapi_object_t *h) while (c -> outbufs && !BYTES_IN_BUFFER (c -> outbufs)) { if (c -> outbufs -> next) { - omapi_buffer_reference - (&buffer, c -> outbufs -> next, - "omapi_private_flush"); - omapi_buffer_dereference - (&c -> outbufs -> next, "omapi_private_flush"); + omapi_buffer_reference (&buffer, + c -> outbufs -> next, MDL); + omapi_buffer_dereference (&c -> outbufs -> next, MDL); } - omapi_buffer_dereference (&c -> outbufs, - "omapi_private_flush"); + omapi_buffer_dereference (&c -> outbufs, MDL); if (buffer) { - omapi_buffer_reference (&c -> outbufs, buffer, - "omapi_private_flush"); - omapi_buffer_dereference (&buffer, - "omapi_private_flush"); + omapi_buffer_reference (&c -> outbufs, buffer, MDL); + omapi_buffer_dereference (&buffer, MDL); } } return ISC_R_SUCCESS; diff --git a/omapip/connection.c b/omapip/connection.c index 01ef90997..7e2b26bb1 100644 --- a/omapip/connection.c +++ b/omapip/connection.c @@ -3,7 +3,7 @@ Subroutines for dealing with connections. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -33,25 +33,23 @@ isc_result_t omapi_connect (omapi_object_t *c, omapi_connection_object_t *obj; int flag; - obj = (omapi_connection_object_t *)malloc (sizeof *obj); + obj = (omapi_connection_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; + rc_register_mdl (obj, obj -> refcnt); obj -> type = omapi_type_connection; status = omapi_object_reference (&c -> outer, (omapi_object_t *)obj, - "omapi_protocol_connect"); + MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&obj -> inner, c, - "omapi_protocol_connect"); + status = omapi_object_reference (&obj -> inner, c, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -65,7 +63,7 @@ isc_result_t omapi_connect (omapi_object_t *c, he = gethostbyname (server_name); if (!he) { omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + MDL); return ISC_R_HOSTUNKNOWN; } hix = 1; @@ -87,8 +85,7 @@ isc_result_t omapi_connect (omapi_object_t *c, obj -> socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (obj -> socket < 0) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); if (errno == EMFILE || errno == ENFILE || errno == ENOBUFS) return ISC_R_NORESOURCES; return ISC_R_UNEXPECTED; @@ -97,8 +94,7 @@ isc_result_t omapi_connect (omapi_object_t *c, #if defined (HAVE_SETFD) if (fcntl (obj -> socket, F_SETFD, 1) < 0) { close (obj -> socket); - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } #endif @@ -107,8 +103,7 @@ isc_result_t omapi_connect (omapi_object_t *c, flag = 1; if (setsockopt (obj -> socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof flag) < 0) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } @@ -120,7 +115,7 @@ isc_result_t omapi_connect (omapi_object_t *c, sizeof obj -> remote_addr)) { if (!he || !he -> h_addr_list [hix]) { omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + MDL); if (errno == ECONNREFUSED) return ISC_R_CONNREFUSED; if (errno == ENETUNREACH) @@ -143,8 +138,7 @@ isc_result_t omapi_connect (omapi_object_t *c, } if (fcntl (obj -> socket, F_SETFL, O_NONBLOCK) < 0) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } @@ -155,8 +149,7 @@ isc_result_t omapi_connect (omapi_object_t *c, omapi_connection_writer, omapi_connection_reaper); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -198,7 +191,7 @@ isc_result_t omapi_disconnect (omapi_object_t *h, /* Disconnect from I/O object, if any. */ if (h -> outer) - omapi_object_dereference (&h -> outer, "omapi_disconnect"); + omapi_object_dereference (&h -> outer, MDL); /* If whatever created us registered a signal handler, send it a disconnect signal. */ @@ -302,7 +295,8 @@ isc_result_t omapi_connection_get_value (omapi_object_t *h, return ISC_R_NOTFOUND; } -isc_result_t omapi_connection_destroy (omapi_object_t *h, const char *name) +isc_result_t omapi_connection_destroy (omapi_object_t *h, + const char *file, int line) { omapi_connection_object_t *c; @@ -312,7 +306,7 @@ isc_result_t omapi_connection_destroy (omapi_object_t *h, const char *name) if (c -> state == omapi_connection_connected) omapi_disconnect (h, 1); if (c -> listener) - omapi_object_dereference (&c -> listener, name); + omapi_object_dereference (&c -> listener, file, line); return ISC_R_SUCCESS; } diff --git a/omapip/dispatch.c b/omapip/dispatch.c index 659f998a2..6f48a8e0e 100644 --- a/omapip/dispatch.c +++ b/omapip/dispatch.c @@ -3,7 +3,7 @@ I/O dispatcher. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -50,27 +50,24 @@ isc_result_t omapi_register_io_object (omapi_object_t *h, omapi_io_states.type = omapi_type_io_object; } - obj = malloc (sizeof *obj); + obj = dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); - obj -> refcnt = 1; + rc_register_mdl (obj, obj -> refcnt); obj -> type = omapi_type_io_object; - status = omapi_object_reference (&obj -> inner, h, - "omapi_register_io_object"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_register_io_object"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "omapi_register_io_object"); + status = omapi_object_reference (&h -> outer, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_register_io_object"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -105,11 +102,12 @@ isc_result_t omapi_wait_for_completion (omapi_object_t *object, omapi_object_t *inner; if (object) { - waiter = malloc (sizeof *waiter); + waiter = dmalloc (sizeof *waiter, MDL); if (!waiter) return ISC_R_NOMEMORY; memset (waiter, 0, sizeof *waiter); waiter -> refcnt = 1; + rc_register_mdl (waiter, waiter -> refcnt); waiter -> type = omapi_type_waiter; /* Paste the waiter object onto the inner object we're @@ -117,20 +115,19 @@ isc_result_t omapi_wait_for_completion (omapi_object_t *object, for (inner = object; inner -> inner; inner = inner -> inner) ; - status = omapi_object_reference (&waiter -> outer, inner, - "omapi_wait_for_completion"); + status = omapi_object_reference (&waiter -> outer, inner, MDL); if (status != ISC_R_SUCCESS) { omapi_object_dereference ((omapi_object_t **)&waiter, - "omapi_wait_for_completion"); + MDL); return status; } status = omapi_object_reference (&inner -> inner, (omapi_object_t *)waiter, - "omapi_wait_for_completion"); + MDL); if (status != ISC_R_SUCCESS) { omapi_object_dereference ((omapi_object_t **)&waiter, - "omapi_wait_for_completion"); + MDL); return status; } } else @@ -145,22 +142,18 @@ isc_result_t omapi_wait_for_completion (omapi_object_t *object, if (waiter -> outer) { if (waiter -> outer -> inner) { omapi_object_dereference (&waiter -> outer -> inner, - "omapi_wait_for_completion"); + MDL); if (waiter -> inner) omapi_object_reference (&waiter -> outer -> inner, - waiter -> inner, - "omapi_wait_for_completion"); + waiter -> inner, MDL); } - omapi_object_dereference (&waiter -> outer, - "omapi_wait_for_completion"); + omapi_object_dereference (&waiter -> outer, MDL); } if (waiter -> inner) - omapi_object_dereference (&waiter -> inner, - "omapi_wait_for_completion"); + omapi_object_dereference (&waiter -> inner, MDL); - omapi_object_dereference ((omapi_object_t **)&waiter, - "omapi_wait_for_completion"); + omapi_object_dereference ((omapi_object_t **)&waiter, MDL); return ISC_R_SUCCESS; } @@ -280,28 +273,28 @@ isc_result_t omapi_one_dispatch (omapi_object_t *wo, omapi_object_reference ((omapi_object_t **)&tmp, (omapi_object_t *)io -> next, - "omapi_wfc"); + MDL); if (prev) { omapi_object_dereference (((omapi_object_t **) - &prev -> next), "omapi_wfc"); + &prev -> next), MDL); if (tmp) omapi_object_reference (((omapi_object_t **) &prev -> next), (omapi_object_t *)tmp, - "omapi_wfc"); + MDL); } else { omapi_object_dereference (((omapi_object_t **) &omapi_io_states.next), - "omapi_wfc"); + MDL); if (tmp) omapi_object_reference (((omapi_object_t **) &omapi_io_states.next), (omapi_object_t *)tmp, - "omapi_wfc"); + MDL); else omapi_signal_in ((omapi_object_t *) @@ -310,8 +303,7 @@ isc_result_t omapi_one_dispatch (omapi_object_t *wo, } if (tmp) omapi_object_dereference - ((omapi_object_t **)&tmp, - "omapi_wfc"); + ((omapi_object_t **)&tmp, MDL); } } prev = io; @@ -348,7 +340,7 @@ isc_result_t omapi_io_get_value (omapi_object_t *h, return ISC_R_NOTFOUND; } -isc_result_t omapi_io_destroy (omapi_object_t *h, const char *name) +isc_result_t omapi_io_destroy (omapi_object_t *h, const char *file, int line) { if (h -> type != omapi_type_io_object) return ISC_R_INVALIDARG; diff --git a/omapip/errwarn.c b/omapip/errwarn.c index c55a2dfe0..018a6399c 100644 --- a/omapip/errwarn.c +++ b/omapip/errwarn.c @@ -4,7 +4,7 @@ /* * Copyright (c) 1995 RadioMail Corporation. - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you @@ -29,13 +29,19 @@ #ifndef lint static char copyright[] = -"$Id: errwarn.c,v 1.1 2000/01/25 20:41:45 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: errwarn.c,v 1.2 2000/01/26 14:56:05 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ -#include "dhcpd.h" +#include #include -static void do_percentm PROTO ((char *obuf, const char *ibuf)); +#ifdef DEBUG +int log_perror = -1; +#else +int log_perror = 1; +#endif +int log_priority; +void (*log_cleanup) (void); static char mbuf [1024]; static char fbuf [1024]; @@ -69,7 +75,8 @@ void log_fatal (ANSI_DECL(const char *) fmt, VA_DOTDOTDOT) fprintf (stderr, "exiting.\n"); fflush (stderr); } - cleanup (); + if (log_cleanup) + (*log_cleanup) (); exit (1); } @@ -153,7 +160,7 @@ int log_debug (ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) /* Find %m in the input string and substitute an error message string. */ -static void do_percentm (obuf, ibuf) +void do_percentm (obuf, ibuf) char *obuf; const char *ibuf; { @@ -193,66 +200,6 @@ static void do_percentm (obuf, ibuf) *p = 0; } - -int parse_warn (ANSI_DECL (struct parse *)cfile, - ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) - KandR (struct parse *cfile;) - KandR (char *fmt;) - va_dcl -{ - va_list list; - static char spaces [] = " "; - char lexbuf [256]; - unsigned i, lix; - - do_percentm (mbuf, fmt); -#ifndef NO_SNPRINTF - snprintf (fbuf, sizeof fbuf, "%s line %d: %s", - cfile -> tlname, cfile -> lexline, mbuf); -#else - sprintf (fbuf, "%s line %d: %s", - cfile -> tlname, cfile -> lexline, mbuf); -#endif - - VA_start (list, fmt); - vsnprintf (mbuf, sizeof mbuf, fbuf, list); - va_end (list); - - lix = 0; - for (i = 0; - cfile -> token_line [i] && i < (cfile -> lexchar - 1); i++) { - if (lix < (sizeof lexbuf) - 1) - lexbuf [lix++] = ' '; - if (cfile -> token_line [i] == '\t') { - for (lix; - lix < (sizeof lexbuf) - 1 && (lix & 7); lix++) - lexbuf [lix] = ' '; - } - } - lexbuf [lix] = 0; - -#ifndef DEBUG - syslog (log_priority | LOG_ERR, mbuf); - syslog (log_priority | LOG_ERR, cfile -> token_line); - if (cfile -> lexchar < 81) - syslog (log_priority | LOG_ERR, "%s^", lexbuf); -#endif - - if (log_perror) { - write (2, mbuf, strlen (mbuf)); - write (2, "\n", 1); - write (2, cfile -> token_line, strlen (cfile -> token_line)); - write (2, "\n", 1); - if (cfile -> lexchar < 81) - write (2, lexbuf, lix); - write (2, "^\n", 2); - } - - cfile -> warnings_occurred = 1; - - return 0; -} - #ifdef NO_STRERROR char *strerror (err) int err; diff --git a/omapip/generic.c b/omapip/generic.c index ad63b9216..a3f69f240 100644 --- a/omapip/generic.c +++ b/omapip/generic.c @@ -3,7 +3,7 @@ Subroutines that support the generic object. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -22,18 +22,19 @@ #include -isc_result_t omapi_generic_new (omapi_object_t **gen, const char *name) +isc_result_t omapi_generic_new (omapi_object_t **gen, + const char *file, int line) { omapi_generic_object_t *obj; - obj = malloc (sizeof *obj); + obj = dmalloc (sizeof *obj, file, line); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 0; obj -> type = omapi_type_generic; - return omapi_object_reference (gen, (omapi_object_t *)obj, name); + return omapi_object_reference (gen, (omapi_object_t *)obj, file, line); } isc_result_t omapi_generic_set_value (omapi_object_t *h, @@ -71,25 +72,18 @@ isc_result_t omapi_generic_set_value (omapi_object_t *h, maps to a name/null pair, ISC_R_NOTFOUND is returned. */ new = (omapi_value_t *)0; - status = (omapi_value_new (&new, - "omapi_message_get_value")); + status = (omapi_value_new (&new, MDL)); if (status != ISC_R_SUCCESS) return status; - omapi_data_string_reference - (&new -> name, name, - "omapi_message_get_value"); + omapi_data_string_reference (&new -> name, name, MDL); if (value) - omapi_typed_data_reference - (&new -> value, value, - "omapi_generic_set_value"); + omapi_typed_data_reference (&new -> value, + value, MDL); - omapi_value_dereference (&(g -> values [i]), - "omapi_message_set_value"); + omapi_value_dereference (&(g -> values [i]), MDL); status = (omapi_value_reference - (&(g -> values [i]), new, - "omapi_message_set_value")); - omapi_value_dereference (&new, - "omapi_message_set_value"); + (&(g -> values [i]), new, MDL)); + omapi_value_dereference (&new, MDL); return status; } } @@ -116,27 +110,25 @@ isc_result_t omapi_generic_set_value (omapi_object_t *h, vm_new = 2 * g -> va_max; else vm_new = 10; - va = malloc (vm_new * sizeof *va); + va = dmalloc (vm_new * sizeof *va, MDL); if (!va) return ISC_R_NOMEMORY; if (g -> va_max) memcpy (va, g -> values, g -> va_max * sizeof *va); memset (va + g -> va_max, 0, (vm_new - g -> va_max) * sizeof *va); - free (g -> values); + dfree (g -> values, MDL); g -> values = va; g -> va_max = vm_new; } - status = omapi_value_new (&g -> values [g -> nvalues], - "omapi_generic_set_value"); + status = omapi_value_new (&g -> values [g -> nvalues], MDL); if (status != ISC_R_SUCCESS) return status; - omapi_data_string_reference (&g -> values [g -> nvalues] -> name, name, - "omapi_generic_set_value"); + omapi_data_string_reference (&g -> values [g -> nvalues] -> name, + name, MDL); if (value) omapi_typed_data_reference - (&g -> values [g -> nvalues] -> value, value, - "omapi_generic_set_value"); + (&g -> values [g -> nvalues] -> value, value, MDL); g -> nvalues++; return ISC_R_SUCCESS; } @@ -162,9 +154,8 @@ isc_result_t omapi_generic_get_value (omapi_object_t *h, if (!g -> values [i] -> value) return ISC_R_NOTFOUND; /* Otherwise, return the name/value pair. */ - return omapi_value_reference - (value, g -> values [i], - "omapi_message_get_value"); + return omapi_value_reference (value, + g -> values [i], MDL); } } @@ -174,7 +165,8 @@ isc_result_t omapi_generic_get_value (omapi_object_t *h, return ISC_R_NOTFOUND; } -isc_result_t omapi_generic_destroy (omapi_object_t *h, const char *name) +isc_result_t omapi_generic_destroy (omapi_object_t *h, + const char *file, int line) { omapi_generic_object_t *g; int i; @@ -187,9 +179,9 @@ isc_result_t omapi_generic_destroy (omapi_object_t *h, const char *name) for (i = 0; i < g -> nvalues; i++) { if (g -> values [i]) omapi_value_dereference (&g -> values [i], - name); + file, line); } - free (g -> values); + dfree (g -> values, file, line); g -> values = (omapi_value_t **)0; g -> va_max = 0; } diff --git a/omapip/handle.c b/omapip/handle.c index 9c0154149..23a4aaa54 100644 --- a/omapip/handle.c +++ b/omapip/handle.c @@ -68,7 +68,7 @@ isc_result_t omapi_object_handle (omapi_handle_t *h, omapi_object_t *o) } if (!omapi_handle_table) { - omapi_handle_table = malloc (sizeof *omapi_handle_table); + omapi_handle_table = dmalloc (sizeof *omapi_handle_table, MDL); if (!omapi_handle_table) return ISC_R_NOMEMORY; memset (omapi_handle_table, 0, sizeof *omapi_handle_table); @@ -86,7 +86,7 @@ isc_result_t omapi_object_handle (omapi_handle_t *h, omapi_object_t *o) while (omapi_next_handle >= omapi_handle_table -> limit) { omapi_handle_table_t *new; - new = malloc (sizeof *new); + new = dmalloc (sizeof *new, MDL); if (!new) return ISC_R_NOMEMORY; memset (new, 0, sizeof *new); @@ -140,7 +140,7 @@ static isc_result_t omapi_object_handle_in_table (omapi_handle_t h, if (table -> leafp) { status = (omapi_object_reference (&table -> children [h - table -> first].object, - o, "omapi_object_handle_in_table")); + o, MDL)); if (status != ISC_R_SUCCESS) return status; o -> handle = h; @@ -161,7 +161,7 @@ static isc_result_t omapi_object_handle_in_table (omapi_handle_t h, /* If there is no more direct table than this one in the slot we came up with, make one. */ if (!inner) { - inner = malloc (sizeof *inner); + inner = dmalloc (sizeof *inner, MDL); if (!inner) return ISC_R_NOMEMORY; memset (inner, 0, sizeof *inner); @@ -211,7 +211,7 @@ static isc_result_t omapi_handle_table_enclose (omapi_handle_table_t **table) we are allocating sequentially. */ index = (base - inner -> first) / OMAPI_HANDLE_TABLE_SIZE; - new = malloc (sizeof *new); + new = dmalloc (sizeof *new, MDL); if (!new) return ISC_R_NOMEMORY; memset (new, 0, sizeof *new); @@ -247,7 +247,7 @@ static isc_result_t omapi_handle_lookup_in (omapi_object_t **o, return ISC_R_NOTFOUND; return omapi_object_reference (o, table -> children [h - table -> first].object, - "omapi_handle_lookup_in"); + MDL); } /* Scale is the number of handles represented by each child of this diff --git a/omapip/listener.c b/omapip/listener.c index dba434a69..a6ecab866 100644 --- a/omapip/listener.c +++ b/omapip/listener.c @@ -32,26 +32,24 @@ isc_result_t omapi_listen (omapi_object_t *h, omapi_listener_object_t *obj; /* Get the handle. */ - obj = (omapi_listener_object_t *)malloc (sizeof *obj); + obj = (omapi_listener_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; + rc_register_mdl (obj, obj -> refcnt); obj -> type = omapi_type_listener; /* Connect this object to the inner object. */ - status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "omapi_protocol_listen"); + status = omapi_object_reference (&h -> outer, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&obj -> inner, h, - "omapi_protocol_listen"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -62,8 +60,7 @@ isc_result_t omapi_listen (omapi_object_t *h, /* Create a socket on which to listen. */ obj -> socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (!obj -> socket) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); if (errno == EMFILE || errno == ENFILE || errno == ENOBUFS) return ISC_R_NORESOURCES; return ISC_R_UNEXPECTED; @@ -72,8 +69,7 @@ isc_result_t omapi_listen (omapi_object_t *h, #if defined (HAVE_SETFD) if (fcntl (obj -> socket, F_SETFD, 1) < 0) { close (obj -> socket); - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } #endif @@ -82,8 +78,7 @@ isc_result_t omapi_listen (omapi_object_t *h, we were given. */ if (bind (obj -> socket, (struct sockaddr *)&obj -> address, sizeof obj -> address)) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); if (errno == EADDRINUSE) return ISC_R_ADDRNOTAVAIL; if (errno == EPERM) @@ -93,14 +88,12 @@ isc_result_t omapi_listen (omapi_object_t *h, /* Now tell the kernel to listen for connections. */ if (listen (obj -> socket, max)) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } if (fcntl (obj -> socket, F_SETFL, O_NONBLOCK) < 0) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } @@ -108,8 +101,7 @@ isc_result_t omapi_listen (omapi_object_t *h, omapi_listener_readfd, 0, omapi_accept, 0, 0); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -142,11 +134,12 @@ isc_result_t omapi_accept (omapi_object_t *h) listener = (omapi_listener_object_t *)h; /* Get the handle. */ - obj = (omapi_connection_object_t *)malloc (sizeof *obj); + obj = (omapi_connection_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; + rc_register_mdl (obj, obj -> refcnt); obj -> type = omapi_type_connection; /* Accept the connection. */ @@ -156,8 +149,7 @@ isc_result_t omapi_accept (omapi_object_t *h) ((struct sockaddr *) &(obj -> remote_addr)), &len); if (obj -> socket < 0) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_accept"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); if (errno == EMFILE || errno == ENFILE || errno == ENOBUFS) return ISC_R_NORESOURCES; return ISC_R_UNEXPECTED; @@ -172,19 +164,18 @@ isc_result_t omapi_accept (omapi_object_t *h) omapi_connection_writer, omapi_connection_reaper); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_accept"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - omapi_object_reference (&obj -> listener, (omapi_object_t *)listener, - "omapi_accept"); + omapi_object_reference (&obj -> listener, + (omapi_object_t *)listener, MDL); status = omapi_signal (h, "connect", obj); /* Lose our reference to the connection, so it'll be gc'd when it's reaped. */ - omapi_object_dereference ((omapi_object_t **)&obj, "omapi_accept"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -216,7 +207,8 @@ isc_result_t omapi_listener_get_value (omapi_object_t *h, return ISC_R_NOTFOUND; } -isc_result_t omapi_listener_destroy (omapi_object_t *h, const char *name) +isc_result_t omapi_listener_destroy (omapi_object_t *h, + const char *file, int line) { omapi_listener_object_t *l; diff --git a/omapip/message.c b/omapip/message.c index 2eb18adf5..962b127e5 100644 --- a/omapip/message.c +++ b/omapip/message.c @@ -30,23 +30,24 @@ isc_result_t omapi_message_new (omapi_object_t **o, const char *file, int line) omapi_object_t *g; isc_result_t status; - m = malloc (sizeof *m); + m = dmalloc (sizeof *m, file, line); if (!m) return ISC_R_NOMEMORY; memset (m, 0, sizeof *m); m -> type = omapi_type_message; + rc_register (file, line, m, m -> refcnt); m -> refcnt = 1; g = (omapi_object_t *)0; status = omapi_generic_new (&g, file, line); if (status != ISC_R_SUCCESS) { - free (m); + dfree (m, file, line); return status; } status = omapi_object_reference (&m -> inner, g, file, line); if (status != ISC_R_SUCCESS) { omapi_object_dereference ((omapi_object_t **)&m, file, line); - omapi_object_dereference (&g, name); + omapi_object_dereference (&g, file, line); return status; } status = omapi_object_reference (&g -> outer, @@ -54,7 +55,7 @@ isc_result_t omapi_message_new (omapi_object_t **o, const char *file, int line) if (status != ISC_R_SUCCESS) { omapi_object_dereference ((omapi_object_t **)&m, file, line); - omapi_object_dereference (&g, name); + omapi_object_dereference (&g, file, line); return status; } @@ -84,28 +85,24 @@ isc_result_t omapi_message_set_value (omapi_object_t *h, /* Can set authenticator, but the value must be typed data. */ if (!omapi_ds_strcmp (name, "authenticator")) { if (m -> authenticator) - omapi_typed_data_dereference - (&m -> authenticator, MDL); - omapi_typed_data_reference (&m -> authenticator, - value, MDL); + omapi_typed_data_dereference (&m -> authenticator, + MDL); + omapi_typed_data_reference (&m -> authenticator, value, MDL); return ISC_R_SUCCESS; } else if (!omapi_ds_strcmp (name, "object")) { if (value -> type != omapi_datatype_object) return ISC_R_INVALIDARG; if (m -> object) - omapi_object_dereference - (&m -> object, MDL); - omapi_object_reference (&m -> object, - value -> u.object, MDL); + omapi_object_dereference (&m -> object, MDL); + omapi_object_reference (&m -> object, value -> u.object, MDL); return ISC_R_SUCCESS; } else if (!omapi_ds_strcmp (name, "notify-object")) { if (value -> type != omapi_datatype_object) return ISC_R_INVALIDARG; if (m -> notify_object) - omapi_object_dereference - (&m -> notify_object, MDL); + omapi_object_dereference (&m -> notify_object, MDL); omapi_object_reference (&m -> notify_object, value -> u.object, MDL); return ISC_R_SUCCESS; @@ -205,7 +202,7 @@ isc_result_t omapi_message_destroy (omapi_object_t *h, omapi_message_object_t *m; if (h -> type != omapi_type_message) return ISC_R_INVALIDARG; - m = (omapi_message_object *)h; + m = (omapi_message_object_t *)h; if (m -> authenticator) { omapi_typed_data_dereference (&m -> authenticator, file, line); } @@ -276,18 +273,16 @@ isc_result_t omapi_message_register (omapi_object_t *mo) if (omapi_registered_messages) { omapi_object_reference ((omapi_object_t **)&m -> next, - (omapi_object_t *)omapi_registered_messages, - file, line); + (omapi_object_t *)omapi_registered_messages, MDL); omapi_object_reference ((omapi_object_t **)&omapi_registered_messages -> prev, - (omapi_object_t *)m, file, line); + (omapi_object_t *)m, MDL); omapi_object_dereference - ((omapi_object_t **)&omapi_registered_messages, - file, line); + ((omapi_object_t **)&omapi_registered_messages, MDL); } omapi_object_reference ((omapi_object_t **)&omapi_registered_messages, - (omapi_object_t *)m, file, line); + (omapi_object_t *)m, MDL); return ISC_R_SUCCESS;; } diff --git a/omapip/protocol.c b/omapip/protocol.c index c85675004..555207efc 100644 --- a/omapip/protocol.c +++ b/omapip/protocol.c @@ -30,31 +30,28 @@ isc_result_t omapi_protocol_connect (omapi_object_t *h, isc_result_t status; omapi_protocol_object_t *obj; - obj = (omapi_protocol_object_t *)malloc (sizeof *obj); + obj = (omapi_protocol_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; + rc_register_mdl (obj, obj -> refcnt); obj -> type = omapi_type_protocol; status = omapi_connect ((omapi_object_t *)obj, server_name, port); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "omapi_protocol_connect"); + status = omapi_object_reference (&h -> outer, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&obj -> inner, h, - "omapi_protocol_connect"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -63,16 +60,13 @@ isc_result_t omapi_protocol_connect (omapi_object_t *h, OMAPI_PROTOCOL_VERSION, sizeof (omapi_protocol_header_t)); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_connect"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } if (authinfo) - omapi_object_reference (&obj -> authinfo, authinfo, - "omapi_protocol_connect"); - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_accept"); + omapi_object_reference (&obj -> authinfo, authinfo, MDL); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_SUCCESS; } @@ -288,7 +282,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h, case omapi_protocol_header_wait: status = omapi_message_new ((omapi_object_t **)&p -> message, - "omapi_protocol_signal_handler"); + MDL); if (status != ISC_R_SUCCESS) { omapi_disconnect (c, 1); return status; @@ -366,8 +360,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h, } /* Allocate a buffer for the name. */ - status = (omapi_data_string_new - (&p -> name, nlen, "omapi_protocol_signal_handler")); + status = (omapi_data_string_new (&p -> name, nlen, MDL)); if (status != ISC_R_SUCCESS) { omapi_disconnect (c, 1); return ISC_R_NOMEMORY; @@ -395,9 +388,9 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h, if (!vlen) goto insert_new_value; - status = (omapi_typed_data_new - (&p -> value, omapi_datatype_data, vlen, - "omapi_protocol_signal_handler")); + status = omapi_typed_data_new (MDL, &p -> value, + omapi_datatype_data, + vlen); if (status != ISC_R_SUCCESS) { omapi_disconnect (c, 1); return ISC_R_NOMEMORY; @@ -423,8 +416,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h, /* We need a generic object to hang off of the incoming message. */ status = (omapi_generic_new - (&p -> message -> object, - "omapi_protocol_signal_handler")); + (&p -> message -> object, MDL)); if (status != ISC_R_SUCCESS) { omapi_disconnect (c, 1); return status; @@ -439,15 +431,14 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h, omapi_disconnect (c, 1); return status; } - omapi_data_string_dereference - (&p -> name, "omapi_protocol_signal_handler"); - omapi_typed_data_dereference (&p -> value, - "omapi_protocol_signal_handler"); + omapi_data_string_dereference (&p -> name, MDL); + omapi_typed_data_dereference (&p -> value, MDL); goto need_name_length; signature_wait: case omapi_protocol_signature_wait: - status = omapi_typed_data_new (&p -> message -> authenticator, + status = omapi_typed_data_new (MDL, + &p -> message -> authenticator, omapi_datatype_data, p -> message -> authlen); @@ -472,7 +463,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h, /* XXX unbind the authenticator. */ auth_unbind: omapi_object_dereference ((omapi_object_t **)&p -> message, - "omapi_protocol_signal_handler"); + MDL); /* Now wait for the next message. */ goto to_header_wait; @@ -512,7 +503,8 @@ isc_result_t omapi_protocol_get_value (omapi_object_t *h, return ISC_R_NOTFOUND; } -isc_result_t omapi_protocol_destroy (omapi_object_t *h, const char *name) +isc_result_t omapi_protocol_destroy (omapi_object_t *h, + const char *file, int line) { omapi_protocol_object_t *p; if (h -> type != omapi_type_protocol) @@ -520,9 +512,9 @@ isc_result_t omapi_protocol_destroy (omapi_object_t *h, const char *name) p = (omapi_protocol_object_t *)h; if (p -> message) omapi_object_dereference ((omapi_object_t **)&p -> message, - name); + file, line); if (p -> authinfo) - return omapi_object_dereference (&p -> authinfo, name); + return omapi_object_dereference (&p -> authinfo, file, line); return ISC_R_SUCCESS; } @@ -554,31 +546,27 @@ isc_result_t omapi_protocol_listen (omapi_object_t *h, isc_result_t status; omapi_protocol_listener_object_t *obj; - obj = (omapi_protocol_listener_object_t *)malloc (sizeof *obj); + obj = (omapi_protocol_listener_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; obj -> type = omapi_type_protocol_listener; - status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "omapi_protocol_listen"); + status = omapi_object_reference (&h -> outer, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&obj -> inner, h, - "omapi_protocol_listen"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } status = omapi_listen ((omapi_object_t *)obj, port, max); - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -609,25 +597,23 @@ isc_result_t omapi_protocol_listener_signal (omapi_object_t *o, if (!c || c -> type != omapi_type_connection) return ISC_R_INVALIDARG; - obj = (omapi_protocol_object_t *)malloc (sizeof *obj); + obj = (omapi_protocol_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; obj -> type = omapi_type_protocol; - status = omapi_object_reference (&obj -> outer, c, - "omapi_protocol_accept"); + status = omapi_object_reference (&obj -> outer, c, MDL); if (status != ISC_R_SUCCESS) { lose: - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_accept"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); omapi_disconnect (c, 1); return status; } - status = omapi_object_reference (&c -> inner, (omapi_object_t *)obj, - "omapi_protocol_accept"); + status = omapi_object_reference (&c -> inner, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) goto lose; @@ -638,8 +624,7 @@ isc_result_t omapi_protocol_listener_signal (omapi_object_t *o, if (status != ISC_R_SUCCESS) goto lose; - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_accept"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -672,7 +657,7 @@ isc_result_t omapi_protocol_listener_get_value (omapi_object_t *h, } isc_result_t omapi_protocol_listener_destroy (omapi_object_t *h, - const char *name) + const char *file, int line) { if (h -> type != omapi_type_protocol_listener) return ISC_R_INVALIDARG; @@ -708,31 +693,28 @@ isc_result_t omapi_protocol_send_status (omapi_object_t *po, if (po -> type != omapi_type_protocol) return ISC_R_INVALIDARG; - status = omapi_message_new (&message, "omapi_protocol_send_status"); + status = omapi_message_new (&message, MDL); if (status != ISC_R_SUCCESS) return status; status = omapi_set_int_value (message, (omapi_object_t *)0, "op", OMAPI_OP_STATUS); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "omapi_protocol_send_status"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "rid", (int)rid); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "omapi_protocol_send_status"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "result", (int)waitstatus); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "omapi_protocol_send_status"); + omapi_object_dereference (&message, MDL); return status; } @@ -741,8 +723,7 @@ isc_result_t omapi_protocol_send_status (omapi_object_t *po, status = omapi_set_string_value (message, (omapi_object_t *)0, "message", msg); if (status != ISC_R_SUCCESS) { - omapi_object_dereference - (&message, "omapi_protocol_send_status"); + omapi_object_dereference (&message, MDL); return status; } } @@ -762,15 +743,14 @@ isc_result_t omapi_protocol_send_update (omapi_object_t *po, if (po -> type != omapi_type_protocol) return ISC_R_INVALIDARG; - status = omapi_message_new (&message, "omapi_protocol_send_update"); + status = omapi_message_new (&message, MDL); if (status != ISC_R_SUCCESS) return status; status = omapi_set_int_value (message, (omapi_object_t *)0, "op", OMAPI_OP_UPDATE); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, - "omapi_protocol_send_update"); + omapi_object_dereference (&message, MDL); return status; } @@ -779,22 +759,19 @@ isc_result_t omapi_protocol_send_update (omapi_object_t *po, status = omapi_set_int_value (message, (omapi_object_t *)0, "rid", (int)rid); if (status != ISC_R_SUCCESS) { - omapi_object_dereference - (&message, "omapi_protocol_send_update"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_object_handle (&handle, object); if (status != ISC_R_SUCCESS) { - omapi_object_dereference - (&message, "omapi_protocol_send_update"); + omapi_object_dereference (&message, MDL); return status; } status = omapi_set_int_value (message, (omapi_object_t *)0, "handle", (int)handle); if (status != ISC_R_SUCCESS) { - omapi_object_dereference - (&message, "omapi_protocol_send_update"); + omapi_object_dereference (&message, MDL); return status; } } @@ -802,7 +779,7 @@ isc_result_t omapi_protocol_send_update (omapi_object_t *po, status = omapi_set_object_value (message, (omapi_object_t *)0, "object", object); if (status != ISC_R_SUCCESS) { - omapi_object_dereference (&message, "dhcpctl_open_object"); + omapi_object_dereference (&message, MDL); return status; } diff --git a/omapip/support.c b/omapip/support.c index 5b2cb9e00..4beb2c627 100644 --- a/omapip/support.c +++ b/omapip/support.c @@ -147,7 +147,7 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **type, omapi_value_t **), isc_result_t (*destroy) (omapi_object_t *, - const char *), + const char *, int), isc_result_t (*signal_handler) (omapi_object_t *, const char *, va_list), @@ -168,7 +168,7 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **type, { omapi_object_type_t *t; - t = malloc (sizeof *t); + t = dmalloc (sizeof *t, MDL); if (!t) return ISC_R_NOMEMORY; memset (t, 0, sizeof *t); @@ -251,8 +251,7 @@ isc_result_t omapi_set_value_str (omapi_object_t *h, isc_result_t status; nds = (omapi_data_string_t *)0; - status = omapi_data_string_new (&nds, strlen (name), - "omapi_set_value_str"); + status = omapi_data_string_new (&nds, strlen (name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (nds -> value, name, strlen (name)); @@ -269,22 +268,20 @@ isc_result_t omapi_set_boolean_value (omapi_object_t *h, omapi_object_t *id, int len; int ip; - status = omapi_data_string_new (&n, strlen (name), - "omapi_set_boolean_value"); + status = omapi_data_string_new (&n, strlen (name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (n -> value, name, strlen (name)); - status = omapi_typed_data_new (&tv, omapi_datatype_int, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_int, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&n, - "omapi_set_boolean_value"); + omapi_data_string_dereference (&n, MDL); return status; } status = omapi_set_value (h, id, n, tv); - omapi_data_string_dereference (&n, "omapi_set_boolean_value"); - omapi_typed_data_dereference (&tv, "omapi_set_boolean_value"); + omapi_data_string_dereference (&n, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -297,22 +294,20 @@ isc_result_t omapi_set_int_value (omapi_object_t *h, omapi_object_t *id, int len; int ip; - status = omapi_data_string_new (&n, strlen (name), - "omapi_set_int_value"); + status = omapi_data_string_new (&n, strlen (name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (n -> value, name, strlen (name)); - status = omapi_typed_data_new (&tv, omapi_datatype_int, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_int, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&n, - "omapi_set_int_value"); + omapi_data_string_dereference (&n, MDL); return status; } status = omapi_set_value (h, id, n, tv); - omapi_data_string_dereference (&n, "omapi_set_int_value"); - omapi_typed_data_dereference (&tv, "omapi_set_int_value"); + omapi_data_string_dereference (&n, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -325,22 +320,20 @@ isc_result_t omapi_set_object_value (omapi_object_t *h, omapi_object_t *id, int len; int ip; - status = omapi_data_string_new (&n, strlen (name), - "omapi_set_object_value"); + status = omapi_data_string_new (&n, strlen (name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (n -> value, name, strlen (name)); - status = omapi_typed_data_new (&tv, omapi_datatype_object, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_object, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&n, - "omapi_set_object_value"); + omapi_data_string_dereference (&n, MDL); return status; } status = omapi_set_value (h, id, n, tv); - omapi_data_string_dereference (&n, "omapi_set_object_value"); - omapi_typed_data_dereference (&tv, "omapi_set_object_value"); + omapi_data_string_dereference (&n, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -353,22 +346,20 @@ isc_result_t omapi_set_string_value (omapi_object_t *h, omapi_object_t *id, int len; int ip; - status = omapi_data_string_new (&n, strlen (name), - "omapi_set_string_value"); + status = omapi_data_string_new (&n, strlen (name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (n -> value, name, strlen (name)); - status = omapi_typed_data_new (&tv, omapi_datatype_string, value); + status = omapi_typed_data_new (MDL, &tv, omapi_datatype_string, value); if (status != ISC_R_SUCCESS) { - omapi_data_string_dereference (&n, - "omapi_set_string_value"); + omapi_data_string_dereference (&n, MDL); return status; } status = omapi_set_value (h, id, n, tv); - omapi_data_string_dereference (&n, "omapi_set_string_value"); - omapi_typed_data_dereference (&tv, "omapi_set_string_value"); + omapi_data_string_dereference (&n, MDL); + omapi_typed_data_dereference (&tv, MDL); return status; } @@ -397,8 +388,7 @@ isc_result_t omapi_get_value_str (omapi_object_t *h, isc_result_t status; nds = (omapi_data_string_t *)0; - status = omapi_data_string_new (&nds, strlen (name), - "omapi_get_value_str"); + status = omapi_data_string_new (&nds, strlen (name), MDL); if (status != ISC_R_SUCCESS) return status; memcpy (nds -> value, name, strlen (name)); @@ -523,25 +513,28 @@ int omapi_td_strcmp (omapi_typed_data_t *s1, const char *s2) return 0; } -isc_result_t omapi_make_value (omapi_value_t **vp, omapi_data_string_t *name, - omapi_typed_data_t *value, const char *caller) +isc_result_t omapi_make_value (omapi_value_t **vp, + omapi_data_string_t *name, + omapi_typed_data_t *value, + const char *file, int line) { isc_result_t status; - status = omapi_value_new (vp, caller); + status = omapi_value_new (vp, file, line); if (status != ISC_R_SUCCESS) return status; - status = omapi_data_string_reference (&(*vp) -> name, name, caller); + status = omapi_data_string_reference (&(*vp) -> name, + name, file, line); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } if (value) { status = omapi_typed_data_reference (&(*vp) -> value, - value, caller); + value, file, line); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } } @@ -551,24 +544,26 @@ isc_result_t omapi_make_value (omapi_value_t **vp, omapi_data_string_t *name, isc_result_t omapi_make_const_value (omapi_value_t **vp, omapi_data_string_t *name, const unsigned char *value, - unsigned len, const char *caller) + unsigned len, + const char *file, int line) { isc_result_t status; - status = omapi_value_new (vp, caller); + status = omapi_value_new (vp, file, line); if (status != ISC_R_SUCCESS) return status; - status = omapi_data_string_reference (&(*vp) -> name, name, caller); + status = omapi_data_string_reference (&(*vp) -> name, + name, file, line); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } if (value) { - status = omapi_typed_data_new (&(*vp) -> value, + status = omapi_typed_data_new (file, line, &(*vp) -> value, omapi_datatype_data, len); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } memcpy ((*vp) -> value -> u.buffer.value, value, len); @@ -578,24 +573,25 @@ isc_result_t omapi_make_const_value (omapi_value_t **vp, isc_result_t omapi_make_int_value (omapi_value_t **vp, omapi_data_string_t *name, - int value, const char *caller) + int value, const char *file, int line) { isc_result_t status; - status = omapi_value_new (vp, caller); + status = omapi_value_new (vp, file, line); if (status != ISC_R_SUCCESS) return status; - status = omapi_data_string_reference (&(*vp) -> name, name, caller); + status = omapi_data_string_reference (&(*vp) -> name, + name, file, line); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } if (value) { - status = omapi_typed_data_new (&(*vp) -> value, + status = omapi_typed_data_new (file, line, &(*vp) -> value, omapi_datatype_int); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } (*vp) -> value -> u.integer = value; @@ -606,31 +602,32 @@ isc_result_t omapi_make_int_value (omapi_value_t **vp, isc_result_t omapi_make_handle_value (omapi_value_t **vp, omapi_data_string_t *name, omapi_object_t *value, - const char *caller) + const char *file, int line) { isc_result_t status; - status = omapi_value_new (vp, caller); + status = omapi_value_new (vp, file, line); if (status != ISC_R_SUCCESS) return status; - status = omapi_data_string_reference (&(*vp) -> name, name, caller); + status = omapi_data_string_reference (&(*vp) -> name, + name, file, line); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } if (value) { - status = omapi_typed_data_new (&(*vp) -> value, + status = omapi_typed_data_new (file, line, &(*vp) -> value, omapi_datatype_int); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } status = (omapi_object_handle ((omapi_handle_t *)&(*vp) -> value -> u.integer, value)); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } } @@ -639,24 +636,26 @@ isc_result_t omapi_make_handle_value (omapi_value_t **vp, isc_result_t omapi_make_string_value (omapi_value_t **vp, omapi_data_string_t *name, - const char *value, const char *caller) + const char *value, + const char *file, int line) { isc_result_t status; - status = omapi_value_new (vp, caller); + status = omapi_value_new (vp, file, line); if (status != ISC_R_SUCCESS) return status; - status = omapi_data_string_reference (&(*vp) -> name, name, caller); + status = omapi_data_string_reference (&(*vp) -> name, + name, file, line); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } if (value) { - status = omapi_typed_data_new (&(*vp) -> value, + status = omapi_typed_data_new (file, line, &(*vp) -> value, omapi_datatype_string, value); if (status != ISC_R_SUCCESS) { - omapi_value_dereference (vp, caller); + omapi_value_dereference (vp, file, line); return status; } } diff --git a/omapip/test.c b/omapip/test.c index cea562d94..5a25b1397 100644 --- a/omapip/test.c +++ b/omapip/test.c @@ -40,7 +40,7 @@ int main (int argc, char **argv) fprintf (stderr, "Usage: test listen port\n"); exit (1); } - status = omapi_generic_new (&listener, "main"); + status = omapi_generic_new (&listener, MDL); if (status != ISC_R_SUCCESS) { fprintf (stderr, "omapi_generic_new: %s\n", isc_result_totext (status)); @@ -59,7 +59,7 @@ int main (int argc, char **argv) fprintf (stderr, "Usage: test listen address port\n"); exit (1); } - status = omapi_generic_new (&connection, "main"); + status = omapi_generic_new (&connection, MDL); if (status != ISC_R_SUCCESS) { fprintf (stderr, "omapi_generic_new: %s\n", isc_result_totext (status)); diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c index 9eeede998..ec13f70c1 100644 --- a/relay/dhcrelay.c +++ b/relay/dhcrelay.c @@ -3,7 +3,7 @@ DHCP/BOOTP Relay Agent. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -22,7 +22,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhcrelay.c,v 1.37 2000/01/05 18:11:53 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcrelay.c,v 1.38 2000/01/26 14:56:16 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -35,8 +35,6 @@ TIME default_lease_time = 43200; /* 12 hours... */ TIME max_lease_time = 86400; /* 24 hours... */ struct tree_cache *global_options [256]; -int log_perror = 1; - /* Needed to prevent linking against conflex.c. */ int lexline; int lexchar; @@ -82,7 +80,6 @@ enum { forward_and_append, /* Forward and append our own relay option. */ u_int16_t local_port; u_int16_t remote_port; -int log_priority; struct server_list { struct server_list *next; @@ -130,7 +127,7 @@ int main (argc, argv, envp) } else if (!strcmp (argv [i], "-i")) { struct interface_info *tmp = ((struct interface_info *) - dmalloc (sizeof *tmp, "specified_interface")); + dmalloc (sizeof *tmp, MDL)); if (!tmp) log_fatal ("Insufficient memory to %s %s", "record interface", argv [i]); @@ -183,7 +180,8 @@ int main (argc, argv, envp) } } if (iap) { - sp = (struct server_list *)malloc (sizeof *sp); + sp = ((struct server_list *) + dmalloc (sizeof *sp, MDL)); if (!sp) log_fatal ("no memory for server.\n"); sp -> next = servers; @@ -418,10 +416,6 @@ static void usage () " [server1 [... serverN]]"); } -void cleanup () -{ -} - int write_lease (lease) struct lease *lease; { diff --git a/server/confpars.c b/server/confpars.c index 1f948476b..85851eaa7 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: confpars.c,v 1.96 2000/01/25 01:38:17 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: confpars.c,v 1.97 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -655,7 +655,7 @@ void parse_failover_peer (cfile, group, type) return; } - peer = dmalloc (sizeof *peer, "parse_failover_peer"); + peer = dmalloc (sizeof *peer, MDL); if (!peer) log_fatal ("no memory for failover peer%s.", name); memset (peer, 0, sizeof *peer); @@ -1620,7 +1620,8 @@ void parse_shared_net_declaration (cfile, group) if (token == RBRACE) { token = next_token (&val, cfile); if (!share -> subnets) { - parse_warn (cfile, MDL); + parse_warn (cfile, + "empty shared-network decl"); return; } enter_shared_network (share); diff --git a/server/db.c b/server/db.c index 30802c1e2..3481381d1 100644 --- a/server/db.c +++ b/server/db.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: db.c,v 1.41 2000/01/25 01:39:57 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: db.c,v 1.42 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -324,7 +324,7 @@ int write_host (host) (struct option_state *)0, (struct option_state *)0, &global_scope, - host -> fixed_addr)) { + host -> fixed_addr, MDL)) { errno = 0; fprintf (db_file, "\n fixed-address "); diff --git a/server/dhcp.c b/server/dhcp.c index 797c0bae0..fdcea8d7f 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.133 2000/01/25 01:35:38 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.134 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -120,7 +120,7 @@ void dhcpdiscover (packet) /* If it's an expired lease, get rid of any bindings. */ if (lease -> ends < cur_time && lease -> scope.bindings) - free_bindings (&lease -> scope, "dhcpdiscover"); + free_bindings (&lease -> scope, MDL); /* Set the lease to really expire in 2 minutes, unless it has not yet expired, in which case leave its expiry time alone. */ @@ -153,7 +153,7 @@ void dhcprequest (packet) &global_scope, oc, MDL)) { cip.len = 4; memcpy (cip.iabuf, data.data, 4); - data_string_forget (&data, "dhcprequest"); + data_string_forget (&data, MDL); } else { oc = (struct option_cache *)0; cip.len = 4; @@ -310,7 +310,7 @@ void dhcprelease (packet) packet -> options, (struct option_state *)0, &global_scope, oc, MDL)) { lease = find_lease_by_uid (data.data, data.len); - data_string_forget (&data, "dhcprelease"); + data_string_forget (&data, MDL); /* See if we can find a lease that matches the IP address the client is claiming. */ @@ -386,10 +386,10 @@ void dhcpdecline (packet) cip.len = 4; memcpy (cip.iabuf, data.data, 4); - data_string_forget (&data, "dhcpdecline"); + data_string_forget (&data, MDL); lease = find_lease_by_ip_addr (cip); - option_state_allocate (&options, "dhcpdecline"); + option_state_allocate (&options, MDL); /* Execute statements in scope starting with the subnet scope. */ if (lease) @@ -447,7 +447,7 @@ void dhcpdecline (packet) status); } - option_state_dereference (&options, "dhcpdecline"); + option_state_dereference (&options, MDL); } void dhcpinform (packet) @@ -509,7 +509,7 @@ void dhcpinform (packet) } memset (&d1, 0, sizeof d1); - option_state_allocate (&options, "dhcpinform"); + option_state_allocate (&options, MDL); memset (&outgoing, 0, sizeof outgoing); memset (&raw, 0, sizeof raw); outgoing.raw = &raw; @@ -542,7 +542,7 @@ void dhcpinform (packet) else raw.file [i] = 0; memcpy (raw.file, d1.data, i); - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } /* Choose a server name as above. */ @@ -557,7 +557,7 @@ void dhcpinform (packet) else raw.sname [i] = 0; memcpy (raw.sname, d1.data, i); - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } /* Set a flag if this client is a lame Microsoft client that NUL @@ -570,26 +570,26 @@ void dhcpinform (packet) &global_scope, oc, MDL)) { if (d1.data [d1.len - 1] == '\0') nulltp = 1; - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } } /* Put in DHCP-specific options. */ i = DHO_DHCP_MESSAGE_TYPE; oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "dhcpinform")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, &dhcpack, 1, 0, 0)) { oc -> option = dhcp_universe.options [i]; save_option (&dhcp_universe, options, oc); } - option_cache_dereference (&oc, "dhcpinform"); + option_cache_dereference (&oc, MDL); } i = DHO_DHCP_SERVER_IDENTIFIER; if (!(oc = lookup_option (&dhcp_universe, options, i))) { use_primary: oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "dhcpinform")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, ((unsigned char *) @@ -601,7 +601,7 @@ void dhcpinform (packet) save_option (&dhcp_universe, options, oc); } - option_cache_dereference (&oc, "dhcpinform"); + option_cache_dereference (&oc, MDL); } from = packet -> interface -> primary_address; } else { @@ -609,11 +609,11 @@ void dhcpinform (packet) packet -> options, options, &global_scope, oc, MDL)) { if (!d1.len || d1.len != sizeof from) { - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); goto use_primary; } memcpy (&from, d1.data, sizeof from); - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } else goto use_primary; } @@ -623,14 +623,14 @@ void dhcpinform (packet) i = DHO_SUBNET_MASK; if (subnet && !lookup_option (&dhcp_universe, options, i)) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "dhcpinform")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, subnet -> netmask.iabuf, subnet -> netmask.len, 0, 0)) { oc -> option = dhcp_universe.options [i]; save_option (&dhcp_universe, options, oc); } - option_cache_dereference (&oc, "dhcpinform"); + option_cache_dereference (&oc, MDL); } } @@ -639,7 +639,7 @@ void dhcpinform (packet) i = DHO_NWIP_SUBOPTIONS; if (!lookup_option (&dhcp_universe, options, i)) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "dhcpinform")) { + if (option_cache_allocate (&oc, MDL)) { memset (&d1, 0, sizeof d1); d1.data = "nwip"; d1.len = 4; @@ -647,7 +647,7 @@ void dhcpinform (packet) oc -> option = dhcp_universe.options [i]; save_option (&dhcp_universe, options, oc); } - option_cache_dereference (&oc, "dhcpinform"); + option_cache_dereference (&oc, MDL); } } @@ -662,14 +662,14 @@ void dhcpinform (packet) packet -> options, options, &global_scope, oc, MDL)) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "dhcpinform")) { + if (option_cache_allocate (&oc, MDL)) { if (make_encapsulation (&oc -> expression, &d1)) { oc -> option = dhcp_universe.options [i]; save_option (&dhcp_universe, options, oc); } - option_cache_dereference (&oc, "dhcpinform"); + option_cache_dereference (&oc, MDL); } - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } /* If a site option space has been specified, use that for @@ -685,13 +685,13 @@ void dhcpinform (packet) hash_lookup (&universe_hash, d1.data, d1.len)); if (!u) { log_error ("unknown option space %s.", d1.data); - option_state_dereference (&options, "dhcpinform"); + option_state_dereference (&options, MDL); return; } options -> site_universe = u -> index; options -> site_code_min = 128; /* XXX */ - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } else { options -> site_universe = dhcp_universe.index; options -> site_code_min = 0; /* Trust me, it works. */ @@ -734,7 +734,7 @@ void dhcpinform (packet) take the first. */ if (d1.len >= 4 && d1.data) memcpy (&raw.siaddr, d1.data, 4); - data_string_forget (&d1, "dhcpinform"); + data_string_forget (&d1, MDL); } } @@ -744,8 +744,8 @@ void dhcpinform (packet) 0, packet -> options, options, &global_scope, 0, nulltp, 0, prl.len ? &prl : (struct data_string *)0); - option_state_dereference (&options, "dhcpinform"); - data_string_forget (&prl, "dhcpinform"); + option_state_dereference (&options, MDL); + data_string_forget (&prl, MDL); /* Make sure that the packet is at least as big as a BOOTP packet. */ if (outgoing.packet_length < BOOTP_MIN_LEN) @@ -806,44 +806,44 @@ void nak_lease (packet, cip) struct expression *expr; struct option_cache *oc = (struct option_cache *)0; - option_state_allocate (&options, "nak_lease"); + option_state_allocate (&options, MDL); memset (&outgoing, 0, sizeof outgoing); memset (&raw, 0, sizeof raw); outgoing.raw = &raw; /* Set DHCP_MESSAGE_TYPE to DHCPNAK */ - if (!option_cache_allocate (&oc, "nak_lease")) { + if (!option_cache_allocate (&oc, MDL)) { log_error ("No memory for DHCPNAK message type."); - option_state_dereference (&options, "nak_lease"); + option_state_dereference (&options, MDL); return; } if (!make_const_data (&oc -> expression, &nak, sizeof nak, 0, 0)) { log_error ("No memory for expr_const expression."); - option_cache_dereference (&oc, "nak_lease"); - option_state_dereference (&options, "nak_lease"); + option_cache_dereference (&oc, MDL); + option_state_dereference (&options, MDL); return; } oc -> option = dhcp_universe.options [DHO_DHCP_MESSAGE_TYPE]; save_option (&dhcp_universe, options, oc); - option_cache_dereference (&oc, "nak_lease"); + option_cache_dereference (&oc, MDL); /* Set DHCP_MESSAGE to whatever the message is */ - if (!option_cache_allocate (&oc, "nak_lease")) { + if (!option_cache_allocate (&oc, MDL)) { log_error ("No memory for DHCPNAK message type."); - option_state_dereference (&options, "nak_lease"); + option_state_dereference (&options, MDL); return; } if (!make_const_data (&oc -> expression, (unsigned char *)dhcp_message, strlen (dhcp_message), 1, 0)) { log_error ("No memory for expr_const expression."); - option_cache_dereference (&oc, "nak_lease"); - option_state_dereference (&options, "nak_lease"); + option_cache_dereference (&oc, MDL); + option_state_dereference (&options, MDL); return; } oc -> option = dhcp_universe.options [DHO_DHCP_MESSAGE]; save_option (&dhcp_universe, options, oc); - option_cache_dereference (&oc, "nak_lease"); + option_cache_dereference (&oc, MDL); /* Do not use the client's requested parameter list. */ delete_option (&dhcp_universe, packet -> options, @@ -854,7 +854,7 @@ void nak_lease (packet, cip) cons_options (packet, outgoing.raw, (struct lease *)0, 0, packet -> options, options, &global_scope, 0, 0, 0, (struct data_string *)0); - option_state_dereference (&options, "nak_lease"); + option_state_dereference (&options, MDL); /* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/ raw.siaddr = packet -> interface -> primary_address; @@ -962,7 +962,7 @@ void ack_lease (packet, lease, offer, when, msg) return; /* Allocate a lease state structure... */ - state = new_lease_state ("ack_lease"); + state = new_lease_state (MDL); if (!state) log_fatal ("unable to allocate lease state!"); state -> got_requested_address = packet -> got_requested_address; @@ -986,21 +986,21 @@ void ack_lease (packet, lease, offer, when, msg) strlen (lease -> client_hostname) == d1.len && !memcmp (lease -> client_hostname, d1.data, d1.len)) { /* Hasn't changed. */ - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } else if (oc && s1) { if (lease -> client_hostname) - dfree (lease -> client_hostname, "ack_lease"); + dfree (lease -> client_hostname, MDL); lease -> client_hostname = - dmalloc (d1.len + 1, "ack_lease"); + dmalloc (d1.len + 1, MDL); if (!lease -> client_hostname) log_error ("no memory for client hostname."); else { memcpy (lease -> client_hostname, d1.data, d1.len); lease -> client_hostname [d1.len] = 0; } - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } else if (lease -> client_hostname) { - dfree (lease -> client_hostname, "ack_lease"); + dfree (lease -> client_hostname, MDL); lease -> client_hostname = 0; } @@ -1023,13 +1023,13 @@ void ack_lease (packet, lease, offer, when, msg) ones if there are any to insert. */ if (lease -> on_expiry) executable_statement_dereference (&lease -> on_expiry, - "ack_lease"); + MDL); if (lease -> on_commit) executable_statement_dereference (&lease -> on_commit, - "ack_lease"); + MDL); if (lease -> on_release) executable_statement_dereference (&lease -> on_release, - "ack_lease"); + MDL); } /* Execute statements in scope starting with the subnet scope. */ @@ -1140,12 +1140,12 @@ void ack_lease (packet, lease, offer, when, msg) if (d1.len && packet -> raw -> secs < d1.data [0]) { log_info ("%s: %d secs < %d", msg, packet -> raw -> secs, d1.data [0]); - data_string_forget (&d1, "ack_lease"); - free_lease_state (state, "ack_lease"); - static_lease_dereference (lease, "ack_lease"); + data_string_forget (&d1, MDL); + free_lease_state (state, MDL); + static_lease_dereference (lease, MDL); return; } - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1165,7 +1165,7 @@ void ack_lease (packet, lease, offer, when, msg) packet -> options, state -> options, &lease -> scope, oc, MDL)) { hp = find_hosts_by_uid (d1.data, d1.len); - data_string_forget (&d1, "dhcpdiscover"); + data_string_forget (&d1, MDL); if (!hp) hp = find_hosts_by_haddr (packet -> raw -> htype, @@ -1191,8 +1191,8 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (!ignorep) log_info ("%s: unknown client", msg); - free_lease_state (state, "ack_lease"); - static_lease_dereference (lease, "ack_lease"); + free_lease_state (state, MDL); + static_lease_dereference (lease, MDL); return; } @@ -1206,8 +1206,8 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (!ignorep) log_info ("%s: bootp disallowed", msg); - free_lease_state (state, "ack_lease"); - static_lease_dereference (lease, "ack_lease"); + free_lease_state (state, MDL); + static_lease_dereference (lease, MDL); return; } @@ -1221,8 +1221,8 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (!ignorep) log_info ("%s: booting disallowed", msg); - free_lease_state (state, "ack_lease"); - static_lease_dereference (lease, "ack_lease"); + free_lease_state (state, MDL); + static_lease_dereference (lease, MDL); return; } @@ -1258,10 +1258,9 @@ void ack_lease (packet, lease, offer, when, msg) if (i == packet -> class_count) { log_info ("%s: no available billing", msg); - free_lease_state (state, "ack_lease"); + free_lease_state (state, MDL); /* XXX probably not necessary: */ - static_lease_dereference (lease, - "ack_lease"); + static_lease_dereference (lease, MDL); return; } } @@ -1308,7 +1307,7 @@ void ack_lease (packet, lease, offer, when, msg) if (d1.len == sizeof (u_int32_t)) default_lease_time = getULong (d1.data); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1322,10 +1321,10 @@ void ack_lease (packet, lease, offer, when, msg) s1 = 0; if (s1 && d1.len == sizeof (u_int32_t)) { lease_time = getULong (d1.data); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } else { if (s1) - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); lease_time = default_lease_time; } @@ -1340,7 +1339,7 @@ void ack_lease (packet, lease, offer, when, msg) if (d1.len == sizeof (u_int32_t)) max_lease_time = getULong (d1.data); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1361,7 +1360,7 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (d1.len == sizeof (u_int32_t)) min_lease_time = getULong (d1.data); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1432,7 +1431,7 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (d1.len == sizeof (u_int32_t)) lease_time = getULong (d1.data); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1445,7 +1444,7 @@ void ack_lease (packet, lease, offer, when, msg) if (d1.len == sizeof (u_int32_t)) lease_time = (getULong (d1.data) - cur_time); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1471,15 +1470,14 @@ void ack_lease (packet, lease, offer, when, msg) unsigned char *tuid; lt.uid_max = d1.len; lt.uid_len = d1.len; - tuid = (unsigned char *)dmalloc (lt.uid_max, - "ack_lease"); + tuid = (unsigned char *)dmalloc (lt.uid_max, MDL); /* XXX inelegant */ if (!tuid) log_fatal ("no memory for large uid."); memcpy (tuid, d1.data, lt.uid_len); lt.uid = tuid; } - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } lt.host = lease -> host; @@ -1507,7 +1505,7 @@ void ack_lease (packet, lease, offer, when, msg) lease -> on_commit); if (lease -> on_commit) executable_statement_dereference (&lease -> on_commit, - "ack_lease"); + MDL); } /* Save any bindings. */ @@ -1538,8 +1536,8 @@ void ack_lease (packet, lease, offer, when, msg) if (!(supersede_lease (lease, <, !offer || offer == DHCPACK) || (offer && offer != DHCPACK))) { log_info ("%s: database update failed", msg); - free_lease_state (state, "ack_lease"); - static_lease_dereference (lease, "ack_lease"); + free_lease_state (state, MDL); + static_lease_dereference (lease, MDL); return; } else { /* If this is a DHCPOFFER transaction, supersede_lease @@ -1588,7 +1586,7 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (d1.len == sizeof (u_int16_t)) state -> max_message_size = getUShort (d1.data); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } /* Now, if appropriate, put in DHCP-specific options that @@ -1596,7 +1594,7 @@ void ack_lease (packet, lease, offer, when, msg) if (state -> offer) { i = DHO_DHCP_MESSAGE_TYPE; oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, &state -> offer, 1, 0, 0)) { oc -> option = @@ -1604,14 +1602,14 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } i = DHO_DHCP_SERVER_IDENTIFIER; if (!(oc = lookup_option (&dhcp_universe, state -> options, i))) { use_primary: oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, ((unsigned char *) @@ -1623,7 +1621,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } state -> from.len = sizeof state -> ip -> primary_address; @@ -1637,12 +1635,12 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, oc, MDL)) { if (!d1.len || d1.len > sizeof state -> from.iabuf) { - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); goto use_primary; } memcpy (state -> from.iabuf, d1.data, d1.len); state -> from.len = d1.len; - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } else goto use_primary; } @@ -1657,7 +1655,7 @@ void ack_lease (packet, lease, offer, when, msg) log_error ("dhcp-lease-time option for %s overridden.", inet_ntoa (state -> ciaddr)); oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, (unsigned char *)&state -> expiry, sizeof state -> expiry, 0, 0)) { @@ -1665,7 +1663,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } /* Renewal time is lease time * 0.5. */ @@ -1677,7 +1675,7 @@ void ack_lease (packet, lease, offer, when, msg) log_error ("overriding dhcp-renewal-time for %s.", inet_ntoa (state -> ciaddr)); oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, (unsigned char *) &state -> renewal, @@ -1686,7 +1684,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } /* Rebinding time is lease time * 0.875. */ @@ -1699,7 +1697,7 @@ void ack_lease (packet, lease, offer, when, msg) log_error ("overriding dhcp-rebinding-time for %s.", inet_ntoa (state -> ciaddr)); oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, (unsigned char *)&state -> rebind, sizeof state -> rebind, 0, 0)) { @@ -1707,7 +1705,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } } else { state -> from.len = @@ -1729,7 +1727,7 @@ void ack_lease (packet, lease, offer, when, msg) take the first. */ if (d1.len >= 4 && d1.data) memcpy (&state -> siaddr, d1.data, 4); - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } } @@ -1737,7 +1735,7 @@ void ack_lease (packet, lease, offer, when, msg) mask has been provided. */ i = DHO_SUBNET_MASK; if (!lookup_option (&dhcp_universe, state -> options, i)) { - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, lease -> subnet -> netmask.iabuf, lease -> subnet -> netmask.len, @@ -1746,7 +1744,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } } @@ -1762,7 +1760,7 @@ void ack_lease (packet, lease, offer, when, msg) &lease -> scope, lookup_option (&server_universe, state -> options, j), MDL))) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, ((unsigned char *) lease -> host -> name), @@ -1772,7 +1770,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } } @@ -1794,7 +1792,7 @@ void ack_lease (packet, lease, offer, when, msg) log_error ("No hostname for %s", inet_ntoa (ia)); else { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, ((unsigned char *) h -> h_name), @@ -1805,7 +1803,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } } } @@ -1823,7 +1821,7 @@ void ack_lease (packet, lease, offer, when, msg) oc = lookup_option (&dhcp_universe, state -> options, i); if (!oc) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_const_data (&oc -> expression, lease -> ip_addr.iabuf, lease -> ip_addr.len, @@ -1836,7 +1834,7 @@ void ack_lease (packet, lease, offer, when, msg) } } if (oc) - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } /* Make an encapsulation for the NWIP suboptions if the client @@ -1844,7 +1842,7 @@ void ack_lease (packet, lease, offer, when, msg) i = DHO_NWIP_SUBOPTIONS; if (!(oc = lookup_option (&dhcp_universe, state -> options, i))) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "dhcpinform")) { + if (option_cache_allocate (&oc, MDL)) { memset (&d1, 0, sizeof d1); d1.data = "nwip"; d1.len = 4; @@ -1853,7 +1851,7 @@ void ack_lease (packet, lease, offer, when, msg) save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "dhcpinform"); + option_cache_dereference (&oc, MDL); } } @@ -1868,15 +1866,15 @@ void ack_lease (packet, lease, offer, when, msg) packet -> options, state -> options, &lease -> scope, oc, MDL)) { oc = (struct option_cache *)0; - if (option_cache_allocate (&oc, "ack_lease")) { + if (option_cache_allocate (&oc, MDL)) { if (make_encapsulation (&oc -> expression, &d1)) { oc -> option = dhcp_universe.options [i]; save_option (&dhcp_universe, state -> options, oc); } - option_cache_dereference (&oc, "ack_lease"); + option_cache_dereference (&oc, MDL); } - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } /* If a site option space has been specified, use that for @@ -1897,7 +1895,7 @@ void ack_lease (packet, lease, offer, when, msg) state -> options -> site_universe = u -> index; state -> options -> site_code_min = 128; /* XXX */ - data_string_forget (&d1, "ack_lease"); + data_string_forget (&d1, MDL); } else { state -> options -> site_code_min = 0; state -> options -> site_universe = dhcp_universe.index; @@ -1930,7 +1928,7 @@ void ack_lease (packet, lease, offer, when, msg) log_info ("%s", msg); /* Hang the packet off the lease state. */ - packet_reference (&lease -> state -> packet, packet, "ack_lease"); + packet_reference (&lease -> state -> packet, packet, MDL); /* If this is a DHCPOFFER, ping the lease address before actually sending the offer. */ @@ -1942,7 +1940,7 @@ void ack_lease (packet, lease, offer, when, msg) ++outstanding_pings; } else { lease -> timestamp = cur_time; - static_lease_dereference (lease, "ack_lease"); + static_lease_dereference (lease, MDL); dhcp_reply (lease); } } @@ -2093,7 +2091,7 @@ void dhcp_reply (lease) raw.siaddr, &to, (struct hardware *)0); - free_lease_state (state, "dhcp_reply fallback 1"); + free_lease_state (state, MDL); lease -> state = (struct lease_state *)0; return; } @@ -2125,7 +2123,7 @@ void dhcp_reply (lease) &raw, packet_length, raw.siaddr, &to, (struct hardware *)0); - free_lease_state (state, "dhcp_reply fallback 2"); + free_lease_state (state, MDL); lease -> state = (struct lease_state *)0; return; } @@ -2154,7 +2152,7 @@ void dhcp_reply (lease) /* Free all of the entries in the option_state structure now that we're done with them. */ - free_lease_state (state, "dhcp_reply"); + free_lease_state (state, MDL); lease -> state = (struct lease_state *)0; } @@ -2185,7 +2183,7 @@ struct lease *find_lease (packet, share, ours) packet -> got_requested_address = 1; cip.len = 4; memcpy (cip.iabuf, d1.data, cip.len); - data_string_forget (&d1, "find_lease"); + data_string_forget (&d1, MDL); } else if (packet -> raw -> ciaddr.s_addr) { cip.len = 4; memcpy (cip.iabuf, &packet -> raw -> ciaddr, 4); @@ -2632,7 +2630,7 @@ struct lease *find_lease (packet, share, ours) out: if (have_client_identifier) - data_string_forget (&client_identifier, "find_lease"); + data_string_forget (&client_identifier, MDL); #if defined (DEBUG_FIND_LEASE) if (lease) @@ -2674,20 +2672,24 @@ struct lease *mockup_lease (packet, share, hp) dangling from the lease will be lost, so reference counts will be screwed up and memory leaks will occur. */ -void static_lease_dereference (lease, name) +void static_lease_dereference (lease, file, line) struct lease *lease; - const char *name; + const char *file; + int line; { if (!(lease -> flags & STATIC_LEASE)) return; if (lease -> on_release) - executable_statement_dereference (&lease -> on_release, name); + executable_statement_dereference (&lease -> on_release, + file, line); if (lease -> on_expiry) - executable_statement_dereference (&lease -> on_expiry, name); + executable_statement_dereference (&lease -> on_expiry, + file, line); if (lease -> on_commit) - executable_statement_dereference (&lease -> on_commit, name); + executable_statement_dereference (&lease -> on_commit, + file, line); if (&lease -> scope) - free_bindings (&lease -> scope, name); + free_bindings (&lease -> scope, file, line); } /* Look through all the pools in a list starting with the specified pool @@ -2873,8 +2875,7 @@ int parse_agent_information_option (packet, len, data) return 0; /* Make space for this suboption. */ t = (struct option_tag *) - dmalloc (op [1] + 1 + sizeof *t, - "parse_agent_information_option"); + dmalloc (op [1] + 1 + sizeof *t, MDL); if (!t) log_fatal ("no memory for option tag data."); @@ -2889,8 +2890,7 @@ int parse_agent_information_option (packet, len, data) } /* Make an agent options structure to put on the list. */ - a = (struct agent_options *)dmalloc (sizeof *a, - "parse_agent_information_option"); + a = (struct agent_options *)dmalloc (sizeof *a, MDL); if (!a) log_fatal ("can't allocate space for agent option structure."); diff --git a/server/dhcpd.c b/server/dhcpd.c index 12c902b2c..220660bd2 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -3,7 +3,7 @@ DHCP Server Daemon. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * Use is subject to license terms which appear in the file named * ISC-LICENSE that should have accompanied this file when you * received it. If a file named ISC-LICENSE did not accompany this @@ -22,7 +22,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhcpd.c,v 1.80 2000/01/05 18:17:10 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium."; +"$Id: dhcpd.c,v 1.81 2000/01/26 14:56:18 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium."; #endif static char copyright[] = @@ -48,13 +48,6 @@ u_int16_t remote_port; struct in_addr limited_broadcast; -int log_priority; -#ifdef DEBUG -int log_perror = -1; -#else -int log_perror = 1; -#endif - const char *path_dhcpd_conf = _PATH_DHCPD_CONF; const char *path_dhcpd_db = _PATH_DHCPD_DB; const char *path_dhcpd_pid = _PATH_DHCPD_PID; @@ -157,7 +150,7 @@ int main (argc, argv, envp) } else { struct interface_info *tmp = ((struct interface_info *) - dmalloc (sizeof *tmp, "get_interface_list")); + dmalloc (sizeof *tmp, MDL)); if (!tmp) log_fatal ("Insufficient memory to %s %s", "record interface", argv [i]); @@ -238,12 +231,12 @@ int main (argc, argv, envp) exit(0); /* Now try to get the lease file name. */ - option_state_allocate (&options, "dhcpinform"); + option_state_allocate (&options, MDL); execute_statements_in_scope ((struct packet *)0, (struct lease *)0, (struct option_state *)0, - options, + options, &global_scope, &root_group, (struct group *)0); memset (&fname, 0, sizeof fname); @@ -251,13 +244,14 @@ int main (argc, argv, envp) if (oc && evaluate_option_cache (&fname, (struct packet *)0, (struct lease *)0, options, - (struct option_state *)0, oc)) { - s = dmalloc (fname.len + 1, "main"); + (struct option_state *)0, + &global_scope, oc, MDL)) { + s = dmalloc (fname.len + 1, MDL); if (!s) log_fatal ("no memory for lease db filename."); memcpy (s, fname.data, fname.len); s [fname.len] = 0; - data_string_forget (&fname, "main"); + data_string_forget (&fname, MDL); path_dhcpd_db = s; } @@ -265,18 +259,19 @@ int main (argc, argv, envp) if (oc && evaluate_option_cache (&fname, (struct packet *)0, (struct lease *)0, options, - (struct option_state *)0, oc)) { - s = dmalloc (fname.len + 1, "main"); + (struct option_state *)0, + &global_scope, oc, MDL)) { + s = dmalloc (fname.len + 1, MDL); if (!s) log_fatal ("no memory for lease db filename."); memcpy (s, fname.data, fname.len); s [fname.len] = 0; - data_string_forget (&fname, "main"); + data_string_forget (&fname, MDL); path_dhcpd_pid = s; } /* Don't need the options anymore. */ - option_state_dereference (&options, "main"); + option_state_dereference (&options, MDL); /* Start up the database... */ db_startup (lftest); @@ -307,7 +302,7 @@ int main (argc, argv, envp) /* Start up a listener for the object management API protocol. */ listener = (omapi_object_t *)0; - result = omapi_generic_new (&listener, "main"); + result = omapi_generic_new (&listener, MDL); if (result != ISC_R_SUCCESS) log_fatal ("Can't allocate new generic object: %s\n", isc_result_totext (result)); @@ -401,10 +396,6 @@ static void usage () "\n [-lf lease-file] [if0 [...ifN]]"); } -void cleanup () -{ -} - void lease_pinged (from, packet, length) struct iaddr from; u_int8_t *packet; @@ -433,15 +424,14 @@ void lease_pinged (from, packet, length) } if (lp -> ends > cur_time) { - log_error ("ICMP Echo reply arrived while lease %s was valid.\n", - piaddr (from)); + log_error ("ICMP Echo reply while lease %s valid\n", + piaddr (from)); } /* At this point it looks like we pinged a lease and got a response, which shouldn't have happened. */ - data_string_forget (&lp -> state -> parameter_request_list, - "lease_pinged"); - free_lease_state (lp -> state, "lease_pinged"); + data_string_forget (&lp -> state -> parameter_request_list, MDL); + free_lease_state (lp -> state, MDL); lp -> state = (struct lease_state *)0; abandon_lease (lp, "pinged before offer"); diff --git a/server/dhcpd.conf.cat5 b/server/dhcpd.conf.cat5 index f97bec6b2..e076b4cfa 100644 --- a/server/dhcpd.conf.cat5 +++ b/server/dhcpd.conf.cat5 @@ -87,18 +87,22 @@ dhcpd.conf(5) dhcpd.conf(5) tions can be enclosed in a _g_r_o_u_p declaration along with the parameters which are common to that department. For clients whose addresses will be dynamically assigned, - there is currently no way to group parameter assignments - other than by network topology. - - When a client is to be booted, its boot parameters are - determined by first consulting that client's _h_o_s_t declara­ - tion (if any), then consulting the _g_r_o_u_p declaration (if - any) which enclosed that _h_o_s_t declaration, then consulting - the _s_u_b_n_e_t declaration for the subnet on which the client - is booting, then consulting the _s_h_a_r_e_d_-_n_e_t_w_o_r_k declaration - (if any) containing that subnet, and finally consulting - the top-level parameters which may be specified outside of - any declaration. + class declarations and conditional declarations may be + used to group parameter assignments based on information + the client sends. + + When a client is to be booted, its boot parameters are + determined by consulting that client's _h_o_s_t declaration + (if any), and then consulting the any _c_l_a_s_s declarations + matching the client, followed by the _p_o_o_l, _s_u_b_n_e_t and + _s_h_a_r_e_d_-_n_e_t_w_o_r_k declarations for the IP address assigned to + the client. Each of these declarations itself appears + within a lexical scope, and all declarations at less spe­ + cific lexical scopes are also consulted for client option + declarations as well. Scopes are never considered twice, + and if parameters are declared in more than one scope, the + parameter declared in the most specific scope is the one + that is used. When dhcpd tries to find a _h_o_s_t declaration for a client, it first looks for a _h_o_s_t declaration which has a _f_i_x_e_d_- @@ -120,10 +124,6 @@ EEXXAAMMPPLLEESS range 204.254.239.10 204.254.239.30; } - subnet 204.254.239.32 netmask 255.255.255.224 { - _s_u_b_n_e_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._. - range 204.254.239.42 204.254.239.62; - } @@ -136,6 +136,11 @@ EEXXAAMMPPLLEESS dhcpd.conf(5) dhcpd.conf(5) + subnet 204.254.239.32 netmask 255.255.255.224 { + _s_u_b_n_e_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._. + range 204.254.239.42 204.254.239.62; + } + subnet 204.254.239.64 netmask 255.255.255.224 { _s_u_b_n_e_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._. range 204.254.239.74 204.254.239.94; @@ -184,12 +189,7 @@ dhcpd.conf(5) dhcpd.conf(5) Note that the address here is specified numerically. This is not required - if you have a different domain name - for each interface on your router, it's perfectly legiti­ - mate to use the domain name for that interface instead of - the numeric address. However, in many cases there may be - only one domain name for all of a router's IP addresses, - and it would not be appropriate to use that name here. - + for each interface on your router, it's perfectly @@ -202,17 +202,23 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - In Figure 1 there is also a _g_r_o_u_p statement, which pro­ - vides common parameters for a set of three hosts - zappo, - beppo and harpo. As you can see, these hosts are all in - the test.isc.org domain, so it might make sense for a - group-specific parameter to override the domain name sup­ + legitimate to use the domain name for that interface + instead of the numeric address. However, in many cases + there may be only one domain name for all of a router's IP + addresses, and it would not be appropriate to use that + name here. + + In Figure 1 there is also a _g_r_o_u_p statement, which pro­ + vides common parameters for a set of three hosts - zappo, + beppo and harpo. As you can see, these hosts are all in + the test.isc.org domain, so it might make sense for a + group-specific parameter to override the domain name sup­ plied to these hosts: option domain-name "test.isc.org"; Also, given the domain they're in, these are probably test - machines. If we wanted to test the DHCP leasing mecha­ + machines. If we wanted to test the DHCP leasing mecha­ nism, we might set the lease timeout somewhat shorter than the default: @@ -220,26 +226,26 @@ dhcpd.conf(5) dhcpd.conf(5) default-lease-time 120; You may have noticed that while some parameters start with - the _o_p_t_i_o_n keyword, some do not. Parameters starting + the _o_p_t_i_o_n keyword, some do not. Parameters starting with the _o_p_t_i_o_n keyword correspond to actual DHCP options, while parameters that do not start with the option keyword either control the behaviour of the DHCP server (e.g., how - long a lease dhcpd will give out), or specify client + long a lease dhcpd will give out), or specify client parameters that are not optional in the DHCP protocol (for example, server-name and filename). - In Figure 1, each host had _h_o_s_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s. - These could include such things as the _h_o_s_t_n_a_m_e option, - the name of a file to upload (the _f_i_l_e_n_a_m_e _p_a_r_a_m_e_t_e_r_) _a_n_d - _t_h_e _a_d_d_r_e_s_s _o_f _t_h_e _s_e_r_v_e_r _f_r_o_m _w_h_i_c_h _t_o _u_p_l_o_a_d _t_h_e _f_i_l_e - _(_t_h_e _n_e_x_t_-_s_e_r_v_e_r parameter). In general, any parameter - can appear anywhere that parameters are allowed, and will - be applied according to the scope in which the parameter + In Figure 1, each host had _h_o_s_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s. + These could include such things as the _h_o_s_t_n_a_m_e option, + the name of a file to upload (the _f_i_l_e_n_a_m_e _p_a_r_a_m_e_t_e_r_) _a_n_d + _t_h_e _a_d_d_r_e_s_s _o_f _t_h_e _s_e_r_v_e_r _f_r_o_m _w_h_i_c_h _t_o _u_p_l_o_a_d _t_h_e _f_i_l_e + _(_t_h_e _n_e_x_t_-_s_e_r_v_e_r parameter). In general, any parameter + can appear anywhere that parameters are allowed, and will + be applied according to the scope in which the parameter appears. - Imagine that you have a site with a lot of NCD X-Termi­ - nals. These terminals come in a variety of models, and - you want to specify the boot files for each models. One + Imagine that you have a site with a lot of NCD X-Termi­ + nals. These terminals come in a variety of models, and + you want to specify the boot files for each models. One way to do this would be to have host declarations for each server and group them by model: @@ -250,12 +256,6 @@ dhcpd.conf(5) dhcpd.conf(5) host ncd1 { hardware ethernet 0:c0:c3:49:2b:57; } host ncd4 { hardware ethernet 0:c0:c3:80:fc:32; } host ncd8 { hardware ethernet 0:c0:c3:22:46:81; } - } - - group { - filename "Xncd19c"; - next-server ncd-booter; - @@ -268,6 +268,12 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) + } + + group { + filename "Xncd19c"; + next-server ncd-booter; + host ncd2 { hardware ethernet 0:c0:c3:88:2d:81; } host ncd3 { hardware ethernet 0:c0:c3:00:14:11; } } @@ -282,18 +288,18 @@ dhcpd.conf(5) dhcpd.conf(5) } AADDDDRREESSSS PPOOOOLLSS - The ppooooll declaration can be used to specify a pool of - addresses that will be treated differently than another - pool of addresses, even on the same network segment or + The ppooooll declaration can be used to specify a pool of + addresses that will be treated differently than another + pool of addresses, even on the same network segment or subnet. For example, you may want to provide a large set of addresses that can be assigned to DHCP clients that are - registered to your DHCP server, while providing a smaller - set of addresses, possibly with short lease times, that - are available for unknown clients. If you have a fire­ - wall, you may be able to arrange for addresses from one + registered to your DHCP server, while providing a smaller + set of addresses, possibly with short lease times, that + are available for unknown clients. If you have a fire­ + wall, you may be able to arrange for addresses from one pool to be allowed access to the Internet, while addresses - in another pool are not, thus encouraging users to regis­ - ter their DHCP clients. To do this, you would set up a + in another pool are not, thus encouraging users to regis­ + ter their DHCP clients. To do this, you would set up a pair of pool declarations: subnet 10.0.0.0 netmask 255.255.255.0 { @@ -316,12 +322,6 @@ AADDDDRREESSSS PPOOOOLLSS } } - It is also possible to set up entirely different subnets - for known and unknown clients - address pools exist at the - level of shared networks, so address ranges within pool - declarations can be on different subnets. - - As you can see in the preceding example, pools can have @@ -334,60 +334,60 @@ AADDDDRREESSSS PPOOOOLLSS dhcpd.conf(5) dhcpd.conf(5) + It is also possible to set up entirely different subnets + for known and unknown clients - address pools exist at the + level of shared networks, so address ranges within pool + declarations can be on different subnets. + + As you can see in the preceding example, pools can have permit lists that control which clients are allowed access to the pool and which aren't. Each entry in a pool's per­ - mit list is introduced with the _a_l_l_o_w or _d_e_n_y keyword. - If a pool has a permit list, then only those clients that + mit list is introduced with the _a_l_l_o_w or _d_e_n_y keyword. + If a pool has a permit list, then only those clients that match specific entries on the permit list will be elegible - to be assigned addresses from the pool. If a pool has a - deny list, then only those clients that do not match any + to be assigned addresses from the pool. If a pool has a + deny list, then only those clients that do not match any entries on the deny list will be elegible. If both per­ - mit and deny lists exist for a pool, then only clients - that match the permit list and do not match the deny list + mit and deny lists exist for a pool, then only clients + that match the permit list and do not match the deny list will be allowed access. AADDDDRREESSSS AALLLLOOCCAATTIIOONN - Address allocation is actually only done when a client is + Address allocation is actually only done when a client is in the INIT state and has sent a DHCPDISCOVER message. If the client thinks it has a valid lease and sends a DHCPRE­ QUEST to initiate or renew that lease, the server has only - three choices - it can ignore the DHCPREQUEST, send a - DHCPNAK to tell the client it should stop using the + three choices - it can ignore the DHCPREQUEST, send a + DHCPNAK to tell the client it should stop using the address, or send a DHCPACK, telling the client to go ahead - and use the address for a while. If the server finds the - address the client is requesting, and that address is - available to the client, the server will send a DHCPACK. + and use the address for a while. If the server finds the + address the client is requesting, and that address is + available to the client, the server will send a DHCPACK. If the address is no longer available, or the client isn't - permitted to have it, the server will send a DHCPNAK. If + permitted to have it, the server will send a DHCPNAK. If the server knows nothing about the, it will remain silent, unless the address is incorrect for the network segment to - which the client has been attached and the server is - authoritative for that network segment, in which case the - server will send a DHCPNAK even though it doesn't know + which the client has been attached and the server is + authoritative for that network segment, in which case the + server will send a DHCPNAK even though it doesn't know about the address. - When the DHCP server allocates a new address for a client - (remember, this only happens if the client has sent a + When the DHCP server allocates a new address for a client + (remember, this only happens if the client has sent a DHCPDISCOVER), it first looks to see if the client already - has a valid lease on an IP address, or if there is an old - IP address the client had before that hasn't yet been - reassigned. In that case, the server will take that + has a valid lease on an IP address, or if there is an old + IP address the client had before that hasn't yet been + reassigned. In that case, the server will take that address and check it to see if the client is still permit­ - ted to use it. If the client is no longer permitted to - use it, the lease is freed if the server thought it was - still in use - the fact that the client has sent a - DHCPDISCOVER proves to the server that the client is no + ted to use it. If the client is no longer permitted to + use it, the lease is freed if the server thought it was + still in use - the fact that the client has sent a + DHCPDISCOVER proves to the server that the client is no longer using the lease. If no existing lease is found, or if the client is forbid­ - den to receive the existing lease, then the server will - look in the list of address pools for the network segment - to which the client is attached for a lease that is not in - use and that the client is permitted to have. It looks - through each pool declaration in sequence (all _r_a_n_g_e dec­ - larations that appear outside of pool declarations are - grouped into a single pool with no permit list). If the - permit list for the pool allows the client to be allocated + den to receive the existing lease, then the server will + look in the list of address pools for the network segment @@ -400,61 +400,61 @@ AADDDDRREESSSS AALLLLOOCCAATTIIOONN dhcpd.conf(5) dhcpd.conf(5) - an address from that pool, the pool is examined to see if + to which the client is attached for a lease that is not in + use and that the client is permitted to have. It looks + through each pool declaration in sequence (all _r_a_n_g_e dec­ + larations that appear outside of pool declarations are + grouped into a single pool with no permit list). If the + permit list for the pool allows the client to be allocated + an address from that pool, the pool is examined to see if there is an address available. If so, then the client is - tentatively assigned that address. Otherwise, the next - pool is tested. If no addresses are found that can be + tentatively assigned that address. Otherwise, the next + pool is tested. If no addresses are found that can be assigned to the client, no response is sent to the client. - If an address is found that the client is permitted to - have, and that has never been assigned to any client + If an address is found that the client is permitted to + have, and that has never been assigned to any client before, the address is immediately allocated to the - client. If the address is available for allocation but - has been previously assigned to a different client, the - server will keep looking in hopes of finding an address + client. If the address is available for allocation but + has been previously assigned to a different client, the + server will keep looking in hopes of finding an address that has never before been assigned to a client. CCLLIIEENNTT CCLLAASSSSIINNGG Clients can be seperated into classes, and treated differ­ - ently depending on what class they are in. This sepera­ - tion can be done either with a conditional statement, or - with a match statement within the class declaration. It - is possible to specify a limit on the total number of - clients within a particular class or subclass that may - hold leases at one time, and it is possible to specify - automatic subclassing based on the contents of the client + ently depending on what class they are in. This sepera­ + tion can be done either with a conditional statement, or + with a match statement within the class declaration. It + is possible to specify a limit on the total number of + clients within a particular class or subclass that may + hold leases at one time, and it is possible to specify + automatic subclassing based on the contents of the client packet. To add clients to classes based on conditional evaluation, - you would write an conditional statement to match the - clients you wanted in the class, and then put an aadddd + you would write an conditional statement to match the + clients you wanted in the class, and then put an aadddd statement in the conditional's list of statements: if substring (option dhcp-client-identifier, 0, 3) = "RAS" { add "ras-clients"; } - A nearly equivalent way to do this is to simply specify + A nearly equivalent way to do this is to simply specify the conditional expression as a matching expression in the class statement: class "ras-clients" { match if substring (option dhcp-client-identifier, 0, 3) = "RAS"; } - Note that whether you use matching expressions or add - statements (or both) to classify clients, you must always + Note that whether you use matching expressions or add + statements (or both) to classify clients, you must always write a class declaration for any class that you use. If - there will be no match statement and no in-scope state­ + there will be no match statement and no in-scope state­ ments for a class, the declaration should look like this: class "ras-clients" { } - Also, the aadddd statement adds the client to the class as - the client's scopes are being evaluated - after any - address assignment decision has been made. This means - that a client that's a member of a class due to an add - statement will not be affected by pool permits related to - 7 @@ -466,20 +466,25 @@ CCLLIIEENNTT CCLLAASSSSIINNGG dhcpd.conf(5) dhcpd.conf(5) - that class - when the pool permit list is computed, the - client will not yet be a member of the pool. This is an - inconsistency that will probably be addressed in later - versions of the DHCP server, but it important to be aware + Also, the aadddd statement adds the client to the class as + the client's scopes are being evaluated - after any + address assignment decision has been made. This means + that a client that's a member of a class due to an add + statement will not be affected by pool permits related to + that class - when the pool permit list is computed, the + client will not yet be a member of the pool. This is an + inconsistency that will probably be addressed in later + versions of the DHCP server, but it important to be aware of it at lease for the time being. SSUUBBCCLLAASSSSEESS - In addition to classes, it is possible to declare sub­ - classes. A subclass is a class with the same name as a - regular class, but with a specific submatch expression + In addition to classes, it is possible to declare sub­ + classes. A subclass is a class with the same name as a + regular class, but with a specific submatch expression which is hashed for quick matching. This is essentially a speed hack - the main difference between five classes with - match expressions and one class with five subclasses is - that it will be quicker to find the subclasses. Sub­ + match expressions and one class with five subclasses is + that it will be quicker to find the subclasses. Sub­ classes work as follows: class "allocation-class-1" { @@ -506,20 +511,15 @@ SSUUBBCCLLAASSSSEESS } The data following the class name in the subclass declara­ - tion is a constant value to use in matching the match - expression for the class. When class matching is done, - the server will evaluate the match expression and then - look the result up in the hash table. If it finds a + tion is a constant value to use in matching the match + expression for the class. When class matching is done, + the server will evaluate the match expression and then + look the result up in the hash table. If it finds a match, the client is considered a member of both the class and the subclass. Subclasses can be declared with or without scope. In the - above example, the sole purpose of the subclass is to - allow some clients access to one address pool, while other - clients are given access to the other pool, so these sub­ - classes are declared without scopes. If part of the pur­ - pose of the subclass were to define different parameter - values for some clients, you might want to declare some + above example, the sole purpose of the subclass is to @@ -532,11 +532,16 @@ SSUUBBCCLLAASSSSEESS dhcpd.conf(5) dhcpd.conf(5) + allow some clients access to one address pool, while other + clients are given access to the other pool, so these sub­ + classes are declared without scopes. If part of the pur­ + pose of the subclass were to define different parameter + values for some clients, you might want to declare some subclasses with scopes. - In the above example, if you had a single client that - needed some configuration parameters, while most didn't, - you might write the following subclass declaration for + In the above example, if you had a single client that + needed some configuration parameters, while most didn't, + you might write the following subclass declaration for that client: subclass "allocation-class-2" 1:08:00:2b:a1:11:31 { @@ -544,23 +549,23 @@ dhcpd.conf(5) dhcpd.conf(5) filename "/tftpboot/netbsd.alphapc-diskless"; } - In this example, we've used subclassing as a way to con­ - trol address allocation on a per-client basis. However, + In this example, we've used subclassing as a way to con­ + trol address allocation on a per-client basis. However, it's also possible to use subclassing in ways that are not specific to clients - for example, to use the value of the vendor-class-identifier option to determine what values to - send in the vendor-encapsulated-options option. An exam­ + send in the vendor-encapsulated-options option. An exam­ ple of this is shown under the VENDOR ENCAPSULATED OPTIONS head later on in this document. PPEERR--CCLLAASSSS AADDDDRREESSSS AASSSSIIGGNNMMEENNTT LLIIMMIITTSS - You may specify a limit to the number of clients in a - class that can be assigned leases. The effect of this - will be to make it difficult for a new client in a class - to get an address. Once a class with such a limit has + You may specify a limit to the number of clients in a + class that can be assigned leases. The effect of this + will be to make it difficult for a new client in a class + to get an address. Once a class with such a limit has reached its limit, the only way a new client in that class - can get a lease is for an existing client to relinquish - its lease, either by letting it expire, or by sending a + can get a lease is for an existing client to relinquish + its lease, either by letting it expire, or by sending a DHCPRELEASE packet. Classes with lease limits are speci­ fied as follows: @@ -568,24 +573,19 @@ PPEERR--CCLLAASSSS AADDDDRREESSSS AASSSSIIGGNNMMEENNTT lease limit 4; } - This will produce a class in which a maximum of four mem­ + This will produce a class in which a maximum of four mem­ bers may hold a lease at one time. SSPPAAWWNNIINNGG CCLLAASSSSEESS - It is possible to declare a _s_p_a_w_n_i_n_g _c_l_a_s_s. A spawning - class is a class that automatically produces subclasses + It is possible to declare a _s_p_a_w_n_i_n_g _c_l_a_s_s. A spawning + class is a class that automatically produces subclasses based on what the client sends. The reason that spawning - classes were created was to make it possible to create - lease-limited classes on the fly. The envisioned appli­ - cation is a cable-modem environment where the ISP wishes + classes were created was to make it possible to create + lease-limited classes on the fly. The envisioned appli­ + cation is a cable-modem environment where the ISP wishes to provide clients at a particular site with more than one IP address, but does not wish to provide such clients with - their own subnet, nor give them an unlimited number of IP - addresses from the network segment to which they are con­ - nected. - - Many cable modem head-end systems can be configured to add - a Relay Agent Information option to DHCP packets when + their own subnet, nor give them an unlimited number of IP @@ -598,60 +598,60 @@ SSPPAAWWNNIINNGG CCLLAASSSSEESS dhcpd.conf(5) dhcpd.conf(5) - relaying them to the DHCP server. These systems typi­ - cally add a circuit ID or remote ID option that uniquely + addresses from the network segment to which they are con­ + nected. + + Many cable modem head-end systems can be configured to add + a Relay Agent Information option to DHCP packets when + relaying them to the DHCP server. These systems typi­ + cally add a circuit ID or remote ID option that uniquely identifies the customer site. To take advantage of this, you can write a class declaration as follows: class "customer" { - match if exists agent.circuit-id; spawn with option agent.circuit-id; lease limit 4; } - Now whenever a request comes in from a customer site, the + Now whenever a request comes in from a customer site, the circuit ID option will be checked against the class's hash - table. If a subclass is found that matches the circuit - ID, the client will be classified in that subclass and - treated accordingly. If no subclass is found matching - the circuit ID, a new one will be created and logged in - the ddhhccppdd..lleeaasseess file, and the client will be classified - in this new class. Once the client has been classified, - it will be treated according to the rules of the class, - including, in this case, being subject to the per-site + table. If a subclass is found that matches the circuit + ID, the client will be classified in that subclass and + treated accordingly. If no subclass is found matching + the circuit ID, a new one will be created and logged in + the ddhhccppdd..lleeaasseess file, and the client will be classified + in this new class. Once the client has been classified, + it will be treated according to the rules of the class, + including, in this case, being subject to the per-site limit of four leases. - The use of the subclass spawning mechanism is not - restricted to relay agent options - this particular exam­ - ple is given only because it is a fairly straightforward + The use of the subclass spawning mechanism is not + restricted to relay agent options - this particular exam­ + ple is given only because it is a fairly straightforward one. RREEFFEERREENNCCEE:: EEVVEENNTTSS - There are three kinds of events that can happen regarding - a lease, and it is possible to declare statements that - occur when any of these events happen. These events are + There are three kinds of events that can happen regarding + a lease, and it is possible to declare statements that + occur when any of these events happen. These events are the commit event, when the server has made a commitment of - a certain lease to a client, the release event, when the - client has released the server from its commitment, and + a certain lease to a client, the release event, when the + client has released the server from its commitment, and the expiry event, when the commitment expires. - Currently, only the commit event is fully supported. The - commit event occurs just before the DHCP server sends a - DHCPACK message to a DHCP client, or a BOOTREPLY message + Currently, only the commit event is fully supported. The + commit event occurs just before the DHCP server sends a + DHCPACK message to a DHCP client, or a BOOTREPLY message to a BOOTP client. - The release event is partially supported, but currently - will not occur if the server is restarted after the lease + The release event is partially supported, but currently + will not occur if the server is restarted after the lease is assigned. This will be fixed in the near future. The expiry event is not currently supported at all. This will also be fixed in the reasonably near future. - To declare a set of statements to execute when an event - happens, you must use the oonn statement, followed by the - name of the event, followed by a series of statements to - execute when the event happens, enclosed in braces. For - example: + To declare a set of statements to execute when an event @@ -664,6 +664,11 @@ RREEFFEERREENNCCEE:: EEVVEENNTTSS dhcpd.conf(5) dhcpd.conf(5) + happens, you must use the oonn statement, followed by the + name of the event, followed by a series of statements to + execute when the event happens, enclosed in braces. For + example: + on commit { if dns-update ("a", concat (option host-name, ".ssd.example.net"), @@ -687,24 +692,24 @@ RREEFFEERREENNCCEE:: DDEECCLLAARRAATTIIOONNSS [ _d_e_c_l_a_r_a_t_i_o_n_s ] }} - The _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement is used to inform the DHCP + The _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement is used to inform the DHCP server that some IP subnets actually share the same physi­ - cal network. Any subnets in a shared network should be - declared within a _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement. Parameters - specified in the _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement will be used - when booting clients on those subnets unless parameters - provided at the subnet or host level override them. If + cal network. Any subnets in a shared network should be + declared within a _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement. Parameters + specified in the _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement will be used + when booting clients on those subnets unless parameters + provided at the subnet or host level override them. If any subnet in a shared network has addresses available for - dynamic allocation, those addresses are collected into a - common pool for that shared network and assigned to - clients as needed. There is no way to distinguish on + dynamic allocation, those addresses are collected into a + common pool for that shared network and assigned to + clients as needed. There is no way to distinguish on which subnet of a shared network a client should boot. _N_a_m_e should be the name of the shared network. This name - is used when printing debugging messages, so it should be - descriptive for the shared network. The name may have - the syntax of a valid domain name (although it will never - be used as such), or it may be any arbitrary name, + is used when printing debugging messages, so it should be + descriptive for the shared network. The name may have + the syntax of a valid domain name (although it will never + be used as such), or it may be any arbitrary name, enclosed in quotes. TThhee _s_u_b_n_e_t ssttaatteemmeenntt @@ -714,11 +719,6 @@ RREEFFEERREENNCCEE:: DDEECCLLAARRAATTIIOONNSS [ _d_e_c_l_a_r_a_t_i_o_n_s ] }} - The _s_u_b_n_e_t statement is used to provide dhcpd with enough - information to tell whether or not an IP address is on - that subnet. It may also be used to provide subnet-spe­ - cific parameters and to specify what addresses may be - 11 @@ -730,21 +730,25 @@ RREEFFEERREENNCCEE:: DDEECCLLAARRAATTIIOONNSS dhcpd.conf(5) dhcpd.conf(5) - dynamically allocated to clients booting on that subnet. - Such addresses are specified using the _r_a_n_g_e declaration. + The _s_u_b_n_e_t statement is used to provide dhcpd with enough + information to tell whether or not an IP address is on + that subnet. It may also be used to provide subnet-spe­ + cific parameters and to specify what addresses may be + dynamically allocated to clients booting on that subnet. + Such addresses are specified using the _r_a_n_g_e declaration. - The _s_u_b_n_e_t_-_n_u_m_b_e_r should be an IP address or domain name - which resolves to the subnet number of the subnet being + The _s_u_b_n_e_t_-_n_u_m_b_e_r should be an IP address or domain name + which resolves to the subnet number of the subnet being described. The _n_e_t_m_a_s_k should be an IP address or domain name which resolves to the subnet mask of the subnet being described. The subnet number, together with the netmask, - are sufficient to determine whether any given IP address + are sufficient to determine whether any given IP address is on the specified subnet. - Although a netmask must be given with every subnet decla­ + Although a netmask must be given with every subnet decla­ ration, it is recommended that if there is any variance in - subnet masks at a site, a subnet-mask option statement be - used in each subnet declaration to set the desired subnet + subnet masks at a site, a subnet-mask option statement be + used in each subnet declaration to set the desired subnet mask, since any subnet-mask option statement will override the subnet mask declared in the subnet statement. @@ -753,13 +757,13 @@ dhcpd.conf(5) dhcpd.conf(5) rraannggee [ ddyynnaammiicc--bboooottpp ] _l_o_w_-_a_d_d_r_e_s_s [ _h_i_g_h_-_a_d_d_r_e_s_s];; For any subnet on which addresses will be assigned dynami­ - cally, there must be at least one _r_a_n_g_e statement. The - range statement gives the lowest and highest IP addresses - in a range. All IP addresses in the range should be in + cally, there must be at least one _r_a_n_g_e statement. The + range statement gives the lowest and highest IP addresses + in a range. All IP addresses in the range should be in the subnet in which the _r_a_n_g_e statement is declared. The - _d_y_n_a_m_i_c_-_b_o_o_t_p flag may be specified if addresses in the - specified range may be dynamically assigned to BOOTP - clients as well as DHCP clients. When specifying a sin­ + _d_y_n_a_m_i_c_-_b_o_o_t_p flag may be specified if addresses in the + specified range may be dynamically assigned to BOOTP + clients as well as DHCP clients. When specifying a sin­ gle address, _h_i_g_h_-_a_d_d_r_e_s_s can be omitted. TThhee _h_o_s_t ssttaatteemmeenntt @@ -769,21 +773,17 @@ dhcpd.conf(5) dhcpd.conf(5) [ _d_e_c_l_a_r_a_t_i_o_n_s ] }} - There must be at least one hhoosstt statement for every BOOTP - client that is to be served. hhoosstt statements may also be - specified for DHCP clients, although this is not required + There must be at least one hhoosstt statement for every BOOTP + client that is to be served. hhoosstt statements may also be + specified for DHCP clients, although this is not required unless booting is only enabled for known hosts. - If it is desirable to be able to boot a DHCP or BOOTP - client on more than one subnet with fixed addresses, more - than one address may be specified in the _f_i_x_e_d_-_a_d_d_r_e_s_s - parameter, or more than one hhoosstt statement may be speci­ + If it is desirable to be able to boot a DHCP or BOOTP + client on more than one subnet with fixed addresses, more + than one address may be specified in the _f_i_x_e_d_-_a_d_d_r_e_s_s + parameter, or more than one hhoosstt statement may be speci­ fied. - If client-specific boot parameters must change based on - the network to which the client is attached, then multiple - hhoosstt statements should be used. - @@ -796,22 +796,26 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - If a client is to be booted using a fixed address if it's + If client-specific boot parameters must change based on + the network to which the client is attached, then multiple + hhoosstt statements should be used. + + If a client is to be booted using a fixed address if it's possible, but should be allocated a dynamic address other­ - wise, then a hhoosstt statement must be specified without a + wise, then a hhoosstt statement must be specified without a ffiixxeedd--aaddddrreessss clause. _h_o_s_t_n_a_m_e should be a name identify­ - ing the host. If a _h_o_s_t_n_a_m_e option is not specified for + ing the host. If a _h_o_s_t_n_a_m_e option is not specified for the host, _h_o_s_t_n_a_m_e is used. - _H_o_s_t declarations are matched to actual DHCP or BOOTP + _H_o_s_t declarations are matched to actual DHCP or BOOTP clients by matching the dhcp-client-identifier option - specified in the _h_o_s_t declaration to the one supplied by + specified in the _h_o_s_t declaration to the one supplied by the client, or, if the _h_o_s_t declaration or the client does - not provide a dhcp-client-identifier option, by matching + not provide a dhcp-client-identifier option, by matching the _h_a_r_d_w_a_r_e parameter in the _h_o_s_t declaration to the net­ - work hardware address supplied by the client. BOOTP - clients do not normally provide a _d_h_c_p_-_c_l_i_e_n_t_-_i_d_e_n_t_i_f_i_e_r, - so the hardware address must be used for all clients that + work hardware address supplied by the client. BOOTP + clients do not normally provide a _d_h_c_p_-_c_l_i_e_n_t_-_i_d_e_n_t_i_f_i_e_r, + so the hardware address must be used for all clients that may boot using the BOOTP protocol. TThhee _g_r_o_u_p ssttaatteemmeenntt @@ -821,35 +825,31 @@ dhcpd.conf(5) dhcpd.conf(5) [ _d_e_c_l_a_r_a_t_i_o_n_s ] }} - The group statement is used simply to apply one or more + The group statement is used simply to apply one or more parameters to a group of declarations. It can be used to - group hosts, shared networks, subnets, or even other + group hosts, shared networks, subnets, or even other groups. RREEFFEERREENNCCEE:: AALLLLOOWW AANNDD DDEENNYY - The _a_l_l_o_w and _d_e_n_y statements can be used to control the - response of the DHCP server to various sorts of requests. - The allow and deny keywords actually have different mean­ - ings depending on the context. In a pool context, these - keywords can be used to set up access lists for address - allocation pools. In other contexts, the keywords simply - control general server behaviour with respect to clients - based on scope. In a non-pool context, the _i_g_n_o_r_e key­ - word can be used in place of the _d_e_n_y keyword to prevent + The _a_l_l_o_w and _d_e_n_y statements can be used to control the + response of the DHCP server to various sorts of requests. + The allow and deny keywords actually have different mean­ + ings depending on the context. In a pool context, these + keywords can be used to set up access lists for address + allocation pools. In other contexts, the keywords simply + control general server behaviour with respect to clients + based on scope. In a non-pool context, the _i_g_n_o_r_e key­ + word can be used in place of the _d_e_n_y keyword to prevent logging of denied requests. AALLLLOOWW DDEENNYY AANNDD IIGGNNOORREE IINN SSCCOOPPEE - The following usages of allow and deny will work in any + The following usages of allow and deny will work in any scope, although it is not recommended that they be used in pool declarations. TThhee _u_n_k_n_o_w_n_-_c_l_i_e_n_t_s kkeeyywwoorrdd - aallllooww uunnkknnoowwnn--cclliieennttss;; - ddeennyy uunnkknnoowwnn--cclliieennttss;; - iiggnnoorree uunnkknnoowwnn--cclliieennttss;; - @@ -862,9 +862,13 @@ AALLLLOOWW DDEENNYY AANNDD IIGGNNOORREE IINN SSCCOOPPEE dhcpd.conf(5) dhcpd.conf(5) - The uunnkknnoowwnn--cclliieennttss flag is used to tell dhcpd whether or - not to dynamically assign addresses to unknown clients. - Dynamic address assignment to unknown clients is aalllloowwed + aallllooww uunnkknnoowwnn--cclliieennttss;; + ddeennyy uunnkknnoowwnn--cclliieennttss;; + iiggnnoorree uunnkknnoowwnn--cclliieennttss;; + + The uunnkknnoowwnn--cclliieennttss flag is used to tell dhcpd whether or + not to dynamically assign addresses to unknown clients. + Dynamic address assignment to unknown clients is aalllloowwed by default. TThhee _b_o_o_t_p kkeeyywwoorrdd @@ -873,8 +877,8 @@ dhcpd.conf(5) dhcpd.conf(5) ddeennyy bboooottpp;; iiggnnoorree bboooottpp;; - The bboooottpp flag is used to tell dhcpd whether or not to - respond to bootp queries. Bootp queries are aalllloowwed by + The bboooottpp flag is used to tell dhcpd whether or not to + respond to bootp queries. Bootp queries are aalllloowwed by default. TThhee _b_o_o_t_i_n_g kkeeyywwoorrdd @@ -883,39 +887,35 @@ dhcpd.conf(5) dhcpd.conf(5) ddeennyy bboooottiinngg;; iiggnnoorree bboooottiinngg;; - The bboooottiinngg flag is used to tell dhcpd whether or not to + The bboooottiinngg flag is used to tell dhcpd whether or not to respond to queries from a particular client. This keyword - only has meaning when it appears in a host declaration. - By default, booting is aalllloowwed, but if it is disabled for - a particular client, then that client will not be able to + only has meaning when it appears in a host declaration. + By default, booting is aalllloowwed, but if it is disabled for + a particular client, then that client will not be able to get and address from the DHCP server. TThhee _d_u_p_l_i_c_a_t_e_s kkeeyy­­ wwoorrdd aallllooww dduupplliiccaatteess;; ddeennyy dduupplliiccaatteess;; - Host declarations can match client messages based on the + Host declarations can match client messages based on the DHCP Client Identifer option or based on the client's net­ - work hardware type and MAC address. If the MAC address - is used, the host declaration will match any client with - that MAC address - even clients with different client + work hardware type and MAC address. If the MAC address + is used, the host declaration will match any client with + that MAC address - even clients with different client identifiers. This doesn't normally happen, but is possi­ - ble when one computer has more than one operating system - installed on it - for example, Microsoft Windows and + ble when one computer has more than one operating system + installed on it - for example, Microsoft Windows and NetBSD or Linux. - The dduupplliiccaatteess flag tells the DHCP server that if a - request is received from a client that matches the MAC - address of a host declaration, any other leases matching - that MAC address should be discarded by the server, even - if the UID is not the same. This is a violation of the - DHCP protocol, but can prevent clients whose client iden­ - tifiers change regularly from holding many leases at the - same time. By default, duplicates are aalllloowwed. TThhee - _d_e_c_l_i_n_e_s kkeeyywwoorrdd - - aallllooww ddeecclliinneess;; - ddeennyy ddeecclliinneess;; + The dduupplliiccaatteess flag tells the DHCP server that if a + request is received from a client that matches the MAC + address of a host declaration, any other leases matching + that MAC address should be discarded by the server, even + if the UID is not the same. This is a violation of the + DHCP protocol, but can prevent clients whose client iden­ + tifiers change regularly from holding many leases at the + same time. By default, duplicates are aalllloowwed. TThhee @@ -928,60 +928,60 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) + _d_e_c_l_i_n_e_s kkeeyywwoorrdd + + aallllooww ddeecclliinneess;; + ddeennyy ddeecclliinneess;; iiggnnoorree ddeecclliinneess;; - The DHCPDECLINE message is used by DHCP clients to indi­ - cate that the lease the server has offered is not valid. - When the server receives a DHCPDECLINE for a particular - address, it normally abandons that address, assuming that - some unauthorized system is using it. Unfortunately, a + The DHCPDECLINE message is used by DHCP clients to indi­ + cate that the lease the server has offered is not valid. + When the server receives a DHCPDECLINE for a particular + address, it normally abandons that address, assuming that + some unauthorized system is using it. Unfortunately, a malicious or buggy client can, using DHCPDECLINE messages, - completely exhaust the DHCP server's allocation pool. + completely exhaust the DHCP server's allocation pool. The server will reclaim these leases, but while the client - is running through the pool, it may cause serious thrash­ - ing in the DNS, and it will also cause the DHCP server to + is running through the pool, it may cause serious thrash­ + ing in the DNS, and it will also cause the DHCP server to forget old DHCP client address allocations. - The ddeecclliinneess flag tells the DHCP server whether or not to - honor DHCPDECLINE messages. If it is set to ddeennyy or - iiggnnoorree in a particular scope, the DHCP server will not + The ddeecclliinneess flag tells the DHCP server whether or not to + honor DHCPDECLINE messages. If it is set to ddeennyy or + iiggnnoorree in a particular scope, the DHCP server will not respond to DHCPDECLINE messages. AALLLLOOWW AANNDD DDEENNYY WWIITTHHIINN PPOOOOLL DDEECCLLAARRAATTIIOONNSS The uses of the allow and deny keyword shown in the previ­ - ous section work pretty much the same way whether the - client is sending a DHCPDISCOVER or a DHCPREQUEST message - - an address will be allocated to the client (either the - old address it's requesting, or a new address) and then + ous section work pretty much the same way whether the + client is sending a DHCPDISCOVER or a DHCPREQUEST message + - an address will be allocated to the client (either the + old address it's requesting, or a new address) and then that address will be tested to see if it's okay to let the client have it. If the client requested it, and it's not okay, the server will send a DHCPNAK message. Otherwise, - the server will simply not respond to the client. If it + the server will simply not respond to the client. If it is okay to give the address to the client, the server will send a DHCPACK message. The primary motivation behind pool declarations is to have - address allocation pools whose allocation policies are - different. A client may be denied access to one pool, - but allowed access to another pool on the same network - segment. In order for this to work, access control has - to be done during address allocation, not after address + address allocation pools whose allocation policies are + different. A client may be denied access to one pool, + but allowed access to another pool on the same network + segment. In order for this to work, access control has + to be done during address allocation, not after address allocation is done. - When a DHCPREQUEST message is processed, address alloca­ - tion simply consists of looking up the address the client - is requesting and seeing if it's still available for the - client. If it is, then the DHCP server checks both the - address pool permit lists and the relevant in-scope allow - and deny statements to see if it's okay to give the lease + When a DHCPREQUEST message is processed, address alloca­ + tion simply consists of looking up the address the client + is requesting and seeing if it's still available for the + client. If it is, then the DHCP server checks both the + address pool permit lists and the relevant in-scope allow + and deny statements to see if it's okay to give the lease to the client. In the case of a DHCPDISCOVER message, the - allocation process is done as described previously in the + allocation process is done as described previously in the ADDRESS ALLOCATION section. - When declaring permit lists for address allocation pools, - the following syntaxes are recognized following the allow - or deny keyword: - @@ -994,61 +994,61 @@ AALLLLOOWW AANNDD DDEENNYY WWIITTHHIINN PPOOOOLL DDEECC dhcpd.conf(5) dhcpd.conf(5) + When declaring permit lists for address allocation pools, + the following syntaxes are recognized following the allow + or deny keyword: + kknnoowwnn cclliieennttss;; - If specified, this statement either allows or prevents - allocation from this pool to any client that has a host + If specified, this statement either allows or prevents + allocation from this pool to any client that has a host declaration (i.e., is known). uunnkknnoowwnn cclliieennttss;; - If specified, this statement either allows or prevents - allocation from this pool to any client that has no host + If specified, this statement either allows or prevents + allocation from this pool to any client that has no host declaration (i.e., is not known). mmeemmbbeerrss ooff ""class"";; - If specified, this statement either allows or prevents - allocation from this pool to any client that is a member + If specified, this statement either allows or prevents + allocation from this pool to any client that is a member of the named class. ddyynnaammiicc bboooottpp cclliieennttss;; - If specified, this statement either allows or prevents + If specified, this statement either allows or prevents allocation from this pool to any bootp client. aauutthheennttiiccaatteedd cclliieennttss;; - If specified, this statement either allows or prevents - allocation from this pool to any client that has been + If specified, this statement either allows or prevents + allocation from this pool to any client that has been authenticated using the DHCP authentication protocol. This is not yet supported. uunnaauutthheennttiiccaatteedd cclliieennttss;; - If specified, this statement either allows or prevents - allocation from this pool to any client that has not been + If specified, this statement either allows or prevents + allocation from this pool to any client that has not been authenticated using the DHCP authentication protocol. This is not yet supported. aallll cclliieennttss;; - If specified, this statement either allows or prevents - allocation from this pool to all clients. This can be - used when you want to write a pool declaration for some + If specified, this statement either allows or prevents + allocation from this pool to all clients. This can be + used when you want to write a pool declaration for some reason, but hold it in reserve, or when you want to renum­ - ber your network quickly, and thus want the server to - force all clients that have been allocated addresses from - this pool to obtain new addresses immediately when they + ber your network quickly, and thus want the server to + force all clients that have been allocated addresses from + this pool to obtain new addresses immediately when they next renew. RREEFFEERREENNCCEE:: PPAARRAAMMEETTEERRSS TThhee _l_e_a_s_e_-_f_i_l_e_-_n_a_m_e ssttaatteemmeenntt - lleeaassee--ffiillee--nnaammee _n_a_m_e;; - - _N_a_m_e should be the name of the DHCP server's lease file. - 16 @@ -1060,6 +1060,9 @@ RREEFFEERREENNCCEE:: PPAARRAAMMEETTEERRSS dhcpd.conf(5) dhcpd.conf(5) + lleeaassee--ffiillee--nnaammee _n_a_m_e;; + + _N_a_m_e should be the name of the DHCP server's lease file. By default, this is /var/db/dhcpd.leases. This statement mmuusstt appear in the outer scope of the configuration file - if it appears in some other scope, it will have no effect. @@ -1068,11 +1071,11 @@ dhcpd.conf(5) dhcpd.conf(5) ppiidd--ffiillee--nnaammee _n_a_m_e;; - _N_a_m_e should be the name of the DHCP server's process ID - file. This is the file in which the DHCP server's pro­ - cess ID is stored when the server starts. By default, - this is /var/run/dhcpd.pid. Like the lease-file-name - statement, this statement must appear in the outer scope + _N_a_m_e should be the name of the DHCP server's process ID + file. This is the file in which the DHCP server's pro­ + cess ID is stored when the server starts. By default, + this is /var/run/dhcpd.pid. Like the lease-file-name + statement, this statement must appear in the outer scope of the configuration file. TThhee _d_e_f_a_u_l_t_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt @@ -1087,34 +1090,31 @@ dhcpd.conf(5) dhcpd.conf(5) mmaaxx--lleeaassee--ttiimmee _t_i_m_e;; - _T_i_m_e should be the maximum length in seconds that will be - assigned to a lease. The only exception to this is that - Dynamic BOOTP lease lengths, which are not specified by + _T_i_m_e should be the maximum length in seconds that will be + assigned to a lease. The only exception to this is that + Dynamic BOOTP lease lengths, which are not specified by the client, are not limited by this maximum. TThhee _m_i_n_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt mmiinn--lleeaassee--ttiimmee _t_i_m_e;; - _T_i_m_e should be the minimum length in seconds that will be + _T_i_m_e should be the minimum length in seconds that will be assigned to a lease. TThhee _m_i_n_-_s_e_c_s ssttaatteemmeenntt mmiinn--sseeccss _s_e_c_o_n_d_s;; - _S_e_c_o_n_d_s should be the minimum number of seconds since a + _S_e_c_o_n_d_s should be the minimum number of seconds since a client began trying to acquire a new lease before the DHCP server will respond to its request. The number of seconds is based on what the client reports, and the maximum value - that the client can report is 255 seconds. Generally, - setting this to one will result in the DHCP server not - responding to the client's first request, but always + that the client can report is 255 seconds. Generally, + setting this to one will result in the DHCP server not + responding to the client's first request, but always responding to its second request. - This can be used to set up a secondary DHCP server which - never offers an address to a client until the primary - 17 @@ -1126,36 +1126,38 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - server has been given a chance to do so. If the primary - server is down, the client will bind to the secondary - server, but otherwise clients should always bind to the - primary. Note that this does not, by itself, permit a - primary server and a secondary server to share a pool of + This can be used to set up a secondary DHCP server which + never offers an address to a client until the primary + server has been given a chance to do so. If the primary + server is down, the client will bind to the secondary + server, but otherwise clients should always bind to the + primary. Note that this does not, by itself, permit a + primary server and a secondary server to share a pool of dynamically-allocatable addresses. TThhee _h_a_r_d_w_a_r_e ssttaatteemmeenntt hhaarrddwwaarree _h_a_r_d_w_a_r_e_-_t_y_p_e _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s;; - In order for a BOOTP client to be recognized, its network - hardware address must be declared using a _h_a_r_d_w_a_r_e clause - in the _h_o_s_t statement. _h_a_r_d_w_a_r_e_-_t_y_p_e must be the name of - a physical hardware interface type. Currently, only the - eetthheerrnneett and ttookkeenn--rriinngg types are recognized, although - support for a ffddddii hardware type (and others) would also - be desirable. The _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s should be a set of - hexadecimal octets (numbers from 0 through ff) seperated - by colons. The _h_a_r_d_w_a_r_e statement may also be used for + In order for a BOOTP client to be recognized, its network + hardware address must be declared using a _h_a_r_d_w_a_r_e clause + in the _h_o_s_t statement. _h_a_r_d_w_a_r_e_-_t_y_p_e must be the name of + a physical hardware interface type. Currently, only the + eetthheerrnneett and ttookkeenn--rriinngg types are recognized, although + support for a ffddddii hardware type (and others) would also + be desirable. The _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s should be a set of + hexadecimal octets (numbers from 0 through ff) seperated + by colons. The _h_a_r_d_w_a_r_e statement may also be used for DHCP clients. TThhee _f_i_l_e_n_a_m_e ssttaatteemmeenntt ffiilleennaammee ""_f_i_l_e_n_a_m_e"";; - The _f_i_l_e_n_a_m_e statement can be used to specify the name of - the initial boot file which is to be loaded by a client. + The _f_i_l_e_n_a_m_e statement can be used to specify the name of + the initial boot file which is to be loaded by a client. The _f_i_l_e_n_a_m_e should be a filename recognizable to whatever - file transfer protocol the client can be expected to use + file transfer protocol the client can be expected to use to load the file. TThhee _s_e_r_v_e_r_-_n_a_m_e ssttaatteemmeenntt @@ -1170,17 +1172,15 @@ dhcpd.conf(5) dhcpd.conf(5) nneexxtt--sseerrvveerr _s_e_r_v_e_r_-_n_a_m_e;; - The _n_e_x_t_-_s_e_r_v_e_r statement is used to specify the host - address of the server from which the initial boot file - (specified in the _f_i_l_e_n_a_m_e statement) is to be loaded. - _S_e_r_v_e_r_-_n_a_m_e should be a numeric IP address or a domain - name. If no _n_e_x_t_-_s_e_r_v_e_r parameter applies to a given + The _n_e_x_t_-_s_e_r_v_e_r statement is used to specify the host + address of the server from which the initial boot file + (specified in the _f_i_l_e_n_a_m_e statement) is to be loaded. + _S_e_r_v_e_r_-_n_a_m_e should be a numeric IP address or a domain + name. If no _n_e_x_t_-_s_e_r_v_e_r parameter applies to a given client, the DHCP server's IP address is used. TThhee _f_i_x_e_d_-_a_d_d_r_e_s_s ssttaatteemmeenntt - ffiixxeedd--aaddddrreessss _a_d_d_r_e_s_s [,, _a_d_d_r_e_s_s ... ];; - 18 @@ -1192,14 +1192,16 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - The _f_i_x_e_d_-_a_d_d_r_e_s_s statement is used to assign one or more - fixed IP addresses to a client. It should only appear in + ffiixxeedd--aaddddrreessss _a_d_d_r_e_s_s [,, _a_d_d_r_e_s_s ... ];; + + The _f_i_x_e_d_-_a_d_d_r_e_s_s statement is used to assign one or more + fixed IP addresses to a client. It should only appear in a _h_o_s_t declaration. If more than one address is supplied, - then when the client boots, it will be assigned the - address which corresponds to the network on which it is - booting. If none of the addresses in the _f_i_x_e_d_-_a_d_d_r_e_s_s - statement are on the network on which the client is boot­ - ing, that client will not match the _h_o_s_t declaration con­ + then when the client boots, it will be assigned the + address which corresponds to the network on which it is + booting. If none of the addresses in the _f_i_x_e_d_-_a_d_d_r_e_s_s + statement are on the network on which the client is boot­ + ing, that client will not match the _h_o_s_t declaration con­ taining that _f_i_x_e_d_-_a_d_d_r_e_s_s statement. Each _a_d_d_r_e_s_s should be either an IP address or a domain name which resolves to one or more IP addresses. @@ -1208,13 +1210,13 @@ dhcpd.conf(5) dhcpd.conf(5) ddyynnaammiicc--bboooottpp--lleeaassee--ccuuttooffff _d_a_t_e;; - The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f statement sets the ending + The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f statement sets the ending time for all leases assigned dynamically to BOOTP clients. - Because BOOTP clients do not have any way of renewing - leases, and don't know that their leases could expire, by + Because BOOTP clients do not have any way of renewing + leases, and don't know that their leases could expire, by default dhcpd assignes infinite leases to all BOOTP clients. However, it may make sense in some situations to - set a cutoff date for all BOOTP leases - for example, the + set a cutoff date for all BOOTP leases - for example, the end of a school term, or the time at night when a facility is closed and all machines are required to be powered off. @@ -1223,29 +1225,27 @@ dhcpd.conf(5) dhcpd.conf(5) W YYYY/MM/DD HH:MM:SS - W is the day of the week expressed as a number from zero - (Sunday) to six (Saturday). YYYY is the year, including + W is the day of the week expressed as a number from zero + (Sunday) to six (Saturday). YYYY is the year, including the century. MM is the month expressed as a number from 1 - to 12. DD is the day of the month, counting from 1. HH - is the hour, from zero to 23. MM is the minute and SS is - the second. The time is always in Greenwich Mean Time + to 12. DD is the day of the month, counting from 1. HH + is the hour, from zero to 23. MM is the minute and SS is + the second. The time is always in Greenwich Mean Time (GMT), not local time. TThhee _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h ssttaatteemmeenntt ddyynnaammiicc--bboooottpp--lleeaassee--lleennggtthh _l_e_n_g_t_h;; - The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h statement is used to set - the length of leases dynamically assigned to BOOTP - clients. At some sites, it may be possible to assume - that a lease is no longer in use if its holder has not - used BOOTP or DHCP to get its address within a certain + The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h statement is used to set + the length of leases dynamically assigned to BOOTP + clients. At some sites, it may be possible to assume + that a lease is no longer in use if its holder has not + used BOOTP or DHCP to get its address within a certain time period. The period is specified in _l_e_n_g_t_h as a num­ - ber of seconds. If a client reboots using BOOTP during + ber of seconds. If a client reboots using BOOTP during the timeout period, the lease duration is reset to _l_e_n_g_t_h, - so a BOOTP client that boots frequently enough will never - lose its lease. Needless to say, this parameter should be - adjusted with extreme caution. + so a BOOTP client that boots frequently enough will never @@ -1258,25 +1258,28 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) + lose its lease. Needless to say, this parameter should be + adjusted with extreme caution. + TThhee _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s ssttaatteemmeenntt ggeett--lleeaassee--hhoossttnnaammeess _f_l_a_g;; - The _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s statement is used to tell dhcpd + The _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s statement is used to tell dhcpd whether or not to look up the domain name corresponding to - the IP address of each address in the lease pool and use - that address for the DHCP _h_o_s_t_n_a_m_e option. If _f_l_a_g is - true, then this lookup is done for all addresses in the - current scope. By default, or if _f_l_a_g is false, no + the IP address of each address in the lease pool and use + that address for the DHCP _h_o_s_t_n_a_m_e option. If _f_l_a_g is + true, then this lookup is done for all addresses in the + current scope. By default, or if _f_l_a_g is false, no lookups are done. TThhee _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s ssttaatteemmeenntt uussee--hhoosstt--ddeeccll--nnaammeess _f_l_a_g;; - If the _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s parameter is true in a given - scope, then for every host declaration within that scope, - the name provided for the host declaration will be sup­ + If the _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s parameter is true in a given + scope, then for every host declaration within that scope, + the name provided for the host declaration will be sup­ plied to the client as its hostname. So, for example, group { @@ -1296,7 +1299,7 @@ dhcpd.conf(5) dhcpd.conf(5) option host-name "joe"; } - An _o_p_t_i_o_n _h_o_s_t_-_n_a_m_e statement within a host declaration + An _o_p_t_i_o_n _h_o_s_t_-_n_a_m_e statement within a host declaration will override the use of the name in the host declaration. TThhee _a_u_t_h_o_r_i_t_a_t_i_v_e ssttaatteemmeenntt @@ -1305,13 +1308,10 @@ dhcpd.conf(5) dhcpd.conf(5) nnoott aauutthhoorriittaattiivvee;; - The DHCP server will normally assume that the configura­ + The DHCP server will normally assume that the configura­ tion information about a given network segment is known to be correct and is authoritative. So if a client requests - an IP address on a given network segment that the server - knows is not valid for that segment, the server will - respond with a DHCPNAK message, causing the client to for­ - get its IP address and try to get a new one. + an IP address on a given network segment that the server @@ -1324,60 +1324,60 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - If a DHCP server is being configured by somebody who is - not the network administrator and who therefore does not + knows is not valid for that segment, the server will + respond with a DHCPNAK message, causing the client to for­ + get its IP address and try to get a new one. + + If a DHCP server is being configured by somebody who is + not the network administrator and who therefore does not wish to assert this level of authority, then the statement - "not authoritative" should be written in the appropriate + "not authoritative" should be written in the appropriate scope in the configuration file. - Usually, writing nnoott aauutthhoorriittaattiivvee;; at the top level of + Usually, writing nnoott aauutthhoorriittaattiivvee;; at the top level of the file should be sufficient. However, if a DHCP server - is to be set up so that it is aware of some networks for - which it is authoritative and some networks for which it + is to be set up so that it is aware of some networks for + which it is authoritative and some networks for which it is not, it may be more appropriate to declare authority on a per-network-segment basis. Note that the most specific scope for which the concept of - authority makes any sense is the physical network segment - - either a shared-network statement or a subnet statement - that is not contained within a shared-network statement. + authority makes any sense is the physical network segment + - either a shared-network statement or a subnet statement + that is not contained within a shared-network statement. It is not meaningful to specify that the server is author­ - itative for some subnets within a shared network, but not - authoritative for others, nor is it meaningful to specify - that the server is authoritative for some host declara­ + itative for some subnets within a shared network, but not + authoritative for others, nor is it meaningful to specify + that the server is authoritative for some host declara­ tions and not others. TThhee _a_l_w_a_y_s_-_r_e_p_l_y_-_r_f_c_1_0_4_8 ssttaatteemmeenntt aallwwaayyss--rreeppllyy--rrffcc11004488 _f_l_a_g;; - Some BOOTP clients expect RFC1048-style responses, but do - not follow RFC1048 when sending their requests. You can - tell that a client is having this problem if it is not - getting the options you have configured for it and if you - see in the server log the message "(non-rfc1048)" printed + Some BOOTP clients expect RFC1048-style responses, but do + not follow RFC1048 when sending their requests. You can + tell that a client is having this problem if it is not + getting the options you have configured for it and if you + see in the server log the message "(non-rfc1048)" printed with each BOOTREQUEST that is logged. - If you want to send rfc1048 options to such a client, you - can set the aallwwaayyss--rreeppllyy--rrffcc11004488 option in that client's + If you want to send rfc1048 options to such a client, you + can set the aallwwaayyss--rreeppllyy--rrffcc11004488 option in that client's host declaration, and the DHCP server will respond with an - RFC-1048-style vendor options field. This flag can be - set in any scope, and will affect all clients covered by + RFC-1048-style vendor options field. This flag can be + set in any scope, and will affect all clients covered by that scope. TThhee _a_l_w_a_y_s_-_b_r_o_a_d_c_a_s_t ssttaatteemmeenntt aallwwaayyss--bbrrooaaddccaasstt _f_l_a_g;; - The DHCP and BOOTP protocols both require DHCP and BOOTP + The DHCP and BOOTP protocols both require DHCP and BOOTP clients to set the broadcast bit in the flags field of the - BOOTP message header. Unfortunately, some DHCP and BOOTP - clients do not do this, and therefore may not receive - responses from the DHCP server. The DHCP server can be - made to always broadcast its responses to clients by set­ - ting this flag to 'on' for the relevant scope. To avoid - creating excess broadcast traffic on your network, we rec­ - ommend that you restrict the use of this option to as few + BOOTP message header. Unfortunately, some DHCP and BOOTP + clients do not do this, and therefore may not receive + responses from the DHCP server. The DHCP server can be @@ -1390,7 +1390,11 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - clients as possible. For example, the Microsoft DHCP + made to always broadcast its responses to clients by set­ + ting this flag to 'on' for the relevant scope. To avoid + creating excess broadcast traffic on your network, we rec­ + ommend that you restrict the use of this option to as few + clients as possible. For example, the Microsoft DHCP client is known not to have this problem, as are the Open­ Transport and ISC DHCP clients. @@ -1399,13 +1403,13 @@ dhcpd.conf(5) dhcpd.conf(5) oonnee--lleeaassee--ppeerr--cclliieenntt _f_l_a_g;; If this flag is enabled, whenever a client sends a DHCPRE­ - QUEST for a particular lease, the server will automati­ - cally free any other leases the client holds. This pre­ - sumes that when the client sends a DHCPREQUEST, it has - forgotten any lease not mentioned in the DHCPREQUEST - - i.e., the client has only a single network interface _a_n_d - it does not remember leases it's holding on networks to - which it is not currently attached. Neither of these + QUEST for a particular lease, the server will automati­ + cally free any other leases the client holds. This pre­ + sumes that when the client sends a DHCPREQUEST, it has + forgotten any lease not mentioned in the DHCPREQUEST - + i.e., the client has only a single network interface _a_n_d + it does not remember leases it's holding on networks to + which it is not currently attached. Neither of these assumptions are guaranteed or provable, so we urge caution in the use of this statement. @@ -1413,37 +1417,33 @@ dhcpd.conf(5) dhcpd.conf(5) uussee--lleeaassee--aaddddrr--ffoorr--ddeeffaauulltt--rroouuttee _f_l_a_g;; - If the _u_s_e_-_l_e_a_s_e_-_a_d_d_r_-_f_o_r_-_d_e_f_a_u_l_t_-_r_o_u_t_e parameter is true + If the _u_s_e_-_l_e_a_s_e_-_a_d_d_r_-_f_o_r_-_d_e_f_a_u_l_t_-_r_o_u_t_e parameter is true in a given scope, then instead of sending the value speci­ - fied in the routers option (or sending no value at all), - the IP address of the lease being assigned is sent to the + fied in the routers option (or sending no value at all), + the IP address of the lease being assigned is sent to the client. This supposedly causes Win95 machines to ARP for - all IP addresses, which can be helpful if your router is + all IP addresses, which can be helpful if your router is configured for proxy ARP. TThhee _s_e_r_v_e_r_-_i_d_e_n_t_i_f_i_e_r ssttaatteemmeenntt sseerrvveerr--iiddeennttiiffiieerr _h_o_s_t_n_a_m_e;; - The server-identifier statement can be used to define the - value that is sent in the DHCP Server Identifier option - for a given scope. The value specified mmuusstt be an IP - address for the DHCP server, and must be reachable by all + The server-identifier statement can be used to define the + value that is sent in the DHCP Server Identifier option + for a given scope. The value specified mmuusstt be an IP + address for the DHCP server, and must be reachable by all clients served by a particular scope. - The use of the server-identifier statement is not recom­ - mended - the only reason to use it is to force a value + The use of the server-identifier statement is not recom­ + mended - the only reason to use it is to force a value other than the default value to be sent on occasions where - the default value would be incorrect. The default value - is the first IP address associated with the physical net­ + the default value would be incorrect. The default value + is the first IP address associated with the physical net­ work interface on which the request arrived. The usual case where the _s_e_r_v_e_r_-_i_d_e_n_t_i_f_i_e_r statement needs - to be sent is when a physical interface has more than one - IP address, and the one being sent by default isn't appro­ - priate for some or all clients served by that interface. - Another common case is when an alias is defined for the - purpose of having a consistent IP address for the DHCP + to be sent is when a physical interface has more than one @@ -1456,111 +1456,45 @@ dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) dhcpd.conf(5) - server, and it is desired that the clients use this IP + IP address, and the one being sent by default isn't appro­ + priate for some or all clients served by that interface. + Another common case is when an alias is defined for the + purpose of having a consistent IP address for the DHCP + server, and it is desired that the clients use this IP address when contacting the server. Supplying a value for the dhcp-server-identifier option is equivalent to using the server-identifier statement. RREEFFEERREENNCCEE:: OOPPTTIIOONN SSTTAATTEEMMEENNTTSS - DHCP option statements are documented in the ddhhccpp-- + DHCP option statements are documented in the ddhhccpp-- ooppttiioonnss((55)) manual page. -VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD OOPPTTIIOONNSS - The DHCP protocol defines the vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss - option, which allows vendors to define their own options - that will be sent encapsulated in a standard DHCP option. - The format of the vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option is - either a hunk of opaque data, or an actual option buffer - just like a standard DHCP option buffer. - - You can send this option to clients in one of two ways - - either define the data directly, using a text string or a - colon-seperated list of hexadecimal values, or define an - option space, define some options in that option space, - provide values for them, and specify that that option - space should be used to generate the vveennddoorr--eennccaappssuullaatteedd-- - ooppttiioonnss option in some scope. - - To send a simple clump of data, simply provide a value for - the option in the right scope - for example: - - option vendor-encapsulated-options - 2:4:AC:11:41:1: - 3:12:73:75:6e:64:68:63:70:2d:73:65:72:76:65:72:31:37:2d:31: - 4:12:2f:65:78:70:6f:72:74:2f:72:6f:6f:74:2f:69:38:36:70:63; - - To define a new option space in which vendor options can - be stored, use the option space statement: - - ooppttiioonn ssppaaccee _n_a_m_e ;; - - The name can then be used in option definitions, as - described in the ddhhccpp--ooppttiioonnss((55)) manual page. For exam­ - ple: - - option space SUNW; - option SUNW.server-address code 2 = ip-address; - option SUNW.server-name code 3 = text; - option SUNW.root-path code 4 = text; - - Once you have defined an option space and some options, - you can set up scopes that define values for those - options, and you can say when to use them. For example, - suppose you want to handle two different classes of - clients, as in the example in the VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD - OOPPTTIIOONNSS section. Using the option space definition shown +SSEEEE AALLSSOO + dhcpd.conf(5), dhcpd.leases(5), RFC2132, RFC2131. +AAUUTTHHOORR + ddhhccppdd((88)) was written by Ted Lemon under a + contract with Vixie Labs. Funding for this project was + provided by the Internet Software Consortium. Information + about the Internet Software Consortium can be found at + hhttttpp::////wwwwww..iisscc..oorrgg//iisscc.. - 23 -dhcpd.conf(5) dhcpd.conf(5) - in the previous example, something very similar to the - vendor-encapsulated-options definition shown earlier can - be done as follows: - class "vendor-classes" { - match option vendor-class-identifier; - } - option SUNW.server-address 172.17.65.1; - option SUNW.server-name "sundhcp-server17-1"; - subclass "vendor-classes" "SUNW.Ultra-5_10" { - vendor-option-space SUNW; - option SUNW.root-path "/export/root/sparc"; - } - subclass "vendor-classes" "SUNW.i86pc" { - vendor-option-space SUNW; - option SUNW.root-path "/export/root/i86pc"; - } - As you can see in the preceding example, regular scoping - rules apply, so you can define values that are global in - the global scope, and only define values that are specific - to a particular class in the local scope. The vveennddoorr-- - ooppttiioonn--ssppaaccee declaration indicates that in that scope, the - vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option should be constructed - using the values of all the options in the SUNW option - space. -SSEEEE AALLSSOO - dhcpd.conf(5), dhcpd.leases(5), RFC2132, RFC2131. -AAUUTTHHOORR - ddhhccppdd((88)) was written by Ted Lemon under a - contract with Vixie Labs. Funding for this project was - provided by the Internet Software Consortium. Information - about the Internet Software Consortium can be found at - hhttttpp::////wwwwww..iisscc..oorrgg//iisscc.. @@ -1579,6 +1513,6 @@ AAUUTTHHOORR - 24 + 23 diff --git a/server/failover.c b/server/failover.c index 7c09fba98..a51213f04 100644 --- a/server/failover.c +++ b/server/failover.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: failover.c,v 1.6 2000/01/05 18:21:01 mellon Exp $ Copyright (c) 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: failover.c,v 1.7 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -51,8 +51,7 @@ isc_result_t find_failover_peer (peer, name) break; if (p) return omapi_object_reference ((omapi_object_t **)peer, - (omapi_object_t *)p, - "find_failover_peer"); + (omapi_object_t *)p, MDL); return ISC_R_NOTFOUND; } @@ -94,25 +93,22 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h) return ISC_R_INVALIDARG; state = (dhcp_failover_state_t *)o; - obj = (dhcp_failover_link_t *)malloc (sizeof *obj); + obj = (dhcp_failover_link_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; obj -> type = dhcp_type_failover_link; - option_cache_reference (&obj -> peer_address, state -> address, - "dhcp_failover_link_initiate"); + option_cache_reference (&obj -> peer_address, state -> address, MDL); obj -> peer_port = state -> port; memset (&ds, 0, sizeof ds); if (!evaluate_option_cache (&ds, (struct packet *)0, (struct lease *)0, (struct option_state *)0, (struct option_state *)0, - obj -> peer_address)) { - option_cache_dereference (&obj -> peer_address, - "dhcp_failover_link_initiate"); - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_link_initiate"); + &global_scope, obj -> peer_address, MDL)) { + option_cache_dereference (&obj -> peer_address, MDL); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_UNEXPECTED; } @@ -129,23 +125,20 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h) if (status == ISC_R_SUCCESS) break; } - data_string_forget (&ds, "dhcp_failover_link_initiate"); + data_string_forget (&ds, MDL); /* If we didn't connect to any of the addresses, give up. */ if (status != ISC_R_SUCCESS) { lose: - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_link_initiate"); - option_cache_dereference (&obj -> peer_address, - "dhcp_failover_link_initiate"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); + option_cache_dereference (&obj -> peer_address, MDL); return status; } - status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "dhcp_failover_link_initiate"); + status = omapi_object_reference (&h -> outer, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) goto lose; - status = omapi_object_reference (&obj -> inner, h, - "dhcp_failover_link_initiate"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) goto lose; @@ -154,8 +147,7 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h) if (status != ISC_R_SUCCESS) goto lose; - omapi_object_dereference ((omapi_object_t **)&obj, - "omapi_protocol_accept"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return ISC_R_SUCCESS; } @@ -197,13 +189,11 @@ isc_result_t dhcp_failover_link_signal (omapi_object_t *h, break; case dhcp_flink_message_length_wait: link -> state = dhcp_flink_message_wait; - link -> imsg = dmalloc (sizeof (failover_message_t), - "dhcp_failover_link_signal"); + link -> imsg = dmalloc (sizeof (failover_message_t), MDL); if (!link -> imsg) { dhcp_flink_fail: if (link -> imsg) { - dfree (link -> imsg, - "dhcp_failover_link_signal"); + dfree (link -> imsg, MDL); link -> imsg = (failover_message_t *)0; } link -> state = dhcp_flink_disconnected; @@ -403,7 +393,7 @@ static isc_result_t do_a_failover_option (c, link) op_count = option_len - op_count; ddns -> length = op_count; - ddns -> data = malloc (op_count); + ddns -> data = dmalloc (op_count, MDL); if (!ddns -> data) { log_error ("FAILOVER: no memory getting%s(%d)", " DNS data ", op_count); @@ -438,7 +428,7 @@ static isc_result_t do_a_failover_option (c, link) ft_options [option_code].offset)); fo -> count = op_count; - fo -> data = malloc (option_len); + fo -> data = dmalloc (option_len, MDL); if (!fo -> data) { log_error ("FAILOVER: no memory getting %s (%d)", "option data", op_count); @@ -517,18 +507,16 @@ isc_result_t dhcp_failover_link_get_value (omapi_object_t *h, if (!omapi_ds_strcmp (name, "link-port")) { return omapi_make_int_value (value, name, - (int)link -> peer_port, - "dhcp_failover_link_get_value"); + (int)link -> peer_port, MDL); } else if (!omapi_ds_strcmp (name, "link-state")) { if (link -> state < 0 || link -> state >= dhcp_flink_state_max) - return omapi_make_string_value - (value, name, "invalid link state", - "dhcp_failover_link_get_value"); + return omapi_make_string_value (value, name, + "invalid link state", + MDL); return omapi_make_string_value (value, name, - dhcp_flink_state_names [link -> state], - "dhcp_failover_link_get_value"); + dhcp_flink_state_names [link -> state], MDL); } if (h -> inner && h -> inner -> type -> get_value) @@ -537,14 +525,15 @@ isc_result_t dhcp_failover_link_get_value (omapi_object_t *h, return ISC_R_NOTFOUND; } -isc_result_t dhcp_failover_link_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcp_failover_link_destroy (omapi_object_t *h, + const char *file, int line) { dhcp_failover_link_t *link; if (h -> type != dhcp_type_failover_link) return ISC_R_INVALIDARG; link = (dhcp_failover_link_t *)h; if (link -> imsg) { - dfree (link -> imsg, "dhcp_failover_link_destroy"); + dfree (link -> imsg, file, line); link -> imsg = (failover_message_t *)0; } return ISC_R_SUCCESS; @@ -607,16 +596,16 @@ isc_result_t dhcp_failover_listen (omapi_object_t *h) if (status != ISC_R_SUCCESS) return status; if (!value -> value) { - omapi_value_dereference (&value, "dhcp_failover_listen"); + omapi_value_dereference (&value, MDL); return ISC_R_INVALIDARG; } status = omapi_get_int_value (&port, value -> value); - omapi_value_dereference (&value, "dhcp_failover_listen"); + omapi_value_dereference (&value, MDL); if (status != ISC_R_SUCCESS) return status; - obj = (dhcp_failover_listener_t *)malloc (sizeof *obj); + obj = (dhcp_failover_listener_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); @@ -625,23 +614,19 @@ isc_result_t dhcp_failover_listen (omapi_object_t *h) obj -> local_port = port; status = omapi_listen ((omapi_object_t *)obj, port, 1); - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); if (status != ISC_R_SUCCESS) return status; - status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "dhcp_failover_listen"); + status = omapi_object_reference (&h -> outer, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&obj -> inner, h, - "dhcp_failover_listen"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -687,7 +672,8 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o, (struct lease *)0, (struct option_state *)0, (struct option_state *)0, - state -> address)) { + &global_scope, + state -> address, MDL)) { for (i = 0; i < ds.len; i += 4) { if (!memcmp (&ds.data [i], &c -> remote_addr, 4)) @@ -707,28 +693,26 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o, return ISC_R_INVALIDARG; } - obj = (dhcp_failover_link_t *)malloc (sizeof *obj); + obj = (dhcp_failover_link_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); obj -> refcnt = 1; obj -> type = dhcp_type_failover_link; - option_cache_reference (&obj -> peer_address, state -> address, - "dhcp_failover_listen_signal"); + option_cache_reference (&obj -> peer_address, state -> address, MDL); obj -> peer_port = ntohs (c -> remote_addr.sin_port); - status = omapi_object_reference (&obj -> outer, (omapi_object_t *)c, - "dhcp_failover_listener_signal"); + status = omapi_object_reference (&obj -> outer, + (omapi_object_t *)c, MDL); if (status != ISC_R_SUCCESS) { lose: - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listener_signal"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); omapi_disconnect ((omapi_object_t *)c, 1); return status; } - status = omapi_object_reference (&c -> inner, (omapi_object_t *)obj, - "dhcp_failover_listener_signal"); + status = omapi_object_reference (&c -> inner, + (omapi_object_t *)obj, MDL); if (status != ISC_R_SUCCESS) goto lose; @@ -738,8 +722,7 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o, if (status != ISC_R_SUCCESS) goto lose; - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listener_signal"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -772,7 +755,7 @@ isc_result_t dhcp_failover_listener_get_value (omapi_object_t *h, } isc_result_t dhcp_failover_listener_destroy (omapi_object_t *h, - const char *name) + const char *file, int line) { if (h -> type != dhcp_type_failover_listener) return ISC_R_INVALIDARG; @@ -811,16 +794,16 @@ isc_result_t dhcp_failover_register (omapi_object_t *h) if (status != ISC_R_SUCCESS) return status; if (!value -> value) { - omapi_value_dereference (&value, "dhcp_failover_register"); + omapi_value_dereference (&value, MDL); return ISC_R_INVALIDARG; } status = omapi_get_int_value (&port, value -> value); - omapi_value_dereference (&value, "dhcp_failover_listen"); + omapi_value_dereference (&value, MDL); if (status != ISC_R_SUCCESS) return status; - obj = (dhcp_failover_state_t *)malloc (sizeof *obj); + obj = (dhcp_failover_state_t *)dmalloc (sizeof *obj, MDL); if (!obj) return ISC_R_NOMEMORY; memset (obj, 0, sizeof *obj); @@ -829,23 +812,19 @@ isc_result_t dhcp_failover_register (omapi_object_t *h) obj -> listen_port = port; status = omapi_listen ((omapi_object_t *)obj, port, 1); - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); if (status != ISC_R_SUCCESS) return status; status = omapi_object_reference (&h -> outer, (omapi_object_t *)obj, - "dhcp_failover_listen"); + MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } - status = omapi_object_reference (&obj -> inner, h, - "dhcp_failover_listen"); + status = omapi_object_reference (&obj -> inner, h, MDL); if (status != ISC_R_SUCCESS) { - omapi_object_dereference ((omapi_object_t **)&obj, - "dhcp_failover_listen"); + omapi_object_dereference ((omapi_object_t **)&obj, MDL); return status; } @@ -910,7 +889,7 @@ isc_result_t dhcp_failover_state_get_value (omapi_object_t *h, } isc_result_t dhcp_failover_state_destroy (omapi_object_t *h, - const char *name) + const char *file, int line) { if (h -> type != dhcp_type_failover_state) return ISC_R_INVALIDARG; @@ -948,14 +927,13 @@ isc_result_t dhcp_failover_state_lookup (omapi_object_t **sp, if (status == ISC_R_SUCCESS) { status = omapi_handle_td_lookup (sp, tv -> value); - omapi_value_dereference (&tv, "dhcp_failover_state_lookup"); + omapi_value_dereference (&tv, MDL); if (status != ISC_R_SUCCESS) return status; /* Don't return the object if the type is wrong. */ if ((*sp) -> type != dhcp_type_failover_state) { - omapi_object_dereference - (sp, "dhcp_failover_state_lookup"); + omapi_object_dereference (sp, MDL); return ISC_R_INVALIDARG; } } @@ -970,24 +948,21 @@ isc_result_t dhcp_failover_state_lookup (omapi_object_t **sp, tv -> value -> u.buffer.value, l)) break; } - omapi_value_dereference (&tv, "dhcp_failover_state_lookup"); + omapi_value_dereference (&tv, MDL); /* If we already have a lease, and it's not the same one, then the query was invalid. */ if (*sp && *sp != (omapi_object_t *)s) { - omapi_object_dereference - (sp, "dhcp_failover_state_lookup"); + omapi_object_dereference (sp, MDL); return ISC_R_KEYCONFLICT; } else if (!s) { if (*sp) - omapi_object_dereference - (sp, "dhcp_failover_state_lookup"); + omapi_object_dereference (sp, MDL); return ISC_R_NOTFOUND; } else if (!*sp) /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (sp, (omapi_object_t *)s, - "dhcp_failover_state_lookup"); + omapi_object_reference (sp, (omapi_object_t *)s, MDL); } /* If we get to here without finding a lease, no valid key was @@ -1094,7 +1069,7 @@ failover_option_t *dhcp_failover_make_option (unsigned code, /* Allocate a buffer for the option. */ option.count = size; - option.data = dmalloc (option.count, "dhcp_failover_make_option"); + option.data = dmalloc (option.count, MDL); if (!option.data) return &null_failover_option; @@ -1124,8 +1099,7 @@ failover_option_t *dhcp_failover_make_option (unsigned code, for (i = 0; i < count; i++) { ival = va_arg (va, struct iaddr *); if (ival -> len != 4) { - dfree (option.data, - "dhcp_failover_make_option"); + dfree (option.data, MDL); log_error ("IP addrlen=%d, should be 4.", ival -> len); return &null_failover_option; @@ -1213,10 +1187,9 @@ failover_option_t *dhcp_failover_make_option (unsigned code, failover_print (obuf, obufix, obufmax, ")"); /* Now allocate a place to store what we just set up. */ - op = dmalloc (sizeof (failover_option_t), - "dhcp_failover_make_option"); + op = dmalloc (sizeof (failover_option_t), MDL); if (!op) { - dfree (option.data, "dhcp_failover_make_option"); + dfree (option.data, MDL); return &null_failover_option; } @@ -1253,7 +1226,7 @@ isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *link, /* Allocate an option buffer, unless we got an error. */ if (!bad_option) { - opbuf = dmalloc (size, "dhcp_failover_put_message"); + opbuf = dmalloc (size, MDL); if (!opbuf) status = ISC_R_NOMEMORY; } @@ -1266,8 +1239,8 @@ isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *link, memcpy (&opbuf [opix], option -> data, option -> count); opix += option -> count; - dfree (option -> data, "dhcp_failover_put_message"); - dfree (option, "dhcp_failover_put_message"); + dfree (option -> data, MDL); + dfree (option, MDL); } if (bad_option || !opbuf) @@ -1307,11 +1280,11 @@ isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *link, status = omapi_connection_copyin (connection, opbuf, size); if (status != ISC_R_SUCCESS) goto err; - dfree (opbuf, "dhcp_failover_put_message"); + dfree (opbuf, MDL); return status; err: - dfree (opbuf, "dhcp_failover_put_message"); + dfree (opbuf, MDL); omapi_disconnect (connection, 1); return status; } diff --git a/server/mdb.c b/server/mdb.c index 284cf7fd7..566c928ce 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: mdb.c,v 1.25 2000/01/25 01:42:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: mdb.c,v 1.26 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -135,7 +135,7 @@ isc_result_t enter_host (hd, dynamicp, commit) (&hd -> client_identifier, (struct packet *)0, (struct lease *)0, (struct option_state *)0, (struct option_state *)0, &global_scope, - esp -> data.option); + esp -> data.option, MDL); break; } } @@ -281,7 +281,7 @@ isc_result_t delete_host (hd, commit) hd -> n_ipaddr -> refcnt++; } omapi_object_dereference ((omapi_object_t **)&hd -> n_ipaddr, - "delete_host"); + MDL); } if (host_name_hash) { @@ -359,7 +359,8 @@ struct subnet *find_host_for_network (host, addr, share) (struct lease *)0, (struct option_state *)0, (struct option_state *)0, - &global_scope, hp -> fixed_addr)) + &global_scope, + hp -> fixed_addr, MDL)) continue; for (i = 0; i < fixed_addr.len; i += 4) { ip_address.len = 4; @@ -369,12 +370,11 @@ struct subnet *find_host_for_network (host, addr, share) if (subnet) { *addr = ip_address; *host = hp; - data_string_forget (&fixed_addr, - "find_host_for_network"); + data_string_forget (&fixed_addr, MDL); return subnet; } } - data_string_forget (&fixed_addr, "find_host_for_network"); + data_string_forget (&fixed_addr, MDL); } return (struct subnet *)0; } @@ -410,7 +410,7 @@ isc_result_t delete_group (struct group_object *group, int writep) } else { group -> flags |= GROUP_OBJECT_DELETED; if (group -> group) { - dfree (group -> group, "delete_group"); + dfree (group -> group, MDL); group -> group = (struct group *)0; } } @@ -459,8 +459,7 @@ isc_result_t supersede_group (struct group_object *group, int writep) (unsigned char *)group -> name, strlen (group -> name)); omapi_object_dereference - ((omapi_object_t **)&t, - "supersede_group"); + ((omapi_object_t **)&t, MDL); } } } else { @@ -554,7 +553,7 @@ void new_address_range (low, high, subnet, pool) } /* Get a lease structure for each address in the range. */ - address_range = new_leases (max - min + 1, "new_address_range"); + address_range = new_leases (max - min + 1, MDL); if (!address_range) { strcpy (lowbuf, piaddr (low)); strcpy (highbuf, piaddr (high)); @@ -623,7 +622,7 @@ void new_address_range (low, high, subnet, pool) address_range [lhost - i].client_hostname = lp -> client_hostname; supersede_lease (&address_range [lhost - i], lp, 0); - free_lease (lp, "new_address_range"); + free_lease (lp, MDL); } else plp = lp; } @@ -738,7 +737,7 @@ void new_shared_network_interface (cfile, share, name) if (!strcmp (ip -> name, name)) break; if (!ip) { - ip = dmalloc (sizeof *ip, "parse_subnet_declaration"); + ip = dmalloc (sizeof *ip, MDL); if (!ip) log_fatal ("No memory to record interface %s", name); memset (ip, 0, sizeof *ip); @@ -769,7 +768,7 @@ void enter_lease (lease) /* If we don't have a place for this lease yet, save it for later. */ if (!comp) { - comp = new_lease ("enter_lease"); + comp = new_lease (MDL); if (!comp) { log_fatal ("No memory for lease %s\n", piaddr (lease -> ip_addr)); @@ -835,7 +834,7 @@ int supersede_lease (comp, lease, commit) uid_hash_delete (comp); enter_uid = 1; if (comp -> uid != &comp -> uid_buf [0]) { - free (comp -> uid); + dfree (comp -> uid, MDL); comp -> uid_max = 0; comp -> uid_len = 0; } @@ -885,33 +884,32 @@ int supersede_lease (comp, lease, commit) comp -> flags = ((lease -> flags & ~PERSISTENT_FLAGS) | (comp -> flags & ~EPHEMERAL_FLAGS)); if (comp -> scope.bindings) - free_bindings (&comp -> scope, "supersede_lease"); + free_bindings (&comp -> scope, MDL); comp -> scope.bindings = lease -> scope.bindings; lease -> scope.bindings = (struct binding *)0; if (lease -> on_expiry) { if (comp -> on_expiry) executable_statement_dereference (&comp -> on_expiry, - "supersede_lease"); + MDL); executable_statement_reference (&comp -> on_expiry, lease -> on_expiry, - "supersede_lease"); + MDL); } if (lease -> on_commit) { if (comp -> on_commit) executable_statement_dereference (&comp -> on_commit, - "supersede_lease"); + MDL); executable_statement_reference (&comp -> on_commit, lease -> on_commit, - "supersede_lease"); + MDL); } if (lease -> on_release) { if (comp -> on_release) executable_statement_dereference (&comp -> on_release, - "supersede_lease"); + MDL); executable_statement_reference (&comp -> on_release, - lease -> on_release, - "supersede_lease"); + lease -> on_release, MDL); } /* Record the lease in the uid hash if necessary. */ @@ -1041,15 +1039,14 @@ int supersede_lease (comp, lease, commit) &lease -> scope, comp -> on_expiry); executable_statement_dereference (&comp -> on_expiry, - "supersede_lease"); + MDL); #if defined (FAILOVER_PROTOCOL) } #endif /* No sense releasing a lease after it's expired. */ if (comp -> on_release) executable_statement_dereference - (&comp -> on_release, - "supersede_lease"); + (&comp -> on_release, MDL); } else { /* If this is the next lease that will timeout on the pool, zap the old timeout and set the timeout on @@ -1119,15 +1116,14 @@ void release_lease (lease, packet) &lease -> scope, lease -> on_release); if (lease -> on_release) executable_statement_dereference (&lease -> on_release, - "dhcprelease"); + MDL); } /* We do either the on_release or the on_expiry events, but not both (it's possible that they could be the same, in any case). */ if (lease -> on_expiry) - executable_statement_dereference (&lease -> on_expiry, - "dhcprelease"); + executable_statement_dereference (&lease -> on_expiry, MDL); if (lease -> ends > cur_time) { lt = *lease; @@ -1230,13 +1226,13 @@ void pool_timer (vpool) lease -> on_expiry); if (lease -> on_expiry) executable_statement_dereference - (&lease -> on_expiry, "pool_timer"); + (&lease -> on_expiry, MDL); } /* If there's an on_release event, blow it away. */ if (lease -> on_release) executable_statement_dereference (&lease -> on_release, - "pool_timer"); + MDL); #if defined (FAILOVER_PROTOCOL) lease -> tstp = 0; update_partner (lease); @@ -1509,7 +1505,7 @@ void write_leases () (l -> flags & ABANDONED_LEASE)) { if (!write_lease (l)) log_fatal ("Can't rewrite %s", - "lease database"); + "lease database"); num_written++; } } diff --git a/server/omapi.c b/server/omapi.c index c30bbd31c..32e058aa2 100644 --- a/server/omapi.c +++ b/server/omapi.c @@ -29,7 +29,7 @@ #ifndef lint static char copyright[] = -"$Id: omapi.c,v 1.25 2000/01/25 01:43:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: omapi.c,v 1.26 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -216,67 +216,57 @@ isc_result_t dhcp_lease_get_value (omapi_object_t *h, omapi_object_t *id, if (!omapi_ds_strcmp (name, "abandoned")) return omapi_make_int_value (value, name, (lease -> flags & - ABANDONED_LEASE) ? 1 : 0, - "dhcp_lease_get_value"); + ABANDONED_LEASE) ? 1 : 0, MDL); else if (!omapi_ds_strcmp (name, "bootpp")) return omapi_make_int_value (value, name, (lease -> flags & - BOOTP_LEASE) ? 1 : 0, - "dhcp_lease_get_value"); + BOOTP_LEASE) ? 1 : 0, MDL); else if (!omapi_ds_strcmp (name, "ip-address")) return omapi_make_const_value (value, name, lease -> ip_addr.iabuf, - lease -> ip_addr.len, - "dhcp_lease_get_value"); + lease -> ip_addr.len, MDL); else if (!omapi_ds_strcmp (name, "dhcp-client-identifier")) { return omapi_make_const_value (value, name, lease -> uid, - lease -> uid_len, - "dhcp_lease_get_value"); + lease -> uid_len, MDL); } else if (!omapi_ds_strcmp (name, "hostname")) { if (lease -> hostname) return omapi_make_string_value - (value, name, lease -> hostname, - "dhcp_lease_get_value"); + (value, name, lease -> hostname, MDL); return ISC_R_NOTFOUND; } else if (!omapi_ds_strcmp (name, "client-hostname")) { if (lease -> client_hostname) return omapi_make_string_value - (value, name, lease -> client_hostname, - "dhcp_lease_get_value"); + (value, name, lease -> client_hostname, MDL); return ISC_R_NOTFOUND; } else if (!omapi_ds_strcmp (name, "host")) { if (lease -> host) return omapi_make_handle_value (value, name, - ((omapi_object_t *)lease -> host), - "dhcp_lease_get_value"); + ((omapi_object_t *)lease -> host), MDL); } else if (!omapi_ds_strcmp (name, "subnet")) return omapi_make_handle_value (value, name, ((omapi_object_t *) - lease -> subnet), - "dhcp_lease_get_value"); + lease -> subnet), MDL); else if (!omapi_ds_strcmp (name, "pool")) return omapi_make_handle_value (value, name, ((omapi_object_t *) - lease -> pool), - "dhcp_lease_get_value"); + lease -> pool), MDL); else if (!omapi_ds_strcmp (name, "billing-class")) { if (lease -> billing_class) return omapi_make_handle_value (value, name, ((omapi_object_t *)lease -> billing_class), - "dhcp_lease_get_value"); + MDL); return ISC_R_NOTFOUND; } else if (!omapi_ds_strcmp (name, "hardware-address")) return omapi_make_const_value (value, name, &lease -> hardware_addr.hbuf [1], - (unsigned)(lease -> hardware_addr.hlen - 1), - "dhcp_lease_get_value"); + (unsigned)(lease -> hardware_addr.hlen - 1), MDL); else if (!omapi_ds_strcmp (name, "hardware-type")) return omapi_make_int_value (value, name, lease -> hardware_addr.hbuf [0], - "dhcp_lease_get_value"); + MDL); /* Try to find some inner object that can take the value. */ if (h -> inner && h -> inner -> type -> get_value) { @@ -288,7 +278,7 @@ isc_result_t dhcp_lease_get_value (omapi_object_t *h, omapi_object_t *id, return ISC_R_NOTFOUND; } -isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *file, int line) { struct lease *lease; isc_result_t status; @@ -301,39 +291,43 @@ isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *name) hw_hash_delete (lease); if (lease -> billing_class) omapi_object_dereference - ((omapi_object_t **)&lease -> billing_class, name); + ((omapi_object_t **)&lease -> billing_class, + file, line); if (lease -> uid && lease -> uid != &lease -> uid_buf [0]) { - free (lease -> uid); + dfree (lease -> uid, MDL); lease -> uid = &lease -> uid_buf [0]; lease -> uid_len = 0; } if (lease -> hostname) { - free (lease -> hostname); + dfree (lease -> hostname, MDL); lease -> hostname = (char *)0; } if (lease -> client_hostname) { - free (lease -> client_hostname); + dfree (lease -> client_hostname, MDL); lease -> hostname = (char *)0; } if (lease -> host) omapi_object_dereference ((omapi_object_t **)&lease -> host, - name); + file, line); if (lease -> subnet) omapi_object_dereference ((omapi_object_t **)&lease -> subnet, - name); + file, line); if (lease -> pool) omapi_object_dereference ((omapi_object_t **)&lease -> pool, - name); + file, line); if (lease -> on_expiry) - executable_statement_dereference (&lease -> on_expiry, name); + executable_statement_dereference (&lease -> on_expiry, + file, line); if (lease -> on_commit) - executable_statement_dereference (&lease -> on_commit, name); + executable_statement_dereference (&lease -> on_commit, + file, line); if (lease -> on_release) - executable_statement_dereference (&lease -> on_release, name); + executable_statement_dereference (&lease -> on_release, + file, line); if (lease -> state) { data_string_forget (&lease -> state -> parameter_request_list, - name); - free_lease_state (lease -> state, name); + file, line); + free_lease_state (lease -> state, file, line); lease -> state = (struct lease_state *)0; cancel_timeout (lease_ping_timeout, lease); @@ -553,13 +547,13 @@ isc_result_t dhcp_lease_lookup (omapi_object_t **lp, if (status == ISC_R_SUCCESS) { status = omapi_handle_td_lookup (lp, tv -> value); - omapi_value_dereference (&tv, "dhcp_lease_lookup"); + omapi_value_dereference (&tv, MDL); if (status != ISC_R_SUCCESS) return status; /* Don't return the object if the type is wrong. */ if ((*lp) -> type != dhcp_type_lease) { - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_INVALIDARG; } } @@ -572,23 +566,22 @@ isc_result_t dhcp_lease_lookup (omapi_object_t **lp, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_lease_lookup"); + omapi_value_dereference (&tv, MDL); /* If we already have a lease, and it's not the same one, then the query was invalid. */ if (*lp && *lp != (omapi_object_t *)lease) { - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!lease) { if (*lp) - omapi_object_dereference (lp, - "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } else if (!*lp) /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (lp, (omapi_object_t *)lease, - "dhcp_lease_lookup"); + omapi_object_reference (lp, + (omapi_object_t *)lease, MDL); } /* Now look for a client identifier. */ @@ -598,24 +591,24 @@ isc_result_t dhcp_lease_lookup (omapi_object_t **lp, hash_lookup (lease_uid_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_lease_lookup"); + omapi_value_dereference (&tv, MDL); if (*lp && *lp != (omapi_object_t *)lease) { - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!lease) { if (*lp) - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } else if (lease -> n_uid) { if (*lp) - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_MULTIPLE; } else if (!*lp) { /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (lp, (omapi_object_t *)lease, - "dhcp_lease_lookup"); + omapi_object_reference (lp, + (omapi_object_t *)lease, MDL); } } @@ -626,24 +619,24 @@ isc_result_t dhcp_lease_lookup (omapi_object_t **lp, hash_lookup (lease_hw_addr_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_lease_lookup"); + omapi_value_dereference (&tv, MDL); if (*lp && *lp != (omapi_object_t *)lease) { - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!lease) { if (*lp) - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } else if (lease -> n_hw) { if (*lp) - omapi_object_dereference (lp, "dhcp_lease_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_MULTIPLE; } else if (!*lp) { /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (lp, (omapi_object_t *)lease, - "dhcp_lease_lookup"); + omapi_object_reference (lp, + (omapi_object_t *)lease, MDL); } } @@ -686,7 +679,8 @@ isc_result_t dhcp_group_set_value (omapi_object_t *h, return ISC_R_EXISTS; if (value -> type == omapi_datatype_data || value -> type == omapi_datatype_string) { - group -> name = malloc (value -> u.buffer.len + 1); + group -> name = dmalloc (value -> u.buffer.len + 1, + MDL); if (!group -> name) return ISC_R_NOMEMORY; memcpy (group -> name, @@ -702,8 +696,7 @@ isc_result_t dhcp_group_set_value (omapi_object_t *h, if (group -> group && group -> group -> statements) return ISC_R_EXISTS; if (!group -> group) - group -> group = clone_group (&root_group, - "dhcp_group_set_value"); + group -> group = clone_group (&root_group, MDL); if (!group -> group) return ISC_R_NOMEMORY; if (value -> type == omapi_datatype_data || @@ -754,8 +747,8 @@ isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id, group = (struct group_object *)h; if (!omapi_ds_strcmp (name, "name")) - return omapi_make_string_value (value, name, group -> name, - "dhcp_group_get_value"); + return omapi_make_string_value (value, + name, group -> name, MDL); /* Try to find some inner object that can take the value. */ if (h -> inner && h -> inner -> type -> get_value) { @@ -767,7 +760,7 @@ isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id, return ISC_R_NOTFOUND; } -isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line) { struct group_object *group, *t; isc_result_t status; @@ -790,7 +783,7 @@ isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *name) --group -> refcnt; } } - free (group -> name); + dfree (group -> name, file, line); group -> name = (char *)0; } if (group -> group) @@ -821,7 +814,7 @@ isc_result_t dhcp_group_signal_handler (omapi_object_t *h, char hnbuf [64]; sprintf (hnbuf, "ng%08lx%08lx", cur_time, (unsigned long)group); - group -> name = malloc (strlen (hnbuf) + 1); + group -> name = dmalloc (strlen (hnbuf) + 1, MDL); if (!group -> name) return ISC_R_NOMEMORY; strcpy (group -> name, hnbuf); @@ -887,13 +880,13 @@ isc_result_t dhcp_group_lookup (omapi_object_t **lp, if (status == ISC_R_SUCCESS) { status = omapi_handle_td_lookup (lp, tv -> value); - omapi_value_dereference (&tv, "dhcp_group_lookup"); + omapi_value_dereference (&tv, MDL); if (status != ISC_R_SUCCESS) return status; /* Don't return the object if the type is wrong. */ if ((*lp) -> type != dhcp_type_group) { - omapi_object_dereference (lp, "dhcp_group_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_INVALIDARG; } } @@ -906,7 +899,7 @@ isc_result_t dhcp_group_lookup (omapi_object_t **lp, hash_lookup (group_name_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_group_lookup"); + omapi_value_dereference (&tv, MDL); /* Don't register a deleted group here. */ if (group -> flags & GROUP_OBJECT_DELETED) { @@ -916,17 +909,17 @@ isc_result_t dhcp_group_lookup (omapi_object_t **lp, } if (*lp && *lp != (omapi_object_t *)group) { - omapi_object_dereference (lp, "dhcp_group_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!group) { - omapi_object_dereference (lp, "dhcp_group_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } else if (!*lp) { /* XXX fix so that hash lookup itself creates XXX the reference. */ omapi_object_reference (lp, (omapi_object_t *)group, - "dhcp_group_lookup"); + MDL); } } else if (!*lp) return ISC_R_NOTFOUND; @@ -938,7 +931,7 @@ isc_result_t dhcp_group_lookup (omapi_object_t **lp, return ISC_R_NOKEYS; if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) { - omapi_object_dereference (lp, "dhcp_group_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } return ISC_R_SUCCESS; @@ -949,15 +942,14 @@ isc_result_t dhcp_group_create (omapi_object_t **lp, { struct group_object *group; group = (struct group_object *)dmalloc (sizeof (struct group_object), - "dhcp_group_create"); + MDL); if (!group) return ISC_R_NOMEMORY; memset (group, 0, sizeof *group); group -> refcnt = 0; group -> type = dhcp_type_group; group -> flags = GROUP_OBJECT_DYNAMIC; - return omapi_object_reference (lp, (omapi_object_t *)group, - "dhcp_group_create"); + return omapi_object_reference (lp, (omapi_object_t *)group, MDL); } isc_result_t dhcp_group_remove (omapi_object_t *lp, @@ -973,8 +965,7 @@ isc_result_t dhcp_group_remove (omapi_object_t *lp, if (!write_group (group) || !commit_leases ()) return ISC_R_IOERROR; - status = dhcp_group_destroy ((omapi_object_t *)group, - "dhcp_group_remove"); + status = dhcp_group_destroy ((omapi_object_t *)group, MDL); return ISC_R_SUCCESS; } @@ -999,7 +990,8 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h, return ISC_R_EXISTS; if (value -> type == omapi_datatype_data || value -> type == omapi_datatype_string) { - host -> name = malloc (value -> u.buffer.len + 1); + host -> name = dmalloc (value -> u.buffer.len + 1, + MDL); if (!host -> name) return ISC_R_NOMEMORY; memcpy (host -> name, @@ -1025,12 +1017,10 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h, if (host -> named_group) omapi_object_dereference ((omapi_object_t **) - &host -> named_group, - "dhcp_host_set_value"); + &host -> named_group, MDL); omapi_object_reference ((omapi_object_t **) &host -> named_group, - (omapi_object_t *)group, - "dhcp_host_set_value"); + (omapi_object_t *)group, MDL); } else return ISC_R_INVALIDARG; return ISC_R_SUCCESS; @@ -1075,19 +1065,17 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h, return ISC_R_EXISTS; if (value -> type == omapi_datatype_data || value -> type == omapi_datatype_string) { - if (!buffer_allocate - (&host -> client_identifier.buffer, - value -> u.buffer.len, - "dhcp_host_set_value")) - return ISC_R_NOMEMORY; - host -> client_identifier.data = - &host -> client_identifier.buffer -> data [0]; - memcpy (host -> client_identifier.buffer -> data, - value -> u.buffer.value, - value -> u.buffer.len); - host -> client_identifier.len = value -> u.buffer.len; + if (!buffer_allocate (&host -> client_identifier.buffer, + value -> u.buffer.len, MDL)) + return ISC_R_NOMEMORY; + host -> client_identifier.data = + &host -> client_identifier.buffer -> data [0]; + memcpy (host -> client_identifier.buffer -> data, + value -> u.buffer.value, + value -> u.buffer.len); + host -> client_identifier.len = value -> u.buffer.len; } else - return ISC_R_INVALIDARG; + return ISC_R_INVALIDARG; return ISC_R_SUCCESS; } @@ -1099,8 +1087,7 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h, struct data_string ds; memset (&ds, 0, sizeof ds); ds.len = value -> u.buffer.len; - if (!buffer_allocate (&ds.buffer, ds.len, - "dhcp_host_set_value")) + if (!buffer_allocate (&ds.buffer, ds.len, MDL)) return ISC_R_NOMEMORY; ds.data = (&ds.buffer -> data [0]); memcpy (ds.buffer -> data, @@ -1108,11 +1095,10 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h, if (!option_cache (&host -> fixed_addr, &ds, (struct expression *)0, (struct option *)0)) { - data_string_forget (&ds, - "dhcp_host_set_value"); + data_string_forget (&ds, MDL); return ISC_R_NOMEMORY; } - data_string_forget (&ds, "dhcp_host_set_value"); + data_string_forget (&ds, MDL); } else return ISC_R_INVALIDARG; return ISC_R_SUCCESS; @@ -1120,16 +1106,14 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h, if (!omapi_ds_strcmp (name, "statements")) { if (!host -> group) - host -> group = clone_group (&root_group, - "dhcp_host_set_value"); + host -> group = clone_group (&root_group, MDL); else { if (host -> group -> statements && (!host -> named_group || host -> group != host -> named_group -> group) && host -> group != &root_group) return ISC_R_EXISTS; - host -> group = clone_group (host -> group, - "dhcp_host_set_value"); + host -> group = clone_group (host -> group, MDL); } if (!host -> group) return ISC_R_NOMEMORY; @@ -1187,21 +1171,21 @@ isc_result_t dhcp_host_get_value (omapi_object_t *h, omapi_object_t *id, host = (struct host_decl *)h; if (!omapi_ds_strcmp (name, "ip-addresses")) { - memset (&ip_addrs, 0, sizeof ip_addrs); - if (host -> fixed_addr && - evaluate_option_cache (&ip_addrs, (struct packet *)0, - (struct lease *)0, - (struct option_state *)0, - (struct option_state *)0, - &global_scope, - host -> fixed_addr)) { - status = (omapi_make_const_value - (value, name, ip_addrs.data, ip_addrs.len, - "dhcp_host_get_value")); - data_string_forget (&ip_addrs, "dhcp_host_get_value"); - return status; - } - return ISC_R_NOTFOUND; + memset (&ip_addrs, 0, sizeof ip_addrs); + if (host -> fixed_addr && + evaluate_option_cache (&ip_addrs, (struct packet *)0, + (struct lease *)0, + (struct option_state *)0, + (struct option_state *)0, + &global_scope, + host -> fixed_addr, MDL)) { + status = omapi_make_const_value (value, name, + ip_addrs.data, + ip_addrs.len, MDL); + data_string_forget (&ip_addrs, MDL); + return status; + } + return ISC_R_NOTFOUND; } if (!omapi_ds_strcmp (name, "dhcp-client-identifier")) { @@ -1210,28 +1194,26 @@ isc_result_t dhcp_host_get_value (omapi_object_t *h, omapi_object_t *id, return omapi_make_const_value (value, name, host -> client_identifier.data, host -> client_identifier.len, - "dhcp_host_get_value"); + MDL); } if (!omapi_ds_strcmp (name, "name")) return omapi_make_string_value (value, name, host -> name, - "dhcp_host_get_value"); + MDL); if (!omapi_ds_strcmp (name, "hardware-address")) { if (!host -> interface.hlen) return ISC_R_NOTFOUND; return (omapi_make_const_value (value, name, &host -> interface.hbuf [1], - (unsigned long)(host -> interface.hlen - 1), - "dhcp_host_get_value")); + (unsigned long)(host -> interface.hlen - 1), MDL)); } if (!omapi_ds_strcmp (name, "hardware-type")) { if (!host -> interface.hlen) return ISC_R_NOTFOUND; return omapi_make_int_value (value, name, - host -> interface.hbuf [0], - "dhcp_host_get_value"); + host -> interface.hbuf [0], MDL); } /* Try to find some inner object that can take the value. */ @@ -1244,7 +1226,7 @@ isc_result_t dhcp_host_get_value (omapi_object_t *h, omapi_object_t *id, return ISC_R_NOTFOUND; } -isc_result_t dhcp_host_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcp_host_destroy (omapi_object_t *h, const char *file, int line) { struct host_decl *host; isc_result_t status; @@ -1281,7 +1263,7 @@ isc_result_t dhcp_host_signal_handler (omapi_object_t *h, char hnbuf [64]; sprintf (hnbuf, "nh%08lx%08lx", cur_time, (unsigned long)host); - host -> name = malloc (strlen (hnbuf) + 1); + host -> name = dmalloc (strlen (hnbuf) + 1, MDL); if (!host -> name) return ISC_R_NOMEMORY; strcpy (host -> name, hnbuf); @@ -1329,7 +1311,7 @@ isc_result_t dhcp_host_stuff_values (omapi_object_t *c, (struct option_state *)0, (struct option_state *)0, &global_scope, - host -> fixed_addr)) { + host -> fixed_addr, MDL)) { status = omapi_connection_put_name (c, "ip-address"); if (status != ISC_R_SUCCESS) return status; @@ -1417,17 +1399,17 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, if (status == ISC_R_SUCCESS) { status = omapi_handle_td_lookup (lp, tv -> value); - omapi_value_dereference (&tv, "dhcp_host_lookup"); + omapi_value_dereference (&tv, MDL); if (status != ISC_R_SUCCESS) return status; /* Don't return the object if the type is wrong. */ if ((*lp) -> type != dhcp_type_host) { - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_INVALIDARG; } if (((struct host_decl *)(*lp)) -> flags & HOST_DECL_DELETED) { - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); } } @@ -1438,20 +1420,20 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, hash_lookup (host_uid_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_host_lookup"); + omapi_value_dereference (&tv, MDL); if (*lp && *lp != (omapi_object_t *)host) { - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!host || (host -> flags & HOST_DECL_DELETED)) { if (*lp) - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } else if (!*lp) { /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (lp, (omapi_object_t *)host, - "dhcp_host_lookup"); + omapi_object_reference (lp, + (omapi_object_t *)host, MDL); } } @@ -1462,20 +1444,20 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, hash_lookup (host_hw_addr_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_host_lookup"); + omapi_value_dereference (&tv, MDL); if (*lp && *lp != (omapi_object_t *)host) { - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!host || (host -> flags & HOST_DECL_DELETED)) { if (*lp) - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_NOTFOUND; } else if (!*lp) { /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (lp, (omapi_object_t *)host, - "dhcp_host_lookup"); + omapi_object_reference (lp, + (omapi_object_t *)host, MDL); } } @@ -1489,7 +1471,7 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, hash_lookup (lease_ip_addr_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_host_lookup"); + omapi_value_dereference (&tv, MDL); if (!l && !*lp) return ISC_R_NOTFOUND; @@ -1502,7 +1484,7 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, l -> hardware_addr.hlen)); if (host && *lp && *lp != (omapi_object_t *)host) { - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!host || (host -> flags & HOST_DECL_DELETED)) { @@ -1513,7 +1495,7 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, XXX the reference. */ omapi_object_reference (lp, (omapi_object_t *)host, - "dhcp_host_lookup"); + MDL); } } } @@ -1525,18 +1507,18 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp, hash_lookup (host_name_hash, tv -> value -> u.buffer.value, tv -> value -> u.buffer.len)); - omapi_value_dereference (&tv, "dhcp_host_lookup"); + omapi_value_dereference (&tv, MDL); if (*lp && *lp != (omapi_object_t *)host) { - omapi_object_dereference (lp, "dhcp_host_lookup"); + omapi_object_dereference (lp, MDL); return ISC_R_KEYCONFLICT; } else if (!host || (host -> flags & HOST_DECL_DELETED)) { return ISC_R_NOTFOUND; } else if (!*lp) { /* XXX fix so that hash lookup itself creates XXX the reference. */ - omapi_object_reference (lp, (omapi_object_t *)host, - "dhcp_host_lookup"); + omapi_object_reference (lp, + (omapi_object_t *)host, MDL); } } @@ -1551,8 +1533,7 @@ isc_result_t dhcp_host_create (omapi_object_t **lp, omapi_object_t *id) { struct host_decl *hp; - hp = (struct host_decl *)dmalloc (sizeof (struct host_decl), - "dhcp_host_create"); + hp = (struct host_decl *)dmalloc (sizeof (struct host_decl), MDL); if (!hp) return ISC_R_NOMEMORY; memset (hp, 0, sizeof *hp); @@ -1560,8 +1541,7 @@ isc_result_t dhcp_host_create (omapi_object_t **lp, hp -> type = dhcp_type_host; hp -> group = &root_group; /* XXX */ hp -> flags = HOST_DECL_DYNAMIC; - return omapi_object_reference (lp, (omapi_object_t *)hp, - "dhcp_host_create"); + return omapi_object_reference (lp, (omapi_object_t *)hp, MDL); } isc_result_t dhcp_host_remove (omapi_object_t *lp, @@ -1629,7 +1609,7 @@ isc_result_t dhcp_pool_get_value (omapi_object_t *h, omapi_object_t *id, return ISC_R_NOTFOUND; } -isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *name) +isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line) { struct pool *pool; isc_result_t status; -- 2.39.5