Browse Source

[3201] Constants moved to dhcp4.h

Tomek Mrugalski 11 years ago
parent
commit
ff2b7624b7
2 changed files with 27 additions and 20 deletions
  1. 17 6
      src/lib/dhcp/dhcp4.h
  2. 10 14
      src/lib/dhcp/tests/libdhcp++_unittest.cc

+ 17 - 6
src/lib/dhcp/dhcp4.h

@@ -164,16 +164,27 @@ 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_VIRTUAL_SUBNET_SELECT = 151; //RFC6607
+static const uint16_t 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
 // to be used.
 #if 0
-/* Relay Agent Information option subtypes: */
-#define RAI_CIRCUIT_ID  1
-#define RAI_REMOTE_ID   2
-#define RAI_AGENT_ID    3
-#define RAI_LINK_SELECT 5
-
 /* FQDN suboptions: */
 #define FQDN_NO_CLIENT_UPDATE           1
 #define FQDN_SERVER_UPDATE              2

+ 10 - 14
src/lib/dhcp/tests/libdhcp++_unittest.cc

@@ -43,12 +43,8 @@ using namespace isc::util;
 
 namespace {
 
-// DHCPv4 suboptions of standard option Relay Agent Information
-const uint16_t OPTION_AGENT_CIRCUIT_ID = 1;
-const uint16_t OPTION_REMOTE_ID = 2;
-const uint16_t OPTION_VSI = 9;
-
 // DHCPv6 suboptions of Vendor Options Option.
+/// @todo move to src/lib/dhcp/docsis3_option_defs.h once #3194 is merged.
 const uint16_t OPTION_CMTS_CAPS = 1025;
 const uint16_t OPTION_CM_MAC = 1026;
 
@@ -502,18 +498,18 @@ TEST_F(LibDhcpTest, packOptions4) {
     // option in on-wire format is correct.
 
     // Create Ciruit ID sub-option and add to RAI.
-    OptionPtr circuit_id(new Option(Option::V4, OPTION_AGENT_CIRCUIT_ID,
+    OptionPtr circuit_id(new Option(Option::V4, RAI_OPTION_AGENT_CIRCUIT_ID,
                                     OptionBuffer(v4_opts + 29,
                                                  v4_opts + 33)));
     rai->addOption(circuit_id);
 
     // Create Remote ID option and add to RAI.
-    OptionPtr remote_id(new Option(Option::V4, OPTION_REMOTE_ID,
+    OptionPtr remote_id(new Option(Option::V4, RAI_OPTION_REMOTE_ID,
                                    OptionBuffer(v4_opts + 35, v4_opts + 41)));
     rai->addOption(remote_id);
 
     // Create Vendor Specific Information and add to RAI.
-    OptionPtr vsi(new Option(Option::V4, OPTION_VSI,
+    OptionPtr vsi(new Option(Option::V4, RAI_OPTION_VSI,
                              OptionBuffer(v4_opts + 43, v4_opts + 52)));
     rai->addOption(vsi);
 
@@ -602,23 +598,23 @@ TEST_F(LibDhcpTest, unpackOptions4) {
     // the generic Option class.
 
     // Check that Circuit ID option is among parsed options.
-    OptionPtr rai_option = rai->getOption(OPTION_AGENT_CIRCUIT_ID);
+    OptionPtr rai_option = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);
     ASSERT_TRUE(rai_option);
-    EXPECT_EQ(OPTION_AGENT_CIRCUIT_ID, rai_option->getType());
+    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 + 29, 4));
 
     // Check that Remote ID option is among parsed options.
-    rai_option = rai->getOption(OPTION_REMOTE_ID);
+    rai_option = rai->getOption(RAI_OPTION_REMOTE_ID);
     ASSERT_TRUE(rai_option);
-    EXPECT_EQ(OPTION_REMOTE_ID, rai_option->getType());
+    EXPECT_EQ(RAI_OPTION_REMOTE_ID, rai_option->getType());
     ASSERT_EQ(8, rai_option->len());
     EXPECT_EQ(0, memcmp(&rai_option->getData()[0], v4_opts + 35, 6));
 
     // Check that Vendor Specific Information option is among parsed options.
-    rai_option = rai->getOption(OPTION_VSI);
+    rai_option = rai->getOption(RAI_OPTION_VSI);
     ASSERT_TRUE(rai_option);
-    EXPECT_EQ(OPTION_VSI, rai_option->getType());
+    EXPECT_EQ(RAI_OPTION_VSI, rai_option->getType());
     ASSERT_EQ(11, rai_option->len());
     EXPECT_EQ(0, memcmp(&rai_option->getData()[0], v4_opts + 43, 11));