Skip to content

Commit 075bb45

Browse files
authored
Merge branch 'dev' into bugfix/bgp-headerlen-memory-safety
2 parents f27a0a6 + 098dd4b commit 075bb45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+458
-468
lines changed

.github/workflows/build_and_test.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,47 @@ jobs:
504504
path: ${{ env.CCACHE_DIR }}
505505
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
506506

507+
define-windows-pcap-backend-matrix:
508+
name: Determine Windows Pcap Backend Matrix
509+
runs-on: ubuntu-latest
510+
outputs:
511+
npcap-or-default: ${{ steps.generate-backends.outputs.npcap_or_default}}
512+
steps:
513+
- name: Initialize NPcap backend variable
514+
run: echo "npcap_available=false" >> $GITHUB_ENV
515+
516+
- name: Enable NPcap backend if OEM credentials are available
517+
env: # Secrets can't be accessed directly in 'if' conditionals.
518+
npcap_username: ${{ secrets.NPCAP_USERNAME }}
519+
npcap_password: ${{ secrets.NPCAP_PASSWORD }}
520+
if: ${{ env.npcap_username != '' && env.npcap_password != '' }}
521+
run: echo "npcap_available=true" >> $GITHUB_ENV
522+
523+
- name: NPcap backend is unavailable
524+
if: ${{ env.npcap_available != 'true' }}
525+
run: echo "NPcap backend will be skipped since OEM credentials are missing. NPCAP_USERNAME and NPCAP_PASSWORD are required."
526+
527+
- name: Generate pcap backends matrix
528+
id: generate-backends
529+
run: |
530+
if [[ "${{ env.npcap_available }}" == "true" ]]; then
531+
echo 'npcap_or_default=npcap' >> "$GITHUB_OUTPUT"
532+
else
533+
echo 'npcap_or_default=winpcap' >> "$GITHUB_OUTPUT"
534+
fi
535+
507536
mingw-w64:
508-
runs-on: windows-latest
537+
needs: define-windows-pcap-backend-matrix
509538
strategy:
510539
matrix:
511540
include:
512-
- env: i686
513-
sys: mingw32
541+
- sys: mingw32
542+
env: i686
514543
pcap_lib: "winpcap"
515-
- env: x86_64
516-
sys: mingw64
517-
pcap_lib: "winpcap"
518-
544+
- sys: mingw64
545+
env: x86_64
546+
pcap_lib: ${{ needs.define-windows-pcap-backend-matrix.outputs.npcap-or-default }}
547+
runs-on: windows-latest
519548
steps:
520549
- name: Checkout code
521550
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -596,6 +625,7 @@ jobs:
596625
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
597626

598627
visual-studio:
628+
needs: define-windows-pcap-backend-matrix
599629
strategy:
600630
matrix:
601631
include:
@@ -606,11 +636,11 @@ jobs:
606636
- os: windows-2025
607637
platform: "Visual Studio 17 2022"
608638
arch: "x64"
609-
pcap_lib: "winpcap"
639+
pcap_lib: ${{ needs.define-windows-pcap-backend-matrix.outputs.npcap-or-default }}
610640
- os: windows-2022
611641
platform: "Visual Studio 17 2022"
612642
arch: "x64"
613-
pcap_lib: "winpcap"
643+
pcap_lib: ${{ needs.define-windows-pcap-backend-matrix.outputs.npcap-or-default }}
614644

615645
runs-on: ${{ matrix.os }}
616646
steps:

