diff options
author | Thomas Markwalder <tmark@isc.org> | 2014-10-27 14:51:20 -0400 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2014-10-27 14:51:20 -0400 |
commit | 0a7e1a8ab06b462095f1aff14d07f83b5ff2e101 (patch) | |
tree | 0aeebd289ee185dd7d0f37dcd68b035140b63c02 /common/tree.c | |
parent | e046c826214dbf49bf8a507e4fbdc64f3394edd0 (diff) | |
download | isc-dhcp-0a7e1a8ab06b462095f1aff14d07f83b5ff2e101.tar.gz |
[master] Add use-host-decl-names support to BOOTP
Merges in rt36233.
Diffstat (limited to 'common/tree.c')
-rw-r--r-- | common/tree.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/common/tree.c b/common/tree.c index 102d80e6..bf5f0ec3 100644 --- a/common/tree.c +++ b/common/tree.c @@ -2072,7 +2072,7 @@ int evaluate_data_expression (result, packet, lease, client_state, ((packet == NULL) || (packet->dhcpv6_container_packet == NULL)))) { #if defined (DEBUG_EXPRESSIONS) - log_debug("data: v6relay(%d) = NULL", len); + log_debug("data: v6relay(%lu) = NULL", len); #endif return (0); } @@ -2090,7 +2090,7 @@ int evaluate_data_expression (result, packet, lease, client_state, /* We wanted a specific relay but were unable to find it */ if ((len <= MAX_V6RELAY_HOPS) && (i != 0)) { #if defined (DEBUG_EXPRESSIONS) - log_debug("data: v6relay(%d) = NULL", len); + log_debug("data: v6relay(%lu) = NULL", len); #endif return (0); } @@ -2107,7 +2107,7 @@ int evaluate_data_expression (result, packet, lease, client_state, } #if defined (DEBUG_EXPRESSIONS) - log_debug("data: v6relay(%d) = %s", len, + log_debug("data: v6relay(%lu) = %s", len, s1 ? print_hex_3(result->len, result->data, 30) : "NULL"); #endif @@ -2664,9 +2664,16 @@ int evaluate_option_cache (result, packet, lease, client_state, oc -> expression, file, line); } -/* Evaluate an option cache and extract a boolean from the result, - returning the boolean. Return false if there is no data. */ - +/* Evaluate an option cache and extract a boolean from the result. + * The boolean option cache is actually a trinary value where: + * + * 0 = return 0, ignore parameter 0 (also the case for no data) + * 1 = return 1, ignore parameter 0 + * 2 = return 0, ignore parameter 1 + * + * This supports both classic boolean flags on/off as well as the + * allow/deny/ignore keywords +*/ int evaluate_boolean_option_cache (ignorep, packet, lease, client_state, in_options, cfg_options, scope, oc, file, line) @@ -2681,36 +2688,35 @@ int evaluate_boolean_option_cache (ignorep, packet, const char *file; int line; { - struct data_string ds; - int result; + int result = 0; + if (ignorep) + *ignorep = 0; - /* So that we can be called with option_lookup as an argument. */ - if (!oc || !in_options) - return 0; - - memset (&ds, 0, sizeof ds); - if (!evaluate_option_cache (&ds, packet, - lease, client_state, in_options, - cfg_options, scope, oc, file, line)) - return 0; + /* Only attempt to evaluate if option_cache is not null. This permits + * us to be called with option_lookup() as an argument. */ + if (oc && in_options) { + struct data_string ds; + + memset(&ds, 0, sizeof ds); + if (evaluate_option_cache(&ds, packet, + lease, client_state, in_options, + cfg_options, scope, oc, file, + line)) { + /* We have a value for the option set result and + * ignore parameter accordingly. */ + if (ds.len) { + if (ds.data[0] == 1) + result = 1; + else if ((ds.data[0] == 2) && (ignorep != NULL)) + *ignorep = 1; + } - /* The boolean option cache is actually a trinary value. Zero is - * off, one is on, and 2 is 'ignore'. - */ - if (ds.len) { - result = ds.data [0]; - if (result == 2) { - result = 0; - if (ignorep != NULL) - *ignorep = 1; - } else if (ignorep != NULL) - *ignorep = 0; - } else - result = 0; - data_string_forget (&ds, MDL); - return result; + data_string_forget(&ds, MDL); + } + } + + return (result); } - /* Evaluate a boolean expression and return the result of the evaluation, or FALSE if it failed. */ |