// Let's create a relayed DISCOVER. This particular relayed DISCOVER has
// added option 82 (relay agent info) with 3 suboptions. The server
// is supposed to echo it back in its response.
- Pkt4Ptr dis = captureRelayedDiscover();
+ Pkt4Ptr dis;
+ ASSERT_NO_THROW(dis = captureRelayedDiscover());
// Simulate that we have received that traffic
srv.fakeReceive(dis);
/// @return relayed DISCOVER
Pkt4Ptr captureRelayedDiscover();
+ /// @brief generates a DHCPv4 packet based on provided hex string
+ ///
+ /// @return created packet
+ Pkt4Ptr packetFromCapture(const std::string& hex_string);
+
/// @brief Tests if Discover or Request message is processed correctly
///
/// @param msg_type DHCPDISCOVER or DHCPREQUEST
}; // end of isc::dhcp namespace
}; // end of isc namespace
-#endif // DHCP6_TEST_UTILS_H
+#endif // DHCP4_TEST_UTILS_H
#include <util/encode/hex.h>
/// @file wireshark.cc
-///
+///
/// @brief contains packet captures imported from Wireshark
-///
+///
/// These are actual packets captured over wire. They are used in various
/// tests.
///
namespace dhcp {
namespace test {
+Pkt4Ptr Dhcpv4SrvTest::packetFromCapture(const std::string& hex_string) {
+ std::vector<uint8_t> bin;
+
+ // Decode the hex string and store it in bin (which happens
+ // to be OptionBuffer format)
+ isc::util::encode::decodeHex(hex_string, bin);
+
+ Pkt4Ptr pkt(new Pkt4(&bin[0], bin.size()));
+ captureSetDefaultFields(pkt);
+
+ return (pkt);
+}
+
void Dhcpv4SrvTest::captureSetDefaultFields(const Pkt4Ptr& pkt) {
pkt->setRemotePort(546);
pkt->setRemoteAddr(IOAddress("fe80::1"));
Option: (82) Agent Information Option
Option: (255) End */
- string hex_string =
+ string hex_string =
"010106015d05478d000000000000000000000000000000000afee20120e52ab8151400"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000000000"
"140003000120e52ab81514390205dc5219010420000002020620e52ab8151409090000"
"118b0401020300ff";
- std::vector<uint8_t> bin;
-
- // Decode the hex string and store it in bin (which happens
- // to be OptionBuffer format)
- isc::util::encode::decodeHex(hex_string, bin);
-
- Pkt4Ptr pkt(new Pkt4(&bin[0], bin.size()));
- captureSetDefaultFields(pkt);
-
- return (pkt);
+ return (packetFromCapture(hex_string));
}
}; // end of isc::dhcp::test namespace