Skip to content

Commit

Permalink
Support for latest NPCAP changes (1.10)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianReimold committed Feb 11, 2021
1 parent 6e35faa commit e1d1962
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build_win/download_npcap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ New-Item "$target_dir" -ItemType "directory" -Force

$webclient = New-Object System.Net.WebClient

$webclient.DownloadFile("https://nmap.org/npcap/dist/npcap-sdk-1.05.zip","$target_dir\npcap-sdk-1.05.zip")
$webclient.DownloadFile("https://nmap.org/npcap/dist/npcap-sdk-1.05.zip","$target_dir\npcap-sdk-1.06.zip")
$webclient.DownloadFile("https://github.com/seladb/PcapPlusPlus/releases/download/v20.08/pcapplusplus-20.08-windows-vs2015.zip","$target_dir\pcapplusplus-20.08-windows-vs2015.zip")

Expand-Archive -Force -Path "$target_dir\npcap-sdk-1.05.zip" -DestinationPath "$target_dir\npcap-sdk"
Expand-Archive -Force -Path "$target_dir\npcap-sdk-1.06.zip" -DestinationPath "$target_dir\npcap-sdk"
Expand-Archive -Force -Path "$target_dir\pcapplusplus-20.08-windows-vs2015.zip" -DestinationPath "$target_dir"
12 changes: 8 additions & 4 deletions lib/Udpcap/src/npcap_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,20 @@ namespace Udpcap
}

// Lower-case everything
//std::transform(given_uuid.begin(), given_uuid.end(), given_uuid.begin(), ::tolower); // cause warning C4244 with VS2017
std::transform(given_uuid.begin(), given_uuid.end(), given_uuid.begin(),
[](char c) {return static_cast<char>(::tolower(c)); });

std::string loopback_uuid_lower = loopback_device_uuid_string;
//std::transform(loopback_uuid_lower.begin(), loopback_uuid_lower.end(), loopback_uuid_lower.begin(), ::tolower); // cause warning C4244 with VS2017

std::transform(loopback_uuid_lower.begin(), loopback_uuid_lower.end(), loopback_uuid_lower.begin(),
[](char c) {return static_cast<char>(::tolower(c)); });

// String compare
return (loopback_uuid_lower == given_uuid);
// At some point between NPCAP 0.9996 and NPCAP 1.10 the loopback device
// was renamed to "\device\npf_loopback".
// For newer NPCAP versions the complicated method to get the Device
// UUID is obsolete. However, we leave the code in place, as it works
// and still provides downwards compatibility to older NPCAP versions.
return (given_uuid == "\\device\\npf_loopback") || (loopback_uuid_lower == given_uuid);
}
}

Expand Down

0 comments on commit e1d1962

Please sign in to comment.