Skip to content

Commit

Permalink
Merge branch 'dev' into refactor/live-device-IPAddresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimi1010 committed Jul 26, 2024
2 parents 4100859 + 123994c commit 111d0dd
Show file tree
Hide file tree
Showing 70 changed files with 4,547 additions and 4,316 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PointerAlignment: Left
AccessModifierOffset: -4
AlignTrailingComments: true
AllowShortEnumsOnASingleLine: false
BreakStringLiterals: true
BreakStringLiterals: false
AlignArrayOfStructures: Left
BreakArrays: true
SpacesBeforeTrailingComments: 2
Expand Down
36 changes: 25 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ jobs:
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.image }}-ccache
key: ${{ matrix.image }}-ccache-${{ github.run_id }}
restore-keys: |
${{ matrix.image }}-ccache
- name: Configure PcapPlusPlus
run: cmake -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DPCAPPP_BUILD_COVERAGE=ON ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR"
Expand Down Expand Up @@ -137,7 +139,7 @@ jobs:
gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml
- name: Upload Coverage Results
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6
with:
files: ./coverage.xml
flags: ${{ matrix.image }},unittest
Expand Down Expand Up @@ -173,7 +175,9 @@ jobs:
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.image }}-ccache
key: ${{ matrix.image }}-ccache-${{ github.run_id }}
restore-keys: |
${{ matrix.image }}-ccache
- name: Configure PcapPlusPlus
run: cmake -DPCAPPP_USE_DPDK=ON ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR"
Expand Down Expand Up @@ -231,7 +235,9 @@ jobs:
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.image }}-ccache
key: ${{ matrix.image }}-ccache-${{ github.run_id }}
restore-keys: |
${{ matrix.image }}-ccache
- name: Configure PcapPlusPlus
run: ${{ matrix.configure }}
Expand Down Expand Up @@ -317,7 +323,9 @@ jobs:
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.os-version }}-ccache
key: ${{ matrix.os-version }}-${{ matrix.arch }}-ccache-${{ github.run_id }}
restore-keys: |
${{ matrix.os-version }}-${{ matrix.arch }}-ccache
- name: Configure PcapPlusPlus
# Ensure user have access to network devices instead of giving super-user right
Expand Down Expand Up @@ -365,12 +373,14 @@ jobs:
run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld

- name: Create Cobertura Report
if: ${{ matrix.host-arch == matrix.arch }}
run: |
python3 -m pip install gcovr
gcovr -v -r . $GCOVR_FLAGS -o coverage.xml
- name: Upload Coverage Results
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6
if: ${{ matrix.host-arch == matrix.arch }}
with:
files: ./coverage.xml
flags: ${{ matrix.os-version }},unittest
Expand Down Expand Up @@ -458,7 +468,7 @@ jobs:
run: gcovr -v -g -k -r . $env:GCOVR_FLAGS.split() -o coverage.xml

- name: Upload Coverage Results
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6
with:
files: ./coverage.xml
flags: ${{ matrix.sys }},unittest
Expand Down Expand Up @@ -549,7 +559,7 @@ jobs:
python -m pytest --root-path=../../Dist/examples_bin
- name: Upload Coverage Results
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6
with:
files: ./Tests/Pcap++Test/Pcap++Coverage.xml,./Tests/Packet++Test/Packet++Coverage.xml
flags: ${{ matrix.os }},unittest,${{ matrix.pcap_lib }}
Expand Down Expand Up @@ -678,7 +688,9 @@ jobs:
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.image }}-ccache
key: ${{ matrix.image }}-ccache-${{ github.run_id }}
restore-keys: |
${{ matrix.image }}-ccache
- name: Configure PcapPlusPlus
run: cmake -DPCAPPP_USE_XDP=ON -DPCAPPP_BUILD_COVERAGE=ON -S . -B $BUILD_DIR
Expand All @@ -698,7 +710,7 @@ jobs:
gcovr -v -r . $GCOVR_FLAGS -o coverage.xml
- name: Upload Coverage Results
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6
with:
files: ./coverage.xml
flags: xdp,unittest
Expand Down Expand Up @@ -740,7 +752,9 @@ jobs:
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.engine }}-${{ matrix.sanitizer }}-ccache
key: ${{ matrix.engine }}-${{ matrix.sanitizer }}-ccache-${{ github.run_id }}
restore-keys: |
${{ matrix.engine }}-${{ matrix.sanitizer }}-ccache
- name: Compile PcapPlusPlus Fuzzer application
run: |
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fuzzers/DumpToFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

