diff --git a/Packet++/src/UdpLayer.cpp b/Packet++/src/UdpLayer.cpp index 28ca354f27..e52e1e5857 100644 --- a/Packet++/src/UdpLayer.cpp +++ b/Packet++/src/UdpLayer.cpp @@ -136,35 +136,36 @@ namespace pcpp m_NextLayer = SomeIpLayer::parseSomeIpLayer(udpData, udpDataLen, this, m_Packet); 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::isDataValid(udpData, udpDataLen))) - { - m_NextLayer = WireGuardLayer::parseWireGuardLayer(udpData, udpDataLen, this, m_Packet); - if (!m_NextLayer) + else if ((WireGuardLayer::isWireGuardPorts(portDst, portSrc) && + WireGuardLayer::isDataValid(udpData, udpDataLen))) + { + m_NextLayer = WireGuardLayer::parseWireGuardLayer(udpData, udpDataLen, this, m_Packet); + if (!m_NextLayer) + m_NextLayer = new PayloadLayer(udpData, udpDataLen, this, m_Packet); + } + else if (GvcpLayer::isGvcpPort(portSrc) || GvcpLayer::isGvcpPort(portDst)) + { + m_NextLayer = GvcpLayer::parseGvcpLayer(udpData, udpDataLen, this, m_Packet); + } + else m_NextLayer = new PayloadLayer(udpData, udpDataLen, this, m_Packet); } - else if (GvcpLayer::isGvcpPort(portSrc) || GvcpLayer::isGvcpPort(portDst)) + + void UdpLayer::computeCalculateFields() { - m_NextLayer = GvcpLayer::parseGvcpLayer(udpData, udpDataLen, this, m_Packet); + udphdr* udpHdr = (udphdr*)m_Data; + udpHdr->length = htobe16(m_DataLen); + calculateChecksum(true); } - else m_NextLayer = new PayloadLayer(udpData, udpDataLen, this, m_Packet); -} - -void UdpLayer::computeCalculateFields() -{ - udphdr* udpHdr = (udphdr*)m_Data; - udpHdr->length = htobe16(m_DataLen); - calculateChecksum(true); -} -std::string UdpLayer::toString() const -{ - std::ostringstream srcPortStream; - srcPortStream << getSrcPort(); - std::ostringstream dstPortStream; - dstPortStream << getDstPort(); + std::string UdpLayer::toString() const + { + std::ostringstream srcPortStream; + srcPortStream << getSrcPort(); + std::ostringstream dstPortStream; + dstPortStream << getDstPort(); - return "UDP Layer, Src port: " + srcPortStream.str() + ", Dst port: " + dstPortStream.str(); -} + return "UDP Layer, Src port: " + srcPortStream.str() + ", Dst port: " + dstPortStream.str(); + } } // namespace pcpp