Kea 2.7.5
|
DHCPv4 message exchange. More...
#include <dhcp4_srv.h>
Public Member Functions | |
Dhcpv4Exchange (const AllocEnginePtr &alloc_engine, const Pkt4Ptr &query, AllocEngine::ClientContext4Ptr &context, const ConstSubnet4Ptr &subnet, bool &drop) | |
Constructor. | |
void | conditionallySetReservedClientClasses () |
Assigns classes retrieved from host reservation database if they haven't been yet set. | |
void | deleteResponse () |
Removes the response message by resetting the pointer to null. | |
CfgOptionList & | getCfgOptionList () |
Returns the configured option list (non-const version) | |
const CfgOptionList & | getCfgOptionList () const |
Returns the configured option list (const version) | |
AllocEngine::ClientContext4Ptr | getContext () const |
Returns the copy of the context for the Allocation engine. | |
bool | getIPv6OnlyPreferred () const |
Returns the IPv6-Only Preferred flag. | |
Pkt4Ptr | getQuery () const |
Returns the pointer to the query from the client. | |
Pkt4Ptr | getResponse () const |
Returns the pointer to the server's response. | |
void | initResponse () |
Initializes the instance of the response message. | |
void | initResponse4o6 () |
Initializes the DHCPv6 part of the response message. | |
void | setIPv6OnlyPreferred (bool ipv6_only_preferred) |
Set the IPv6-Only Preferred flag. | |
void | setReservedMessageFields () |
Sets reserved values of siaddr, sname and file in the server's response. | |
Static Public Member Functions | |
static void | classifyByVendor (const Pkt4Ptr &pkt) |
Assign class using vendor-class-identifier option. | |
static void | classifyPacket (const Pkt4Ptr &pkt) |
Assigns incoming packet to zero or more classes. | |
static void | evaluateClasses (const Pkt4Ptr &pkt, bool depend_on_known) |
Evaluate classes. | |
static void | removeDependentEvaluatedClasses (const Pkt4Ptr &query) |
Removed evaluated client classes. | |
static void | setHostIdentifiers (AllocEngine::ClientContext4Ptr context) |
Set host identifiers within a context. | |
static void | setReservedClientClasses (AllocEngine::ClientContext4Ptr context) |
Assigns classes retrieved from host reservation database. | |
DHCPv4 message exchange.
This class represents the DHCPv4 message exchange. The message exchange consists of the single client message, server response to this message and the mechanisms to generate the server's response. The server creates the instance of the Dhcpv4Exchange
for each inbound message that it accepts for processing.
The use of the Dhcpv4Exchange
object as a central repository of information about the message exchange simplifies the API of the Dhcpv4Srv
class.
Another benefit of using this class is that different methods of the Dhcpv4Srv
may share information. For example, the constructor of this class selects the subnet and multiple methods of Dhcpv4Srv
use this subnet, without the need to select it again.
Dhcpv4Srv
class will be migrated here. Definition at line 62 of file dhcp4_srv.h.
isc::dhcp::Dhcpv4Exchange::Dhcpv4Exchange | ( | const AllocEnginePtr & | alloc_engine, |
const Pkt4Ptr & | query, | ||
AllocEngine::ClientContext4Ptr & | context, | ||
const ConstSubnet4Ptr & | subnet, | ||
bool & | drop ) |
Constructor.
The constructor selects the subnet for the query and checks for the static host reservations for the client which has sent the message. The information about the reservations is stored in the AllocEngine::ClientContext4
object, which can be obtained by calling the getContext
.
alloc_engine | Pointer to the instance of the Allocation Engine used by the server. |
query | Pointer to the client message. |
context | Pointer to the client context. |
subnet | Pointer to the subnet to which the client belongs. |
drop | if it is true the packet will be dropped. |
Definition at line 205 of file dhcp4_srv.cc.
References isc::dhcp::DBG_DHCP4_BASIC, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_CLASS_ASSIGNED, isc::dhcp::DHCP4_CLASSES_ASSIGNED_AFTER_SUBNET_SELECTION, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_PACKET_DROP_0013, evaluateClasses(), initResponse(), isc::stats::StatsMgr::instance(), isc_throw, LOG_DEBUG, isc::dhcp::packet4_logger, removeDependentEvaluatedClasses(), setHostIdentifiers(), and setReservedClientClasses().
|
static |
Assign class using vendor-class-identifier option.
pkt | packet to be classified |
Definition at line 613 of file dhcp4_srv.cc.
References isc::dhcp::DHO_VENDOR_CLASS_IDENTIFIER, and isc::dhcp::Dhcpv4Srv::VENDOR_CLASS_PREFIX.
Referenced by classifyPacket().
|
static |
Assigns incoming packet to zero or more classes.
pkt | packet to be classified |
Definition at line 625 of file dhcp4_srv.cc.
References classifyByVendor(), and evaluateClasses().
Referenced by isc::dhcp::Dhcpv4Srv::classifyPacket().
void isc::dhcp::Dhcpv4Exchange::conditionallySetReservedClientClasses | ( | ) |
Assigns classes retrieved from host reservation database if they haven't been yet set.
This function sets reserved client classes in case they haven't been set after fetching host reservations from the database. This is the case when the client has non-global host reservation and the selected subnet belongs to a shared network.
Definition at line 577 of file dhcp4_srv.cc.
References setReservedClientClasses().
|
inline |
Removes the response message by resetting the pointer to null.
Definition at line 108 of file dhcp4_srv.h.
|
static |
Evaluate classes.
Evaluate expressions of client classes: if it returns true the class is added to the incoming packet.
pkt | packet to be classified. |
depend_on_known | if false classes depending on the KNOWN or UNKNOWN classes are skipped, if true only these classes are evaluated. |
Definition at line 636 of file dhcp4_srv.cc.
References isc::dhcp::CfgMgr::instance().
Referenced by Dhcpv4Exchange(), classifyPacket(), and isc::dhcp::Dhcpv4Srv::earlyGHRLookup().
|
inline |
Returns the configured option list (non-const version)
Definition at line 118 of file dhcp4_srv.h.
|
inline |
Returns the configured option list (const version)
Definition at line 123 of file dhcp4_srv.h.
|
inline |
Returns the copy of the context for the Allocation engine.
Definition at line 113 of file dhcp4_srv.h.
|
inline |
Returns the IPv6-Only Preferred flag.
Definition at line 128 of file dhcp4_srv.h.
|
inline |
Returns the pointer to the query from the client.
Definition at line 96 of file dhcp4_srv.h.
Referenced by initResponse(), and initResponse4o6().
|
inline |
Returns the pointer to the server's response.
The returned pointer is null if the query type is DHCPRELEASE or DHCPDECLINE.
Definition at line 103 of file dhcp4_srv.h.
void isc::dhcp::Dhcpv4Exchange::initResponse | ( | ) |
Initializes the instance of the response message.
The type of the response depends on the type of the query message. For the DHCPDISCOVER the DHCPOFFER is created. For the DHCPREQUEST and DHCPINFORM the DHCPACK is created. For the DHCPRELEASE the response is not initialized.
Definition at line 323 of file dhcp4_srv.cc.
References isc::dhcp::DHCPACK, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPOFFER, isc::dhcp::DHCPREQUEST, getQuery(), and initResponse4o6().
Referenced by Dhcpv4Exchange().
void isc::dhcp::Dhcpv4Exchange::initResponse4o6 | ( | ) |
Initializes the DHCPv6 part of the response message.
Called by initResponse() when the query is a DHCP4o6 message
Definition at line 349 of file dhcp4_srv.cc.
References DHCPV6_DHCPV4_RESPONSE, and getQuery().
Referenced by initResponse().
|
static |
Removed evaluated client classes.
query | the query message. |
Definition at line 552 of file dhcp4_srv.cc.
References isc::dhcp::CfgMgr::instance().
Referenced by Dhcpv4Exchange(), and isc::dhcp::Dhcpv4Srv::earlyGHRLookup().
|
static |
Set host identifiers within a context.
This method sets an ordered list of host identifier types and values which the server should use to find host reservations. The order of the set is determined by the configuration parameter, host-reservation-identifiers
context | pointer to the context. |
Definition at line 451 of file dhcp4_srv.cc.
References isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::log::DBGLVL_TRACE_BASIC, isc::dhcp::DHCP4_FLEX_ID, isc::dhcp::DHO_DHCP_AGENT_OPTIONS, isc::dhcp::getCalloutHandle(), isc::dhcp::Host::getIdentifierAsText(), Hooks, isc::dhcp::Host::IDENT_CIRCUIT_ID, isc::dhcp::Host::IDENT_CLIENT_ID, isc::dhcp::Host::IDENT_DUID, isc::dhcp::Host::IDENT_FLEX, isc::dhcp::Host::IDENT_HWADDR, isc::dhcp::CfgMgr::instance(), LOG_DEBUG, isc::hooks::CalloutHandle::NEXT_STEP_CONTINUE, isc::dhcp::packet4_logger, and isc::dhcp::RAI_OPTION_AGENT_CIRCUIT_ID.
Referenced by Dhcpv4Exchange(), and isc::dhcp::Dhcpv4Srv::earlyGHRLookup().
|
inline |
Set the IPv6-Only Preferred flag.
ipv6_only_preferred | new flag value. |
Definition at line 135 of file dhcp4_srv.h.
|
static |
Assigns classes retrieved from host reservation database.
context | pointer to the context. |
Definition at line 567 of file dhcp4_srv.cc.
Referenced by Dhcpv4Exchange(), and conditionallySetReservedClientClasses().
void isc::dhcp::Dhcpv4Exchange::setReservedMessageFields | ( | ) |
Sets reserved values of siaddr, sname and file in the server's response.
Definition at line 591 of file dhcp4_srv.cc.