From: Francis Dupont Date: Wed, 17 Apr 2019 18:35:34 +0000 (+0200) Subject: [564-customer-request-relax-constraints-on-allowable-option-types-to-permit-option... X-Git-Tag: Kea-1.6.0-beta~231^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a0a0b84d91893f08c0ee6f236daa05bede65166;p=thirdparty%2Fkea.git [564-customer-request-relax-constraints-on-allowable-option-types-to-permit-option-type-0-and-255] Addressed comments --- diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc index 64ce61def9..58f1656d16 100644 --- a/src/lib/dhcp/tests/libdhcp++_unittest.cc +++ b/src/lib/dhcp/tests/libdhcp++_unittest.cc @@ -551,12 +551,10 @@ TEST_F(LibDhcpTest, unpackEmptyOption6) { LibDHCP::commitRuntimeOptionDefs(); // Create the buffer holding the structure of the empty option. - const uint8_t raw_data[] = { + OptionBuffer buf = { 0x04, 0x00, // option code = 1024 0x00, 0x00 // option length = 0 }; - size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t); - OptionBuffer buf(raw_data, raw_data + raw_data_len); // Parse options. OptionCollection options; @@ -599,7 +597,7 @@ TEST_F(LibDhcpTest, unpackSubOptions6) { LibDHCP::commitRuntimeOptionDefs(); // Create the buffer holding the structure of options. - const char raw_data[] = { + OptionBuffer buf = { // First option starts here. 0x00, 0x01, // option code = 1 0x00, 0x0F, // option length = 15 @@ -613,7 +611,6 @@ TEST_F(LibDhcpTest, unpackSubOptions6) { 0x00, 0x01, // option length = 1 0x00 // This option carries a single uint8 value and has no sub options. }; - OptionBuffer buf(raw_data, raw_data + sizeof(raw_data)); // Parse options. OptionCollection options; @@ -919,12 +916,10 @@ TEST_F(LibDhcpTest, unpackEmptyOption4) { LibDHCP::commitRuntimeOptionDefs(); // Create the buffer holding the structure of the empty option. - const uint8_t raw_data[] = { + OptionBuffer buf = { 0xFE, // option code = 254 0x00 // option length = 0 }; - size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t); - OptionBuffer buf(raw_data, raw_data + raw_data_len); // Parse options. OptionCollection options; @@ -969,7 +964,7 @@ TEST_F(LibDhcpTest, unpackSubOptions4) { LibDHCP::commitRuntimeOptionDefs(); // Create the buffer holding the structure of options. - const uint8_t raw_data[] = { + OptionBuffer buf = { // First option starts here. 0x01, // option code = 1 0x0B, // option length = 11 @@ -984,8 +979,6 @@ TEST_F(LibDhcpTest, unpackSubOptions4) { 0x00 // This option carries a single uint8 // value and has no sub options. }; - size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t); - OptionBuffer buf(raw_data, raw_data + raw_data_len); // Parse options. OptionCollection options; @@ -1042,7 +1035,7 @@ TEST_F(LibDhcpTest, unpackPadEnd) { LibDHCP::commitRuntimeOptionDefs(); // Create the buffer holding the structure of options. - const uint8_t raw_data[] = { + OptionBuffer buf = { // Add a PAD 0x00, // option code = 0 (PAD) // Container option starts here. @@ -1059,8 +1052,6 @@ TEST_F(LibDhcpTest, unpackPadEnd) { // Extra bytes at tail. 0x01, 0x02, 0x03, 0x04 }; - size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t); - OptionBuffer buf(raw_data, raw_data + raw_data_len); // Parse options. OptionCollection options; @@ -1070,7 +1061,7 @@ TEST_F(LibDhcpTest, unpackPadEnd) { options, deferred)); // Returned offset should point to the END. - EXPECT_EQ(0xff, raw_data[offset]); + EXPECT_EQ(0xff, buf[offset]); // There should be one top level option. ASSERT_EQ(1, options.size()); @@ -1081,7 +1072,7 @@ TEST_F(LibDhcpTest, unpackPadEnd) { EXPECT_EQ(200, option->getType()); // There should be 3 suboptions. - EXPECT_EQ(3, option->getOptions().size()); + ASSERT_EQ(3, option->getOptions().size()); // Get suboption 0. boost::shared_ptr > sub0 =