2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[4027] Minor corrections.

This commit is contained in:
Tomek Mrugalski
2015-10-31 18:49:07 +09:00
parent 3435b6f64d
commit b8b57816c2
2 changed files with 12 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ public:
/// @brief Constructor, used in message reception. /// @brief Constructor, used in message reception.
/// ///
/// @param pkt4 DHCPv4 message /// @param pkt4 Content of the DHCPv4-message option
/// @param pkt6 encapsulating unpacked DHCPv6 message /// @param pkt6 encapsulating unpacked DHCPv6 message
/// the DHCPv4 message option will be removed /// the DHCPv4 message option will be removed
Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6); Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6);
@@ -52,10 +52,10 @@ public:
/// ///
/// Calls pack() on both DHCPv4 and DHCPv6 parts /// Calls pack() on both DHCPv4 and DHCPv6 parts
/// Inserts the DHCPv4-message option /// Inserts the DHCPv4-message option
/// @ref pkt4::pack and @ref pkt6::pack /// @ref Pkt4::pack and @ref Pkt6::pack
virtual void pack(); virtual void pack();
/// @brief Checks if a DHCPv4 message has beeb transported over DHCPv6 /// @brief Checks if a DHCPv4 message has been transported over DHCPv6
/// ///
/// @return Boolean value which indicates whether the message is /// @return Boolean value which indicates whether the message is
/// transported over DHCPv6 (true) or native DHCPv4 (false) /// transported over DHCPv6 (true) or native DHCPv4 (false)

View File

@@ -27,6 +27,9 @@
using namespace isc::dhcp; using namespace isc::dhcp;
namespace { namespace {
/// @brief A Fixture class dedicated to testing of the Pkt4o6 class that
/// represents a DHCPv4-over-DHCPv6 packet.
class Pkt4o6Test : public ::testing::Test { class Pkt4o6Test : public ::testing::Test {
protected: protected:
Pkt4o6Test() : Pkt4o6Test() :
@@ -48,6 +51,7 @@ protected:
OptionBuffer buffer4_; // wire-format data buffer of pkt4_ OptionBuffer buffer4_; // wire-format data buffer of pkt4_
}; };
// This test verifies that the constructors are working as expected.
TEST_F(Pkt4o6Test, construct) { TEST_F(Pkt4o6Test, construct) {
// Construct 4o6 packet, unpack the data to examine it // Construct 4o6 packet, unpack the data to examine it
boost::scoped_ptr<Pkt4o6> pkt4o6(new Pkt4o6(buffer4_, pkt6_)); boost::scoped_ptr<Pkt4o6> pkt4o6(new Pkt4o6(buffer4_, pkt6_));
@@ -68,6 +72,8 @@ TEST_F(Pkt4o6Test, construct) {
EXPECT_EQ(DHCPDISCOVER, pkt4o6->getType()); EXPECT_EQ(DHCPDISCOVER, pkt4o6->getType());
} }
// This test verifies that the pack() method handles the building
// process correctly.
TEST_F(Pkt4o6Test, pack) { TEST_F(Pkt4o6Test, pack) {
// prepare unpacked DHCPv4 packet (see the note in constructor test) // prepare unpacked DHCPv4 packet (see the note in constructor test)
pkt4_.reset(new Pkt4(&buffer4_[0], buffer4_.size())); pkt4_.reset(new Pkt4(&buffer4_[0], buffer4_.size()));
@@ -86,7 +92,7 @@ TEST_F(Pkt4o6Test, pack) {
// Check the DHCPv4 message option content (Pkt4o6 class is not responsible // Check the DHCPv4 message option content (Pkt4o6 class is not responsible
// for making it valid, so we won't examine it) // for making it valid, so we won't examine it)
const u_int8_t* cp = static_cast<const u_int8_t*>( const uint8_t* cp = static_cast<const u_int8_t*>(
pkt4o6.getPkt6()->getBuffer().getData()); pkt4o6.getPkt6()->getBuffer().getData());
EXPECT_EQ(0, cp[4]); EXPECT_EQ(0, cp[4]);
EXPECT_EQ(D6O_DHCPV4_MSG, cp[5]); EXPECT_EQ(D6O_DHCPV4_MSG, cp[5]);
@@ -95,4 +101,6 @@ TEST_F(Pkt4o6Test, pack) {
EXPECT_EQ(0, memcmp(&cp[8], &buffer4_[0], buffer4_.size())); EXPECT_EQ(0, memcmp(&cp[8], &buffer4_[0], buffer4_.size()));
} }
/// @todo: Add a test that handles actual DHCP4o6 traffic capture
/// once we get it. We should add the capture to pkt_captures{4,6}.cc
} }