From: Ted Lemon Date: Sun, 1 Aug 1999 14:26:57 +0000 (+0000) Subject: - Add a static operator indicating whether the client's lease is static. X-Git-Tag: V3-BETA-1-PATCH-2~5^2~144 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c5d573185ab5b93742c6531066796ff11d50049;p=thirdparty%2Fdhcp.git - Add a static operator indicating whether the client's lease is static. --- diff --git a/common/conflex.c b/common/conflex.c index 2ffc404ae..34857e0ff 100644 --- a/common/conflex.c +++ b/common/conflex.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: conflex.c,v 1.51 1999/07/19 15:32:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: conflex.c,v 1.52 1999/08/01 14:26:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -668,6 +668,8 @@ static enum dhcp_token intern (atom, dfv) return SPAWN; if (!strcasecmp (atom + 1, "pace")) return SPACE; + if (!strcasecmp (atom + 1, "tatic")) + return STATIC; break; case 't': if (!strcasecmp (atom + 1, "imestamp")) diff --git a/common/dhcp-eval.5 b/common/dhcp-eval.5 index 2ab9d9c56..0e7e26bed 100644 --- a/common/dhcp-eval.5 +++ b/common/dhcp-eval.5 @@ -164,6 +164,13 @@ The \fBknown\fR expression returns true if the client whose request is currently being processed is known - that is, if there's a host declaration for it. .RE +.B static +.PP +.RS 0.25i +The \fBstatic\fR expression returns true if the lease assigned to the +client whose request is currently being processed is derived from a static +address assignment. +.RE .SH DATA EXPRESSIONS Several of the boolean expressions above depend on the results of evaluating data expressions. A list of these expressions is provided diff --git a/common/parse.c b/common/parse.c index 197fe1702..20806fd70 100644 --- a/common/parse.c +++ b/common/parse.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.35 1999/07/31 21:35:12 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.36 1999/08/01 14:26:49 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -1648,9 +1648,16 @@ int parse_non_binary (expr, cfile, lose, context) } break; + case STATIC: + token = next_token (&val, cfile); + if (!expression_allocate (expr, "parse_expression: STATIC")) + log_fatal ("can't allocate expression"); + (*expr) -> op = expr_static; + break; + case KNOWN: token = next_token (&val, cfile); - if (!expression_allocate (expr, "parse_expression: EXISTS")) + if (!expression_allocate (expr, "parse_expression: KNOWN")) log_fatal ("can't allocate expression"); (*expr) -> op = expr_known; break; diff --git a/common/tree.c b/common/tree.c index b8cdc0ef1..9006019aa 100644 --- a/common/tree.c +++ b/common/tree.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: tree.c,v 1.45 1999/07/31 23:24:32 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: tree.c,v 1.46 1999/08/01 14:26:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -530,12 +530,29 @@ int evaluate_boolean_expression (result, packet, lease, in_options, *result = packet -> known; return 1; + case expr_static: + if (!lease || !(lease -> flags & STATIC_LEASE)) { +#if defined (DEBUG_EXPRESSIONS) + log_debug ("bool: static = false"); +#endif + *result = 0; + return 1; + } +#if defined (DEBUG_EXPRESSIONS) + log_debug ("bool: static = true"); +#endif + *result = 1; + return 1; + case expr_dns_update: #if !defined (NSUPDATE) return 0; #else /* we only want to do this on a DHCPREQUEST */ - if (packet -> packet_type != DHCPREQUEST) + if (!packet || packet -> packet_type != DHCPREQUEST) + return 0; + /* no update for static leases */ + if (lease && (lease -> flags & STATIC_LEASE)) return 0; memset (&rrtype, 0, sizeof expr1); s0 = evaluate_data_expression (&rrtype, packet, lease, @@ -1248,6 +1265,7 @@ int evaluate_data_expression (result, packet, lease, case expr_or: case expr_not: case expr_match: + case expr_static: case expr_known: log_error ("Boolean opcode in evaluate_data_expression: %d", expr -> op); @@ -1286,6 +1304,7 @@ int evaluate_numeric_expression (result, packet, lease, case expr_or: case expr_not: case expr_match: + case expr_static: case expr_known: log_error ("Boolean opcode in evaluate_numeric_expression: %d", expr -> op); @@ -1673,7 +1692,8 @@ int is_boolean_expression (expr) expr -> op == expr_or || expr -> op == expr_dns_update || expr -> op == expr_not || - expr -> op == expr_known); + expr -> op == expr_known || + expr -> op == expr_static); } int is_data_expression (expr) @@ -1717,6 +1737,7 @@ static int op_val (op) switch (op) { case expr_none: case expr_match: + case expr_static: case expr_check: case expr_substring: case expr_suffix: @@ -1773,6 +1794,7 @@ enum expression_context op_context (op) /* XXX Why aren't these specific? */ case expr_none: case expr_match: + case expr_static: case expr_check: case expr_substring: case expr_suffix: diff --git a/includes/dhctoken.h b/includes/dhctoken.h index 73626ba5a..fd7820ad5 100644 --- a/includes/dhctoken.h +++ b/includes/dhctoken.h @@ -193,6 +193,7 @@ enum dhcp_token { COMMIT = 411, DNS_UPDATE = 412, LEASE_TIME = 413, + STATIC = 414, }; #define is_identifier(x) ((x) >= FIRST_TOKEN && \ diff --git a/includes/tree.h b/includes/tree.h index c57828254..7768ede6e 100644 --- a/includes/tree.h +++ b/includes/tree.h @@ -91,6 +91,7 @@ enum expr_op { expr_pick_first_value, expr_lease_time, expr_dns_update, + expr_static, }; struct expression {