Kea 2.7.6
isc::dhcp::Dhcpv4Exchange Class Reference

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.
 
CfgOptionListgetCfgOptionList ()
 Returns the configured option list (non-const version)
 
const CfgOptionListgetCfgOptionList () 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.
 

Detailed Description

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.

Todo
This is the initial version of this class. In the future a lot of code from the Dhcpv4Srv class will be migrated here.

Definition at line 62 of file dhcp4_srv.h.

Constructor & Destructor Documentation

◆ Dhcpv4Exchange()

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.

Parameters
alloc_enginePointer to the instance of the Allocation Engine used by the server.
queryPointer to the client message.
contextPointer to the client context.
subnetPointer to the subnet to which the client belongs.
dropif it is true the packet will be dropped.

Definition at line 205 of file dhcp4_srv.cc.

References isc::stats::StatsMgr::addValue(), 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(), setReservedClientClasses(), and isc::dhcp::ClientClasses::toText().

+ Here is the call graph for this function:

Member Function Documentation

◆ classifyByVendor()

void isc::dhcp::Dhcpv4Exchange::classifyByVendor ( const Pkt4Ptr & pkt)
static

Assign class using vendor-class-identifier option.

Note
This is the first part of classifyPacket
Parameters
pktpacket 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().

◆ classifyPacket()

void isc::dhcp::Dhcpv4Exchange::classifyPacket ( const Pkt4Ptr & pkt)
static

Assigns incoming packet to zero or more classes.

Note
This is done in two phases: first the content of the vendor-class-identifier option is used as a class, by calling classifyByVendor(). Second, the classification match expressions are evaluated. The resulting classes will be stored in the packet (see isc::dhcp::Pkt4::classes_ and isc::dhcp::Pkt4::inClass).
Parameters
pktpacket to be classified

Definition at line 625 of file dhcp4_srv.cc.

References classifyByVendor(), and evaluateClasses().

Referenced by isc::dhcp::Dhcpv4Srv::classifyPacket().

+ Here is the call graph for this function:

◆ conditionallySetReservedClientClasses()

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().

Referenced by isc::dhcp::Dhcpv4Srv::processDiscover(), isc::dhcp::Dhcpv4Srv::processInform(), and isc::dhcp::Dhcpv4Srv::processRequest().

+ Here is the call graph for this function:

◆ deleteResponse()

void isc::dhcp::Dhcpv4Exchange::deleteResponse ( )
inline

Removes the response message by resetting the pointer to null.

Definition at line 108 of file dhcp4_srv.h.

Referenced by isc::dhcp::Dhcpv4Srv::assignLease().

◆ evaluateClasses()

void isc::dhcp::Dhcpv4Exchange::evaluateClasses ( const Pkt4Ptr & pkt,
bool depend_on_known )
static

Evaluate classes.

Note
Second part of the classification.

Evaluate expressions of client classes: if it returns true the class is added to the incoming packet.

Parameters
pktpacket to be classified.
depend_on_knownif 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::getCurrentCfg(), and isc::dhcp::CfgMgr::instance().

Referenced by Dhcpv4Exchange(), classifyPacket(), and isc::dhcp::Dhcpv4Srv::earlyGHRLookup().

+ Here is the call graph for this function:

◆ getCfgOptionList() [1/2]

CfgOptionList & isc::dhcp::Dhcpv4Exchange::getCfgOptionList ( )
inline

◆ getCfgOptionList() [2/2]

const CfgOptionList & isc::dhcp::Dhcpv4Exchange::getCfgOptionList ( ) const
inline

Returns the configured option list (const version)

Definition at line 123 of file dhcp4_srv.h.

◆ getContext()

◆ getIPv6OnlyPreferred()

bool isc::dhcp::Dhcpv4Exchange::getIPv6OnlyPreferred ( ) const
inline

Returns the IPv6-Only Preferred flag.

Definition at line 128 of file dhcp4_srv.h.

Referenced by isc::dhcp::Dhcpv4Srv::processDiscover(), and isc::dhcp::Dhcpv4Srv::processRequest().

◆ getQuery()

◆ getResponse()

◆ initResponse()

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().

+ Here is the call graph for this function:

◆ initResponse4o6()

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().

+ Here is the call graph for this function:

◆ removeDependentEvaluatedClasses()

void isc::dhcp::Dhcpv4Exchange::removeDependentEvaluatedClasses ( const Pkt4Ptr & query)
static

Removed evaluated client classes.

Todo
: keep the list of dependent evaluated classes so remove only them.
Parameters
querythe query message.

Definition at line 552 of file dhcp4_srv.cc.

References isc::dhcp::CfgMgr::getCurrentCfg(), and isc::dhcp::CfgMgr::instance().

Referenced by Dhcpv4Exchange(), and isc::dhcp::Dhcpv4Srv::earlyGHRLookup().

+ Here is the call graph for this function:

◆ setHostIdentifiers()

void isc::dhcp::Dhcpv4Exchange::setHostIdentifiers ( AllocEngine::ClientContext4Ptr context)
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

Parameters
contextpointer 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::CfgMgr::getCurrentCfg(), 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().

+ Here is the call graph for this function:

◆ setIPv6OnlyPreferred()

void isc::dhcp::Dhcpv4Exchange::setIPv6OnlyPreferred ( bool ipv6_only_preferred)
inline

Set the IPv6-Only Preferred flag.

Parameters
ipv6_only_preferrednew flag value.

Definition at line 135 of file dhcp4_srv.h.

Referenced by isc::dhcp::Dhcpv4Srv::assignLease().

◆ setReservedClientClasses()

void isc::dhcp::Dhcpv4Exchange::setReservedClientClasses ( AllocEngine::ClientContext4Ptr context)
static

Assigns classes retrieved from host reservation database.

Parameters
contextpointer to the context.

Definition at line 567 of file dhcp4_srv.cc.

Referenced by Dhcpv4Exchange(), and conditionallySetReservedClientClasses().

◆ setReservedMessageFields()

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.

Referenced by isc::dhcp::Dhcpv4Srv::setFixedFields().


The documentation for this class was generated from the following files: