mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[#2357] Filled dhcp-agent-options-space
This commit is contained in:
@@ -259,29 +259,30 @@ static const uint16_t DHCP4_SERVER_PORT = 67;
|
||||
/// extensions field).
|
||||
static const uint32_t DHCP_OPTIONS_COOKIE = 0x63825363;
|
||||
|
||||
/* Relay Agent Information option subtypes: */
|
||||
|
||||
static const uint16_t RAI_OPTION_AGENT_CIRCUIT_ID = 1; // RFC3046
|
||||
static const uint16_t RAI_OPTION_REMOTE_ID = 2; // RFC3046
|
||||
/* option 3 is reserved and will never be assigned */
|
||||
static const uint16_t RAI_OPTION_DOCSIS_DEVICE_CLASS = 4; // RFC3256
|
||||
static const uint16_t RAI_OPTION_LINK_SELECTION = 5; // RFC3527
|
||||
static const uint16_t RAI_OPTION_SUBSCRIBER_ID = 6; //RFC3993
|
||||
static const uint16_t RAI_OPTION_RADIUS = 7; //RFC4014
|
||||
static const uint16_t RAI_OPTION_AUTH = 8; //RFC4030
|
||||
static const uint16_t RAI_OPTION_VSI = 9; // RFC4243
|
||||
static const uint16_t RAI_OPTION_RELAY_FLAGS = 10; // RFC5010
|
||||
static const uint16_t RAI_OPTION_SERVER_ID_OVERRIDE = 11; // RFC5107
|
||||
static const uint16_t RAI_OPTION_RELAY_ID = 12; //RFC6925
|
||||
static const uint16_t RAI_OPTION_ACCESS_TECHNO_TYPE = 13; // RFC7839
|
||||
static const uint16_t RAI_OPTION_ACCESS_NETWORK_NAME = 14; // RFC7839
|
||||
static const uint16_t RAI_OPTION_ACCESS_POINT_NAME = 15; // RFC7839
|
||||
static const uint16_t RAI_OPTION_ACCESS_POINT_BSSID = 16; // RFC7839
|
||||
static const uint16_t RAI_OPTION_OPERATOR_ID = 17; // RFC7839
|
||||
static const uint16_t RAI_OPTION_OPERATOR_REALM = 18; // RFC7839
|
||||
static const uint16_t RAI_OPTION_RELAY_PORT = 19; // RFC8357
|
||||
static const uint16_t RAI_OPTION_VIRTUAL_SUBNET_SELECT = 151; //RFC6607
|
||||
static const uint16_t RAI_OPTION_VIRTUAL_SUBNET_SELECT_CTRL = 152; //RFC6607
|
||||
/// Relay Agent Information suboption types.
|
||||
enum RAISubOptionType {
|
||||
RAI_OPTION_AGENT_CIRCUIT_ID = 1, // RFC3046
|
||||
RAI_OPTION_REMOTE_ID = 2, // RFC3046
|
||||
/* option 3 is reserved and will never be assigned */
|
||||
RAI_OPTION_DOCSIS_DEVICE_CLASS = 4, // RFC3256
|
||||
RAI_OPTION_LINK_SELECTION = 5, // RFC3527
|
||||
RAI_OPTION_SUBSCRIBER_ID = 6, // RFC3993
|
||||
RAI_OPTION_RADIUS = 7, // RFC4014
|
||||
RAI_OPTION_AUTH = 8, // RFC4030
|
||||
RAI_OPTION_VSI = 9, // RFC4243
|
||||
RAI_OPTION_RELAY_FLAGS = 10, // RFC5010
|
||||
RAI_OPTION_SERVER_ID_OVERRIDE = 11, // RFC5107
|
||||
RAI_OPTION_RELAY_ID = 12, // RFC6925
|
||||
RAI_OPTION_ACCESS_TECHNO_TYPE = 13, // RFC7839
|
||||
RAI_OPTION_ACCESS_NETWORK_NAME = 14, // RFC7839
|
||||
RAI_OPTION_ACCESS_POINT_NAME = 15, // RFC7839
|
||||
RAI_OPTION_ACCESS_POINT_BSSID = 16, // RFC7839
|
||||
RAI_OPTION_OPERATOR_ID = 17, // RFC7839
|
||||
RAI_OPTION_OPERATOR_REALM = 18, // RFC7839
|
||||
RAI_OPTION_RELAY_PORT = 19, // RFC8357
|
||||
RAI_OPTION_VIRTUAL_SUBNET_SELECT = 151, // RFC6607
|
||||
RAI_OPTION_VIRTUAL_SUBNET_SELECT_CTRL = 152 // RFC6607
|
||||
};
|
||||
|
||||
// TODO: Following are leftovers from dhcp.h import from ISC DHCP
|
||||
// They will be converted to C++-style defines once they will start
|
||||
|
@@ -51,6 +51,7 @@ const OptionDefParamsEncapsulation OPTION_DEF_PARAMS[] = {
|
||||
{ LW_V6_OPTION_DEFINITIONS, LW_V6_OPTION_DEFINITIONS_SIZE, LW_V6_OPTION_SPACE },
|
||||
{ V4V6_RULE_OPTION_DEFINITIONS, V4V6_RULE_OPTION_DEFINITIONS_SIZE, V4V6_RULE_OPTION_SPACE },
|
||||
{ V4V6_BIND_OPTION_DEFINITIONS, V4V6_BIND_OPTION_DEFINITIONS_SIZE, V4V6_BIND_OPTION_SPACE },
|
||||
{ DHCP_AGENT_OPTION_DEFINITIONS, DHCP_AGENT_OPTION_DEFINITIONS_SIZE, DHCP_AGENT_OPTION_SPACE },
|
||||
{ LAST_RESORT_V4_OPTION_DEFINITIONS, LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE, LAST_RESORT_V4_OPTION_SPACE },
|
||||
{ NULL, 0, "" }
|
||||
};
|
||||
|
@@ -377,6 +377,56 @@ const int STANDARD_V4_OPTION_DEFINITIONS_SIZE =
|
||||
sizeof(STANDARD_V4_OPTION_DEFINITIONS) /
|
||||
sizeof(STANDARD_V4_OPTION_DEFINITIONS[0]);
|
||||
|
||||
/// Definitions of DHCPv4 agent options.
|
||||
const OptionDefParams DHCP_AGENT_OPTION_DEFINITIONS[] = {
|
||||
{ "circuit-id", RAI_OPTION_AGENT_CIRCUIT_ID,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "remote-id", RAI_OPTION_REMOTE_ID,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "docsis-device-class", RAI_OPTION_DOCSIS_DEVICE_CLASS,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "link-selection", RAI_OPTION_LINK_SELECTION,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_IPV4_ADDRESS_TYPE, false,
|
||||
NO_RECORD_DEF, "" },
|
||||
{ "subscriber-id", RAI_OPTION_SUBSCRIBER_ID,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "radius", RAI_OPTION_RADIUS,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "auth", RAI_OPTION_AUTH,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "vendor-specific-info", RAI_OPTION_VSI,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "relay-flags", RAI_OPTION_RELAY_FLAGS,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "server-id-override", RAI_OPTION_SERVER_ID_OVERRIDE,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_IPV4_ADDRESS_TYPE, false,
|
||||
NO_RECORD_DEF, "" },
|
||||
{ "relay-id", RAI_OPTION_RELAY_ID,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "access-techno-type", RAI_OPTION_ACCESS_TECHNO_TYPE,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "access-network-name", RAI_OPTION_ACCESS_NETWORK_NAME,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "access-point-name", RAI_OPTION_ACCESS_POINT_NAME,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "access-point-bssid", RAI_OPTION_ACCESS_POINT_BSSID,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "operator-id", RAI_OPTION_OPERATOR_ID,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "operator-realm", RAI_OPTION_OPERATOR_REALM,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "relay-port", RAI_OPTION_RELAY_PORT,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "virtual-subnet-select", RAI_OPTION_VIRTUAL_SUBNET_SELECT,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
|
||||
{ "virtual-subnet-select-ctrl", RAI_OPTION_VIRTUAL_SUBNET_SELECT_CTRL,
|
||||
DHCP_AGENT_OPTION_SPACE, OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "" }
|
||||
};
|
||||
|
||||
const int DHCP_AGENT_OPTION_DEFINITIONS_SIZE =
|
||||
sizeof(DHCP_AGENT_OPTION_DEFINITIONS) /
|
||||
sizeof(DHCP_AGENT_OPTION_DEFINITIONS[0]);
|
||||
|
||||
/// Last resort definitions (only option 43 for now, these definitions
|
||||
/// are applied in deferred unpacking when none is found).
|
||||
const OptionDefParams LAST_RESORT_V4_OPTION_DEFINITIONS[] = {
|
||||
|
@@ -1276,22 +1276,25 @@ TEST_F(LibDhcpTest, unpackOptions4) {
|
||||
// space called "dhcp4" and other option spaces. These sub-options do not
|
||||
// belong to standard option space and should be parsed using different
|
||||
// option definitions.
|
||||
// @todo Currently, definitions for option space "dhcp-agent-options-space"
|
||||
// are not defined. Therefore all suboptions will be represented here by
|
||||
// the generic Option class.
|
||||
|
||||
// Check that Circuit ID option is among parsed options.
|
||||
OptionPtr rai_option = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);
|
||||
ASSERT_TRUE(rai_option);
|
||||
EXPECT_EQ(RAI_OPTION_AGENT_CIRCUIT_ID, rai_option->getType());
|
||||
ASSERT_EQ(6, rai_option->len());
|
||||
EXPECT_EQ(0, memcmp(&rai_option->getData()[0], v4_opts + 46, 4));
|
||||
boost::shared_ptr<OptionString> circuit_id =
|
||||
boost::dynamic_pointer_cast<OptionString>(rai_option);
|
||||
ASSERT_TRUE(circuit_id);
|
||||
EXPECT_EQ(RAI_OPTION_AGENT_CIRCUIT_ID, circuit_id->getType());
|
||||
ASSERT_EQ(6, circuit_id->len());
|
||||
EXPECT_EQ(0, memcmp(&circuit_id->getData()[0], v4_opts + 46, 4));
|
||||
|
||||
// Check that Remote ID option is among parsed options.
|
||||
rai_option = rai->getOption(RAI_OPTION_REMOTE_ID);
|
||||
ASSERT_TRUE(rai_option);
|
||||
EXPECT_EQ(RAI_OPTION_REMOTE_ID, rai_option->getType());
|
||||
ASSERT_EQ(8, rai_option->len());
|
||||
boost::shared_ptr<OptionString> remote_id =
|
||||
boost::dynamic_pointer_cast<OptionString>(rai_option);
|
||||
ASSERT_TRUE(remote_id);
|
||||
EXPECT_EQ(RAI_OPTION_REMOTE_ID, remote_id->getType());
|
||||
ASSERT_EQ(8, remote_id->len());
|
||||
EXPECT_EQ(0, memcmp(&rai_option->getData()[0], v4_opts + 52, 6));
|
||||
|
||||
// Check that Vendor Specific Information option is among parsed options.
|
||||
|
Reference in New Issue
Block a user