// This function is created as PcapPlusPlus doesn't seem to offer a way of
// parsing Pcap files directly from memory
static int dumpDataToPcapFile(const uint8_t *data, size_t size, const char* path)
static int dumpDataToPcapFile(const uint8_t* data, size_t size, const char* path)
{
FILE *fd;
FILE* fd;
int written = 0;

fd = fopen(path, "wb");
Expand Down
13 changes: 6 additions & 7 deletions Tests/Fuzzers/FuzzTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
static std::string tmpName;
static std::string tmpFile;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
if (tmpName.empty())
tmpName = tmpnam (NULL);
tmpName = tmpnam(NULL);

if (tmpFile.empty())
tmpFile = tmpName + FILE_EXT;
Expand All @@ -32,15 +32,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

pcpp::IPcapDevice::PcapStats stats;
reader->getStatistics(stats);
std::cout << "Read " << stats.packetsRecv << " packets successfully and "
<< stats.packetsDrop << " packets could not be read" << std::endl;
std::cout << "Read " << stats.packetsRecv << " packets successfully and " << stats.packetsDrop
<< " packets could not be read" << std::endl;

if (auto ngReader = dynamic_cast<pcpp::PcapNgFileReaderDevice*>(reader.get()))
{
std::cout << "OS is '" << ngReader->getOS() << "'; Hardware is '" << ngReader->getHardware() << "'"
<< "'; CaptureApplication is '" << ngReader->getCaptureApplication()
<< "'; CaptureFileComment is '" << ngReader->getCaptureFileComment()
<< "'" << std::endl;
<< "'; CaptureApplication is '" << ngReader->getCaptureApplication() << "'; CaptureFileComment is '"
<< ngReader->getCaptureFileComment() << "'" << std::endl;
}

pcpp::RawPacketVector packets;
Expand Down
12 changes: 6 additions & 6 deletions Tests/Fuzzers/FuzzWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ static std::string tmpFile;
static std::string outPcapFile;
static int writes = 0;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
if (tmpName.empty())
tmpName = tmpnam (NULL);
tmpName = tmpnam(NULL);

if (tmpFile.empty())
tmpFile = tmpName + FILE_EXT;
Expand Down Expand Up @@ -41,9 +41,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
#endif

#ifdef NG_WRITER
pcpp::PcapNgFileWriterDevice pcapWriter(outPcapFile);
pcpp::PcapNgFileWriterDevice pcapWriter(outPcapFile);
#else
pcpp::PcapFileWriterDevice pcapWriter(outPcapFile, pcpp::LINKTYPE_ETHERNET);
pcpp::PcapFileWriterDevice pcapWriter(outPcapFile, pcpp::LINKTYPE_ETHERNET);
#endif
if (writes++ == 10)
{
Expand Down Expand Up @@ -71,8 +71,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

pcpp::IPcapDevice::PcapStats stats;
pcapWriter.getStatistics(stats);
std::cout << "Written " << stats.packetsRecv << " packets successfully to pcap writer and "
<< stats.packetsDrop << " packets could not be written" << std::endl;
std::cout << "Written " << stats.packetsRecv << " packets successfully to pcap writer and " << stats.packetsDrop
<< " packets could not be written" << std::endl;

pcapWriter.close();
return 0;
Expand Down
Loading

0 comments on commit 111d0dd

Please sign in to comment.