Factor out the "raw_socket" and "tap_interface" features
This makes it possible to build smoltcp with the "std" feature on platforms without libc, such as redox.
This commit is contained in:
parent
f29b610801
commit
59fc0c0358
|
@ -2,13 +2,13 @@ language: rust
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- rust: stable
|
- rust: stable
|
||||||
env: FEATURES='std' MODE='test'
|
env: FEATURES='std raw_socket tap_interface' MODE='test'
|
||||||
- rust: beta
|
- rust: beta
|
||||||
env: FEATURES='std' MODE='test'
|
env: FEATURES='std raw_socket tap_interface' MODE='test'
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES='std' MODE='test'
|
env: FEATURES='std raw_socket tap_interface' MODE='test'
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES='std log' MODE='test'
|
env: FEATURES='std raw_socket tap_interface log' MODE='test'
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES='alloc collections' MODE='build'
|
env: FEATURES='alloc collections' MODE='build'
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
|
|
|
@ -23,11 +23,13 @@ env_logger = "0.4"
|
||||||
getopts = "0.2"
|
getopts = "0.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
std = ["managed/std", "libc"]
|
std = ["managed/std"]
|
||||||
alloc = ["managed/alloc"]
|
alloc = ["managed/alloc"]
|
||||||
collections = ["managed/collections"]
|
collections = ["managed/collections"]
|
||||||
verbose = []
|
verbose = []
|
||||||
default = ["std", "log", "verbose"]
|
raw_socket = ["libc"]
|
||||||
|
tap_interface = ["libc"]
|
||||||
|
default = ["std", "raw_socket", "tap_interface", "log", "verbose"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "tcpdump"
|
name = "tcpdump"
|
||||||
|
|
|
@ -87,11 +87,16 @@ smoltcp = { version = "0.3", default-features = false, features = ["..."] }
|
||||||
### Feature `std`
|
### Feature `std`
|
||||||
|
|
||||||
The `std` feature enables use of objects and slices owned by the networking stack through a
|
The `std` feature enables use of objects and slices owned by the networking stack through a
|
||||||
dependency on `std::boxed::Box` and `std::vec::Vec`. It also enables `smoltcp::phy::RawSocket`
|
dependency on `std::boxed::Box` and `std::vec::Vec`.
|
||||||
and `smoltcp::phy::TapInterface`, if the platform supports it.
|
|
||||||
|
|
||||||
This feature is enabled by default.
|
This feature is enabled by default.
|
||||||
|
|
||||||
|
### Features `raw_socket` and `tap_interface`
|
||||||
|
|
||||||
|
Enable `smoltcp::phy::RawSocket` and `smoltcp::phy::TapInterface`, respectively.
|
||||||
|
|
||||||
|
These features are enabled by default.
|
||||||
|
|
||||||
### Feature `alloc`
|
### Feature `alloc`
|
||||||
|
|
||||||
The `alloc` feature enables use of objects owned by the networking stack through a dependency
|
The `alloc` feature enables use of objects owned by the networking stack through a dependency
|
||||||
|
|
|
@ -72,7 +72,7 @@ extern crate managed;
|
||||||
#[cfg(any(test, feature = "std"))]
|
#[cfg(any(test, feature = "std"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate std;
|
extern crate std;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(any(feature = "raw_socket", feature="tap_interface"))]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -102,21 +102,21 @@ impl Drop for EthernetTxBuffer {
|
||||||
|
|
||||||
use Error;
|
use Error;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(any(feature = "raw_socket", feature="tap_interface"))]
|
||||||
mod sys;
|
mod sys;
|
||||||
|
|
||||||
mod tracer;
|
mod tracer;
|
||||||
mod fault_injector;
|
mod fault_injector;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "raw_socket")]
|
||||||
mod raw_socket;
|
mod raw_socket;
|
||||||
#[cfg(all(feature = "std", target_os = "linux"))]
|
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
|
||||||
mod tap_interface;
|
mod tap_interface;
|
||||||
|
|
||||||
pub use self::tracer::Tracer;
|
pub use self::tracer::Tracer;
|
||||||
pub use self::fault_injector::FaultInjector;
|
pub use self::fault_injector::FaultInjector;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(any(feature = "raw_socket"))]
|
||||||
pub use self::raw_socket::RawSocket;
|
pub use self::raw_socket::RawSocket;
|
||||||
#[cfg(all(feature = "std", target_os = "linux"))]
|
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
|
||||||
pub use self::tap_interface::TapInterface;
|
pub use self::tap_interface::TapInterface;
|
||||||
|
|
||||||
/// A description of device limitations.
|
/// A description of device limitations.
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "raw_socket"))]
|
||||||
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
|
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
|
||||||
|
#[cfg(any(feature = "raw_socket"))]
|
||||||
pub const SIOCGIFINDEX: libc::c_ulong = 0x8933;
|
pub const SIOCGIFINDEX: libc::c_ulong = 0x8933;
|
||||||
|
#[cfg(any(feature = "raw_socket"))]
|
||||||
|
pub const ETH_P_ALL: libc::c_short = 0x0003;
|
||||||
|
|
||||||
|
#[cfg(feature = "tap_interface")]
|
||||||
pub const TUNSETIFF: libc::c_ulong = 0x400454CA;
|
pub const TUNSETIFF: libc::c_ulong = 0x400454CA;
|
||||||
|
#[cfg(feature = "tap_interface")]
|
||||||
pub const IFF_TAP: libc::c_int = 0x0002;
|
pub const IFF_TAP: libc::c_int = 0x0002;
|
||||||
|
#[cfg(feature = "tap_interface")]
|
||||||
pub const IFF_NO_PI: libc::c_int = 0x1000;
|
pub const IFF_NO_PI: libc::c_int = 0x1000;
|
||||||
|
|
||||||
pub const ETH_P_ALL: libc::c_short = 0x0003;
|
|
||||||
|
|
|
@ -5,12 +5,14 @@ use std::io;
|
||||||
#[path = "linux.rs"]
|
#[path = "linux.rs"]
|
||||||
mod imp;
|
mod imp;
|
||||||
|
|
||||||
|
#[cfg(feature = "raw_socket")]
|
||||||
pub mod raw_socket;
|
pub mod raw_socket;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
|
||||||
pub mod tap_interface;
|
pub mod tap_interface;
|
||||||
|
|
||||||
|
#[cfg(feature = "raw_socket")]
|
||||||
pub use self::raw_socket::RawSocketDesc;
|
pub use self::raw_socket::RawSocketDesc;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
|
||||||
pub use self::tap_interface::TapInterfaceDesc;
|
pub use self::tap_interface::TapInterfaceDesc;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
Loading…
Reference in New Issue