diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 000000000..32c4f9364 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,49 @@ +name: Rust + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + LIB: 'c:\winpcap-dp\WpdPack\Lib\x64' + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Install WinPcap 4.1.3 + run: cinst -y winpcap --version 4.1.3.20161116 + - name: Install WinPcap 4.1.2 Developer's Pack + shell: bash + run: | + mkdir /c/winpcap-dp + pushd /c/winpcap-dp + curl -O https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip + 7z x WpdPack_4_1_2.zip -o. + ls -l WpdPack/Lib/x64 + # echo "::set-env LIB=$LIB:/c/winpcap-dp/WpdPack/Lib/x64" + popd + - name: Build and Test (default) + run: | + cargo build --verbose + cargo test --verbose + cargo clean + - name: Build and Test (tokio) + run: | + cargo build --verbose --features tokio + cargo test --verbose --features tokio + cargo clean + - name: Build and Test (full) + run: | + cargo build --verbose --features full + cargo test --verbose --features full + cargo clean + - name: Clean up + shell: bash + run: rm -r /c/winpcap-dp \ No newline at end of file diff --git a/README.md b/README.md index d66088269..a33ecc832 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ See examples for usage. Install [WinPcap](http://www.winpcap.org/install/default.htm). -Place wpcap.dll in your `C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\` directory on 64 bit -or `C:\Rust\bin\rustlib\i686-pc-windows-gnu\lib\` on 32 bit. +Download the WinPcap [Developer's Pack](https://www.winpcap.org/devel.htm). +Add the `/Lib` or `/Lib/x64` folder to your `LIB` environment variable. ## Linux diff --git a/tests/lib.rs b/tests/lib.rs index f17ec60d8..89215c40c 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -9,6 +9,16 @@ use tempdir::TempDir; use pcap::{Active, Activated, Offline, Capture, Packet, PacketHeader, Linktype, Precision, Error}; +#[cfg(not(windows))] +type time_t = libc::time_t; +#[cfg(windows)] +type time_t = libc::c_long; + +#[cfg(not(windows))] +type suseconds_t = libc::suseconds_t; +#[cfg(windows)] +type suseconds_t = libc::c_long; + #[test] fn read_packet_with_full_data() { let mut capture = capture_from_test_file("packet_snaplen_65535.pcap"); @@ -61,8 +71,8 @@ impl Packets { } pub fn push(&mut self, - tv_sec: libc::time_t, - tv_usec: libc::suseconds_t, + tv_sec: time_t, + tv_usec: suseconds_t, caplen: u32, len: u32, data: &[u8]) { @@ -163,8 +173,8 @@ fn test_raw_fd_api() { let data: Vec = (0..191).cycle().take(N_PACKETS * 1024).collect(); let mut packets = Packets::new(); for i in 0..N_PACKETS { - packets.push(1460408319 + i as libc::time_t, - 1000 + i as libc::suseconds_t, + packets.push(1460408319 + i as time_t, + 1000 + i as suseconds_t, 1024, 1024, &data[i * 1024..(i + 1) * 1024]);