]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Add a static operator indicating whether the client's lease is static.
authorTed Lemon <source@isc.org>
Sun, 1 Aug 1999 14:26:57 +0000 (14:26 +0000)
committerTed Lemon <source@isc.org>
Sun, 1 Aug 1999 14:26:57 +0000 (14:26 +0000)
common/conflex.c
common/dhcp-eval.5
common/parse.c
common/tree.c
includes/dhctoken.h
includes/tree.h

index 2ffc404aea4164c8a6d84a3e2638c186c9237eb4..34857e0ff77b12103a7d11167afd3893ce8d8042 100644 (file)
@@ -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"))
index 2ab9d9c5681fd6f2add36c61a3a553118a7e3b16..0e7e26bed80cf4e0d3ac24667bf34814271af715 100644 (file)
@@ -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
index 197fe1702100aa12af972d2a4ce343388cf9493c..20806fd7071037284d4a765764de3c68e30091c9 100644 (file)
@@ -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;
index b8cdc0ef1341a5fc156118c9db3399ef5b10c0bd..9006019aac05ab7ceda0583bd2d56bf70a9580c5 100644 (file)
@@ -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:
index 73626ba5a521a58211612b85aebf8fa0886f8386..fd7820ad593fed77a2b234f54551477b121f38a4 100644 (file)
@@ -193,6 +193,7 @@ enum dhcp_token {
        COMMIT = 411,
        DNS_UPDATE = 412,
        LEASE_TIME = 413,
+       STATIC = 414,
 };
 
 #define is_identifier(x)       ((x) >= FIRST_TOKEN &&  \
index c578282547e58d2cd7ed6e4c5819b716bd0f7f0c..7768ede6e36dead71d5dd7459431dde5501ffdb4 100644 (file)
@@ -91,6 +91,7 @@ enum expr_op {
        expr_pick_first_value,
        expr_lease_time,
        expr_dns_update,
+       expr_static,
 };
 
 struct expression {