Kea
1.9.9-git
|
Controlled version of the DHCPv6 server. More...
#include <ctrl_dhcp6_srv.h>
Public Member Functions | |
ControlledDhcpv6Srv (uint16_t server_port=DHCP6_SERVER_PORT, uint16_t client_port=0) | |
Constructor. More... | |
virtual | ~ControlledDhcpv6Srv () |
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) |
Configure DHCPv6 server using the configuration file specified. More... | |
virtual void | shutdownServer (int exit_value) |
Initiates shutdown procedure for the whole DHCPv6 server. More... | |
Public Member Functions inherited from isc::dhcp::Dhcpv6Srv | |
Dhcpv6Srv (uint16_t server_port=DHCP6_SERVER_PORT, uint16_t client_port=0) | |
Default constructor. More... | |
virtual | ~Dhcpv6Srv () |
Destructor. Used during DHCPv6 service shutdown. More... | |
void | classifyByVendor (const Pkt6Ptr &pkt, std::string &classes) |
Assign class using vendor-class-identifier option. More... | |
virtual void | d2ClientErrorHandler (const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr) |
Implements the error handler for DHCP_DDNS IO errors. More... | |
void | discardPackets () |
Discards parked packets Clears the packet parking lots of all packets. More... | |
CBControlDHCPv6Ptr | getCBControl () const |
Returns an object which controls access to the configuration backends. 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... | |
OptionPtr | getServerID () |
Returns server-identifier option. More... | |
bool | inTestMode () const |
Checks if the server is running in unit test mode. More... | |
std::list< std::list< std::string > > | jsonPathsToRedact () const finaloverride |
Return a list of all paths that contain passwords or secrets for kea-dhcp6. More... | |
void | processDhcp6Query (Pkt6Ptr &query, Pkt6Ptr &rsp) |
Process a single incoming DHCPv6 query. More... | |
void | processDhcp6QueryAndSendResponse (Pkt6Ptr &query, Pkt6Ptr &rsp) |
Process a single incoming DHCPv6 query. More... | |
void | processPacket (Pkt6Ptr &query, Pkt6Ptr &rsp) |
Process a single incoming DHCPv6 packet. More... | |
void | processPacketAndSendResponse (Pkt6Ptr &query) |
Process a single incoming DHCPv6 packet and sends the response. More... | |
void | processPacketAndSendResponseNoThrow (Pkt6Ptr &query) |
Process a single incoming DHCPv6 packet and sends the response. More... | |
void | processPacketBufferSend (hooks::CalloutHandlePtr &callout_handle, Pkt6Ptr &rsp) |
Executes buffer6_send callout and sends the response. More... | |
int | run () |
Main server processing loop. More... | |
void | run_one () |
Main server processing step. More... | |
void | sendResponseNoThrow (hooks::CalloutHandlePtr &callout_handle, Pkt6Ptr &query, Pkt6Ptr &rsp) |
Process an unparked DHCPv6 packet and sends the response. More... | |
void | shutdown () override |
Instructs the server to shut down. More... | |
void | startD2 () |
Starts DHCP_DDNS client IO if DDNS updates are enabled. More... | |
void | stopD2 () |
Stops DHCP_DDNS client IO if DDNS updates are enabled. More... | |
uint16_t | getServerPort () const |
Get UDP port on which server should listen. 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... | |
int | getExitValue () |
Fetches the exit value. 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... | |
isc::data::ConstElementPtr | redactConfig (isc::data::ConstElementPtr const &config) |
Redact a configuration. More... | |
void | setConfigFile (const std::string &config_file) |
Sets the configuration file name. More... | |
void | setExitValue (int value) |
Sets the exit value. 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... | |
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 ControlledDhcpv6Srv * | getInstance () |
Returns pointer to the sole instance of Dhcpv6Srv. 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::Dhcpv6Srv | |
static uint16_t | checkRelaySourcePort (const Pkt6Ptr &query) |
Used for DHCPv4-over-DHCPv6 too. More... | |
static int | getHookIndexBuffer6Send () |
Returns the index of the buffer6_send hook. More... | |
static std::string | getVersion (bool extended) |
returns Kea version on stdout and exit. More... | |
static void | processStatsSent (const Pkt6Ptr &response) |
Updates statistics for transmitted packets. More... | |
Static Public Member Functions inherited from isc::process::Daemon | |
static void | configureLogger (const isc::data::ConstElementPtr &log_config, const isc::process::ConfigPtr &storage) |
Configures logger. More... | |
static std::string | getDefaultLoggerName () |
Returns default logger name. More... | |
static std::string | getProcName () |
returns the process name This value is used as when forming the default PID file 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 | setProcName (const std::string &proc_name) |
Sets the process name. More... | |
static void | setVerbose (const bool verbose) |
Sets or clears verbose mode. More... | |
Additional Inherited Members | |
Public Types inherited from isc::dhcp::Dhcpv6Srv | |
enum | RequirementLevel { FORBIDDEN, MANDATORY, OPTIONAL } |
defines if certain option may, must or must not appear More... | |
Static Public Attributes inherited from isc::dhcp::Dhcpv6Srv | |
static const size_t | MIN_MAC_LEN = 6 |
Minimum length of a MAC address to be used in DUID generation. More... | |
Protected Member Functions inherited from isc::dhcp::Dhcpv6Srv | |
void | appendDefaultOptions (const Pkt6Ptr &question, Pkt6Ptr &answer, const CfgOptionList &co_list) |
Appends default options to server's answer. More... | |
void | appendRequestedOptions (const Pkt6Ptr &question, Pkt6Ptr &answer, const CfgOptionList &co_list) |
Appends requested options to server's answer. More... | |
void | appendRequestedVendorOptions (const Pkt6Ptr &question, Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx, const CfgOptionList &co_list) |
Appends requested vendor options to server's answer. More... | |
OptionPtr | assignIA_NA (const isc::dhcp::Pkt6Ptr &query, const isc::dhcp::Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx, Option6IAPtr ia) |
Processes IA_NA option (and assigns addresses if necessary). More... | |
OptionPtr | assignIA_PD (const Pkt6Ptr &query, const isc::dhcp::Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx, boost::shared_ptr< Option6IA > ia) |
Processes IA_PD option (and assigns prefixes if necessary). More... | |
void | assignLeases (const Pkt6Ptr &question, Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx) |
Assigns leases. More... | |
void | buildCfgOptionList (const Pkt6Ptr &question, AllocEngine::ClientContext6 &ctx, CfgOptionList &co_list) |
Build the configured option list. More... | |
void | checkDynamicSubnetChange (const Pkt6Ptr &question, Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx, const Subnet6Ptr orig_subnet) |
Iterates over new leases, update stale DNS entries. More... | |
void | classifyPacket (const Pkt6Ptr &pkt) |
Assigns incoming packet to zero or more classes. More... | |
void | conditionallySetReservedClientClasses (const Pkt6Ptr &pkt, const AllocEngine::ClientContext6 &ctx) |
Assigns classes retrieved from host reservation database if they haven't been yet set. More... | |
void | copyClientOptions (const Pkt6Ptr &question, Pkt6Ptr &answer) |
Copies required options from client message to server answer. More... | |
void | createNameChangeRequests (const Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx) |
Creates a number of isc::dhcp_ddns::NameChangeRequest objects based on the DHCPv6 Client FQDN Option. More... | |
OptionPtr | declineIA (const Pkt6Ptr &decline, const DuidPtr &duid, int &general_status, boost::shared_ptr< Option6IA > ia, Lease6Collection &new_leases) |
Declines leases in a single IA_NA option. More... | |
bool | declineLease (const Pkt6Ptr &decline, const Lease6Ptr lease, boost::shared_ptr< Option6IA > ia_rsp) |
Declines specific IPv6 lease. More... | |
bool | declineLeases (const Pkt6Ptr &decline, Pkt6Ptr &reply, AllocEngine::ClientContext6 &ctx) |
Attempts to decline all leases in specified Decline message. More... | |
void | evaluateClasses (const Pkt6Ptr &pkt, bool depend_on_known) |
Evaluate classes. More... | |
OptionPtr | extendIA_NA (const Pkt6Ptr &query, const Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx, Option6IAPtr ia) |
Extends lifetime of the specific IA_NA option. More... | |
OptionPtr | extendIA_PD (const Pkt6Ptr &query, AllocEngine::ClientContext6 &ctx, Option6IAPtr ia) |
Extends lifetime of the prefix. More... | |
void | extendLeases (const Pkt6Ptr &query, Pkt6Ptr &reply, AllocEngine::ClientContext6 &ctx) |
Attempts to extend the lifetime of IAs. More... | |
void | initContext (const Pkt6Ptr &pkt, AllocEngine::ClientContext6 &ctx, bool &drop) |
Initializes client context for specified packet. More... | |
void | processClientFqdn (const Pkt6Ptr &question, const Pkt6Ptr &answer, AllocEngine::ClientContext6 &ctx) |
Processes Client FQDN Option. More... | |
Pkt6Ptr | processConfirm (AllocEngine::ClientContext6 &ctx) |
Processes incoming Confirm message and returns Reply. More... | |
Pkt6Ptr | processDecline (AllocEngine::ClientContext6 &ctx) |
Process incoming Decline message. More... | |
void | processDhcp4Query (const Pkt6Ptr &dhcp4_query) |
Processes incoming DHCPv4-query message. More... | |
Pkt6Ptr | processInfRequest (AllocEngine::ClientContext6 &ctx) |
Processes incoming Information-request message. More... | |
void | processPacketPktSend (hooks::CalloutHandlePtr &callout_handle, Pkt6Ptr &query, Pkt6Ptr &rsp) |
Executes pkt6_send callout. More... | |
Pkt6Ptr | processRebind (AllocEngine::ClientContext6 &ctx) |
Processes incoming Rebind message. More... | |
Pkt6Ptr | processRelease (AllocEngine::ClientContext6 &ctx) |
Process incoming Release message. More... | |
Pkt6Ptr | processRenew (AllocEngine::ClientContext6 &ctx) |
Processes incoming Renew message. More... | |
Pkt6Ptr | processRequest (AllocEngine::ClientContext6 &ctx) |
Processes incoming Request and returns Reply response. More... | |
void | processRSOO (const Pkt6Ptr &query, const Pkt6Ptr &rsp) |
Processes Relay-supplied options, if present. More... | |
Pkt6Ptr | processSolicit (AllocEngine::ClientContext6 &ctx) |
Processes incoming Solicit and returns response. More... | |
virtual Pkt6Ptr | receivePacket (int timeout) |
dummy wrapper around IfaceMgr::receive6 More... | |
OptionPtr | releaseIA_NA (const DuidPtr &duid, const Pkt6Ptr &query, int &general_status, boost::shared_ptr< Option6IA > ia, Lease6Ptr &old_lease) |
Releases specific IA_NA option. More... | |
OptionPtr | releaseIA_PD (const DuidPtr &duid, const Pkt6Ptr &query, int &general_status, boost::shared_ptr< Option6IA > ia, Lease6Ptr &old_lease) |
Releases specific IA_PD option. More... | |
void | releaseLeases (const Pkt6Ptr &release, Pkt6Ptr &reply, AllocEngine::ClientContext6 &ctx) |
Attempts to release received addresses. More... | |
void | requiredClassify (const Pkt6Ptr &pkt, AllocEngine::ClientContext6 &ctx) |
Assigns incoming packet to zero or more classes (required pass). More... | |
bool | sanityCheck (const Pkt6Ptr &pkt) |
Verifies if specified packet meets RFC requirements. More... | |
void | sanityCheck (const Pkt6Ptr &pkt, RequirementLevel clientid, RequirementLevel serverid) |
verifies if specified packet meets RFC requirements More... | |
void | sanityCheckDUID (const OptionPtr &opt, const std::string &opt_name) |
verifies if received DUID option (client-id or server-id) is sane More... | |
isc::dhcp::Subnet6Ptr | selectSubnet (const Pkt6Ptr &question, bool &drop) |
Selects a subnet for a given client's packet. More... | |
virtual void | sendPacket (const Pkt6Ptr &pkt) |
dummy wrapper around IfaceMgr::send() More... | |
void | setPacketStatisticsDefaults () |
This function sets statistics related to DHCPv6 packets processing to their initial values. More... | |
void | setReservedClientClasses (const Pkt6Ptr &pkt, const AllocEngine::ClientContext6 &ctx) |
Assigns classes retrieved from host reservation database. More... | |
void | setStatusCode (boost::shared_ptr< Option6IA > &container, const OptionPtr &status) |
A simple utility method that sets the status code. More... | |
void | setTeeTimes (uint32_t preferred_lft, const Subnet6Ptr &subnet, Option6IAPtr &resp) |
Sets the T1 and T2 timers in the outbound IA. More... | |
bool | testServerID (const Pkt6Ptr &pkt) |
Compare received server id with our server id. More... | |
bool | testUnicast (const Pkt6Ptr &pkt) const |
Check if the message can be sent to unicast. More... | |
Protected Member Functions inherited from isc::process::Daemon | |
std::string | makePIDFileName () const |
Manufacture the pid file name. More... | |
Static Protected Member Functions inherited from isc::dhcp::Dhcpv6Srv | |
static std::string | duidToString (const OptionPtr &opt) |
converts DUID to text Converts content of DUID option to a text representation, e.g. More... | |
static HWAddrPtr | getMAC (const Pkt6Ptr &pkt) |
Attempts to get a MAC/hardware address using configured sources. More... | |
Protected Attributes inherited from isc::dhcp::Dhcpv6Srv | |
boost::shared_ptr< AllocEngine > | alloc_engine_ |
Allocation Engine. More... | |
CBControlDHCPv6Ptr | cb_control_ |
Controls access to the configuration backends. More... | |
uint16_t | client_port_ |
UDP port number to which server sends all responses. More... | |
std::queue< isc::dhcp_ddns::NameChangeRequest > | name_change_reqs_ |
Holds a list of isc::dhcp_ddns::NameChangeRequest objects, which are waiting for sending to kea-dhcp-ddns module. More... | |
NetworkStatePtr | network_state_ |
Holds information about disabled DHCP service and/or disabled subnet/network scopes. More... | |
uint16_t | server_port_ |
UDP port number on which server listens. More... | |
OptionPtr | serverid_ |
Server DUID (to be sent in server-identifier option) More... | |
volatile bool | shutdown_ |
Indicates if shutdown is in progress. More... | |
Protected Attributes inherited from isc::process::Daemon | |
isc::asiolink::IOSignalSetPtr | signal_set_ |
A pointer to the object installing custom signal handlers. More... | |
boost::posix_time::ptime | start_ |
Timestamp of the start of the daemon. More... | |
Static Protected Attributes inherited from isc::dhcp::Dhcpv6Srv | |
static const std::string | VENDOR_CLASS_PREFIX |
this is a prefix added to the content of vendor-class option More... | |
Controlled version of the DHCPv6 server.
This is a class that is responsible for DHCPv6 server being controllable, by reading configuration file from disk.
Definition at line 25 of file ctrl_dhcp6_srv.h.
isc::dhcp::ControlledDhcpv6Srv::ControlledDhcpv6Srv | ( | uint16_t | server_port = DHCP6_SERVER_PORT , |
uint16_t | client_port = 0 |
||
) |
Constructor.
server_port | UDP port to be opened for DHCP traffic |
client_port | UDP port where all responses are sent to. |
Definition at line 1067 of file ctrl_dhcp6_srv.cc.
References getInstance(), isc::dhcp::Dhcpv6Srv::getIOService(), isc::dhcp::TimerMgr::instance(), isc_throw, isc::dhcp::HostMgr::setIOService(), and isc::dhcp::LeaseMgr::setIOService().
|
virtual |
Destructor.
Definition at line 1173 of file ctrl_dhcp6_srv.cc.
References cleanup(), isc::dhcp::HostMgr::create(), isc::db::DatabaseConnection::db_failed_callback_, isc::db::DatabaseConnection::db_lost_callback_, isc::db::DatabaseConnection::db_recovered_callback_, isc::dhcp::LeaseMgrFactory::destroy(), isc::dhcp::HostMgr::setIOService(), and isc::dhcp::LeaseMgr::setIOService().
isc::data::ConstElementPtr isc::dhcp::ControlledDhcpv6Srv::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 1051 of file ctrl_dhcp6_srv.cc.
References isc::dhcp::configureDhcp6Server(), isc::config::createAnswer(), isc::dhcp::DBG_DHCP6_COMMAND, isc::dhcp::DHCP6_CONFIG_RECEIVED, isc::dhcp::dhcp6_logger, LOG_DEBUG, and isc::process::redactConfig().
|
virtual |
Performs cleanup, immediately before termination.
This method performs final clean up, just before the Dhcpv6Srv object is destroyed. Currently it is a no-op.
Reimplemented from isc::process::Daemon.
Definition at line 196 of file ctrl_dhcp6_srv.cc.
Referenced by ~ControlledDhcpv6Srv().
|
inlinestatic |
Returns pointer to the sole instance of Dhcpv6Srv.
Definition at line 127 of file ctrl_dhcp6_srv.h.
Referenced by ControlledDhcpv6Srv().
void isc::dhcp::ControlledDhcpv6Srv::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 167 of file ctrl_dhcp6_srv.cc.
References isc::config::CONTROL_RESULT_SUCCESS, isc_throw, and isc::config::parseAnswer().
Referenced by main().
ConstElementPtr isc::dhcp::ControlledDhcpv6Srv::loadConfigFile | ( | const std::string & | file_name | ) |
Configure DHCPv6 server using the configuration file specified.
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 DHCPv6 server's configuration from the 'Dhcp6' section of the JSON configuration file.
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 (apply it as current configuration).
file_name | name of the file to be loaded |
Definition at line 95 of file ctrl_dhcp6_srv.cc.
References isc::config::CONTROL_RESULT_SUCCESS, isc::dhcp::DHCP6_CONFIG_LOAD_FAIL, isc::dhcp::dhcp6_logger, isc::dhcp::DHCP6_MULTI_THREADING_INFO, isc_throw, LOG_ERROR, LOG_WARN, isc::data::Element::map, isc::config::parseAnswer(), isc::dhcp::Parser6Context::parseFile(), and isc::Exception::what().
|
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 781 of file ctrl_dhcp6_srv.cc.
References isc::config::createAnswer(), isc::dhcp::DBG_DHCP6_COMMAND, isc::dhcp::DHCP6_COMMAND_RECEIVED, isc::dhcp::dhcp6_logger, LOG_DEBUG, and isc::Exception::what().
|
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 855 of file ctrl_dhcp6_srv.cc.
References isc::dhcp::configureDhcp6Server(), isc::config::CONTROL_RESULT_ERROR, isc::config::createAnswer(), D6O_SERVERID, isc::dhcp::DBG_DHCP6_COMMAND, isc::dhcp::DHCP6_CONFIG_PACKET_QUEUE, isc::dhcp::DHCP6_CONFIG_RECEIVED, isc::dhcp::dhcp6_logger, isc::dhcp::DHCP6_USING_SERVERID, isc::dhcp::Dhcpv6Srv::getIOService(), isc::dhcp::Dhcpv6Srv::getNetworkState(), isc::dhcp::Dhcpv6Srv::getServerPort(), LOG_DEBUG, LOG_INFO, isc::asiolink::IntervalTimer::ONE_SHOT, isc::config::parseAnswer(), isc::process::Daemon::redactConfig(), and isc::dhcp::Dhcpv6Srv::startD2().
|
virtual |
Initiates shutdown procedure for the whole DHCPv6 server.
exit_value | integer value to the process should exit with. |
Definition at line 1167 of file ctrl_dhcp6_srv.cc.
References isc::dhcp::Dhcpv6Srv::getIOService(), isc::process::Daemon::setExitValue(), and isc::dhcp::Dhcpv6Srv::shutdown().