Commit Graph

91 Commits

Author SHA1 Message Date
whitequark e0d8fcfb72 Emit exceptional events with the DEBUG log level, not TRACE. 2017-08-01 11:21:58 +00:00
whitequark 8d8a4ea583 Get rid of Result<_, ()>.
The use of this type has several drawbacks:
  * It does not allow distinguishing between different error
    conditions. In fact, we wrongly conflated some of them
    before this commit.
  * It does not allow propagation via ? and requires manual use
    of map_err, which is especially tiresome for downstream code.
  * It prevents us from expanding the set of error conditions
    even if right now we have only one.
  * It prevents us from blanket using Result<T> everywhere
    (a nitpick at most).

Instead, use Result<T, Error> everywhere, and differentiate error
conditions where applicable.
2017-07-27 13:55:47 +00:00
whitequark 8a2432dcd7 Rework error handling in TcpSocket::connect. 2017-07-27 12:27:33 +00:00
whitequark a61c1a5d2e Rearrange errors and clarify their semantics. 2017-07-27 12:10:04 +00:00
whitequark fe6fb087e5 Move macros into their own module.
This allows us to use `enum_with_unknown` in `phy`.
2017-07-23 07:54:36 +00:00
whitequark 63ab7d4e7a Implement loopback interfaces.
This also adds a default implementation of Device::limits.
2017-07-14 01:14:40 +00:00
whitequark 8b27330c8b Do not attempt to validate length of packets being emitted.
This is a form of an uninitialized read bug; although safe it caused
panics. In short, transmit buffers received from the network stack
should be considered uninitialized (in practice they will often
contain previously transmitted packets or parts thereof). Wrapping
them with the only method we had (e.g. Ipv4Packet) treated the buffer
as if it contained a valid incoming packet, which can easily fail
with Error::Truncated.

This commit splits every `fn new(buffer: T) -> Result<Self, Error>`
method on a `Packet` into three smaller ones:
  * `fn check_len(&self) -> Result<(), Error>`, purely a validator;
  * `fn new(T) -> Self`, purely a wrapper;
  * `fn new_checked(T) -> Result<Self, Error>`, a validating wrapper.

This makes it easy to process ingress packets (using `new_checked`),
egress packets (using `new`), and, if needed, maintain the invariants
at any point during packet construction (using `check_len`).

Fixes #17.
2017-06-24 11:42:32 +00:00
Egor Karavaev c1c4ed68c5 Factor out the `RingBuffer` container. 2017-06-21 02:50:10 +00:00
Egor Karavaev 59fc0c0358 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.
2017-06-15 10:12:11 +00:00
whitequark b305797cb4 Trace eviction and fill in SliceArpCache. 2017-03-07 06:25:47 +00:00
whitequark 493a319132 Remove the `use_` prefix from feature names.
I haven't realized that a feature `log` with an optional crate
dependency `log` activates that dependency, and added the prefix
to avoid a "clash". This is unnecessary.
2017-03-05 05:49:38 +00:00
whitequark 9905b3de86 Pull in macros from the log crate in tests. 2017-01-31 11:46:07 +00:00
whitequark 22e5462936 Add Internet and Ethernet address parsing (from strings). 2017-01-25 19:41:02 +00:00
whitequark 40716a348d Do not send RST in response to invalid SEQ or ACK. 2017-01-16 16:58:45 +00:00
whitequark 362c954624 Make interfaces not own the sockets. 2017-01-11 05:25:54 +00:00
whitequark 67430aa589 Use the managed crate. 2017-01-10 11:04:00 +00:00
whitequark bf3b62bb25 Examples for the phy layer! 2016-12-31 12:28:59 +00:00
whitequark 345670f618 Documentation! 2016-12-31 10:26:59 +00:00
whitequark 151b3ba07b Get rid of the #![feature(associated_consts)]. 2016-12-28 00:12:15 +00:00
whitequark 71268ace88 Get rid of the #![feature(const_fn)]. 2016-12-28 00:08:51 +00:00
whitequark e043e7c496 Get rid of the #![feature(step_by)]. 2016-12-28 00:08:51 +00:00
whitequark b409eec11b Suppress unused variable warnings in net_trace!. 2016-12-27 23:52:43 +00:00
whitequark bba505bc90 Add a use_alloc feature. 2016-12-27 23:49:37 +00:00
whitequark de24d635fa Rename features: std→use_std, logging→use_log. 2016-12-27 23:45:24 +00:00
whitequark 3c05139204 Add logging capability. 2016-12-23 07:59:38 +00:00
whitequark c672b94ef7 Rethink the buffering strategy with Managed<T>. 2016-12-17 04:15:55 +00:00
whitequark d1d910b46d Significantly simplify buffering. 2016-12-15 17:27:17 +00:00
whitequark fb172ed1ed Implement UDP sockets. 2016-12-14 17:39:44 +00:00
whitequark d587981ef5 Implement ICMPv4 echo replies. 2016-12-12 23:22:59 +00:00
whitequark c5bdf30458 Implement IPv4 representation parsing and emission. 2016-12-12 20:09:37 +00:00
whitequark 921ca353b4 Implement IPv4 packet support. 2016-12-12 17:26:06 +00:00
whitequark 4421b2fe27 Implement ARP replies. 2016-12-12 07:19:53 +00:00
whitequark d862512582 Implement an ARP LRU cache. 2016-12-12 02:39:46 +00:00
whitequark e7d6237279 Implement TAP interface support. 2016-12-11 00:30:40 +00:00
whitequark fb3faa9d28 Implement a trait for sending and receiving frames. 2016-12-10 19:27:07 +00:00
whitequark 683652a9a6 smoltcp::interface → smoltcp::phy. 2016-12-10 18:33:19 +00:00
whitequark b1149e746c Implement raw socket interface and tcpdump. 2016-12-10 16:58:30 +00:00
whitequark 32ff49a795 Move protocol-related data structures to smoltcp::wire. 2016-12-10 13:13:13 +00:00
whitequark d966c1870b Implement ARP representation parsing and emission. 2016-12-10 11:16:58 +00:00
whitequark adff3c0069 Imlpement ARP packet support. 2016-12-10 10:40:46 +00:00
whitequark c638f45373 Implement Ethernet II frame support. 2016-12-10 09:55:45 +00:00