|
@@ -17,12 +17,13 @@
|
|
|
#include <dhcp/dhcp4.h>
|
|
|
#include <dhcp/dhcp6.h>
|
|
|
#include <dhcp/libdhcp++.h>
|
|
|
+#include <dhcp/option4_addrlst.h>
|
|
|
#include <dhcp/option6_addrlst.h>
|
|
|
#include <dhcp/option6_ia.h>
|
|
|
#include <dhcp/option6_iaaddr.h>
|
|
|
-#include <dhcp/option6_int.h>
|
|
|
-#include <dhcp/option6_int_array.h>
|
|
|
#include <dhcp/option_custom.h>
|
|
|
+#include <dhcp/option_int.h>
|
|
|
+#include <dhcp/option_int_array.h>
|
|
|
#include <util/buffer.h>
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
@@ -55,23 +56,69 @@ public:
|
|
|
return OptionPtr(option);
|
|
|
}
|
|
|
|
|
|
- /// @brief Test option option definition.
|
|
|
+ /// @brief Test DHCPv4 option definition.
|
|
|
///
|
|
|
/// This function tests if option definition for standard
|
|
|
/// option has been initialized correctly.
|
|
|
///
|
|
|
/// @param code option code.
|
|
|
- /// @param bug buffer to be used to create option instance.
|
|
|
+ /// @param begin iterator pointing a begining of a buffer to
|
|
|
+ /// be used to create option instance.
|
|
|
+ /// @param end iterator pointing an end of a buffer to be
|
|
|
+ /// used to create option instance.
|
|
|
+ /// @param expected_type type of the option created by the
|
|
|
+ /// factory function returned by the option definition.
|
|
|
+ static void testStdOptionDefs4(const uint16_t code,
|
|
|
+ const OptionBufferConstIter begin,
|
|
|
+ const OptionBufferConstIter end,
|
|
|
+ const std::type_info& expected_type) {
|
|
|
+ // Use V4 universe.
|
|
|
+ testStdOptionDefs(Option::V4, code, begin, end, expected_type);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// @brief Test DHCPv6 option definition.
|
|
|
+ ///
|
|
|
+ /// This function tests if option definition for standard
|
|
|
+ /// option has been initialized correctly.
|
|
|
+ ///
|
|
|
+ /// @param code option code.
|
|
|
+ /// @param begin iterator pointing a begining of a buffer to
|
|
|
+ /// be used to create option instance.
|
|
|
+ /// @param end iterator pointing an end of a buffer to be
|
|
|
+ /// used to create option instance.
|
|
|
/// @param expected_type type of the option created by the
|
|
|
/// factory function returned by the option definition.
|
|
|
static void testStdOptionDefs6(const uint16_t code,
|
|
|
- const OptionBuffer& buf,
|
|
|
- const std::type_info& expected_type) {
|
|
|
+ const OptionBufferConstIter begin,
|
|
|
+ const OptionBufferConstIter end,
|
|
|
+ const std::type_info& expected_type) {
|
|
|
+ // Use V6 universe.
|
|
|
+ testStdOptionDefs(Option::V6, code, begin, end, expected_type);
|
|
|
+ }
|
|
|
+private:
|
|
|
+
|
|
|
+ /// @brief Test DHCPv4 or DHCPv6 option definition.
|
|
|
+ ///
|
|
|
+ /// This function tests if option definition for standard
|
|
|
+ /// option has been initialized correctly.
|
|
|
+ ///
|
|
|
+ /// @param code option code.
|
|
|
+ /// @param begin iterator pointing a begining of a buffer to
|
|
|
+ /// be used to create option instance.
|
|
|
+ /// @param end iterator pointing an end of a buffer to be
|
|
|
+ /// used to create option instance.
|
|
|
+ /// @param expected_type type of the option created by the
|
|
|
+ /// factory function returned by the option definition.
|
|
|
+ static void testStdOptionDefs(const Option::Universe u,
|
|
|
+ const uint16_t code,
|
|
|
+ const OptionBufferConstIter begin,
|
|
|
+ const OptionBufferConstIter end,
|
|
|
+ const std::type_info& expected_type) {
|
|
|
// Get all option definitions, we will use them to extract
|
|
|
// the definition for a particular option code.
|
|
|
// We don't have to initialize option definitions here because they
|
|
|
// are initialized in the class's constructor.
|
|
|
- OptionDefContainer options = LibDHCP::getOptionDefs(Option::V6);
|
|
|
+ OptionDefContainer options = LibDHCP::getOptionDefs(u);
|
|
|
// Get the container index #1. This one allows for searching
|
|
|
// option definitions using option code.
|
|
|
const OptionDefContainerTypeIndex& idx = options.get<1>();
|
|
@@ -79,20 +126,25 @@ public:
|
|
|
// For standard options we expect that the range returned
|
|
|
// will contain single option as their codes are unique.
|
|
|
OptionDefContainerTypeRange range = idx.equal_range(code);
|
|
|
- ASSERT_EQ(1, std::distance(range.first, range.second));
|
|
|
+ ASSERT_EQ(1, std::distance(range.first, range.second))
|
|
|
+ << "Standard option definition for the code " << code
|
|
|
+ << " has not been found.";
|
|
|
// If we have single option definition returned, the
|
|
|
// first iterator holds it.
|
|
|
OptionDefinitionPtr def = *(range.first);
|
|
|
// It should not happen that option definition is NULL but
|
|
|
// let's make sure (test should take things like that into
|
|
|
// account).
|
|
|
- ASSERT_TRUE(def);
|
|
|
+ ASSERT_TRUE(def) << "Option definition for the code "
|
|
|
+ << code << " is NULL.";
|
|
|
// Check that option definition is valid.
|
|
|
- ASSERT_NO_THROW(def->validate());
|
|
|
+ ASSERT_NO_THROW(def->validate())
|
|
|
+ << "Option definition for the option code " << code
|
|
|
+ << " is invalid";
|
|
|
OptionPtr option;
|
|
|
// Create the option.
|
|
|
- ASSERT_NO_THROW(option = def->optionFactory(Option::V6, code, buf))
|
|
|
- << "Option creation failed to option code " << code;
|
|
|
+ ASSERT_NO_THROW(option = def->optionFactory(u, code, begin, end))
|
|
|
+ << "Option creation failed for option code " << code;
|
|
|
// Make sure it is not NULL.
|
|
|
ASSERT_TRUE(option);
|
|
|
// And the actual object type is the one that we expect.
|
|
@@ -103,7 +155,8 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-static const uint8_t packed[] = {
|
|
|
+// The DHCPv6 options in the wire format, used by multiple tests.
|
|
|
+const uint8_t v6packed[] = {
|
|
|
0, 1, 0, 5, 100, 101, 102, 103, 104, // CLIENT_ID (9 bytes)
|
|
|
0, 2, 0, 3, 105, 106, 107, // SERVER_ID (7 bytes)
|
|
|
0, 14, 0, 0, // RAPID_COMMIT (0 bytes)
|
|
@@ -207,8 +260,8 @@ TEST_F(LibDhcpTest, packOptions6) {
|
|
|
OutputBuffer assembled(512);
|
|
|
|
|
|
EXPECT_NO_THROW(LibDHCP::packOptions6(assembled, opts));
|
|
|
- EXPECT_EQ(sizeof(packed), assembled.getLength());
|
|
|
- EXPECT_EQ(0, memcmp(assembled.getData(), packed, sizeof(packed)));
|
|
|
+ EXPECT_EQ(sizeof(v6packed), assembled.getLength());
|
|
|
+ EXPECT_EQ(0, memcmp(assembled.getData(), v6packed, sizeof(v6packed)));
|
|
|
}
|
|
|
|
|
|
TEST_F(LibDhcpTest, unpackOptions6) {
|
|
@@ -220,10 +273,10 @@ TEST_F(LibDhcpTest, unpackOptions6) {
|
|
|
isc::dhcp::Option::OptionCollection options; // list of options
|
|
|
|
|
|
OptionBuffer buf(512);
|
|
|
- memcpy(&buf[0], packed, sizeof(packed));
|
|
|
+ memcpy(&buf[0], v6packed, sizeof(v6packed));
|
|
|
|
|
|
EXPECT_NO_THROW ({
|
|
|
- LibDHCP::unpackOptions6(OptionBuffer(buf.begin(), buf.begin() + sizeof(packed)),
|
|
|
+ LibDHCP::unpackOptions6(OptionBuffer(buf.begin(), buf.begin() + sizeof(v6packed)),
|
|
|
options);
|
|
|
});
|
|
|
|
|
@@ -234,14 +287,14 @@ TEST_F(LibDhcpTest, unpackOptions6) {
|
|
|
EXPECT_EQ(1, x->second->getType()); // this should be option 1
|
|
|
ASSERT_EQ(9, x->second->len()); // it should be of length 9
|
|
|
ASSERT_EQ(5, x->second->getData().size());
|
|
|
- EXPECT_EQ(0, memcmp(&x->second->getData()[0], packed + 4, 5)); // data len=5
|
|
|
+ EXPECT_EQ(0, memcmp(&x->second->getData()[0], v6packed + 4, 5)); // data len=5
|
|
|
|
|
|
x = options.find(2);
|
|
|
ASSERT_FALSE(x == options.end()); // option 2 should exist
|
|
|
EXPECT_EQ(2, x->second->getType()); // this should be option 2
|
|
|
ASSERT_EQ(7, x->second->len()); // it should be of length 7
|
|
|
ASSERT_EQ(3, x->second->getData().size());
|
|
|
- EXPECT_EQ(0, memcmp(&x->second->getData()[0], packed + 13, 3)); // data len=3
|
|
|
+ EXPECT_EQ(0, memcmp(&x->second->getData()[0], v6packed + 13, 3)); // data len=3
|
|
|
|
|
|
x = options.find(14);
|
|
|
ASSERT_FALSE(x == options.end()); // option 14 should exist
|
|
@@ -254,11 +307,11 @@ TEST_F(LibDhcpTest, unpackOptions6) {
|
|
|
EXPECT_EQ(6, x->second->getType()); // this should be option 6
|
|
|
ASSERT_EQ(8, x->second->len()); // it should be of length 8
|
|
|
// Option with code 6 is the OPTION_ORO. This option is
|
|
|
- // represented by the Option6IntArray<uint16_t> class which
|
|
|
+ // represented by the OptionIntArray<uint16_t> class which
|
|
|
// comprises the set of uint16_t values. We need to cast the
|
|
|
// returned pointer to this type to get values stored in it.
|
|
|
- boost::shared_ptr<Option6IntArray<uint16_t> > opt_oro =
|
|
|
- boost::dynamic_pointer_cast<Option6IntArray<uint16_t> >(x->second);
|
|
|
+ boost::shared_ptr<OptionIntArray<uint16_t> > opt_oro =
|
|
|
+ boost::dynamic_pointer_cast<OptionIntArray<uint16_t> >(x->second);
|
|
|
// This value will be NULL if cast was unsuccessful. This is the case
|
|
|
// when returned option has different type than expected.
|
|
|
ASSERT_TRUE(opt_oro);
|
|
@@ -280,8 +333,8 @@ TEST_F(LibDhcpTest, unpackOptions6) {
|
|
|
// Option with code 8 is OPTION_ELAPSED_TIME. This option is
|
|
|
// represented by Option6Int<uint16_t> value that holds single
|
|
|
// uint16_t value.
|
|
|
- boost::shared_ptr<Option6Int<uint16_t> > opt_elapsed_time =
|
|
|
- boost::dynamic_pointer_cast<Option6Int<uint16_t> >(x->second);
|
|
|
+ boost::shared_ptr<OptionInt<uint16_t> > opt_elapsed_time =
|
|
|
+ boost::dynamic_pointer_cast<OptionInt<uint16_t> >(x->second);
|
|
|
// This value will be NULL if cast was unsuccessful. This is the case
|
|
|
// when returned option has different type than expected.
|
|
|
ASSERT_TRUE(opt_elapsed_time);
|
|
@@ -301,13 +354,17 @@ TEST_F(LibDhcpTest, unpackOptions6) {
|
|
|
EXPECT_TRUE(x == options.end()); // option 32000 not found */
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+/// V4 Options being used to test pack/unpack operations.
|
|
|
+/// These are variable length options only so as there
|
|
|
+/// is no restriction on the data length being carried by them.
|
|
|
+/// For simplicity, we assign data of the length 3 for each
|
|
|
+/// of them.
|
|
|
static uint8_t v4Opts[] = {
|
|
|
- 12, 3, 0, 1, 2,
|
|
|
- 13, 3, 10, 11, 12,
|
|
|
- 14, 3, 20, 21, 22,
|
|
|
- 254, 3, 30, 31, 32,
|
|
|
- 128, 3, 40, 41, 42
|
|
|
+ 12, 3, 0, 1, 2, // Hostname
|
|
|
+ 60, 3, 10, 11, 12, // Class Id
|
|
|
+ 14, 3, 20, 21, 22, // Merit Dump File
|
|
|
+ 254, 3, 30, 31, 32, // Reserved
|
|
|
+ 128, 3, 40, 41, 42 // Vendor specific
|
|
|
};
|
|
|
|
|
|
TEST_F(LibDhcpTest, packOptions4) {
|
|
@@ -321,7 +378,7 @@ TEST_F(LibDhcpTest, packOptions4) {
|
|
|
}
|
|
|
|
|
|
OptionPtr opt1(new Option(Option::V4, 12, payload[0]));
|
|
|
- OptionPtr opt2(new Option(Option::V4, 13, payload[1]));
|
|
|
+ OptionPtr opt2(new Option(Option::V4, 60, payload[1]));
|
|
|
OptionPtr opt3(new Option(Option::V4, 14, payload[2]));
|
|
|
OptionPtr opt4(new Option(Option::V4,254, payload[3]));
|
|
|
OptionPtr opt5(new Option(Option::V4,128, payload[4]));
|
|
@@ -344,11 +401,11 @@ TEST_F(LibDhcpTest, packOptions4) {
|
|
|
|
|
|
TEST_F(LibDhcpTest, unpackOptions4) {
|
|
|
|
|
|
- vector<uint8_t> packed(v4Opts, v4Opts + sizeof(v4Opts));
|
|
|
+ vector<uint8_t> v4packed(v4Opts, v4Opts + sizeof(v4Opts));
|
|
|
isc::dhcp::Option::OptionCollection options; // list of options
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
- LibDHCP::unpackOptions4(packed, options);
|
|
|
+ LibDHCP::unpackOptions4(v4packed, options);
|
|
|
);
|
|
|
|
|
|
isc::dhcp::Option::OptionCollection::const_iterator x = options.find(12);
|
|
@@ -358,9 +415,9 @@ TEST_F(LibDhcpTest, unpackOptions4) {
|
|
|
EXPECT_EQ(5, x->second->len()); // total option length 5
|
|
|
EXPECT_EQ(0, memcmp(&x->second->getData()[0], v4Opts+2, 3)); // data len=3
|
|
|
|
|
|
- x = options.find(13);
|
|
|
- ASSERT_FALSE(x == options.end()); // option 1 should exist
|
|
|
- EXPECT_EQ(13, x->second->getType()); // this should be option 13
|
|
|
+ x = options.find(60);
|
|
|
+ ASSERT_FALSE(x == options.end()); // option 2 should exist
|
|
|
+ EXPECT_EQ(60, x->second->getType()); // this should be option 60
|
|
|
ASSERT_EQ(3, x->second->getData().size()); // it should be of length 3
|
|
|
EXPECT_EQ(5, x->second->len()); // total option length 5
|
|
|
EXPECT_EQ(0, memcmp(&x->second->getData()[0], v4Opts+7, 3)); // data len=3
|
|
@@ -396,6 +453,235 @@ TEST_F(LibDhcpTest, unpackOptions4) {
|
|
|
EXPECT_TRUE(x == options.end()); // option 2 not found
|
|
|
}
|
|
|
|
|
|
+TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
+
|
|
|
+ // Create a buffer that holds dummy option data.
|
|
|
+ // It will be used to create most of the options.
|
|
|
+ std::vector<uint8_t> buf(48, 1);
|
|
|
+ OptionBufferConstIter begin = buf.begin();
|
|
|
+ OptionBufferConstIter end = buf.begin();
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_SUBNET_MASK, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_TIME_OFFSET, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ROUTERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_TIME_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NAME_SERVERS, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DOMAIN_NAME_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_LOG_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_COOKIE_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_LPR_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_IMPRESS_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_RESOURCE_LOCATION_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_HOST_NAME, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_BOOT_SIZE, begin, begin + 2,
|
|
|
+ typeid(OptionInt<uint16_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_MERIT_DUMP, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DOMAIN_NAME, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_SWAP_SERVER, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ROOT_PATH, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_EXTENSIONS_PATH, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_IP_FORWARDING, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NON_LOCAL_SOURCE_ROUTING, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_POLICY_FILTER, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_MAX_DGRAM_REASSEMBLY, begin, begin + 2,
|
|
|
+ typeid(OptionInt<uint16_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DEFAULT_IP_TTL, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_PATH_MTU_AGING_TIMEOUT, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_PATH_MTU_PLATEAU_TABLE, begin, begin + 10,
|
|
|
+ typeid(OptionIntArray<uint16_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_INTERFACE_MTU, begin, begin + 2,
|
|
|
+ typeid(OptionInt<uint16_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ALL_SUBNETS_LOCAL, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_BROADCAST_ADDRESS, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_PERFORM_MASK_DISCOVERY, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_MASK_SUPPLIER, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ROUTER_DISCOVERY, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ROUTER_SOLICITATION_ADDRESS, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_STATIC_ROUTES, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_TRAILER_ENCAPSULATION, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ARP_CACHE_TIMEOUT, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_IEEE802_3_ENCAPSULATION, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DEFAULT_TCP_TTL, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_TCP_KEEPALIVE_INTERVAL, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_TCP_KEEPALIVE_GARBAGE, begin, begin + 1,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NIS_DOMAIN, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NIS_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NTP_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_VENDOR_ENCAPSULATED_OPTIONS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NETBIOS_NAME_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NETBIOS_DD_SERVER, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NETBIOS_NODE_TYPE, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NETBIOS_SCOPE, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_FONT_SERVERS, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_X_DISPLAY_MANAGER, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_REQUESTED_ADDRESS, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_LEASE_TIME, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_OPTION_OVERLOAD, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_MESSAGE_TYPE, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_SERVER_IDENTIFIER, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_PARAMETER_REQUEST_LIST, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_MESSAGE, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_MAX_MESSAGE_SIZE, begin, begin + 2,
|
|
|
+ typeid(OptionInt<uint16_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_RENEWAL_TIME, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_REBINDING_TIME, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_VENDOR_CLASS_IDENTIFIER, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_CLIENT_IDENTIFIER, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NWIP_DOMAIN_NAME, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_NWIP_SUBOPTIONS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_USER_CLASS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_FQDN, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DHCP_AGENT_OPTIONS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_AUTHENTICATE, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_CLIENT_LAST_TRANSACTION_TIME,
|
|
|
+ begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_ASSOCIATED_IP, begin, end,
|
|
|
+ typeid(Option4AddrLst));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_SUBNET_SELECTION, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_DOMAIN_SEARCH, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_VIVCO_SUBOPTIONS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+
|
|
|
+ LibDhcpTest::testStdOptionDefs4(DHO_VIVSO_SUBOPTIONS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
+}
|
|
|
+
|
|
|
// Test that definitions of standard options have been initialized
|
|
|
// correctly.
|
|
|
// @todo Only limited number of option definitions are now created
|
|
@@ -406,6 +692,8 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
|
|
|
// Create a buffer that holds dummy option data.
|
|
|
// It will be used to create most of the options.
|
|
|
std::vector<uint8_t> buf(48, 1);
|
|
|
+ OptionBufferConstIter begin = buf.begin();
|
|
|
+ OptionBufferConstIter end = buf.end();
|
|
|
|
|
|
// Prepare buffer holding an array of FQDNs.
|
|
|
const char data[] = {
|
|
@@ -428,122 +716,144 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
|
|
|
fqdn_buf.end());
|
|
|
|
|
|
// The actual test starts here for all supported option codes.
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_CLIENTID, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_CLIENTID, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_SERVERID, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_SERVERID, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_IA_NA, buf, typeid(Option6IA));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_IA_NA, begin, end,
|
|
|
+ typeid(Option6IA));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_IA_TA, buf,
|
|
|
- typeid(Option6Int<uint32_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_IA_TA, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_IAADDR, buf, typeid(Option6IAAddr));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_IAADDR, begin, end,
|
|
|
+ typeid(Option6IAAddr));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_ORO, buf,
|
|
|
- typeid(Option6IntArray<uint16_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_ORO, begin, end,
|
|
|
+ typeid(OptionIntArray<uint16_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_PREFERENCE, buf,
|
|
|
- typeid(Option6Int<uint8_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_PREFERENCE, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_ELAPSED_TIME, buf,
|
|
|
- typeid(Option6Int<uint16_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_ELAPSED_TIME, begin, begin + 2,
|
|
|
+ typeid(OptionInt<uint16_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_RELAY_MSG, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_RELAY_MSG, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_STATUS_CODE, buf, typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_STATUS_CODE, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_RAPID_COMMIT, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_RAPID_COMMIT, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_USER_CLASS, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_USER_CLASS, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_VENDOR_CLASS, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_VENDOR_CLASS, begin, end,
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_VENDOR_OPTS, buf, typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_VENDOR_OPTS, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_INTERFACE_ID, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_INTERFACE_ID, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_RECONF_MSG, buf,
|
|
|
- typeid(Option6Int<uint8_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_RECONF_MSG, begin, begin + 1,
|
|
|
+ typeid(OptionInt<uint8_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_RECONF_ACCEPT, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_RECONF_ACCEPT, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_SIP_SERVERS_DNS, fqdn_buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_SIP_SERVERS_DNS, fqdn_buf.begin(),
|
|
|
+ fqdn_buf.end(),
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_SIP_SERVERS_ADDR, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_SIP_SERVERS_ADDR, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NAME_SERVERS, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NAME_SERVERS, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_DOMAIN_SEARCH, fqdn_buf,
|
|
|
- typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_DOMAIN_SEARCH, fqdn_buf.begin(),
|
|
|
+ fqdn_buf.end(), typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_IA_PD, buf, typeid(Option6IA));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_IA_PD, begin, end,
|
|
|
+ typeid(Option6IA));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_IAPREFIX, buf, typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_IAPREFIX, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NIS_SERVERS, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NIS_SERVERS, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NISP_SERVERS, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NISP_SERVERS, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NIS_DOMAIN_NAME, fqdn_buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NIS_DOMAIN_NAME, fqdn_buf.begin(),
|
|
|
+ fqdn_buf.end(),
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NISP_DOMAIN_NAME, fqdn_buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NISP_DOMAIN_NAME, fqdn_buf.begin(),
|
|
|
+ fqdn_buf.end(),
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_SNTP_SERVERS, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_SNTP_SERVERS, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs6(D6O_INFORMATION_REFRESH_TIME,
|
|
|
- buf, typeid(Option6Int<uint32_t>));
|
|
|
+ begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_BCMCS_SERVER_D, fqdn_buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_BCMCS_SERVER_D, fqdn_buf.begin(),
|
|
|
+ fqdn_buf.end(),
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_BCMCS_SERVER_A, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_BCMCS_SERVER_A, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_GEOCONF_CIVIC, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_GEOCONF_CIVIC, begin, end,
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_REMOTE_ID, buf, typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_REMOTE_ID, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_SUBSCRIBER_ID, buf,typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_SUBSCRIBER_ID, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_CLIENT_FQDN, client_fqdn_buf,
|
|
|
- typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_CLIENT_FQDN, client_fqdn_buf.begin(),
|
|
|
+ client_fqdn_buf.end(), typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_PANA_AGENT, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_PANA_AGENT, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_PANA_AGENT, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_PANA_AGENT, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NEW_POSIX_TIMEZONE, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NEW_POSIX_TIMEZONE, begin, end,
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_NEW_TZDB_TIMEZONE, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_NEW_TZDB_TIMEZONE, begin, end,
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_ERO, buf,
|
|
|
- typeid(Option6IntArray<uint16_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_ERO, begin, end,
|
|
|
+ typeid(OptionIntArray<uint16_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_LQ_QUERY, buf, typeid(OptionCustom));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_LQ_QUERY, begin, end,
|
|
|
+ typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_CLIENT_DATA, buf, typeid(Option));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_CLIENT_DATA, begin, end,
|
|
|
+ typeid(Option));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_CLT_TIME, buf,
|
|
|
- typeid(Option6Int<uint32_t>));
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_CLT_TIME, begin, begin + 4,
|
|
|
+ typeid(OptionInt<uint32_t>));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_LQ_RELAY_DATA, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_LQ_RELAY_DATA, begin, end,
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
- LibDhcpTest::testStdOptionDefs6(D6O_LQ_CLIENT_LINK, buf,
|
|
|
+ LibDhcpTest::testStdOptionDefs6(D6O_LQ_CLIENT_LINK, begin, end,
|
|
|
typeid(Option6AddrLst));
|
|
|
}
|
|
|
|