Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercosmos committed Sep 28, 2024
1 parent 655fef5 commit 1b96823
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions Packet++/src/UdpLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1b96823

Please sign in to comment.