Commit Graph

147 Commits (master)

Author SHA1 Message Date
Dario Nieuwenhuis 8c43fdd443 Remove braces that were previously needed to workaround SocketRef borrow issues. 2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis f8cc1eacbe socket: remove SocketRef.
The intent was to run custom code after the user is done modifying the socket,
for example to update a (not yet existing) port->socket map in SocketSet. However
this wouldn't work, since the SocketRef would have to borrow the SocketSet at
the same time as the Socket to be able to notify the SocketSet.

I believe such indexing can be achieved by setting a "dirty" bit *before* giving
the socket to the user, then on poll() reindexing all dirty sockets. This could
even be faster: if user gets a socket multiple times between polls, it'd be reindexed
only once.
2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis c08dd8dcf6 iface: own the SocketSet instead of borrowing it 2021-11-03 23:32:32 +01:00
Thibaut Vandervelden 1154390307 Use one PAN ID for source and destination
Also check for the correct destination PAN id when receiving a frame (as
discussed). Linux does this as well.
However, hardware implementations also can drop those packets.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis 3b8a0781e5 example/6lowpan: expand readme, do not use monitor interface.
Using a raw socket on `monitor0` causes weird results: packets we receive
include FCS, packets we send are parsed as if they didn't have FCS, except
by wireshark which always expects a FCS??

Turns out the sane way is to use raw sockets on normal `wpanX` interfaces,
in which case all packets we send/receive are without FCS.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis b4764e4973 Add RawHardwareAddress, use it in wire ndisc.
This avoids wire needing to know what medium we're on.
2021-10-21 01:25:13 +02:00
Thibaut Vandervelden fb2d0029d8 Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +02:00
Dario Nieuwenhuis 17e0ddcee3 Add rand module.
On `std` targets, `OsRng` is used by default. The user can supply a custom impl
by enabling the `rand-custom-impl` Cargo feature and using the `rand_custom_impl!()` macro.
Specifying a custom impl is mandatory when `std` is not enabled.
2021-10-11 20:53:04 +02:00
qiujiangkun acfa7f0b19 use micros in Instant and Duration 2021-10-05 22:33:58 +02:00
Dario Nieuwenhuis b674f0d0ba phy: simplify PcapSink trait 2021-10-03 21:29:40 +02:00
Dario Nieuwenhuis 1ac34f34eb Fix redundant closure clippy 2021-06-27 10:43:05 +02:00
Dario Nieuwenhuis 98fe17890a rustfmt 2021-06-27 09:31:59 +02:00
Dario Nieuwenhuis 743f9de039 dhcp: address review comments. 2021-05-28 18:23:50 +02:00
Dario Nieuwenhuis a916888ab8 dhcp: add max_lease_duration option 2021-04-13 20:23:28 +02:00
Dario Nieuwenhuis 0d53163c55 dhcp: convert to socket 2021-04-07 19:00:36 +02:00
Dario Nieuwenhuis d64c8593f0 Add defmt logging support 2021-04-01 01:30:47 +02:00
Dario Nieuwenhuis 6e8c2a8455 Add IP medium support to PcapWriter and Tracer. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis 9e3b373e36 Add support for TUN interfaces. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis 9ac2cac075 Add support for IP mediums.
- Add `medium` in `DeviceCapabilities`.
- Rename EthernetInterface to Interface.
- Add support to Interface for both Ethernet and IP mediums. The medium to use is detected from `device.capabilities().medium`.
- Ethernet-only features are gated behind the "ethernet" feature, as before.
- IP features are always enabled for now.
2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis f5f7037045 Remove unnecessary semicolon 2021-01-08 19:25:21 +01:00
Alex Crawford ea4579d68a Clean up examples
These were flagged by `cargo clippy`:

    warning: you seem to be trying to use match for destructuring a
             single pattern. Consider using `if let`
    warning: called `.nth(0)` on a `std::iter::Iterator`, when `.next()`
             is equivalent
    warning: using `write!()` with a format string that ends in a single
             newline
    warning: useless conversion to the same type:
             `smoltcp::wire::Ipv4Address`
    warning: called `map(f)` on an `Option` value where `f` is a closure
             that returns the unit type `()`
    warning: returning the result of a `let` binding from a block
    warning: use of `unwrap_or` followed by a function call
2021-01-04 10:39:27 -08:00
Alex Crawford 33236f23f4 Remove an unneeded semicolon 2020-12-28 23:20:01 -08:00
Alex Crawford fff5926210 Clean up a couple of if-blocks
These were flagged by `cargo clippy`:

    warning: this `else { if .. }` block can be collapsed
2020-12-28 22:27:24 -08:00
Alex Crawford b2c04416c2 Use is_empty instead of length comparison
These were flagged by `cargo clippy`:

    warning: length comparison to zero
