From 33d12801b7d382fb8ad8f3dd24aa8b5c38709120 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 6 Jul 2020 12:59:51 +0800 Subject: [PATCH] runtime: use network addresses from config --- src/runtime/src/comms.rs | 52 +++++++++++++++++++++++++--------------- src/runtime/src/main.rs | 2 -- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index af4e2b25..5642ad3d 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -13,14 +13,15 @@ use libboard_zynq::{ self as zynq, smoltcp::{ self, - wire::{EthernetAddress, IpAddress, Ipv4Address, IpCidr}, - iface::{NeighborCache, EthernetInterfaceBuilder, Routes}, + wire::IpCidr, + iface::{NeighborCache, EthernetInterfaceBuilder}, time::Instant, }, timer::GlobalTimer, }; use libasync::{smoltcp::{Sockets, TcpStream}, task}; +use crate::net_settings; use crate::proto_async::*; use crate::kernel; use crate::rpc; @@ -252,12 +253,11 @@ async fn handle_connection(stream: &TcpStream, control: Rc { + let ip_addrs = [ + IpCidr::new(net_addresses.ipv4_addr, 0), + IpCidr::new(net_addresses.ipv6_ll_addr, 0), + IpCidr::new(addr, 0) + ]; + EthernetInterfaceBuilder::new(&mut eth) + .ethernet_addr(net_addresses.hardware_addr) + .ip_addrs(ip_addrs) + .neighbor_cache(neighbor_cache) + .finalize() + } + None => { + let ip_addrs = [ + IpCidr::new(net_addresses.ipv4_addr, 0), + IpCidr::new(net_addresses.ipv6_ll_addr, 0) + ]; + EthernetInterfaceBuilder::new(&mut eth) + .ethernet_addr(net_addresses.hardware_addr) + .ip_addrs(ip_addrs) + .neighbor_cache(neighbor_cache) + .finalize() + } + }; Sockets::init(32); diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index faadfd6a..d54d1ccc 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -72,7 +72,5 @@ pub fn main_core0() { pl::csr::rtio_core::reset_phy_write(1); } - info!("network addresses: {}", net_settings::get_adresses()); - comms::main(timer); }