-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 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
TEST_F(ConfirmTest, directClientSameIAID) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(CONFIRM_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
TEST_F(ConfirmTest, directClientDifferentIAID) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(CONFIRM_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
// Client to send relayed message.
client.useRelay();
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(CONFIRM_CONFIGS[1], 2, client));
// Keep the client's lease for future reference.
// Client to send relayed message.
client.useRelay();
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(CONFIRM_CONFIGS[1], 2, client));
// Now that the client has a lease, let's remove any subnets to check
// Client to send relayed message.
client.useRelay();
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(CONFIRM_CONFIGS[1], 2, client));
// Make sure we have got the lease.
TEST_F(ConfirmTest, unicast) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(CONFIRM_CONFIGS[0], 2, client));
// Make sure the client has got the lease.
-// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2016 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
StatsMgr::instance().setValue("declined-addresses", static_cast<int64_t>(0));
client.setDUID(duid1);
- client.useNA(iaid1);
+ client.requestAddress(iaid1);
// Configure the server with a configuration.
ASSERT_NO_THROW(configure(DECLINE_CONFIGS[0], *client.getServer()));
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 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
srv_->run();
}
-/*void
-Dhcp6Client::useNA(const bool use, const uint32_t iaid) {
- use_na_ = use;
- client_ias_.push_back(ClientIA(Lease::TYPE_NA, iaid,
- asiolink::IOAddress::IPV6_ZERO_ADDRESS(),
- 0));
- na_iaid_ = iaid;
-} */
-
void
-Dhcp6Client::useNA(const uint32_t iaid, const asiolink::IOAddress& address) {
+Dhcp6Client::requestAddress(const uint32_t iaid,
+ const asiolink::IOAddress& address) {
client_ias_.push_back(ClientIA(Lease::TYPE_NA, iaid, address, 128));
}
-/*void
-Dhcp6Client::usePD(const bool use, const uint32_t iaid) {
- use_pd_ = use;
- client_ias_.push_back(ClientIA(Lease::TYPE_PD, iaid,
- asiolink::IOAddress::IPV6_ZERO_ADDRESS(),
- 0));
- pd_iaid_ = iaid;
-}*/
-
void
-Dhcp6Client::usePD(const uint32_t iaid,const asiolink::IOAddress& prefix,
- const uint8_t prefix_len) {
+Dhcp6Client::requestPrefix(const uint32_t iaid,
+ const uint8_t prefix_len,
+ const asiolink::IOAddress& prefix) {
client_ias_.push_back(ClientIA(Lease::TYPE_PD, iaid, prefix, prefix_len));
}
link_local_ = link_local;
}
- /// @brief Place IA_NA options to request address assignment.
- ///
- /// This function configures the client to place IA_NA options in its
- /// Solicit messages to request the IPv6 address assignment.
- ///
- /// @param iaid IAID to be used in the IA_NA.
-/* void useNA(const uint32_t iaid) {
- useNA(true, iaid);
- } */
-
-/* /// @brief Place IA_NA options to request address assignment.
- ///
- /// This function configures the client to place IA_NA options in its
- /// Solicit messages to request the IPv6 address assignment.
- ///
- /// @param use Parameter which 'true' value indicates that client should
- /// request address assignment.
- /// @param iaid IAID to be used in the IA_NA.
- void useNA(const bool use = true, const uint32_t iaid = 1234); */
-
- /// @brief Place IA_PD options to request address assignment.
- ///
- /// This function configures the client to place IA_NA options in its
- /// Solicit messages to request the IPv6 address assignment.
- ///
- /// @param iaid IAID to be used in the IA_PD.
-/* void usePD(const uint32_t iaid) {
- usePD(true, iaid);
- } */
-
- /// @brief Place IA_PD options to request prefix assignment.
- ///
- /// This function configures the client to place IA_PD options in its
- /// Solicit messages to request the IPv6 address assignment.
- ///
- /// @param use Parameter which 'true' value indicates that client should
- /// request prefix assignment.
- /// @param iaid IAID to be used in the IA_NA.
-// void usePD(const bool use = true, const uint32_t iaid = 5678);
-
- void useNA(const uint32_t iaid = 1234, const asiolink::IOAddress& address =
- asiolink::IOAddress::IPV6_ZERO_ADDRESS());
-
- void usePD(const uint32_t iaid = 5678, const asiolink::IOAddress& prefix =
- asiolink::IOAddress::IPV6_ZERO_ADDRESS(),
- const uint8_t prefix_len = 0);
-
- /// @brief Removes requested IAs.
+ /// @brief Specifies address to be included in client's message.
+ ///
+ /// This method specifies IPv6 address to be included within IA_NA
+ /// option sent by the client. In order to specify multiple addresses
+ /// to be included in a particular IA_NA, this method must be called
+ /// multiple times to specify each address separately. In such case,
+ /// the value of the IAID should remain the same across all calls to
+ /// this method.
+ ///
+ /// This method is typically called to specify IA_NA options to be
+ /// sent to the server during 4-way handshakes and during lease
+ /// renewal to request allocation of new leases (as per RFC7550).
+ ///
+ /// @param iaid IAID.
+ /// @param address IPv6 address to be included in the IA_NA. It defaults
+ /// to IPv6 zero address, which indicates that no address should be
+ /// included in the IA_NA (empty IA_NA will be sent).
+ void requestAddress(const uint32_t iaid = 1234,
+ const asiolink::IOAddress& address =
+ asiolink::IOAddress::IPV6_ZERO_ADDRESS());
+
+ /// @brief Specifies IPv6 prefix to be included in client's message.
+ ///
+ /// This method specifies IPv6 prefix to be included within IA_PD
+ /// option sent by the client. In order to specify multiple prefixes
+ /// to be included in a particular IA_PD, this method must be called
+ /// multiple times to specify each prefix separately. In such case,
+ /// the value of the IAID should remain the same across all calls to
+ /// this method.
+ ///
+ /// This method is typically called to specify IA_PD options to be
+ /// sent to the server during 4-way handshakes and during lease
+ /// renewal to request allocation of new leases (as per RFC7550).
+ ///
+ /// @param iaid IAID.
+ /// @param prefix_len Prefix length.
+ /// @param prefix Prefix to be included. This value defaults to the
+ /// IPv6 zero address. If zero address is specified and prefix_len is
+ /// set to 0, the IA Prefix option will not be included in the IA_PD.
+ /// If the prefix_len is non-zero and the prefix is IPv6 zero address
+ /// the prefix length hint will be included in the IA Prefix option.
+ void requestPrefix(const uint32_t iaid = 5678,
+ const uint8_t prefix_len = 0,
+ const asiolink::IOAddress& prefix =
+ asiolink::IOAddress::IPV6_ZERO_ADDRESS());
+
+ /// @brief Removes IAs specified with @ref includeAddress and
+ /// @ref includePrefix methods.
+ ///
+ /// If this method is called and the client initiates an exchange with
+ /// a server the client will only include IAs for which it has leases.
+ /// If the client has no leases (e.g. a Solicit case), no IAs will be
+ /// included in the client's message.
void clearRequestedIAs() {
client_ias_.clear();
}
/// @brief Includes IAs to be requested.
///
- /// This method checks if @c use_na_ and/or @c use_pd_ are specified and
- /// includes appropriate IA types, if they are not already included.
+ /// This method includes IAs explicitly requested using
///
/// @param query Pointer to the client's message to which IAs should be
/// added.
// Configure client to request IA_NA and append IA_NA option
// to the client's message.
- client.useNA(1234, IOAddress("2001:db8:1:1::dead:beef"));
+ client.requestAddress(1234, IOAddress("2001:db8:1:1::dead:beef"));
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
// Configure client to request IA_NA and aAppend IA_NA option
// to the client's message.
client.setDUID("01:02:03:04");
- client.useNA(1234, IOAddress("2001:db8:1:1::dead:beef"));
+ client.requestAddress(1234, IOAddress("2001:db8:1:1::dead:beef"));
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
client.clearConfig();
client.modifyDUID();
client.clearRequestedIAs();
- client.useNA(1234);
+ client.requestAddress(1234);
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
configure(CONFIGS[0], *client.getServer());
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
const Subnet6Collection* subnets = CfgMgr::instance().getCurrentCfg()->
getCfgSubnets6()->getAll();
// Configure client to request IA_NA and aAppend IA_NA option
// to the client's message.
client.setDUID("01:02:03:04");
- client.useNA(1234, IOAddress("2001:db8:1:1::dead:beef"));
+ client.requestAddress(1234, IOAddress("2001:db8:1:1::dead:beef"));
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
configure(CONFIGS[0], *client.getServer());
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
const Subnet6Collection* subnets = CfgMgr::instance().getCurrentCfg()->
getCfgSubnets6()->getAll();
// Configure client to request IA_NA and aAppend IA_NA option
// to the client's message.
client.setDUID("01:02:03:04");
- client.useNA(1234, IOAddress("2001:db8:1:1::dead:beef"));
+ client.requestAddress(1234, IOAddress("2001:db8:1:1::dead:beef"));
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 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
TEST_F(RebindTest, directClient) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, directClientChangingSubnet) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, directClientChangingIAID) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
// one to IAID we guarantee that the IAID will change.
client.clearRequestedIAs();
client.config_.leases_[0].iaid_ = 1235;
- client.useNA(1235);
+ client.requestAddress(1235);
// Try to Rebind. The server should allocate new lease for this IAID.
ASSERT_NO_THROW(client.doRebind());
TEST_F(RebindTest, directClientLostLease) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, relayedClient) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Configure DHCPv6 client to simulate sending the message through a relay
// agent. The default link-addr is 3001:1::1. This address should be used
// by the server to pick the suitable subnet.
TEST_F(RebindTest, relayedClientChangingSubnet) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Configure DHCPv6 client to simulate sending the message through a relay
// agent. The default link-addr is 3001:1::1. This address should be used
// by the server to pick the suitable subnet.
TEST_F(RebindTest, relayedClientChangingIAID) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Configure DHCPv6 client to simulate sending the message through a relay
// agent. The default link-addr is 3001:1::1. This address should be used
// by the server to pick the suitable subnet.
// one to IAID we guarantee that the IAID will change.
client.clearRequestedIAs();
client.config_.leases_[0].iaid_ = 1235;
- client.useNA(1235);
+ client.requestAddress(1235);
// Try to Rebind. The server should allocate new lease for this IAID.
ASSERT_NO_THROW(client.doRebind());
TEST_F(RebindTest, relayedClientLostLease) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Configure DHCPv6 client to simulate sending the message through a relay
// agent. The default link-addr is 3001:1::1. This address should be used
// by the server to pick the suitable subnet.
TEST_F(RebindTest, relayedClientChangingAddress) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[2], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, directClientPD) {
Dhcp6Client client;
// Configure client to request IA_PD.
- client.usePD();
+ client.requestPrefix();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[4], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, directClientPDChangingSubnet) {
Dhcp6Client client;
// Configure client to request IA_PD.
- client.usePD();
+ client.requestPrefix();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[4], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, directClientPDChangingIAID) {
Dhcp6Client client;
// Configure client to request IA_PD.
- client.usePD();
+ client.requestPrefix();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[4], 2, client));
// Keep the client's lease for future reference.
// one to IAID we guarantee that the IAID will change.
client.clearRequestedIAs();
client.config_.leases_[0].iaid_ = 5679;
- client.usePD(5679);
+ client.requestPrefix(5679);
// Try to Rebind. The server should allocate new lease for this IAID.
ASSERT_NO_THROW(client.doRebind());
TEST_F(RebindTest, directClientPDChangingPrefix) {
Dhcp6Client client;
// Configure client to request IA_PD.
- client.usePD();
+ client.requestPrefix();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[4], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, unicast) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Make 4-way exchange to get the lease.
ASSERT_NO_FATAL_FAILURE(requestLease(REBIND_CONFIGS[0], 2, client));
// Keep the client's lease for future reference.
TEST_F(RebindTest, relayedUnicast) {
Dhcp6Client client;
// Configure client to request IA_NA.
- client.useNA();
+ client.requestAddress();
// Configure DHCPv6 client to simulate sending the message through a relay
// agent. The default link-addr is 3001:1::1. This address should be used
// by the server to pick the suitable subnet.
Dhcp6Client client;
// Configure client to request IA_NA and IA_PD.
- client.useNA();
- client.usePD();
+ client.requestAddress();
+ client.requestPrefix();
// Configure the server with NA pools only.
ASSERT_NO_THROW(configure(REBIND_CONFIGS[0], *client.getServer()));
Dhcp6Client client;
// Configure client to request IA_NA and IA_PD.
- client.useNA();
- client.usePD();
+ client.requestAddress();
+ client.requestPrefix();
// Configure the server with PD pools only.
ASSERT_NO_THROW(configure(REBIND_CONFIGS[4], *client.getServer()));
Dhcp6Client client;
// Configure client to request IA_NA and IA_PD.
- client.useNA(na_iaid_);
- client.usePD(pd_iaid_);
+ client.requestAddress(na_iaid_);
+ client.requestPrefix(pd_iaid_);
// Configure the server with NA pools only.
ASSERT_NO_THROW(configure(RENEW_CONFIGS[0], *client.getServer()));
Dhcp6Client client;
// Configure client to request IA_NA and IA_PD.
- client.useNA(na_iaid_);
- client.usePD(pd_iaid_);
+ client.requestAddress(na_iaid_);
+ client.requestPrefix(pd_iaid_);
// Configure the server with NA pools only.
ASSERT_NO_THROW(configure(RENEW_CONFIGS[0], *client.getServer()));
EXPECT_EQ(STATUS_Success, client.getStatusCode(na_iaid_));
// Specify the hint used for IA_PD.
- client.usePD(pd_iaid_, IOAddress::IPV6_ZERO_ADDRESS(), 64);
+ client.requestPrefix(pd_iaid_, 64, IOAddress::IPV6_ZERO_ADDRESS());
// Send Renew message to the server, including IA_NA and requesting IA_PD.
ASSERT_NO_THROW(client.doRenew());
Dhcp6Client client;
// Configure client to request IA_NA and IA_PD.
- client.useNA(na_iaid_);
- client.usePD(pd_iaid_);
+ client.requestAddress(na_iaid_);
+ client.requestPrefix(pd_iaid_);
// Configure the server with PD pools only.
ASSERT_NO_THROW(configure(RENEW_CONFIGS[1], *client.getServer()));
Dhcp6Client client;
// Configure client to request IA_NA and IA_PD.
- client.useNA(na_iaid_);
- client.usePD(pd_iaid_);
+ client.requestAddress(na_iaid_);
+ client.requestPrefix(pd_iaid_);
// Configure the server with PD pools only.
ASSERT_NO_THROW(configure(RENEW_CONFIGS[1], *client.getServer()));
ASSERT_EQ(0, leases_client_na.size());
ASSERT_EQ(STATUS_NoAddrsAvail, client.getStatusCode(na_iaid_));
- client.useNA(na_iaid_, IOAddress("2001:db8:1::100"));
+ client.requestAddress(na_iaid_, IOAddress("2001:db8:1::100"));
// Send Renew message to the server, including IA_PD and requesting IA_NA.
// The server should return NoAddrsAvail status code in this case.
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2016 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
TEST_F(SARRTest, directClientPrefixHint) {
Dhcp6Client client;
// Configure client to request IA_PD.
- client.usePD();
+ client.requestPrefix();
configure(CONFIGS[0], *client.getServer());
// Make sure we ended-up having expected number of subnets configured.
const Subnet6Collection* subnets = CfgMgr::instance().getCurrentCfg()->
getCfgSubnets6()->getAll();
ASSERT_EQ(1, subnets->size());
// Append IAPREFIX option to the client's message.
- ASSERT_NO_THROW(client.usePD(5678, asiolink::IOAddress("2001:db8:3:33::33"),
- 64));
+ ASSERT_NO_THROW(client.requestPrefix(5678, 64, asiolink::IOAddress("2001:db8:3:33::33")));
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
// Server should have assigned a prefix.
// Use the hint with some least significant bytes set.
client.clearRequestedIAs();
- ASSERT_NO_THROW(client.usePD(5678, IOAddress("2001:db8:3:33::34"), 64));
+ ASSERT_NO_THROW(client.requestPrefix(5678, 64, IOAddress("2001:db8:3:33::34")));
ASSERT_NO_THROW(client.doSARR());
// Server should assign a lease.
ASSERT_EQ(1, client.getLeaseNum());
TEST_F(SARRTest, rapidCommitEnable) {
Dhcp6Client client;
// Configure client to request IA_NA
- client.useNA();
+ client.requestAddress();
configure(CONFIGS[1], *client.getServer());
ASSERT_NO_THROW(client.getServer()->startD2());
// Make sure we ended-up having expected number of subnets configured.
TEST_F(SARRTest, rapidCommitNoOption) {
Dhcp6Client client;
// Configure client to request IA_NA
- client.useNA();
+ client.requestAddress();
configure(CONFIGS[1], *client.getServer());
ASSERT_NO_THROW(client.getServer()->startD2());
// Make sure we ended-up having expected number of subnets configured.
// The subnet assigned to eth1 has Rapid Commit disabled.
client.setInterface("eth1");
// Configure client to request IA_NA
- client.useNA();
+ client.requestAddress();
configure(CONFIGS[1], *client.getServer());
ASSERT_NO_THROW(client.getServer()->startD2());
// Make sure we ended-up having expected number of subnets configured.
Dhcp6Client client;
configure(CONFIGS[1], *client.getServer());
client.setInterface("eth1");
- client.useNA();
+ client.requestAddress();
// Make sure we ended-up having expected number of subnets configured.
const Subnet6Collection* subnets = CfgMgr::instance().getCurrentCfg()->
Dhcp6Client client;
configure(CONFIGS[1], *client.getServer());
client.setInterface("eth1");
- client.useNA();
+ client.requestAddress();
client.doSolicit();
client.useServerId(bogus_srv_id);
Dhcp6Client client;
configure(CONFIGS[1], *client.getServer());
client.setInterface("eth1");
- client.useNA();
+ client.requestAddress();
client.setDestAddress(asiolink::IOAddress("2001:db8::1")); // Pretend it's unicast
client.doSolicit();
Dhcp6Client client;
configure(CONFIGS[1], *client.getServer());
client.setInterface("eth1");
- client.useNA();
+ client.requestAddress();
// Let's send our client-id as server-id. That will result in the
// packet containing the client-id twice. That should cause RFCViolation