From 8db083d2e8fdc7796e572a1c47c7900df20a356b Mon Sep 17 00:00:00 2001 From: Benedikt Constantin Radtke Date: Wed, 6 Sep 2017 21:21:19 +0200 Subject: [PATCH] use winapi on windows, update windows build instructions fixes #70, fixes #73 --- Cargo.toml | 3 +++ README.md | 5 ++--- src/lib.rs | 2 ++ src/raw.rs | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 15017eb03..a236663a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,9 @@ mio = { version = "0.6", optional = true } tokio-core = { version = "0.1", optional = true } futures = { version = "0.1", optional = true } +[target.'cfg(target_os = "windows")'.dependencies] +winapi = "0.2" + [dev-dependencies] tempdir = "0.3" diff --git a/README.md b/README.md index d66088269..d740dcf7b 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,8 @@ See examples for usage. ## Windows 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/src/lib.rs b/src/lib.rs index ca9f7d28c..d0a94717d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,8 @@ extern crate mio; extern crate futures; #[cfg(feature = "tokio")] extern crate tokio_core; +#[cfg(target_os = "windows")] +extern crate winapi; use unique::Unique; diff --git a/src/raw.rs b/src/raw.rs index 1d67b1cde..d1d36cd02 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -1,7 +1,11 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -use libc::{c_int, c_uint, c_char, c_uchar, c_ushort, sockaddr, timeval, FILE}; +use libc::{c_int, c_uint, c_char, c_uchar, c_ushort, timeval, FILE}; +#[cfg(target_os = "windows")] +use winapi::ws2def::SOCKADDR as sockaddr; +#[cfg(not(target_os = "windows"))] +use libc::sockaddr; #[repr(C)] #[derive(Copy, Clone)]