Driver: Prefer Npcap

Prefer Npcap over WinPcap and TCP
liveDataSetValue
Kyle Schwarz 2025-06-04 22:14:09 -04:00
parent b3d47f2ae5
commit c4e858d346
4 changed files with 9 additions and 17 deletions

View File

@ -430,7 +430,6 @@ if(LIBICSNEO_ENABLE_RAW_ETHERNET)
add_definitions(-DWPCAP -DHAVE_REMOTE) add_definitions(-DWPCAP -DHAVE_REMOTE)
else() else()
target_include_directories(icsneocpp PUBLIC AFTER ${LIBICSNEO_NPCAP_INCLUDE_DIR}) target_include_directories(icsneocpp PUBLIC AFTER ${LIBICSNEO_NPCAP_INCLUDE_DIR})
add_definitions(-DNPCAP)
endif() endif()
else() else()
find_package(PCAP REQUIRED) find_package(PCAP REQUIRED)

View File

@ -50,7 +50,7 @@ public:
bool ok() const; bool ok() const;
private: private:
PCAPDLL(); PCAPDLL();
HINSTANCE dll; HINSTANCE dll = nullptr;
void closeDLL(); void closeDLL();
}; };
} }

View File

@ -28,21 +28,15 @@ bool PCAPDLL::ok() const
PCAPDLL::PCAPDLL() PCAPDLL::PCAPDLL()
{ {
#ifdef NPCAP // Use -DLIBICSNEO_NPCAP_INCLUDE_DIR when configuring, point towards the npcap includes TCHAR dir[512] = {0};
DLL_DIRECTORY_COOKIE cookie = 0; if(GetSystemDirectory(dir, 480)) {
TCHAR dllPath[512] = { 0 }; _tcscat_s(dir, 512, TEXT("\\Npcap"));
int len = GetSystemDirectory(dllPath, 480); // be safe if(SetDllDirectory(dir)) {
if (len) { // will search for Npcap first, then fall back to WinPcap
_tcscat_s(dllPath, 512, TEXT("\\Npcap"));
cookie = AddDllDirectory(dllPath);
}
dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_USER_DIRS);
if (cookie)
RemoveDllDirectory(cookie);
#else // Otherwise we'll use WinPCAP, or npcap in compatibility mode
dll = LoadLibrary(TEXT("wpcap.dll")); dll = LoadLibrary(TEXT("wpcap.dll"));
#endif SetDllDirectory(nullptr); // reset
}
}
if(dll == NULL) { if(dll == NULL) {
closeDLL(); closeDLL();

View File

@ -46,7 +46,6 @@ local_scheme = "no-local-version"
[tool.scikit-build.cmake.define] [tool.scikit-build.cmake.define]
LIBICSNEO_ENABLE_BINDINGS_PYTHON = true LIBICSNEO_ENABLE_BINDINGS_PYTHON = true
LIBICSNEO_ENABLE_TCP = true
CMAKE_MSVC_RUNTIME_LIBRARY = "MultiThreaded" CMAKE_MSVC_RUNTIME_LIBRARY = "MultiThreaded"
[tool.cibuildwheel] [tool.cibuildwheel]