-
Notifications
You must be signed in to change notification settings - Fork 693
General refactor of PcapLiveDeviceList and PcapRemoteDeviceList. #1431
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
Labels
Comments
This was referenced Jun 5, 2024
@Dimi1010 should we keep this issue open or can we close it? |
Eh, most of it is done. We can possibly close it. There is the open PR that is linked to it tho. |
What is the remaining PR, it it this? |
Yes, it had a merge conflict, but I updated it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an issue to track progress that will be done over several PRs.
Task overview:
PcapLiveDeviceList
to use smart pointers internally for memory management.PcapRemoteDeviceList
to use smart pointers internally for memory management.(Consolidate shared DeviceList functionality under a common base class. #1488)
PcapRemoteDevice
to keep a shared reference ofRemoteAuthentication
withPcapRemoteDeviceList
viastd::shared_ptr
as it currently uses a raw pointer to share authentication with the device list.Unify the public "getDevice" API of both lists using smart pointers.(Consolidate shared DeviceList functionality under a common base class. #1488)
PcapRemoteDeviceList
's factories to returnunique_ptr
instead of raw pointers.1. Use smart pointers for internal memory management in
PcapLiveDeviceList
The current implementation uses a vector of raw pointers and manually handles
new
/delete
calls. The move towards smart pointers will automate the need for manual memory management.2. Use smart pointers for internal memory management in
PcapRemoteDeviceList
The current implementation uses a vector of raw pointers and manually handles
new
/delete
calls. The move towards smart pointers will automate the need for manual memory management.3. Use
shared_ptr
to storeRemoteAuthentication
inPcapRemoteDeviceList
andPcapRemoteDevice
.The current implementation uses a raw pointer to
RemoteAuthentication
shared betweenPcapRemoteDeviceList
and itsPcapRemoteDevice
s. The move towards smart pointers will relieve the need forPcapRemoteDeviceList
to need to manage the lifetime of the authentication object manually, and will prevent potentially deallocating it while anotherPcapRemoteDevice
is using it.4.
Unifying the public API for fetching single devices.Currently the public APIs of
PcapLiveDeviceList
andPcapRemoteDeviceList
use similar but not entirely the same syntax for getter functions.PcapLiveDeviceList
usesgetPcapLiveDeviceBy*
returning a raw pointer toPcapLiveDevice
PcapRemoteDeviceList
usesgetPcapRemoteDeviceBy*
returning a raw pointer toPcapRemoteDevice
The proposed task is to unify the API of both lists so they can be used interchangeably. This may also allow centralizing much of the getter functionality under a base class as both lists generally keep their devices in a vector of pointers. Additional list specific class members can stay in their respective classes.
Working draft syntax for the methods is as follows:
getPcapDeviceBy*
orgetDeviceBy*
shared_ptr<PcapLiveDevice>
asPcapRemoteDevice
is a virtual subclass ofPcapLiveDevice
.5. Unify the public API for iterating over all devices.
Currently
PcapLiveDeviceList
andPcapRemoteDeviceList
provide different APIs for iterating over all devices in the list.PcapLiveDeviceList
uses the methodgetPcapLiveDevicesList
returning avector
by referencePcapRemoteDeviceList
implements container stylebegin
/end
methods.The proposed change is to unify the APIs, providing common methods between the two classes.
The proposed API is as follows:
getAllPcapDevices
returningvector<shared_ptr<PcapLiveDevice>>
.NB:
PcapRemoteDeviceList
may implement additionalgetAllPcapRemoteDevices
that returnsvector<shared_ptr<PcapRemoteDevice>>
begin
/end
methods. Return signature TBD. (May conflict with point 4's base class vector.)6. Refactor
PcapRemoteDeviceList
's factories to returnunique_ptr
instead of raw pointersThe current implementation of the remote device list's factories returns raw pointers to the device list, relying on the caller to deallocated the list via a
delete
call. Changing the factory to return aunique_ptr
will increase memory safety by automatically releasing the memory when the user is done with the list,7. Centralize code calling Libpcap/Winpcap/Npcap to fetch devices into a utility header.
Currently there are duplicated calls to fetch all devices in
PcapLiveDeviceList
and during the clone procedure inPcapLiveDevice
Centralizing that code to its own dedicated utilities header will make it easier to maintain.
The text was updated successfully, but these errors were encountered: