-
Notifications
You must be signed in to change notification settings - Fork 715
Cleanup of PcapLiveDevice
capture machinery.
#1838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Cleanup of PcapLiveDevice
capture machinery.
#1838
Conversation
Removed redundant fields.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1838 +/- ##
==========================================
- Coverage 83.18% 83.12% -0.06%
==========================================
Files 285 285
Lines 49843 49888 +45
Branches 10589 10835 +246
==========================================
+ Hits 41461 41470 +9
+ Misses 7575 7277 -298
- Partials 807 1141 +334
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Can we review this? It has been sitting here for a while. |
@Dimi1010 It's a big one... That's why... I will look into this recently. |
This PR moves the implementation of the capture procedures to internally linked functions in
PcapLiveDevice.cpp
and aims to reduce the the need for extensive bookkeeping of capture thread only variables inside the device object's fields.The static member function callback routines for
pcap_dispatch
have been replaced with internal linkage free functions to improve readability and encapsulation. The user token is now expected to be a pointer to a specific capture context object instead of the device instance.Replacement list:
onPacketArrivesCallback
replacesonPacketArrives
. Expects user token of typeCaptureContext
onPacketArrivesAccumulator
replacesonPacketArrivesNoCallback
. Expects user token of typeAccumulatorCaptureContext
onPacketArrivesCallbackWithCancellation
replacesonPacketArrivesBlockingMode
. Expects user token of typeCaptureContextST
onPacketArrivesNoop
to be used when no handling is required.Replaced
captureThreadMain
static private function with internal linkage free functions. The free functions take their inputs as parameters instead of relying on data from the implicitthis
pointer, simplifying data ownership and reducing risk of data races.captureThreadMain
- used for callback or noop capture.captureThreadMainAccumulator
- used for accumulating the packets into aRawPacketVector
.Changed blocking mode capture to utilize
onPacketArrivesCallbackWithCancellation
. The new infrastructure provides a layer of separation between the device threading machinery and the cancellation requests by relying onrequestStop
flag to record a cancellation request that is then forwarded tom_StopThread
after dispatch finishes instead of directly writing tom_StopThread
.Removed
PcapLiveDevice
member fields previously only used to store data for the capture thread as that data is now stored in context objects created on demand during capture startup.