diff options
author | Thomas Markwalder <tmark@isc.org> | 2018-03-06 16:00:45 +0100 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2018-03-06 16:00:45 +0100 |
commit | b791aaefdf28777b64b5042609d081b05e3365d8 (patch) | |
tree | f5b6ec0a15094ad141224e0dd2aea35a7ebc8f7e /src/lib/dhcp/tests/pkt4_unittest.cc | |
parent | [5551] Added missing dot. (diff) | |
download | kea-b791aaefdf28777b64b5042609d081b05e3365d8.tar.xz kea-b791aaefdf28777b64b5042609d081b05e3365d8.zip |
[5551] Addressed review comments
Added commentary, updated sub-options unpacking,
and added support for skip logic to kea-dhcp6.
src/lib/dhcp/option.h
Added detail to SkipRemainingOptionsError commentary
src/lib/dhcp/libdhcp++.cc
LibDHCP::unpackVendorOptions4()
LibDHCP::unpackVendorOptions6()
src/lib/dhcp/tests/pkt4_unittest.cc
TEST_F(Pkt4Test, unpackVendorMalformed) - updated for
new exception type
TEST_F(Pkt4Test, truncatedVendorLength) - removed
extraneous byte streams
src/lib/dhcp/tests/pkt6_unittest.cc
TEST_F(Pkt6Test, unpackVendorMalformed) - updated for
new exception type
TEST_F(Pkt6Test, truncatedVendorLength) - new test for
truncated vendor options
src/lib/dhcp/tests/pkt_captures.h
src/lib/dhcp/tests/pkt_captures.cc
isc::dhcp::Pkt6Ptr captureSolicitWithVIVSO()
isc::dhcp::Pkt6Ptr captureSolicitWithTruncatedVIVSO() -
new captured packets
src/bin/dhcp6/dhcp6_messages.mes
DHCP6_PACKET_OPTIONS_SKIPPED - new log message
src/bin/dhcp6/dhcp6_srv.cc
Dhcpv6Srv::processPacket() - added explicit catch of
SkipRemainingOptionsError to allow processing the packet
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
TEST_F(Dhcpv6SrvTest, truncatedVIVSO) - new test to verify
server's ability to handle SkipRemainingOptionsError
Diffstat (limited to 'src/lib/dhcp/tests/pkt4_unittest.cc')
-rw-r--r-- | src/lib/dhcp/tests/pkt4_unittest.cc | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/src/lib/dhcp/tests/pkt4_unittest.cc b/src/lib/dhcp/tests/pkt4_unittest.cc index a20c8aa939..970f4ef367 100644 --- a/src/lib/dhcp/tests/pkt4_unittest.cc +++ b/src/lib/dhcp/tests/pkt4_unittest.cc @@ -763,7 +763,7 @@ TEST_F(Pkt4Test, unpackVendorMalformed) { baddatalen.resize(orig.size() - 5); baddatalen[full_len_index] = 10; Pkt4Ptr bad_data_len_pkt(new Pkt4(&baddatalen[0], baddatalen.size())); - EXPECT_THROW(bad_data_len_pkt->unpack(), InvalidOptionValue); + EXPECT_THROW(bad_data_len_pkt->unpack(), SkipRemainingOptionsError); // A suboption must have a length byte vector<uint8_t> nolength = orig; @@ -771,7 +771,7 @@ TEST_F(Pkt4Test, unpackVendorMalformed) { nolength[full_len_index] = 11; nolength[data_len_index] = 6; Pkt4Ptr no_length_pkt(new Pkt4(&nolength[0], nolength.size())); - EXPECT_THROW(no_length_pkt->unpack(), InvalidOptionValue); + EXPECT_THROW(no_length_pkt->unpack(), SkipRemainingOptionsError); // Truncated data is not accepted either vector<uint8_t> shorty = orig; @@ -779,7 +779,7 @@ TEST_F(Pkt4Test, unpackVendorMalformed) { shorty[full_len_index] = 14; shorty[data_len_index] = 9; Pkt4Ptr too_short_pkt(new Pkt4(&shorty[0], shorty.size())); - EXPECT_THROW(too_short_pkt->unpack(), InvalidOptionValue); + EXPECT_THROW(too_short_pkt->unpack(), SkipRemainingOptionsError); } // This test verifies methods that are used for manipulating meta fields @@ -1138,46 +1138,6 @@ TEST_F(Pkt4Test, getType) { // short (i.e. less than sizeof(uint8_t), unpack throws a // SkipRemainingOptionsError exception TEST_F(Pkt4Test, truncatedVendorLength) { - // Raw data for a valid DISCOVER packet. Its option 125 has a valid length - // of 133 (x85). Look for 303a7d: next two digits = 85 - const char* good_discover = - "010106012d5d43cb000080000000000000000000000000000ace50017896845ef7af0" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000063825363350" - "10137070102030407067d3c0a646f63736973332e303a7d850000118b80010102057b" - "01010102010303010104010105010106010107010f0801100901030a01010b01180c0" - "1010d0201000e0201000f010110040000000211010113010114010015013f16010117" - "01011801041901041a01041b01201c01021d01081e01201f011020011021010222010" - "1230100240100250101260200ff2701012801d82b7c020345434d030b45434d3a4552" - "4f5554455208030020400418333936373739343234343335353037373031303134303" - "035050131061e534247365838322d382e362e302e302d47412d30312d3937312d4e4f" - "5348070432343030090a534247363738322d41430a144d6f746f726f6c6120436f727" - "06f726174696f6e3d0fff845ef7af000300017896845ef7af390205dc521b01048005" - "03f802067896845ef7af090b0000118b06010401020300ff"; - - // Same DISCOVER as above but with the option 125 length changed to 01. - const char* bad_discover = - "010106012d5d43cb000080000000000000000000000000000ace50017896845ef7af0" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000063825363350" - "10137070102030407067d3c0a646f63736973332e303a7d010000118b80010102057b" - "01010102010303010104010105010106010107010f0801100901030a01010b01180c0" - "1010d0201000e0201000f010110040000000211010113010114010015013f16010117" - "01011801041901041a01041b01201c01021d01081e01201f011020011021010222010" - "1230100240100250101260200ff2701012801d82b7c020345434d030b45434d3a4552" - "4f5554455208030020400418333936373739343234343335353037373031303134303" - "035050131061e534247365838322d382e362e302e302d47412d30312d3937312d4e4f" - "5348070432343030090a534247363738322d41430a144d6f746f726f6c6120436f727" - "06f726174696f6e3d0fff845ef7af000300017896845ef7af390205dc521b01048005" - "03f802067896845ef7af090b0000118b06010401020300ff"; // Build a good discover packet Pkt4Ptr pkt = test::PktCaptures::discoverWithValidVIVSO(); |