|
@@ -197,7 +197,7 @@ public:
|
|
buffer4_receive_callout(CalloutHandle& callout_handle) {
|
|
buffer4_receive_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("buffer4_receive");
|
|
callback_name_ = string("buffer4_receive");
|
|
|
|
|
|
- callout_handle.getArgument("query4", callback_pkt4_);
|
|
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
|
|
|
|
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
return (0);
|
|
return (0);
|
|
@@ -242,7 +242,7 @@ public:
|
|
pkt4_receive_callout(CalloutHandle& callout_handle) {
|
|
pkt4_receive_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("pkt4_receive");
|
|
callback_name_ = string("pkt4_receive");
|
|
|
|
|
|
- callout_handle.getArgument("query4", callback_pkt4_);
|
|
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
|
|
|
|
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
return (0);
|
|
return (0);
|
|
@@ -307,9 +307,9 @@ public:
|
|
pkt4_send_callout(CalloutHandle& callout_handle) {
|
|
pkt4_send_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("pkt4_send");
|
|
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();
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
return (0);
|
|
return (0);
|
|
@@ -372,7 +372,7 @@ public:
|
|
buffer4_send_callout(CalloutHandle& callout_handle) {
|
|
buffer4_send_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("buffer4_send");
|
|
callback_name_ = string("buffer4_send");
|
|
|
|
|
|
- callout_handle.getArgument("response4", callback_pkt4_);
|
|
+ callout_handle.getArgument("response4", callback_resp_pkt4_);
|
|
|
|
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
return (0);
|
|
return (0);
|
|
@@ -412,7 +412,7 @@ public:
|
|
subnet4_select_callout(CalloutHandle& callout_handle) {
|
|
subnet4_select_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("subnet4_select");
|
|
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("subnet4", callback_subnet4_);
|
|
callout_handle.getArgument("subnet4collection", callback_subnet4collection_);
|
|
callout_handle.getArgument("subnet4collection", callback_subnet4collection_);
|
|
|
|
|
|
@@ -450,7 +450,7 @@ public:
|
|
lease4_release_callout(CalloutHandle& callout_handle) {
|
|
lease4_release_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("lease4_release");
|
|
callback_name_ = string("lease4_release");
|
|
|
|
|
|
- callout_handle.getArgument("query4", callback_pkt4_);
|
|
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
|
|
callout_handle.getArgument("lease4", callback_lease4_);
|
|
callout_handle.getArgument("lease4", callback_lease4_);
|
|
|
|
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
callback_argument_names_ = callout_handle.getArgumentNames();
|
|
@@ -464,6 +464,7 @@ public:
|
|
lease4_renew_callout(CalloutHandle& callout_handle) {
|
|
lease4_renew_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("lease4_renew");
|
|
callback_name_ = string("lease4_renew");
|
|
|
|
|
|
|
|
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
|
|
callout_handle.getArgument("subnet4", callback_subnet4_);
|
|
callout_handle.getArgument("subnet4", callback_subnet4_);
|
|
callout_handle.getArgument("lease4", callback_lease4_);
|
|
callout_handle.getArgument("lease4", callback_lease4_);
|
|
callout_handle.getArgument("hwaddr", callback_hwaddr_);
|
|
callout_handle.getArgument("hwaddr", callback_hwaddr_);
|
|
@@ -480,7 +481,7 @@ public:
|
|
static int
|
|
static int
|
|
lease4_decline_callout(CalloutHandle& callout_handle) {
|
|
lease4_decline_callout(CalloutHandle& callout_handle) {
|
|
callback_name_ = string("lease4_decline");
|
|
callback_name_ = string("lease4_decline");
|
|
- callout_handle.getArgument("query4", callback_pkt4_);
|
|
+ callout_handle.getArgument("query4", callback_qry_pkt4_);
|
|
callout_handle.getArgument("lease4", callback_lease4_);
|
|
callout_handle.getArgument("lease4", callback_lease4_);
|
|
|
|
|
|
return (0);
|
|
return (0);
|
|
@@ -500,8 +501,8 @@ public:
|
|
/// resets buffers used to store data received by callouts
|
|
/// resets buffers used to store data received by callouts
|
|
void resetCalloutBuffers() {
|
|
void resetCalloutBuffers() {
|
|
callback_name_ = string("");
|
|
callback_name_ = string("");
|
|
- callback_pkt4_.reset();
|
|
+ callback_qry_pkt4_.reset();
|
|
- callback_pkt4_query_.reset();
|
|
+ callback_qry_pkt4_.reset();
|
|
callback_lease4_.reset();
|
|
callback_lease4_.reset();
|
|
callback_hwaddr_.reset();
|
|
callback_hwaddr_.reset();
|
|
callback_clientid_.reset();
|
|
callback_clientid_.reset();
|
|
@@ -518,14 +519,11 @@ public:
|
|
/// String name of the received callout
|
|
/// String name of the received callout
|
|
static string callback_name_;
|
|
static string callback_name_;
|
|
|
|
|
|
- /// Pkt4 structure returned in the callout
|
|
+ /// Client/query Pkt4 structure returned in the callout
|
|
- static Pkt4Ptr callback_pkt4_;
|
|
+ static Pkt4Ptr callback_qry_pkt4_;
|
|
|
|
|
|
- /// @brief Pkt4 structure returned in the callout
|
|
+ /// Server/response Pkt4 structure returned in the callout
|
|
- ///
|
|
+ static Pkt4Ptr callback_resp_pkt4_;
|
|
- /// pkt4_send hook now passes both the query and the response,
|
|
|
|
- /// so we actually need two fields.
|
|
|
|
- static Pkt4Ptr callback_pkt4_query_;
|
|
|
|
|
|
|
|
/// Lease4 structure returned in the callout
|
|
/// Lease4 structure returned in the callout
|
|
static Lease4Ptr callback_lease4_;
|
|
static Lease4Ptr callback_lease4_;
|
|
@@ -549,8 +547,8 @@ public:
|
|
// The following fields are used in testing pkt4_receive_callout.
|
|
// The following fields are used in testing pkt4_receive_callout.
|
|
// See fields description in the class for details
|
|
// See fields description in the class for details
|
|
string HooksDhcpv4SrvTest::callback_name_;
|
|
string HooksDhcpv4SrvTest::callback_name_;
|
|
-Pkt4Ptr HooksDhcpv4SrvTest::callback_pkt4_;
|
|
+Pkt4Ptr HooksDhcpv4SrvTest::callback_qry_pkt4_;
|
|
-Pkt4Ptr HooksDhcpv4SrvTest::callback_pkt4_query_;
|
|
+Pkt4Ptr HooksDhcpv4SrvTest::callback_resp_pkt4_;
|
|
Subnet4Ptr HooksDhcpv4SrvTest::callback_subnet4_;
|
|
Subnet4Ptr HooksDhcpv4SrvTest::callback_subnet4_;
|
|
HWAddrPtr HooksDhcpv4SrvTest::callback_hwaddr_;
|
|
HWAddrPtr HooksDhcpv4SrvTest::callback_hwaddr_;
|
|
ClientIdPtr HooksDhcpv4SrvTest::callback_clientid_;
|
|
ClientIdPtr HooksDhcpv4SrvTest::callback_clientid_;
|
|
@@ -618,7 +616,7 @@ TEST_F(HooksDhcpv4SrvTest, Buffer4ReceiveSimple) {
|
|
EXPECT_EQ("buffer4_receive", callback_name_);
|
|
EXPECT_EQ("buffer4_receive", callback_name_);
|
|
|
|
|
|
// Check that pkt4 argument passing was successful and returned proper value
|
|
// 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
|
|
// Check that all expected parameters are there
|
|
vector<string> expected_argument_names;
|
|
vector<string> expected_argument_names;
|
|
@@ -723,7 +721,7 @@ TEST_F(HooksDhcpv4SrvTest, pkt4ReceiveSimple) {
|
|
EXPECT_EQ("pkt4_receive", callback_name_);
|
|
EXPECT_EQ("pkt4_receive", callback_name_);
|
|
|
|
|
|
// check that pkt4 argument passing was successful and returned proper value
|
|
// 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
|
|
// Check that all expected parameters are there
|
|
vector<string> expected_argument_names;
|
|
vector<string> expected_argument_names;
|
|
@@ -853,12 +851,12 @@ TEST_F(HooksDhcpv4SrvTest, pkt4SendSimple) {
|
|
Pkt4Ptr adv = srv_->fake_sent_.front();
|
|
Pkt4Ptr adv = srv_->fake_sent_.front();
|
|
|
|
|
|
// Check that pkt4 argument passing was successful and returned proper value
|
|
// Check that pkt4 argument passing was successful and returned proper value
|
|
- ASSERT_TRUE(callback_pkt4_);
|
|
+ ASSERT_TRUE(callback_resp_pkt4_);
|
|
- EXPECT_TRUE(callback_pkt4_.get() == adv.get());
|
|
+ EXPECT_TRUE(callback_resp_pkt4_.get() == adv.get());
|
|
|
|
|
|
// That that the query4 argument was correctly set to the Discover we sent.
|
|
// That that the query4 argument was correctly set to the Discover we sent.
|
|
- ASSERT_TRUE(callback_pkt4_query_);
|
|
+ ASSERT_TRUE(callback_qry_pkt4_);
|
|
- EXPECT_TRUE(callback_pkt4_query_.get() == sol.get());
|
|
+ EXPECT_TRUE(callback_qry_pkt4_.get() == sol.get());
|
|
|
|
|
|
// Check that all expected parameters are there
|
|
// Check that all expected parameters are there
|
|
vector<string> expected_argument_names;
|
|
vector<string> expected_argument_names;
|
|
@@ -1002,7 +1000,7 @@ TEST_F(HooksDhcpv4SrvTest, buffer4SendSimple) {
|
|
Pkt4Ptr adv = srv_->fake_sent_.front();
|
|
Pkt4Ptr adv = srv_->fake_sent_.front();
|
|
|
|
|
|
// Check that pkt4 argument passing was successful and returned proper value
|
|
// 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
|
|
// Check that all expected parameters are there
|
|
vector<string> expected_argument_names;
|
|
vector<string> expected_argument_names;
|
|
@@ -1124,7 +1122,7 @@ TEST_F(HooksDhcpv4SrvTest, subnet4SelectSimple) {
|
|
EXPECT_EQ("subnet4_select", callback_name_);
|
|
EXPECT_EQ("subnet4_select", callback_name_);
|
|
|
|
|
|
// Check that pkt4 argument passing was successful and returned proper value
|
|
// 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 =
|
|
const Subnet4Collection* exp_subnets =
|
|
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
|
|
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
|
|
@@ -1274,6 +1272,10 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) {
|
|
// Check that the callback called is indeed the one we installed
|
|
// Check that the callback called is indeed the one we installed
|
|
EXPECT_EQ("lease4_renew", callback_name_);
|
|
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
|
|
// Check that hwaddr parameter is passed properly
|
|
ASSERT_TRUE(callback_hwaddr_);
|
|
ASSERT_TRUE(callback_hwaddr_);
|
|
EXPECT_TRUE(*callback_hwaddr_ == *req->getHWAddr());
|
|
EXPECT_TRUE(*callback_hwaddr_ == *req->getHWAddr());
|
|
@@ -1288,6 +1290,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) {
|
|
|
|
|
|
// Check if all expected parameters were really received
|
|
// Check if all expected parameters were really received
|
|
vector<string> expected_argument_names;
|
|
vector<string> expected_argument_names;
|
|
|
|
+ expected_argument_names.push_back("query4");
|
|
expected_argument_names.push_back("subnet4");
|
|
expected_argument_names.push_back("subnet4");
|
|
expected_argument_names.push_back("clientid");
|
|
expected_argument_names.push_back("clientid");
|
|
expected_argument_names.push_back("hwaddr");
|
|
expected_argument_names.push_back("hwaddr");
|
|
@@ -1444,7 +1447,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSimple) {
|
|
EXPECT_EQ("lease4_release", callback_name_);
|
|
EXPECT_EQ("lease4_release", callback_name_);
|
|
|
|
|
|
// Check that pkt4 argument passing was successful and returned proper value
|
|
// 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
|
|
// Check if all expected parameters were really received
|
|
vector<string> expected_argument_names;
|
|
vector<string> expected_argument_names;
|
|
@@ -1540,15 +1543,15 @@ TEST_F(HooksDhcpv4SrvTest, HooksDecline) {
|
|
// Verifying DHCPDECLINE is a bit tricky, as it is created somewhere in
|
|
// Verifying DHCPDECLINE is a bit tricky, as it is created somewhere in
|
|
// acquireAndDecline. We'll just verify that it's really a DECLINE
|
|
// acquireAndDecline. We'll just verify that it's really a DECLINE
|
|
// and that its address is equal to what we have in LeaseMgr.
|
|
// 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_);
|
|
ASSERT_TRUE(callback_lease4_);
|
|
|
|
|
|
// Check that it's the proper packet that was reported.
|
|
// 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.
|
|
// Extract the address being declined.
|
|
OptionCustomPtr opt_declined_addr = boost::dynamic_pointer_cast<
|
|
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);
|
|
ASSERT_TRUE(opt_declined_addr);
|
|
IOAddress addr(opt_declined_addr->readAddress());
|
|
IOAddress addr(opt_declined_addr->readAddress());
|
|
|
|
|
|
@@ -1584,15 +1587,15 @@ TEST_F(HooksDhcpv4SrvTest, HooksDeclineDrop) {
|
|
// Verifying DHCPDECLINE is a bit tricky, as it is created somewhere in
|
|
// Verifying DHCPDECLINE is a bit tricky, as it is created somewhere in
|
|
// acquireAndDecline. We'll just verify that it's really a DECLINE
|
|
// acquireAndDecline. We'll just verify that it's really a DECLINE
|
|
// and that its address is equal to what we have in LeaseMgr.
|
|
// 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_);
|
|
ASSERT_TRUE(callback_lease4_);
|
|
|
|
|
|
// Check that it's the proper packet that was reported.
|
|
// 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.
|
|
// Extract the address being declined.
|
|
OptionCustomPtr opt_declined_addr = boost::dynamic_pointer_cast<
|
|
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);
|
|
ASSERT_TRUE(opt_declined_addr);
|
|
IOAddress addr(opt_declined_addr->readAddress());
|
|
IOAddress addr(opt_declined_addr->readAddress());
|
|
|
|
|