Commit 1c5d5731 authored by Ted Lemon's avatar Ted Lemon

- Add a static operator indicating whether the client's lease is static.

parent b5b7abf8
......@@ -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"))
......
......@@ -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
......
......@@ -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;
......
......@@ -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:
......
......@@ -193,6 +193,7 @@ enum dhcp_token {
COMMIT = 411,
DNS_UPDATE = 412,
LEASE_TIME = 413,
STATIC = 414,
};
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
......
......@@ -91,6 +91,7 @@ enum expr_op {
expr_pick_first_value,
expr_lease_time,
expr_dns_update,
expr_static,
};
struct expression {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment