-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-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
@subsection dhcpv4HooksLeaseSelect lease4_select
- @b Arguments:
+ - name: @b query4, type: isc::dhcp::Pkt4Ptr, direction: <b>in</b>
- name: @b subnet4, type: isc::dhcp::Subnet4Ptr, direction: <b>in</b>
- name: @b fake_allocation, type: bool, direction: <b>in</b>
- name: @b lease4, type: isc::dhcp::Lease4Ptr, direction: <b>in/out</b>
@subsection dhcpv4HooksLeaseRenew lease4_renew
- @b Arguments:
+ - name: @b query4, type: isc::dhcp::Pkt4Ptr, direction: <b>in</b>
- name: @b subnet4, type: isc::dhcp::Subnet4Ptr, direction: <b>in</b>
- name: @b clientid, type: isc::dhcp::ClientId, direction: <b>in</b>
- name: @b hwaddr, type: isc::dhcp::HWAddr, direction: <b>in</b>
buffer4_receive_callout(CalloutHandle& callout_handle) {
callback_name_ = string("buffer4_receive");
- callout_handle.getArgument("query4", callback_pkt4_);
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
pkt4_receive_callout(CalloutHandle& callout_handle) {
callback_name_ = string("pkt4_receive");
- callout_handle.getArgument("query4", callback_pkt4_);
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
pkt4_send_callout(CalloutHandle& callout_handle) {
callback_name_ = string("pkt4_send");
- callout_handle.getArgument("response4", callback_pkt4_);
+ callout_handle.getArgument("response4", callback_resp_pkt4_);
- callout_handle.getArgument("query4", callback_pkt4_query_);
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
buffer4_send_callout(CalloutHandle& callout_handle) {
callback_name_ = string("buffer4_send");
- callout_handle.getArgument("response4", callback_pkt4_);
+ callout_handle.getArgument("response4", callback_resp_pkt4_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
subnet4_select_callout(CalloutHandle& callout_handle) {
callback_name_ = string("subnet4_select");
- callout_handle.getArgument("query4", callback_pkt4_);
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callout_handle.getArgument("subnet4", callback_subnet4_);
callout_handle.getArgument("subnet4collection", callback_subnet4collection_);
lease4_release_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease4_release");
- callout_handle.getArgument("query4", callback_pkt4_);
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callout_handle.getArgument("lease4", callback_lease4_);
callback_argument_names_ = callout_handle.getArgumentNames();
lease4_renew_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease4_renew");
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callout_handle.getArgument("subnet4", callback_subnet4_);
callout_handle.getArgument("lease4", callback_lease4_);
callout_handle.getArgument("hwaddr", callback_hwaddr_);
static int
lease4_decline_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease4_decline");
- callout_handle.getArgument("query4", callback_pkt4_);
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callout_handle.getArgument("lease4", callback_lease4_);
return (0);
/// resets buffers used to store data received by callouts
void resetCalloutBuffers() {
callback_name_ = string("");
- callback_pkt4_.reset();
- callback_pkt4_query_.reset();
+ callback_qry_pkt4_.reset();
+ callback_qry_pkt4_.reset();
callback_lease4_.reset();
callback_hwaddr_.reset();
callback_clientid_.reset();
/// String name of the received callout
static string callback_name_;
- /// Pkt4 structure returned in the callout
- static Pkt4Ptr callback_pkt4_;
+ /// Client/query Pkt4 structure returned in the callout
+ static Pkt4Ptr callback_qry_pkt4_;
- /// @brief Pkt4 structure returned in the callout
- ///
- /// pkt4_send hook now passes both the query and the response,
- /// so we actually need two fields.
- static Pkt4Ptr callback_pkt4_query_;
+ /// Server/response Pkt4 structure returned in the callout
+ static Pkt4Ptr callback_resp_pkt4_;
/// Lease4 structure returned in the callout
static Lease4Ptr callback_lease4_;
// The following fields are used in testing pkt4_receive_callout.
// See fields description in the class for details
string HooksDhcpv4SrvTest::callback_name_;
-Pkt4Ptr HooksDhcpv4SrvTest::callback_pkt4_;
-Pkt4Ptr HooksDhcpv4SrvTest::callback_pkt4_query_;
+Pkt4Ptr HooksDhcpv4SrvTest::callback_qry_pkt4_;
+Pkt4Ptr HooksDhcpv4SrvTest::callback_resp_pkt4_;
Subnet4Ptr HooksDhcpv4SrvTest::callback_subnet4_;
HWAddrPtr HooksDhcpv4SrvTest::callback_hwaddr_;
ClientIdPtr HooksDhcpv4SrvTest::callback_clientid_;
EXPECT_EQ("buffer4_receive", callback_name_);
// Check that pkt4 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt4_.get() == dis.get());
+ EXPECT_TRUE(callback_qry_pkt4_.get() == dis.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
EXPECT_EQ("pkt4_receive", callback_name_);
// check that pkt4 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt4_.get() == sol.get());
+ EXPECT_TRUE(callback_qry_pkt4_.get() == sol.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
Pkt4Ptr adv = srv_->fake_sent_.front();
// Check that pkt4 argument passing was successful and returned proper value
- ASSERT_TRUE(callback_pkt4_);
- EXPECT_TRUE(callback_pkt4_.get() == adv.get());
+ ASSERT_TRUE(callback_resp_pkt4_);
+ EXPECT_TRUE(callback_resp_pkt4_.get() == adv.get());
// That that the query4 argument was correctly set to the Discover we sent.
- ASSERT_TRUE(callback_pkt4_query_);
- EXPECT_TRUE(callback_pkt4_query_.get() == sol.get());
+ ASSERT_TRUE(callback_qry_pkt4_);
+ EXPECT_TRUE(callback_qry_pkt4_.get() == sol.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
Pkt4Ptr adv = srv_->fake_sent_.front();
// Check that pkt4 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt4_.get() == adv.get());
+ EXPECT_TRUE(callback_resp_pkt4_.get() == adv.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
EXPECT_EQ("subnet4_select", callback_name_);
// Check that pkt4 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt4_.get() == sol.get());
+ EXPECT_TRUE(callback_qry_pkt4_.get() == sol.get());
const Subnet4Collection* exp_subnets =
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
// Check that the callback called is indeed the one we installed
EXPECT_EQ("lease4_renew", callback_name_);
+ // Check that query4 argument passing was successful and
+ // returned proper value
+ EXPECT_TRUE(callback_qry_pkt4_.get() == req.get());
+
// Check that hwaddr parameter is passed properly
ASSERT_TRUE(callback_hwaddr_);
EXPECT_TRUE(*callback_hwaddr_ == *req->getHWAddr());
// Check if all expected parameters were really received
vector<string> expected_argument_names;
+ expected_argument_names.push_back("query4");
expected_argument_names.push_back("subnet4");
expected_argument_names.push_back("clientid");
expected_argument_names.push_back("hwaddr");
EXPECT_EQ("lease4_release", callback_name_);
// Check that pkt4 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt4_.get() == rel.get());
+ EXPECT_TRUE(callback_qry_pkt4_.get() == rel.get());
// Check if all expected parameters were really received
vector<string> expected_argument_names;
// Verifying DHCPDECLINE is a bit tricky, as it is created somewhere in
// acquireAndDecline. We'll just verify that it's really a DECLINE
// and that its address is equal to what we have in LeaseMgr.
- ASSERT_TRUE(callback_pkt4_);
+ ASSERT_TRUE(callback_qry_pkt4_);
ASSERT_TRUE(callback_lease4_);
// Check that it's the proper packet that was reported.
- EXPECT_EQ(DHCPDECLINE, callback_pkt4_->getType());
+ EXPECT_EQ(DHCPDECLINE, callback_qry_pkt4_->getType());
// Extract the address being declined.
OptionCustomPtr opt_declined_addr = boost::dynamic_pointer_cast<
- OptionCustom>(callback_pkt4_->getOption(DHO_DHCP_REQUESTED_ADDRESS));
+ OptionCustom>(callback_qry_pkt4_->getOption(DHO_DHCP_REQUESTED_ADDRESS));
ASSERT_TRUE(opt_declined_addr);
IOAddress addr(opt_declined_addr->readAddress());
// Verifying DHCPDECLINE is a bit tricky, as it is created somewhere in
// acquireAndDecline. We'll just verify that it's really a DECLINE
// and that its address is equal to what we have in LeaseMgr.
- ASSERT_TRUE(callback_pkt4_);
+ ASSERT_TRUE(callback_qry_pkt4_);
ASSERT_TRUE(callback_lease4_);
// Check that it's the proper packet that was reported.
- EXPECT_EQ(DHCPDECLINE, callback_pkt4_->getType());
+ EXPECT_EQ(DHCPDECLINE, callback_qry_pkt4_->getType());
// Extract the address being declined.
OptionCustomPtr opt_declined_addr = boost::dynamic_pointer_cast<
- OptionCustom>(callback_pkt4_->getOption(DHO_DHCP_REQUESTED_ADDRESS));
+ OptionCustom>(callback_qry_pkt4_->getOption(DHO_DHCP_REQUESTED_ADDRESS));
ASSERT_TRUE(opt_declined_addr);
IOAddress addr(opt_declined_addr->readAddress());
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-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
@subsection dhcpv6HooksPkt6Send pkt6_send
- @b Arguments:
+ - name: @b query6, type: isc::dhcp::Pkt6Ptr, direction: <b>in</b>
- name: @b response6, type: isc::dhcp::Pkt6Ptr, direction: <b>in/out</b>
- @b Description: This callout is executed when server's response
// Delete all previous arguments
callout_handle->deleteAllArguments();
+ // Pass incoming packet as argument
+ callout_handle->setArgument("query6", query);
+
// Set our response
callout_handle->setArgument("response6", rsp);
pkt6_receive_callout(CalloutHandle& callout_handle) {
callback_name_ = string("pkt6_receive");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
buffer6_receive_callout(CalloutHandle& callout_handle) {
callback_name_ = string("buffer6_receive");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
pkt6_send_callout(CalloutHandle& callout_handle) {
callback_name_ = string("pkt6_send");
- callout_handle.getArgument("response6", callback_pkt6_);
+ callout_handle.getArgument("response6", callback_resp_pkt6_);
+
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callback_argument_names_ = callout_handle.getArgumentNames();
return (0);
subnet6_select_callout(CalloutHandle& callout_handle) {
callback_name_ = string("subnet6_select");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callout_handle.getArgument("subnet6", callback_subnet6_);
callout_handle.getArgument("subnet6collection", callback_subnet6collection_);
lease6_renew_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease6_renew");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callout_handle.getArgument("lease6", callback_lease6_);
callout_handle.getArgument("ia_na", callback_ia_na_);
return (0);
}
+ /// Test callback that stores received callout name and pkt6 value
+ /// @param callout_handle handle passed by the hooks framework
+ /// @return always 0
+ static int
+ lease6_rebind_callout(CalloutHandle& callout_handle) {
+ callback_name_ = string("lease6_rebind");
+
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
+ callout_handle.getArgument("lease6", callback_lease6_);
+ callout_handle.getArgument("ia_na", callback_ia_na_);
+
+ callback_argument_names_ = callout_handle.getArgumentNames();
+ return (0);
+ }
+
+
/// The following values are used by the callout to override
/// renewed lease parameters
static const uint32_t override_iaid_;
lease6_renew_update_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease6_renew");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callout_handle.getArgument("lease6", callback_lease6_);
callout_handle.getArgument("ia_na", callback_ia_na_);
lease6_release_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease6_release");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callout_handle.getArgument("lease6", callback_lease6_);
callback_argument_names_ = callout_handle.getArgumentNames();
static int
lease6_decline_callout(CalloutHandle& callout_handle) {
callback_name_ = string("lease6_decline");
- callout_handle.getArgument("query6", callback_pkt6_);
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callout_handle.getArgument("lease6", callback_lease6_);
return (0);
/// Resets buffers used to store data received by callouts
void resetCalloutBuffers() {
callback_name_ = string("");
- callback_pkt6_.reset();
+ callback_qry_pkt6_.reset();
+ callback_resp_pkt6_.reset();
callback_subnet6_.reset();
callback_lease6_.reset();
callback_ia_na_.reset();
/// String name of the received callout
static string callback_name_;
- /// Pkt6 structure returned in the callout
- static Pkt6Ptr callback_pkt6_;
+ /// Client's query Pkt6 structure returned in the callout
+ static Pkt6Ptr callback_qry_pkt6_;
+
+ /// Server's response Pkt6 structure returned in the callout
+ static Pkt6Ptr callback_resp_pkt6_;
/// Pointer to lease6
static Lease6Ptr callback_lease6_;
// The following fields are used in testing pkt6_receive_callout.
// See fields description in the class for details
string HooksDhcpv6SrvTest::callback_name_;
-Pkt6Ptr HooksDhcpv6SrvTest::callback_pkt6_;
+Pkt6Ptr HooksDhcpv6SrvTest::callback_qry_pkt6_;
+Pkt6Ptr HooksDhcpv6SrvTest::callback_resp_pkt6_;
Subnet6Ptr HooksDhcpv6SrvTest::callback_subnet6_;
const Subnet6Collection* HooksDhcpv6SrvTest::callback_subnet6collection_;
vector<string> HooksDhcpv6SrvTest::callback_argument_names_;
EXPECT_EQ("buffer6_receive", callback_name_);
// Check that pkt6 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt6_.get() == sol.get());
+ EXPECT_TRUE(callback_qry_pkt6_.get() == sol.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
EXPECT_EQ("pkt6_receive", callback_name_);
// Check that pkt6 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt6_.get() == sol.get());
+ EXPECT_TRUE(callback_qry_pkt6_.get() == sol.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
ASSERT_EQ(1, srv_->fake_sent_.size());
Pkt6Ptr adv = srv_->fake_sent_.front();
- // Check that pkt6 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt6_.get() == adv.get());
+ // Check that pkt6 argument passing was successful and returned proper
+ // values
+ EXPECT_TRUE(callback_qry_pkt6_.get() == sol.get());
+ EXPECT_TRUE(callback_resp_pkt6_.get() == adv.get());
// Check that all expected parameters are there
vector<string> expected_argument_names;
+ expected_argument_names.push_back(string("query6"));
expected_argument_names.push_back(string("response6"));
EXPECT_TRUE(expected_argument_names == callback_argument_names_);
}
EXPECT_EQ("subnet6_select", callback_name_);
// Check that pkt6 argument passing was successful and returned proper value
- EXPECT_TRUE(callback_pkt6_.get() == sol.get());
+ EXPECT_TRUE(callback_qry_pkt6_.get() == sol.get());
const Subnet6Collection* exp_subnets =
CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
EXPECT_EQ("lease6_renew", callback_name_);
// Check that appropriate parameters are passed to the callouts
- EXPECT_TRUE(callback_pkt6_);
+ EXPECT_TRUE(callback_qry_pkt6_);
EXPECT_TRUE(callback_lease6_);
EXPECT_TRUE(callback_ia_na_);
EXPECT_EQ("lease6_release", callback_name_);
// Check that appropriate parameters are passed to the callouts
- EXPECT_TRUE(callback_pkt6_);
+ EXPECT_TRUE(callback_qry_pkt6_);
EXPECT_TRUE(callback_lease6_);
// Check if all expected parameters were really received
EXPECT_EQ("lease6_decline", callback_name_);
// And valid parameters were passed.
- ASSERT_TRUE(callback_pkt6_);
+ ASSERT_TRUE(callback_qry_pkt6_);
ASSERT_TRUE(callback_lease6_);
// Test sanity check - it was a decline, right?
- EXPECT_EQ(DHCPV6_DECLINE, callback_pkt6_->getType());
+ EXPECT_EQ(DHCPV6_DECLINE, callback_qry_pkt6_->getType());
// Get the address from this decline.
- OptionPtr ia = callback_pkt6_->getOption(D6O_IA_NA);
+ OptionPtr ia = callback_qry_pkt6_->getOption(D6O_IA_NA);
ASSERT_TRUE(ia);
boost::shared_ptr<Option6IAAddr> addr_opt =
boost::dynamic_pointer_cast<Option6IAAddr>(ia->getOption(D6O_IAADDR));
EXPECT_EQ("lease6_decline", callback_name_);
// And valid parameters were passed.
- ASSERT_TRUE(callback_pkt6_);
+ ASSERT_TRUE(callback_qry_pkt6_);
ASSERT_TRUE(callback_lease6_);
// Test sanity check - it was a decline, right?
- EXPECT_EQ(DHCPV6_DECLINE, callback_pkt6_->getType());
+ EXPECT_EQ(DHCPV6_DECLINE, callback_qry_pkt6_->getType());
// Get the address from this decline.
- OptionPtr ia = callback_pkt6_->getOption(D6O_IA_NA);
+ OptionPtr ia = callback_qry_pkt6_->getOption(D6O_IA_NA);
ASSERT_TRUE(ia);
boost::shared_ptr<Option6IAAddr> addr_opt =
boost::dynamic_pointer_cast<Option6IAAddr>(ia->getOption(D6O_IAADDR));
EXPECT_EQ("lease6_decline", callback_name_);
// And valid parameters were passed.
- ASSERT_TRUE(callback_pkt6_);
+ ASSERT_TRUE(callback_qry_pkt6_);
ASSERT_TRUE(callback_lease6_);
// Test sanity check - it was a decline, right?
- EXPECT_EQ(DHCPV6_DECLINE, callback_pkt6_->getType());
+ EXPECT_EQ(DHCPV6_DECLINE, callback_qry_pkt6_->getType());
// Get the address from this decline.
- OptionPtr ia = callback_pkt6_->getOption(D6O_IA_NA);
+ OptionPtr ia = callback_qry_pkt6_->getOption(D6O_IA_NA);
ASSERT_TRUE(ia);
boost::shared_ptr<Option6IAAddr> addr_opt =
boost::dynamic_pointer_cast<Option6IAAddr>(ia->getOption(D6O_IAADDR));
ctx.callout_handle_->deleteAllArguments();
// Pass necessary arguments
+
+ // Pass the original packet
+ ctx.callout_handle_->setArgument("query6", ctx.query_);
+
// Subnet from which we do the allocation
ctx.callout_handle_->setArgument("subnet6", ctx.subnet_);
// Pass necessary arguments
+ // Pass the original packet
+ ctx.callout_handle_->setArgument("query6", ctx.query_);
+
// Subnet from which we do the allocation
ctx.callout_handle_->setArgument("subnet6", ctx.subnet_);
ctx.callout_handle_->deleteAllArguments();
// Pass necessary arguments
+ // Pass the original client query
+ ctx.callout_handle_->setArgument("query4", ctx.query_);
// Subnet from which we do the allocation (That's as far as we can go
// with using SubnetPtr to point to Subnet4 object. Users should not
Subnet4Ptr subnet4 = boost::dynamic_pointer_cast<Subnet4>(ctx.subnet_);
// Pass the parameters
+ ctx.callout_handle_->setArgument("query4", ctx.query_);
ctx.callout_handle_->setArgument("subnet4", subnet4);
ctx.callout_handle_->setArgument("clientid", ctx.clientid_);
ctx.callout_handle_->setArgument("hwaddr", ctx.hwaddr_);
ctx.callout_handle_->deleteAllArguments();
// Pass necessary arguments
+ // Pass the original client query
+ ctx.callout_handle_->setArgument("query4", ctx.query_);
// Subnet from which we do the allocation. Convert the general subnet
// pointer to a pointer to a Subnet4. Note that because we are using
callback_argument_names_.clear();
callback_addr_original_ = IOAddress("::");
callback_addr_updated_ = IOAddress("::");
+ callback_qry_pkt6_.reset();
}
/// callback that stores received callout name and received values
callback_name_ = string("lease6_select");
+ callout_handle.getArgument("query6", callback_qry_pkt6_);
callout_handle.getArgument("subnet6", callback_subnet6_);
callout_handle.getArgument("fake_allocation", callback_fake_allocation_);
callout_handle.getArgument("lease6", callback_lease6_);
static Lease6Ptr callback_lease6_;
static bool callback_fake_allocation_;
static vector<string> callback_argument_names_;
+ static Pkt6Ptr callback_qry_pkt6_;
};
// For some reason intialization within a class makes the linker confused.
Lease6Ptr HookAllocEngine6Test::callback_lease6_;
bool HookAllocEngine6Test::callback_fake_allocation_;
vector<string> HookAllocEngine6Test::callback_argument_names_;
+Pkt6Ptr HookAllocEngine6Test::callback_qry_pkt6_;
// This test checks if the lease6_select callout is executed and expected
// parameters as passed.
// Check that callouts were indeed called
EXPECT_EQ("lease6_select", callback_name_);
+ // Check that query6 argument was set correctly
+ ASSERT_TRUE(callback_qry_pkt6_);
+ EXPECT_EQ(callback_qry_pkt6_.get(), ctx.query_.get());
+
// Now check that the lease in LeaseMgr has the same parameters
ASSERT_TRUE(callback_lease6_);
detailCompareLease(callback_lease6_, from_mgr);
EXPECT_FALSE(callback_fake_allocation_);
- // Check if all expected parameters are reported. It's a bit tricky, because
- // order may be different. If the test starts failing, because someone tweaked
- // hooks engine, we'll have to implement proper vector matching (ignoring order)
+ // Check if all expected parameters are reported. The order needs to be
+ // alphapbetical to match the order returned by
+ // CallbackHandle::getAgrumentNames()
vector<string> expected_argument_names;
expected_argument_names.push_back("fake_allocation");
expected_argument_names.push_back("lease6");
+ expected_argument_names.push_back("query6");
expected_argument_names.push_back("subnet6");
sort(callback_argument_names_.begin(), callback_argument_names_.end());
callback_argument_names_.clear();
callback_addr_original_ = IOAddress("::");
callback_addr_updated_ = IOAddress("::");
+ callback_qry_pkt4_.reset();
}
/// callback that stores received callout name and received values
callback_name_ = string("lease4_select");
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
callout_handle.getArgument("subnet4", callback_subnet4_);
callout_handle.getArgument("fake_allocation", callback_fake_allocation_);
callout_handle.getArgument("lease4", callback_lease4_);
static Lease4Ptr callback_lease4_;
static bool callback_fake_allocation_;
static vector<string> callback_argument_names_;
+ static Pkt4Ptr callback_qry_pkt4_;
};
// For some reason intialization within a class makes the linker confused.
Lease4Ptr HookAllocEngine4Test::callback_lease4_;
bool HookAllocEngine4Test::callback_fake_allocation_;
vector<string> HookAllocEngine4Test::callback_argument_names_;
+Pkt4Ptr HookAllocEngine4Test::callback_qry_pkt4_;
// This test checks if the lease4_select callout is executed and expected
// parameters as passed.
// Check that callouts were indeed called
EXPECT_EQ("lease4_select", callback_name_);
+ // Check that query4 argument was set correctly
+ ASSERT_TRUE(callback_qry_pkt4_);
+ EXPECT_EQ(callback_qry_pkt4_.get(), ctx.query_.get());
+
// Now check that the lease in LeaseMgr has the same parameters
ASSERT_TRUE(callback_lease4_);
detailCompareLease(callback_lease4_, from_mgr);
EXPECT_EQ(callback_fake_allocation_, false);
- // Check if all expected parameters are reported. It's a bit tricky, because
- // order may be different. If the test starts failing, because someone tweaked
- // hooks engine, we'll have to implement proper vector matching (ignoring order)
+ // Check if all expected parameters are reported. The order needs to be
+ // alphapbetical to match the order returned by
+ // CallbackHandle::getAgrumentNames()
vector<string> expected_argument_names;
expected_argument_names.push_back("fake_allocation");
expected_argument_names.push_back("lease4");
+ expected_argument_names.push_back("query4");
expected_argument_names.push_back("subnet4");
EXPECT_TRUE(callback_argument_names_ == expected_argument_names);
}