Rename features: std→use_std, logging→use_log.
parent
df69303624
commit
de24d635fa
|
@ -13,6 +13,6 @@ libc = { version = "0.2.18", optional = true }
|
|||
env_logger = "0.3"
|
||||
|
||||
[features]
|
||||
std = ["libc"]
|
||||
logging = ["log"]
|
||||
default = ["std", "logging"]
|
||||
use_std = ["libc"]
|
||||
use_log = ["log"]
|
||||
default = ["use_std", "use_log"]
|
||||
|
|
29
README.md
29
README.md
|
@ -46,9 +46,13 @@ The UDP protocol is supported over IPv4.
|
|||
The TCP protocol is supported over IPv4.
|
||||
|
||||
* TCP header checksum is supported.
|
||||
* TCP options are **not** supported. In particular, the MSS of the remote endpoint
|
||||
is hardcoded at the default value, 536.
|
||||
* Multiple packets will be transmitted without waiting for an acknowledgement.
|
||||
* TCP urgent pointer is **not** supported; any urgent octets will be received alongside data.
|
||||
* Reassembly of out-of-order segments is **not** supported.
|
||||
* TCP options are **not** supported, in particular:
|
||||
* Maximum segment size is hardcoded at the default value, 536.
|
||||
* Window scaling is **not** supported.
|
||||
* Keepalive is **not** supported.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
@ -60,6 +64,27 @@ To use the _smoltcp_ library in your project, add the following to `Cargo.toml`:
|
|||
smoltcp = "0.1"
|
||||
```
|
||||
|
||||
The default configuration assumes a hosted environment, for ease of evaluation.
|
||||
You probably want to disable default features and configure them one by one:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
smoltcp = { version = ..., default-features = false, features = [...] }
|
||||
```
|
||||
|
||||
### Feature `use_std`
|
||||
|
||||
The `use_std` feature enables use of buffers owned by the networking stack through a dependency
|
||||
on `std::boxed::Box`. It also enables `smoltcp::phy::RawSocket` and `smoltcp::phy::TapInterface`,
|
||||
if the platform supports it.
|
||||
|
||||
### Feature `use_log`
|
||||
|
||||
The `use_log` feature enables logging of events within the networking stack through
|
||||
the [log crate][log]. The events are emitted with the TRACE log level.
|
||||
|
||||
[log]: https://crates.io/crates/log
|
||||
|
||||
Usage example
|
||||
-------------
|
||||
|
||||
|
|
|
@ -67,12 +67,12 @@ impl<'a> SliceCache<'a> {
|
|||
|
||||
/// Sort entries in an order suitable for `find`.
|
||||
fn sort(&mut self) {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
fn sort(data: &mut [(IpAddress, EthernetAddress, usize)]) {
|
||||
data.sort_by_key(|&(key, _, _)| key)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[cfg(not(feature = "use_std"))]
|
||||
fn sort(data: &mut [(IpAddress, EthernetAddress, usize)]) {
|
||||
// Use an insertion sort, which performs best on 10 elements and less.
|
||||
for i in 1..data.len() {
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
|
||||
extern crate byteorder;
|
||||
|
||||
#[cfg(any(test, feature = "std"))]
|
||||
#[cfg(any(test, feature = "use_std"))]
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
extern crate libc;
|
||||
#[cfg(feature = "logging")]
|
||||
#[cfg(feature = "use_log")]
|
||||
#[macro_use(trace, log)]
|
||||
extern crate log;
|
||||
|
||||
macro_rules! net_trace {
|
||||
($($arg:tt)*) => {
|
||||
#[cfg(feature = "logging")]
|
||||
#[cfg(feature = "use_log")]
|
||||
trace!($($arg)*)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use core::ops::{Deref, DerefMut};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
use core::borrow::BorrowMut;
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
use std::boxed::Box;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
use std::vec::Vec;
|
||||
|
||||
/// A managed object.
|
||||
|
@ -26,7 +26,7 @@ pub enum Managed<'a, T: 'a + ?Sized> {
|
|||
/// Borrowed variant, either a single element or a slice.
|
||||
Borrowed(&'a mut T),
|
||||
/// Owned variant, only available with `std` present.
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
Owned(Box<BorrowMut<T>>)
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ impl<'a, T: 'a + ?Sized> From<&'a mut T> for Managed<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
impl<T, U: BorrowMut<T> + 'static> From<Box<U>> for Managed<'static, T> {
|
||||
fn from(value: Box<U>) -> Self {
|
||||
Managed::Owned(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]> {
|
||||
fn from(mut value: Vec<T>) -> Self {
|
||||
value.shrink_to_fit();
|
||||
|
@ -63,7 +63,7 @@ impl<'a, T: 'a + ?Sized> Deref for Managed<'a, T> {
|
|||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
&Managed::Borrowed(ref value) => value,
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
&Managed::Owned(ref value) => (**value).borrow()
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ impl<'a, T: 'a + ?Sized> DerefMut for Managed<'a, T> {
|
|||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
match self {
|
||||
&mut Managed::Borrowed(ref mut value) => value,
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
&mut Managed::Owned(ref mut value) => (**value).borrow_mut()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,19 +7,19 @@
|
|||
|
||||
use Error;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
mod sys;
|
||||
|
||||
mod tracer;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
mod raw_socket;
|
||||
#[cfg(all(feature = "std", target_os = "linux"))]
|
||||
#[cfg(all(feature = "use_std", target_os = "linux"))]
|
||||
mod tap_interface;
|
||||
|
||||
pub use self::tracer::Tracer;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
pub use self::raw_socket::RawSocket;
|
||||
#[cfg(all(feature = "std", target_os = "linux"))]
|
||||
#[cfg(all(feature = "use_std", target_os = "linux"))]
|
||||
pub use self::tap_interface::TapInterface;
|
||||
|
||||
/// An interface for sending and receiving raw network frames.
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<T: Device, U: PrettyPrint> Tracer<T, U> {
|
|||
}
|
||||
|
||||
/// Create a tracer device, printing to standard output.
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "use_std")]
|
||||
pub fn new_stdout(lower: T) -> Tracer<T, U> {
|
||||
fn writer<U: PrettyPrint>(printer: PrettyPrinter<U>) {
|
||||
print!("{}", printer)
|
||||
|
|
Loading…
Reference in New Issue