diff --git a/Packet++/header/ProtocolType.h b/Packet++/header/ProtocolType.h index f2ad34558b..f4807946ef 100644 --- a/Packet++/header/ProtocolType.h +++ b/Packet++/header/ProtocolType.h @@ -350,7 +350,7 @@ namespace pcpp /* * Wireguard protocol */ - const ProtocolType WIREGUARD = 56; + const ProtocolType Wireguard = 56; /** * An enum representing OSI model layers diff --git a/Packet++/header/WireGuardLayer.h b/Packet++/header/WireGuardLayer.h index 8ec8d895ba..4c1d83d4d2 100644 --- a/Packet++/header/WireGuardLayer.h +++ b/Packet++/header/WireGuardLayer.h @@ -116,7 +116,7 @@ namespace pcpp * @param packet Pointer to the packet this layer belongs to */ WireGuardLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) - : Layer(data, dataLen, prevLayer, packet, WIREGUARD) + : Layer(data, dataLen, prevLayer, packet, Wireguard) {} /** @@ -175,7 +175,7 @@ namespace pcpp * @param dataLen Length of the data * @return True if the data starts with a valid WireGuard message type, false otherwise */ - static inline bool isWireGuard(const uint8_t* data, size_t dataLen); + static inline bool isDataValid(const uint8_t* data, size_t dataLen); /** * No operation required for parsing the next layer since WireGuard does not have a next layer. @@ -240,7 +240,7 @@ namespace pcpp * @param dataLen Length of the data * @return True if the data starts with a valid WireGuard message type, false otherwise */ - bool WireGuardLayer::isWireGuard(const uint8_t* data, size_t dataLen) + bool WireGuardLayer::isDataValid(const uint8_t* data, size_t dataLen) { if (dataLen < sizeof(wg_common_header)) return false; diff --git a/Packet++/src/UdpLayer.cpp b/Packet++/src/UdpLayer.cpp index 4a1a8f8a69..9b3f3e4a7e 100644 --- a/Packet++/src/UdpLayer.cpp +++ b/Packet++/src/UdpLayer.cpp @@ -136,7 +136,7 @@ namespace pcpp else if ((WakeOnLanLayer::isWakeOnLanPort(portDst) && WakeOnLanLayer::isDataValid(udpData, udpDataLen))) m_NextLayer = new WakeOnLanLayer(udpData, udpDataLen, this, m_Packet); else if ((WireGuardLayer::isWireguardPorts(portDst, portSrc) && - WireGuardLayer::isWireGuard(udpData, udpDataLen))) + WireGuardLayer::isDataValid(udpData, udpDataLen))) m_NextLayer = new WireGuardLayer(udpData, udpDataLen, this, m_Packet); else m_NextLayer = new PayloadLayer(udpData, udpDataLen, this, m_Packet); diff --git a/Tests/Packet++Test/TestDefinition.h b/Tests/Packet++Test/TestDefinition.h index 19252c5d28..b944e705e9 100644 --- a/Tests/Packet++Test/TestDefinition.h +++ b/Tests/Packet++Test/TestDefinition.h @@ -264,6 +264,6 @@ PTF_TEST_CASE(LdapParsingTest); PTF_TEST_CASE(LdapCreationTest); // Implemented in WireGuardTests.cpp -PTF_TEST_CASE(WGHandshakeInitParsingTest); -PTF_TEST_CASE(WGHandshakeRespParsingTest); -PTF_TEST_CASE(WGTransportDataParsingTest); +PTF_TEST_CASE(WireGuardHandshakeInitParsingTest); +PTF_TEST_CASE(WireGuardHandshakeRespParsingTest); +PTF_TEST_CASE(WireGuardTransportDataParsingTest); diff --git a/Tests/Packet++Test/Tests/WireGuardTests.cpp b/Tests/Packet++Test/Tests/WireGuardTests.cpp index c4c8f49a6d..911df00633 100644 --- a/Tests/Packet++Test/Tests/WireGuardTests.cpp +++ b/Tests/Packet++Test/Tests/WireGuardTests.cpp @@ -5,7 +5,7 @@ #include "SystemUtils.h" #include -PTF_TEST_CASE(WGHandshakeInitParsingTest) +PTF_TEST_CASE(WireGuardHandshakeInitParsingTest) { timeval time; gettimeofday(&time, nullptr); @@ -13,7 +13,7 @@ PTF_TEST_CASE(WGHandshakeInitParsingTest) READ_FILE_AND_CREATE_PACKET(1, "PacketExamples/WireGuardHandshakeInitiation.dat"); pcpp::Packet wgPacket(&rawPacket1); - PTF_ASSERT_TRUE(wgPacket.isPacketOfType(pcpp::WIREGUARD)); + PTF_ASSERT_TRUE(wgPacket.isPacketOfType(pcpp::Wireguard)); pcpp::WireGuardLayer* wgLayer = wgPacket.getLayerOfType(); PTF_ASSERT_NOT_NULL(wgLayer); PTF_ASSERT_TRUE(wgLayer->getHeaderLen() == sizeof(pcpp::wg_handshake_initiation)); @@ -50,7 +50,7 @@ PTF_TEST_CASE(WGHandshakeInitParsingTest) PTF_ASSERT_TRUE(std::memcmp(handshakeInit->mac2, expectedMac2, sizeof(expectedMac2)) == 0); } -PTF_TEST_CASE(WGHandshakeRespParsingTest) +PTF_TEST_CASE(WireGuardHandshakeRespParsingTest) { timeval time; gettimeofday(&time, nullptr); @@ -58,7 +58,7 @@ PTF_TEST_CASE(WGHandshakeRespParsingTest) READ_FILE_AND_CREATE_PACKET(1, "PacketExamples/WireGuardHandshakeResponse.dat"); pcpp::Packet wgPacket(&rawPacket1); - PTF_ASSERT_TRUE(wgPacket.isPacketOfType(pcpp::WIREGUARD)); + PTF_ASSERT_TRUE(wgPacket.isPacketOfType(pcpp::Wireguard)); pcpp::WireGuardLayer* wgLayer = wgPacket.getLayerOfType(); PTF_ASSERT_NOT_NULL(wgLayer); @@ -86,7 +86,7 @@ PTF_TEST_CASE(WGHandshakeRespParsingTest) PTF_ASSERT_TRUE(std::memcmp(handshakeResponse->mac2, expectedMac2, sizeof(expectedMac2)) == 0); } -PTF_TEST_CASE(WGTransportDataParsingTest) +PTF_TEST_CASE(WireGuardTransportDataParsingTest) { timeval time; gettimeofday(&time, nullptr); @@ -94,7 +94,7 @@ PTF_TEST_CASE(WGTransportDataParsingTest) READ_FILE_AND_CREATE_PACKET(1, "PacketExamples/WireGuardTransportData.dat"); pcpp::Packet wgPacket(&rawPacket1); - PTF_ASSERT_TRUE(wgPacket.isPacketOfType(pcpp::WIREGUARD)); + PTF_ASSERT_TRUE(wgPacket.isPacketOfType(pcpp::Wireguard)); pcpp::WireGuardLayer* wgLayer = wgPacket.getLayerOfType(); PTF_ASSERT_NOT_NULL(wgLayer); PTF_ASSERT_TRUE(wgLayer->getHeaderLen() >= sizeof(pcpp::wg_transport_data)); diff --git a/Tests/Packet++Test/main.cpp b/Tests/Packet++Test/main.cpp index c1f75168b8..64bb9088f3 100644 --- a/Tests/Packet++Test/main.cpp +++ b/Tests/Packet++Test/main.cpp @@ -333,9 +333,9 @@ int main(int argc, char* argv[]) PTF_RUN_TEST(LdapParsingTest, "ldap"); PTF_RUN_TEST(LdapCreationTest, "ldap"); - PTF_RUN_TEST(WGHandshakeInitParsingTest, "wg"); - PTF_RUN_TEST(WGHandshakeRespParsingTest, "wg"); - PTF_RUN_TEST(WGTransportDataParsingTest, "wg"); + PTF_RUN_TEST(WireGuardHandshakeInitParsingTest, "wg"); + PTF_RUN_TEST(WireGuardHandshakeRespParsingTest, "wg"); + PTF_RUN_TEST(WireGuardTransportDataParsingTest, "wg"); PTF_END_RUNNING_TESTS; }