2020-12-27 15:18:51 -08:00
Dario Nieuwenhuis 88256dbdcf Update to Rust 2018. Fixes #271 2020-12-27 17:54:56 +01:00
Alex Crawford d217c81e5d Remove explicit calls to as_ref/as_mut
These were flagged by `cargo clippy`:

    warning: this call to `as_ref` does nothing
    warning: this call to `as_mut` does nothing
2020-12-26 10:27:32 -08:00
Dario Nieuwenhuis 7782b24427 Fix crash in server example due to returning length bigger than received buffer. 2020-04-16 07:39:11 +00:00
Jeremy Andrews bce8d13c7f replace the use of the deprecated item (#314) 2019-11-02 19:11:08 +00:00
whitequark be7750486f Bump log dependency to version 0.4. NFC.
This doesn't affect downstream code because log 0.3.9 is a facade
crate implemented in terms of log 0.4, and so log 0.3 and log 0.4
APIs can be used together.
2019-06-22 08:31:11 +00:00
whitequark 04d1430fc9 Fix unused mut in examples/ping.rs. NFC. 2019-06-22 08:20:41 +00:00
whitequark 0134bb7399 Bump Rust version requirement to 1.27.
This allows us to use:
(1.26)
  - impl Trait
  - autoderef in pattern matching
  - fixed slice patterns
  - inclusive ranges
(1.27)
  - dyn Trait
  - #[must_use] on functions

To prepare for edition change, dyn is added where applicable. Other
edition changes would require bumping the requirement even higher,
and so they are not applied for now.
2019-06-22 08:19:39 +00:00
Astro 49f638e2d2 Implement DHCPv4 client + example.
Closes: #186
Approved by: whitequark
2019-05-14 00:37:43 +08:00
Astro a8f2725784 Implement IGMPv1/v2 processing.
Closes: #178
Approved by: whitequark
2018-08-01 10:26:51 +08:00
whitequark 06c7e6eb54 examples: remove the remaining panics on poll error. 2018-07-31 13:58:00 +00:00
whitequark 5bcb358eb5 Rename `new` method on Packet types to `new_checked`.
Fixes #195.

Closes: #254
Approved by: dlrobertson
2018-07-11 12:59:05 +08:00
Michal Podhradsky 3e124ef482 Log and print error for all examples 2018-06-22 19:30:03 +00:00
Valentin Lorentz 728ae3fbb5 Add support for arbitrarily many routes instead of only gateways.
Closes: #219
Approved by: whitequark
2018-06-10 05:31:08 +08:00
Michal Podhradsky 6249f69bd9 Log and print poll errors instead of crashing the server
Closes: #228
Approved by: dlrobertson
2018-06-06 06:30:18 +08:00
Dan Robertson 3a3ac474f6 Fix server example
Make the IPv6 address used in the server example the same as the IPv6
address used in the others.

Closes: #217
Approved by: dlrobertson
2018-05-19 04:34:02 +08:00
Valentin Lorentz 2d716883b6 Add support for IPv6 gateways.
Closes: #207
Approved by: dlrobertson
2018-05-14 09:39:39 +08:00
Dan Robertson bed3d8bd4b Add Address Resolution for IPv6
Add Address Resolution via NDISC for IPv6.

Closes: #196
Approved by: whitequark
2018-05-07 23:49:56 +08:00
whitequark 485b46a5e6 fn PacketMetadata::empty() → const PacketMetadata::EMPTY.
Fixes #181.
2018-03-24 03:23:37 +00:00
whitequark b1f0011056 Fix an off-by-1000 in time display in examples/ping.rs. 2018-02-22 12:25:07 +00:00
whitequark 3d12690009 Use storage::PacketBuffer for implementing socket::IcmpSocket.
This substantially increases its space efficiency.
2018-02-22 12:23:35 +00:00
whitequark c474d0c32e Factor out storage::PacketBuffer from socket::UdpSocket. 2018-02-22 11:34:58 +00:00
Philipp Oppermann ed2dcaaff9 Use separate metadata and payload buffers for UDP sockets.
Co-authored-by: Dan Robertson <danlrobertson89@gmail.com>
2018-02-22 06:33:11 +00:00
Dan Robertson 9747733dd7 Use time types in socket
Use the time types (Instant and Duration) in the socket modules instead
of a simple u64.

Closes: #141
Approved by: whitequark
2018-02-16 10:44:03 +08:00
Dan Robertson e0b48caca3 Update phy mod to use new time types
Update everything but the socket types to use the new time types instead
of a basic u64

Closes: #141
Approved by: whitequark
2018-02-16 10:44:03 +08:00
Dan Robertson 20d1dd8a4a Update examples to use time types
Closes: #141
Approved by: whitequark
2018-02-16 10:44:02 +08:00
寧靜 96fd18ff8f Add missing #[cfg(feature = "phy-tap_interface")]. 2018-02-04 08:31:03 +00:00