mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 14:25:41 +00:00
[master] Add use-host-decl-names support to BOOTP
Merges in rt36233.
This commit is contained in:
@@ -3216,33 +3216,10 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
|
||||
}
|
||||
}
|
||||
|
||||
/* Use the hostname from the host declaration if there is one
|
||||
/* Use the name of the host declaration if there is one
|
||||
and no hostname has otherwise been provided, and if the
|
||||
use-host-decl-name flag is set. */
|
||||
i = DHO_HOST_NAME;
|
||||
j = SV_USE_HOST_DECL_NAMES;
|
||||
if (!lookup_option (&dhcp_universe, state -> options, i) &&
|
||||
lease -> host && lease -> host -> name &&
|
||||
(evaluate_boolean_option_cache
|
||||
(&ignorep, packet, lease, (struct client_state *)0,
|
||||
packet -> options, state -> options, &lease -> scope,
|
||||
lookup_option (&server_universe, state -> options, j), MDL))) {
|
||||
oc = (struct option_cache *)0;
|
||||
if (option_cache_allocate (&oc, MDL)) {
|
||||
if (make_const_data (&oc -> expression,
|
||||
((unsigned char *)
|
||||
lease -> host -> name),
|
||||
strlen (lease -> host -> name),
|
||||
1, 0, MDL)) {
|
||||
option_code_hash_lookup(&oc->option,
|
||||
dhcp_universe.code_hash,
|
||||
&i, 0, MDL);
|
||||
save_option (&dhcp_universe,
|
||||
state -> options, oc);
|
||||
}
|
||||
option_cache_dereference (&oc, MDL);
|
||||
}
|
||||
}
|
||||
use_host_decl_name(packet, lease, state->options);
|
||||
|
||||
/* Send client_id back if we received it and echo-client-id is on. */
|
||||
echo_client_id(packet, lease, state->options, state->options);
|
||||
@@ -5144,3 +5121,44 @@ maybe_return_agent_options(struct packet *packet, struct option_state *options)
|
||||
options->universe_count = agent_universe.index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds hostname option when use-host-decl-names is enabled.
|
||||
*
|
||||
* Constructs a hostname option from the name of the host declaration if
|
||||
* there is one and no hostname has otherwise been provided and the
|
||||
* use-host-decl-names flag is set, then adds the new option to the given
|
||||
* option_state. This funciton is used for both bootp and dhcp.
|
||||
*
|
||||
* \param packet inbound packet received from the client
|
||||
* \param lease lease associated with the client
|
||||
* \param options option state to search and update
|
||||
*/
|
||||
void use_host_decl_name(struct packet* packet,
|
||||
struct lease *lease,
|
||||
struct option_state *options) {
|
||||
unsigned int ocode = SV_USE_HOST_DECL_NAMES;
|
||||
if ((lease->host && lease->host->name) &&
|
||||
!lookup_option(&dhcp_universe, options, DHO_HOST_NAME) &&
|
||||
(evaluate_boolean_option_cache(NULL, packet, lease, NULL,
|
||||
packet->options, options,
|
||||
&lease->scope,
|
||||
lookup_option(&server_universe,
|
||||
options, ocode),
|
||||
MDL))) {
|
||||
struct option_cache *oc = NULL;
|
||||
if (option_cache_allocate (&oc, MDL)) {
|
||||
if (make_const_data(&oc -> expression,
|
||||
((unsigned char*)lease->host->name),
|
||||
strlen(lease->host->name),
|
||||
1, 0, MDL)) {
|
||||
ocode = DHO_HOST_NAME;
|
||||
option_code_hash_lookup(&oc->option,
|
||||
dhcp_universe.code_hash,
|
||||
&ocode, 0, MDL);
|
||||
save_option(&dhcp_universe, options, oc);
|
||||
}
|
||||
option_cache_dereference(&oc, MDL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user