pkt->addOption(oro);
}
+ OptionPtr tmp = pkt->getOption(D6O_CLIENTID);
return (pkt);
}
}
/// @brief Verifies if the DHCPv6 server processes DHCPv6 Client FQDN option
- /// as expected.
+ /// as expected and subsequent interpretation of this processing when
+ /// creating NCRs, if any should be created.
///
/// This function simulates generation of the client's message holding FQDN.
/// It then calls the server's @c Dhcpv6Srv::processClientFqdn option to
/// generate server's response to the FQDN. This function returns the FQDN
/// which should be appended to the server's response to the client.
- /// This function verifies that the FQDN option returned is correct.
+ /// This function verifies that the FQDN option returned is correct
+ /// Optionally, this function then proceeds to call createNameChangeRequests
+ /// to verify if that method interprets the FQDN information properly.
///
/// @param msg_type A type of the client's message.
/// @param in_flags A value of flags field to be set for the FQDN carried
/// @param exp_flags A value of flags expected in the FQDN sent by a server.
/// @param exp_domain_name A domain name expected in the FQDN sent by a
/// server.
+ /// @param create_ncr_check if true, calls createNameChangeRequests method
+ /// and tests the outcome.
+ /// @param exp_fwd indicates whether or not a forward change is expected
+ /// @param exp_fwd indicates whether or not a reverse change is expected
void testFqdn(const uint16_t msg_type,
const uint8_t in_flags,
const std::string& in_domain_name,
const Option6ClientFqdn::DomainNameType in_domain_type,
const uint8_t exp_flags,
- const std::string& exp_domain_name) {
+ const std::string& exp_domain_name,
+ const bool create_ncr_check,
+ const bool exp_fwd = true, const bool exp_rev = true) {
Pkt6Ptr question = generateMessage(msg_type,
in_flags,
in_domain_name,
in_domain_type,
true);
+
ASSERT_TRUE(getClientFqdnOption(question));
- Pkt6Ptr answer(new Pkt6(msg_type == DHCPV6_SOLICIT ? DHCPV6_ADVERTISE :
- DHCPV6_REPLY, question->getTransid()));
+ Pkt6Ptr answer = generateMessageWithIds(msg_type == DHCPV6_SOLICIT
+ ? DHCPV6_ADVERTISE :
+ DHCPV6_REPLY);
+
+ // Create three IAs, each having different address.
+ addIA(1234, IOAddress("2001:db8:1::1"), answer);
+
ASSERT_NO_THROW(srv_->processClientFqdn(question, answer));
Option6ClientFqdnPtr answ_fqdn = boost::dynamic_pointer_cast<
Option6ClientFqdn>(answer->getOption(D6O_CLIENT_FQDN));
EXPECT_EQ(Option6ClientFqdn::FULL, answ_fqdn->getDomainNameType());
}
+
+ if (create_ncr_check) {
+ // Call createNameChangeRequests
+ ASSERT_NO_THROW(srv_->createNameChangeRequests(answer));
+ if (exp_fwd || exp_rev) {
+ // Should have created 1 NCR.
+ NameChangeRequestPtr ncr;
+ ASSERT_EQ(1, d2_mgr_.getQueueSize());
+ ASSERT_NO_THROW(ncr = d2_mgr_.peekAt(0));
+ ASSERT_TRUE(ncr);
+ EXPECT_EQ(dhcp_ddns::CHG_ADD, ncr->getChangeType());
+ EXPECT_EQ(exp_fwd, ncr->isForwardChange());
+ EXPECT_EQ(exp_rev, ncr->isReverseChange());
+ ASSERT_NO_THROW(d2_mgr_.runReadyIO());
+ } else {
+ // Should not have created any NCRs.
+ EXPECT_EQ(0, d2_mgr_.getQueueSize());
+ }
+ }
}
/// @brief Tests that the client's message holding an FQDN is processed
testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S,
"myhost.example.com",
Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S,
- "myhost.example.com.");
+ "myhost.example.com.", true, true, true);
}
// Test server's response when client provides partial domain-name and requests
TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) {
testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "myhost",
Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
- "myhost.example.com.");
+ "myhost.example.com.", true, true, true);
}
// Test server's response when client provides empty domain-name and requests
// that server performs AAAA update.
TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdateNoName) {
testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "",
- Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S, "");
+ Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S, "", false);
}
// Test server's response when client requests no DNS update.
testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_N,
"myhost.example.com",
Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_N,
- "myhost.example.com.");
+ "myhost.example.com.", true, false, false);
}
// Test server's response when client requests no DNS update and
"myhost.example.com",
Option6ClientFqdn::FULL,
(Option6ClientFqdn::FLAG_S | Option6ClientFqdn::FLAG_O),
- "myhost.example.com.");
+ "myhost.example.com.", true, true, true);
}
// Test server's response when client requests that server delegates the AAAA
testFqdn(DHCPV6_SOLICIT, 0, "myhost.example.com.",
Option6ClientFqdn::FULL,
0,
- "myhost.example.com.");
+ "myhost.example.com.", true, false, true);
}
// Test server's response when client requests that server delegates the AAAA
testFqdn(DHCPV6_SOLICIT, 0, "myhost.example.com.",
Option6ClientFqdn::FULL,
Option6ClientFqdn::FLAG_S | Option6ClientFqdn::FLAG_O,
- "myhost.example.com.");
+ "myhost.example.com.", true, true, true);
}
// Test that exception is thrown if supplied NULL answer packet when