Commit 123d69f2 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[5132] host4_identifer hook implemented.

parent fb402f75
......@@ -61,14 +61,6 @@ by the process. The signal will be handled before the server starts
waiting for next packets. The argument specifies the next signal to
be handled by the server.
% DHCP4_CCSESSION_STARTED control channel session started on socket %1
A debug message issued during startup after the DHCPv4 server has
successfully established a session with the Kea control channel.
% DHCP4_CCSESSION_STARTING starting control channel session, specfile: %1
This debug message is issued just before the DHCPv4 server attempts
to establish a session with the Kea control channel.
% DHCP4_CLASS_ASSIGNED %1: client packet has been assigned to the following class(es): %2
This debug message informs that incoming packet has been assigned to specified
class or classes. This is a normal behavior and indicates successful operation.
......@@ -243,6 +235,12 @@ from a client. Server does not process empty Hostname options and therefore
option is skipped. The argument holds the client and transaction identification
information.
% DHCP4_FLEX_ID flexible identifier generated for incoming packet: %1
This debug message is printed when host reservation type is set to flexible identifier
and the expression specified in its configuration generated (was evaluated to)
an indetifier for incoming packet. This debug message is mainly intended as a
debugging assistance for flexible identifier.
% DHCP4_GENERATE_FQDN %1: client did not send a FQDN or hostname; FQDN will be be generated for the client
This debug message is issued when the server did not receive a Hostname option
from the client and hostname generation is enabled. This provides a means to
......
......@@ -76,23 +76,25 @@ using namespace std;
/// Structure that holds registered hook indexes
struct Dhcp4Hooks {
int hook_index_buffer4_receive_;///< index for "buffer4_receive" hook point
int hook_index_pkt4_receive_; ///< index for "pkt4_receive" hook point
int hook_index_subnet4_select_; ///< index for "subnet4_select" hook point
int hook_index_lease4_release_; ///< index for "lease4_release" hook point
int hook_index_pkt4_send_; ///< index for "pkt4_send" hook point
int hook_index_buffer4_send_; ///< index for "buffer4_send" hook point
int hook_index_lease4_decline_; ///< index for "lease4_decline" hook point
int hook_index_buffer4_receive_; ///< index for "buffer4_receive" hook point
int hook_index_pkt4_receive_; ///< index for "pkt4_receive" hook point
int hook_index_subnet4_select_; ///< index for "subnet4_select" hook point
int hook_index_lease4_release_; ///< index for "lease4_release" hook point
int hook_index_pkt4_send_; ///< index for "pkt4_send" hook point
int hook_index_buffer4_send_; ///< index for "buffer4_send" hook point
int hook_index_lease4_decline_; ///< index for "lease4_decline" hook point
int hook_index_host4_identifier_;///< index for "host4_identifier" hook point
/// Constructor that registers hook points for DHCPv4 engine
Dhcp4Hooks() {
hook_index_buffer4_receive_= HooksManager::registerHook("buffer4_receive");
hook_index_pkt4_receive_ = HooksManager::registerHook("pkt4_receive");
hook_index_subnet4_select_ = HooksManager::registerHook("subnet4_select");
hook_index_pkt4_send_ = HooksManager::registerHook("pkt4_send");
hook_index_lease4_release_ = HooksManager::registerHook("lease4_release");
hook_index_buffer4_send_ = HooksManager::registerHook("buffer4_send");
hook_index_lease4_decline_ = HooksManager::registerHook("lease4_decline");
hook_index_buffer4_receive_ = HooksManager::registerHook("buffer4_receive");
hook_index_pkt4_receive_ = HooksManager::registerHook("pkt4_receive");
hook_index_subnet4_select_ = HooksManager::registerHook("subnet4_select");
hook_index_pkt4_send_ = HooksManager::registerHook("pkt4_send");
hook_index_lease4_release_ = HooksManager::registerHook("lease4_release");
hook_index_buffer4_send_ = HooksManager::registerHook("buffer4_send");
hook_index_lease4_decline_ = HooksManager::registerHook("lease4_decline");
hook_index_host4_identifier_ = HooksManager::registerHook("host4_identifier");
}
};
......@@ -338,7 +340,40 @@ Dhcpv4Exchange::setHostIdentifiers() {
}
}
break;
case Host::IDENT_FLEX:
if (HooksManager::calloutsPresent(Hooks.hook_index_host4_identifier_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(context_->query_);
Host::IdentifierType type = Host::IDENT_FLEX;
std::vector<uint8_t> id;
// Delete previously set arguments
callout_handle->deleteAllArguments();
// Pass incoming packet as argument
callout_handle->setArgument("query4", context_->query_);
callout_handle->setArgument("id_type", type);
callout_handle->setArgument("id_value", id);
// Call callouts
HooksManager::callCallouts(Hooks.hook_index_host4_identifier_,
*callout_handle);
callout_handle->getArgument("id_type", type);
callout_handle->getArgument("id_value", id);
if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_CONTINUE) &&
!id.empty()) {
LOG_DEBUG(packet4_logger, DBGLVL_TRACE_BASIC, DHCP4_FLEX_ID)
.arg(Host::getIdentifierAsText(type, &id[0], id.size()));
context_->addHostIdentifier(type, id);
}
}
break;
default:
;
}
......
......@@ -68,14 +68,6 @@ by the process. The signal will be handled before the server starts
waiting for next packets. The argument specifies the next signal to
be handled by the server.
% DHCP6_CCSESSION_STARTED control channel session started on socket %1
A debug message issued during startup after the IPv6 DHCP server has
successfully established a session with the Kea control channel.
% DHCP6_CCSESSION_STARTING starting control channel session, specfile: %1
This debug message is issued just before the IPv6 DHCP server attempts
to establish a session with the Kea control channel.
% DHCP6_CLASS_ASSIGNED %1: client packet has been assigned to the following class(es): %2
This debug message informs that incoming packet has been assigned to specified
class or classes. This is a normal behavior and indicates successful operation.
......
......@@ -344,7 +344,8 @@ Dhcpv6Srv::initContext(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx) {
callout_handle->setArgument("id_value", id);
// Call callouts
HooksManager::callCallouts(Hooks.hook_index_pkt6_receive_, *callout_handle);
HooksManager::callCallouts(Hooks.hook_index_host6_identifier_,
*callout_handle);
callout_handle->getArgument("id_type", type);
callout_handle->getArgument("id_value", id);
......
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