Commit 5496d551 authored by Marcin Siodelski's avatar Marcin Siodelski

[1955] Access perf_pktN and pktN class members via getters and setters.

Some of the pktN protected variables are still accessed directly in derived
classes thus warnings have been added in libs.
parent 652738d3
......@@ -579,7 +579,7 @@ INPUT = ../src/lib/exceptions ../src/lib/cc \
../src/lib/testutils ../src/lib/cache ../src/lib/server_common/ \
../src/bin/sockcreator/ ../src/lib/util/ ../src/lib/util/io/ \
../src/lib/resolve ../src/lib/acl ../src/bin/dhcp6 ../src/lib/dhcp \
../src/bin/dhcp4 devel
../src/bin/dhcp4 ../tests/tools/perfdhcp devel
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
......@@ -204,6 +204,11 @@ public:
void
setGiaddr(const isc::asiolink::IOAddress& giaddr) { giaddr_ = giaddr; };
/// @brief Sets transaction-id value
///
/// @param transid transaction-id to be set.
void setTransid(uint32_t transid) { transid_ = transid; }
/// @brief Returns value of transaction-id field.
///
/// @return transaction-id
......@@ -488,12 +493,26 @@ protected:
// end of real DHCPv4 fields
/// output buffer (used during message transmission)
///
/// @warning This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt4. The impact on derived clasess'
/// behavior must be taken into consideration before making
/// changes to this member such as access scope restriction or
/// data format change etc.
isc::util::OutputBuffer bufferOut_;
/// that's the data of input buffer used in RX packet. Note that
/// InputBuffer does not store the data itself, but just expects that
/// data will be valid for the whole life of InputBuffer. Therefore we
/// need to keep the data around.
///
/// @warning This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt4. The impact on derived clasess'
/// behavior must be taken into consideration before making
/// changes to this member such as access scope restriction or
/// data format change etc.
std::vector<uint8_t> data_;
/// message type (e.g. 1=DHCPDISCOVER)
......@@ -502,6 +521,13 @@ protected:
uint8_t msg_type_;
/// collection of options present in this message
///
/// @warnig This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt4. The impact on derived clasess'
/// behavior must be taken into consideration before making
/// changes to this member such as access scope restriction or
/// data format change etc.
isc::dhcp::Option::OptionCollection options_;
/// packet timestamp
......
......@@ -131,6 +131,11 @@ public:
/// @param type message type to be set
void setType(uint8_t type) { msg_type_=type; };
/// @brief Sets transaction-id value
///
/// @param transid transaction-id to be set.
void setTransid(uint32_t transid) { transid_ = transid; }
/// Returns value of transaction-id field
///
/// @return transaction-id
......@@ -241,6 +246,13 @@ public:
/// TODO Need to implement getOptions() as well
/// collection of options present in this message
///
/// @warning This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt6. The impact on derived clasess'
/// behavior must be taken into consideration before making
/// changes to this member such as access scope restriction or
/// data format change etc.
isc::dhcp::Option::OptionCollection options_;
/// @brief Update packet timestamp.
......@@ -296,6 +308,13 @@ protected:
uint32_t transid_;
/// unparsed data (in received packets)
///
/// @warning This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt6. The impact on derived clasess'
/// behavior must be taken into consideration before making
/// changes to this member such as access scope restriction or
/// data format change etc.
OptionBuffer data_;
/// name of the network interface the packet was received/to be sent over
......@@ -322,6 +341,13 @@ protected:
uint16_t remote_port_;
/// output buffer (used during message transmission)
///
/// @warning This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt6. The impact on derived clasess'
/// behavior must be taken into consideration before making
/// changes to this member such as access scope restriction or
/// data format change etc.
isc::util::OutputBuffer bufferOut_;
/// packet timestamp
......
......@@ -31,7 +31,7 @@ PerfPkt4::PerfPkt4(const uint8_t* buf,
uint32_t transid) :
Pkt4(buf, len),
transid_offset_(transid_offset) {
transid_ = transid;
setTransid(transid);
}
bool
......@@ -39,18 +39,23 @@ PerfPkt4::rawPack() {
return (PktTransform::pack(dhcp::Option::V4,
data_,
options_,
transid_offset_,
transid_,
getTransidOffset(),
getTransid(),
bufferOut_));
}
bool
PerfPkt4::rawUnpack() {
return (PktTransform::unpack(dhcp::Option::V4,
data_,
options_,
transid_offset_,
transid_));
uint32_t transid = getTransid();
bool res = PktTransform::unpack(dhcp::Option::V4,
data_,
options_,
getTransidOffset(),
transid);
if (res) {
setTransid(transid);
}
return (res);
}
} // namespace perfdhcp
......
......@@ -74,7 +74,7 @@ public:
/// \brief Returns transaction id offset in packet buffer
///
/// \return Transaction ID offset in packet buffer
size_t getTransIdOffset() const { return transid_offset_; };
size_t getTransidOffset() const { return transid_offset_; };
/// \brief Prepares on-wire format from raw buffer.
///
......
......@@ -33,7 +33,7 @@ PerfPkt6::PerfPkt6(const uint8_t* buf,
uint32_t transid) :
Pkt6(buf, len, Pkt6::UDP),
transid_offset_(transid_offset) {
transid_ = transid;
setTransid(transid);
}
bool
......@@ -41,18 +41,23 @@ PerfPkt6::rawPack() {
return (PktTransform::pack(dhcp::Option::V6,
data_,
options_,
transid_offset_,
transid_,
getTransidOffset(),
getTransid(),
bufferOut_));
}
bool
PerfPkt6::rawUnpack() {
return (PktTransform::unpack(dhcp::Option::V6,
data_,
options_,
transid_offset_,
transid_));
uint32_t transid = getTransid();
bool res = PktTransform::unpack(dhcp::Option::V6,
data_,
options_,
getTransidOffset(),
transid);
if (res) {
setTransid(transid);
}
return (res);
}
} // namespace perfdhcp
......
......@@ -74,7 +74,7 @@ public:
/// \brief Returns transaction id offset in packet buffer
///
/// \return Transaction ID offset in the packet buffer.
size_t getTransIdOffset() const { return transid_offset_; };
size_t getTransidOffset() const { return transid_offset_; };
/// \brief Prepares on-wire format from raw buffer
///
......
......@@ -57,7 +57,7 @@ public:
/// \param in_buffer Input buffer holding intial packet
/// data, this can be directly read from template file
/// \param options Options collection with offsets
/// \param transid_Offset offset of transaction id in a packet,
/// \param transid_offset offset of transaction id in a packet,
/// transaction ID will be written to output buffer at this
/// offset
/// \param transid Transaction ID value
......
......@@ -121,18 +121,18 @@ TEST_F(PerfPkt4Test, Constructor) {
// Test constructor to be used for incoming messages.
// Use default (1) offset value and don't specify transaction id.
boost::scoped_ptr<PerfPkt4> pkt1(new PerfPkt4(data, sizeof(data), 1));
EXPECT_EQ(1, pkt1->getTransIdOffset());
EXPECT_EQ(1, pkt1->getTransidOffset());
// Test constructor to be used for outgoing messages.
// Use non-zero offset and specify transaction id.
boost::scoped_ptr<PerfPkt4> pkt2(new PerfPkt4(data, sizeof(data),
10, 0x010203));
EXPECT_EQ(0x010203, pkt2->getTransid());
EXPECT_EQ(10, pkt2->getTransIdOffset());
EXPECT_EQ(10, pkt2->getTransidOffset());
// Test default constructor. Transaction id offset is expected to be 1.
boost::scoped_ptr<PerfPkt4> pkt3(new PerfPkt4(data, sizeof(data)));
EXPECT_EQ(1, pkt3->getTransIdOffset());
EXPECT_EQ(1, pkt3->getTransidOffset());
}
TEST_F(PerfPkt4Test, RawPack) {
......
......@@ -113,7 +113,7 @@ TEST_F(PerfPkt6Test, Constructor) {
boost::scoped_ptr<PerfPkt6> pkt1(new PerfPkt6(data, sizeof(data)));
EXPECT_EQ(6, pkt1->getData().size());
EXPECT_EQ(0, memcmp(&pkt1->getData()[0], data, sizeof(data)));
EXPECT_EQ(1, pkt1->getTransIdOffset());
EXPECT_EQ(1, pkt1->getTransidOffset());
// Test constructor to be used for outgoing messages.
// Use non-zero offset and specify transaction id.
......@@ -122,7 +122,7 @@ TEST_F(PerfPkt6Test, Constructor) {
EXPECT_EQ(6, pkt2->getData().size());
EXPECT_EQ(0, memcmp(&pkt2->getData()[0], data, sizeof(data)));
EXPECT_EQ(0x010203, pkt2->getTransid());
EXPECT_EQ(10, pkt2->getTransIdOffset());
EXPECT_EQ(10, pkt2->getTransidOffset());
}
TEST_F(PerfPkt6Test, RawPackUnpack) {
......
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