# addresses from the other pool, or the clients obtaining
# stateless configuration will be assigned subnet specific value
# of option 12, i.e. 2001:db8:1:0:ff00::1.
+# For DHCPv6 subnets can have prefix delegation pools too so
+# a pd-pools with an option-data is defined too.
"subnet6": [
{
"option-data": [
"pool": "2001:db8:1::500 - 2001:db8:2::1000"
}
],
+ "pd-pools": [
+ {
+ "prefix": "2001:2b8:2::",
+ "prefix-len": 56,
+ "delegated-len": 64,
+ "option-data": [
+ {
+ "code": 12,
+ "data": "3001:cafe::12:"
+ }
+ ]
+ }
+ ],
"subnet": "2001:db8:1::/64",
"interface": "ethX"
}
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2017 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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#include <stdint.h>
#include <cc/simple_parser.h>
#include <gtest/gtest.h>
}
};
+class SimpleParserClassTest : public SimpleParser {
+public:
+ /// @brief Instantiation of extractInt for uint8_t
+ ///
+ /// @param name name of the parameter for error report
+ /// @param value value of the parameter
+ uint8_t extractUint8(const std::string& name, ConstElementPtr value) const {
+ return (extractInt<uint8_t, isc::OutOfRange>(name, value));
+ }
+
+};
+
// This test checks if the parameters can be inherited from the global
// scope to the subnet scope.
TEST_F(SimpleParserTest, deriveParams) {
checkIntegerValue(third, "rebind-timer", 1800);
checkIntegerValue(third, "renew-timer", 900);
}
+
+// This test exercises the extractInt template
+TEST_F(SimpleParserTest, extractInt) {
+
+ SimpleParserClassTest parser;
+
+ // extractInt checks if it is an integer
+ ConstElementPtr not_int(new StringElement("xyz"));
+ EXPECT_THROW(parser.extractUint8("foo", not_int), TypeError);
+
+ // extractInt checks bounds
+ ConstElementPtr negative(new IntElement(-1));
+ EXPECT_THROW(parser.extractUint8("foo", negative), isc::OutOfRange);
+ ConstElementPtr too_large(new IntElement(1024));
+ EXPECT_THROW(parser.extractUint8("foo", too_large),isc::OutOfRange);
+
+ // checks if extractInt can return the expected value
+ ConstElementPtr hundred(new IntElement(100));
+ uint8_t val = 0;
+ EXPECT_NO_THROW(val = parser.extractUint8("foo", hundred));
+ EXPECT_EQ(100, val);
+}