![]() |
Kea
1.5.0
|
Controlled version of the DHCPv4 server. More...
#include <ctrl_dhcp4_srv.h>
Inheritance diagram for isc::dhcp::ControlledDhcpv4Srv:Public Member Functions | |
| ControlledDhcpv4Srv (uint16_t port=DHCP4_SERVER_PORT) | |
| Constructor. More... | |
| ~ControlledDhcpv4Srv () | |
| Destructor. More... | |
| isc::data::ConstElementPtr | checkConfig (isc::data::ConstElementPtr new_config) |
| Configuration checker. More... | |
| void | cleanup () |
| Performs cleanup, immediately before termination. More... | |
| void | init (const std::string &config_file) |
| Initializes the server. More... | |
| isc::data::ConstElementPtr | loadConfigFile (const std::string &file_name) |
| Loads specific config file. More... | |
| void | shutdown () |
| Initiates shutdown procedure for the whole DHCPv4 server. More... | |
Public Member Functions inherited from isc::dhcp::Dhcpv4Srv | |
| 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... | |
| asiolink::IOServicePtr & | getIOService () |
| Returns pointer to the IO service used by the server. More... | |
| NetworkStatePtr & | getNetworkState () |
| 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... | |
| 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... | |
| 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... | |
| virtual void | d2ClientErrorHandler (const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr) |
| Implements the error handler for DHCP_DDNS IO errors. More... | |
| void | discardPackets () |
| Discard all in-progress packets. More... | |
| void | declineLease (const Lease4Ptr &lease, const Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context) |
| Marks lease as declined. More... | |
| void | classifyByVendor (const Pkt4Ptr &pkt) |
| Assign class using vendor-class-identifier option. 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... | |
| 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 ControlledDhcpv4Srv * | getInstance () |
| Returns pointer to the sole instance of Dhcpv4Srv. More... | |
| static isc::data::ConstElementPtr | processCommand (const std::string &command, isc::data::ConstElementPtr args) |
| Command processor. More... | |
| static isc::data::ConstElementPtr | processConfig (isc::data::ConstElementPtr new_config) |
| Configuration processor. More... | |
Static Public Member Functions inherited from isc::dhcp::Dhcpv4Srv | |
| static std::string | getVersion (bool extended) |
| returns Kea version on stdout and exit. More... | |
| static void | evaluateClasses (const Pkt4Ptr &pkt, bool depend_on_known) |
| Evaluate classes. 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 int | getHookIndexBuffer4Receive () |
| Returns the index for "buffer4_receive" hook point. More... | |
| static int | getHookIndexPkt4Receive () |
| Returns the index for "pkt4_receive" hook point. More... | |
| static int | getHookIndexSubnet4Select () |
| Returns the index for "subnet4_select" hook point. More... | |
| static int | getHookIndexLease4Release () |
| Returns the index for "lease4_release" hook point. More... | |
| static int | getHookIndexPkt4Send () |
| Returns the index for "pkt4_send" 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 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... | |
Additional Inherited Members | |
Public Types inherited from isc::dhcp::Dhcpv4Srv | |
| enum | RequirementLevel { FORBIDDEN, MANDATORY, OPTIONAL } |
| defines if certain option may, must or must not appear More... | |
Protected Member Functions inherited from isc::dhcp::Dhcpv4Srv | |
| 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... | |
| Pkt4Ptr | processDiscover (Pkt4Ptr &discover) |
| Processes incoming DISCOVER and returns response. More... | |
| Pkt4Ptr | processRequest (Pkt4Ptr &request, AllocEngine::ClientContext4Ptr &context) |
| Processes incoming REQUEST and returns REPLY response. More... | |
| void | processRelease (Pkt4Ptr &release, AllocEngine::ClientContext4Ptr &context) |
| Processes incoming DHCPRELEASE messages. More... | |
| void | processDecline (Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context) |
| Process incoming DHCPDECLINE messages. More... | |
| Pkt4Ptr | processInform (Pkt4Ptr &inform) |
| Processes incoming DHCPINFORM messages. More... | |
| void | buildCfgOptionList (Dhcpv4Exchange &ex) |
| Build the configured option list. 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 | appendBasicOptions (Dhcpv4Exchange &ex) |
| Append basic options if they are not present. More... | |
| void | setFixedFields (Dhcpv4Exchange &ex) |
| Sets fixed fields of the outgoing packet. More... | |
| void | processClientName (Dhcpv4Exchange &ex) |
| Processes Client FQDN and Hostname Options sent by a client. More... | |
| void | createNameChangeRequests (const Lease4Ptr &lease, const Lease4Ptr &old_lease) |
| Creates NameChangeRequests which correspond to the lease which has been acquired. More... | |
| void | renewLease (const Pkt4Ptr &renew, Pkt4Ptr &reply) |
| Attempts to renew received addresses. 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 Pkt4Ptr | receivePacket (int timeout) |
| dummy wrapper around IfaceMgr::receive4 More... | |
| virtual void | sendPacket (const Pkt4Ptr &pkt) |
| dummy wrapper around IfaceMgr::send() More... | |
| void | classifyPacket (const Pkt4Ptr &pkt) |
| Assigns incoming packet to zero or more classes. More... | |
| void | requiredClassify (Dhcpv4Exchange &ex) |
| Assigns incoming packet to zero or more classes (required pass). More... | |
| void | deferredUnpack (Pkt4Ptr &query) |
| Perform deferred option unpacking. More... | |
| void | processPacketPktSend (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp) |
| Executes pkt4_send callout. More... | |
| void | processPacketBufferSend (hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &rsp) |
| Executes buffer4_send callout and sends the response. 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 inherited from isc::dhcp::Dhcpv4Srv | |
| static void | sanityCheck (const Pkt4Ptr &query, RequirementLevel serverid) |
| Verifies if specified packet meets RFC requirements. 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 | 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 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 inherited from isc::dhcp::Dhcpv4Srv | |
| volatile bool | shutdown_ |
| indicates if shutdown is in progress. More... | |
| boost::shared_ptr< AllocEngine > | alloc_engine_ |
| Allocation Engine. More... | |
| NetworkStatePtr | network_state_ |
| Holds information about disabled DHCP service and/or disabled subnet/network scopes. 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 inherited from isc::dhcp::Dhcpv4Srv | |
| static const std::string | VENDOR_CLASS_PREFIX |
| this is a prefix added to the content of vendor-class option More... | |
Controlled version of the DHCPv4 server.
This is a class that is responsible for DHCPv4 server being controllable, by reading configuration file from disk.
Definition at line 25 of file ctrl_dhcp4_srv.h.
| isc::dhcp::ControlledDhcpv4Srv::ControlledDhcpv4Srv | ( | uint16_t | port = DHCP4_SERVER_PORT | ) |
Constructor.
| port | UDP port to be opened for DHCP traffic |
Definition at line 718 of file ctrl_dhcp4_srv.cc.
References getInstance(), isc::dhcp::Dhcpv4Srv::getIOService(), isc::dhcp::TimerMgr::instance(), and isc_throw.
Here is the call graph for this function:| isc::dhcp::ControlledDhcpv4Srv::~ControlledDhcpv4Srv | ( | ) |
Destructor.
Definition at line 796 of file ctrl_dhcp4_srv.cc.
References cleanup().
Here is the call graph for this function:| isc::data::ConstElementPtr isc::dhcp::ControlledDhcpv4Srv::checkConfig | ( | isc::data::ConstElementPtr | new_config | ) |
Configuration checker.
This is a method for checking incoming configuration.
| new_config | JSON representation of the new configuration |
Definition at line 700 of file ctrl_dhcp4_srv.cc.
References isc::dhcp::configureDhcp4Server(), isc::config::createAnswer(), isc::dhcp::DBG_DHCP4_COMMAND, isc::dhcp::dhcp4_logger, and LOG_DEBUG.
Here is the call graph for this function:
|
virtual |
Performs cleanup, immediately before termination.
This method performs final clean up, just before the Dhcpv4Srv object is destroyed. Currently it is a no-op.
Reimplemented from isc::process::Daemon.
Definition at line 103 of file ctrl_dhcp4_srv.cc.
Referenced by ~ControlledDhcpv4Srv().
|
inlinestatic |
Returns pointer to the sole instance of Dhcpv4Srv.
Definition at line 118 of file ctrl_dhcp4_srv.h.
Referenced by ControlledDhcpv4Srv(), and isc::dhcp::Dhcp4to6Ipc::handler().
| void isc::dhcp::ControlledDhcpv4Srv::init | ( | const std::string & | config_file | ) |
Initializes the server.
It reads the JSON file from disk or may perform any other setup operation. In particular, it also install signal handlers.
This method may throw if initialization fails.
Definition at line 80 of file ctrl_dhcp4_srv.cc.
References isc_throw, and isc::config::parseAnswer().
Here is the call graph for this function:| ConstElementPtr isc::dhcp::ControlledDhcpv4Srv::loadConfigFile | ( | const std::string & | file_name | ) |
Loads specific config file.
Configure DHCPv4 server using the configuration file specified.
This utility method is called whenever we know a filename of the config and need to load it. It calls config-set command once the content of the file has been loaded and verified to be a sane JSON configuration. config-set handler will process the config file (load it as current configuration).
| file_name | name of the file to be loaded |
This function is used to both configure the DHCP server on its startup and dynamically reconfigure the server when SIGHUP signal is received.
It fetches DHCPv4 server's configuration from the 'Dhcp4' section of the JSON configuration file.
| file_name | Configuration file location. |
Definition at line 118 of file ctrl_dhcp4_srv.cc.
References isc::dhcp::dhcp4_logger, isc_throw, LOG_ERROR, isc::asiodns::logger, isc::data::Element::map, isc::config::parseAnswer(), isc::dhcp::Parser4Context::parseFile(), and isc::Exception::what().
Here is the call graph for this function:
|
static |
Command processor.
This method is uniform for all config backends. It processes received command (as a string + JSON arguments). Internally, it's just a wrapper that calls process*Command() methods and catches exceptions in them.
Currently supported commands are:
| command | Text representation of the command (e.g. "shutdown") |
| args | Optional parameters |
Definition at line 511 of file ctrl_dhcp4_srv.cc.
References isc::config::createAnswer(), isc::dhcp::DBG_DHCP4_COMMAND, isc::dhcp::dhcp4_logger, LOG_DEBUG, and isc::Exception::what().
Here is the call graph for this function:
|
static |
Configuration processor.
This is a method for handling incoming configuration updates. This method should be called by all configuration backends when the server is starting up or when configuration has changed.
As pointer to this method is used a callback in ASIO used in ModuleCCSession, it has to be static.
| new_config | textual representation of the new configuration |
Definition at line 576 of file ctrl_dhcp4_srv.cc.
References isc::dhcp::configureDhcp4Server(), isc::config::createAnswer(), isc::dhcp::DBG_DHCP4_COMMAND, isc::dhcp::dhcp4_logger, isc::dhcp::Dhcpv4Srv::getIOService(), isc::dhcp::Dhcpv4Srv::getNetworkState(), isc::dhcp::Dhcpv4Srv::getPort(), Hooks, LOG_DEBUG, LOG_INFO, isc::config::parseAnswer(), and isc::dhcp::Dhcpv4Srv::startD2().
Here is the call graph for this function:
|
virtual |
Initiates shutdown procedure for the whole DHCPv4 server.
Reimplemented from isc::process::Daemon.
Definition at line 791 of file ctrl_dhcp4_srv.cc.
References isc::dhcp::Dhcpv4Srv::shutdown(), and isc::asiolink::IOService::stop().
Here is the call graph for this function: