isc_throw(Unexpected, "can't convert the IAADDR option");
}
- // Set per-IA context values.
- // Note the address is considered as not-temporary address.
-
- ctx.createIAContext();
- ctx.currentIA().type_ = Lease::TYPE_NA;
- ctx.currentIA().iaid_ = no_iaid;
-
// Client and IADDR addresses must match.
if (addr != iaaddr->getAddress()) {
isc_throw(RFCViolation, "Address mismatch: client at " << addr
addr_reg_inf->getTransid()));
addr_reg_rep->addOption(iaaddr);
+ // Set per-IA context values for DDNS.
+ // Note the address is considered as not-temporary address.
+ ctx.createIAContext();
+ ctx.currentIA().type_ = Lease::TYPE_NA;
+ ctx.currentIA().iaid_ = no_iaid;
+ Option6IAPtr ia(new Option6IA(D6O_IA_NA, no_iaid));
+ ia->addOption(iaaddr);
+ ctx.currentIA().ia_rsp_ = ia;
+
// Process FQDN.
processClientFqdn(addr_reg_inf, addr_reg_rep, ctx);
#include <config.h>
#include <asiolink/io_address.h>
#include <cc/data.h>
+#include <dhcp/option_int.h>
#include <dhcp/option6_addrlst.h>
#include <dhcp/testutils/iface_mgr_test_config.h>
#include <dhcp6/json_config_parser.h>
}
// Test that an IA_NA option is fordidden.
-TEST_F(AddrRegTest, iA_NA) {
+TEST_F(AddrRegTest, unexpectedIA_NA) {
IfaceMgrTestConfig test_config(true);
ASSERT_NO_THROW(configure(config_));
}
// Test that an IA_TA option is fordidden.
-TEST_F(AddrRegTest, iA_TA) {
+TEST_F(AddrRegTest, unexpectedIA_TA) {
IfaceMgrTestConfig test_config(true);
ASSERT_NO_THROW(configure(config_));
addr_reg_inf->setIndex(ETH0_INDEX);
OptionPtr clientid = generateClientId();
addr_reg_inf->addOption(clientid);
- Option6IAPtr ia(new Option6IA(D6O_IA_TA, 234));
+ OptionPtr ia(new OptionInt<uint32_t>(Option::V6, D6O_IA_TA, 234));
addr_reg_inf->addOption(ia);
// Pass it to the server.
}
// Test that an IA_PD option is fordidden.
-TEST_F(AddrRegTest, iA_PD) {
+TEST_F(AddrRegTest, unexpectedIA_PD) {
IfaceMgrTestConfig test_config(true);
ASSERT_NO_THROW(configure(config_));
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
- expected += "Exactly 1 IAADDRE option expected, but 0 received";
+ expected += "Exactly 1 IAADDR option expected, but 0 received";
EXPECT_EQ(1, countFile(expected));
}
EXPECT_EQ(1, countFile(expected));
}
+// Test that a well formed IAADDR option is required.
+TEST_F(AddrRegTest, badIAADDR) {
+ IfaceMgrTestConfig test_config(true);
+
+ ASSERT_NO_THROW(configure(config_));
+
+ Pkt6Ptr addr_reg_inf = Pkt6Ptr(new Pkt6(DHCPV6_ADDR_REG_INFORM, 1234));
+ addr_reg_inf->setRemoteAddr(IOAddress("fe80::abcd"));
+ addr_reg_inf->setIface("eth0");
+ addr_reg_inf->setIndex(ETH0_INDEX);
+ OptionPtr clientid = generateClientId();
+ addr_reg_inf->addOption(clientid);
+ OptionCustomPtr iaddr(new OptionCustom(LibDHCP::D6O_IAADDR_DEF(),
+ Option::V6));
+ iaddr->writeAddress(IOAddress("2001:db8:1::1"), 0);
+ iaddr->writeInteger<uint32_t>(3000, 1);
+ iaddr->writeInteger<uint32_t>(4000, 2);
+ addr_reg_inf->addOption(iaddr);
+
+ // Pass it to the server.
+ AllocEngine::ClientContext6 ctx;
+ bool drop = !srv_->earlyGHRLookup(addr_reg_inf, ctx);
+ ASSERT_FALSE(drop);
+ ctx.subnet_ = srv_->selectSubnet(addr_reg_inf, drop);
+ ASSERT_FALSE(drop);
+ srv_->initContext(ctx, drop);
+ ASSERT_FALSE(drop);
+ ASSERT_TRUE(ctx.subnet_);
+
+ // Two IAADDR options: no response.
+ EXPECT_FALSE(srv_->processAddrRegInform(ctx));
+
+ string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
+ expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
+ expected += "can't convert the IAADDR option";
+ EXPECT_EQ(1, countFile(expected));
+}
+
// Test that addresses must match.
TEST_F(AddrRegTest, noAddrMatch) {
IfaceMgrTestConfig test_config(true);
static_cast<void>(LibDHCP::D6O_NTP_SERVER_DEF());
static_cast<void>(LibDHCP::D6O_BOOTFILE_URL_DEF());
static_cast<void>(LibDHCP::D6O_RSOO_DEF());
+ static_cast<void>(LibDHCP::D6O_IAADDR_DEF());
return (true);
}
}
return (*def);
}
+
+const OptionDefinition&
+LibDHCP::D6O_IAADDR_DEF() {
+ static OptionDefinitionPtr def =
+ LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, D6O_IAADDR);
+ static bool check_once(true);
+ if (check_once) {
+ isc_throw_assert(def);
+ isc_throw_assert(def->getName() == "iaaddr");
+ isc_throw_assert(def->getCode() == D6O_IAADDR);
+ isc_throw_assert(def->getType() == OPT_RECORD_TYPE);
+ isc_throw_assert(!def->getArrayType());
+ isc_throw_assert(def->getEncapsulatedSpace().empty());
+ isc_throw_assert(def->getOptionSpaceName() == DHCP6_OPTION_SPACE);
+ check_once = false;
+ }
+ return (*def);
+}