Added Windows support for the bind shell

Brings in support from winpcap as npcap has a restrictive license
This commit is contained in:
Andrew Rioux
2024-01-24 19:12:45 -05:00
parent 862dc3e743
commit af5ceb66ab
10 changed files with 97 additions and 26 deletions

View File

@@ -17,14 +17,16 @@ use fs_extra::dir::{copy, CopyOptions};
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
println!("cargo:rustc-lib-lib=pcap");
println!("cargo:rustc-link-search=native={}", std::env::var("SPARSE_BUILD_WINPCAP").unwrap());
println!("cargo:rustc-link-search=native={}/x64", std::env::var("SPARSE_BUILD_WINPCAP").unwrap());
println!("cargo:rustc-link-lib=wpcap");
} else {
let libpcap_src = format!("{}/pcap_src", std::env::var("OUT_DIR").unwrap());
let mut options = CopyOptions::new();
options.copy_inside = true;
options.skip_exist = true;
copy(std::env!("SPARSE_BUILD_LIBPCAP"), &libpcap_src, &options).expect("could not copy libpcap source code to build");
copy(std::env::var("SPARSE_BUILD_LIBPCAP").unwrap(), &libpcap_src, &options).expect("could not copy libpcap source code to build");
let dst = cmake::Config::new(&libpcap_src)
.define("BUILD_SHARED_LIBS", "OFF")

View File

@@ -228,7 +228,7 @@ impl<T: Disabled> Interface<T> {
}
pub fn activate(mut self) -> error::Result<Interface<DevActivated>> {
if unsafe { ffi::pcap_activate(self.dev) } != 0 {
if unsafe { dbg!(ffi::pcap_activate(self.dev)) } != 0 {
Err(unsafe { ffi::pcap_geterr(self.dev) })?;
}