]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3747] Ignore Client Id flag is added to Subnet4.
authorMarcin Siodelski <marcin@isc.org>
Tue, 12 May 2015 08:54:29 +0000 (10:54 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 12 May 2015 08:54:29 +0000 (10:54 +0200)
src/lib/dhcpsrv/subnet.cc
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/tests/subnet_unittest.cc

index 04db5e3a6982c73c8947d0061fb70bcf51d53483..f92d8ea9218ef72e64ac7b37598613af4336082e 100644 (file)
@@ -179,8 +179,8 @@ Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
                  const Triplet<uint32_t>& t2,
                  const Triplet<uint32_t>& valid_lifetime,
                  const SubnetID id)
-:Subnet(prefix, length, t1, t2, valid_lifetime,
-        RelayInfo(IOAddress("0.0.0.0")), id), siaddr_(IOAddress("0.0.0.0")) {
+    : Subnet(prefix, length, t1, t2, valid_lifetime, RelayInfo(IOAddress("0.0.0.0")), id),
+      siaddr_(IOAddress("0.0.0.0")), ignore_client_id_(false) {
     if (!prefix.isV4()) {
         isc_throw(BadValue, "Non IPv4 prefix " << prefix.toText()
                   << " specified in subnet4");
index 1a786bfc8065e109ebf5fc36ece3311d6e9ae84c..87dedd6fd322d62b87a526352affd088f1ad53c3 100644 (file)
@@ -542,7 +542,24 @@ public:
     /// @return siaddr value
     isc::asiolink::IOAddress getSiaddr() const;
 
-protected:
+    /// @brief Sets the flag indicating if the client identifier should be
+    /// ignored in the client's message.
+    ///
+    /// @param ignore If this value is true, the client identifiers are ignored
+    /// in the messages from the clients for this subnet.
+    void setIgnoreClientId(const bool ignore) {
+        ignore_client_id_ = ignore;
+    }
+
+    /// @brief Returns the flag indicating if the client identifiers should
+    /// be ignored for this subnet.
+    ///
+    /// @return true if client identifiers should be ignored, false otherwise.
+    bool getIgnoreClientId() const {
+        return (ignore_client_id_);
+    }
+
+private:
 
     /// @brief Returns default address for pool selection
     /// @return ANY IPv4 address
@@ -560,6 +577,9 @@ protected:
 
     /// @brief siaddr value for this subnet
     isc::asiolink::IOAddress siaddr_;
+
+    /// @brief Should server ignore client identifiers.
+    bool ignore_client_id_;
 };
 
 /// @brief A pointer to a @c Subnet4 object
index c55ad76dbc88aeffd44ed898e923710744643540..3f879daa2e9457a7d9d620b906494e0cb2d2663a 100644 (file)
@@ -116,6 +116,22 @@ TEST(Subnet4Test, siaddr) {
         BadValue);
 }
 
+// Checks if the ignore-client-id flag can be set and retrieved.
+TEST(Subnet4Test, ignoreClientId) {
+    Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+
+    // By default the flag should be set to false.
+    EXPECT_FALSE(subnet.getIgnoreClientId());
+
+    // Modify it and retrieve.
+    subnet.setIgnoreClientId(true);
+    EXPECT_TRUE(subnet.getIgnoreClientId());
+
+    // Modify again.
+    subnet.setIgnoreClientId(false);
+    EXPECT_FALSE(subnet.getIgnoreClientId());
+}
+
 TEST(Subnet4Test, Pool4InSubnet4) {
 
     Subnet4Ptr subnet(new Subnet4(IOAddress("192.1.2.0"), 24, 1, 2, 3));