Host::IdentifierType type = Host::IDENT_FLEX;
std::vector<uint8_t> id;
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Pass incoming packet as argument
callout_handle->setArgument("query4", context_->query_);
HooksManager::calloutsPresent(Hooks.hook_index_subnet4_select_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // We're reusing callout_handle from previous calls
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(query);
HooksManager::calloutsPresent(Hooks.hook_index_subnet4_select_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // We're reusing callout_handle from previous calls
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Set new arguments
callout_handle->setArgument("query4", query);
if (HooksManager::calloutsPresent(Hooks.hook_index_buffer4_receive_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(query);
if (HooksManager::calloutsPresent(Hooks.hook_index_pkt4_receive_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(query);
if (ctx && HooksManager::calloutsPresent(Hooks.hook_index_leases4_committed_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
-
- // Clear skip flag if it was set in previous callouts
- callout_handle->setStatus(CalloutHandle::NEXT_STEP_CONTINUE);
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(query);
// Execute all callouts registered for pkt4_send
if (HooksManager::calloutsPresent(Hooks.hook_index_pkt4_send_)) {
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
-
- // Clear skip flag if it was set in previous callouts
- callout_handle->setStatus(CalloutHandle::NEXT_STEP_CONTINUE);
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the query and response packets within
// hook library.
// Let's execute all callouts registered for buffer4_send
if (HooksManager::calloutsPresent(Hooks.hook_index_buffer4_send_)) {
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> resp4_options_copy(rsp);
if (HooksManager::calloutsPresent(Hooks.hook_index_lease4_release_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(release);
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(release);
if (HooksManager::calloutsPresent(Hooks.hook_index_lease4_decline_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(decline);
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(decline);
return (dis);
}
+ /// @brief Checks if the state of the callout handle associated with a query
+ /// was reset after the callout invocation.
+ ///
+ /// The check includes verification if the status was set to 'continue' and
+ /// that all arguments were deleted.
+ ///
+ /// @param query pointer to the query which callout handle is associated
+ /// with.
+ void checkCalloutHandleReset(const Pkt4Ptr& query) {
+ CalloutHandlePtr callout_handle = query->getCalloutHandle();
+ ASSERT_TRUE(callout_handle);
+ EXPECT_EQ(CalloutHandle::NEXT_STEP_CONTINUE, callout_handle->getStatus());
+ EXPECT_TRUE(callout_handle->getArgumentNames().empty());
+ }
+
/// Test callback that stores received callout name and pkt4 value
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(dis);
}
// Checks if callouts installed on buffer4_receive is able to change
// ... and check if it is the modified value
ASSERT_FALSE(hwaddr->hwaddr_.empty()); // there must be a MAC address
EXPECT_EQ(0xff, hwaddr->hwaddr_[0]); // check that its first byte was modified
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Checks if callouts installed on buffer4_receive is able to set skip flag that
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Checks if callouts installed on buffer4_receive is able to set drop flag that
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Checks if callouts installed on pkt4_receive are indeed called and the
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_received is able to change
// ... and check if it is the modified value
OptionPtr expected = createOption(DHO_DHCP_CLIENT_IDENTIFIER);
EXPECT_TRUE(clientid->equals(expected));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_received is able to delete
// Check that the server dropped the packet and did not send a response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_received is able to set skip flag that
// check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_received is able to set drop flag that
// check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
EXPECT_TRUE(callback_resp_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_send is able to change
// ... and check if it is the modified value
OptionPtr expected = createOption(DHO_DHCP_SERVER_IDENTIFIER);
EXPECT_TRUE(clientid->equals(expected));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_send is able to delete
// Make sure that it does not have server-id
EXPECT_FALSE(adv->getOption(DHO_DHCP_SERVER_IDENTIFIER));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_skip is able to set skip flag that
// did not do packing on its own)
Pkt4Ptr sent = srv_->fake_sent_.front();
EXPECT_EQ(0, sent->getBuffer().getLength());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt4_drop is able to set drop flag that
// did not do packing on its own)
Pkt4Ptr sent = srv_->fake_sent_.front();
EXPECT_EQ(0, sent->getBuffer().getLength());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer4_send are indeed called and the
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_resp_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Checks if callouts installed on buffer4_send are indeed called and that
// The callout is supposed to fill the output buffer with dummyFile content
ASSERT_EQ(sizeof(dummyFile), adv->getBuffer().getLength());
EXPECT_EQ(0, memcmp(adv->getBuffer().getData(), dummyFile, sizeof(dummyFile)));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Checks if callouts installed on buffer4_send can set skip flag and that flag
// Check that there is no packet sent.
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Checks if callouts installed on buffer4_send can set drop flag and that flag
// Check that there is no packet sent.
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(discover);
}
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// This test checks if callout installed on subnet4_select hook point can pick
// in dynamic pool)
EXPECT_TRUE((*subnets)[1]->inRange(addr));
EXPECT_TRUE((*subnets)[1]->inPool(Lease::TYPE_V4, addr));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// This test verifies that the leases4_committed hook point is not triggered
// Make sure that the callout wasn't called.
EXPECT_TRUE(callback_name_.empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases4_committed hook point is not triggered
// Make sure that the callout wasn't called.
EXPECT_TRUE(callback_name_.empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that incoming (positive) REQUEST/Renewing can be handled
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that a callout installed on lease4_renew can trigger
EXPECT_EQ(temp_timestamp, l->cltt_);
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(addr));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that the callout installed on the leases4_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Renew the lease and make sure that the callout has been executed.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Let's try to renew again but force the client to request a different
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Now request an address that can't be allocated. The client should receive
EXPECT_FALSE(callback_lease4_);
EXPECT_FALSE(callback_deleted_lease4_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that it is possible to park a packet as a result of
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client1.getContext().query_);
+
// Reset all indicators because we'll be now creating a second client.
resetCalloutBuffers();
rsp = client2.getContext().response_;
EXPECT_EQ(DHCPACK, rsp->getType());
EXPECT_EQ("192.0.2.101", rsp->getYiaddr().toText());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client2.getContext().query_);
}
// This test verifies that valid RELEASE triggers lease4_release callouts
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(rel);
}
// This test verifies that skip flag returned by a callout installed on the
// Try by client-id, should be successful as well.
leases = LeaseMgrFactory::instance().getLease4(*client_id_);
EXPECT_EQ(leases.size(), 1);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(rel);
}
// This test verifies that the leases4_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that drop flag returned by a callout installed on the
// Try by client-id, should be successful as well.
leases = LeaseMgrFactory::instance().getLease4(*client_id_);
EXPECT_EQ(leases.size(), 1);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(rel);
}
// Checks that decline4 hooks (lease4_decline) are triggered properly.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// Checks that decline4 hook is able to skip the packet.
// lease returned and lease from the lease manager) all match.
EXPECT_EQ(addr, from_mgr->addr_);
EXPECT_EQ(addr, callback_lease4_->addr_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// Checks that decline4 hook is able to drop the packet.
// lease returned and lease from the lease manager) all match.
EXPECT_EQ(addr, from_mgr->addr_);
EXPECT_EQ(addr, callback_lease4_->addr_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases4_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// Checks if callout installed on host4_identifier can generate an
// Make sure the address offered is the one that was reserved.
EXPECT_EQ("192.0.2.201", adv->getYiaddr().toText());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callout installed on host4_identifier can generate identifier of
// Make sure the address offered is the one that was reserved.
EXPECT_EQ("192.0.2.201", adv->getYiaddr().toText());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
Host::IdentifierType type = Host::IDENT_FLEX;
std::vector<uint8_t> id;
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Pass incoming packet as argument
callout_handle->setArgument("query6", pkt);
if (HooksManager::calloutsPresent(Hooks.hook_index_buffer6_receive_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
+
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(query);
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
-
// Pass incoming packet as argument
callout_handle->setArgument("query6", query);
if (HooksManager::calloutsPresent(Hooks.hook_index_pkt6_receive_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(query);
HooksManager::calloutsPresent(Hooks.hook_index_leases6_committed_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
-
- // Clear skip flag if it was set in previous callouts
- callout_handle->setStatus(CalloutHandle::NEXT_STEP_CONTINUE);
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(query);
// Execute all callouts registered for packet6_send
if (HooksManager::calloutsPresent(Hooks.hook_index_pkt6_send_)) {
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
+
// Enable copying options from the packets within hook library.
ScopedEnableOptionsCopy<Pkt6> query_resp_options_copy(query, rsp);
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
-
// Pass incoming packet as argument
callout_handle->setArgument("query6", query);
// Let's execute all callouts registered for buffer6_send
if (HooksManager::calloutsPresent(Hooks.hook_index_buffer6_send_)) {
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> response6_options_copy(rsp);
if (HooksManager::calloutsPresent(Hooks.hook_index_subnet6_select_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(question);
- // We're reusing callout_handle from previous calls
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(question);
if (HooksManager::calloutsPresent(Hooks.hook_index_lease6_release_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
+
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(query);
if (HooksManager::calloutsPresent(Hooks.hook_index_lease6_release_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(query);
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(query);
if (HooksManager::calloutsPresent(Hooks.hook_index_lease6_decline_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(decline);
- // Delete previously set arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(decline);
return OptionPtr(new Option(Option::V6, option_code, tmp));
}
+ /// @brief Checks if the state of the callout handle associated with a query
+ /// was reset after the callout invocation.
+ ///
+ /// The check includes verification if the status was set to 'continue' and
+ /// that all arguments were deleted.
+ ///
+ /// @param query pointer to the query which callout handle is associated
+ /// with.
+ void checkCalloutHandleReset(const Pkt6Ptr& query) {
+ CalloutHandlePtr callout_handle = query->getCalloutHandle();
+ ASSERT_TRUE(callout_handle);
+ EXPECT_EQ(CalloutHandle::NEXT_STEP_CONTINUE, callout_handle->getStatus());
+ EXPECT_TRUE(callout_handle->getArgumentNames().empty());
+ }
+
/// test callback that stores received callout name and pkt6 value
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_receive is able to change
// ... and check if it is the modified value
EXPECT_EQ(0xff, clientid->getData()[0]);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_receive is able to delete
// Check that the server dropped the packet and did not send a response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_received is able to set skip flag that
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_received is able to set drop flag that
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_receive are indeed called and the
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_received is able to change
// ... and check if it is the modified value
OptionPtr expected = createOption(D6O_CLIENTID);
EXPECT_TRUE(clientid->equals(expected));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_received is able to delete
// Check that the server dropped the packet and did not send a response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_received is able to set skip flag that
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_received is able to set drop flag that
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
EXPECT_TRUE(callback_resp_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_send is able to change
// ... and check if it is the modified value
OptionPtr expected = createOption(D6O_SERVERID);
EXPECT_TRUE(clientid->equals(expected));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_send is able to delete
// Make sure that it does not have server-id
EXPECT_FALSE(adv->getOption(D6O_SERVERID));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_skip is able to set skip flag that
// The actual size of sent packet should be 0
EXPECT_EQ(0, sent->getBuffer().getLength());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on pkt6_drop is able to set drop flag that
// Check that the server does not send the packet
EXPECT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_send are indeed called and the
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_resp_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_send can set skip flag and that flag
// Check that there is no packet sent
EXPECT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callouts installed on buffer6_send can set drop flag and that flag
// Check that there is no packet sent
EXPECT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// This test checks if subnet6_select callout is triggered and reports
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// This test checks if callout installed on subnet6_select hook point can pick
// in dynamic pool)
EXPECT_TRUE((*subnets)[1]->inRange(addr_opt->getAddress()));
EXPECT_TRUE((*subnets)[1]->inPool(Lease::TYPE_NA, addr_opt->getAddress()));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks that subnet6_select is able to drop the packet.
// Check that the server dropped the packet and did not produce any response
ASSERT_EQ(0, srv_->fake_sent_.size());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// This test verifies that the leases6_committed hook point is not triggered
// Make sure that the callout wasn't called.
EXPECT_TRUE(callback_name_.empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases6_committed hook point is not triggered
// Make sure that the callout wasn't called.
EXPECT_TRUE(callback_name_.empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases6_committed hook point is not triggered
// Make sure that the callout wasn't called.
EXPECT_TRUE(callback_name_.empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that it is possible to park a SOLICIT packet including
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client1.getContext().query_);
+
// Reset all indicators because we'll be now creating a second client.
resetCalloutBuffers();
rsp = client2.getContext().response_;
EXPECT_EQ(DHCPV6_REPLY, rsp->getType());
EXPECT_TRUE(client2.hasLeaseForPrefix(IOAddress("2001:db8:1:29::"), 64));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client2.getContext().query_);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Request the lease and make sure that the callout has been executed.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Let's try to request again but force the client to request a different
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// The requested address is just a hint.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Request a prefix: this should lead to an error as no prefix pool
EXPECT_EQ(3, callback_new_leases6_->size());
ASSERT_TRUE(callback_deleted_leases6_);
EXPECT_TRUE(callback_deleted_leases6_->empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Request the lease and make sure that the callout has been executed.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Let's try to request again but force the client to request a different
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// The requested prefix is just a hint.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Request an address: this should lead to an error as no address pool
EXPECT_EQ(3, callback_new_leases6_->size());
ASSERT_TRUE(callback_deleted_leases6_);
EXPECT_TRUE(callback_deleted_leases6_->empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that it is possible to park a packet as a result of
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client1.getContext().query_);
+
// Reset all indicators because we'll be now creating a second client.
resetCalloutBuffers();
rsp = client2.getContext().response_;
EXPECT_EQ(DHCPV6_REPLY, rsp->getType());
EXPECT_TRUE(client2.hasLeaseForAddress(IOAddress("2001:db8:1::29")));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client2.getContext().query_);
}
// This test verifies that it is possible to park a packet as a result of
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client1.getContext().query_);
+
// Reset all indicators because we'll be now creating a second client.
resetCalloutBuffers();
rsp = client2.getContext().response_;
EXPECT_EQ(DHCPV6_REPLY, rsp->getType());
EXPECT_TRUE(client2.hasLeaseForPrefix(IOAddress("2001:db8:1:29::"), 64));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client2.getContext().query_);
}
// This test verifies that incoming (positive) RENEW can be handled properly,
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that incoming (positive) RENEW can be handled properly,
EXPECT_GE(1, abs(cltt - expected));
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(addr_opt->getAddress()));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that incoming (positive) RENEW can be handled properly,
EXPECT_NE(l->preferred_lft_, subnet_->getPreferred());
EXPECT_NE(l->valid_lft_, subnet_->getValid());
EXPECT_NE(l->cltt_, time(NULL));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Renew the lease and make sure that the callout has been executed.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// The renewed address is just a hint.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Renew a prefix: this should lead to an error as no prefix pool
EXPECT_EQ(3, callback_new_leases6_->size());
ASSERT_TRUE(callback_deleted_leases6_);
EXPECT_TRUE(callback_deleted_leases6_->empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Let's try to renew again but force the client to renew a different
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// The renewed prefix is just a hint.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Renew an address: this should lead to an error as no address pool
EXPECT_EQ(3, callback_new_leases6_->size());
ASSERT_TRUE(callback_deleted_leases6_);
EXPECT_TRUE(callback_deleted_leases6_->empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that incoming (positive) RELEASE can be handled properly,
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This is a variant of the previous test that tests that callouts are
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that skip flag returned by a callout installed on the
l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, *duid_, iaid,
subnet_->getID());
ASSERT_TRUE(l);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that drop flag returned by a callout installed on the
l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, *duid_, iaid,
subnet_->getID());
ASSERT_TRUE(l);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that the leases6_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases6_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases6_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that incoming (positive) REBIND can be handled properly,
// Check that the returned lease6 in callout is the same as the one in the
// database
EXPECT_TRUE(*callback_lease6_ == *l);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that incoming (positive) REBIND can be handled properly,
EXPECT_GE(1, abs(cltt - expected));
EXPECT_TRUE(LeaseMgrFactory::instance().deleteLease(addr_opt->getAddress()));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that incoming (positive) REBIND can be handled properly,
EXPECT_NE(l->preferred_lft_, subnet_->getPreferred());
EXPECT_NE(l->valid_lft_, subnet_->getValid());
EXPECT_NE(l->cltt_, time(NULL));
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(req);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Rebind the lease and make sure that the callout has been executed.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Let's try to rebind again but force the client to rebind a different
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// The rebound address is just a hint.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Rebind a prefix: this should lead to an error as no prefix pool
EXPECT_EQ(3, callback_new_leases6_->size());
ASSERT_TRUE(callback_deleted_leases6_);
EXPECT_TRUE(callback_deleted_leases6_->empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the callout installed on the leases6_committed hook
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Rebind the lease and make sure that the callout has been executed.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Let's try to rebind again but force the client to rebind a different
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// The rebound prefix is just a hint.
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
+
resetCalloutBuffers();
// Rebind an address: this should lead to an error as no address pool
EXPECT_EQ(3, callback_new_leases6_->size());
ASSERT_TRUE(callback_deleted_leases6_);
EXPECT_TRUE(callback_deleted_leases6_->empty());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test checks that the basic decline hook (lease6_decline) is
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// Test that the lease6_decline hook point can handle SKIP status.
// And that the parameters passed to callout are consistent with the database
EXPECT_EQ(addr, from_mgr->addr_);
EXPECT_EQ(addr, callback_lease6_->addr_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// Test that the lease6_decline hook point can handle DROP status.
ASSERT_TRUE(from_mgr);
// Now check that it's NOT declined.
EXPECT_EQ(Lease::STATE_DEFAULT, from_mgr->state_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases6_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// This test verifies that the leases6_committed callout is executed
// Pkt passed to a callout must be configured to copy retrieved options.
EXPECT_TRUE(callback_qry_options_copy_);
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(client.getContext().query_);
}
// Should test with one NA and two addresses but need an example first...
ASSERT_TRUE(addr_opt);
ASSERT_EQ("2001:db8::f00", addr_opt->getAddress().toText());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
// Checks if callout installed on host6_identifier can generate an identifier
ASSERT_TRUE(addr_opt);
ASSERT_EQ("2001:db8::f00", addr_opt->getAddress().toText());
+
+ // Check if the callout handle state was reset after the callout.
+ checkCalloutHandleReset(sol);
}
if (ctx.callout_handle_ &&
HooksManager::getHooksManager().calloutsPresent(hook_index_lease6_select_)) {
- // Delete all previous arguments
- ctx.callout_handle_->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(ctx.callout_handle_);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(ctx.query_);
if (ctx.callout_handle_ &&
HooksManager::getHooksManager().calloutsPresent(hook_index_lease6_select_)) {
- // Delete all previous arguments
- ctx.callout_handle_->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(ctx.callout_handle_);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(ctx.query_);
if (HooksManager::calloutsPresent(hook_point)) {
CalloutHandlePtr callout_handle = ctx.callout_handle_;
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt6> query6_options_copy(ctx.query_);
// will not update DNS nor update the database.
bool skipped = false;
if (callout_handle) {
+
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
+
callout_handle->deleteAllArguments();
callout_handle->setArgument("lease6", lease);
callout_handle->setArgument("remove_lease", reclaim_mode == DB_RECLAIM_REMOVE);
// will not update DNS nor update the database.
bool skipped = false;
if (callout_handle) {
- callout_handle->deleteAllArguments();
+
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
+
callout_handle->setArgument("lease4", lease);
callout_handle->setArgument("remove_lease", reclaim_mode == DB_RECLAIM_REMOVE);
callout_handle = HooksManager::createCalloutHandle();
}
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Pass necessary arguments
callout_handle->setArgument("lease4", lease);
callout_handle = HooksManager::createCalloutHandle();
}
- // Delete all previous arguments
- callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
// Pass necessary arguments
callout_handle->setArgument("lease6", lease);
if (ctx.callout_handle_ &&
HooksManager::getHooksManager().calloutsPresent(hook_index_lease4_select_)) {
- // Delete all previous arguments
- ctx.callout_handle_->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(ctx.callout_handle_);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(ctx.query_);
if (HooksManager::getHooksManager().
calloutsPresent(Hooks.hook_index_lease4_renew_)) {
- // Delete all previous arguments
- ctx.callout_handle_->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(ctx.callout_handle_);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(ctx.query_);
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> query4_options_copy(ctx.query_);
- // Delete all previous arguments
- ctx.callout_handle_->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(ctx.callout_handle_);
// Pass necessary arguments
// Pass the original client query
return (hook);
}
-ScopedCalloutHandleState::ScopedCalloutHandleState(CalloutHandlePtr& callout_handle)
+ScopedCalloutHandleState::
+ScopedCalloutHandleState(const CalloutHandlePtr& callout_handle)
: callout_handle_(callout_handle) {
if (!callout_handle_) {
isc_throw(BadValue, "callout_handle argument must not be null");
/// @param callout_handle reference to the pointer to the callout
/// handle which state should be reset.
/// @throw isc::BadValue if the callout handle is null.
- explicit ScopedCalloutHandleState(CalloutHandlePtr& callout_handle);
+ explicit ScopedCalloutHandleState(const CalloutHandlePtr& callout_handle);
/// @brief Destructor.
///