Kea  1.5.0
isc::dhcp::Dhcpv4Srv Class Reference

DHCPv4 server service. More...

#include <dhcp4_srv.h>

+ Inheritance diagram for isc::dhcp::Dhcpv4Srv:

Public Types

enum  RequirementLevel { FORBIDDEN, MANDATORY, OPTIONAL }
 defines if certain option may, must or must not appear More...
 

Public Member Functions

 Dhcpv4Srv (uint16_t port=DHCP4_SERVER_PORT, const bool use_bcast=true, const bool direct_response_desired=true)
 Default constructor. More...
 
virtual ~Dhcpv4Srv ()
 Destructor. Used during DHCPv4 service shutdown. More...
 
void classifyByVendor (const Pkt4Ptr &pkt)
 Assign class using vendor-class-identifier option. More...
 
virtual void d2ClientErrorHandler (const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
 Implements the error handler for DHCP_DDNS IO errors. More...
 
void declineLease (const Lease4Ptr &lease, const Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context)
 Marks lease as declined. More...
 
void discardPackets ()
 Discard all in-progress packets. More...
 
asiolink::IOServicePtrgetIOService ()
 Returns pointer to the IO service used by the server. More...
 
NetworkStatePtrgetNetworkState ()
 Returns pointer to the network state used by the server. More...
 
void processPacket (Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park=true)
 Process a single incoming DHCPv4 packet. More...
 
bool run ()
 Main server processing loop. More...
 
void run_one ()
 Main server processing step. More...
 
void shutdown ()
 Instructs the server to shut down. More...
 
void startD2 ()
 Starts DHCP_DDNS client IO if DDNS updates are enabled. More...
 
void stopD2 ()
 Stops DHCP_DDNS client IO if DDNS updates are enabled. More...
 
Public accessors returning values required to (re)open sockets.
uint16_t getPort () const
 Get UDP port on which server should listen. More...
 
bool useBroadcast () const
 Return bool value indicating that broadcast flags should be set on sockets. More...
 
- Public Member Functions inherited from isc::process::Daemon
 Daemon ()
 Default constructor. More...
 
virtual ~Daemon ()
 Destructor. More...
 
void checkConfigFile () const
 Checks the configuration file name. More...
 
virtual void cleanup ()
 Performs final deconfiguration. More...
 
void createPIDFile (int pid=0)
 Creates the PID file. More...
 
std::string getConfigFile () const
 Returns config file name. More...
 
std::string getPIDFileDir () const
 Returns the directory used when forming default PID file name. More...
 
std::string getPIDFileName () const
 Returns the current PID file name. More...
 
std::string getProcName () const
 returns the process name This value is used as when forming the default PID file name More...
 
void setConfigFile (const std::string &config_file)
 Sets the configuration file name. More...
 
void setPIDFileDir (const std::string &pid_file_dir)
 Sets the PID file directory. More...
 
void setPIDFileName (const std::string &pid_file_name)
 Sets PID file name. More...
 
void setProcName (const std::string &proc_name)
 Sets the process name. More...
 
virtual size_t writeConfigFile (const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
 Writes current configuration to specified file. More...
 

Static Public Member Functions

static void evaluateClasses (const Pkt4Ptr &pkt, bool depend_on_known)
 Evaluate classes. More...
 
static int getHookIndexBuffer4Receive ()
 Returns the index for "buffer4_receive" hook point. More...
 
static int getHookIndexBuffer4Send ()
 Returns the index for "buffer4_send" hook point. More...
 
static int getHookIndexLease4Decline ()
 Returns the index for "lease4_decline" hook point. More...
 
static int getHookIndexLease4Release ()
 Returns the index for "lease4_release" hook point. More...
 
static int getHookIndexPkt4Receive ()
 Returns the index for "pkt4_receive" hook point. More...
 
static int getHookIndexPkt4Send ()
 Returns the index for "pkt4_send" hook point. More...
 
static int getHookIndexSubnet4Select ()
 Returns the index for "subnet4_select" hook point. More...
 
static std::string getVersion (bool extended)
 returns Kea version on stdout and exit. More...
 
static void processStatsReceived (const Pkt4Ptr &query)
 Class methods for DHCPv4-over-DHCPv6 handler. More...
 
static void processStatsSent (const Pkt4Ptr &response)
 Updates statistics for transmitted packets. More...
 
- Static Public Member Functions inherited from isc::process::Daemon
static void configureLogger (const isc::data::ConstElementPtr &log_config, const isc::process::ConfigPtr &storage)
 Configures logger. More...
 
static std::string getDefaultLoggerName ()
 Returns default logger name. More...
 
static bool getVerbose ()
 Returns if running in verbose mode. More...
 
static std::string getVersion (bool extended)
 returns Kea version on stdout and exits. More...
 
static void loggerInit (const char *log_name, bool verbose)
 Initializes logger. More...
 
static void setDefaultLoggerName (const std::string &logger)
 Sets the default logger name. More...
 
static void setVerbose (const bool verbose)
 Sets or clears verbose mode. More...
 

Protected Member Functions

void appendBasicOptions (Dhcpv4Exchange &ex)
 Append basic options if they are not present. More...
 
void appendRequestedOptions (Dhcpv4Exchange &ex)
 Appends options requested by client. More...
 
void appendRequestedVendorOptions (Dhcpv4Exchange &ex)
 Appends requested vendor options as requested by client. More...
 
void assignLease (Dhcpv4Exchange &ex)
 Assigns a lease and appends corresponding options. More...
 
void buildCfgOptionList (Dhcpv4Exchange &ex)
 Build the configured option list. More...
 
void classifyPacket (const Pkt4Ptr &pkt)
 Assigns incoming packet to zero or more classes. More...
 
void createNameChangeRequests (const Lease4Ptr &lease, const Lease4Ptr &old_lease)
 Creates NameChangeRequests which correspond to the lease which has been acquired. More...
 
void deferredUnpack (Pkt4Ptr &query)
 Perform deferred option unpacking. More...
 
void processClientName (Dhcpv4Exchange &ex)
 Processes Client FQDN and Hostname Options sent by a client. More...
 
void processDecline (Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context)
 Process incoming DHCPDECLINE messages. More...
 
Pkt4Ptr processDiscover (Pkt4Ptr &discover)
 Processes incoming DISCOVER and returns response. More...
 
Pkt4Ptr processInform (Pkt4Ptr &inform)
 Processes incoming DHCPINFORM messages. More...
 
void processPacketBufferSend (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &rsp)
 Executes buffer4_send callout and sends the response. More...
 
void processPacketPktSend (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp)
 Executes pkt4_send callout. More...
 
void processRelease (Pkt4Ptr &release, AllocEngine::ClientContext4Ptr &context)
 Processes incoming DHCPRELEASE messages. More...
 
Pkt4Ptr processRequest (Pkt4Ptr &request, AllocEngine::ClientContext4Ptr &context)
 Processes incoming REQUEST and returns REPLY response. More...
 
virtual Pkt4Ptr receivePacket (int timeout)
 dummy wrapper around IfaceMgr::receive4 More...
 
void renewLease (const Pkt4Ptr &renew, Pkt4Ptr &reply)
 Attempts to renew received addresses. More...
 
void requiredClassify (Dhcpv4Exchange &ex)
 Assigns incoming packet to zero or more classes (required pass). More...
 
isc::dhcp::Subnet4Ptr selectSubnet (const Pkt4Ptr &query, bool &drop, bool sanity_only=false) const
 Selects a subnet for a given client's packet. More...
 
isc::dhcp::Subnet4Ptr selectSubnet4o6 (const Pkt4Ptr &query, bool &drop, bool sanity_only=false) const
 Selects a subnet for a given client's DHCP4o6 packet. More...
 
virtual void sendPacket (const Pkt4Ptr &pkt)
 dummy wrapper around IfaceMgr::send() More...
 
void setFixedFields (Dhcpv4Exchange &ex)
 Sets fixed fields of the outgoing packet. More...
 
Functions filtering and sanity-checking received messages.
Todo:
These functions are supposed to be moved to a new class which will manage different rules for accepting and rejecting messages.

Perhaps ticket #3116 is a good opportunity to do it.

bool accept (const Pkt4Ptr &query) const
 Checks whether received message should be processed or discarded. More...
 
bool acceptDirectRequest (const Pkt4Ptr &query) const
 Check if a message sent by directly connected client should be accepted or discarded. More...
 
bool acceptMessageType (const Pkt4Ptr &query) const
 Check if received message type is valid for the server to process. More...
 
bool acceptServerId (const Pkt4Ptr &pkt) const
 Verifies if the server id belongs to our server. More...
 
- Protected Member Functions inherited from isc::process::Daemon
virtual void handleSignal ()
 Invokes handler for the next received signal. More...
 
std::string makePIDFileName () const
 Manufacture the pid file name. More...
 

Static Protected Member Functions

static void adjustIfaceData (Dhcpv4Exchange &ex)
 Set IP/UDP and interface parameters for the DHCPv4 response. More...
 
static void adjustRemoteAddr (Dhcpv4Exchange &ex)
 Sets remote addresses for outgoing packet. More...
 
static void appendServerID (Dhcpv4Exchange &ex)
 Adds server identifier option to the server's response. More...
 
static uint16_t checkRelayPort (const Dhcpv4Exchange &ex)
 Check if the relay port RAI sub-option was set in the query. More...
 
static void sanityCheck (const Pkt4Ptr &query, RequirementLevel serverid)
 Verifies if specified packet meets RFC requirements. More...
 
static std::string srvidToString (const OptionPtr &opt)
 converts server-id to text Converts content of server-id option to a text representation, e.g. More...
 

Protected Attributes

boost::shared_ptr< AllocEnginealloc_engine_
 Allocation Engine. More...
 
NetworkStatePtr network_state_
 Holds information about disabled DHCP service and/or disabled subnet/network scopes. More...
 
volatile bool shutdown_
 indicates if shutdown is in progress. More...
 
- Protected Attributes inherited from isc::process::Daemon
isc::util::SignalHandler signal_handler_
 Pointer to the common signal handler invoked by the handleSignal function. More...
 
isc::util::SignalSetPtr signal_set_
 A pointer to the object installing custom signal handlers. More...
 

Static Protected Attributes

static const std::string VENDOR_CLASS_PREFIX
 this is a prefix added to the content of vendor-class option More...
 

Detailed Description

DHCPv4 server service.

This singleton class represents DHCPv4 server. It contains all top-level methods and routines necessary for server operation. In particular, it instantiates IfaceMgr, loads or generates DUID that is going to be used as server-identifier, receives incoming packets, processes them, manages leases assignment and generates appropriate responses.

This class does not support any controlling mechanisms directly. See the derived ControlledDhcpv4Srv class for support for command and configuration updates over msgq.

Definition at line 194 of file dhcp4_srv.h.

Member Enumeration Documentation

◆ RequirementLevel

defines if certain option may, must or must not appear

Enumerator
FORBIDDEN 
MANDATORY 
OPTIONAL 

Definition at line 203 of file dhcp4_srv.h.

Constructor & Destructor Documentation

◆ Dhcpv4Srv()

isc::dhcp::Dhcpv4Srv::Dhcpv4Srv ( uint16_t  port = DHCP4_SERVER_PORT,
const bool  use_bcast = true,
const bool  direct_response_desired = true 
)

Default constructor.

Instantiates necessary services, required to run DHCPv4 server. In particular, creates IfaceMgr that will be responsible for network interaction. Will instantiate lease manager, and load old or create new DUID. It is possible to specify alternate port on which DHCPv4 server will listen on. That is mostly useful for testing purposes. The Last two arguments of the constructor should be left at default values for normal server operation. They should be set to 'false' when creating an instance of this class for unit testing because features they enable require root privileges.

Parameters
portspecifies port number to listen on
use_bcastconfigure sockets to support broadcast messages.
direct_response_desiredspecifies if it is desired to use direct V4 traffic.
Todo:
call loadLibraries() when handling configuration changes

Definition at line 444 of file dhcp4_srv.cc.

References alloc_engine_, isc::dhcp::AllocEngine::ALLOC_ITERATIVE, isc::dhcp::DBG_DHCP4_START, isc::dhcp::dhcp4_logger, isc::dhcp::IfaceMgr::instance(), LOG_DEBUG, LOG_ERROR, isc::dhcp::IfaceMgr::setMatchingPacketFilter(), and shutdown_.

+ Here is the call graph for this function:

◆ ~Dhcpv4Srv()

isc::dhcp::Dhcpv4Srv::~Dhcpv4Srv ( )
virtual

Member Function Documentation

◆ accept()

bool isc::dhcp::Dhcpv4Srv::accept ( const Pkt4Ptr query) const
protected

Checks whether received message should be processed or discarded.

This function checks whether received message should be processed or discarded. It should be called on the beginning of message processing (just after the message has been decoded). This message calls a number of other functions which check whether message should be processed, using different criteria.

This function should be extended when new criteria for accepting received message have to be implemented. This function is meant to aggregate all early filtering checks on the received message. By having a single function like this, we are avoiding bloat of the server's main loop.

Warning
This function should remain exception safe.
Parameters
queryReceived message.
Returns
true if the message should be further processed, or false if the message should be discarded.

Definition at line 2983 of file dhcp4_srv.cc.

References acceptDirectRequest(), acceptMessageType(), acceptServerId(), isc::dhcp::bad_packet4_logger, isc::dhcp::DBG_DHCP4_DETAIL, and LOG_DEBUG.

Referenced by processPacket().

+ Here is the call graph for this function:

◆ acceptDirectRequest()

bool isc::dhcp::Dhcpv4Srv::acceptDirectRequest ( const Pkt4Ptr query) const
protected

Check if a message sent by directly connected client should be accepted or discarded.

This function checks if the received message is from directly connected client. If it is, it checks that it should be processed or discarded.

Note that this function doesn't validate all addresses being carried in the message. The primary purpose of this function is to filter out direct messages in the local network for which there is no suitable subnet configured. For example, this function accepts unicast messages because unicasts may be used by clients located in remote networks to to renew existing leases. If their notion of address is wrong, the server will have to sent a NAK, instead of dropping the message. Detailed validation of such messages is performed at later stage of processing.

This function accepts the following messages:

  • all valid relayed messages,
  • all unicast messages,
  • all broadcast messages except DHCPINFORM received on the interface for which the suitable subnet exists (is configured).
  • all DHCPINFORM messages with source address or ciaddr set.
Parameters
queryMessage sent by a client.
Returns
true if message is accepted for further processing, false otherwise.

Definition at line 3011 of file dhcp4_srv.cc.

References isc::dhcp::DHCPINFORM, and selectSubnet().

Referenced by accept().

+ Here is the call graph for this function:

◆ acceptMessageType()

bool isc::dhcp::Dhcpv4Srv::acceptMessageType ( const Pkt4Ptr query) const
protected

Check if received message type is valid for the server to process.

This function checks that the received message type belongs to the range of types recognized by the server and that the message of this type should be processed by the server.

The messages types accepted for processing are:

  • Discover
  • Request
  • Release
  • Decline
  • Inform
Parameters
queryMessage sent by a client.
Returns
true if message is accepted for further processing, false otherwise.

Definition at line 3049 of file dhcp4_srv.cc.

References isc::dhcp::bad_packet4_logger, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DHCP_NOTYPE, isc::dhcp::DHCP_TYPES_EOF, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, LOG_DEBUG, and LOG_INFO.

Referenced by accept().

◆ acceptServerId()

bool isc::dhcp::Dhcpv4Srv::acceptServerId ( const Pkt4Ptr pkt) const
protected

Verifies if the server id belongs to our server.

This function checks if the server identifier carried in the specified DHCPv4 message belongs to this server. If the server identifier option is absent or the value carried by this option is equal to one of the server identifiers used by the server, the true is returned. If the server identifier option is present, but it doesn't match any server identifier used by this server, the false value is returned.

Parameters
pktDHCPv4 message which server identifier is to be checked.
Returns
true, if the server identifier is absent or matches one of the server identifiers that the server is using; false otherwise.
Todo:
Currently we only check subnet identifiers configured on the subnet level, shared network level and global level. This should be sufficient for most of cases. At this point, trying to support server identifiers on the class level seems to be an overkill and is probably not needed. Same with host reservations. In fact, at this point we don't know the reservations for the client communicating with the server. We may revise some of these choices in the future.

Definition at line 3105 of file dhcp4_srv.cc.

References DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::IfaceMgr::hasOpenSocket(), isc::dhcp::CfgMgr::instance(), isc::dhcp::IfaceMgr::instance(), and isc::asiolink::IOAddress::isV4().

Referenced by accept().

+ Here is the call graph for this function:

◆ adjustIfaceData()

void isc::dhcp::Dhcpv4Srv::adjustIfaceData ( Dhcpv4Exchange ex)
staticprotected

Set IP/UDP and interface parameters for the DHCPv4 response.

This method sets the following parameters for the DHCPv4 message being sent to a client:

  • client unicast or a broadcast address,
  • client or relay port,
  • server address,
  • server port,
  • name and index of the interface which is to be used to send the message.

Internally it calls the Dhcpv4Srv::adjustRemoteAddr to figure out the destination address (client unicast address or broadcast address).

The destination port is always DHCPv4 client (68) or relay (67) port, depending if the response will be sent directly to a client.

The source port is always set to DHCPv4 server port (67).

The interface selected for the response is always the same as the one through which the query has been received.

The source address for the response is the IPv4 address assigned to the interface being used to send the response. This function uses IfaceMgr to get the socket bound to the IPv4 address on the particular interface.

Note
This method is static because it is not dependent on the class state.
Parameters
exThe exchange holding both the client's message and the server's response.
Todo:
Consider an optimization that we use local address from the query if this address is not broadcast.

Definition at line 2267 of file dhcp4_srv.cc.

References isc::dhcp::SocketInfo::addr_, adjustRemoteAddr(), checkRelayPort(), isc::dhcp::DHCPINFORM, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::IfaceMgr::getSocket(), isc::dhcp::CfgMgr::instance(), isc::dhcp::IfaceMgr::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc::asiolink::IOAddress::isV4Bcast(), isc::dhcp::CfgIface::SOCKET_UDP, and isc::dhcp::CfgIface::USE_ROUTING.

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ adjustRemoteAddr()

void isc::dhcp::Dhcpv4Srv::adjustRemoteAddr ( Dhcpv4Exchange ex)
staticprotected

Sets remote addresses for outgoing packet.

This method sets the local and remote addresses on outgoing packet. The addresses being set depend on the following conditions:

  • has incoming packet been relayed,
  • is direct response to a client without address supported,
  • type of the outgoing packet,
  • broadcast flag set in the incoming packet.
Warning
This method does not check whether provided packet pointers are valid. Make sure that pointers are correct before calling this function.
Note
This method is static because it is not dependent on the class state.
Parameters
exThe exchange holding both the client's message and the server's response.

Definition at line 2348 of file dhcp4_srv.cc.

References isc::dhcp::DHCPINFORM, isc::dhcp::DHCPNAK, isc::dhcp::Pkt4::FLAG_BROADCAST_MASK, isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::IfaceMgr::instance(), isc::asiolink::IOAddress::IPV4_BCAST_ADDRESS(), and isc::dhcp::IfaceMgr::isDirectResponseSupported().

Referenced by adjustIfaceData().

+ Here is the call graph for this function:

◆ appendBasicOptions()

void isc::dhcp::Dhcpv4Srv::appendBasicOptions ( Dhcpv4Exchange ex)
protected

Append basic options if they are not present.

This function adds the following basic options if they are not yet added to the response message:

  • Subnet Mask,
  • Router,
  • Name Server,
  • Domain Name,
  • Server Identifier.
Parameters
exDHCPv4 exchange holding the client's message to be checked.

Definition at line 1540 of file dhcp4_srv.cc.

References DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::DHO_DOMAIN_NAME, isc::dhcp::DHO_DOMAIN_NAME_SERVERS, isc::dhcp::DHO_ROUTERS, isc::dhcp::Dhcpv4Exchange::getCfgOptionList(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getResponse(), and isc::dhcp::OptionDescriptor::option_.

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ appendRequestedOptions()

void isc::dhcp::Dhcpv4Srv::appendRequestedOptions ( Dhcpv4Exchange ex)
protected

Appends options requested by client.

This method assigns options that were requested by client (sent in PRL) or are enforced by server.

Parameters
exThe exchange holding both the client's message and the server's response.

Definition at line 1381 of file dhcp4_srv.cc.

References DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_PARAMETER_REQUEST_LIST, isc::dhcp::Dhcpv4Exchange::getCfgOptionList(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), and isc::dhcp::OptionDescriptor::option_.

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ appendRequestedVendorOptions()

void isc::dhcp::Dhcpv4Srv::appendRequestedVendorOptions ( Dhcpv4Exchange ex)
protected

Appends requested vendor options as requested by client.

This method is similar to appendRequestedOptions(), but uses vendor options. The major difference is that vendor-options use its own option spaces (there may be more than one distinct set of vendor options, each with unique vendor-id). Vendor options are requested using separate options within their respective vendor-option spaces.

Parameters
exThe exchange holding both the client's message and the server's response.
Todo:
This is very specific to vendor-id=4491 (Cable Labs). Other vendors may have different policies.

Definition at line 1452 of file dhcp4_srv.cc.

References isc::dhcp::DHO_VIVSO_SUBOPTIONS, DOCSIS3_V4_ORO, isc::dhcp::Dhcpv4Exchange::getCfgOptionList(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::OptionVendor::getVendorId(), isc::dhcp::OptionDescriptor::option_, and isc::dhcp::Option::V4.

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ appendServerID()

void isc::dhcp::Dhcpv4Srv::appendServerID ( Dhcpv4Exchange ex)
staticprotected

Adds server identifier option to the server's response.

This method adds a server identifier to the DHCPv4 message if it doesn't exist yet. This is set to the local address on which the client's query has been received with the exception of broadcast traffic and DHCPv4o6 query for which a socket on the particular interface is found and its address is used as server id.

Note
This method doesn't throw exceptions by itself but the underlying classes being used my throw. The reason for this method to not sanity check the specified message is that it is meant to be called internally by the Dhcpv4Srv class.
This method is static because it is not dependent on the class state.
Parameters
exThe exchange holding both the client's message and the server's response.

Definition at line 1283 of file dhcp4_srv.cc.

References isc::dhcp::SocketInfo::addr_, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::IfaceMgr::getSocket(), isc::dhcp::IfaceMgr::instance(), and isc::asiolink::IOAddress::isV4Bcast().

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ assignLease()

void isc::dhcp::Dhcpv4Srv::assignLease ( Dhcpv4Exchange ex)
protected

Assigns a lease and appends corresponding options.

This method chooses the most appropriate lease for requesting client and assigning it. Options corresponding to the lease are added to specific message.

This method may reset the pointer to the response in the ex object to indicate that the response should not be sent to the client. The caller must check if the response is is null after calling this method.

The response type in the ex object may be set to DHCPACK or DHCPNAK.

Parameters
exDHCPv4 exchange holding the client's message to be checked.
Todo:
It could be configurable what sort of updates the server is doing when Hostname option was sent.
Todo:
The server should check what ciaddr the client has supplied in ciaddr. Currently the ciaddr is ignored except for the subnet selection. If the client supplied an invalid address, the server will also return an invalid address here.

Definition at line 1864 of file dhcp4_srv.cc.

References alloc_engine_, isc::dhcp::bad_packet4_logger, createNameChangeRequests(), isc::dhcp::DBG_DHCP4_BASIC_DATA, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::ddns4_logger, isc::dhcp::Dhcpv4Exchange::deleteResponse(), isc::dhcp::dhcp4_logger, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPNAK, isc::dhcp::DHO_DHCP_LEASE_TIME, isc::dhcp::DHO_DHCP_REBINDING_TIME, isc::dhcp::DHO_DHCP_RENEWAL_TIME, isc::dhcp::DHO_DHCP_REQUESTED_ADDRESS, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::DHO_FQDN, isc::dhcp::DHO_HOST_NAME, isc::dhcp::Option4ClientFqdn::FULL, isc::dhcp::D2ClientMgr::generateFqdn(), isc::dhcp::getCalloutHandle(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::Option4ClientFqdn::getDomainName(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::D2ClientMgr::getUpdateDirections(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc::dhcp::lease4_logger, LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::dhcp::packet4_logger, isc::dhcp::D2ClientMgr::qualifyName(), isc::dhcp::LeaseMgr::updateLease4(), isc::dhcp::Option::V4, and isc::Exception::what().

Referenced by processDiscover(), and processRequest().

+ Here is the call graph for this function:

◆ buildCfgOptionList()

void isc::dhcp::Dhcpv4Srv::buildCfgOptionList ( Dhcpv4Exchange ex)
protected

◆ checkRelayPort()

uint16_t isc::dhcp::Dhcpv4Srv::checkRelayPort ( const Dhcpv4Exchange ex)
staticprotected

Check if the relay port RAI sub-option was set in the query.

Parameters
exThe exchange holding the client's message
Returns
the port to use to join the relay or 0 for the default

Definition at line 2254 of file dhcp4_srv.cc.

References isc::dhcp::DHO_DHCP_AGENT_OPTIONS, and isc::dhcp::Dhcpv4Exchange::getQuery().

Referenced by adjustIfaceData().

+ Here is the call graph for this function:

◆ classifyByVendor()

void isc::dhcp::Dhcpv4Srv::classifyByVendor ( const Pkt4Ptr pkt)

Assign class using vendor-class-identifier option.

Note
This is the first part of classifyPacket
Parameters
pktpacket to be classified

Definition at line 3243 of file dhcp4_srv.cc.

References isc::dhcp::DHO_VENDOR_CLASS_IDENTIFIER, and VENDOR_CLASS_PREFIX.

Referenced by classifyPacket().

◆ classifyPacket()

void isc::dhcp::Dhcpv4Srv::classifyPacket ( const Pkt4Ptr pkt)
protected

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 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 3255 of file dhcp4_srv.cc.

References classifyByVendor(), and evaluateClasses().

Referenced by processPacket().

+ Here is the call graph for this function:

◆ createNameChangeRequests()

void isc::dhcp::Dhcpv4Srv::createNameChangeRequests ( const Lease4Ptr lease,
const Lease4Ptr old_lease 
)
protected

Creates NameChangeRequests which correspond to the lease which has been acquired.

If this function is called when an existing lease is renewed, it may generate NameChangeRequest to remove existing DNS entries which correspond to the old lease instance. This function may cease to generate NameChangeRequests if the notion of the client's FQDN hasn't changed between an old and new lease.

Parameters
leaseA pointer to the new lease which has been acquired.
old_leaseA pointer to the instance of the old lease which has been replaced by the new lease passed in the first argument. The NULL value indicates that the new lease has been allocated, rather than lease being renewed.

Definition at line 1844 of file dhcp4_srv.cc.

References isc::dhcp_ddns::CHG_ADD, isc::dhcp_ddns::CHG_REMOVE, isc_throw, and isc::dhcp::queueNCR().

Referenced by assignLease().

+ Here is the call graph for this function:

◆ d2ClientErrorHandler()

void isc::dhcp::Dhcpv4Srv::d2ClientErrorHandler ( const dhcp_ddns::NameChangeSender::Result  result,
dhcp_ddns::NameChangeRequestPtr ncr 
)
virtual

Implements the error handler for DHCP_DDNS IO errors.

Invoked when a NameChangeRequest send to kea-dhcp-ddns completes with a failed status. These are communications errors, not data related failures.

This method logs the failure and then suspends all further updates. Updating can only be restored by reconfiguration or restarting the server. There is currently no retry logic so the first IO error that occurs will suspend updates.

Todo:
We may wish to make this more robust or sophisticated.
Parameters
resultResult code of the send operation.
ncrNameChangeRequest which failed to send.
Todo:
We may wish to revisit this, but for now we will simply turn them off.

Definition at line 3486 of file dhcp4_srv.cc.

References isc::dhcp::ddns4_logger, isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::CfgMgr::instance(), LOG_ERROR, and isc::dhcp::D2ClientMgr::suspendUpdates().

Referenced by startD2().

+ Here is the call graph for this function:

◆ declineLease()

void isc::dhcp::Dhcpv4Srv::declineLease ( const Lease4Ptr lease,
const Pkt4Ptr decline,
AllocEngine::ClientContext4Ptr context 
)

Marks lease as declined.

This method moves a lease to declined state with all the steps involved:

  • trigger DNS removal (if necessary)
  • disassociate the client information
  • update lease in the database (switch to DECLINED state)
  • increase necessary statistics
  • call lease4_decline hook
Parameters
leaselease to be declined
declineclient's message
contextreference to a client context

Definition at line 2858 of file dhcp4_srv.cc.

References isc::dhcp_ddns::CHG_REMOVE, isc::dhcp::DBG_DHCP4_HOOKS, isc::dhcp::getCalloutHandle(), Hooks, isc::hooks::hooks_logger, isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::dhcp::lease4_logger, LOG_DEBUG, LOG_INFO, isc::dhcp::queueNCR(), and isc::dhcp::LeaseMgr::updateLease4().

Referenced by processDecline().

+ Here is the call graph for this function:

◆ deferredUnpack()

void isc::dhcp::Dhcpv4Srv::deferredUnpack ( Pkt4Ptr query)
protected

Perform deferred option unpacking.

Note
Options 43 and 224-254 are processed after classification. If a class configures a definition it is applied, if none the global (user) definition is applied. For option 43 a last resort definition (same definition as used in previous Kea versions) is applied when none is found.
Parameters
queryPointer to the client message.

Definition at line 3406 of file dhcp4_srv.cc.

References isc::dhcp::ClientClasses::cbegin(), isc::dhcp::ClientClasses::cend(), DHCP4_OPTION_SPACE, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LibDHCP::getLastResortOptionDef(), isc::dhcp::LibDHCP::getOptionDef(), isc::dhcp::LibDHCP::getRuntimeOptionDef(), isc::dhcp::CfgMgr::instance(), and isc::dhcp::Option::V4.

Referenced by processPacket().

+ Here is the call graph for this function:

◆ discardPackets()

void isc::dhcp::Dhcpv4Srv::discardPackets ( )

Discard all in-progress packets.

Definition at line 3631 of file dhcp4_srv.cc.

References isc::dhcp::getCalloutHandle().

Referenced by isc::dhcp::configureDhcp4Server(), and ~Dhcpv4Srv().

+ Here is the call graph for this function:

◆ evaluateClasses()

void isc::dhcp::Dhcpv4Srv::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 3266 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::evaluateBool(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::dhcp::options4_logger, and isc::Exception::what().

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

+ Here is the call graph for this function:

◆ getHookIndexBuffer4Receive()

int isc::dhcp::Dhcpv4Srv::getHookIndexBuffer4Receive ( )
static

Returns the index for "buffer4_receive" hook point.

Returns
the index for "buffer4_receive" hook point

Definition at line 3603 of file dhcp4_srv.cc.

References Hooks.

◆ getHookIndexBuffer4Send()

int isc::dhcp::Dhcpv4Srv::getHookIndexBuffer4Send ( )
static

Returns the index for "buffer4_send" hook point.

Returns
the index for "buffer4_send" hook point

Definition at line 3623 of file dhcp4_srv.cc.

References Hooks.

Referenced by isc::dhcp::Dhcp4to6Ipc::handler().

◆ getHookIndexLease4Decline()

int isc::dhcp::Dhcpv4Srv::getHookIndexLease4Decline ( )
static

Returns the index for "lease4_decline" hook point.

Returns
the index for "lease4_decline" hook point

Definition at line 3627 of file dhcp4_srv.cc.

References Hooks.

◆ getHookIndexLease4Release()

int isc::dhcp::Dhcpv4Srv::getHookIndexLease4Release ( )
static

Returns the index for "lease4_release" hook point.

Returns
the index for "lease4_release" hook point

Definition at line 3615 of file dhcp4_srv.cc.

References Hooks.

◆ getHookIndexPkt4Receive()

int isc::dhcp::Dhcpv4Srv::getHookIndexPkt4Receive ( )
static

Returns the index for "pkt4_receive" hook point.

Returns
the index for "pkt4_receive" hook point

Definition at line 3607 of file dhcp4_srv.cc.

References Hooks.

◆ getHookIndexPkt4Send()

int isc::dhcp::Dhcpv4Srv::getHookIndexPkt4Send ( )
static

Returns the index for "pkt4_send" hook point.

Returns
the index for "pkt4_send" hook point

Definition at line 3619 of file dhcp4_srv.cc.

References Hooks.

◆ getHookIndexSubnet4Select()

int isc::dhcp::Dhcpv4Srv::getHookIndexSubnet4Select ( )
static

Returns the index for "subnet4_select" hook point.

Returns
the index for "subnet4_select" hook point

Definition at line 3611 of file dhcp4_srv.cc.

References Hooks.

◆ getIOService()

asiolink::IOServicePtr& isc::dhcp::Dhcpv4Srv::getIOService ( )
inline

Returns pointer to the IO service used by the server.

Definition at line 234 of file dhcp4_srv.h.

Referenced by isc::dhcp::ControlledDhcpv4Srv::ControlledDhcpv4Srv(), isc::dhcp::ControlledDhcpv4Srv::processConfig(), and run().

◆ getNetworkState()

NetworkStatePtr& isc::dhcp::Dhcpv4Srv::getNetworkState ( )
inline

Returns pointer to the network state used by the server.

Definition at line 239 of file dhcp4_srv.h.

References network_state_.

Referenced by isc::dhcp::ControlledDhcpv4Srv::processConfig().

◆ getPort()

uint16_t isc::dhcp::Dhcpv4Srv::getPort ( ) const
inline

Get UDP port on which server should listen.

Typically, server listens on UDP port number 67. Other ports are used for testing purposes only.

Returns
UDP port on which server should listen.

Definition at line 288 of file dhcp4_srv.h.

Referenced by isc::dhcp::ControlledDhcpv4Srv::processConfig().

◆ getVersion()

std::string isc::dhcp::Dhcpv4Srv::getVersion ( bool  extended)
static

returns Kea version on stdout and exit.

redeclaration/redefinition. isc::process::Daemon::getVersion()

Definition at line 3501 of file dhcp4_srv.cc.

References isc::dhcp::PgSqlLeaseMgr::getDBVersion(), isc::dhcp::MySqlLeaseMgr::getDBVersion(), isc::dhcp::CqlLeaseMgr::getDBVersion(), and isc::dhcp::Memfile_LeaseMgr::getDBVersion().

+ Here is the call graph for this function:

◆ processClientName()

void isc::dhcp::Dhcpv4Srv::processClientName ( Dhcpv4Exchange ex)
protected

Processes Client FQDN and Hostname Options sent by a client.

Client may send Client FQDN or Hostname option to communicate its name to the server. Server may use this name to perform DNS update for the lease being assigned to a client. If server takes responsibility for updating DNS for a client it may communicate it by sending the Client FQDN or Hostname Option back to the client. Server select a different name than requested by a client to update DNS. In such case, the server stores this different name in its response.

Client should not send both Client FQDN and Hostname options. However, if client sends both options, server should prefer Client FQDN option and ignore the Hostname option. If Client FQDN option is not present, the Hostname option is processed.

The Client FQDN Option is processed by this function as described in RFC4702.

In response to a Hostname Option sent by a client, the server may send Hostname option with the same or different hostname. If different hostname is sent, it is an indication to the client that server has overridden the client's preferred name and will rather use this different name to update DNS. However, since Hostname option doesn't carry an information whether DNS update will be carried by the server or not, the client is responsible for checking whether DNS update has been performed.

After successful processing options stored in the first parameter, this function may add Client FQDN or Hostname option to the response message. In some cases, server may cease to add any options to the response, i.e. when server doesn't support DNS updates.

This function does not throw. It simply logs the debug message if the processing of the FQDN or Hostname failed.

Parameters
exThe exchange holding both the client's message and the server's response.

Definition at line 1586 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::ddns4_logger, isc::dhcp::DHO_FQDN, isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), LOG_DEBUG, and isc::Exception::what().

Referenced by processDiscover(), and processRequest().

+ Here is the call graph for this function:

◆ processDecline()

void isc::dhcp::Dhcpv4Srv::processDecline ( Pkt4Ptr decline,
AllocEngine::ClientContext4Ptr context 
)
protected

Process incoming DHCPDECLINE messages.

This method processes incoming DHCPDECLINE. In particular, it extracts Requested IP Address option, checks that the address really belongs to the client and if it does, calls declineLease.

Parameters
declinemessage received from client
[out]contextpointer to the client context where declined lease is stored.
Todo:
Uncomment this (see ticket #3116)

Definition at line 2784 of file dhcp4_srv.cc.

References declineLease(), isc::dhcp::dhcp4_logger, isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::dhcp::DHO_DHCP_REQUESTED_ADDRESS, isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, and LOG_WARN.

Referenced by processPacket().

+ Here is the call graph for this function:

◆ processDiscover()

Pkt4Ptr isc::dhcp::Dhcpv4Srv::processDiscover ( Pkt4Ptr discover)
protected

Processes incoming DISCOVER and returns response.

Processes received DISCOVER message and verifies that its sender should be served. In particular, a lease is selected and sent as an offer to a client if it should be served.

Parameters
discoverDISCOVER message received from client
Returns
OFFER message or NULL

Definition at line 2548 of file dhcp4_srv.cc.

References adjustIfaceData(), alloc_engine_, appendBasicOptions(), appendRequestedOptions(), appendRequestedVendorOptions(), appendServerID(), assignLease(), buildCfgOptionList(), FORBIDDEN, isc::dhcp::Dhcpv4Exchange::getResponse(), processClientName(), requiredClassify(), sanityCheck(), selectSubnet(), setFixedFields(), and isc::dhcp::Dhcpv4Exchange::setReservedClientClasses().

Referenced by processPacket().

+ Here is the call graph for this function:

◆ processInform()

Pkt4Ptr isc::dhcp::Dhcpv4Srv::processInform ( Pkt4Ptr inform)
protected

◆ processPacket()

void isc::dhcp::Dhcpv4Srv::processPacket ( Pkt4Ptr query,
Pkt4Ptr rsp,
bool  allow_packet_park = true 
)

◆ processPacketBufferSend()

void isc::dhcp::Dhcpv4Srv::processPacketBufferSend ( hooks::CalloutHandlePtr callout_handle,
Pkt4Ptr rsp 
)
protected

Executes buffer4_send callout and sends the response.

Parameters
callout_handlepointer to the callout handle.
rsppointer to a response.

Definition at line 1190 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::DBG_DHCP4_HOOKS, Hooks, isc::hooks::hooks_logger, LOG_DEBUG, LOG_ERROR, isc::dhcp::packet4_logger, processStatsSent(), and sendPacket().

Referenced by processPacket(), and run_one().

+ Here is the call graph for this function:

◆ processPacketPktSend()

void isc::dhcp::Dhcpv4Srv::processPacketPktSend ( hooks::CalloutHandlePtr callout_handle,
Pkt4Ptr query,
Pkt4Ptr rsp 
)
protected

Executes pkt4_send callout.

Parameters
callout_handlepointer to the callout handle.
queryPointer to a query.
rspPointer to a response.

Definition at line 1132 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_HOOKS, Hooks, isc::hooks::hooks_logger, LOG_DEBUG, LOG_ERROR, and isc::dhcp::options4_logger.

Referenced by processPacket().

◆ processRelease()

void isc::dhcp::Dhcpv4Srv::processRelease ( Pkt4Ptr release,
AllocEngine::ClientContext4Ptr context 
)
protected

Processes incoming DHCPRELEASE messages.

In DHCPv4, server does not respond to RELEASE messages, therefore this function does not return anything.

Parameters
releasemessage received from client
[out]contextpointer to the client context where released lease is stored.
Todo:
Uncomment this (see ticket #3116) sanityCheck(release, MANDATORY);

Definition at line 2669 of file dhcp4_srv.cc.

References isc::dhcp_ddns::CHG_REMOVE, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_HOOKS, isc::dhcp::LeaseMgr::deleteLease(), isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::dhcp::getCalloutHandle(), isc::dhcp::LeaseMgr::getLease4(), Hooks, isc::hooks::hooks_logger, isc::dhcp::LeaseMgrFactory::instance(), isc::dhcp::lease4_logger, LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::dhcp::queueNCR(), and isc::Exception::what().

Referenced by processPacket().

+ Here is the call graph for this function:

◆ processRequest()

Pkt4Ptr isc::dhcp::Dhcpv4Srv::processRequest ( Pkt4Ptr request,
AllocEngine::ClientContext4Ptr context 
)
protected

Processes incoming REQUEST and returns REPLY response.

Processes incoming REQUEST message and verifies that its sender should be served. In particular, verifies that requested lease is valid, not expired, not reserved, not used by other client and that requesting client is allowed to use it.

Returns ACK message, NAK message, or NULL

Parameters
requesta message received from client
[out]contextpointer to the client context where allocated and deleted leases are stored.
Returns
ACK or NAK message
Todo:
Uncomment this (see ticket #3116) sanityCheck(request, MANDATORY);

Definition at line 2607 of file dhcp4_srv.cc.

References adjustIfaceData(), alloc_engine_, appendBasicOptions(), appendRequestedOptions(), appendRequestedVendorOptions(), appendServerID(), assignLease(), buildCfgOptionList(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getResponse(), processClientName(), requiredClassify(), selectSubnet(), setFixedFields(), and isc::dhcp::Dhcpv4Exchange::setReservedClientClasses().

Referenced by processPacket().

+ Here is the call graph for this function:

◆ processStatsReceived()

void isc::dhcp::Dhcpv4Srv::processStatsReceived ( const Pkt4Ptr query)
static

Class methods for DHCPv4-over-DHCPv6 handler.

Updates statistics for received packets

Parameters
querypacket received

Definition at line 3528 of file dhcp4_srv.cc.

References isc::stats::StatsMgr::addValue(), isc::dhcp::DHCPACK, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPNAK, isc::dhcp::DHCPOFFER, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, and isc::stats::StatsMgr::instance().

Referenced by processPacket().

+ Here is the call graph for this function:

◆ processStatsSent()

void isc::dhcp::Dhcpv4Srv::processStatsSent ( const Pkt4Ptr response)
static

Updates statistics for transmitted packets.

Parameters
responsepacket transmitted

Definition at line 3577 of file dhcp4_srv.cc.

References isc::stats::StatsMgr::addValue(), isc::dhcp::DHCPACK, isc::dhcp::DHCPNAK, isc::dhcp::DHCPOFFER, and isc::stats::StatsMgr::instance().

Referenced by isc::dhcp::Dhcp4to6Ipc::handler(), and processPacketBufferSend().

+ Here is the call graph for this function:

◆ receivePacket()

Pkt4Ptr isc::dhcp::Dhcpv4Srv::receivePacket ( int  timeout)
protectedvirtual

dummy wrapper around IfaceMgr::receive4

This method is useful for testing purposes, where its replacement simulates reception of a packet. For that purpose it is protected.

Definition at line 721 of file dhcp4_srv.cc.

References isc::dhcp::IfaceMgr::instance().

Referenced by run_one().

+ Here is the call graph for this function:

◆ renewLease()

void isc::dhcp::Dhcpv4Srv::renewLease ( const Pkt4Ptr renew,
Pkt4Ptr reply 
)
protected

Attempts to renew received addresses.

Attempts to renew existing lease. This typically includes finding a lease that corresponds to the received address. If no such lease is found, a status code response is generated.

Parameters
renewclient's message asking for renew
replyserver's response (ACK or NAK)

◆ requiredClassify()

void isc::dhcp::Dhcpv4Srv::requiredClassify ( Dhcpv4Exchange ex)
protected

Assigns incoming packet to zero or more classes (required pass).

Note
This required classification evaluates all classes which were marked for required evaluation. Classes are collected so evaluated in the reversed order than output option processing.
The only-if-required flag is related because it avoids double evaluation (which is not forbidden).
Parameters
exThe exchange holding needed informations.

Definition at line 3314 of file dhcp4_srv.cc.

References isc::dhcp::ClientClasses::cbegin(), isc::dhcp::ClientClasses::cend(), isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::dhcp4_logger, isc::dhcp::evaluateBool(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::ClientClasses::insert(), isc::dhcp::CfgMgr::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc::asiolink::IOAddress::isV4Zero(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::dhcp::options4_logger, isc::dhcp::Lease::TYPE_V4, and isc::Exception::what().

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ run()

bool isc::dhcp::Dhcpv4Srv::run ( )

Main server processing loop.

Main server processing loop. Call the processing step routine until shut down.

Returns
true, if being shut down gracefully, never fail.

Definition at line 731 of file dhcp4_srv.cc.

References getIOService(), LOG_ERROR, isc::dhcp::packet4_logger, run_one(), and shutdown_.

+ Here is the call graph for this function:

◆ run_one()

void isc::dhcp::Dhcpv4Srv::run_one ( )

Main server processing step.

Main server processing step. Receives one incoming packet, calls the processing packet routing and (if necessary) transmits a response.

Definition at line 753 of file dhcp4_srv.cc.

References isc::dhcp::bad_packet4_logger, isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::dhcp4_logger, isc::dhcp::getCalloutHandle(), isc::process::Daemon::handleSignal(), LOG_DEBUG, LOG_ERROR, network_state_, isc::dhcp::packet4_logger, processPacket(), processPacketBufferSend(), receivePacket(), and isc::process::Daemon::signal_set_.

Referenced by run().

+ Here is the call graph for this function:

◆ sanityCheck()

void isc::dhcp::Dhcpv4Srv::sanityCheck ( const Pkt4Ptr query,
RequirementLevel  serverid 
)
staticprotected

Verifies if specified packet meets RFC requirements.

Checks if mandatory option is really there, that forbidden option is not there, and that client-id or server-id appears only once.

Parameters
queryPointer to the client's message.
serveridexpectation regarding server-id option
Exceptions
RFCViolationif any issues are detected

Definition at line 3202 of file dhcp4_srv.cc.

References isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, FORBIDDEN, isc_throw, MANDATORY, and OPTIONAL.

Referenced by processDiscover(), and processInform().

◆ selectSubnet()

isc::dhcp::Subnet4Ptr isc::dhcp::Dhcpv4Srv::selectSubnet ( const Pkt4Ptr query,
bool &  drop,
bool  sanity_only = false 
) const
protected

Selects a subnet for a given client's packet.

If selectSubnet is called to simply do sanity checks (check if a subnet would be selected), then there is no need to call hooks, as this will happen later (when selectSubnet is called again). In such case the sanity_only should be set to true.

Parameters
queryclient's message
dropif it is true the packet will be dropped
sanity_onlyif it is true the callout won't be called
Returns
selected subnet (or NULL if no suitable subnet was found)

Definition at line 517 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_BASIC_DATA, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::DBG_DHCP4_HOOKS, isc::dhcp::getCalloutHandle(), isc::dhcp::CfgMgr::getCurrentCfg(), Hooks, isc::hooks::hooks_logger, isc::dhcp::CfgSubnets4::initSelector(), isc::dhcp::CfgMgr::instance(), LOG_DEBUG, isc::dhcp::packet4_logger, and selectSubnet4o6().

Referenced by acceptDirectRequest(), processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ selectSubnet4o6()

isc::dhcp::Subnet4Ptr isc::dhcp::Dhcpv4Srv::selectSubnet4o6 ( const Pkt4Ptr query,
bool &  drop,
bool  sanity_only = false 
) const
protected

Selects a subnet for a given client's DHCP4o6 packet.

If selectSubnet is called to simply do sanity checks (check if a subnet would be selected), then there is no need to call hooks, as this will happen later (when selectSubnet is called again). In such case the sanity_only should be set to true.

Parameters
queryclient's message
dropif it is true the packet will be dropped
sanity_onlyif it is true the callout won't be called
Returns
selected subnet (or NULL if no suitable subnet was found)

Definition at line 603 of file dhcp4_srv.cc.

References isc::dhcp::SubnetSelector::ciaddr_, isc::dhcp::SubnetSelector::client_classes_, D6O_INTERFACE_ID, isc::dhcp::DBG_DHCP4_BASIC_DATA, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::DBG_DHCP4_HOOKS, isc::dhcp::SubnetSelector::dhcp4o6_, isc::dhcp::DHO_SUBNET_SELECTION, isc::dhcp::SubnetSelector::first_relay_linkaddr_, isc::dhcp::getCalloutHandle(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::SubnetSelector::giaddr_, Hooks, isc::hooks::hooks_logger, isc::dhcp::SubnetSelector::iface_name_, isc::dhcp::CfgMgr::instance(), isc::dhcp::SubnetSelector::interface_id_, isc_throw, isc::asiolink::IOAddress::isV6LinkLocal(), isc::asiolink::IOAddress::isV6Zero(), isc::dhcp::Pkt6::RelayInfo::linkaddr_, isc::dhcp::SubnetSelector::local_address_, LOG_DEBUG, isc::dhcp::SubnetSelector::option_select_, isc::dhcp::packet4_logger, isc::dhcp::Pkt6::RELAY_GET_FIRST, and isc::dhcp::SubnetSelector::remote_address_.

Referenced by selectSubnet().

+ Here is the call graph for this function:

◆ sendPacket()

void isc::dhcp::Dhcpv4Srv::sendPacket ( const Pkt4Ptr pkt)
protectedvirtual

dummy wrapper around IfaceMgr::send()

This method is useful for testing purposes, where its replacement simulates transmission of a packet. For that purpose it is protected.

Definition at line 726 of file dhcp4_srv.cc.

References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::send().

Referenced by processPacketBufferSend().

+ Here is the call graph for this function:

◆ setFixedFields()

void isc::dhcp::Dhcpv4Srv::setFixedFields ( Dhcpv4Exchange ex)
protected

Sets fixed fields of the outgoing packet.

If the incoming packets belongs to a class and that class defines next-server, server-hostname or boot-file-name, we need to set the siaddr, sname or filename fields in the outgoing packet. Also, those values can be defined for subnet or in reservations. The values defined in reservation takes precedence over class values, which in turn take precedence over subnet values.

Parameters
exDHCPv4 exchange holding the client's message and the server's response to be adjusted.

Definition at line 2445 of file dhcp4_srv.cc.

References isc::dhcp::ClientClasses::cbegin(), isc::dhcp::ClientClasses::cend(), isc::dhcp::ClientClasses::empty(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::CfgMgr::instance(), isc::asiolink::IOAddress::isV4Zero(), and isc::dhcp::Dhcpv4Exchange::setReservedMessageFields().

Referenced by processDiscover(), processInform(), and processRequest().

+ Here is the call graph for this function:

◆ shutdown()

void isc::dhcp::Dhcpv4Srv::shutdown ( )
virtual

Instructs the server to shut down.

Reimplemented from isc::process::Daemon.

Definition at line 511 of file dhcp4_srv.cc.

References isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::dhcp4_logger, LOG_DEBUG, and shutdown_.

Referenced by isc::dhcp::ControlledDhcpv4Srv::shutdown().

◆ srvidToString()

string isc::dhcp::Dhcpv4Srv::srvidToString ( const OptionPtr opt)
staticprotected

converts server-id to text Converts content of server-id option to a text representation, e.g.

"192.0.2.1"

Parameters
optoption that contains server-id
Returns
string representation

Definition at line 1263 of file dhcp4_srv.cc.

References isc_throw.

◆ startD2()

void isc::dhcp::Dhcpv4Srv::startD2 ( )

Starts DHCP_DDNS client IO if DDNS updates are enabled.

If updates are enabled, it instructs the D2ClientMgr singleton to enter send mode. If D2ClientMgr encounters errors it may throw D2ClientError. This method does not catch exceptions.

Definition at line 3465 of file dhcp4_srv.cc.

References d2ClientErrorHandler(), isc::dhcp::D2ClientMgr::ddnsEnabled(), isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::CfgMgr::instance(), and isc::dhcp::D2ClientMgr::startSender().

Referenced by isc::dhcp::ControlledDhcpv4Srv::processConfig().

+ Here is the call graph for this function:

◆ stopD2()

void isc::dhcp::Dhcpv4Srv::stopD2 ( )

Stops DHCP_DDNS client IO if DDNS updates are enabled.

If updates are enabled, it instructs the D2ClientMgr singleton to leave send mode. If D2ClientMgr encounters errors it may throw D2ClientError. This method does not catch exceptions.

Definition at line 3477 of file dhcp4_srv.cc.

References isc::dhcp::D2ClientMgr::ddnsEnabled(), isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::CfgMgr::instance(), and isc::dhcp::D2ClientMgr::stopSender().

Referenced by ~Dhcpv4Srv().

+ Here is the call graph for this function:

◆ useBroadcast()

bool isc::dhcp::Dhcpv4Srv::useBroadcast ( ) const
inline

Return bool value indicating that broadcast flags should be set on sockets.

Returns
A bool value indicating that broadcast should be used (if true).

Definition at line 296 of file dhcp4_srv.h.

Member Data Documentation

◆ alloc_engine_

boost::shared_ptr<AllocEngine> isc::dhcp::Dhcpv4Srv::alloc_engine_
protected

Allocation Engine.

Pointer to the allocation engine that we are currently using It must be a pointer, because we will support changing engines during normal operation (e.g. to use different allocators)

Definition at line 911 of file dhcp4_srv.h.

Referenced by assignLease(), Dhcpv4Srv(), processDiscover(), processInform(), and processRequest().

◆ network_state_

NetworkStatePtr isc::dhcp::Dhcpv4Srv::network_state_
protected

Holds information about disabled DHCP service and/or disabled subnet/network scopes.

Definition at line 937 of file dhcp4_srv.h.

Referenced by getNetworkState(), and run_one().

◆ shutdown_

volatile bool isc::dhcp::Dhcpv4Srv::shutdown_
protected

indicates if shutdown is in progress.

Setting it to true will initiate server shutdown procedure.

Definition at line 827 of file dhcp4_srv.h.

Referenced by Dhcpv4Srv(), run(), and shutdown().

◆ VENDOR_CLASS_PREFIX

const std::string isc::dhcp::Dhcpv4Srv::VENDOR_CLASS_PREFIX
staticprotected

this is a prefix added to the content of vendor-class option

If incoming packet has a vendor class option, its content is prepended with this prefix and then interpreted as a class. For example, a packet that sends vendor class with value of "FOO" will cause the packet to be assigned to class VENDOR_CLASS_FOO.

Definition at line 613 of file dhcp4_srv.h.

Referenced by classifyByVendor().


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