From: Tomek Date: Wed, 29 Mar 2017 04:56:01 +0000 (-0500) Subject: [5132] host4_identifer hook implemented. X-Git-Tag: trac5196_base~12^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=123d69f24d315f498d50e9ef9e711d712ed96335;p=thirdparty%2Fkea.git [5132] host4_identifer hook implemented. --- diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index d90bee7292..b50e173ad9 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -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 diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index fba30d3544..50b2ca7c55 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -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 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: ; } diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 7cdc24e8ce..976e29a8a9 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -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. diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 9deb7eb410..155c47cad7 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -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);