Common++/src/IpUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@ int inet_pton(int af, const char* src, void* dst)
443443
{
444444
# ifdef AF_INET
445445
case AF_INET:
446-
return (inet_pton4(src, (uint8_t*)dst));
446+
return (inet_pton4(src, static_cast<uint8_t*>(dst)));
447447
# endif
448448
# ifdef AF_INET6
449449
case AF_INET6:
450-
return (inet_pton6(src, (uint8_t*)dst));
450+
return (inet_pton6(src, static_cast<uint8_t*>(dst)));
451451
# endif
452452
default:
453453
return (-1);

Examples/DnsSpoofing/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ bool stringCountComparer(const std::pair<std::string, int>& first, const std::pa
264264
void onApplicationInterrupted(void* cookie)
265265
{
266266
DnsSpoofingArgs* args = (DnsSpoofingArgs*)cookie;
267-
if (args->stats.spoofedHosts.size() == 0)
267+
if (args->stats.spoofedHosts.empty())
268268
{
269269
std::cout << std::endl << "Application closing. No hosts were spoofed." << std::endl;
270270
}

Examples/DpdkExample-FilterTraffic/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
exit(1); \
3232
} while (0)
3333

34-
typedef std::unordered_map<pcpp::DpdkDevice*, std::vector<int>> InputDataConfig;
34+
using InputDataConfig = std::unordered_map<pcpp::DpdkDevice*, std::vector<int>>;
3535

3636
/**
3737
* Contains all the configuration needed for the worker thread including:

Examples/DpdkExample-FilterTraffic/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void prepareCoreConfiguration(std::vector<pcpp::DpdkDevice*>& dpdkDevicesToUse,
221221
}
222222
std::cout << std::endl;
223223
}
224-
if (workerConfigArr[i].inDataCfg.size() == 0)
224+
if (workerConfigArr[i].inDataCfg.empty())
225225
{
226226
std::cout << " None" << std::endl;
227227
}

Examples/TLSFingerprinting/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void printStats(const TLSFingerprintingStats& stats, bool chFP, bool shFP)
297297
// write a table of the 10 most common TLS fingerprints
298298

299299
// if user requested to extract ClientHello TLS fingerprints and there is data to show
300-
if (chFP && stats.chFingerprints.size() > 0)
300+
if (chFP && !stats.chFingerprints.empty())
301301
{
302302
if (stats.chFingerprints.size() > 10)
303303
std::cout << "Top 10 ";
@@ -309,7 +309,7 @@ void printStats(const TLSFingerprintingStats& stats, bool chFP, bool shFP)
309309
}
310310

311311
// if user requested to extract ServerHello TLS fingerprints and there is data to show
312-
if (shFP && stats.shFingerprints.size() > 0)
312+
if (shFP && !stats.shFingerprints.empty())
313313
{
314314
if (stats.shFingerprints.size() > 10)
315315
std::cout << "Top 10 ";

Examples/TcpReassembly/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ struct TcpReassemblyData
276276
}
277277
};
278278

279-
// typedef representing the connection manager
280-
typedef std::unordered_map<uint32_t, TcpReassemblyData> TcpReassemblyConnMgr;
279+
// using declaration representing the connection manager
280+
using TcpReassemblyConnMgr = std::unordered_map<uint32_t, TcpReassemblyData>;
281281

282282
/**
283283
* Print application usage

Packet++/header/IPReassembly.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ namespace pcpp
284284
/// @param[in] key A pointer to the identifier of the packet that is being dropped
285285
/// @param[in] userCookie A pointer to the cookie provided by the user in IPReassemby c'tor (or nullptr if no
286286
/// cookie provided)
287-
typedef void (*OnFragmentsClean)(const PacketKey* key, void* userCookie);
287+
using OnFragmentsClean = void (*)(const PacketKey* key, void* userCookie);
288288

289289
/// An enum representing the status returned from processing a fragment
290290
enum ReassemblyStatus

Packet++/header/ProtocolType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ namespace pcpp
3232

3333
/// @typedef ProtocolType
3434
/// Representing all protocols supported by PcapPlusPlus
35-
typedef uint8_t ProtocolType;
35+
using ProtocolType = uint8_t;
3636

3737
/// @typedef ProtocolTypeFamily
3838
/// Representing a family of protocols
39-
typedef uint32_t ProtocolTypeFamily;
39+
using ProtocolTypeFamily = uint32_t;
4040

4141
/// Unknown protocol (or unsupported by PcapPlusPlus)
4242
const ProtocolType UnknownProtocol = 0;

Packet++/header/SomeIpSdLayer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,10 @@ namespace pcpp
508508
public:
509509
friend class SomeIpSdEntry;
510510

511-
typedef SomeIpSdEntry* EntryPtr;
512-
typedef std::vector<EntryPtr> EntriesVec;
513-
typedef SomeIpSdOption* OptionPtr;
514-
typedef std::vector<OptionPtr> OptionsVec;
511+
using EntryPtr = SomeIpSdEntry*;
512+
using EntriesVec = std::vector<EntryPtr>;
513+
using OptionPtr = SomeIpSdOption*;
514+
using OptionsVec = std::vector<OptionPtr>;
515515

516516
/// A constructor that creates the layer from an existing packet raw data
517517
/// @param[in] data A pointer to the raw data

0 commit comments

Comments
 (0)