2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 22:35:25 +00:00

Move support of server allow/deny into common code.

This commit is contained in:
Ted Lemon
1999-03-30 15:20:10 +00:00
parent 196be7203b
commit b1013db725
3 changed files with 71 additions and 55 deletions

View File

@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -1109,8 +1109,10 @@ struct executable_statement *parse_executable_statement (cfile, lose)
struct executable_statement *stmt, base; struct executable_statement *stmt, base;
struct class *cta; struct class *cta;
struct option *option; struct option *option;
struct option_cache *cache;
switch (peek_token (&val, cfile)) { token = peek_token (&val, cfile);
switch (token) {
case IF: case IF:
next_token (&val, cfile); next_token (&val, cfile);
stmt = parse_if_statement (cfile, lose); 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, return parse_option_statement (cfile, 1, option,
supersede_option_statement); 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: case DEFAULT:
token = next_token (&val, cfile); token = next_token (&val, cfile);
option = parse_option_name (cfile, 0); option = parse_option_name (cfile, 0);
@@ -2078,6 +2092,57 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
return 1; 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) int parse_auth_key (key_id, cfile)
struct data_string *key_id; struct data_string *key_id;
FILE *cfile; FILE *cfile;

View File

@@ -821,7 +821,6 @@ int parse_statement PROTO ((FILE *,
void parse_failover_peer PROTO ((FILE *, struct group *, int)); void parse_failover_peer PROTO ((FILE *, struct group *, int));
enum failover_state parse_failover_state PROTO ((FILE *)); enum failover_state parse_failover_state PROTO ((FILE *));
void parse_pool_statement PROTO ((FILE *, struct group *, int)); 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_boolean PROTO ((FILE *));
int parse_lbrace PROTO ((FILE *)); int parse_lbrace PROTO ((FILE *));
void parse_host_declaration PROTO ((FILE *, struct group *)); 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 *, int parse_option_token PROTO ((struct expression **, FILE *, char *,
struct expression *, int, int)); struct expression *, int, int));
int parse_allow_deny PROTO ((struct option_cache **, FILE *, int));
int parse_auth_key PROTO ((struct data_string *, FILE *)); int parse_auth_key PROTO ((struct data_string *, FILE *));
/* tree.c */ /* tree.c */

View File

@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#include "dhcpd.h" #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); parse_address_range (cfile, group, type, (struct pool *)0);
return declaration; return declaration;
#if 0
case ALLOW: case ALLOW:
case DENY: case DENY:
token = next_token (&val, cfile); token = next_token (&val, cfile);
@@ -364,6 +365,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
et -> op = supersede_option_statement; et -> op = supersede_option_statement;
et -> data.option = cache; et -> data.option = cache;
goto insert_statement; goto insert_statement;
#endif
case TOKEN_NOT: case TOKEN_NOT:
token = next_token (&val, cfile); token = next_token (&val, cfile);
@@ -815,57 +817,6 @@ void parse_pool_statement (cfile, group, type)
*p = pool; *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 */ /* boolean :== ON SEMI | OFF SEMI | TRUE SEMI | FALSE SEMI */
int parse_boolean (cfile) int parse_boolean (cfile)