Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ca6fa2d423bd
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 974bad1adf54
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Aug 21, 2017

  1. README.md: cleanup.

    whitequark committed Aug 21, 2017
    Copy the full SHA
    53df308 View commit details
  2. Copy the full SHA
    2773fa7 View commit details
  3. Copy the full SHA
    974bad1 View commit details
Showing with 13 additions and 27 deletions.
  1. +7 −13 README.md
  2. +1 −13 examples/utils.rs
  3. +5 −1 src/phy/sys/tap_interface.rs
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
smoltcp
=======
# smoltcp

_smoltcp_ is a standalone, event-driven TCP/IP stack that is designed for bare-metal,
real-time systems. Its design goals are simplicity and robustness. Its design anti-goals
@@ -11,8 +10,7 @@ and compiles on stable Rust 1.19 and later.

[docs]: https://docs.rs/smoltcp/

Features
--------
## Features

_smoltcp_ is missing many widely deployed features, whether by design or simply because
no one implemented them yet. To set expectations right, both implemented and omitted
@@ -66,8 +64,7 @@ The TCP protocol is supported over IPv4. Server and client sockets are supported
* Fast open is **not** supported.
* Keepalive is **not** supported.

Installation
------------
## Installation

To use the _smoltcp_ library in your project, add the following to `Cargo.toml`:

@@ -127,14 +124,13 @@ or `BufWriter` is used, which are of course not available on heap-less systems.

This feature is disabled by default.

Hosted usage examples
---------------------
## Hosted usage examples

_smoltcp_, being a freestanding networking stack, needs to be able to transmit and receive
raw frames. For testing purposes, we will use a regular OS, and run _smoltcp_ in
a userspace process. Only Linux is supported (right now).

On *nix OSes, transmiting and receiving raw frames normally requires superuser privileges, but
On \*nix OSes, transmiting and receiving raw frames normally requires superuser privileges, but
on Linux it is possible to create a _persistent tap interface_ that can be manipulated by
a specific user:

@@ -250,8 +246,7 @@ Currently, netmasks are not implemented, and so the only address this example ca
is the other endpoint of the tap interface, `192.168.1.100`. It cannot reach itself because
packets entering a tap interface do not loop back.

Bare-metal usage examples
-------------------------
## Bare-metal usage examples

Examples that use no services from the host OS are necessarily less illustrative than examples
that do. Because of this, only one such example is provided.
@@ -281,8 +276,7 @@ is possible; otherwise, nothing at all will be displayed and no options are acce

[wireshark]: https://wireshark.org

License
-------
## License

_smoltcp_ is distributed under the terms of 0-clause BSD license.

14 changes: 1 addition & 13 deletions examples/utils.rs
Original file line number Diff line number Diff line change
@@ -47,18 +47,6 @@ pub fn setup_logging(filter: &str) {
})
}

struct Dispose;

impl io::Write for Dispose {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
Ok(data.len())
}

fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}

pub fn create_options() -> (Options, Vec<&'static str>) {
let mut opts = Options::new();
opts.optflag("h", "help", "print this help menu");
@@ -123,7 +111,7 @@ pub fn parse_middleware_options<D: Device>(matches: &mut Matches, device: D, loo
if let Some(pcap_filename) = matches.opt_str("pcap") {
pcap_writer = Box::new(File::create(pcap_filename).expect("cannot open file"))
} else {
pcap_writer = Box::new(Dispose)
pcap_writer = Box::new(io::sink())
}

let seed = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().subsec_nanos();
6 changes: 5 additions & 1 deletion src/phy/sys/tap_interface.rs
Original file line number Diff line number Diff line change
@@ -37,7 +37,11 @@ impl TapInterfaceDesc {
lower
};

ifreq_ioctl(lower, &mut self.ifreq, imp::SIOCGIFMTU).map(|mtu| mtu as usize)
let mtu = ifreq_ioctl(lower, &mut self.ifreq, imp::SIOCGIFMTU).map(|mtu| mtu as usize);

unsafe { libc::close(lower); }

mtu
}

fn wait(&mut self, ms: u32) -> io::Result<bool> {