12#include <boost/foreach.hpp>
22IfacesConfigParser::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() <<
")");
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);
64 if (element.first ==
"dhcp-socket-type") {
65 if (protocol_ == AF_INET) {
66 cfg->useSocketType(AF_INET, element.second->stringValue());
67 socket_type_specified =
true;
71 "dhcp-socket-type is not supported in DHCPv6");
75 if (element.first ==
"outbound-interface") {
76 if (protocol_ == AF_INET) {
79 cfg->setOutboundIface(type);
83 "outbound-interface is not supported in DHCPv6");
87 if (element.first ==
"service-sockets-require-all") {
88 cfg->setServiceSocketsRequireAll(element.second->boolValue());
92 if (element.first ==
"service-sockets-retry-wait-time") {
93 cfg->setServiceSocketsRetryWaitTime(
static_cast<uint32_t
>(element.second->intValue()));
97 if (element.first ==
"service-sockets-max-retries") {
98 cfg->setServiceSocketsMaxRetries(
static_cast<uint32_t
>(element.second->intValue()));
102 if (element.first ==
"user-context") {
103 cfg->setContext(element.second);
112 << element.first <<
"'");
113 }
catch (
const std::exception& ex) {
116 << element.second->getPosition() <<
")");
123 if (!socket_type_specified && (protocol_ == AF_INET) ) {
125 .arg(cfg->socketTypeToText());
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
OutboundIface
Indicates how outbound interface is selected for relayed traffic.
static OutboundIface textToOutboundIface(const std::string &txt)
Converts text to outbound interface selection mode.
To be removed. Please use ConfigError instead.
void clearIfaces()
Removes detected interfaces.
void detectIfaces(bool update_only=false)
Detects network interfaces.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
void parse(const CfgIfacePtr &config, const isc::data::ConstElementPtr &values)
Parses content of the "interfaces-config".
IfacesConfigParser(const uint16_t protocol, bool test_mode)
Constructor.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
boost::shared_ptr< const Element > ConstElementPtr
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
std::pair< std::string, isc::data::ConstElementPtr > ConfigPair
Combination of parameter name and configuration contents.
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
const isc::log::MessageID DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT
Defines the logger used by the top-level component of kea-lfc.