Reorganize features using namespaces, to match module hierarchy.

I'm about to add a whole lot more features, and it's going to get
quite confusing otherwise.
v0.7.x
whitequark 2017-09-24 23:51:19 +00:00
parent 38f648affb
commit 0a8a962e94
7 changed files with 39 additions and 30 deletions

View File

@ -1,16 +1,22 @@
language: rust
matrix:
include:
# litmus check that we work on stable/beta
- rust: stable
env: FEATURES='std raw_socket tap_interface' MODE='test'
env: FEATURES='default' MODE='test'
- rust: beta
env: FEATURES='std raw_socket tap_interface' MODE='test'
env: FEATURES='default' MODE='test'
# actually test everything
- rust: nightly
env: FEATURES='std raw_socket tap_interface' MODE='test'
env: FEATURES='default' MODE='test'
- rust: nightly
env: FEATURES='std raw_socket tap_interface log' MODE='test'
env: FEATURES='std' MODE='test'
- rust: nightly
env: FEATURES='alloc' MODE='build'
- rust: nightly
env: FEATURES='phy-raw_socket' MODE='build'
- rust: nightly
env: FEATURES='phy-tap_interface' MODE='build'
- rust: nightly
env: FEATURES='' MODE='build'
script:

View File

@ -26,9 +26,9 @@ getopts = "0.2"
std = ["managed/std"]
alloc = ["managed/alloc"]
verbose = []
raw_socket = ["libc"]
tap_interface = ["libc"]
default = ["std", "raw_socket", "tap_interface", "log", "verbose"]
"phy-raw_socket" = ["std", "libc"]
"phy-tap_interface" = ["std", "libc"]
default = ["std", "log", "phy-raw_socket", "phy-tap_interface"]
[[example]]
name = "tcpdump"

View File

@ -94,17 +94,13 @@ dependency on `std::boxed::Box` and `std::vec::Vec`.
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`
The `alloc` feature enables use of objects owned by the networking stack through a dependency
on collections from the `alloc` crate. This only works on nightly rustc.
This feature is disabled by default.
### Feature `log`
The `log` feature enables logging of events within the networking stack through
@ -125,6 +121,12 @@ or `BufWriter` is used, which are of course not available on heap-less systems.
This feature is disabled by default.
### Features `phy-raw_socket` and `phy-tap_interface`
Enable `smoltcp::phy::RawSocket` and `smoltcp::phy::TapInterface`, respectively.
These features are enabled by default.
## Hosted usage examples
_smoltcp_, being a freestanding networking stack, needs to be able to transmit and receive

View File

@ -72,7 +72,7 @@ extern crate managed;
#[cfg(any(test, feature = "std"))]
#[macro_use]
extern crate std;
#[cfg(any(feature = "raw_socket", feature="tap_interface"))]
#[cfg(any(feature = "phy-raw_socket", feature = "phy-tap_interface"))]
extern crate libc;
#[cfg(feature = "alloc")]
extern crate alloc;

View File

@ -106,7 +106,7 @@ impl Drop for EthernetTxBuffer {
use Result;
#[cfg(any(feature = "raw_socket", feature = "tap_interface"))]
#[cfg(any(feature = "phy-raw_socket", feature = "phy-tap_interface"))]
mod sys;
mod tracer;
@ -114,12 +114,12 @@ mod fault_injector;
mod pcap_writer;
#[cfg(any(feature = "std", feature = "alloc"))]
mod loopback;
#[cfg(feature = "raw_socket")]
#[cfg(feature = "phy-raw_socket")]
mod raw_socket;
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))]
mod tap_interface;
#[cfg(any(feature = "raw_socket", feature = "tap_interface"))]
#[cfg(any(feature = "phy-raw_socket", feature = "phy-tap_interface"))]
pub use self::sys::wait;
pub use self::tracer::Tracer;
@ -127,9 +127,9 @@ pub use self::fault_injector::FaultInjector;
pub use self::pcap_writer::{PcapLinkType, PcapMode, PcapSink, PcapWriter};
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::loopback::Loopback;
#[cfg(any(feature = "raw_socket"))]
#[cfg(any(feature = "phy-raw_socket"))]
pub use self::raw_socket::RawSocket;
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))]
pub use self::tap_interface::TapInterface;
/// A tracer device for Ethernet frames.

View File

@ -1,16 +1,17 @@
use libc;
#[cfg(any(feature = "raw_socket"))]
#[cfg(any(feature = "phy-raw_socket",
feature = "phy-tap_interface"))]
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
#[cfg(any(feature = "raw_socket"))]
#[cfg(any(feature = "phy-raw_socket"))]
pub const SIOCGIFINDEX: libc::c_ulong = 0x8933;
#[cfg(any(feature = "raw_socket"))]
#[cfg(any(feature = "phy-raw_socket"))]
pub const ETH_P_ALL: libc::c_short = 0x0003;
#[cfg(feature = "tap_interface")]
#[cfg(feature = "phy-tap_interface")]
pub const TUNSETIFF: libc::c_ulong = 0x400454CA;
#[cfg(feature = "tap_interface")]
#[cfg(feature = "phy-tap_interface")]
pub const IFF_TAP: libc::c_int = 0x0002;
#[cfg(feature = "tap_interface")]
#[cfg(feature = "phy-tap_interface")]
pub const IFF_NO_PI: libc::c_int = 0x1000;

View File

@ -6,14 +6,14 @@ use std::os::unix::io::RawFd;
#[path = "linux.rs"]
mod imp;
#[cfg(feature = "raw_socket")]
#[cfg(feature = "phy-raw_socket")]
pub mod raw_socket;
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))]
pub mod tap_interface;
#[cfg(feature = "raw_socket")]
#[cfg(feature = "phy-raw_socket")]
pub use self::raw_socket::RawSocketDesc;
#[cfg(all(feature = "tap_interface", target_os = "linux"))]
#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))]
pub use self::tap_interface::TapInterfaceDesc;
/// Wait until given file descriptor becomes readable, but no longer than given timeout.