|
@@ -37,24 +37,16 @@
|
|
|
|
|
|
#include <list>
|
|
#include <list>
|
|
|
|
|
|
-using namespace isc::dhcp;
|
|
|
|
-using namespace isc::config;
|
|
|
|
-using namespace isc::data;
|
|
|
|
-using namespace isc::hooks;
|
|
|
|
-using namespace isc::asiolink;
|
|
|
|
-using namespace isc::util;
|
|
|
|
-using namespace isc::hooks;
|
|
|
|
-
|
|
|
|
namespace isc {
|
|
namespace isc {
|
|
namespace test {
|
|
namespace test {
|
|
|
|
|
|
/// @brief "naked" Dhcpv6Srv class that exposes internal members
|
|
/// @brief "naked" Dhcpv6Srv class that exposes internal members
|
|
class NakedDhcpv6Srv: public isc::dhcp::Dhcpv6Srv {
|
|
class NakedDhcpv6Srv: public isc::dhcp::Dhcpv6Srv {
|
|
public:
|
|
public:
|
|
- NakedDhcpv6Srv(uint16_t port) : Dhcpv6Srv(port) {
|
|
|
|
|
|
+ NakedDhcpv6Srv(uint16_t port) : isc::dhcp::Dhcpv6Srv(port) {
|
|
// Open the "memfile" database for leases
|
|
// Open the "memfile" database for leases
|
|
std::string memfile = "type=memfile";
|
|
std::string memfile = "type=memfile";
|
|
- LeaseMgrFactory::create(memfile);
|
|
|
|
|
|
+ isc::dhcp::LeaseMgrFactory::create(memfile);
|
|
}
|
|
}
|
|
|
|
|
|
/// @brief fakes packet reception
|
|
/// @brief fakes packet reception
|
|
@@ -70,7 +62,7 @@ public:
|
|
// If there is anything prepared as fake incoming
|
|
// If there is anything prepared as fake incoming
|
|
// traffic, use it
|
|
// traffic, use it
|
|
if (!fake_received_.empty()) {
|
|
if (!fake_received_.empty()) {
|
|
- Pkt6Ptr pkt = fake_received_.front();
|
|
|
|
|
|
+ isc::dhcp::Pkt6Ptr pkt = fake_received_.front();
|
|
fake_received_.pop_front();
|
|
fake_received_.pop_front();
|
|
return (pkt);
|
|
return (pkt);
|
|
}
|
|
}
|
|
@@ -78,7 +70,7 @@ public:
|
|
// If not, just trigger shutdown and
|
|
// If not, just trigger shutdown and
|
|
// return immediately
|
|
// return immediately
|
|
shutdown();
|
|
shutdown();
|
|
- return (Pkt6Ptr());
|
|
|
|
|
|
+ return (isc::dhcp::Pkt6Ptr());
|
|
}
|
|
}
|
|
|
|
|
|
/// @brief fake packet sending
|
|
/// @brief fake packet sending
|
|
@@ -86,20 +78,20 @@ public:
|
|
/// Pretend to send a packet, but instead just store
|
|
/// Pretend to send a packet, but instead just store
|
|
/// it in fake_send_ list where test can later inspect
|
|
/// it in fake_send_ list where test can later inspect
|
|
/// server's response.
|
|
/// server's response.
|
|
- virtual void sendPacket(const Pkt6Ptr& pkt) {
|
|
|
|
|
|
+ virtual void sendPacket(const isc::dhcp::Pkt6Ptr& pkt) {
|
|
fake_sent_.push_back(pkt);
|
|
fake_sent_.push_back(pkt);
|
|
}
|
|
}
|
|
|
|
|
|
/// @brief adds a packet to fake receive queue
|
|
/// @brief adds a packet to fake receive queue
|
|
///
|
|
///
|
|
/// See fake_received_ field for description
|
|
/// See fake_received_ field for description
|
|
- void fakeReceive(const Pkt6Ptr& pkt) {
|
|
|
|
|
|
+ void fakeReceive(const isc::dhcp::Pkt6Ptr& pkt) {
|
|
fake_received_.push_back(pkt);
|
|
fake_received_.push_back(pkt);
|
|
}
|
|
}
|
|
|
|
|
|
virtual ~NakedDhcpv6Srv() {
|
|
virtual ~NakedDhcpv6Srv() {
|
|
// Close the lease database
|
|
// Close the lease database
|
|
- LeaseMgrFactory::destroy();
|
|
|
|
|
|
+ isc::dhcp::LeaseMgrFactory::destroy();
|
|
}
|
|
}
|
|
|
|
|
|
using Dhcpv6Srv::processSolicit;
|
|
using Dhcpv6Srv::processSolicit;
|
|
@@ -121,13 +113,14 @@ public:
|
|
|
|
|
|
/// @brief packets we pretend to receive
|
|
/// @brief packets we pretend to receive
|
|
///
|
|
///
|
|
- /// Instead of setting up sockets on interfaces that change between OSes, it
|
|
|
|
- /// is much easier to fake packet reception. This is a list of packets that
|
|
|
|
- /// we pretend to have received. You can schedule new packets to be received
|
|
|
|
- /// using fakeReceive() and NakedDhcpv6Srv::receivePacket() methods.
|
|
|
|
- std::list<Pkt6Ptr> fake_received_;
|
|
|
|
-
|
|
|
|
- std::list<Pkt6Ptr> fake_sent_;
|
|
|
|
|
|
+ /// Instead of setting up sockets on interfaces that change between
|
|
|
|
+ /// OSes, it is much easier to fake packet reception. This is a list
|
|
|
|
+ /// of packets that we pretend to have received. You can schedule
|
|
|
|
+ /// new packets to be received using fakeReceive() and
|
|
|
|
+ /// NakedDhcpv6Srv::receivePacket() methods.
|
|
|
|
+ std::list<isc::dhcp::Pkt6Ptr> fake_received_;
|
|
|
|
+
|
|
|
|
+ std::list<isc::dhcp::Pkt6Ptr> fake_sent_;
|
|
};
|
|
};
|
|
|
|
|
|
static const char* DUID_FILE = "server-id-test.txt";
|
|
static const char* DUID_FILE = "server-id-test.txt";
|
|
@@ -141,7 +134,8 @@ public:
|
|
// it's ok if that fails. There should not be such a file anyway
|
|
// it's ok if that fails. There should not be such a file anyway
|
|
unlink(DUID_FILE);
|
|
unlink(DUID_FILE);
|
|
|
|
|
|
- const IfaceMgr::IfaceCollection& ifaces = IfaceMgr::instance().getIfaces();
|
|
|
|
|
|
+ const isc::dhcp::IfaceMgr::IfaceCollection& ifaces =
|
|
|
|
+ isc::dhcp::IfaceMgr::instance().getIfaces();
|
|
|
|
|
|
// There must be some interface detected
|
|
// There must be some interface detected
|
|
if (ifaces.empty()) {
|
|
if (ifaces.empty()) {
|
|
@@ -153,47 +147,56 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
// Generate IA_NA or IA_PD option with specified parameters
|
|
// Generate IA_NA or IA_PD option with specified parameters
|
|
- boost::shared_ptr<Option6IA> generateIA(uint16_t type, uint32_t iaid,
|
|
|
|
- uint32_t t1, uint32_t t2);
|
|
|
|
|
|
+ boost::shared_ptr<isc::dhcp::Option6IA> generateIA
|
|
|
|
+ (uint16_t type, uint32_t iaid, uint32_t t1, uint32_t t2);
|
|
|
|
|
|
/// @brief generates interface-id option, based on text
|
|
/// @brief generates interface-id option, based on text
|
|
///
|
|
///
|
|
/// @param iface_id textual representation of the interface-id content
|
|
/// @param iface_id textual representation of the interface-id content
|
|
///
|
|
///
|
|
/// @return pointer to the option object
|
|
/// @return pointer to the option object
|
|
- OptionPtr generateInterfaceId(const std::string& iface_id) {
|
|
|
|
- OptionBuffer tmp(iface_id.begin(), iface_id.end());
|
|
|
|
- return OptionPtr(new Option(Option::V6, D6O_INTERFACE_ID, tmp));
|
|
|
|
|
|
+ isc::dhcp::OptionPtr generateInterfaceId(const std::string& iface_id) {
|
|
|
|
+ isc::dhcp::OptionBuffer tmp(iface_id.begin(), iface_id.end());
|
|
|
|
+ return (isc::dhcp::OptionPtr
|
|
|
|
+ (new isc::dhcp::Option(isc::dhcp::Option::V6,
|
|
|
|
+ D6O_INTERFACE_ID, tmp)));
|
|
}
|
|
}
|
|
|
|
|
|
// Generate client-id option
|
|
// Generate client-id option
|
|
- OptionPtr generateClientId(size_t duid_size = 32) {
|
|
|
|
|
|
+ isc::dhcp::OptionPtr generateClientId(size_t duid_size = 32) {
|
|
|
|
|
|
- OptionBuffer clnt_duid(duid_size);
|
|
|
|
|
|
+ isc::dhcp::OptionBuffer clnt_duid(duid_size);
|
|
for (int i = 0; i < duid_size; i++) {
|
|
for (int i = 0; i < duid_size; i++) {
|
|
clnt_duid[i] = 100 + i;
|
|
clnt_duid[i] = 100 + i;
|
|
}
|
|
}
|
|
|
|
|
|
- duid_ = DuidPtr(new DUID(clnt_duid));
|
|
|
|
|
|
+ duid_ = isc::dhcp::DuidPtr(new isc::dhcp::DUID(clnt_duid));
|
|
|
|
|
|
- return (OptionPtr(new Option(Option::V6, D6O_CLIENTID,
|
|
|
|
- clnt_duid.begin(),
|
|
|
|
- clnt_duid.begin() + duid_size)));
|
|
|
|
|
|
+ return (isc::dhcp::OptionPtr
|
|
|
|
+ (new isc::dhcp::Option(isc::dhcp::Option::V6, D6O_CLIENTID,
|
|
|
|
+ clnt_duid.begin(),
|
|
|
|
+ clnt_duid.begin() + duid_size)));
|
|
}
|
|
}
|
|
|
|
|
|
- // Checks if server response (ADVERTISE or REPLY) includes proper server-id.
|
|
|
|
- void checkServerId(const Pkt6Ptr& rsp, const OptionPtr& expected_srvid) {
|
|
|
|
|
|
+ // Checks if server response (ADVERTISE or REPLY) includes proper
|
|
|
|
+ // server-id.
|
|
|
|
+ void checkServerId(const isc::dhcp::Pkt6Ptr& rsp,
|
|
|
|
+ const isc::dhcp::OptionPtr& expected_srvid)
|
|
|
|
+ {
|
|
// check that server included its server-id
|
|
// check that server included its server-id
|
|
- OptionPtr tmp = rsp->getOption(D6O_SERVERID);
|
|
|
|
|
|
+ isc::dhcp::OptionPtr tmp = rsp->getOption(D6O_SERVERID);
|
|
EXPECT_EQ(tmp->getType(), expected_srvid->getType() );
|
|
EXPECT_EQ(tmp->getType(), expected_srvid->getType() );
|
|
ASSERT_EQ(tmp->len(), expected_srvid->len() );
|
|
ASSERT_EQ(tmp->len(), expected_srvid->len() );
|
|
EXPECT_TRUE(tmp->getData() == expected_srvid->getData());
|
|
EXPECT_TRUE(tmp->getData() == expected_srvid->getData());
|
|
}
|
|
}
|
|
|
|
|
|
- // Checks if server response (ADVERTISE or REPLY) includes proper client-id.
|
|
|
|
- void checkClientId(const Pkt6Ptr& rsp, const OptionPtr& expected_clientid) {
|
|
|
|
|
|
+ // Checks if server response (ADVERTISE or REPLY) includes proper
|
|
|
|
+ // client-id.
|
|
|
|
+ void checkClientId(const isc::dhcp::Pkt6Ptr& rsp,
|
|
|
|
+ const isc::dhcp::OptionPtr& expected_clientid)
|
|
|
|
+ {
|
|
// check that server included our own client-id
|
|
// check that server included our own client-id
|
|
- OptionPtr tmp = rsp->getOption(D6O_CLIENTID);
|
|
|
|
|
|
+ isc::dhcp::OptionPtr tmp = rsp->getOption(D6O_CLIENTID);
|
|
ASSERT_TRUE(tmp);
|
|
ASSERT_TRUE(tmp);
|
|
EXPECT_EQ(expected_clientid->getType(), tmp->getType());
|
|
EXPECT_EQ(expected_clientid->getType(), tmp->getType());
|
|
ASSERT_EQ(expected_clientid->len(), tmp->len());
|
|
ASSERT_EQ(expected_clientid->len(), tmp->len());
|
|
@@ -203,18 +206,21 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
// Checks if server response is a NAK
|
|
// Checks if server response is a NAK
|
|
- void checkNakResponse(const Pkt6Ptr& rsp, uint8_t expected_message_type,
|
|
|
|
|
|
+ void checkNakResponse(const isc::dhcp::Pkt6Ptr& rsp,
|
|
|
|
+ uint8_t expected_message_type,
|
|
uint32_t expected_transid,
|
|
uint32_t expected_transid,
|
|
- uint16_t expected_status_code) {
|
|
|
|
|
|
+ uint16_t expected_status_code)
|
|
|
|
+ {
|
|
// Check if we get response at all
|
|
// Check if we get response at all
|
|
checkResponse(rsp, expected_message_type, expected_transid);
|
|
checkResponse(rsp, expected_message_type, expected_transid);
|
|
|
|
|
|
// Check that IA_NA was returned
|
|
// Check that IA_NA was returned
|
|
- OptionPtr option_ia_na = rsp->getOption(D6O_IA_NA);
|
|
|
|
|
|
+ isc::dhcp::OptionPtr option_ia_na = rsp->getOption(D6O_IA_NA);
|
|
ASSERT_TRUE(option_ia_na);
|
|
ASSERT_TRUE(option_ia_na);
|
|
|
|
|
|
// check that the status is no address available
|
|
// check that the status is no address available
|
|
- boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(option_ia_na);
|
|
|
|
|
|
+ boost::shared_ptr<isc::dhcp::Option6IA> ia =
|
|
|
|
+ boost::dynamic_pointer_cast<isc::dhcp::Option6IA>(option_ia_na);
|
|
ASSERT_TRUE(ia);
|
|
ASSERT_TRUE(ia);
|
|
|
|
|
|
checkIA_NAStatusCode(ia, expected_status_code);
|
|
checkIA_NAStatusCode(ia, expected_status_code);
|
|
@@ -228,8 +234,10 @@ public:
|
|
// Status code indicates type of error encountered (in theory it can also
|
|
// Status code indicates type of error encountered (in theory it can also
|
|
// indicate success, but servers typically don't send success status
|
|
// indicate success, but servers typically don't send success status
|
|
// as this is the default result and it saves bandwidth)
|
|
// as this is the default result and it saves bandwidth)
|
|
- void checkIA_NAStatusCode(const boost::shared_ptr<Option6IA>& ia,
|
|
|
|
- uint16_t expected_status_code) {
|
|
|
|
|
|
+ void checkIA_NAStatusCode
|
|
|
|
+ (const boost::shared_ptr<isc::dhcp::Option6IA>& ia,
|
|
|
|
+ uint16_t expected_status_code)
|
|
|
|
+ {
|
|
// Make sure there is no address assigned.
|
|
// Make sure there is no address assigned.
|
|
EXPECT_FALSE(ia->getOption(D6O_IAADDR));
|
|
EXPECT_FALSE(ia->getOption(D6O_IAADDR));
|
|
|
|
|
|
@@ -237,10 +245,12 @@ public:
|
|
EXPECT_EQ(0, ia->getT1());
|
|
EXPECT_EQ(0, ia->getT1());
|
|
EXPECT_EQ(0, ia->getT2());
|
|
EXPECT_EQ(0, ia->getT2());
|
|
|
|
|
|
- OptionCustomPtr status =
|
|
|
|
- boost::dynamic_pointer_cast<OptionCustom>(ia->getOption(D6O_STATUS_CODE));
|
|
|
|
|
|
+ isc::dhcp::OptionCustomPtr status =
|
|
|
|
+ boost::dynamic_pointer_cast<isc::dhcp::OptionCustom>
|
|
|
|
+ (ia->getOption(D6O_STATUS_CODE));
|
|
|
|
|
|
- // It is ok to not include status success as this is the default behavior
|
|
|
|
|
|
+ // It is ok to not include status success as this is the default
|
|
|
|
+ // behavior
|
|
if (expected_status_code == STATUS_Success && !status) {
|
|
if (expected_status_code == STATUS_Success && !status) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -248,35 +258,42 @@ public:
|
|
EXPECT_TRUE(status);
|
|
EXPECT_TRUE(status);
|
|
|
|
|
|
if (status) {
|
|
if (status) {
|
|
- // We don't have dedicated class for status code, so let's just interpret
|
|
|
|
- // first 2 bytes as status. Remainder of the status code option content is
|
|
|
|
- // just a text explanation what went wrong.
|
|
|
|
|
|
+ // We don't have dedicated class for status code, so let's
|
|
|
|
+ // just interpret first 2 bytes as status. Remainder of the
|
|
|
|
+ // status code option content is just a text explanation
|
|
|
|
+ // what went wrong.
|
|
EXPECT_EQ(static_cast<uint16_t>(expected_status_code),
|
|
EXPECT_EQ(static_cast<uint16_t>(expected_status_code),
|
|
status->readInteger<uint16_t>(0));
|
|
status->readInteger<uint16_t>(0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void checkMsgStatusCode(const Pkt6Ptr& msg, uint16_t expected_status) {
|
|
|
|
- OptionCustomPtr status =
|
|
|
|
- boost::dynamic_pointer_cast<OptionCustom>(msg->getOption(D6O_STATUS_CODE));
|
|
|
|
|
|
+ void checkMsgStatusCode(const isc::dhcp::Pkt6Ptr& msg,
|
|
|
|
+ uint16_t expected_status)
|
|
|
|
+ {
|
|
|
|
+ isc::dhcp::OptionCustomPtr status =
|
|
|
|
+ boost::dynamic_pointer_cast<isc::dhcp::OptionCustom>
|
|
|
|
+ (msg->getOption(D6O_STATUS_CODE));
|
|
|
|
|
|
- // It is ok to not include status success as this is the default behavior
|
|
|
|
|
|
+ // It is ok to not include status success as this is the default
|
|
|
|
+ // behavior
|
|
if (expected_status == STATUS_Success && !status) {
|
|
if (expected_status == STATUS_Success && !status) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
EXPECT_TRUE(status);
|
|
EXPECT_TRUE(status);
|
|
if (status) {
|
|
if (status) {
|
|
- // We don't have dedicated class for status code, so let's just interpret
|
|
|
|
- // first 2 bytes as status. Remainder of the status code option content is
|
|
|
|
- // just a text explanation what went wrong.
|
|
|
|
|
|
+ // We don't have dedicated class for status code, so let's
|
|
|
|
+ // just interpret first 2 bytes as status. Remainder of the
|
|
|
|
+ // status code option content is just a text explanation
|
|
|
|
+ // what went wrong.
|
|
EXPECT_EQ(static_cast<uint16_t>(expected_status),
|
|
EXPECT_EQ(static_cast<uint16_t>(expected_status),
|
|
status->readInteger<uint16_t>(0));
|
|
status->readInteger<uint16_t>(0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Basic checks for generated response (message type and transaction-id).
|
|
// Basic checks for generated response (message type and transaction-id).
|
|
- void checkResponse(const Pkt6Ptr& rsp, uint8_t expected_message_type,
|
|
|
|
|
|
+ void checkResponse(const isc::dhcp::Pkt6Ptr& rsp,
|
|
|
|
+ uint8_t expected_message_type,
|
|
uint32_t expected_transid) {
|
|
uint32_t expected_transid) {
|
|
ASSERT_TRUE(rsp);
|
|
ASSERT_TRUE(rsp);
|
|
EXPECT_EQ(expected_message_type, rsp->getType());
|
|
EXPECT_EQ(expected_message_type, rsp->getType());
|
|
@@ -286,28 +303,27 @@ public:
|
|
virtual ~NakedDhcpv6SrvTest() {
|
|
virtual ~NakedDhcpv6SrvTest() {
|
|
// Let's clean up if there is such a file.
|
|
// Let's clean up if there is such a file.
|
|
unlink(DUID_FILE);
|
|
unlink(DUID_FILE);
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "buffer6_receive");
|
|
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "buffer6_send");
|
|
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "lease6_renew");
|
|
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "lease6_release");
|
|
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "pkt6_receive");
|
|
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "pkt6_send");
|
|
|
|
- HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
|
|
|
|
- "subnet6_select");
|
|
|
|
-
|
|
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("buffer6_receive");
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("buffer6_send");
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("lease6_renew");
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("lease6_release");
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("pkt6_receive");
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("pkt6_send");
|
|
|
|
+ isc::hooks::HooksManager::preCalloutsLibraryHandle()
|
|
|
|
+ .deregisterAllCallouts("subnet6_select");
|
|
};
|
|
};
|
|
|
|
|
|
// A DUID used in most tests (typically as client-id)
|
|
// A DUID used in most tests (typically as client-id)
|
|
- DuidPtr duid_;
|
|
|
|
|
|
+ isc::dhcp::DuidPtr duid_;
|
|
|
|
|
|
int rcode_;
|
|
int rcode_;
|
|
- ConstElementPtr comment_;
|
|
|
|
|
|
+ isc::data::ConstElementPtr comment_;
|
|
|
|
|
|
// Name of a valid network interface
|
|
// Name of a valid network interface
|
|
std::string valid_iface_;
|
|
std::string valid_iface_;
|
|
@@ -324,18 +340,23 @@ public:
|
|
/// Sets up a single subnet6 with one pool for addresses and second
|
|
/// Sets up a single subnet6 with one pool for addresses and second
|
|
/// pool for prefixes.
|
|
/// pool for prefixes.
|
|
Dhcpv6SrvTest() {
|
|
Dhcpv6SrvTest() {
|
|
- subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 48, 1000,
|
|
|
|
- 2000, 3000, 4000));
|
|
|
|
- pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"),
|
|
|
|
- 64));
|
|
|
|
|
|
+ subnet_ = isc::dhcp::Subnet6Ptr
|
|
|
|
+ (new isc::dhcp::Subnet6(isc::asiolink::IOAddress("2001:db8:1::"),
|
|
|
|
+ 48, 1000, 2000, 3000, 4000));
|
|
|
|
+ pool_ = isc::dhcp::Pool6Ptr
|
|
|
|
+ (new isc::dhcp::Pool6(isc::dhcp::Lease::TYPE_NA,
|
|
|
|
+ isc::asiolink::IOAddress("2001:db8:1:1::"),
|
|
|
|
+ 64));
|
|
subnet_->addPool(pool_);
|
|
subnet_->addPool(pool_);
|
|
|
|
|
|
- CfgMgr::instance().deleteSubnets6();
|
|
|
|
- CfgMgr::instance().addSubnet6(subnet_);
|
|
|
|
|
|
+ isc::dhcp::CfgMgr::instance().deleteSubnets6();
|
|
|
|
+ isc::dhcp::CfgMgr::instance().addSubnet6(subnet_);
|
|
|
|
|
|
// configure PD pool
|
|
// configure PD pool
|
|
- pd_pool_ = Pool6Ptr(new Pool6(Lease::TYPE_PD,
|
|
|
|
- IOAddress("2001:db8:1:2::"), 64, 80));
|
|
|
|
|
|
+ pd_pool_ = isc::dhcp::Pool6Ptr
|
|
|
|
+ (new isc::dhcp::Pool6(isc::dhcp::Lease::TYPE_PD,
|
|
|
|
+ isc::asiolink::IOAddress("2001:db8:1:2::"),
|
|
|
|
+ 64, 80));
|
|
subnet_->addPool(pd_pool_);
|
|
subnet_->addPool(pd_pool_);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -343,7 +364,7 @@ public:
|
|
///
|
|
///
|
|
/// Removes existing configuration.
|
|
/// Removes existing configuration.
|
|
~Dhcpv6SrvTest() {
|
|
~Dhcpv6SrvTest() {
|
|
- CfgMgr::instance().deleteSubnets6();
|
|
|
|
|
|
+ isc::dhcp::CfgMgr::instance().deleteSubnets6();
|
|
};
|
|
};
|
|
|
|
|
|
/// @brief Checks that server response (ADVERTISE or REPLY) contains proper
|
|
/// @brief Checks that server response (ADVERTISE or REPLY) contains proper
|
|
@@ -354,8 +375,8 @@ public:
|
|
/// @param expected_t1 expected T1 value
|
|
/// @param expected_t1 expected T1 value
|
|
/// @param expected_t2 expected T2 value
|
|
/// @param expected_t2 expected T2 value
|
|
/// @return IAADDR option for easy chaining with checkIAAddr method
|
|
/// @return IAADDR option for easy chaining with checkIAAddr method
|
|
- boost::shared_ptr<Option6IAAddr>
|
|
|
|
- checkIA_NA(const Pkt6Ptr& rsp, uint32_t expected_iaid,
|
|
|
|
|
|
+ boost::shared_ptr<isc::dhcp::Option6IAAddr>
|
|
|
|
+ checkIA_NA(const isc::dhcp::Pkt6Ptr& rsp, uint32_t expected_iaid,
|
|
uint32_t expected_t1, uint32_t expected_t2);
|
|
uint32_t expected_t1, uint32_t expected_t2);
|
|
|
|
|
|
/// @brief Checks that server response (ADVERTISE or REPLY) contains proper
|
|
/// @brief Checks that server response (ADVERTISE or REPLY) contains proper
|
|
@@ -366,15 +387,15 @@ public:
|
|
/// @param expected_t1 expected T1 value
|
|
/// @param expected_t1 expected T1 value
|
|
/// @param expected_t2 expected T2 value
|
|
/// @param expected_t2 expected T2 value
|
|
/// @return IAPREFIX option for easy chaining with checkIAAddr method
|
|
/// @return IAPREFIX option for easy chaining with checkIAAddr method
|
|
- boost::shared_ptr<Option6IAPrefix>
|
|
|
|
- checkIA_PD(const Pkt6Ptr& rsp, uint32_t expected_iaid,
|
|
|
|
|
|
+ boost::shared_ptr<isc::dhcp::Option6IAPrefix>
|
|
|
|
+ checkIA_PD(const isc::dhcp::Pkt6Ptr& rsp, uint32_t expected_iaid,
|
|
uint32_t expected_t1, uint32_t expected_t2);
|
|
uint32_t expected_t1, uint32_t expected_t2);
|
|
|
|
|
|
// Check that generated IAADDR option contains expected address
|
|
// Check that generated IAADDR option contains expected address
|
|
// and lifetime values match the configured subnet
|
|
// and lifetime values match the configured subnet
|
|
- void checkIAAddr(const boost::shared_ptr<Option6IAAddr>& addr,
|
|
|
|
- const IOAddress& expected_addr,
|
|
|
|
- Lease::Type type) {
|
|
|
|
|
|
+ void checkIAAddr(const boost::shared_ptr<isc::dhcp::Option6IAAddr>& addr,
|
|
|
|
+ const isc::asiolink::IOAddress& expected_addr,
|
|
|
|
+ isc::dhcp::Lease::Type type) {
|
|
|
|
|
|
// Check that the assigned address is indeed from the configured pool.
|
|
// Check that the assigned address is indeed from the configured pool.
|
|
// Note that when comparing addresses, we compare the textual
|
|
// Note that when comparing addresses, we compare the textual
|
|
@@ -388,8 +409,9 @@ public:
|
|
|
|
|
|
// Checks if the lease sent to client is present in the database
|
|
// Checks if the lease sent to client is present in the database
|
|
// and is valid when checked agasint the configured subnet
|
|
// and is valid when checked agasint the configured subnet
|
|
- Lease6Ptr checkLease(const DuidPtr& duid, const OptionPtr& ia_na,
|
|
|
|
- boost::shared_ptr<Option6IAAddr> addr);
|
|
|
|
|
|
+ isc::dhcp::Lease6Ptr checkLease
|
|
|
|
+ (const isc::dhcp::DuidPtr& duid, const isc::dhcp::OptionPtr& ia_na,
|
|
|
|
+ boost::shared_ptr<isc::dhcp::Option6IAAddr> addr);
|
|
|
|
|
|
/// @brief Verifies received IAPrefix option
|
|
/// @brief Verifies received IAPrefix option
|
|
///
|
|
///
|
|
@@ -400,8 +422,9 @@ public:
|
|
/// @param ia_pd IA_PD option that contains the IAPRefix option
|
|
/// @param ia_pd IA_PD option that contains the IAPRefix option
|
|
/// @param prefix pointer to the IAPREFIX option
|
|
/// @param prefix pointer to the IAPREFIX option
|
|
/// @return corresponding IPv6 lease (if found)
|
|
/// @return corresponding IPv6 lease (if found)
|
|
- Lease6Ptr checkPdLease(const DuidPtr& duid, const OptionPtr& ia_pd,
|
|
|
|
- boost::shared_ptr<Option6IAPrefix> prefix);
|
|
|
|
|
|
+ isc::dhcp::Lease6Ptr checkPdLease
|
|
|
|
+ (const isc::dhcp::DuidPtr& duid, const isc::dhcp::OptionPtr& ia_pd,
|
|
|
|
+ boost::shared_ptr<isc::dhcp::Option6IAPrefix> prefix);
|
|
|
|
|
|
/// @brief Creates a message with specified IA
|
|
/// @brief Creates a message with specified IA
|
|
///
|
|
///
|
|
@@ -415,10 +438,10 @@ public:
|
|
/// @param prefix_len length of the prefix (used for prefixes only)
|
|
/// @param prefix_len length of the prefix (used for prefixes only)
|
|
/// @param iaid IA identifier (used in IA_XX option)
|
|
/// @param iaid IA identifier (used in IA_XX option)
|
|
/// @return created message
|
|
/// @return created message
|
|
- Pkt6Ptr
|
|
|
|
- createMessage(uint8_t message_type, Lease::Type lease_type,
|
|
|
|
- const IOAddress& addr, const uint8_t prefix_len,
|
|
|
|
- uint32_t iaid);
|
|
|
|
|
|
+ isc::dhcp::Pkt6Ptr
|
|
|
|
+ createMessage(uint8_t message_type, isc::dhcp::Lease::Type lease_type,
|
|
|
|
+ const isc::asiolink::IOAddress& addr,
|
|
|
|
+ const uint8_t prefix_len, uint32_t iaid);
|
|
|
|
|
|
/// @brief Performs basic (positive) RENEW test
|
|
/// @brief Performs basic (positive) RENEW test
|
|
///
|
|
///
|
|
@@ -432,7 +455,8 @@ public:
|
|
/// @param renew_addr address being sent in RENEW
|
|
/// @param renew_addr address being sent in RENEW
|
|
/// @param prefix_len length of the prefix (128 for addresses)
|
|
/// @param prefix_len length of the prefix (128 for addresses)
|
|
void
|
|
void
|
|
- testRenewBasic(Lease::Type type, const std::string& existing_addr,
|
|
|
|
|
|
+ testRenewBasic(isc::dhcp::Lease::Type type,
|
|
|
|
+ const std::string& existing_addr,
|
|
const std::string& renew_addr, const uint8_t prefix_len);
|
|
const std::string& renew_addr, const uint8_t prefix_len);
|
|
|
|
|
|
/// @brief Performs negative RENEW test
|
|
/// @brief Performs negative RENEW test
|
|
@@ -445,7 +469,8 @@ public:
|
|
/// @param type type (TYPE_NA or TYPE_PD)
|
|
/// @param type type (TYPE_NA or TYPE_PD)
|
|
/// @param addr address being sent in RENEW
|
|
/// @param addr address being sent in RENEW
|
|
void
|
|
void
|
|
- testRenewReject(Lease::Type type, const IOAddress& addr);
|
|
|
|
|
|
+ testRenewReject(isc::dhcp::Lease::Type type,
|
|
|
|
+ const isc::asiolink::IOAddress& addr);
|
|
|
|
|
|
/// @brief Performs basic (positive) RELEASE test
|
|
/// @brief Performs basic (positive) RELEASE test
|
|
///
|
|
///
|
|
@@ -458,44 +483,47 @@ public:
|
|
/// @param existing address to be preinserted into the database
|
|
/// @param existing address to be preinserted into the database
|
|
/// @param release_addr address being sent in RELEASE
|
|
/// @param release_addr address being sent in RELEASE
|
|
void
|
|
void
|
|
- testReleaseBasic(Lease::Type type, const IOAddress& existing,
|
|
|
|
- const IOAddress& release_addr);
|
|
|
|
|
|
+ testReleaseBasic(isc::dhcp::Lease::Type type,
|
|
|
|
+ const isc::asiolink::IOAddress& existing,
|
|
|
|
+ const isc::asiolink::IOAddress& release_addr);
|
|
|
|
|
|
/// @brief Performs negative RELEASE test
|
|
/// @brief Performs negative RELEASE test
|
|
///
|
|
///
|
|
- /// See releaseReject and pdReleaseReject tests for detailed explanation.
|
|
|
|
- /// In essence the test attempts to perform couple failed RELEASE scenarios.
|
|
|
|
|
|
+ /// See releaseReject and pdReleaseReject tests for detailed
|
|
|
|
+ /// explanation. In essence the test attempts to perform couple
|
|
|
|
+ /// failed RELEASE scenarios.
|
|
///
|
|
///
|
|
/// This method does not throw, but uses gtest macros to signify failures.
|
|
/// This method does not throw, but uses gtest macros to signify failures.
|
|
///
|
|
///
|
|
/// @param type type (TYPE_NA or TYPE_PD)
|
|
/// @param type type (TYPE_NA or TYPE_PD)
|
|
/// @param addr address being sent in RELEASE
|
|
/// @param addr address being sent in RELEASE
|
|
void
|
|
void
|
|
- testReleaseReject(Lease::Type type, const IOAddress& addr);
|
|
|
|
|
|
+ testReleaseReject(isc::dhcp::Lease::Type type,
|
|
|
|
+ const isc::asiolink::IOAddress& addr);
|
|
|
|
|
|
// see wireshark.cc for descriptions
|
|
// see wireshark.cc for descriptions
|
|
// The descriptions are too large and too closely related to the
|
|
// The descriptions are too large and too closely related to the
|
|
// code, so it is kept in .cc rather than traditionally in .h
|
|
// code, so it is kept in .cc rather than traditionally in .h
|
|
- Pkt6Ptr captureSimpleSolicit();
|
|
|
|
- Pkt6Ptr captureRelayedSolicit();
|
|
|
|
- Pkt6Ptr captureDocsisRelayedSolicit();
|
|
|
|
- Pkt6Ptr captureeRouterRelayedSolicit();
|
|
|
|
|
|
+ isc::dhcp::Pkt6Ptr captureSimpleSolicit();
|
|
|
|
+ isc::dhcp::Pkt6Ptr captureRelayedSolicit();
|
|
|
|
+ isc::dhcp::Pkt6Ptr captureDocsisRelayedSolicit();
|
|
|
|
+ isc::dhcp::Pkt6Ptr captureeRouterRelayedSolicit();
|
|
|
|
|
|
/// @brief Auxiliary method that sets Pkt6 fields
|
|
/// @brief Auxiliary method that sets Pkt6 fields
|
|
///
|
|
///
|
|
/// Used to reconstruct captured packets. Sets UDP ports, interface names,
|
|
/// Used to reconstruct captured packets. Sets UDP ports, interface names,
|
|
/// and other fields to some believable values.
|
|
/// and other fields to some believable values.
|
|
/// @param pkt packet that will have its fields set
|
|
/// @param pkt packet that will have its fields set
|
|
- void captureSetDefaultFields(const Pkt6Ptr& pkt);
|
|
|
|
|
|
+ void captureSetDefaultFields(const isc::dhcp::Pkt6Ptr& pkt);
|
|
|
|
|
|
/// A subnet used in most tests
|
|
/// A subnet used in most tests
|
|
- Subnet6Ptr subnet_;
|
|
|
|
|
|
+ isc::dhcp::Subnet6Ptr subnet_;
|
|
|
|
|
|
/// A normal, non-temporary pool used in most tests
|
|
/// A normal, non-temporary pool used in most tests
|
|
- Pool6Ptr pool_;
|
|
|
|
|
|
+ isc::dhcp::Pool6Ptr pool_;
|
|
|
|
|
|
/// A prefix pool used in most tests
|
|
/// A prefix pool used in most tests
|
|
- Pool6Ptr pd_pool_;
|
|
|
|
|
|
+ isc::dhcp::Pool6Ptr pd_pool_;
|
|
};
|
|
};
|
|
|
|
|
|
}; // end of isc::test namespace
|
|
}; // end of isc::test namespace
|