/// @brief Link address of the relay to be used for relayed messages.
asiolink::IOAddress relay_link_addr_;
+ /// @brief Controls whether client will send ORO
+ ///
+ /// The actual content of the ORO is specified in oro_.
+ /// It is useful to split the actual content and the ORO sending
+ /// decision, so we could test cases of sending empty ORO.
+ void sendORO(bool send) {
+ send_oro_ = send;
+ }
+
+ /// @brief Instructs client to request specified option in ORO
+ ///
+ /// @param option_code client will request this option code
+ void requestOption(uint16_t option_code) {
+ send_oro_ = true;
+ oro_.push_back(option_code);
+ }
+
+ /// @brief List of options to be requested
+ ///
+ /// Content of this vector will be sent as ORO if send_oro_ is set
+ /// to true. See @ref sendORO for details.
+ std::vector<uint16_t> oro_;
private:
/// @brief Applies the new leases for the client.
/// @brief Pointer to the option holding a prefix hint.
Option6IAPrefixPtr prefix_hint_;
- // @brief List of options to be requested
- std::vector<uint16_t> oro_;
};
} // end of namespace isc::dhcp::test
" \"interface\": \"eth0\""
" } ],"
"\"valid-lifetime\": 4000 }",
+
// Configuration 1
"{ \"interfaces\": [ \"*\" ],"
"\"preferred-lifetime\": 3000,"
" \"interface\": \"eth0\""
" } ],"
"\"valid-lifetime\": 4000 }",
+
// Configuration 2
"{ \"interfaces\": [ \"*\" ],"
"\"preferred-lifetime\": 3000,"
" } ]"
" } ],"
"\"valid-lifetime\": 4000 }",
- // Configuration 2
+
+ // Configuration 3
"{ \"interfaces\": [ \"*\" ],"
"\"option-data\": [ {"
" \"name\": \"nis-servers\","
ASSERT_EQ(1, subnets->size());
// Perform 2-way exchange (Inf-request/reply)
+ client.requestOption(D6O_NAME_SERVERS);
ASSERT_NO_THROW(client.doInfRequest());
// Confirm that there's a response
ASSERT_EQ(1, subnets->size());
// Perform 2-way exchange (Inf-request/reply)
+ client.requestOption(D6O_NAME_SERVERS);
client.sendClientId(false);
ASSERT_NO_THROW(client.doInfRequest());
ASSERT_EQ(1, subnets->size());
// Perform 2-way exchange (Inf-request/reply)
+ client.requestOption(D6O_SIP_SERVERS_ADDR);
ASSERT_NO_THROW(client.doInfRequest());
// Confirm that there's a response
EXPECT_EQ("2001:db8::abcd", addrs[0].toText());
}
+/// Check that server processes correctly an incoming inf-request
+/// if there are options defined at both global and subnet scope.
+TEST_F(InfRequestTest, infRequestSubnetAndGlobal) {
+ Dhcp6Client client;
+
+ // Configure client to request IA_PD.
+ configure(CONFIGS[2], *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());
+
+ // Perform 2-way exchange (Inf-request/reply)
+ client.requestOption(D6O_SIP_SERVERS_ADDR);
+ client.requestOption(D6O_NAME_SERVERS);
+ ASSERT_NO_THROW(client.doInfRequest());
+
+ // Confirm that there's a response
+ Pkt6Ptr response = client.getContext().response_;
+ ASSERT_TRUE(response);
+
+ // Check sip servers
+ Option6AddrLstPtr sip = boost::dynamic_pointer_cast<Option6AddrLst>
+ (response->getOption(D6O_SIP_SERVERS_ADDR));
+ ASSERT_TRUE(sip);
+ Option6AddrLst::AddressContainer addrs = sip->getAddresses();
+ ASSERT_EQ(1, addrs.size());
+ EXPECT_EQ("2001:db8::1", addrs[0].toText());
+
+ // Check dns servers
+ Option6AddrLstPtr dns = boost::dynamic_pointer_cast<Option6AddrLst>
+ (response->getOption(D6O_NAME_SERVERS));
+ ASSERT_TRUE(dns);
+ addrs = sip->getAddresses();
+ ASSERT_EQ(1, addrs.size());
+ EXPECT_EQ("2001:db8::2", addrs[0].toText());
+}
+
+/// Check that server processes correctly an incoming inf-request
+/// if there are options defined at global scope only (no subnets).
+TEST_F(InfRequestTest, infRequestNoSubnets) {
+ Dhcp6Client client;
+
+ // Configure client to request IA_PD.
+ configure(CONFIGS[3], *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());
+
+ // Perform 2-way exchange (Inf-request/reply)
+ client.requestOption(D6O_NIS_SERVERS);
+ ASSERT_NO_THROW(client.doInfRequest());
+
+ // Confirm that there's a response
+ Pkt6Ptr response = client.getContext().response_;
+ ASSERT_TRUE(response);
+
+ // Check sip servers
+ Option6AddrLstPtr nis = boost::dynamic_pointer_cast<Option6AddrLst>
+ (response->getOption(D6O_NIS_SERVERS));
+ ASSERT_TRUE(nis);
+ Option6AddrLst::AddressContainer addrs = nis->getAddresses();
+ ASSERT_EQ(2, addrs.size());
+ EXPECT_EQ("2001:db8::1", addrs[0].toText());
+ EXPECT_EQ("2001:db8::2", addrs[0].toText());
+}
+
+
+
} // end of anonymous namespace