mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
turn PCAPDLL into a singleton
This commit is contained in:
@@ -12,8 +12,7 @@ namespace icsneo {
|
||||
class PCAPDLL {
|
||||
public:
|
||||
// The first time we use the DLL we keep it in here and it won't get freed until the user unloads us (for speed reasons)
|
||||
static std::shared_ptr<PCAPDLL> lazyLoadHolder;
|
||||
static bool lazyLoaded;
|
||||
static const PCAPDLL& getInstance();
|
||||
|
||||
// Functions
|
||||
typedef int(__cdecl* PCAPFINDDEVICE)(char* source, struct pcap_rmtauth* auth, pcap_if_t** alldevs, char* errbuf);
|
||||
@@ -45,14 +44,14 @@ public:
|
||||
PCAPCREATESRCSTR createsrcstr;
|
||||
PCAPSETBUFF setbuff;
|
||||
|
||||
PCAPDLL();
|
||||
~PCAPDLL() { closeDLL(); }
|
||||
bool ok() const { return dll != nullptr; }
|
||||
|
||||
~PCAPDLL();
|
||||
bool ok() const;
|
||||
private:
|
||||
PCAPDLL();
|
||||
HINSTANCE dll;
|
||||
void closeDLL();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
bool isOpen();
|
||||
bool close();
|
||||
private:
|
||||
PCAPDLL pcap;
|
||||
const PCAPDLL& pcap;
|
||||
char errbuf[PCAP_ERRBUF_SIZE] = { 0 };
|
||||
neodevice_t& device;
|
||||
uint8_t deviceMAC[6];
|
||||
|
||||
Reference in New Issue
Block a user