Kea 2.7.6
|
DHCPv4 server service. More...
#include <dhcp4_srv.h>
Public Types | |
enum | RequirementLevel { FORBIDDEN , MANDATORY , OPTIONAL } |
defines if certain option may, must or must not appear More... | |
Public Member Functions | |
Dhcpv4Srv (uint16_t server_port=DHCP4_SERVER_PORT, uint16_t client_port=0, const bool use_bcast=true, const bool direct_response_desired=true) | |
Default constructor. | |
virtual | ~Dhcpv4Srv () |
Destructor. Used during DHCPv4 service shutdown. | |
CBControlDHCPv4Ptr | getCBControl () const |
Returns an object which controls access to the configuration backends. | |
asiolink::IOServicePtr & | getIOService () |
Returns pointer to the IO service used by the server. | |
NetworkStatePtr & | getNetworkState () |
Returns pointer to the network state used by the server. | |
bool | inTestMode () const |
Checks if the server is running in unit test mode. | |
Pkt4Ptr | processDhcp4Query (Pkt4Ptr query, bool allow_answer_park) |
Process a single incoming DHCPv4 query. | |
void | processDhcp4QueryAndSendResponse (Pkt4Ptr query, bool allow_answer_park) |
Process a single incoming DHCPv4 query. | |
Pkt4Ptr | processLocalizedQuery4 (AllocEngine::ClientContext4Ptr &ctx, bool allow_answer_park) |
Process a localized incoming DHCPv4 query. | |
void | processLocalizedQuery4AndSendResponse (Pkt4Ptr query, AllocEngine::ClientContext4Ptr &ctx, bool allow_answer_park) |
Process a localized incoming DHCPv4 query. | |
void | processLocalizedQuery4AndSendResponse (Pkt4Ptr query, bool allow_answer_park) |
Process a localized incoming DHCPv4 query. | |
Pkt4Ptr | processPacket (Pkt4Ptr query, bool allow_answer_park=true) |
Process a single incoming DHCPv4 packet. | |
void | processPacketAndSendResponse (Pkt4Ptr query) |
Process a single incoming DHCPv4 packet and sends the response. | |
void | processPacketAndSendResponseNoThrow (Pkt4Ptr query) |
Process a single incoming DHCPv4 packet and sends the response. | |
int | run () |
Main server processing loop. | |
void | runOne () |
Main server processing step. | |
void | sendResponseNoThrow (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp, ConstSubnet4Ptr &subnet) |
Process an unparked DHCPv4 packet and sends the response. | |
void | shutdown () override |
Instructs the server to shut down. | |
Public accessors returning values required to (re)open sockets. | |
uint16_t | getServerPort () const |
Get UDP port on which server should listen. | |
bool | useBroadcast () const |
Return bool value indicating that broadcast flags should be set on sockets. | |
void | startD2 () |
Starts DHCP_DDNS client IO if DDNS updates are enabled. | |
void | stopD2 () |
Stops DHCP_DDNS client IO if DDNS updates are enabled. | |
virtual void | d2ClientErrorHandler (const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr) |
Implements the error handler for DHCP_DDNS IO errors. | |
void | discardPackets () |
Discards parked packets Clears the packet parking lots of all packets. | |
bool | getSendResponsesToSource () const |
Returns value of the test_send_responses_to_source_ flag. | |
void | initContext0 (const Pkt4Ptr &query, AllocEngine::ClientContext4Ptr ctx) |
Initialize client context (first part). | |
bool | earlyGHRLookup (const Pkt4Ptr &query, AllocEngine::ClientContext4Ptr ctx) |
Initialize client context and perform early global reservations lookup. | |
Public Member Functions inherited from isc::process::Daemon | |
Daemon () | |
Default constructor. | |
virtual | ~Daemon () |
Destructor. | |
void | checkConfigFile () const |
Checks the configuration file name. | |
virtual void | cleanup () |
Performs final deconfiguration. | |
void | createPIDFile (int pid=0) |
Creates the PID file. | |
std::string | getConfigFile () const |
Returns config file name. | |
int | getExitValue () |
Fetches the exit value. | |
std::string | getPIDFileDir () const |
Returns the directory used when forming default PID file name. | |
std::string | getPIDFileName () const |
Returns the current PID file name. | |
isc::data::ConstElementPtr | redactConfig (isc::data::ConstElementPtr const &config) |
Redact a configuration. | |
void | setConfigFile (const std::string &config_file) |
Sets the configuration file name. | |
void | setExitValue (int value) |
Sets the exit value. | |
void | setPIDFileDir (const std::string &pid_file_dir) |
Sets the PID file directory. | |
void | setPIDFileName (const std::string &pid_file_name) |
Sets PID file name. | |
virtual size_t | writeConfigFile (const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const |
Writes current configuration to specified file. | |
Static Public Member Functions | |
static std::string | getVersion (bool extended) |
returns Kea version on stdout and exit. | |
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. | |
static std::string | getDefaultLoggerName () |
Returns default logger name. | |
static std::string | getProcName () |
returns the process name This value is used as when forming the default PID file name | |
static bool | getVerbose () |
Returns if running in verbose mode. | |
static std::string | getVersion (bool extended) |
returns Kea version on stdout and exits. | |
static void | loggerInit (const char *log_name, bool verbose) |
Initializes logger. | |
static void | setDefaultLoggerName (const std::string &logger) |
Sets the default logger name. | |
static void | setProcName (const std::string &proc_name) |
Sets the process name. | |
static void | setVerbose (const bool verbose) |
Sets or clears verbose mode. | |
Functions filtering and sanity-checking received messages. | |
| |
static const std::string | VENDOR_CLASS_PREFIX |
this is a prefix added to the content of vendor-class option | |
uint16_t | server_port_ |
UDP port number on which server listens. | |
uint16_t | client_port_ |
UDP port number to which server sends all responses. | |
volatile bool | shutdown_ |
Indicates if shutdown is in progress. | |
boost::shared_ptr< AllocEngine > | alloc_engine_ |
Allocation Engine. | |
bool | use_bcast_ |
Should broadcast be enabled on sockets (if true). | |
NetworkStatePtr | network_state_ |
Holds information about disabled DHCP service and/or disabled subnet/network scopes. | |
CBControlDHCPv4Ptr | cb_control_ |
Controls access to the configuration backends. | |
void | declineLease (const Lease4Ptr &lease, const Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context) |
Marks lease as declined. | |
std::list< std::list< std::string > > | jsonPathsToRedact () const final override |
Return a list of all paths that contain passwords or secrets for kea-dhcp4. | |
static void | processStatsReceived (const Pkt4Ptr &query) |
Class methods for DHCPv4-over-DHCPv6 handler. | |
static void | processStatsSent (const Pkt4Ptr &response) |
Updates statistics for transmitted packets. | |
static int | getHookIndexBuffer4Receive () |
Returns the index for "buffer4_receive" hook point. | |
static int | getHookIndexPkt4Receive () |
Returns the index for "pkt4_receive" hook point. | |
static int | getHookIndexSubnet4Select () |
Returns the index for "subnet4_select" hook point. | |
static int | getHookIndexLease4Release () |
Returns the index for "lease4_release" hook point. | |
static int | getHookIndexPkt4Send () |
Returns the index for "pkt4_send" hook point. | |
static int | getHookIndexBuffer4Send () |
Returns the index for "buffer4_send" hook point. | |
static int | getHookIndexLease4Decline () |
Returns the index for "lease4_decline" hook point. | |
bool | accept (const Pkt4Ptr &query) |
Checks whether received message should be processed or discarded. | |
bool | acceptDirectRequest (const Pkt4Ptr &query) |
Check if a message sent by directly connected client should be accepted or discarded. | |
bool | acceptMessageType (const Pkt4Ptr &query) const |
Check if received message type is valid for the server to process. | |
bool | acceptServerId (const Pkt4Ptr &pkt) const |
Verifies if the server id belongs to our server. | |
Pkt4Ptr | processDiscover (Pkt4Ptr &discover, AllocEngine::ClientContext4Ptr &context) |
Processes incoming DISCOVER and returns response. | |
Pkt4Ptr | processRequest (Pkt4Ptr &request, AllocEngine::ClientContext4Ptr &context) |
Processes incoming REQUEST and returns REPLY response. | |
void | processRelease (Pkt4Ptr &release, AllocEngine::ClientContext4Ptr &context) |
Processes incoming DHCPRELEASE messages. | |
void | processDecline (Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context) |
Process incoming DHCPDECLINE messages. | |
Pkt4Ptr | processInform (Pkt4Ptr &inform, AllocEngine::ClientContext4Ptr &context) |
Processes incoming DHCPINFORM messages. | |
void | buildCfgOptionList (Dhcpv4Exchange &ex) |
Build the configured option list. | |
void | appendRequestedOptions (Dhcpv4Exchange &ex) |
Appends options requested by client. | |
void | appendRequestedVendorOptions (Dhcpv4Exchange &ex) |
Appends requested vendor options as requested by client. | |
bool | assignZero (ConstSubnet4Ptr &subnet, const ClientClasses &client_classes) |
Assign the 0.0.0.0 address to an IPv6-Only client. | |
void | assignLease (Dhcpv4Exchange &ex) |
Assigns a lease and appends corresponding options. | |
void | postAllocateNameUpdate (const AllocEngine::ClientContext4Ptr &ctx, const Lease4Ptr &lease, const Pkt4Ptr &query, const Pkt4Ptr &resp, bool client_name_changed) |
Update client name and DNS flags in the lease and response. | |
void | setTeeTimes (const Lease4Ptr &lease, const ConstSubnet4Ptr &subnet, Pkt4Ptr resp) |
Adds the T1 and T2 timers to the outbound response as appropriate. | |
void | appendBasicOptions (Dhcpv4Exchange &ex) |
Append basic options if they are not present. | |
void | setFixedFields (Dhcpv4Exchange &ex) |
Sets fixed fields of the outgoing packet. | |
void | processClientName (Dhcpv4Exchange &ex) |
Processes Client FQDN and Hostname Options sent by a client. | |
void | setPacketStatisticsDefaults () |
This function sets statistics related to DHCPv4 packets processing to their initial values. | |
void | setSendResponsesToSource (bool value) |
Sets value of the test_send_responses_to_source_ flag. | |
void | serverDecline (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Lease4Ptr lease, bool lease_exists) |
Renders a lease declined after the server has detected, via ping-check or other means, that its address is already in-use. | |
void | serverDeclineNoThrow (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Lease4Ptr lease, bool lease_exists) |
Exception safe wrapper around serverDecline() | |
void | createNameChangeRequests (const Lease4Ptr &lease, const Lease4Ptr &old_lease, const DdnsParams &ddns_params) |
Creates NameChangeRequests which correspond to the lease which has been acquired. | |
void | renewLease (const Pkt4Ptr &renew, Pkt4Ptr &reply) |
Attempts to renew received addresses. | |
void | adjustIfaceData (Dhcpv4Exchange &ex) |
Set IP/UDP and interface parameters for the DHCPv4 response. | |
void | adjustRemoteAddr (Dhcpv4Exchange &ex) |
Sets remote addresses for outgoing packet. | |
isc::dhcp::ConstSubnet4Ptr | selectSubnet (const Pkt4Ptr &query, bool &drop, bool sanity_only=false, bool allow_answer_park=true) |
Selects a subnet for a given client's packet. | |
isc::dhcp::ConstSubnet4Ptr | selectSubnet4o6 (const Pkt4Ptr &query, bool &drop, bool sanity_only=false, bool allow_answer_park=true) |
Selects a subnet for a given client's DHCP4o6 packet. | |
virtual Pkt4Ptr | receivePacket (int timeout) |
dummy wrapper around IfaceMgr::receive4 | |
virtual void | sendPacket (const Pkt4Ptr &pkt) |
dummy wrapper around IfaceMgr::send() | |
void | classifyPacket (const Pkt4Ptr &pkt) |
Assigns incoming packet to zero or more classes. | |
void | recoverStashedAgentOption (const Pkt4Ptr &query) |
Recover stashed agent options from client address lease. | |
void | evaluateAdditionalClasses (Dhcpv4Exchange &ex) |
Evaluates classes in the additional classes lists. | |
void | deferredUnpack (Pkt4Ptr &query) |
Perform deferred option unpacking. | |
void | processPacketPktSend (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp, ConstSubnet4Ptr &subnet) |
Executes pkt4_send callout. | |
void | processPacketBufferSend (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &rsp) |
Executes buffer4_send callout and sends the response. | |
static void | sanityCheck (const Pkt4Ptr &query) |
Verifies if specified packet meets RFC requirements. | |
static void | sanityCheck (const Pkt4Ptr &query, RequirementLevel serverid) |
Verifies if specified packet meets RFC requirements. | |
static void | appendServerID (Dhcpv4Exchange &ex) |
Adds server identifier option to the server's response. | |
static uint16_t | checkRelayPort (const Dhcpv4Exchange &ex) |
Check if the relay port RAI sub-option was set in the query. | |
static std::string | srvidToString (const OptionPtr &opt) |
converts server-id to text Converts content of server-id option to a text representation, e.g. | |
Additional Inherited Members | |
Protected Member Functions inherited from isc::process::Daemon | |
std::string | makePIDFileName () const |
Manufacture the pid file name. | |
Protected Attributes inherited from isc::process::Daemon | |
isc::asiolink::IOSignalSetPtr | signal_set_ |
A pointer to the object installing custom signal handlers. | |
boost::posix_time::ptime | start_ |
Timestamp of the start of the daemon. | |
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 268 of file dhcp4_srv.h.
defines if certain option may, must or must not appear
Enumerator | |
---|---|
FORBIDDEN | |
MANDATORY | |
OPTIONAL |
Definition at line 277 of file dhcp4_srv.h.
isc::dhcp::Dhcpv4Srv::Dhcpv4Srv | ( | uint16_t | server_port = DHCP4_SERVER_PORT, |
uint16_t | client_port = 0, | ||
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 and alternate port where DHCPv4 server sends all responses to. Those are 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.
server_port | specifies port number to listen on |
client_port | specifies port number to send to |
use_bcast | configure sockets to support broadcast messages. |
direct_response_desired | specifies if it is desired to use direct V4 traffic. |
Definition at line 662 of file dhcp4_srv.cc.
References alloc_engine_, isc::dhcp::DBG_DHCP4_START, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_OPEN_SOCKET, isc::dhcp::DHCP4_SRV_CONSTRUCT_ERROR, isc::dhcp::DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED, isc::dhcp::IfaceMgr::instance(), LOG_DEBUG, LOG_ERROR, LOG_WARN, isc::dhcp::IfaceMgr::setMatchingPacketFilter(), setPacketStatisticsDefaults(), and shutdown_.
|
virtual |
Destructor. Used during DHCPv4 service shutdown.
Definition at line 724 of file dhcp4_srv.cc.
References isc::asiolink::IOServiceMgr::clearIOServices(), isc::dhcp::Dhcp4o6IpcBase::close(), isc::dhcp::IfaceMgr::closeSockets(), isc::dhcp::HostMgr::create(), isc::dhcp::LeaseMgrFactory::destroy(), isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_SRV_D2STOP_ERROR, isc::dhcp::DHCP4_SRV_DHCP4O6_ERROR, isc::dhcp::DHCP4_SRV_UNLOAD_LIBRARIES_ERROR, discardPackets(), isc::hooks::HooksManager::getLibraryNames(), isc::asiolink::IOServiceMgr::instance(), isc::dhcp::Dhcp4to6Ipc::instance(), isc::dhcp::IfaceMgr::instance(), LOG_ERROR, isc::hooks::HooksManager::prepareUnloadLibraries(), stopD2(), and isc::hooks::HooksManager::unloadLibraries().
|
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.
query | Received message. |
Definition at line 4567 of file dhcp4_srv.cc.
References acceptDirectRequest(), acceptMessageType(), acceptServerId(), isc::dhcp::bad_packet4_logger, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_PACKET_DROP_0002, isc::dhcp::DHCP4_PACKET_DROP_0003, and LOG_DEBUG.
Referenced by processPacket().
|
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:
query | Message sent by a client. |
Definition at line 4595 of file dhcp4_srv.cc.
References isc::dhcp::DHCPINFORM, and selectSubnet().
Referenced by accept().
|
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:
query | Message sent by a client. |
Definition at line 4633 of file dhcp4_srv.cc.
References isc::dhcp::bad_packet4_logger, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_PACKET_DROP_0004, isc::dhcp::DHCP4_PACKET_DROP_0005, isc::dhcp::DHCP4_PACKET_DROP_0006, isc::dhcp::DHCP4_PACKET_DROP_0009, isc::dhcp::DHCP_NOTYPE, isc::dhcp::DHCP_TYPES_EOF, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, and LOG_DEBUG.
Referenced by accept().
|
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.
pkt | DHCPv4 message which server identifier is to be checked. |
Definition at line 4689 of file dhcp4_srv.cc.
References DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_AGENT_OPTIONS, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::IfaceMgr::instance(), isc::asiolink::IOAddress::isV4(), isc::dhcp::RAI_OPTION_SERVER_ID_OVERRIDE, and isc::asiolink::IOAddress::toBytes().
Referenced by accept().
|
protected |
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:
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, unless a client port was enforced from the command line.
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.
ex | The exchange holding both the client's message and the server's response. |
Definition at line 3484 of file dhcp4_srv.cc.
References adjustRemoteAddr(), checkRelayPort(), client_port_, 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(), server_port_, isc::dhcp::CfgIface::SOCKET_UDP, and isc::dhcp::CfgIface::USE_ROUTING.
Referenced by processDiscover(), processInform(), and processRequest().
|
protected |
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:
ex | The exchange holding both the client's message and the server's response. |
Definition at line 3572 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(), getSendResponsesToSource(), isc::dhcp::IfaceMgr::instance(), and isc::asiolink::IOAddress::IPV4_BCAST_ADDRESS().
Referenced by adjustIfaceData().
|
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:
ex | DHCPv4 exchange holding the client's message to be checked. |
Definition at line 2496 of file dhcp4_srv.cc.
References isc::dhcp::OptionDescriptor::allowedForClientClasses(), 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::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), and isc::dhcp::OptionDescriptor::option_.
Referenced by processDiscover(), processInform(), and processRequest().
|
protected |
Appends options requested by client.
This method assigns options that were requested by client (sent in PRL) or are enforced by server.
ex | The exchange holding both the client's message and the server's response. |
Definition at line 2152 of file dhcp4_srv.cc.
References isc::dhcp::OptionDescriptor::allowedForClientClasses(), DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_PARAMETER_REQUEST_LIST, isc::dhcp::DHO_VIVCO_SUBOPTIONS, isc::dhcp::DHO_VIVSO_SUBOPTIONS, isc::dhcp::Dhcpv4Exchange::getCfgOptionList(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::OptionDescriptor::option_, and isc::dhcp::Option::V4.
Referenced by processDiscover(), processInform(), and processRequest().
|
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.
ex | The exchange holding both the client's message and the server's response. |
Definition at line 2324 of file dhcp4_srv.cc.
References isc::dhcp::OptionDescriptor::allowedForClientClasses(), isc::dhcp::DHO_VIVCO_SUBOPTIONS, 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::OptionDescriptor::option_, isc::dhcp::Option::V4, and VENDOR_ID_CABLE_LABS.
Referenced by processDiscover(), processInform(), and processRequest().
|
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.
Dhcpv4Srv
class.ex | The exchange holding both the client's message and the server's response. |
Definition at line 2053 of file dhcp4_srv.cc.
References isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::LibDHCP::DHO_DHCP_SERVER_IDENTIFIER_DEF(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::IfaceMgr::getSocket(), isc::dhcp::IfaceMgr::instance(), isc::asiolink::IOAddress::isV4Bcast(), and isc::dhcp::Option::V4.
Referenced by processDiscover(), processInform(), and processRequest().
|
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.
ex | DHCPv4 exchange holding the client's message to be checked. |
Definition at line 2945 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::addValue(), alloc_engine_, assignZero(), isc::dhcp::CfgGlobals::AUTHORITATIVE, isc::dhcp::bad_packet4_logger, isc::data::Element::boolean, createNameChangeRequests(), isc::dhcp::DBG_DHCP4_BASIC_DATA, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::ddns4_logger, isc::dhcp::Dhcpv4Exchange::deleteResponse(), isc::dhcp::DHCP4_CLIENTID_IGNORED_FOR_LEASES, isc::dhcp::DHCP4_DISCOVER, isc::dhcp::DHCP4_INIT_REBOOT, isc::dhcp::DHCP4_LEASE_ALLOC, isc::dhcp::DHCP4_LEASE_OFFER, isc::dhcp::DHCP4_LEASE_REUSE, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_NCR_CREATION_FAILED, isc::dhcp::DHCP4_NO_LEASE_INIT_REBOOT, isc::dhcp::DHCP4_PACKET_NAK_0001, isc::dhcp::DHCP4_PACKET_NAK_0002, isc::dhcp::DHCP4_PACKET_NAK_0003, isc::dhcp::DHCP4_PACKET_NAK_0004, isc::dhcp::DHCP4_REQUEST, isc::dhcp::DHCP4_SUBNET_DYNAMICALLY_CHANGED, isc::dhcp::DHCP4_UNKNOWN_ADDRESS_REQUESTED, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPNAK, isc::dhcp::DHO_DHCP_LEASE_TIME, isc::dhcp::DHO_DHCP_PARAMETER_REQUEST_LIST, isc::dhcp::DHO_DHCP_REQUESTED_ADDRESS, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::DHO_FQDN, isc::dhcp::DHO_HOST_NAME, isc::dhcp::DHO_V6_ONLY_PREFERRED, isc::stats::StatsMgr::generateName(), isc::dhcp::getCalloutHandle(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::AllocEngine::getValidLft(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::stats::StatsMgr::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc::dhcp::lease4_logger, isc::dhcp::Lease::lifetimeToText(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::dhcp::packet4_logger, postAllocateNameUpdate(), processClientName(), isc::dhcp::Dhcpv4Exchange::setIPv6OnlyPreferred(), setTeeTimes(), isc::asiolink::IOAddress::toText(), isc::dhcp::Lease::TYPE_V4, isc::dhcp::Option::V4, and isc::Exception::what().
Referenced by processDiscover(), and processRequest().
|
protected |
Assign the 0.0.0.0 address to an IPv6-Only client.
Check if there is a subnet or shared network defining an IPv6-Only Preferred option which will be included by the response.
subnet | Reference to the selected subnet, can be modified if the option is found in another subnet of the shared network. |
client_classes | Client classes. |
Definition at line 2912 of file dhcp4_srv.cc.
References DHCP4_OPTION_SPACE, isc::dhcp::DHO_V6_ONLY_PREFERRED, and isc::dhcp::OptionDescriptor::option_.
Referenced by assignLease().
|
protected |
Build the configured option list.
CfgOption
objects used to append options to the response.ex | The exchange where the configured option list is cached |
Definition at line 2078 of file dhcp4_srv.cc.
References isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DHCP4_CLASS_UNCONFIGURED, isc::dhcp::dhcp4_logger, isc::dhcp::Dhcpv4Exchange::getCfgOptionList(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::CfgMgr::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), isc::dhcp::isClientClassBuiltIn(), isc::asiolink::IOAddress::isV4Zero(), LOG_DEBUG, and isc::dhcp::Lease::TYPE_V4.
Referenced by processDiscover(), processInform(), and processRequest().
|
staticprotected |
Check if the relay port RAI sub-option was set in the query.
ex | The exchange holding the client's message |
Definition at line 3471 of file dhcp4_srv.cc.
References isc::dhcp::DHO_DHCP_AGENT_OPTIONS, isc::dhcp::Dhcpv4Exchange::getQuery(), and isc::dhcp::RAI_OPTION_RELAY_PORT.
Referenced by adjustIfaceData().
|
protected |
Assigns incoming packet to zero or more classes.
pkt | packet to be classified |
Definition at line 4892 of file dhcp4_srv.cc.
References isc::dhcp::Dhcpv4Exchange::classifyPacket().
Referenced by processPacket().
|
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.
lease | A pointer to the new lease which has been acquired. |
old_lease | A pointer to the instance of the old lease which has |
ddns_params | DDNS configuration parameters 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 2883 of file dhcp4_srv.cc.
References isc::dhcp_ddns::CHG_ADD, isc::dhcp_ddns::CHG_REMOVE, isc::dhcp::DdnsParams::getEnableUpdates(), isc::dhcp::DdnsParams::getUpdateOnRenew(), isc_throw, and isc::dhcp::queueNCR().
Referenced by assignLease().
|
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.
result | Result code of the send operation. |
ncr | NameChangeRequest which failed to send. |
Definition at line 5078 of file dhcp4_srv.cc.
References isc::dhcp::ddns4_logger, isc::dhcp::DHCP4_DDNS_REQUEST_SEND_FAILED, isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::CfgMgr::instance(), LOG_ERROR, and isc::dhcp::D2ClientMgr::suspendUpdates().
Referenced by startD2().
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:
lease | lease to be declined |
decline | client's message |
context | reference to a client context |
Definition at line 4203 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::addValue(), isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp_ddns::CHG_REMOVE, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_DECLINE_FAIL, isc::dhcp::DHCP4_DECLINE_LEASE, isc::dhcp::DHCP4_HOOK_DECLINE_SKIP, isc::stats::StatsMgr::generateName(), isc::dhcp::getCalloutHandle(), isc::dhcp::CfgMgr::getCurrentCfg(), Hooks, isc::hooks::hooks_logger, isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::stats::StatsMgr::instance(), isc::dhcp::lease4_logger, LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::queueNCR(), isc::dhcp::Lease::TYPE_V4, isc::dhcp::LeaseMgr::updateLease4(), and isc::Exception::what().
Referenced by processDecline().
|
protected |
Perform deferred option unpacking.
query | Pointer to the client message. |
Definition at line 4982 of file dhcp4_srv.cc.
References isc::dhcp::bad_packet4_logger, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DHCP4_DEFERRED_OPTION_MISSING, isc::dhcp::DHCP4_DEFERRED_OPTION_UNPACK_FAIL, DHCP4_OPTION_SPACE, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LibDHCP::getLastResortOptionDef(), isc::dhcp::LibDHCP::getOptionDef(), isc::dhcp::LibDHCP::getRuntimeOptionDef(), isc::dhcp::CfgMgr::instance(), LOG_DEBUG, and isc::dhcp::Option::V4.
Referenced by processPacket().
void isc::dhcp::Dhcpv4Srv::discardPackets | ( | ) |
Discards parked packets Clears the packet parking lots of all packets.
Called during reconfigure and shutdown.
Definition at line 5223 of file dhcp4_srv.cc.
References isc::hooks::HooksManager::clearParkingLots().
Referenced by ~Dhcpv4Srv(), and isc::dhcp::configureDhcp4Server().
bool isc::dhcp::Dhcpv4Srv::earlyGHRLookup | ( | const Pkt4Ptr & | query, |
AllocEngine::ClientContext4Ptr | ctx ) |
Initialize client context and perform early global reservations lookup.
query | The query message. |
ctx | Pointer to client context. |
Definition at line 1099 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::addValue(), alloc_engine_, isc::dhcp::DBG_DHCP4_BASIC, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_CLASS_ASSIGNED, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_PACKET_DROP_0014, isc::dhcp::CfgGlobals::EARLY_GLOBAL_RESERVATIONS_LOOKUP, isc::dhcp::Dhcpv4Exchange::evaluateClasses(), isc::dhcp::CfgMgr::getCurrentCfg(), initContext0(), isc::dhcp::CfgMgr::instance(), isc::stats::StatsMgr::instance(), LOG_DEBUG, isc::dhcp::packet4_logger, isc::dhcp::Dhcpv4Exchange::removeDependentEvaluatedClasses(), and isc::dhcp::Dhcpv4Exchange::setHostIdentifiers().
Referenced by processDhcp4Query().
|
protected |
Evaluates classes in the additional classes lists.
The evaluation takes place after all other classification and lease assignment. It evaluates all classes in the packet's additional classes list plus any contributed via evaluate-additional-classes lists.
ex | The exchange holding needed information. |
Definition at line 4896 of file dhcp4_srv.cc.
References isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DHCP4_ADDITIONAL_CLASS_EVAL_ERROR, isc::dhcp::DHCP4_ADDITIONAL_CLASS_EVAL_RESULT, isc::dhcp::DHCP4_ADDITIONAL_CLASS_NO_TEST, isc::dhcp::DHCP4_ADDITIONAL_CLASS_UNDEFINED, 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, isc::dhcp::Lease::TYPE_V4, and isc::Exception::what().
Referenced by processDiscover(), processInform(), and processRequest().
|
inline |
Returns an object which controls access to the configuration backends.
Definition at line 333 of file dhcp4_srv.h.
References cb_control_.
Referenced by isc::dhcp::configureDhcp4Server().
|
static |
Returns the index for "buffer4_receive" hook point.
Definition at line 5195 of file dhcp4_srv.cc.
References Hooks.
|
static |
Returns the index for "buffer4_send" hook point.
Definition at line 5215 of file dhcp4_srv.cc.
References Hooks.
Referenced by isc::dhcp::Dhcp4to6Ipc::handler().
|
static |
Returns the index for "lease4_decline" hook point.
Definition at line 5219 of file dhcp4_srv.cc.
References Hooks.
|
static |
Returns the index for "lease4_release" hook point.
Definition at line 5207 of file dhcp4_srv.cc.
References Hooks.
|
static |
Returns the index for "pkt4_receive" hook point.
Definition at line 5199 of file dhcp4_srv.cc.
References Hooks.
|
static |
Returns the index for "pkt4_send" hook point.
Definition at line 5211 of file dhcp4_srv.cc.
References Hooks.
|
static |
Returns the index for "subnet4_select" hook point.
Definition at line 5203 of file dhcp4_srv.cc.
References Hooks.
|
inline |
Returns pointer to the IO service used by the server.
Definition at line 319 of file dhcp4_srv.h.
Referenced by isc::dhcp::ControlledDhcpv4Srv::ControlledDhcpv4Srv(), isc::dhcp::ControlledDhcpv4Srv::cleanup(), isc::dhcp::ControlledDhcpv4Srv::finishConfigHookLibraries(), isc::dhcp::ControlledDhcpv4Srv::init(), run(), and isc::dhcp::ControlledDhcpv4Srv::shutdownServer().
|
inline |
Returns pointer to the network state used by the server.
Definition at line 324 of file dhcp4_srv.h.
References network_state_.
Referenced by isc::dhcp::ControlledDhcpv4Srv::finishConfigHookLibraries(), and isc::dhcp::ControlledDhcpv4Srv::processConfig().
|
inline |
Returns value of the test_send_responses_to_source_ flag.
Definition at line 509 of file dhcp4_srv.h.
Referenced by adjustRemoteAddr().
uint16_t isc::dhcp::Dhcpv4Srv::getServerPort | ( | ) | const |
Get UDP port on which server should listen.
Typically, server listens on UDP port number 67. Other ports are used for testing purposes only.
Definition at line 5228 of file dhcp4_srv.cc.
References isc::log::interprocess::InterprocessSyncLocker::lock(), server_port_, and isc::log::interprocess::InterprocessSyncLocker::unlock().
Referenced by isc::dhcp::ControlledDhcpv4Srv::processConfig().
|
static |
returns Kea version on stdout and exit.
redeclaration/redefinition. isc::process::Daemon::getVersion()
Definition at line 5090 of file dhcp4_srv.cc.
References isc::dhcp::HostDataSourceFactory::getDBVersions(), isc::dhcp::LeaseMgrFactory::getDBVersions(), isc::cryptolink::CryptoLink::getVersion(), isc::log::Logger::getVersion(), isc::db::info, and version().
Referenced by main().
void isc::dhcp::Dhcpv4Srv::initContext0 | ( | const Pkt4Ptr & | query, |
AllocEngine::ClientContext4Ptr | ctx ) |
Initialize client context (first part).
query | The query message. |
ctx | Pointer to client context. |
Definition at line 1089 of file dhcp4_srv.cc.
Referenced by earlyGHRLookup(), and processLocalizedQuery4AndSendResponse().
|
inline |
Checks if the server is running in unit test mode.
Definition at line 314 of file dhcp4_srv.h.
References server_port_.
Referenced by isc::dhcp::ControlledDhcpv4Srv::processConfig().
|
finaloverridevirtual |
Return a list of all paths that contain passwords or secrets for kea-dhcp4.
Reimplemented from isc::process::Daemon.
Definition at line 5263 of file dhcp4_srv.cc.
|
protected |
Update client name and DNS flags in the lease and response.
There are two cases when the client name (FQDN or hostname) and DNS flags need to updated after the lease has been allocated:
In the first case this function will generate the name from the lease address. In either case, the name and DNS flags are updated in the lease and in the response packet.
ctx | reference to the client context |
lease | reference to the client lease |
query | reference to the client query |
resp | reference to the client response |
client_name_changed | - true if the new values are already in the lease |
TKM - do this on committed-discover
Definition at line 3364 of file dhcp4_srv.cc.
References isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::ddns4_logger, isc::dhcp::DHCP4_POST_ALLOCATION_NAME_UPDATE_FAIL, isc::dhcp::DHCP4_RESPONSE_HOSTNAME_GENERATE, isc::dhcp::DHO_FQDN, isc::dhcp::DHO_HOST_NAME, isc::dhcp::Option4ClientFqdn::FULL, isc::dhcp::D2ClientMgr::generateFqdn(), isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), LOG_DEBUG, LOG_ERROR, isc::dhcp::LeaseMgr::updateLease4(), and isc::Exception::what().
Referenced by assignLease().
|
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.
ex | The exchange holding both the client's message and the server's response. |
Definition at line 2538 of file dhcp4_srv.cc.
References isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::ddns4_logger, isc::dhcp::DHCP4_CLIENT_FQDN_PROCESS, isc::dhcp::DHCP4_CLIENT_HOSTNAME_PROCESS, isc::dhcp::DHCP4_CLIENT_NAME_PROC_FAIL, isc::dhcp::DHCP4_HOOK_DDNS_UPDATE, isc::dhcp::DHO_FQDN, isc::dhcp::DHO_HOST_NAME, isc::dhcp::Option4ClientFqdn::FLAG_N, isc::dhcp::Option4ClientFqdn::FLAG_S, isc::dhcp::Option4ClientFqdn::FULL, isc::dhcp::getCalloutHandle(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::Dhcpv4Exchange::getQuery(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::dhcp::D2ClientMgr::getUpdateDirections(), Hooks, isc::hooks::hooks_logger, isc::dhcp::CfgMgr::instance(), LOG_DEBUG, and isc::Exception::what().
Referenced by assignLease().
|
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.
decline | message received from client |
context | pointer to the client context where declined lease is stored. |
Definition at line 4129 of file dhcp4_srv.cc.
References declineLease(), isc::dhcp::DHCP4_DECLINE_LEASE_MISMATCH, isc::dhcp::DHCP4_DECLINE_LEASE_NOT_FOUND, isc::dhcp::dhcp4_logger, isc::dhcp::DHO_DHCP_REQUESTED_ADDRESS, isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, LOG_WARN, isc::dhcp::Lease::STATE_DEFAULT, and isc::asiolink::IOAddress::toText().
Referenced by processLocalizedQuery4().
Process a single incoming DHCPv4 query.
It localizes the query, calls per-type processXXX methods, generates appropriate answer.
query | A pointer to the packet to be processed. |
allow_answer_park | Indicates if parking a packet is allowed. |
Definition at line 1539 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::addValue(), isc::dhcp::bad_packet4_logger, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_PACKET_DROP_0007, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, earlyGHRLookup(), isc::stats::StatsMgr::instance(), isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, isc::dhcp::makeContinuation(), processDhcp4QueryAndSendResponse(), processLocalizedQuery4(), sanityCheck(), selectSubnet(), and isc::dhcp::ClientHandler::tryLock().
Referenced by processDhcp4QueryAndSendResponse(), and processPacket().
void isc::dhcp::Dhcpv4Srv::processDhcp4QueryAndSendResponse | ( | Pkt4Ptr | query, |
bool | allow_answer_park ) |
Process a single incoming DHCPv4 query.
It localizes the query, calls per-type processXXX methods, generates appropriate answer, sends the answer to the client.
query | A pointer to the packet to be processed. |
allow_answer_park | Indicates if parking a packet is allowed. |
Definition at line 1519 of file dhcp4_srv.cc.
References isc::dhcp::DHCP4_PACKET_PROCESS_EXCEPTION, isc::dhcp::DHCP4_PACKET_PROCESS_STD_EXCEPTION, isc::dhcp::getCalloutHandle(), LOG_ERROR, isc::dhcp::packet4_logger, processDhcp4Query(), and processPacketBufferSend().
Referenced by processDhcp4Query().
|
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.
discover | DISCOVER message received from client |
context | pointer to the client context |
Definition at line 3815 of file dhcp4_srv.cc.
References adjustIfaceData(), alloc_engine_, appendBasicOptions(), appendRequestedOptions(), appendRequestedVendorOptions(), appendServerID(), assignLease(), buildCfgOptionList(), isc::dhcp::Dhcpv4Exchange::conditionallySetReservedClientClasses(), isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DHCP4_CLASSES_ASSIGNED, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER, isc::dhcp::DHO_V6_ONLY_PREFERRED, evaluateAdditionalClasses(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getIPv6OnlyPreferred(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, LOG_ERROR, isc::dhcp::packet4_logger, and setFixedFields().
Referenced by processLocalizedQuery4().
|
protected |
Processes incoming DHCPINFORM messages.
inform | message received from client |
context | pointer to the client context |
Definition at line 4429 of file dhcp4_srv.cc.
References adjustIfaceData(), alloc_engine_, appendBasicOptions(), appendRequestedOptions(), appendRequestedVendorOptions(), appendServerID(), buildCfgOptionList(), isc::dhcp::Dhcpv4Exchange::conditionallySetReservedClientClasses(), isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DHCP4_CLASSES_ASSIGNED, isc::dhcp::DHCP4_INFORM_DIRECT_REPLY, isc::dhcp::dhcp4_logger, isc::dhcp::DHO_DHCP_AGENT_OPTIONS, evaluateAdditionalClasses(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), LOG_DEBUG, isc::dhcp::packet4_logger, and setFixedFields().
Referenced by processLocalizedQuery4().
Pkt4Ptr isc::dhcp::Dhcpv4Srv::processLocalizedQuery4 | ( | AllocEngine::ClientContext4Ptr & | ctx, |
bool | allow_answer_park ) |
Process a localized incoming DHCPv4 query.
It calls per-type processXXX methods, generates appropriate answer.
ctx | Pointer to The client context. |
allow_answer_park | Indicates if parking a packet is allowed. |
Definition at line 1636 of file dhcp4_srv.cc.
References isc::util::ThreadPool< WorkItem, Container >::add(), isc::stats::StatsMgr::addValue(), isc::dhcp::bad_packet4_logger, isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp::DBG_DHCP4_HOOKS, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING, isc::dhcp::DHCP4_HOOK_LEASE4_OFFER_DROP, isc::dhcp::DHCP4_HOOK_LEASE4_OFFER_PARK, isc::dhcp::DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL, isc::dhcp::DHCP4_HOOK_LEASES4_COMMITTED_DROP, isc::dhcp::DHCP4_HOOK_LEASES4_COMMITTED_PARK, isc::dhcp::DHCP4_HOOK_LEASES4_COMMITTED_PARKING_LOT_FULL, isc::dhcp::DHCP4_PACKET_DROP_0007, isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, isc::hooks::HooksManager::drop(), isc::dhcp::getCalloutHandle(), isc::util::MultiThreadingMgr::getThreadPool(), Hooks, isc::hooks::hooks_logger, isc::stats::StatsMgr::instance(), isc::util::MultiThreadingMgr::instance(), isc_throw, LOG_DEBUG, LOG_ERROR, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_PARK, isc::dhcp::packet4_logger, isc::hooks::HooksManager::park(), processDecline(), processDiscover(), processInform(), processPacketBufferSend(), processPacketPktSend(), processRelease(), processRequest(), sendResponseNoThrow(), serverDecline(), serverDeclineNoThrow(), and isc::Exception::what().
Referenced by processDhcp4Query(), and processLocalizedQuery4AndSendResponse().
void isc::dhcp::Dhcpv4Srv::processLocalizedQuery4AndSendResponse | ( | Pkt4Ptr | query, |
AllocEngine::ClientContext4Ptr & | ctx, | ||
bool | allow_answer_park ) |
Process a localized incoming DHCPv4 query.
It calls per-type processXXX methods, generates appropriate answer, sends the answer to the client.
query | A pointer to the unparked packet. |
ctx | Pointer to The client context. |
allow_answer_park | Indicates if parking a packet is allowed. |
Definition at line 1596 of file dhcp4_srv.cc.
References isc::dhcp::DHCP4_PACKET_PROCESS_EXCEPTION, isc::dhcp::DHCP4_PACKET_PROCESS_STD_EXCEPTION, isc::dhcp::getCalloutHandle(), LOG_ERROR, isc::dhcp::packet4_logger, processLocalizedQuery4(), and processPacketBufferSend().
Referenced by processLocalizedQuery4AndSendResponse(), selectSubnet(), and selectSubnet4o6().
void isc::dhcp::Dhcpv4Srv::processLocalizedQuery4AndSendResponse | ( | Pkt4Ptr | query, |
bool | allow_answer_park ) |
Process a localized incoming DHCPv4 query.
A variant of the precedent method used to resume processing for packets parked in the subnet4_select callout.
query | A pointer to the unparked packet. |
allow_answer_park | Indicates if parking a packet is allowed. |
Definition at line 1618 of file dhcp4_srv.cc.
References isc::dhcp::getCalloutHandle(), initContext0(), and processLocalizedQuery4AndSendResponse().
Process a single incoming DHCPv4 packet.
It verifies correctness of the passed packet, calls per-type processXXX methods, generates appropriate answer.
query | A pointer to the packet to be processed. |
allow_answer_park | Indicates if parking a packet is allowed. |
Definition at line 1327 of file dhcp4_srv.cc.
References accept(), isc::stats::StatsMgr::addValue(), isc::dhcp::bad_packet4_logger, isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), classifyPacket(), isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::DBG_DHCP4_HOOKS, isc::log::DBGLVL_PKT_HANDLING, deferredUnpack(), isc::dhcp::DHCP4_BUFFER_UNPACK, isc::dhcp::DHCP4_HOOK_BUFFER_RCVD_DROP, isc::dhcp::DHCP4_HOOK_BUFFER_RCVD_SKIP, isc::dhcp::DHCP4_HOOK_PACKET_RCVD_SKIP, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_PACKET_DROP_0001, isc::dhcp::DHCP4_PACKET_DROP_0010, isc::dhcp::DHCP4_PACKET_OPTIONS_SKIPPED, isc::dhcp::DHCP4_PACKET_RECEIVED, isc::dhcp::DHCP4_QUERY_DATA, isc::dhcp::DHCP4_QUERY_LABEL, isc::dhcp::getCalloutHandle(), Hooks, isc::hooks::hooks_logger, isc::stats::StatsMgr::instance(), LOG_DEBUG, LOG_INFO, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::options4_logger, isc::dhcp::packet4_logger, processDhcp4Query(), processStatsReceived(), recoverStashedAgentOption(), and isc::Exception::what().
Referenced by isc::dhcp::Dhcp4to6Ipc::handler(), and processPacketAndSendResponse().
void isc::dhcp::Dhcpv4Srv::processPacketAndSendResponse | ( | Pkt4Ptr | query | ) |
Process a single incoming DHCPv4 packet and sends the response.
It verifies correctness of the passed packet, calls per-type processXXX methods, generates appropriate answer, sends the answer to the client.
query | A pointer to the packet to be processed. |
Definition at line 1315 of file dhcp4_srv.cc.
References isc::dhcp::getCalloutHandle(), processPacket(), and processPacketBufferSend().
Referenced by processPacketAndSendResponseNoThrow(), and runOne().
void isc::dhcp::Dhcpv4Srv::processPacketAndSendResponseNoThrow | ( | Pkt4Ptr | query | ) |
Process a single incoming DHCPv4 packet and sends the response.
It verifies correctness of the passed packet, calls per-type processXXX methods, generates appropriate answer, sends the answer to the client.
query | A pointer to the packet to be processed. |
Definition at line 1302 of file dhcp4_srv.cc.
References isc::dhcp::DHCP4_PACKET_PROCESS_EXCEPTION, isc::dhcp::DHCP4_PACKET_PROCESS_STD_EXCEPTION, LOG_ERROR, isc::dhcp::packet4_logger, and processPacketAndSendResponse().
Referenced by runOne().
|
protected |
Executes buffer4_send callout and sends the response.
callout_handle | pointer to the callout handle. |
rsp | pointer to a response. |
Definition at line 1960 of file dhcp4_srv.cc.
References isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::DBG_DHCP4_HOOKS, isc::dhcp::DHCP4_HOOK_BUFFER_SEND_SKIP, isc::dhcp::DHCP4_PACKET_SEND, isc::dhcp::DHCP4_PACKET_SEND_FAIL, isc::dhcp::DHCP4_RESPONSE_DATA, Hooks, isc::hooks::hooks_logger, LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::packet4_logger, processStatsSent(), and sendPacket().
Referenced by processDhcp4QueryAndSendResponse(), processLocalizedQuery4(), processLocalizedQuery4AndSendResponse(), processPacketAndSendResponse(), and sendResponseNoThrow().
|
protected |
Executes pkt4_send callout.
callout_handle | pointer to the callout handle. |
query | Pointer to a query. |
rsp | Pointer to a response. |
subnet | A pointer to selected subnet. |
Callouts decided to drop the packet.
Definition at line 1889 of file dhcp4_srv.cc.
References isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_HOOKS, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_HOOK_PACKET_SEND_DROP, isc::dhcp::DHCP4_HOOK_PACKET_SEND_SKIP, isc::dhcp::DHCP4_PACKET_PACK, isc::dhcp::DHCP4_PACKET_PACK_FAIL, Hooks, isc::hooks::hooks_logger, LOG_DEBUG, LOG_ERROR, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, and isc::dhcp::options4_logger.
Referenced by processLocalizedQuery4(), and sendResponseNoThrow().
|
protected |
Processes incoming DHCPRELEASE messages.
In DHCPv4, server does not respond to RELEASE messages, therefore this function does not return anything.
release | message received from client |
context | pointer to the client context where released lease is stored. |
Definition at line 3975 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::addValue(), isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp_ddns::CHG_REMOVE, isc::dhcp::DBG_DHCP4_DETAIL, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::LeaseMgr::deleteLease(), isc::dhcp::DHCP4_HOOK_LEASE4_RELEASE_SKIP, isc::dhcp::DHCP4_RELEASE, isc::dhcp::DHCP4_RELEASE_DELETED, isc::dhcp::DHCP4_RELEASE_EXCEPTION, isc::dhcp::DHCP4_RELEASE_EXPIRED, isc::dhcp::DHCP4_RELEASE_FAIL, isc::dhcp::DHCP4_RELEASE_FAIL_NO_LEASE, isc::dhcp::DHCP4_RELEASE_FAIL_WRONG_CLIENT, isc::stats::StatsMgr::generateName(), isc::dhcp::getCalloutHandle(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLease4(), Hooks, isc::hooks::hooks_logger, isc::dhcp::Lease::INFINITY_LFT, isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::stats::StatsMgr::instance(), isc::dhcp::lease4_logger, LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::queueNCR(), isc::dhcp::Lease::STATE_RELEASED, isc::dhcp::Lease::TYPE_V4, isc::dhcp::LeaseMgr::updateLease4(), and isc::Exception::what().
Referenced by processLocalizedQuery4().
|
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
request | a message received from client |
context | pointer to the client context where allocated and deleted leases are stored. |
Definition at line 3894 of file dhcp4_srv.cc.
References adjustIfaceData(), alloc_engine_, appendBasicOptions(), appendRequestedOptions(), appendRequestedVendorOptions(), appendServerID(), assignLease(), buildCfgOptionList(), isc::dhcp::Dhcpv4Exchange::conditionallySetReservedClientClasses(), isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DHCP4_CLASSES_ASSIGNED, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK, isc::dhcp::DHO_V6_ONLY_PREFERRED, evaluateAdditionalClasses(), isc::dhcp::Dhcpv4Exchange::getContext(), isc::dhcp::Dhcpv4Exchange::getIPv6OnlyPreferred(), isc::dhcp::Dhcpv4Exchange::getResponse(), isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, LOG_ERROR, isc::dhcp::packet4_logger, and setFixedFields().
Referenced by processLocalizedQuery4().
|
static |
Class methods for DHCPv4-over-DHCPv6 handler.
Updates statistics for received packets
query | packet received |
Definition at line 5120 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().
|
static |
Updates statistics for transmitted packets.
response | packet transmitted |
Definition at line 5169 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().
|
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 1079 of file dhcp4_srv.cc.
References isc::dhcp::IfaceMgr::instance().
Referenced by runOne().
|
protected |
Recover stashed agent options from client address lease.
This method checks:
Definition at line 4484 of file dhcp4_srv.cc.
References isc::data::Element::boolean, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::util::str::decodeFormattedHexString(), isc::dhcp::DHCP4_RECOVERED_STASHED_RELAY_AGENT_INFO, isc::dhcp::DHCPREQUEST, isc::dhcp::DHO_DHCP_AGENT_OPTIONS, isc::dhcp::LibDHCP::DHO_DHCP_AGENT_OPTIONS_DEF(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), LOG_DEBUG, isc::data::Element::map, isc::dhcp::Option::OPTION4_HDR_LEN, isc::dhcp::packet4_logger, isc::dhcp::CfgGlobals::STASH_AGENT_OPTIONS, isc::data::Element::string, and isc::dhcp::Option::V4.
Referenced by processPacket().
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.
renew | client's message asking for renew |
reply | server's response (ACK or NAK) |
int isc::dhcp::Dhcpv4Srv::run | ( | ) |
Main server processing loop.
Main server processing loop. Call the processing step routine until shut down.
Daemon::getExitValue()
. Definition at line 1170 of file dhcp4_srv.cc.
References isc::util::MultiThreadingMgr::apply(), isc::dhcp::DHCP4_PACKET_PROCESS_EXCEPTION_MAIN, isc::dhcp::DHCP4_PACKET_PROCESS_STD_EXCEPTION_MAIN, isc::config::HttpCommandMgr::garbageCollectListeners(), isc::process::Daemon::getExitValue(), getIOService(), isc::asiolink::IOServiceMgr::instance(), isc::config::HttpCommandMgr::instance(), isc::util::MultiThreadingMgr::instance(), isc_throw, LOG_ERROR, isc::dhcp::packet4_logger, isc::asiolink::IOServiceMgr::pollIOServices(), runOne(), server_port_, and shutdown_.
Referenced by main().
void isc::dhcp::Dhcpv4Srv::runOne | ( | ) |
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 1228 of file dhcp4_srv.cc.
References isc::dhcp::bad_packet4_logger, isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::DBG_DHCP4_DETAIL, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_BUFFER_RECEIVE_FAIL, isc::dhcp::DHCP4_BUFFER_RECEIVED, isc::dhcp::DHCP4_BUFFER_WAIT_SIGNAL, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_PACKET_DROP_0008, isc::dhcp::DHCP4_PACKET_QUEUE_FULL, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, LOG_ERROR, network_state_, isc::dhcp::packet4_logger, processPacketAndSendResponse(), processPacketAndSendResponseNoThrow(), and receivePacket().
Referenced by run().
|
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. Calls the second method with the requirement level based on message type.
query | Pointer to the client's message. |
RFCViolation | if any issues are detected |
Definition at line 4821 of file dhcp4_srv.cc.
References isc::dhcp::DHCPDECLINE, isc::dhcp::DHCPDISCOVER, isc::dhcp::DHCPINFORM, isc::dhcp::DHCPRELEASE, isc::dhcp::DHCPREQUEST, FORBIDDEN, OPTIONAL, and sanityCheck().
Referenced by processDhcp4Query(), and sanityCheck().
|
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.
query | Pointer to the client's message. |
serverid | expectation regarding server-id option |
RFCViolation | if any issues are detected |
Definition at line 4851 of file dhcp4_srv.cc.
References isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, FORBIDDEN, isc_throw, MANDATORY, and OPTIONAL.
|
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.
query | client's message |
drop | if it is true the packet will be dropped |
sanity_only | if it is true the callout won't be called |
allow_answer_park | Indicates if parking a packet is allowed |
Definition at line 775 of file dhcp4_srv.cc.
References isc::util::ThreadPool< WorkItem, Container >::add(), isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp::DBG_DHCP4_BASIC_DATA, isc::dhcp::DBG_DHCP4_DETAIL, isc::dhcp::DBG_DHCP4_DETAIL_DATA, isc::dhcp::DBG_DHCP4_HOOKS, isc::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_HOOK_SUBNET4_SELECT_DROP, isc::dhcp::DHCP4_HOOK_SUBNET4_SELECT_PARK, isc::dhcp::DHCP4_HOOK_SUBNET4_SELECT_PARKING_LOT_FULL, isc::dhcp::DHCP4_HOOK_SUBNET4_SELECT_SKIP, isc::dhcp::DHCP4_SUBNET_DATA, isc::dhcp::DHCP4_SUBNET_SELECTED, isc::dhcp::DHCP4_SUBNET_SELECTION_FAILED, isc::hooks::HooksManager::drop(), isc::dhcp::getCalloutHandle(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::util::MultiThreadingMgr::getThreadPool(), Hooks, isc::hooks::hooks_logger, isc::dhcp::CfgSubnets4::initSelector(), isc::dhcp::CfgMgr::instance(), isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_PARK, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::packet4_logger, isc::hooks::HooksManager::park(), processLocalizedQuery4AndSendResponse(), and selectSubnet4o6().
Referenced by acceptDirectRequest(), and processDhcp4Query().
|
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.
query | client's message |
drop | if it is true the packet will be dropped |
sanity_only | if it is true the callout won't be called |
allow_answer_park | Indicates if parking a packet is allowed |
Definition at line 909 of file dhcp4_srv.cc.
References isc::util::ThreadPool< WorkItem, Container >::add(), isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), 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::log::DBGLVL_PKT_HANDLING, isc::dhcp::DHCP4_DHCP4O6_HOOK_SUBNET4_SELECT_DROP, isc::dhcp::DHCP4_DHCP4O6_HOOK_SUBNET4_SELECT_SKIP, isc::dhcp::DHCP4_DHCP4O6_SUBNET_DATA, isc::dhcp::DHCP4_DHCP4O6_SUBNET_SELECTED, isc::dhcp::DHCP4_DHCP4O6_SUBNET_SELECTION_FAILED, isc::dhcp::DHCP4_HOOK_SUBNET4_SELECT_4O6_PARKING_LOT_FULL, isc::dhcp::DHCP4_HOOK_SUBNET4_SELECT_PARK, isc::dhcp::SubnetSelector::dhcp4o6_, isc::dhcp::DHO_SUBNET_SELECTION, isc::hooks::HooksManager::drop(), isc::dhcp::SubnetSelector::first_relay_linkaddr_, isc::dhcp::getCalloutHandle(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::util::MultiThreadingMgr::getThreadPool(), isc::dhcp::SubnetSelector::giaddr_, Hooks, isc::hooks::hooks_logger, isc::dhcp::SubnetSelector::iface_name_, isc::dhcp::CfgMgr::instance(), isc::util::MultiThreadingMgr::instance(), isc::dhcp::SubnetSelector::interface_id_, isc_throw, isc::dhcp::SubnetSelector::local_address_, LOG_DEBUG, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_PARK, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, isc::dhcp::SubnetSelector::option_select_, isc::dhcp::packet4_logger, isc::hooks::HooksManager::park(), processLocalizedQuery4AndSendResponse(), isc::dhcp::Pkt6::RELAY_GET_FIRST, and isc::dhcp::SubnetSelector::remote_address_.
Referenced by selectSubnet().
|
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 1084 of file dhcp4_srv.cc.
References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::send().
Referenced by processPacketBufferSend().
void isc::dhcp::Dhcpv4Srv::sendResponseNoThrow | ( | hooks::CalloutHandlePtr & | callout_handle, |
Pkt4Ptr & | query, | ||
Pkt4Ptr & | rsp, | ||
ConstSubnet4Ptr & | subnet ) |
Process an unparked DHCPv4 packet and sends the response.
callout_handle | pointer to the callout handle. |
query | A pointer to the packet to be processed. |
rsp | A pointer to the response. |
subnet | A pointer to selected subnet. |
Definition at line 1873 of file dhcp4_srv.cc.
References isc::dhcp::DHCP4_PACKET_PROCESS_EXCEPTION, isc::dhcp::DHCP4_PACKET_PROCESS_STD_EXCEPTION, LOG_ERROR, isc::dhcp::packet4_logger, processPacketBufferSend(), and processPacketPktSend().
Referenced by processLocalizedQuery4().
|
protected |
Renders a lease declined after the server has detected, via ping-check or other means, that its address is already in-use.
This function is invoked during the unpark callback for the lease4_offer hook point, if a hook callout has set the handle status to NEXT_STEP_DROP. It will create/update the lease to DECLINED state in the lease store, update the appropriate stats, and
callout_handle | - current callout handle. |
query | - DHCPDISCOVER which instigated the declination. |
lease | - lease to decline (i.e lease that would have been offered). |
lease_exists | - true if the lease already exists in the lease store (as is the case when offer-lifetime is > 0). |
Definition at line 4303 of file dhcp4_srv.cc.
References isc::dhcp::LeaseMgr::addLease(), isc::stats::StatsMgr::addValue(), isc::hooks::HooksManager::callCallouts(), isc::hooks::HooksManager::calloutsPresent(), isc::dhcp::DHCP4_SERVER_INITIATED_DECLINE, isc::dhcp::DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED, isc::dhcp::DHCP4_SERVER_INITIATED_DECLINE_RESOURCE_BUSY, isc::dhcp::DHCP4_SERVER_INITIATED_DECLINE_UPDATE_FAILED, isc::stats::StatsMgr::generateName(), isc::dhcp::CfgMgr::getCurrentCfg(), Hooks, isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::stats::StatsMgr::instance(), isc::util::MultiThreadingMgr::instance(), isc::dhcp::lease4_logger, LOG_ERROR, LOG_INFO, isc::dhcp::ResourceHandler4::tryLock4(), isc::dhcp::Lease::TYPE_V4, and isc::dhcp::LeaseMgr::updateLease4().
Referenced by processLocalizedQuery4(), and serverDeclineNoThrow().
|
protected |
Exception safe wrapper around serverDecline()
In MT mode this wrapper is used to safely invoke serverDecline() as a DHCP worker thread task.
callout_handle | - current callout handle. |
query | - DHCPDISCOVER which instigated the declination. |
lease | - lease to decline (i.e lease that would have been offered). |
lease_exists | - true if the lease already exists in the lease store (as is the case when offer-lifetime is > 0). |
Definition at line 4419 of file dhcp4_srv.cc.
References isc::dhcp::DHCP4_PACKET_PROCESS_EXCEPTION, LOG_ERROR, isc::dhcp::packet4_logger, and serverDecline().
Referenced by processLocalizedQuery4().
|
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.
ex | DHCPv4 exchange holding the client's message and the server's response to be adjusted. |
Definition at line 3673 of file dhcp4_srv.cc.
References 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::IPV4_ZERO_ADDRESS(), isc::asiolink::IOAddress::isV4Zero(), and isc::dhcp::Dhcpv4Exchange::setReservedMessageFields().
Referenced by processDiscover(), processInform(), and processRequest().
|
protected |
This function sets statistics related to DHCPv4 packets processing to their initial values.
All of the statistics observed by the DHCPv4 server and with the names like "pkt4-" are reset to 0. This function must be invoked in the class constructor.
Definition at line 714 of file dhcp4_srv.cc.
References isc::stats::StatsMgr::instance(), and isc::stats::StatsMgr::setValue().
Referenced by Dhcpv4Srv().
|
inlineprotected |
Sets value of the test_send_responses_to_source_ flag.
value | new value of the test_send_responses_to_source_ flag. |
Definition at line 891 of file dhcp4_srv.h.
|
protected |
Adds the T1 and T2 timers to the outbound response as appropriate.
This method determines if either of the timers T1 (option 58) and T2 (option 59) should be sent to the client. It is influenced by the lease's subnet's values for renew-timer, rebind-timer, calculate-tee-times, t1-percent, and t2-percent as follows:
By default neither T1 nor T2 will be sent.
T2:
If rebind-timer is set use its value, otherwise if calculate-tee-times is true use the value given by valid lease time * t2-percent. Either way the value will only be sent if it is less than the valid lease time.
T1:
If renew-timer is set use its value, otherwise if calculate-tee-times is true use the value given by valid lease time * t1-percent. Either way the value will only be sent if it is less than T2 when T2 is being sent, or less than the valid lease time if T2 is not being sent.
lease | lease being assigned to the client |
subnet | the subnet to which the lease belongs |
resp | outbound response for the client to which timers are added. |
Definition at line 3432 of file dhcp4_srv.cc.
References isc::dhcp::DHO_DHCP_REBINDING_TIME, isc::dhcp::DHO_DHCP_RENEWAL_TIME, and isc::dhcp::Option::V4.
Referenced by assignLease().
|
overridevirtual |
Instructs the server to shut down.
Reimplemented from isc::process::Daemon.
Definition at line 769 of file dhcp4_srv.cc.
References isc::dhcp::DBG_DHCP4_BASIC, isc::dhcp::dhcp4_logger, isc::dhcp::DHCP4_SHUTDOWN_REQUEST, LOG_DEBUG, and shutdown_.
Referenced by isc::dhcp::ControlledDhcpv4Srv::shutdownServer().
|
staticprotected |
converts server-id to text Converts content of server-id option to a text representation, e.g.
"192.0.2.1"
opt | option that contains server-id |
Definition at line 2033 of file dhcp4_srv.cc.
References isc_throw.
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 5056 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().
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 5068 of file dhcp4_srv.cc.
References isc::dhcp::D2ClientMgr::ddnsEnabled(), isc::dhcp::CfgMgr::getD2ClientMgr(), isc::dhcp::CfgMgr::instance(), isc::dhcp::D2ClientMgr::stop(), and isc::dhcp::D2ClientMgr::stopSender().
Referenced by ~Dhcpv4Srv().
|
inline |
Return bool value indicating that broadcast flags should be set on sockets.
Definition at line 464 of file dhcp4_srv.h.
References use_bcast_.
Referenced by isc::dhcp::ControlledDhcpv4Srv::processConfig().
|
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 1279 of file dhcp4_srv.h.
Referenced by Dhcpv4Srv(), assignLease(), earlyGHRLookup(), processDiscover(), processInform(), and processRequest().
|
protected |
Controls access to the configuration backends.
Definition at line 1289 of file dhcp4_srv.h.
Referenced by getCBControl().
|
protected |
UDP port number to which server sends all responses.
Definition at line 1269 of file dhcp4_srv.h.
Referenced by adjustIfaceData().
|
protected |
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
Definition at line 1286 of file dhcp4_srv.h.
Referenced by getNetworkState(), and runOne().
|
protected |
UDP port number on which server listens.
Definition at line 1266 of file dhcp4_srv.h.
Referenced by adjustIfaceData(), getServerPort(), inTestMode(), and run().
|
protected |
Indicates if shutdown is in progress.
Setting it to true will initiate server shutdown procedure.
Definition at line 1273 of file dhcp4_srv.h.
Referenced by Dhcpv4Srv(), run(), and shutdown().
|
protected |
Should broadcast be enabled on sockets (if true).
Definition at line 1282 of file dhcp4_srv.h.
Referenced by useBroadcast().
|
static |
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 933 of file dhcp4_srv.h.
Referenced by isc::dhcp::Dhcpv4Exchange::classifyByVendor().