]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Support new generalized option_state usage.
authorTed Lemon <source@isc.org>
Mon, 5 Apr 1999 16:34:33 +0000 (16:34 +0000)
committerTed Lemon <source@isc.org>
Mon, 5 Apr 1999 16:34:33 +0000 (16:34 +0000)
server/bootp.c
server/class.c

index 3ddf2aa48ace30b21bdce1c8b3e65a4654d61797..80a5fc4554a094fcc791c171272b08a974579a3c 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: bootp.c,v 1.42 1999/03/30 18:12:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: bootp.c,v 1.43 1999/04/05 16:31:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -38,7 +38,7 @@ void bootp (packet)
        struct sockaddr_in to;
        struct in_addr from;
        struct hardware hto;
-       struct option_state options;
+       struct option_state *options = (struct option_state *)0;
        struct subnet *subnet;
        struct lease *lease;
        struct iaddr ip_address;
@@ -114,30 +114,33 @@ void bootp (packet)
 
        /* Run the executable statements to compute the client and server
           options. */
-
-       memset (&options, 0, sizeof options);
+       option_state_allocate (&options, "bootrequest");
        
        /* Execute the subnet statements. */
-       execute_statements_in_scope (packet, &options, &options,
+       execute_statements_in_scope (packet, options, options,
                                     lease -> subnet -> group,
                                     (struct group *)0);
        
        /* Execute the host statements. */
-       execute_statements_in_scope (packet, &options, &options, hp -> group,
+       execute_statements_in_scope (packet, options, options, hp -> group,
                                     lease -> subnet -> group);
        
        /* Drop the request if it's not allowed for this client. */
-       if (evaluate_boolean_option_cache (packet, &options,
-                                          lookup_option (options.dhcp_hash,
+       if (evaluate_boolean_option_cache (packet, options,
+                                          lookup_option (&dhcp_universe,
+                                                         options,
                                                          SV_ALLOW_BOOTP))) {
                log_info ("%s: bootp disallowed", msgbuf);
+               option_state_dereference (&options, "bootrequest");
                return;
        } 
 
-       if (evaluate_boolean_option_cache (packet, &options,
-                                          lookup_option (options.dhcp_hash,
+       if (evaluate_boolean_option_cache (packet, options,
+                                          lookup_option (&dhcp_universe,
+                                                         options,
                                                          SV_ALLOW_BOOTING))) {
                log_info ("%s: booting disallowed", msgbuf);
+               option_state_dereference (&options, "bootrequest");
                return;
        }
 
@@ -158,8 +161,7 @@ void bootp (packet)
                   name buffers. */
 
                outgoing.packet_length =
-                       cons_options (packet, outgoing.raw, 0,
-                                     &options, (struct agent_options *)0,
+                       cons_options (packet, outgoing.raw, 0, options,
                                      0, 0, 1, (struct data_string *)0);
                if (outgoing.packet_length < BOOTP_MIN_LEN)
                        outgoing.packet_length = BOOTP_MIN_LEN;
@@ -181,9 +183,9 @@ void bootp (packet)
        raw.siaddr = (lease -> subnet -> shared_network ->
                      interface -> primary_address);
        memset (&d1, 0, sizeof d1);
-       oc = lookup_option (options.dhcp_hash, SV_NEXT_SERVER);
+       oc = lookup_option (&dhcp_universe, options, SV_NEXT_SERVER);
        if (oc &&
-           evaluate_option_cache (&d1, packet, &options, oc)) {
+           evaluate_option_cache (&d1, packet, options, oc)) {
                /* If there was more than one answer, take the first. */
                if (d1.len >= 4 && d1.data)
                        memcpy (&raw.siaddr, d1.data, 4);
@@ -193,9 +195,9 @@ void bootp (packet)
        raw.giaddr = packet -> raw -> giaddr;
 
        /* Figure out the filename. */
-       oc = lookup_option (options.dhcp_hash, SV_FILENAME);
+       oc = lookup_option (&dhcp_universe, options, SV_FILENAME);
        if (oc &&
-           evaluate_option_cache (&d1, packet, &options, oc)) {
+           evaluate_option_cache (&d1, packet, options, oc)) {
                memcpy (raw.file, d1.data,
                        d1.len > sizeof raw.file ? sizeof raw.file : d1.len);
                if (sizeof raw.file > d1.len)
@@ -206,9 +208,9 @@ void bootp (packet)
                memcpy (raw.file, packet -> raw -> file, sizeof raw.file);
 
        /* Choose a server name as above. */
-       oc = lookup_option (options.dhcp_hash, SV_SERVER_NAME);
+       oc = lookup_option (&dhcp_universe, options, SV_SERVER_NAME);
        if (oc &&
-           evaluate_option_cache (&d1, packet, &options, oc)) {
+           evaluate_option_cache (&d1, packet, options, oc)) {
                memcpy (raw.sname, d1.data,
                        d1.len > sizeof raw.sname ? sizeof raw.sname : d1.len);
                if (sizeof raw.sname > d1.len)
@@ -217,6 +219,9 @@ void bootp (packet)
                data_string_forget (&d1, "bootrequest");
        }
 
+       /* We're done with the option state. */
+       option_state_dereference (&options, "bootrequest");
+
        /* Set up the hardware destination address... */
        hto.htype = packet -> raw -> htype;
        hto.hlen = packet -> raw -> hlen;
index b88c368d7f70e19a3a1f77f631826cf51de366a7..d63de40fb8e661aca9213d164e264988f3442080 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: class.c,v 1.10 1999/03/16 05:50:42 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: class.c,v 1.11 1999/04/05 16:34:33 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -70,7 +70,7 @@ void classification_setup ()
 void classify_client (packet)
        struct packet *packet;
 {
-       execute_statements (packet, &packet -> options,
+       execute_statements (packet, packet -> options,
                            (struct option_state *)0,
                            default_classification_rules);
 }
@@ -93,7 +93,7 @@ int check_collection (packet, collection)
                   class if we've already billed it to a different class. */
                if (class -> submatch) {
                        status = evaluate_data_expression (&data, packet,
-                                                          &packet -> options,
+                                                          packet -> options,
                                                           class -> submatch);
                        if (status) {
                                if ((nc = ((struct class *)
@@ -132,7 +132,8 @@ int check_collection (packet, collection)
                                                  sizeof (struct lease *),
                                                  "check_collection"));
                                        if (!nc -> billed_leases) {
-                                               log_error ("no memory for billing");
+                                               log_error ("no memory for%s",
+                                                          " billing");
                                                data_string_forget
                                                        (&nc -> hash_string,
                                                         "check_collection");
@@ -158,7 +159,7 @@ int check_collection (packet, collection)
                }
 
                status = (evaluate_boolean_expression_result
-                         (packet, &packet -> options, class -> expr));
+                         (packet, packet -> options, class -> expr));
                if (status) {
                        matched = 1;
 #if defined (DEBUG_CLASS_MATCHING)