12 #include <boost/foreach.hpp>
14 #include <sys/types.h>
22 IfacesConfigParser::parseInterfacesList(
const CfgIfacePtr& cfg_iface,
25 std::string iface_name = iface->stringValue();
27 cfg_iface->use(protocol_, iface_name);
29 }
catch (
const std::exception& ex) {
30 isc_throw(DhcpConfigError,
"Failed to select interface: "
31 << ex.what() <<
" (" << iface->getPosition() <<
")");
36 IfacesConfigParser::IfacesConfigParser(
const uint16_t protocol,
bool test_mode)
37 : protocol_(protocol), test_mode_(test_mode) {
45 bool re_detect =
getBoolean(ifaces_config,
"re-detect");
46 cfg->setReDetect(re_detect);
47 if (re_detect && !test_mode_) {
52 bool socket_type_specified =
false;
53 BOOST_FOREACH(
ConfigPair element, ifaces_config->mapValue()) {
55 if (element.first ==
"re-detect") {
59 if (element.first ==
"interfaces") {
60 parseInterfacesList(cfg, element.second);
65 if (element.first ==
"dhcp-socket-type") {
66 if (protocol_ == AF_INET) {
67 cfg->useSocketType(AF_INET, element.second->stringValue());
68 socket_type_specified =
true;
72 "dhcp-socket-type is not supported in DHCPv6");
76 if (element.first ==
"outbound-interface") {
77 if (protocol_ == AF_INET) {
80 cfg->setOutboundIface(type);
84 "outbound-interface is not supported in DHCPv6");
88 if (element.first ==
"user-context") {
89 cfg->setContext(element.second);
98 << element.first <<
"'");
99 }
catch (
const std::exception& ex) {
102 << element.second->getPosition() <<
")");
109 if (!socket_type_specified && (protocol_ == AF_INET) ) {
111 .arg(cfg->socketTypeToText());
void clearIfaces()
Removes detected interfaces.
std::pair< std::string, isc::data::ConstElementPtr > ConfigPair
Combination of parameter name and configuration contents.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
static OutboundIface textToOutboundIface(const std::string &txt)
Converts text to outbound interface selection mode.
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
To be removed. Please use ConfigError instead.
boost::shared_ptr< const Element > ConstElementPtr
void parse(const CfgIfacePtr &config, const isc::data::ConstElementPtr &values)
Parses content of the "interfaces-config".
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-dhcp-ddns.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
void detectIfaces()
Detects network interfaces.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT
OutboundIface
Indicates how outbound interface is selected for relayed traffic.