]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Execute scoped rules in the correct order (outer to inner).
authorTed Lemon <source@isc.org>
Wed, 11 Nov 1998 07:51:41 +0000 (07:51 +0000)
committerTed Lemon <source@isc.org>
Wed, 11 Nov 1998 07:51:41 +0000 (07:51 +0000)
common/execute.c

index c791a9b10193b692e240d78c033338e931bfab50..5d9fa14c2223f36ec4a120e8a9b4a5cd9ec3a761 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: execute.c,v 1.3 1998/11/06 00:11:53 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: execute.c,v 1.4 1998/11/11 07:51:41 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -153,19 +153,25 @@ int execute_statements (packet, in_options, out_options, statements)
 /* Execute all the statements in a particular scope, and all statements in
    scopes outer from that scope, but if a particular limiting scope is
    reached, do not execute statements in that scope or in scopes outer
-   from it. */
+   from it.   More specific scopes need to take precedence over less
+   specific scopes, so we recursively traverse the scope list, executing
+   the most outer scope first. */
 
-void execute_statements_in_scope (packet, options, group, limiting_group)
+void execute_statements_in_scope (packet, in_options, out_options,
+                                 group, limiting_group)
        struct packet *packet;
-       struct option_state *options;
+       struct option_state *in_options;
+       struct option_state *out_options;
        struct group *group;
        struct group *limiting_group;
 {
        struct group *scope;
 
-       for (scope = group;
-            scope && scope != limiting_group; scope = scope -> next) {
-               execute_statements (packet, options, options,
-                                   scope -> statements);
-       }
+       if (group == limiting_group)
+               return;
+       if (group -> next)
+               execute_statements_in_scope (packet, in_options, out_options,
+                                            group -> next, limiting_group);
+       execute_statements (packet,
+                           in_options, out_options, group -> statements);
 }