Commit 05616834 authored by Marcin Siodelski's avatar Marcin Siodelski

[4106] Renamed DHCPv4 and DHCPv6 specific IPC classes.

parent 0799cba4
......@@ -188,7 +188,7 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
// Setup DHCPv4-over-DHCPv6 IPC
try {
Dhcp4o6Ipc::instance().open();
Dhcp4to6Ipc::instance().open();
} catch (const std::exception& ex) {
std::ostringstream err;
err << "error starting DHCPv4-over-DHCPv6 IPC "
......
......@@ -24,15 +24,15 @@ using namespace std;
namespace isc {
namespace dhcp {
Dhcp4o6Ipc::Dhcp4o6Ipc() : Dhcp4o6IpcBase() {
Dhcp4to6Ipc::Dhcp4to6Ipc() : Dhcp4o6IpcBase() {
}
Dhcp4o6Ipc& Dhcp4o6Ipc::instance() {
static Dhcp4o6Ipc dhcp4o6_ipc;
return (dhcp4o6_ipc);
Dhcp4to6Ipc& Dhcp4to6Ipc::instance() {
static Dhcp4to6Ipc dhcp4to6_ipc;
return (dhcp4to6_ipc);
}
void Dhcp4o6Ipc::open() {
void Dhcp4to6Ipc::open() {
uint32_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port();
if (port == 0) {
Dhcp4o6IpcBase::close();
......@@ -42,12 +42,12 @@ void Dhcp4o6Ipc::open() {
int old_fd = socket_fd_;
socket_fd_ = Dhcp4o6IpcBase::open(static_cast<uint16_t>(port), ENDPOINT_TYPE_V4);
if ((old_fd == -1) && (socket_fd_ != old_fd)) {
IfaceMgr::instance().addExternalSocket(socket_fd_, Dhcp4o6Ipc::handler);
IfaceMgr::instance().addExternalSocket(socket_fd_, Dhcp4to6Ipc::handler);
}
}
void Dhcp4o6Ipc::handler() {
Dhcp4o6Ipc& ipc = Dhcp4o6Ipc::instance();
void Dhcp4to6Ipc::handler() {
Dhcp4to6Ipc& ipc = Dhcp4to6Ipc::instance();
// Reset received message in case we return from this method before the
// received message pointer is updated.
......@@ -80,7 +80,7 @@ void Dhcp4o6Ipc::handler() {
ipc.received_.reset(new Pkt4o6(msg->getData(), pkt));
}
Pkt4o6Ptr& Dhcp4o6Ipc::getReceived() {
Pkt4o6Ptr& Dhcp4to6Ipc::getReceived() {
return (received_);
}
......
......@@ -28,23 +28,23 @@ namespace isc {
namespace dhcp {
/// @brief Handles DHCPv4-over-DHCPv6 IPC on the DHCPv4 server side
class Dhcp4o6Ipc : public Dhcp4o6IpcBase {
class Dhcp4to6Ipc : public Dhcp4o6IpcBase {
protected:
/// @brief Constructor
///
/// Default constructor
Dhcp4o6Ipc();
Dhcp4to6Ipc();
/// @brief Destructor.
virtual ~Dhcp4o6Ipc() { }
virtual ~Dhcp4to6Ipc() { }
public:
/// @brief Returns pointer to the sole instance of Dhcp4o6Ipc
///
/// Dhcp4o6Ipc is a singleton class
/// Dhcp4to6Ipc is a singleton class
///
/// @return the only existing instance of DHCP4o6 IPC
static Dhcp4o6Ipc& instance();
static Dhcp4to6Ipc& instance();
/// @brief Open communication socket
///
......
......@@ -38,14 +38,14 @@ const uint16_t TEST_PORT = 32000;
typedef Dhcp4o6TestIpc TestIpc;
/// @brief Test fixture class for DHCPv4 endpoint of DHCPv4o6 IPC.
class Dhcp4o6IpcTest : public ::testing::Test {
class Dhcp4to6IpcTest : public ::testing::Test {
public:
/// @brief Constructor
///
/// Configures IPC to use a test port. It also provides a fake
/// configuration of interfaces.
Dhcp4o6IpcTest()
Dhcp4to6IpcTest()
: iface_mgr_test_config_(true) {
configurePort(TEST_PORT);
}
......@@ -68,12 +68,12 @@ private:
};
void
Dhcp4o6IpcTest::configurePort(const uint16_t port) {
Dhcp4to6IpcTest::configurePort(const uint16_t port) {
CfgMgr::instance().getStagingCfg()->setDhcp4o6Port(port);
}
OptionPtr
Dhcp4o6IpcTest::createDHCPv4MsgOption() const {
Dhcp4to6IpcTest::createDHCPv4MsgOption() const {
// Create the DHCPv4 message.
Pkt4Ptr pkt(new Pkt4(DHCPREQUEST, 1234));
// Make a wire representation of the DHCPv4 message.
......@@ -89,9 +89,9 @@ Dhcp4o6IpcTest::createDHCPv4MsgOption() const {
// This test verifies that the DHCPv4 endpoint of the DHCPv4o6 IPC can
// receive messages.
TEST_F(Dhcp4o6IpcTest, receive) {
TEST_F(Dhcp4to6IpcTest, receive) {
// Create instance of the IPC endpoint under test.
Dhcp4o6Ipc& ipc = Dhcp4o6Ipc::instance();
Dhcp4to6Ipc& ipc = Dhcp4to6Ipc::instance();
// Create instance of the IPC endpoint being used as a source of messages.
TestIpc src_ipc(TEST_PORT, TestIpc::ENDPOINT_TYPE_V6);
......@@ -121,9 +121,9 @@ TEST_F(Dhcp4o6IpcTest, receive) {
// This test verifies that message with multiple DHCPv4 query options
// is rejected.
TEST_F(Dhcp4o6IpcTest, receiveMultipleQueries) {
TEST_F(Dhcp4to6IpcTest, receiveMultipleQueries) {
// Create instance of the IPC endpoint under test.
Dhcp4o6Ipc& ipc = Dhcp4o6Ipc::instance();
Dhcp4to6Ipc& ipc = Dhcp4to6Ipc::instance();
// Create instance of the IPC endpoint being used as a source of messages.
TestIpc src_ipc(TEST_PORT, TestIpc::ENDPOINT_TYPE_V6);
......@@ -147,9 +147,9 @@ TEST_F(Dhcp4o6IpcTest, receiveMultipleQueries) {
}
// This test verifies that message with no DHCPv4 query options is rejected.
TEST_F(Dhcp4o6IpcTest, receiveNoQueries) {
TEST_F(Dhcp4to6IpcTest, receiveNoQueries) {
// Create instance of the IPC endpoint under test.
Dhcp4o6Ipc& ipc = Dhcp4o6Ipc::instance();
Dhcp4to6Ipc& ipc = Dhcp4to6Ipc::instance();
// Create instance of the IPC endpoint being used as a source of messages.
TestIpc src_ipc(TEST_PORT, TestIpc::ENDPOINT_TYPE_V6);
......
......@@ -186,7 +186,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
// Setup DHCPv4-over-DHCPv6 IPC
try {
Dhcp4o6Ipc::instance().open();
Dhcp6to4Ipc::instance().open();
} catch (const std::exception& ex) {
std::ostringstream err;
err << "error starting DHCPv4-over-DHCPv6 IPC "
......
......@@ -12,6 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
#include <util/buffer.h>
......@@ -24,14 +25,14 @@ using namespace std;
namespace isc {
namespace dhcp {
Dhcp4o6Ipc::Dhcp4o6Ipc() : Dhcp4o6IpcBase() {}
Dhcp6to4Ipc::Dhcp6to4Ipc() : Dhcp4o6IpcBase() {}
Dhcp4o6Ipc& Dhcp4o6Ipc::instance() {
static Dhcp4o6Ipc dhcp4o6_ipc;
return (dhcp4o6_ipc);
Dhcp6to4Ipc& Dhcp6to4Ipc::instance() {
static Dhcp6to4Ipc dhcp6to4_ipc;
return (dhcp6to4_ipc);
}
void Dhcp4o6Ipc::open() {
void Dhcp6to4Ipc::open() {
uint32_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port();
if (port == 0) {
Dhcp4o6IpcBase::close();
......@@ -41,12 +42,12 @@ void Dhcp4o6Ipc::open() {
int old_fd = socket_fd_;
socket_fd_ = Dhcp4o6IpcBase::open(static_cast<uint16_t>(port), ENDPOINT_TYPE_V6);
if ((old_fd == -1) && (socket_fd_ != old_fd)) {
IfaceMgr::instance().addExternalSocket(socket_fd_, Dhcp4o6Ipc::handler);
IfaceMgr::instance().addExternalSocket(socket_fd_, Dhcp6to4Ipc::handler);
}
}
void Dhcp4o6Ipc::handler() {
Dhcp4o6Ipc& ipc = Dhcp4o6Ipc::instance();
void Dhcp6to4Ipc::handler() {
Dhcp6to4Ipc& ipc = Dhcp6to4Ipc::instance();
// Receive message from IPC.
Pkt6Ptr pkt = ipc.receive();
......
......@@ -26,15 +26,15 @@ namespace isc {
namespace dhcp {
/// @brief Handles DHCPv4-over-DHCPv6 IPC on the DHCPv6 server side
class Dhcp4o6Ipc : public Dhcp4o6IpcBase {
class Dhcp6to4Ipc : public Dhcp4o6IpcBase {
protected:
/// @brief Constructor
///
/// Default constructor
Dhcp4o6Ipc();
Dhcp6to4Ipc();
/// @brief Destructor.
virtual ~Dhcp4o6Ipc() { }
virtual ~Dhcp6to4Ipc() { }
public:
/// @brief Returns pointer to the sole instance of Dhcp4o6Ipc
......@@ -42,7 +42,7 @@ public:
/// Dhcp4o6Ipc is a singleton class
///
/// @return the only existing instance of DHCP4o6 IPC
static Dhcp4o6Ipc& instance();
static Dhcp6to4Ipc& instance();
/// @brief Open communication socket
///
......
......@@ -241,7 +241,7 @@ Dhcpv6Srv::~Dhcpv6Srv() {
}
try {
Dhcp4o6Ipc::instance().close();
Dhcp6to4Ipc::instance().close();
} catch(const std::exception& ex) {
// Highly unlikely, but lets Report it but go on
// LOG_ERROR(dhcp6_logger, DHCP6_SRV_DHCP4O6_ERROR).arg(ex.what());
......
......@@ -39,14 +39,14 @@ const uint16_t TEST_PORT = 32000;
typedef Dhcp4o6TestIpc TestIpc;
/// @brief Test fixture class for DHCPv4 endpoint of DHCPv4o6 IPC.
class Dhcp4o6IpcTest : public ::testing::Test {
class Dhcp6to4IpcTest : public ::testing::Test {
public:
/// @brief Constructor
///
/// Configures IPC to use a test port. It also provides a fake
/// configuration of interfaces and opens IPv6 sockets.
Dhcp4o6IpcTest()
Dhcp6to4IpcTest()
: iface_mgr_test_config_(true) {
IfaceMgr::instance().openSockets6();
configurePort(TEST_PORT);
......@@ -69,12 +69,12 @@ private:
};
void
Dhcp4o6IpcTest::configurePort(const uint16_t port) {
Dhcp6to4IpcTest::configurePort(const uint16_t port) {
CfgMgr::instance().getStagingCfg()->setDhcp4o6Port(port);
}
OptionPtr
Dhcp4o6IpcTest::createDHCPv4MsgOption() const {
Dhcp6to4IpcTest::createDHCPv4MsgOption() const {
// Create the DHCPv4 message.
Pkt4Ptr pkt(new Pkt4(DHCPREQUEST, 1234));
// Make a wire representation of the DHCPv4 message.
......@@ -90,9 +90,9 @@ Dhcp4o6IpcTest::createDHCPv4MsgOption() const {
// This test verifies that the DHCPv4 endpoint of the DHCPv4o6 IPC can
// receive messages.
TEST_F(Dhcp4o6IpcTest, receive) {
TEST_F(Dhcp6to4IpcTest, receive) {
// Create instance of the IPC endpoint under test.
Dhcp4o6Ipc& ipc = Dhcp4o6Ipc::instance();
Dhcp6to4Ipc& ipc = Dhcp6to4Ipc::instance();
// Create instance of the IPC endpoint being used as a source of messages.
TestIpc src_ipc(TEST_PORT, TestIpc::ENDPOINT_TYPE_V4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment