}
void Pkt4::check() {
- boost::shared_ptr<Option> typeOpt = getOption(DHO_DHCP_MESSAGE_TYPE);
+ boost::shared_ptr<OptionInt<uint8_t> > typeOpt =
+ boost::dynamic_pointer_cast<OptionInt<uint8_t> >(getOption(DHO_DHCP_MESSAGE_TYPE));
if (typeOpt) {
- uint8_t msg_type = typeOpt->getUint8();
+ uint8_t msg_type = typeOpt->getValue();
- if (msg_type>DHCPLEASEACTIVE) {
- isc_throw(BadValue, "Invalid DHCP message type received:" << msg_type);
+ if (msg_type > DHCPLEASEACTIVE) {
+ isc_throw(BadValue, "Invalid DHCP message type received: "
+ << msg_type);
}
msg_type_ = msg_type;
delete pkt;
}
+ // Check that a null argument generates an exception.
+ Pkt4 pkt4(DHCPOFFER, 1234);
+ EXPECT_THROW(pkt4.setFile(NULL, Pkt4::MAX_FILE_LEN), InvalidParameter);
+ EXPECT_THROW(pkt4.setFile(NULL, 0), InvalidParameter);
}
+ /// V4 Options being used for pack/unpack testing.
+ /// For test simplicity, all selected options have
+ /// variable length data so as there are no restrictions
+ /// on a length of their data.
static uint8_t v4Opts[] = {
- 12, 3, 0, 1, 2,
- 13, 3, 10, 11, 12,
- 14, 3, 20, 21, 22,
- 53, 1, 1, // DHCP_MESSAGE_TYPE (required to not throw exception during unpack)
- 128, 3, 30, 31, 32,
- 254, 3, 40, 41, 42,
+ 12, 3, 0, 1, 2, // Hostname
+ 14, 3, 10, 11, 12, // Merit Dump File
+ 53, 1, 1, // Message Type (required to not throw exception during unpack)
+ 60, 3, 20, 21, 22, // Class Id
+ 128, 3, 30, 31, 32, // Vendor specific
+ 254, 3, 40, 41, 42, // Reserved
};
TEST(Pkt4Test, options) {