|
@@ -24,6 +24,7 @@
|
|
|
#include <dhcp/option_custom.h>
|
|
|
#include <dhcp/option_int.h>
|
|
|
#include <dhcp/option_int_array.h>
|
|
|
+#include <dhcp/option_string.h>
|
|
|
#include <util/buffer.h>
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
@@ -423,10 +424,13 @@ TEST_F(LibDhcpTest, unpackOptions4) {
|
|
|
|
|
|
isc::dhcp::Option::OptionCollection::const_iterator x = options.find(12);
|
|
|
ASSERT_FALSE(x == options.end()); // option 1 should exist
|
|
|
- EXPECT_EQ(12, x->second->getType()); // this should be option 12
|
|
|
- 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+2, 3)); // data len=3
|
|
|
+ // Option 12 holds a string so let's cast it to an appropriate type.
|
|
|
+ OptionStringPtr option12 = boost::static_pointer_cast<OptionString>(x->second);
|
|
|
+ ASSERT_TRUE(option12);
|
|
|
+ EXPECT_EQ(12, option12->getType()); // this should be option 12
|
|
|
+ ASSERT_EQ(3, option12->getValue().length()); // it should be of length 3
|
|
|
+ EXPECT_EQ(5, option12->len()); // total option length 5
|
|
|
+ EXPECT_EQ(0, memcmp(&option12->getValue()[0], v4Opts+2, 3)); // data len=3
|
|
|
|
|
|
x = options.find(60);
|
|
|
ASSERT_FALSE(x == options.end()); // option 2 should exist
|
|
@@ -437,10 +441,12 @@ TEST_F(LibDhcpTest, unpackOptions4) {
|
|
|
|
|
|
x = options.find(14);
|
|
|
ASSERT_FALSE(x == options.end()); // option 3 should exist
|
|
|
- EXPECT_EQ(14, x->second->getType()); // this should be option 14
|
|
|
- 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+12, 3)); // data len=3
|
|
|
+ OptionStringPtr option14 = boost::static_pointer_cast<OptionString>(x->second);
|
|
|
+ ASSERT_TRUE(option14);
|
|
|
+ EXPECT_EQ(14, option14->getType()); // this should be option 14
|
|
|
+ ASSERT_EQ(3, option14->getValue().length()); // it should be of length 3
|
|
|
+ EXPECT_EQ(5, option14->len()); // total option length 5
|
|
|
+ EXPECT_EQ(0, memcmp(&option14->getValue()[0], v4Opts+12, 3)); // data len=3
|
|
|
|
|
|
x = options.find(254);
|
|
|
ASSERT_FALSE(x == options.end()); // option 3 should exist
|
|
@@ -532,7 +538,7 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
// 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();
|
|
|
+ OptionBufferConstIter end = buf.end();
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_SUBNET_MASK, begin, end,
|
|
|
typeid(OptionCustom));
|
|
@@ -568,25 +574,25 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
typeid(Option4AddrLst));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_HOST_NAME, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_BOOT_SIZE, begin, begin + 2,
|
|
|
typeid(OptionInt<uint16_t>));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_MERIT_DUMP, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_DOMAIN_NAME, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_SWAP_SERVER, begin, end,
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_ROOT_PATH, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_EXTENSIONS_PATH, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_IP_FORWARDING, begin, end,
|
|
|
typeid(OptionCustom));
|
|
@@ -652,7 +658,7 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
typeid(OptionCustom));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_NIS_DOMAIN, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_NIS_SERVERS, begin, end,
|
|
|
typeid(Option4AddrLst));
|
|
@@ -674,7 +680,7 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
typeid(OptionInt<uint8_t>));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_NETBIOS_SCOPE, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_FONT_SERVERS, begin, end,
|
|
|
typeid(Option4AddrLst));
|
|
@@ -701,7 +707,7 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
typeid(Option));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_DHCP_MESSAGE, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_DHCP_MAX_MESSAGE_SIZE, begin, begin + 2,
|
|
|
typeid(OptionInt<uint16_t>));
|
|
@@ -719,7 +725,7 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
|
|
|
typeid(Option));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_NWIP_DOMAIN_NAME, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs4(DHO_NWIP_SUBOPTIONS, begin, end,
|
|
|
typeid(Option));
|
|
@@ -908,10 +914,10 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
|
|
|
typeid(Option6AddrLst));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs6(D6O_NEW_POSIX_TIMEZONE, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs6(D6O_NEW_TZDB_TIMEZONE, begin, end,
|
|
|
- typeid(OptionCustom));
|
|
|
+ typeid(OptionString));
|
|
|
|
|
|
LibDhcpTest::testStdOptionDefs6(D6O_ERO, begin, end,
|
|
|
typeid(OptionIntArray<uint16_t>));
|