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;
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
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;
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;
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
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;
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.
// 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;
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());
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<OptionInt<uint8_t> > sub0 =