From: Ted Lemon Date: Tue, 30 Mar 1999 15:20:10 +0000 (+0000) Subject: Move support of server allow/deny into common code. X-Git-Tag: V3-ALPHA-19990330~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1013db72513a5045523e3e65a187453297688c0;p=thirdparty%2Fdhcp.git Move support of server allow/deny into common code. --- diff --git a/common/parse.c b/common/parse.c index 619d630e2..5b0d6bbd8 100644 --- a/common/parse.c +++ b/common/parse.c @@ -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; diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 4975e8437..9626c21a7 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -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 */ diff --git a/server/confpars.c b/server/confpars.c index ac5c2d676..55c181c2e 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -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)