Kea  1.5.0
isc::dhcp::Dhcpv4Exchange Class Reference

DHCPv4 message exchange. More...

#include <dhcp4_srv.h>

Public Member Functions

 Dhcpv4Exchange (const AllocEnginePtr &alloc_engine, const Pkt4Ptr &query, const Subnet4Ptr &subnet)
 Constructor. More...
 
void deleteResponse ()
 Removes the response message by resetting the pointer to NULL. More...
 
CfgOptionListgetCfgOptionList ()
 Returns the configured option list (non-const version) More...
 
const CfgOptionListgetCfgOptionList () const
 Returns the configured option list (const version) More...
 
AllocEngine::ClientContext4Ptr getContext () const
 Returns the copy of the context for the Allocation engine. More...
 
Pkt4Ptr getQuery () const
 Returns the pointer to the query from the client. More...
 
Pkt4Ptr getResponse () const
 Returns the pointer to the server's response. More...
 
void initResponse ()
 Initializes the instance of the response message. More...
 
void initResponse4o6 ()
 Initializes the DHCPv6 part of the response message. More...
 
void setReservedClientClasses ()
 Assigns classes retrieved from host reservation database. More...
 
void setReservedMessageFields ()
 Sets reserved values of siaddr, sname and file in the server's response. More...
 

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 63 of file dhcp4_srv.h.

Constructor & Destructor Documentation

◆ Dhcpv4Exchange()

isc::dhcp::Dhcpv4Exchange::Dhcpv4Exchange ( const AllocEnginePtr alloc_engine,
const Pkt4Ptr query,
const Subnet4Ptr subnet 
)

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.
subnetPointer to the subnet to which the client belongs.

Definition at line 123 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::dhcp4_logger, isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::dhcp::ClientClasses::empty(), isc::dhcp::Dhcpv4Srv::evaluateClasses(), isc::dhcp::Network::HR_DISABLED, initResponse(), isc_throw, LOG_DEBUG, and isc::dhcp::ClientClasses::toText().

+ Here is the call graph for this function:

Member Function Documentation

◆ deleteResponse()

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

Removes the response message by resetting the pointer to NULL.

Definition at line 106 of file dhcp4_srv.h.

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

◆ 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 121 of file dhcp4_srv.h.

◆ getContext()

◆ 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 193 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 219 of file dhcp4_srv.cc.

References DHCPV6_DHCPV4_RESPONSE, and getQuery().

Referenced by initResponse().

+ Here is the call graph for this function:

◆ setReservedClientClasses()

void isc::dhcp::Dhcpv4Exchange::setReservedClientClasses ( )

Assigns classes retrieved from host reservation database.

Definition at line 409 of file dhcp4_srv.cc.

References isc::dhcp::ClientClasses::cbegin(), and isc::dhcp::ClientClasses::cend().

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

+ Here is the call graph for this function:

◆ setReservedMessageFields()

void isc::dhcp::Dhcpv4Exchange::setReservedMessageFields ( )

Sets reserved values of siaddr, sname and file in the server's response.

Definition at line 420 of file dhcp4_srv.cc.

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


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