Skip to content

Commit

Permalink
Merge branch 'dev' into stepsecurity_remediation_1713255167
Browse files Browse the repository at this point in the history
  • Loading branch information
egecetin authored Apr 16, 2024
2 parents 94b8e48 + 1e5094f commit 98d18e2
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Examples/IPFragUtil/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void splitIPPacketToFragmentsBySize(pcpp::RawPacket* rawPacket, size_t fragmentS
newFrag.removeAllLayersAfter(fragIpLayer);

// create a new PayloadLayer with the fragmented data and add it to the new fragment packet
pcpp::PayloadLayer newPayload(ipLayer->getLayerPayload() + curOffset, curFragSize, false);
pcpp::PayloadLayer newPayload(ipLayer->getLayerPayload() + curOffset, curFragSize);
newFrag.addLayer(&newPayload);

// set fragment parameters in IPv4/6 layer
Expand Down
4 changes: 1 addition & 3 deletions Packet++/header/PayloadLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ namespace pcpp
* A constructor that allocates a new payload
* @param[in] data A raw buffer that will be used as a payload. This data will be copied to the layer
* @param[in] dataLen The raw buffer length
* @param[in] dummy A dummy parameter to separate the constructor signature from the other constructor. Its value isn't used anywhere
* @todo dummy is probably not necessary anymore. Remove it
*/
PayloadLayer(const uint8_t* data, size_t dataLen, bool dummy);
PayloadLayer(const uint8_t* data, size_t dataLen);

/**
* A constructor that allocates a new payload from an hex stream
Expand Down
2 changes: 1 addition & 1 deletion Packet++/src/PayloadLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace pcpp
{

PayloadLayer::PayloadLayer(const uint8_t* data, size_t dataLen, bool) : Layer()
PayloadLayer::PayloadLayer(const uint8_t* data, size_t dataLen) : Layer()
{
m_Data = new uint8_t[dataLen];
memcpy(m_Data, data, dataLen);
Expand Down
4 changes: 2 additions & 2 deletions Tests/ExamplesTest/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
attrs==23.2.0
iniconfig==2.0.0
py==1.11.0
pyparsing==3.1.1
pytest==8.0.2
pyparsing==3.1.2
pytest==8.1.1
scapy==2.5.0
toml==0.10.2
4 changes: 2 additions & 2 deletions Tests/Packet++Test/Tests/EthAndArpTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PTF_TEST_CASE(EthPacketCreation)
pcpp::EthLayer ethLayer(srcMac, dstMac, PCPP_ETHERTYPE_IP);

uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04 };
pcpp::PayloadLayer payloadLayer(payload, 4, true);
pcpp::PayloadLayer payloadLayer(payload, 4);

pcpp::Packet ethPacket(1);
PTF_ASSERT_TRUE(ethPacket.addLayer(&ethLayer));
Expand Down Expand Up @@ -61,7 +61,7 @@ PTF_TEST_CASE(EthPacketPointerCreation)
pcpp::EthLayer* ethLayer = new pcpp::EthLayer(srcMac, dstMac, PCPP_ETHERTYPE_IP);

uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04 };
pcpp::PayloadLayer* payloadLayer = new pcpp::PayloadLayer(payload, 4, true);
pcpp::PayloadLayer* payloadLayer = new pcpp::PayloadLayer(payload, 4);

pcpp::Packet* ethPacket = new pcpp::Packet(1);
PTF_ASSERT_TRUE(ethPacket->addLayer(ethLayer, true));
Expand Down
2 changes: 1 addition & 1 deletion Tests/Packet++Test/Tests/GreTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ PTF_TEST_CASE(GreCreationTest)
pppLayer.getPPP_PPTPHeader()->protocol = htobe16(PCPP_PPP_CCP);

uint8_t data[4] = { 0x06, 0x04, 0x00, 0x04 };
pcpp::PayloadLayer payloadLayer(data, 4, true);
pcpp::PayloadLayer payloadLayer(data, 4);

pcpp::Packet grev1Packet(1);
PTF_ASSERT_TRUE(grev1Packet.addLayer(&ethLayer));
Expand Down
2 changes: 1 addition & 1 deletion Tests/Packet++Test/Tests/IPv4Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PTF_TEST_CASE(IPv4PacketCreation)


uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
pcpp::PayloadLayer payloadLayer(payload, 10, true);
pcpp::PayloadLayer payloadLayer(payload, 10);


pcpp::Packet ip4Packet(1);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Packet++Test/Tests/IPv6Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ PTF_TEST_CASE(IPv6UdpPacketParseAndCreate)
pcpp::Layer* afterIpv6Layer = pUdpLayer->getNextLayer();
uint8_t* payloadData = new uint8_t[afterIpv6Layer->getDataLen()];
afterIpv6Layer->copyData(payloadData);
pcpp::PayloadLayer payloadLayer(payloadData, afterIpv6Layer->getDataLen(), true);
pcpp::PayloadLayer payloadLayer(payloadData, afterIpv6Layer->getDataLen());

pcpp::Packet ip6UdpPacketNew(1);
PTF_ASSERT_TRUE(ip6UdpPacketNew.addLayer(&ethLayer));
Expand Down
10 changes: 5 additions & 5 deletions Tests/Packet++Test/Tests/PacketTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PTF_TEST_CASE(InsertDataToPacket)
ip4Layer.getIPv4Header()->protocol = pcpp::PACKETPP_IPPROTO_TCP;

uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
pcpp::PayloadLayer payloadLayer(payload, 10, true);
pcpp::PayloadLayer payloadLayer(payload, 10);

// create the packet
pcpp::Packet ip4Packet(1);
Expand Down Expand Up @@ -119,7 +119,7 @@ PTF_TEST_CASE(CreatePacketFromBuffer)
PTF_ASSERT_TRUE(newPacket->addLayer(&ip4Layer));

uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
pcpp::PayloadLayer payloadLayer(payload, 10, true);
pcpp::PayloadLayer payloadLayer(payload, 10);
PTF_ASSERT_TRUE(newPacket->addLayer(&payloadLayer));

pcpp::Logger::getInstance().suppressLogs();
Expand Down Expand Up @@ -256,7 +256,7 @@ PTF_TEST_CASE(RemoveLayerTest)
PTF_ASSERT_TRUE(testPacket.addLayer(&ip4Layer));

uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
pcpp::PayloadLayer payloadLayer(payload, 10, true);
pcpp::PayloadLayer payloadLayer(payload, 10);
PTF_ASSERT_TRUE(testPacket.addLayer(&payloadLayer));


Expand Down Expand Up @@ -819,7 +819,7 @@ PTF_TEST_CASE(PacketTrailerTest)

// add layer after trailer (result with an error)
uint8_t payload[4] = { 0x1, 0x2, 0x3, 0x4 };
std::unique_ptr<pcpp::PayloadLayer> newPayloadLayer(new pcpp::PayloadLayer(payload, 4, false));
std::unique_ptr<pcpp::PayloadLayer> newPayloadLayer(new pcpp::PayloadLayer(payload, 4));
pcpp::Logger::getInstance().suppressLogs();
PTF_ASSERT_FALSE(trailerIPv4Packet.addLayer(newPayloadLayer.get(), true));
pcpp::Logger::getInstance().enableLogs();
Expand Down Expand Up @@ -923,7 +923,7 @@ PTF_TEST_CASE(PacketTrailerTest)
PTF_TEST_CASE(ResizeLayerTest)
{
uint8_t payload[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
pcpp::PayloadLayer payloadLayer(payload, 10, true);
pcpp::PayloadLayer payloadLayer(payload, 10);

// Creating a packet
pcpp::Packet packet(1500);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Packet++Test/Tests/SipSdpTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ PTF_TEST_CASE(SipRequestLayerCreationTest)
PTF_ASSERT_TRUE(newSipPacket.addLayer(&sipReqLayer));

pcpp::SipRequestLayer* samplePacketSipLayer = sipReqSamplePacket.getLayerOfType<pcpp::SipRequestLayer>();
auto payloadLayer = new pcpp::PayloadLayer(samplePacketSipLayer->getLayerPayload(), samplePacketSipLayer->getLayerPayloadSize(), true);
auto payloadLayer = new pcpp::PayloadLayer(samplePacketSipLayer->getLayerPayload(), samplePacketSipLayer->getLayerPayloadSize());
PTF_ASSERT_TRUE(newSipPacket.addLayer(payloadLayer, true));

newSipPacket.computeCalculateFields();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Packet++Test/Tests/SllNullLoopbackTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ PTF_TEST_CASE(NullLoopbackTest)
pcpp::UdpLayer newUdpLayer(55369, 8612);

uint8_t payload[] = { 0x42, 0x4a, 0x4e, 0x42, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
pcpp::PayloadLayer newPayloadLayer(payload, 16, false);
pcpp::PayloadLayer newPayloadLayer(payload, 16);

pcpp::Packet newNullPacket(1);
PTF_ASSERT_TRUE(newNullPacket.addLayer(&newNullLoopbackLayer));
Expand Down
2 changes: 1 addition & 1 deletion Tests/Packet++Test/Tests/TcpTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ PTF_TEST_CASE(TcpPacketCreation)
PTF_ASSERT_EQUAL(tcpLayer.getTcpOptionCount(), 3);

uint8_t payloadData[9] = { 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 };
pcpp::PayloadLayer payloadLayer(payloadData, 9, true);
pcpp::PayloadLayer payloadLayer(payloadData, 9);

pcpp::Packet tcpPacket(1);
tcpPacket.addLayer(&ethLayer);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Pcap++Test/Tests/LiveDeviceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ PTF_TEST_CASE(TestMtuSize)
size_t smallDataLen = liveDev->getMtu() - (smallIPLayer.getDataLen());
uint8_t* smallData = new uint8_t[smallDataLen];
memset(smallData, 0xFF, smallDataLen);
pcpp::PayloadLayer smallPayload(smallData, smallDataLen, false);
pcpp::PayloadLayer smallPayload(smallData, smallDataLen);
smallPacket.addLayer(&smallPayload);

// Check the size of the small Packet
Expand Down Expand Up @@ -812,7 +812,7 @@ PTF_TEST_CASE(TestMtuSize)
size_t largeDataLen = liveDev->getMtu() - largeIPLayer.getDataLen() + 1;
uint8_t* largeData = new uint8_t[largeDataLen];
memset(largeData, 0xFF, largeDataLen);
pcpp::PayloadLayer largePayload(largeData, largeDataLen, false);
pcpp::PayloadLayer largePayload(largeData, largeDataLen);
largePacket.addLayer(&largePayload);

// Check the size of the large Packet
Expand Down
2 changes: 1 addition & 1 deletion Tests/Pcap++Test/Tests/TcpReassemblyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static pcpp::RawPacket tcpReassemblyAddRetransmissions(pcpp::RawPacket rawPacket

tcpLayer->getTcpHeader()->sequenceNumber = htobe32(be32toh(tcpLayer->getTcpHeader()->sequenceNumber) + beginning);

pcpp::PayloadLayer newPayloadLayer(newPayload, numOfBytes, false);
pcpp::PayloadLayer newPayloadLayer(newPayload, numOfBytes);
packet.addLayer(&newPayloadLayer);

packet.computeCalculateFields();
Expand Down

0 comments on commit 98d18e2

Please sign in to comment.