}
// Verify that zero option code is rejected in the configuration.
-TEST_F(Dhcp4ParserTest, DISABLED_optionCodeZero) {
+TEST_F(Dhcp4ParserTest, optionCodeZero) {
// Option code 0 is reserved and should not be accepted
// by configuration parser.
testInvalidOptionParam("0", "code");
}
// Verify that zero option code is rejected in the configuration.
-TEST_F(Dhcp6ParserTest, DISABLED_optionCodeZero) {
+TEST_F(Dhcp6ParserTest, optionCodeZero) {
// Option code 0 is reserved and should not be accepted
// by configuration parser.
testInvalidOptionParam("0", "code");
#include <config.h>
#include <dhcp/iface_mgr.h>
+#include <dhcp/dhcp4.h>
#include <dhcp/libdhcp++.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/cfg_option.h>
<< getPosition("space", option_def) << ")");
}
+ // Protect against definition of options 0 (PAD) or 255 (END)
+ // in (and only in) the dhcp4 space.
+ if (space == DHCP4_OPTION_SPACE) {
+ if (code == DHO_PAD) {
+ isc_throw(DhcpConfigError, "invalid option code '0': "
+ << "reserved for PAD ("
+ << getPosition("code", option_def) << ")");
+ } else if (code == DHO_END) {
+ isc_throw(DhcpConfigError, "invalid option code '255': "
+ << "reserved for END ("
+ << getPosition("code", option_def) << ")");
+ }
+ }
+
+ // For dhcp6 space the value 0 is reserved.
+ if (space == DHCP6_OPTION_SPACE) {
+ if (code == 0) {
+ isc_throw(DhcpConfigError, "invalid option code '0': "
+ << "reserved value ("
+ << getPosition("code", option_def) << ")");
+ }
+ }
+
// Create option definition.
OptionDefinitionPtr def;
// We need to check if user has set encapsulated option space
#include <config.h>
#include <exceptions/exceptions.h>
+#include <dhcp/dhcp4.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option_definition.h>
#include <dhcp/option_space.h>
}
}
- OptionPtr option;
OptionDescriptor desc(false);
if (!def) {
}
}
+ // Check PAD and END in (and only in) dhcp4 space.
+ if (space_param == DHCP4_OPTION_SPACE) {
+ if (desc.option_->getType() == DHO_PAD) {
+ isc_throw(DhcpConfigError, "invalid option code '0': "
+ << "reserved for PAD ("
+ << option_data->getPosition() << ")");
+ } else if (desc.option_->getType() == DHO_END) {
+ isc_throw(DhcpConfigError, "invalid option code '255': "
+ << "reserved for END ("
+ << option_data->getPosition() << ")");
+ }
+ }
+
+ // For dhcp6 space the value 0 is reserved.
+ if (space_param == DHCP6_OPTION_SPACE) {
+ if (desc.option_->getType() == 0) {
+ isc_throw(DhcpConfigError, "invalid option code '0': "
+ << "reserved value ("
+ << option_data->getPosition() << ")");
+ }
+ }
+
+
// Add user context
if (user_context) {
desc.setContext(user_context);