]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Move support of server allow/deny into common code.
authorTed Lemon <source@isc.org>
Tue, 30 Mar 1999 15:20:10 +0000 (15:20 +0000)
committerTed Lemon <source@isc.org>
Tue, 30 Mar 1999 15:20:10 +0000 (15:20 +0000)
common/parse.c
includes/dhcpd.h
server/confpars.c

index 619d630e2b063f9652e35c931005df399f483940..5b0d6bbd88f7bdb026d880b834b1cab4176cbb4e 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: parse.c,v 1.18 1999/03/25 21:59:36 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: parse.c,v 1.19 1999/03/30 15:20:09 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1109,8 +1109,10 @@ struct executable_statement *parse_executable_statement (cfile, lose)
        struct executable_statement *stmt, base;
        struct class *cta;
        struct option *option;
+       struct option_cache *cache;
 
-       switch (peek_token (&val, cfile)) {
+       token = peek_token (&val, cfile);
+       switch (token) {
              case IF:
                next_token (&val, cfile);
                stmt = parse_if_statement (cfile, lose);
@@ -1167,6 +1169,18 @@ struct executable_statement *parse_executable_statement (cfile, lose)
                return parse_option_statement (cfile, 1, option,
                                               supersede_option_statement);
 
+             case ALLOW:
+             case DENY:
+               token = next_token (&val, cfile);
+               cache = (struct option_cache *)0;
+               if (!parse_allow_deny (&cache, cfile,
+                                      token == ALLOW ? 1 : 0))
+                       return (struct executable_statement *)0;
+               memset (&base, 0, sizeof base);
+               base.op = supersede_option_statement;
+               base.data.option = cache;
+               break;
+
              case DEFAULT:
                token = next_token (&val, cfile);
                option = parse_option_name (cfile, 0);
@@ -2078,6 +2092,57 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
        return 1;
 }
 
+/* allow-deny-keyword :== BOOTP
+                       | BOOTING
+                       | DYNAMIC_BOOTP
+                       | UNKNOWN_CLIENTS */
+
+int parse_allow_deny (oc, cfile, flag)
+       struct option_cache **oc;
+       FILE *cfile;
+       int flag;
+{
+       enum dhcp_token token;
+       char *val;
+       unsigned char rf = flag;
+       struct expression *data = (struct expression *)0;
+       int status;
+
+       if (!make_const_data (&data, &rf, 1, 0, 1))
+               return 0;
+
+       token = next_token (&val, cfile);
+       switch (token) {
+             case BOOTP:
+               status = option_cache (oc, (struct data_string *)0, data,
+                                      &server_options [SV_ALLOW_BOOTP]);
+               break;
+
+             case BOOTING:
+               status = option_cache (oc, (struct data_string *)0, data,
+                                      &server_options [SV_ALLOW_BOOTING]);
+               break;
+
+             case DYNAMIC_BOOTP:
+               status = option_cache (oc, (struct data_string *)0, data,
+                                      &server_options [SV_DYNAMIC_BOOTP]);
+               break;
+
+             case UNKNOWN_CLIENTS:
+               status = (option_cache
+                         (oc, (struct data_string *)0, data,
+                          &server_options [SV_BOOT_UNKNOWN_CLIENTS]));
+               break;
+
+             default:
+               parse_warn ("expecting allow/deny key");
+               skip_to_semi (cfile);
+               return 0;
+       }
+       parse_semi (cfile);
+       return status;
+}
+
 int parse_auth_key (key_id, cfile)
        struct data_string *key_id;
        FILE *cfile;
index 4975e8437c03d54eb3a49589bac463a382e5f498..9626c21a7d2c09294ca5bf4c164c92193068fd68 100644 (file)
@@ -821,7 +821,6 @@ int parse_statement PROTO ((FILE *,
 void parse_failover_peer PROTO ((FILE *, struct group *, int));
 enum failover_state parse_failover_state PROTO ((FILE *));
 void parse_pool_statement PROTO ((FILE *, struct group *, int));
-int parse_allow_deny PROTO ((struct option_cache **, FILE *, int));
 int parse_boolean PROTO ((FILE *));
 int parse_lbrace PROTO ((FILE *));
 void parse_host_declaration PROTO ((FILE *, struct group *));
@@ -870,6 +869,7 @@ struct executable_statement *parse_option_statement PROTO ((FILE *, int,
                                                           );
 int parse_option_token PROTO ((struct expression **, FILE *, char *,
                               struct expression *, int, int));
+int parse_allow_deny PROTO ((struct option_cache **, FILE *, int));
 int parse_auth_key PROTO ((struct data_string *, FILE *));
 
 /* tree.c */
index ac5c2d676adbc329e7cdec013da8e7311732fc64..55c181c2e3d21cb94a00ecd9f0622623abeae05a 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: confpars.c,v 1.68 1999/03/29 18:59:54 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: confpars.c,v 1.69 1999/03/30 15:20:09 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -348,6 +348,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
                parse_address_range (cfile, group, type, (struct pool *)0);
                return declaration;
 
+#if 0
              case ALLOW:
              case DENY:
                token = next_token (&val, cfile);
@@ -364,6 +365,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
                et -> op = supersede_option_statement;
                et -> data.option = cache;
                goto insert_statement;
+#endif
 
              case TOKEN_NOT:
                token = next_token (&val, cfile);
@@ -815,57 +817,6 @@ void parse_pool_statement (cfile, group, type)
        *p = pool;
 }
 
-/* allow-deny-keyword :== BOOTP
-                       | BOOTING
-                       | DYNAMIC_BOOTP
-                       | UNKNOWN_CLIENTS */
-
-int parse_allow_deny (oc, cfile, flag)
-       struct option_cache **oc;
-       FILE *cfile;
-       int flag;
-{
-       enum dhcp_token token;
-       char *val;
-       unsigned char rf = flag;
-       struct expression *data = (struct expression *)0;
-       int status;
-
-       if (!make_const_data (&data, &rf, 1, 0, 1))
-               return 0;
-
-       token = next_token (&val, cfile);
-       switch (token) {
-             case BOOTP:
-               status = option_cache (oc, (struct data_string *)0, data,
-                                      &server_options [SV_ALLOW_BOOTP]);
-               break;
-
-             case BOOTING:
-               status = option_cache (oc, (struct data_string *)0, data,
-                                      &server_options [SV_ALLOW_BOOTING]);
-               break;
-
-             case DYNAMIC_BOOTP:
-               status = option_cache (oc, (struct data_string *)0, data,
-                                      &server_options [SV_DYNAMIC_BOOTP]);
-               break;
-
-             case UNKNOWN_CLIENTS:
-               status = (option_cache
-                         (oc, (struct data_string *)0, data,
-                          &server_options [SV_BOOT_UNKNOWN_CLIENTS]));
-               break;
-
-             default:
-               parse_warn ("expecting allow/deny key");
-               skip_to_semi (cfile);
-               return 0;
-       }
-       parse_semi (cfile);
-       return status;
-}
-
 /* boolean :== ON SEMI | OFF SEMI | TRUE SEMI | FALSE SEMI */
 
 int parse_boolean (cfile)