}
void
-Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer,
- const Option6ClientFqdnPtr& opt_fqdn) {
-
- // It is likely that client haven't included the FQDN option in the message
- // and server is not configured to always update DNS. In such cases,
- // FQDN option will be NULL. This is valid state, so we simply return.
- if (!opt_fqdn) {
- return;
- }
-
+Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer) {
// The response message instance is always required. For instance it
// holds the Client Identifier. It is a programming error if supplied
// message is NULL.
<< " NULL when creating DNS NameChangeRequest");
}
+ // It is likely that client haven't included the FQDN option. In such case,
+ // FQDN option will be NULL. This is valid state, so we simply return.
+ Option6ClientFqdnPtr opt_fqdn = boost::dynamic_pointer_cast<
+ Option6ClientFqdn>(answer->getOption(D6O_CLIENT_FQDN));
+ if (!opt_fqdn) {
+ return;
+ }
+
// Get the Client Id. It is mandatory and a function creating a response
// would have thrown an exception if it was missing. Thus throwning
// Unexpected if it is missing as it is a programming error.
Option6ClientFqdnPtr fqdn = processClientFqdn(request, reply);
assignLeases(request, reply);
- createNameChangeRequests(reply, fqdn);
+ createNameChangeRequests(reply);
return (reply);
}
Option6ClientFqdnPtr fqdn = processClientFqdn(renew, reply);
renewLeases(renew, reply, fqdn);
- createNameChangeRequests(reply, fqdn);
+ createNameChangeRequests(reply);
return (reply);
}
/// @param answer A message beging sent to the Client.
/// @param fqdn_answer A DHCPv6 Client FQDN %Option which is included in the
/// response message sent to a client.
- void createNameChangeRequests(const Pkt6Ptr& answer,
- const Option6ClientFqdnPtr& fqdn_answer);
+ void createNameChangeRequests(const Pkt6Ptr& answer);
/// @brief Creates a @c isc::dhcp_ddns::NameChangeRequest which requests
/// removal of DNS entries for a particular lease.
NakedDhcpv6Srv srv(0);
Pkt6Ptr answer;
- Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
- "myhost.example.com",
- Option6ClientFqdn::FULL);
- EXPECT_THROW(srv.createNameChangeRequests(answer, fqdn),
+
+ EXPECT_THROW(srv.createNameChangeRequests(answer),
isc::Unexpected);
}
Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
"myhost.example.com",
Option6ClientFqdn::FULL);
+ answer->addOption(fqdn);
- EXPECT_THROW(srv.createNameChangeRequests(answer, fqdn),
- isc::Unexpected);
+ EXPECT_THROW(srv.createNameChangeRequests(answer), isc::Unexpected);
}
-// Test no NameChangeRequests are added if FQDN option is NULL.
+// Test no NameChangeRequests if Client FQDN is not added to the server's
+// response.
TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequestsNoFQDN) {
NakedDhcpv6Srv srv(0);
// Create Reply message with Client Id and Server id.
Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY, srv);
- // Pass NULL FQDN option. No NameChangeRequests should be created.
- Option6ClientFqdnPtr fqdn;
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer, fqdn));
+ ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
// There should be no new NameChangeRequests.
EXPECT_TRUE(srv.name_change_reqs_.empty());
// Create Reply message with Client Id and Server id.
Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY, srv);
+ // Add Client FQDN option.
Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
"myhost.example.com",
Option6ClientFqdn::FULL);
+ answer->addOption(fqdn);
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer, fqdn));
+ ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
// We didn't add any IAs, so there should be no NameChangeRequests in th
// queue.
Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
"MYHOST.EXAMPLE.COM",
Option6ClientFqdn::FULL);
+ answer->addOption(fqdn);
// Create NameChangeRequests. Since we have added 3 IAs, it should
// result in generation of 3 distinct NameChangeRequests.
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer, fqdn));
+ ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
ASSERT_EQ(3, srv.name_change_reqs_.size());
// Verify that NameChangeRequests are correct. Each call to the