summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/tests/pkt_captures.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:15:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:15:43 +0000
commitf5f56e1a1c4d9e9496fcb9d81131066a964ccd23 (patch)
tree49e44c6f87febed37efb953ab5485aa49f6481a7 /src/lib/dhcp/tests/pkt_captures.h
parentInitial commit. (diff)
downloadisc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.tar.xz
isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.zip
Adding upstream version 2.4.1.upstream/2.4.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/dhcp/tests/pkt_captures.h')
-rw-r--r--src/lib/dhcp/tests/pkt_captures.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/lib/dhcp/tests/pkt_captures.h b/src/lib/dhcp/tests/pkt_captures.h
new file mode 100644
index 0000000..7063e1a
--- /dev/null
+++ b/src/lib/dhcp/tests/pkt_captures.h
@@ -0,0 +1,103 @@
+// Copyright (C) 2014-2019,2021 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef PKT_CAPTURES_H
+#define PKT_CAPTURES_H
+
+#include <dhcp/pkt4.h>
+#include <dhcp/pkt6.h>
+
+namespace isc {
+namespace dhcp {
+namespace test {
+
+class PktCaptures {
+public:
+
+ /// @brief returns captured DISCOVER that went through a relay
+ ///
+ /// See method code for a detailed explanation. This is a discover from
+ /// docsis3.0 device (Cable Modem)
+ ///
+ /// @return relayed DISCOVER
+ static isc::dhcp::Pkt4Ptr captureRelayedDiscover();
+
+ /// @brief returns captured DISCOVER that went through a relay
+ ///
+ /// See method code for a detailed explanation. This is a discover from
+ /// eRouter1.0 device (CPE device integrated with cable modem)
+ ///
+ /// @return relayed DISCOVER
+ static isc::dhcp::Pkt4Ptr captureRelayedDiscover2();
+
+ /// @brief returns captured DISCOVER that went through a relay
+ ///
+ /// See method code for a detailed explanation. This is a discover from
+ /// a buggy relay device with a bad suboption.
+ ///
+ /// @return relayed DISCOVER
+ static isc::dhcp::Pkt4Ptr captureBadRelayedDiscover();
+
+ /// @brief returns captured DISCOVER that contains a valid VIVSO option
+ ///
+ /// See method code for a detailed explanation.
+ ///
+ /// @return relayed DISCOVER
+ static isc::dhcp::Pkt4Ptr discoverWithValidVIVSO();
+
+ /// @brief returns captured DISCOVER that contains a truncated VIVSO option
+ ///
+ /// See method code for a detailed explanation.
+ ///
+ /// @return relayed DISCOVER
+ static isc::dhcp::Pkt4Ptr discoverWithTruncatedVIVSO();
+
+ /// @brief returns captured DISCOVER from Genexis hardware.
+ ///
+ /// This device in uncommon, because it doesn't send VIVSO in Discover, but
+ /// expects one in Offer.
+ /// @return DISCOVER.
+ static isc::dhcp::Pkt4Ptr discoverGenexis();
+
+ // see pkt_captures6.cc for descriptions
+ // The descriptions are too large and too closely related to the
+ // code, so it is kept in .cc rather than traditionally in .h
+ static isc::dhcp::Pkt6Ptr captureSimpleSolicit();
+ static isc::dhcp::Pkt6Ptr captureRelayedSolicit();
+ static isc::dhcp::Pkt6Ptr captureDocsisRelayedSolicit();
+ static isc::dhcp::Pkt6Ptr captureeRouterRelayedSolicit();
+ static isc::dhcp::Pkt6Ptr captureCableLabsShortVendorClass();
+ static isc::dhcp::Pkt6Ptr captureRelayed2xRSOO();
+ static isc::dhcp::Pkt6Ptr captureSolicitWithVIVSO();
+ static isc::dhcp::Pkt6Ptr captureSolicitWithTruncatedVIVSO();
+
+protected:
+ /// @brief Auxiliary method that sets Pkt6 fields
+ ///
+ /// Used to reconstruct captured packets. Sets UDP ports, interface names,
+ /// and other fields to some believable values.
+ /// @param pkt packet that will have its fields set
+ static void captureSetDefaultFields(const isc::dhcp::Pkt6Ptr& pkt);
+
+
+ /// @brief generates a DHCPv4 packet based on provided hex string
+ ///
+ /// @return created packet
+ static isc::dhcp::Pkt4Ptr packetFromCapture(const std::string& hex_string);
+
+ /// @brief sets default fields in a captured packet
+ ///
+ /// Sets UDP ports, addresses and interface.
+ ///
+ /// @param pkt packet to have default fields set
+ static void captureSetDefaultFields(const isc::dhcp::Pkt4Ptr& pkt);
+};
+
+}; // end of namespace isc::dhcp::test
+}; // end of namespace isc::dhcp
+}; // end of namespace isc
+
+#endif