19 #include <boost/pointer_cast.hpp>
29 SharedNetwork4Parser::SharedNetwork4Parser(
bool check_iface)
30 : check_iface_(check_iface) {
44 std::string name =
getString(shared_network_data,
"name");
49 mutable_params = boost::const_pointer_cast<
Element>(shared_network_data);
57 if (shared_network_data->contains(
"interface")) {
58 std::string iface =
getString(shared_network_data,
"interface");
62 shared_network_data->get(
"interface");
64 "Specified network interface name " << iface
65 <<
" for shared network " << name
66 <<
" is not present in the system ("
67 << error->getPosition() <<
")");
69 shared_network->setIface(iface);
73 if (shared_network_data->contains(
"option-data")) {
74 auto json = shared_network_data->get(
"option-data");
76 CfgOptionPtr cfg_option = shared_network->getCfgOption();
78 parser.
parse(cfg_option, json);
81 if (shared_network_data->contains(
"subnet4")) {
82 auto json = shared_network_data->get(
"subnet4");
87 parser.
parse(subnets, json);
90 for (
auto subnet = subnets.cbegin(); subnet != subnets.cend();
92 shared_network->add(*subnet);
96 if (shared_network_data->contains(
"match-client-id")) {
97 shared_network->setMatchClientId(
getBoolean(shared_network_data,
101 if (shared_network_data->contains(
"authoritative")) {
102 shared_network->setAuthoritative(
getBoolean(shared_network_data,
107 if (shared_network_data->contains(
"next-server")) {
108 std::string next_server;
110 next_server =
getString(shared_network_data,
"next-server");
111 if (!next_server.empty()) {
112 shared_network->setSiaddr(
IOAddress(next_server));
118 pos = next->getPosition().str();
120 pos = shared_network_data->getPosition().str();
123 << next_server <<
"(" << pos <<
")");
128 if (shared_network_data->contains(
"server-hostname")) {
129 std::string sname =
getString(shared_network_data,
"server-hostname");
130 if (!sname.empty()) {
135 << sname.length() <<
" ("
136 << error->getPosition() <<
")");
138 shared_network->setSname(sname);
143 if (shared_network_data->contains(
"boot-file-name")) {
144 std::string filename =
getString(shared_network_data,
"boot-file-name");
145 if (!filename.empty()) {
150 << filename.length() <<
" ("
151 << error->getPosition() <<
")");
153 shared_network->setFilename(filename);
157 if (shared_network_data->contains(
"client-class")) {
158 std::string client_class =
getString(shared_network_data,
"client-class");
159 if (!client_class.empty()) {
160 shared_network->allowClientClass(client_class);
164 ConstElementPtr user_context = shared_network_data->get(
"user-context");
166 shared_network->setContext(user_context);
169 if (shared_network_data->contains(
"require-client-classes")) {
170 const std::vector<data::ElementPtr>& class_list =
171 shared_network_data->get(
"require-client-classes")->listValue();
172 for (
auto cclass = class_list.cbegin();
173 cclass != class_list.cend(); ++cclass) {
174 if (((*cclass)->getType() != Element::string) ||
175 (*cclass)->stringValue().empty()) {
177 << (*cclass)->getPosition() <<
")");
179 shared_network->requireClientClass((*cclass)->stringValue());
183 if (shared_network_data->contains(
"relay")) {
184 auto relay_parms = shared_network_data->get(
"relay");
188 parser.
parse(relay_info, relay_parms);
189 shared_network->setRelayInfo(*relay_info);
203 }
catch (
const std::exception& ex) {
205 << shared_network_data->getPosition() <<
")");
215 return (shared_network);
219 : check_iface_(check_iface) {
229 shared_network_data);
233 std::string name =
getString(shared_network_data,
"name");
238 mutable_params = boost::const_pointer_cast<
Element>(shared_network_data);
247 "preferred-lifetime"));
252 if (shared_network_data->contains(
"interface-id")) {
253 ifaceid =
getString(shared_network_data,
"interface-id");
258 if (shared_network_data->contains(
"interface")) {
259 iface =
getString(shared_network_data,
"interface");
268 "parser error: interface (defined for locally reachable "
269 "subnets) and interface-id (defined for subnets reachable"
270 " via relays) cannot be defined at the same time for "
271 "shared network " << name <<
"("
272 << shared_network_data->getPosition() <<
")");
277 std::string ifaceid_value = ifaceid.
get();
278 OptionBuffer tmp(ifaceid_value.begin(), ifaceid_value.end());
280 shared_network->setInterfaceId(opt);
289 "Specified network interface name " << iface
290 <<
" for shared network " << name
291 <<
" is not present in the system ("
292 << error->getPosition() <<
")");
294 shared_network->setIface(iface);
297 if (shared_network_data->contains(
"rapid-commit")) {
298 shared_network->setRapidCommit(
getBoolean(shared_network_data,
302 if (shared_network_data->contains(
"option-data")) {
303 auto json = shared_network_data->get(
"option-data");
305 CfgOptionPtr cfg_option = shared_network->getCfgOption();
307 parser.
parse(cfg_option, json);
310 if (shared_network_data->contains(
"client-class")) {
311 std::string client_class =
getString(shared_network_data,
"client-class");
312 if (!client_class.empty()) {
313 shared_network->allowClientClass(client_class);
317 ConstElementPtr user_context = shared_network_data->get(
"user-context");
319 shared_network->setContext(user_context);
322 if (shared_network_data->contains(
"require-client-classes")) {
323 const std::vector<data::ElementPtr>& class_list =
324 shared_network_data->get(
"require-client-classes")->listValue();
325 for (
auto cclass = class_list.cbegin();
326 cclass != class_list.cend(); ++cclass) {
327 if (((*cclass)->getType() != Element::string) ||
328 (*cclass)->stringValue().empty()) {
330 << (*cclass)->getPosition() <<
")");
332 shared_network->requireClientClass((*cclass)->stringValue());
336 if (shared_network_data->contains(
"subnet6")) {
337 auto json = shared_network_data->get(
"subnet6");
342 parser.
parse(subnets, json);
345 for (
auto subnet = subnets.cbegin(); subnet != subnets.cend();
347 shared_network->add(*subnet);
351 if (shared_network_data->contains(
"relay")) {
352 auto relay_parms = shared_network_data->get(
"relay");
356 parser.
parse(relay_info, relay_parms);
357 shared_network->setRelayInfo(*relay_info);
368 }
catch (
const std::exception& ex) {
370 << shared_network_data->getPosition() <<
")");
380 return (shared_network);
void parseDdnsParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to DDNS behavior.
static const size_t MAX_SNAME_LEN
length of the SNAME field in DHCPv4 message
IfacePtr getIface(int ifindex)
Returns interface specified interface index.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
void parse(const CfgOptionPtr &cfg, isc::data::ConstElementPtr option_data_list)
Parses a list of options, instantiates them and stores in cfg.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
bool check_iface_
Check if the specified interface exists in the system.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
this class parses a list of DHCP6 subnets
static const isc::data::SimpleKeywords SHARED_NETWORK6_PARAMETERS
This table defines all shared network parameters for DHCPv6.
const dhcp::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
void parseCommon(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses common parameters.
static const size_t MAX_FILE_LEN
length of the FILE field in DHCPv4 message
static CfgMgr & instance()
returns a single instance of Configuration Manager
static const isc::data::SimpleKeywords SHARED_NETWORK4_PARAMETERS
This table defines all shared network parameters for DHCPv4.
boost::shared_ptr< Option > OptionPtr
void parseCacheParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to lease cache settings.
boost::shared_ptr< Element > ElementPtr
bool check_iface_
Check if the specified interface exists in the system.
this class parses list of DHCP4 subnets
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Shared network holding IPv4 subnets.
Holds optional information about relay.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
SharedNetwork6Ptr parse(const data::ConstElementPtr &shared_network_data)
Parses shared configuration information for IPv6 shared network.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID,&Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string,&Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress,&Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime,&data::BaseStampedElement::getModificationTime > > >> Subnet4Collection
A collection of Subnet4 objects.
parser for additional relay information
To be removed. Please use ConfigError instead.
void parseTeePercents(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to "percent" timers settings.
Common interface representing a network to which the DHCP clients are connected.
static void moveReservationMode(isc::data::ElementPtr config)
Moves deprecated reservation-mode parameter to new reservations flags.
boost::shared_ptr< const Element > ConstElementPtr
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
Parser for option data values within a subnet.
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
size_t parse(SrvConfigPtr cfg, data::ConstElementPtr subnets_list)
parses contents of the list
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID,&Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string,&Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime,&data::BaseStampedElement::getModificationTime > > >> Subnet6Collection
A collection of Subnet6 objects.
bool empty() const
Checks if the encapsulated value is empty.
Defines the logger used by the top-level component of kea-dhcp-ddns.
T get() const
Retrieves the encapsulated value.
SharedNetwork6Parser(bool check_iface=true)
Constructor.
void parse(const isc::dhcp::Network::RelayInfoPtr &relay_info, isc::data::ConstElementPtr relay_elem)
parses the actual relay parameters
static IfaceMgr & instance()
IfaceMgr is a singleton class.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
The Element class represents a piece of data, used by the command channel and configuration parts...
Shared network holding IPv6 subnets.
The IOAddress class represents an IP addresses (version agnostic)
SharedNetwork4Ptr parse(const data::ConstElementPtr &shared_network_data)
Parses shared configuration information for IPv4 shared network.