Kea
1.9.9-git
|
DHCPv4 message exchange. More...
#include <dhcp4_srv.h>
Public Member Functions | |
Dhcpv4Exchange (const AllocEnginePtr &alloc_engine, const Pkt4Ptr &query, const Subnet4Ptr &subnet, bool &drop) | |
Constructor. More... | |
void | conditionallySetReservedClientClasses () |
Assigns classes retrieved from host reservation database if they haven't been yet set. More... | |
void | deleteResponse () |
Removes the response message by resetting the pointer to NULL. More... | |
CfgOptionList & | getCfgOptionList () |
Returns the configured option list (non-const version) More... | |
const CfgOptionList & | getCfgOptionList () 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 | setReservedMessageFields () |
Sets reserved values of siaddr, sname and file in the server's response. More... | |
Static Public Member Functions | |
static void | classifyByVendor (const Pkt4Ptr &pkt) |
Assign class using vendor-class-identifier option. More... | |
static void | classifyPacket (const Pkt4Ptr &pkt) |
Assigns incoming packet to zero or more classes. More... | |
static void | setReservedClientClasses (AllocEngine::ClientContext4Ptr context) |
Assigns classes retrieved from host reservation database. More... | |
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, | ||
const Subnet4Ptr & | 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. |
subnet | Pointer to the subnet to which the client belongs. |
drop | if it is true the packet will be dropped. |
Definition at line 147 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::addValue(), isc::dhcp::DBG_DHCP4_BASIC, isc::log::DBGLVL_TRACE_BASIC, isc::dhcp::DHCP4_CLASS_ASSIGNED, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_PACKET_DROP_0013, isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::dhcp::ClientClasses::empty(), isc::dhcp::CfgMgr::getCurrentCfg(), initResponse(), isc::stats::StatsMgr::instance(), isc::dhcp::CfgMgr::instance(), isc_throw, LOG_DEBUG, isc::dhcp::packet4_logger, setReservedClientClasses(), and isc::dhcp::ClientClasses::toText().
|
static |
Assign class using vendor-class-identifier option.
pkt | packet to be classified |
Definition at line 538 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 550 of file dhcp4_srv.cc.
References classifyByVendor().
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 502 of file dhcp4_srv.cc.
References setReservedClientClasses().
Referenced by isc::dhcp::Dhcpv4Srv::processDiscover(), isc::dhcp::Dhcpv4Srv::processInform(), and isc::dhcp::Dhcpv4Srv::processRequest().
|
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().
|
inline |
Returns the configured option list (non-const version)
Definition at line 116 of file dhcp4_srv.h.
Referenced by isc::dhcp::Dhcpv4Srv::appendBasicOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedVendorOptions(), and isc::dhcp::Dhcpv4Srv::buildCfgOptionList().
|
inline |
Returns the configured option list (const version)
Definition at line 121 of file dhcp4_srv.h.
|
inline |
Returns the copy of the context for the Allocation engine.
Definition at line 111 of file dhcp4_srv.h.
Referenced by isc::dhcp::Dhcpv4Srv::appendBasicOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedVendorOptions(), isc::dhcp::Dhcpv4Srv::assignLease(), isc::dhcp::Dhcpv4Srv::buildCfgOptionList(), isc::dhcp::Dhcpv4Srv::processClientName(), isc::dhcp::Dhcpv4Srv::processRequest(), isc::dhcp::Dhcpv4Srv::requiredClassify(), and isc::dhcp::Dhcpv4Srv::setFixedFields().
|
inline |
Returns the pointer to the query from the client.
Definition at line 94 of file dhcp4_srv.h.
Referenced by isc::dhcp::Dhcpv4Srv::adjustIfaceData(), isc::dhcp::Dhcpv4Srv::adjustRemoteAddr(), isc::dhcp::Dhcpv4Srv::appendRequestedOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedVendorOptions(), isc::dhcp::Dhcpv4Srv::appendServerID(), isc::dhcp::Dhcpv4Srv::assignLease(), isc::dhcp::Dhcpv4Srv::buildCfgOptionList(), isc::dhcp::Dhcpv4Srv::checkRelayPort(), initResponse(), initResponse4o6(), isc::dhcp::Dhcpv4Srv::processClientName(), isc::dhcp::Dhcpv4Srv::requiredClassify(), and isc::dhcp::Dhcpv4Srv::setFixedFields().
|
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 101 of file dhcp4_srv.h.
Referenced by isc::dhcp::Dhcpv4Srv::adjustIfaceData(), isc::dhcp::Dhcpv4Srv::adjustRemoteAddr(), isc::dhcp::Dhcpv4Srv::appendBasicOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedOptions(), isc::dhcp::Dhcpv4Srv::appendRequestedVendorOptions(), isc::dhcp::Dhcpv4Srv::appendServerID(), isc::dhcp::Dhcpv4Srv::assignLease(), isc::dhcp::Dhcpv4Srv::buildCfgOptionList(), isc::dhcp::Dhcpv4Srv::processClientName(), isc::dhcp::Dhcpv4Srv::processDiscover(), isc::dhcp::Dhcpv4Srv::processInform(), isc::dhcp::Dhcpv4Srv::processRequest(), isc::dhcp::Dhcpv4Srv::requiredClassify(), and isc::dhcp::Dhcpv4Srv::setFixedFields().
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 270 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 296 of file dhcp4_srv.cc.
References DHCPV6_DHCPV4_RESPONSE, isc::dhcp::Pkt4o6::getPkt6(), and getQuery().
Referenced by initResponse().
|
static |
Assigns classes retrieved from host reservation database.
context | pointer to the context. |
Definition at line 491 of file dhcp4_srv.cc.
References isc::dhcp::ClientClasses::cbegin(), and isc::dhcp::ClientClasses::cend().
Referenced by conditionallySetReservedClientClasses(), and Dhcpv4Exchange().
void isc::dhcp::Dhcpv4Exchange::setReservedMessageFields | ( | ) |
Sets reserved values of siaddr, sname and file in the server's response.
Definition at line 516 of file dhcp4_srv.cc.
Referenced by isc::dhcp::Dhcpv4Srv::setFixedFields().