Cfg4o6& dhcp4o6 = subnet->get4o6();
EXPECT_TRUE(dhcp4o6.enabled());
- EXPECT_EQ(IOAddress("2001:db8::123"), dhcp4o6.getSubnet4o6().first);
- EXPECT_EQ(45, dhcp4o6.getSubnet4o6().second);
+ EXPECT_EQ(IOAddress("2001:db8::123"), dhcp4o6.getSubnet4o6().get().first);
+ EXPECT_EQ(45, dhcp4o6.getSubnet4o6().get().second);
}
// Checks if the DHCPv4 is able to parse the configuration with 4o6 subnet
Cfg4o6& dhcp4o6 = subnet->get4o6();
EXPECT_TRUE(dhcp4o6.enabled());
- EXPECT_EQ("ethX", dhcp4o6.getIface4o6());
+ EXPECT_EQ("ethX", dhcp4o6.getIface4o6().get());
}
// Checks if the DHCPv4 is able to parse the configuration with both 4o6 network
// ... and that subnet has 4o6 network interface specified.
Cfg4o6& dhcp4o6 = subnet->get4o6();
EXPECT_TRUE(dhcp4o6.enabled());
- EXPECT_EQ(IOAddress("2001:db8::543"), dhcp4o6.getSubnet4o6().first);
- EXPECT_EQ(21, dhcp4o6.getSubnet4o6().second);
- EXPECT_EQ("ethX", dhcp4o6.getIface4o6());
+ EXPECT_EQ(IOAddress("2001:db8::543"), dhcp4o6.getSubnet4o6().get().first);
+ EXPECT_EQ(21, dhcp4o6.getSubnet4o6().get().second);
+ EXPECT_EQ("ethX", dhcp4o6.getIface4o6().get());
}
// Checks if the DHCPv4 is able to parse the configuration with 4o6 network
// Convert DHCPv4o6 subnet to text.
std::string dhcp4o6_subnet;
- if (!subnet->get4o6().getSubnet4o6().first.isV6Zero() ||
- (subnet->get4o6().getSubnet4o6().second != 128u)) {
+ if (!subnet->get4o6().getSubnet4o6().get().first.isV6Zero() ||
+ (subnet->get4o6().getSubnet4o6().get().second != 128u)) {
std::ostringstream s;
- s << subnet->get4o6().getSubnet4o6().first << "/"
- << static_cast<int>(subnet->get4o6().getSubnet4o6().second);
+ s << subnet->get4o6().getSubnet4o6().get().first << "/"
+ << static_cast<int>(subnet->get4o6().getSubnet4o6().get().second);
dhcp4o6_subnet = s.str();
}
// Set 4o6-interface
result->set("4o6-interface", Element::create(iface4o6_));
// Set 4o6-subnet
- if (!subnet4o6_.first.isV6Zero() || (subnet4o6_.second != 128u)) {
+ if (!subnet4o6_.get().first.isV6Zero() || (subnet4o6_.get().second != 128u)) {
std::ostringstream oss;
- oss << subnet4o6_.first << "/"
- << static_cast<unsigned>(subnet4o6_.second);
+ oss << subnet4o6_.get().first << "/"
+ << static_cast<unsigned>(subnet4o6_.get().second);
result->set("4o6-subnet", Element::create(oss.str()));
} else {
result->set("4o6-subnet", Element::create(std::string()));
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <asiolink/io_address.h>
#include <cc/cfg_to_element.h>
+#include <util/optional.h>
#include <string>
namespace isc {
///
/// Initializes fields to their default value.
Cfg4o6()
- :enabled_(false), subnet4o6_(std::make_pair(asiolink::IOAddress("::"), 128u)) {
+ :enabled_(false), subnet4o6_(std::make_pair(asiolink::IOAddress("::"), 128u), true) {
}
/// @brief Returns whether the DHCP4o6 is enabled or not.
/// @brief Returns the DHCP4o6 interface.
/// @return value of the 4o6-interface parameter.
- std::string getIface4o6() const {
+ util::Optional<std::string> getIface4o6() const {
return (iface4o6_);
}
/// @brief Returns prefix/len for the IPv6 subnet.
/// @return prefix/length pair
- std::pair<asiolink::IOAddress, uint8_t> getSubnet4o6() const {
+ util::Optional<std::pair<asiolink::IOAddress, uint8_t> > getSubnet4o6() const {
return (subnet4o6_);
}
bool enabled_;
/// Specifies the network interface used as v4 subnet selector.
- std::string iface4o6_;
+ util::Optional<std::string> iface4o6_;
/// Specifies the IPv6 subnet used for v4 subnet selection.
- std::pair<asiolink::IOAddress, uint8_t> subnet4o6_;
+ util::Optional<std::pair<asiolink::IOAddress, uint8_t> > subnet4o6_;
/// Specifies the v6 interface-id used for v4 subnet selection.
OptionPtr interface_id_;
EXPECT_TRUE(subnet.getFilename().unspecified());
EXPECT_TRUE(subnet.getFilename().empty());
+
+ EXPECT_FALSE(subnet.get4o6().enabled());
+
+ EXPECT_TRUE(subnet.get4o6().getIface4o6().unspecified());
+ EXPECT_TRUE(subnet.get4o6().getIface4o6().empty());
+
+ EXPECT_TRUE(subnet.get4o6().getSubnet4o6().unspecified());
+ EXPECT_TRUE(subnet.get4o6().getSubnet4o6().get().first.isV6Zero());
+ EXPECT_EQ(128, subnet.get4o6().getSubnet4o6().get().second);
}
// Checks that the subnet id can be either autogenerated or set to an