Browse Source

[3210] CfgMgr now can store a flag for echoing v4 client-id

Tomek Mrugalski 11 years ago
parent
commit
9fbb30d633
3 changed files with 32 additions and 1 deletions
  1. 1 1
      src/lib/dhcpsrv/cfgmgr.cc
  2. 19 0
      src/lib/dhcpsrv/cfgmgr.h
  3. 12 0
      src/lib/dhcpsrv/tests/cfgmgr_unittest.cc

+ 1 - 1
src/lib/dhcpsrv/cfgmgr.cc

@@ -350,7 +350,7 @@ CfgMgr::getUnicast(const std::string& iface) const {
 
 CfgMgr::CfgMgr()
     : datadir_(DHCP_DATA_DIR),
-      all_ifaces_active_(false) {
+      all_ifaces_active_(false), echo_v4_client_id_(true) {
     // DHCP_DATA_DIR must be set set with -DDHCP_DATA_DIR="..." in Makefile.am
     // Note: the definition of DHCP_DATA_DIR needs to include quotation marks
     // See AM_CPPFLAGS definition in Makefile.am

+ 19 - 0
src/lib/dhcpsrv/cfgmgr.h

@@ -316,6 +316,22 @@ public:
     const isc::asiolink::IOAddress*
     getUnicast(const std::string& iface) const;
 
+
+    /// @brief sets whether server should send back client-id in DHCPv4
+    ///
+    /// This is a compatibility flag. The default (true) is compliant with
+    /// RFC6842. False is for backward compatibility.
+    ///
+    /// @param echo should the client-id be sent or not
+    void echoClientId(bool echo) {
+        echo_v4_client_id_ = echo;
+    }
+
+    /// @brief returns whether server should send back client-id in DHCPv4
+    /// @param returns whether v4 client-id should be returned or not
+    bool echoClientId() const {
+        return (echo_v4_client_id_);
+    }
 protected:
 
     /// @brief Protected constructor.
@@ -392,6 +408,9 @@ private:
     /// A flag which indicates that server should listen on all available
     /// interfaces.
     bool all_ifaces_active_;
+
+    /// Indicates whether v4 server should send back client-id
+    bool echo_v4_client_id_;
 };
 
 } // namespace isc::dhcp

+ 12 - 0
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc

@@ -653,6 +653,18 @@ TEST_F(CfgMgrTest, activateAllIfaces) {
     EXPECT_FALSE(cfg_mgr.isActiveIface("eth2"));
 }
 
+// This test verifies that RFC6842 (echo client-id) compatibility may be
+// configured.
+TEST_F(CfgMgrTest, echoClientId) {
+    CfgMgr& cfg_mgr = CfgMgr::instance();
+
+    EXPECT_TRUE(cfg_mgr.echoClientId());
+
+    cfg_mgr.echoClientId(false);
+
+    EXPECT_FALSE(cfg_mgr.echoClientId());
+}
+
 /// @todo Add unit-tests for testing:
 /// - addActiveIface() with invalid interface name
 /// - addActiveIface() with the same interface twice