Commit 946fe011 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3747] Ignore Client Id flag is added to Subnet4.

parent dc0d1ff6
......@@ -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");
......
......@@ -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
......
......@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment