-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
dhcp6_client_classes_(dhcp6_client_classes),
next_server_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()),
server_host_name_(server_host_name), boot_file_name_(boot_file_name),
- host_id_(0), cfg_option4_(new CfgOption()), cfg_option6_(new CfgOption()) {
+ host_id_(0), cfg_option4_(new CfgOption()),
+ cfg_option6_(new CfgOption()), negative_(false) {
// Initialize host identifier.
setIdentifier(identifier, identifier_len, identifier_type);
dhcp6_client_classes_(dhcp6_client_classes),
next_server_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()),
server_host_name_(server_host_name), boot_file_name_(boot_file_name),
- host_id_(0), cfg_option4_(new CfgOption()), cfg_option6_(new CfgOption()) {
+ host_id_(0), cfg_option4_(new CfgOption()),
+ cfg_option6_(new CfgOption()), negative_(false) {
// Initialize host identifier.
setIdentifier(identifier, identifier_name);
<< "=" << *cclass;
}
+ // Add negative cached.
+ if (negative_) {
+ s << " negative cached";
+ }
+
return (s.str());
}
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
return (host_id_);
}
+ /// @brief Sets the negative cached flag.
+ ///
+ /// @param negative New valie for negative cache flag.
+ void setNegative(bool negative) {
+ negative_ = negative;
+ }
+
+ /// @brief Return the negative cache flag value.
+ bool getNegative() const {
+ return (negative_);
+ }
+
/// @brief Unparses (converts to Element representation) IPv4 host
///
/// @return Element representation of the host
CfgOptionPtr cfg_option4_;
/// @brief Pointer to the DHCPv6 option data configuration for this host.
CfgOptionPtr cfg_option6_;
+
+ /// @brief Negative cached flag.
+ bool negative_;
};
/// @brief Pointer to the @c Host object.
host = (*it)->get4(subnet_id, hwaddr, DuidPtr());
}
}
+ if (host && host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
.arg((*it)->getType())
.arg(host->toText());
+ if (host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
}
!host && it != alternate_sources_.end(); ++it) {
host = (*it)->get4(subnet_id, address);
}
+ if (host && host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
host = (*it)->get6(subnet_id, DuidPtr(), hwaddr);
}
}
+ if (host && host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
!host && it != alternate_sources_.end(); ++it) {
host = (*it)->get6(prefix, prefix_len);
}
+ if (host && host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
identifier_len))
.arg((*it)->getType())
.arg(host->toText());
+
+ if (host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
}
!host && it != alternate_sources_.end(); ++it) {
host = (*it)->get6(subnet_id, addr);
}
+ if (host && host->getNegative()) {
+ return (ConstHostPtr());
+ }
return (host);
}
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
ASSERT_EQ("192.0.2.3", host->getIPv4Reservation().toText());
ASSERT_EQ("some-host.example.org", host->getHostname());
ASSERT_FALSE(host->getContext());
+ ASSERT_FALSE(host->getNegative());
host->setIPv4SubnetID(SubnetID(123));
host->setIPv6SubnetID(SubnetID(234));
host->setBootFileName("bootfile.efi");
std::string user_context = "{ \"foo\": \"bar\" }";
host->setContext(Element::fromJSON(user_context));
+ host->setNegative(true);
EXPECT_EQ(123, host->getIPv4SubnetID());
EXPECT_EQ(234, host->getIPv6SubnetID());
EXPECT_EQ("bootfile.efi", host->getBootFileName());
ASSERT_TRUE(host->getContext());
EXPECT_EQ(user_context, host->getContext()->str());
+ EXPECT_TRUE(host->getNegative());
// Remove IPv4 reservation.
host->removeIPv4Reservation();
host->setHostname("");
host->removeIPv4Reservation();
host->setIPv4SubnetID(0);
+ host->setNegative(true);
EXPECT_EQ("hwaddr=010203040506 ipv6_subnet_id=2"
" hostname=(empty) ipv4_reservation=(no)"
" ipv6_reservation0=2001:db8:1::cafe"
" ipv6_reservation1=2001:db8:1::1"
" ipv6_reservation2=2001:db8:1:1::/64"
- " ipv6_reservation3=2001:db8:1:2::/64",
+ " ipv6_reservation3=2001:db8:1:2::/64"
+ " negative cached",
host->toText());
// Create host identified by DUID, instead of HWADDR, with a very
// Add some classes.
host->addClientClass4("modem");
host->addClientClass4("router");
+ // Set invisible negative cache.
+ host->setNegative(true);
EXPECT_EQ("{ "
"\"boot-file-name\": \"\", "