mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-29 13:28:14 +00:00
Implement ddns-fwd-name and ddns-rev-name subexpressions.
This commit is contained in:
parent
41a7cabfb7
commit
06a8567cf8
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: parse.c,v 1.40 1999/10/01 03:17:59 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: parse.c,v 1.41 1999/10/05 19:01:33 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -2037,6 +2037,22 @@ int parse_non_binary (expr, cfile, lose, context)
|
||||
(*expr) -> op = expr_host_decl_name;
|
||||
break;
|
||||
|
||||
case DDNS_FWD_NAME:
|
||||
token = next_token (&val, cfile);
|
||||
if (!expression_allocate (expr,
|
||||
"parse_expression: DDNS_FWD_NAME"))
|
||||
log_fatal ("can't allocate expression");
|
||||
(*expr) -> op = expr_dns_fwd_name;
|
||||
break;
|
||||
|
||||
case DDNS_REV_NAME:
|
||||
token = next_token (&val, cfile);
|
||||
if (!expression_allocate (expr,
|
||||
"parse_expression: DDNS_REV_NAME"))
|
||||
log_fatal ("can't allocate expression");
|
||||
(*expr) -> op = expr_dns_rev_name;
|
||||
break;
|
||||
|
||||
case PACKET:
|
||||
token = next_token (&val, cfile);
|
||||
if (!expression_allocate (expr, "parse_expression: PACKET"))
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: tree.c,v 1.53 1999/10/04 23:17:37 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: tree.c,v 1.54 1999/10/05 19:01:32 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -619,6 +619,8 @@ int evaluate_boolean_expression (result, packet, lease, in_options,
|
||||
case expr_host_decl_name:
|
||||
case expr_config_option:
|
||||
case expr_leased_address:
|
||||
case expr_dns_fwd_name:
|
||||
case expr_dns_rev_name:
|
||||
log_error ("Data opcode in evaluate_boolean_expression: %d",
|
||||
expr -> op);
|
||||
return 0;
|
||||
@ -1253,7 +1255,8 @@ int evaluate_data_expression (result, packet, lease,
|
||||
if (buffer_allocate (&result -> buffer, result -> len + 1,
|
||||
"host-decl-name")) {
|
||||
result -> data = &result -> buffer -> data [0];
|
||||
strcpy ((char *)&result -> data [0], lease -> host -> name);
|
||||
strcpy ((char *)&result -> data [0],
|
||||
lease -> host -> name);
|
||||
result -> terminated = 1;
|
||||
} else {
|
||||
log_error ("data: host-decl-name: no memory.");
|
||||
@ -1264,6 +1267,50 @@ int evaluate_data_expression (result, packet, lease,
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
case expr_dns_fwd_name:
|
||||
if (!lease || !lease -> ddns_fwd_name) {
|
||||
log_error ("data: dns-fwd-name: not available");
|
||||
return 0;
|
||||
}
|
||||
result -> len = strlen (lease -> ddns_fwd_name);
|
||||
if (buffer_allocate (&result -> buffer, result -> len + 1,
|
||||
"ddns-fwd-name")) {
|
||||
result -> data = &result -> buffer -> data [0];
|
||||
strcpy ((char *)&result -> data [0],
|
||||
lease -> ddns_fwd_name);
|
||||
result -> terminated = 1;
|
||||
} else {
|
||||
log_error ("data: ddns-fwd-name: no memory.");
|
||||
return 0;
|
||||
}
|
||||
#if defined (DEBUG_EXPRESSIONS)
|
||||
log_info ("data: ddns-fwd-name = %s",
|
||||
lease -> ddns_fwd_name);
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
case expr_dns_rev_name:
|
||||
if (!lease || !lease -> ddns_rev_name) {
|
||||
log_error ("data: ddns-rev-name: not available");
|
||||
return 0;
|
||||
}
|
||||
result -> len = strlen (lease -> ddns_rev_name);
|
||||
if (buffer_allocate (&result -> buffer, result -> len + 1,
|
||||
"ddns-rev-name")) {
|
||||
result -> data = &result -> buffer -> data [0];
|
||||
strcpy ((char *)&result -> data [0],
|
||||
lease -> ddns_rev_name);
|
||||
result -> terminated = 1;
|
||||
} else {
|
||||
log_error ("data: ddns-rev-name: no memory.");
|
||||
return 0;
|
||||
}
|
||||
#if defined (DEBUG_EXPRESSIONS)
|
||||
log_info ("data: ddns-rev-name = %s",
|
||||
lease -> ddns_rev_name);
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
case expr_check:
|
||||
case expr_equal:
|
||||
case expr_and:
|
||||
@ -1629,6 +1676,20 @@ void expression_dereference (eptr, name)
|
||||
(&expr -> data.reverse.buffer, name);
|
||||
break;
|
||||
|
||||
case expr_dns_update:
|
||||
if (expr -> data.dns_update.type)
|
||||
expression_dereference (&expr -> data.dns_update.type,
|
||||
name);
|
||||
if (expr -> data.dns_update.expr1)
|
||||
expression_dereference (&expr -> data.dns_update.type,
|
||||
name);
|
||||
if (expr -> data.dns_update.expr2)
|
||||
expression_dereference (&expr -> data.dns_update.type,
|
||||
name);
|
||||
if (expr -> data.dns_update.ttl)
|
||||
expression_dereference (&expr -> data.dns_update.type,
|
||||
name);
|
||||
|
||||
/* No subexpressions. */
|
||||
case expr_leased_address:
|
||||
case expr_lease_time:
|
||||
@ -1638,6 +1699,8 @@ void expression_dereference (eptr, name)
|
||||
case expr_hardware:
|
||||
case expr_exists:
|
||||
case expr_known:
|
||||
case expr_dns_fwd_name:
|
||||
case expr_dns_rev_name:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1721,7 +1784,9 @@ int is_data_expression (expr)
|
||||
expr -> op == expr_pick_first_value ||
|
||||
expr -> op == expr_host_decl_name ||
|
||||
expr -> op == expr_leased_address ||
|
||||
expr -> op == expr_config_option);
|
||||
expr -> op == expr_config_option ||
|
||||
expr -> op == expr_dns_fwd_name ||
|
||||
expr -> op == expr_dns_rev_name);
|
||||
}
|
||||
|
||||
int is_numeric_expression (expr)
|
||||
@ -1770,6 +1835,9 @@ static int op_val (op)
|
||||
case expr_config_option:
|
||||
case expr_leased_address:
|
||||
case expr_lease_time:
|
||||
case expr_dns_update:
|
||||
case expr_dns_fwd_name:
|
||||
case expr_dns_rev_name:
|
||||
return 100;
|
||||
|
||||
case expr_equal:
|
||||
@ -1827,6 +1895,9 @@ enum expression_context op_context (op)
|
||||
case expr_config_option:
|
||||
case expr_leased_address:
|
||||
case expr_lease_time:
|
||||
case expr_dns_update:
|
||||
case expr_dns_fwd_name:
|
||||
case expr_dns_rev_name:
|
||||
return context_any;
|
||||
|
||||
case expr_equal:
|
||||
@ -2177,6 +2248,16 @@ int write_expression (file, expr, col, indent)
|
||||
")");
|
||||
break;
|
||||
|
||||
case expr_dns_fwd_name:
|
||||
col = token_print_indent (file, col, indent, "", "",
|
||||
"dns-fwd-name");
|
||||
break;
|
||||
|
||||
case expr_dns_rev_name:
|
||||
col = token_print_indent (file, col, indent, "", "",
|
||||
"dns-rev-name");
|
||||
break;
|
||||
|
||||
default:
|
||||
log_fatal ("invalid expression type in print_expression: %d",
|
||||
expr -> op);
|
||||
|
@ -92,6 +92,8 @@ enum expr_op {
|
||||
expr_lease_time,
|
||||
expr_dns_update,
|
||||
expr_static,
|
||||
expr_dns_fwd_name,
|
||||
expr_dns_rev_name,
|
||||
};
|
||||
|
||||
struct expression {
|
||||
|
Loading…
x
Reference in New Issue
Block a user