Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump smoltcp-nal from 0.3.0 to 0.4.0 #322

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
* Network stack is randomly seeded on startup so that random ports are used.

## [0.5.0] - 03-07-2023

### Added
Expand Down
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exclude = [
cortex-m = "0.7.7"
cortex-m-rt = "0.7"
cortex-m-rtic = "1.1"
rand_core = "0.6"
mono-clock = "0.1"
systick-monotonic = "1.0.1"
cortex-m-log = { version = "0.8.0", features = ["log-integration"] }
Expand All @@ -53,7 +54,7 @@ minireq = "0.2"
rtt-target = {version = "0.3", features=["cortex-m"]}
enum-iterator = { version = "1.4", default-features = false }
enc424j600 = { version = "0.3", features = ["cortex-m-cpu"] }
smoltcp-nal = { version = "0.3", features=["shared-stack"] }
smoltcp-nal = { version = "0.4", features=["shared-stack"] }

[build-dependencies]
built = { version = "0.6", features = ["git2"], default-features = false }
Expand Down
12 changes: 7 additions & 5 deletions src/hardware/net_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ impl TcpSocketStorage {
/// # Args
/// * `mac` - The smoltcp interface MAC.
/// * `settings` - The device settings to use.
/// * `random_seed` - A random seed for the network stack.
pub fn setup(
device: &mut Mac,
settings: &BoosterSettings,
random_seed: u64,
) -> (
smoltcp::iface::Interface,
smoltcp::iface::SocketSet<'static>,
Expand All @@ -61,12 +63,12 @@ pub fn setup(

let ip_address = settings.ip_address();

let mut config = smoltcp::iface::Config::default();
config
.hardware_addr
.replace(smoltcp::wire::HardwareAddress::Ethernet(settings.mac()));
let mut config =
smoltcp::iface::Config::new(smoltcp::wire::HardwareAddress::Ethernet(settings.mac()));
config.random_seed = random_seed;

let mut interface = smoltcp::iface::Interface::new(config, device);
let mut interface =
smoltcp::iface::Interface::new(config, device, smoltcp::time::Instant::ZERO);

interface
.routes_mut()
Expand Down
11 changes: 9 additions & 2 deletions src/hardware/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use core::convert::TryInto;
use core::fmt::Write;
use hal::prelude::*;
use heapless::String;
use rand_core::RngCore;
use usb_device::prelude::*;

/// Macro for genering an RfChannelPins structure.
Expand Down Expand Up @@ -377,8 +378,14 @@ pub fn setup(
ApplicationMetadata::new(hardware_version, phy_string)
};

let (interface, sockets) = net_interface::setup(&mut mac, &settings);
let network_stack = smoltcp_nal::NetworkStack::new(interface, mac, sockets, clock);
let mut rng = device.RNG.constrain(&clocks);

let (interface, sockets) = net_interface::setup(&mut mac, &settings, rng.next_u64());
let mut network_stack = smoltcp_nal::NetworkStack::new(interface, mac, sockets, clock);

let mut seed_bytes = [0; 8];
rng.fill_bytes(&mut seed_bytes);
network_stack.seed_random_port(&seed_bytes);

let mut fans = {
let main_board_leds = {
Expand Down
Loading