mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
clean up warnings, fix icmp init
This commit is contained in:
parent
64e9248815
commit
5e411f3562
8 changed files with 17 additions and 40 deletions
|
|
@ -458,7 +458,6 @@ pub fn ipaddress_to_ipaddr(other: IpAddress) -> IpAddr {
|
|||
let octets = ipv6.0;
|
||||
IpAddr::V6(Ipv6Addr::from(octets))
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,9 +59,6 @@ impl From<IpAddress> for NetIpAddr {
|
|||
match other {
|
||||
IpAddress::Ipv4(ipv4) => NetIpAddr::Ipv4(ipv4.0),
|
||||
IpAddress::Ipv6(ipv6) => NetIpAddr::Ipv6(ipv6.0),
|
||||
_ => {
|
||||
panic!("Invalid IpAddress")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@ use smoltcp::wire::{ArpPacket, ArpRepr, ArpOperation, Ipv4Address, EthernetAddre
|
|||
use num_traits::*;
|
||||
use std::convert::TryInto;
|
||||
|
||||
use smoltcp::{
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use crate::{MAC_ADDRESS_LSB, MAC_ADDRESS_MSB};
|
||||
use core::sync::atomic::Ordering;
|
||||
use std::collections::VecDeque;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use std_udp::*;
|
|||
mod std_tcplistener;
|
||||
use std_tcplistener::*;
|
||||
|
||||
use com::api::{ComIntSources, Ipv4Conf, NET_MTU};
|
||||
use com::api::{ComIntSources, Ipv4Conf};
|
||||
use num_traits::*;
|
||||
|
||||
mod connection_manager;
|
||||
|
|
@ -23,16 +23,16 @@ mod tests;
|
|||
#[cfg(feature="btest")]
|
||||
mod btests;
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, BTreeSet};
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use xous::{msg_blocking_scalar_unpack, msg_scalar_unpack, send_message, Message, CID, SID};
|
||||
use xous_ipc::Buffer;
|
||||
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
use smoltcp::iface::{Interface, Config, SocketSet};
|
||||
use smoltcp::phy::{Device, Medium, Tracer};
|
||||
use smoltcp::phy::{Device, Tracer};
|
||||
use smoltcp::socket::{tcp, udp, icmp};
|
||||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address, Ipv4Cidr, IpEndpoint};
|
||||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address, IpEndpoint};
|
||||
use smoltcp::wire::{Icmpv4Packet, Icmpv4Repr, Icmpv6Packet, Icmpv6Repr};
|
||||
|
||||
use core::num::NonZeroU64;
|
||||
|
|
@ -51,7 +51,6 @@ pub static MAC_ADDRESS_LSB: AtomicU32 = AtomicU32::new(0);
|
|||
pub static MAC_ADDRESS_MSB: AtomicU16 = AtomicU16::new(0);
|
||||
|
||||
const PING_DEFAULT_TIMEOUT_MS: u32 = 10_000;
|
||||
const MAX_DELAY_THREADS: u32 = 9;
|
||||
const PING_IDENT: u16 = 0x22b;
|
||||
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
|
|
@ -247,6 +246,12 @@ fn main() -> ! {
|
|||
let tcp4_handle = sockets.add(tcp4_socket);
|
||||
*/
|
||||
let icmp_handle = sockets.add(icmp_socket);
|
||||
{ // put in a block to retire the icmp_socket variable in this scope
|
||||
let icmp_socket = sockets.get_mut::<icmp::Socket>(icmp_handle);
|
||||
icmp_socket
|
||||
.bind(icmp::Endpoint::Ident(PING_IDENT))
|
||||
.expect("couldn't bind to icmp socket");
|
||||
}
|
||||
|
||||
// ------------- libstd variant -----------
|
||||
// Each process keeps track of its own sockets. These are kept in a Vec. When a handle
|
||||
|
|
@ -498,7 +503,6 @@ fn main() -> ! {
|
|||
&device_caps.checksum,
|
||||
);
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
seq += 1;
|
||||
// fire off a Pump to get the stack to actually transmit the ping; this call merely queues it for sending
|
||||
|
|
@ -1295,7 +1299,7 @@ fn main() -> ! {
|
|||
}
|
||||
}
|
||||
}),
|
||||
Some(Opcode::NetPump) => msg_scalar_unpack!(msg, wup_hi, wup_lo, _, _, {
|
||||
Some(Opcode::NetPump) => msg_scalar_unpack!(msg, _, _, _, _, {
|
||||
log::trace!("NetPump");
|
||||
let now = timer.elapsed_ms();
|
||||
let timestamp = Instant::from_millis(now as i64);
|
||||
|
|
@ -1890,7 +1894,6 @@ fn main() -> ! {
|
|||
log::error!("got unhandled ICMP type, ignoring!");
|
||||
}
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@ pub(crate) fn write_address(address: IpAddress, data: &mut [u8]) -> Option<usize
|
|||
}
|
||||
Some(16)
|
||||
}
|
||||
_ => {
|
||||
*i.next()? = 0;
|
||||
Some(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use smoltcp::socket::tcp;
|
|||
|
||||
pub(crate) fn std_tcp_listen(
|
||||
mut msg: xous::MessageEnvelope,
|
||||
iface: &mut Interface,
|
||||
_iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
our_sockets: &mut Vec<Option<SocketHandle>>,
|
||||
trng: &trng::Trng,
|
||||
|
|
@ -46,7 +46,6 @@ pub(crate) fn std_tcp_listen(
|
|||
let tcp_socket = tcp::Socket::new(tcp_rx_buffer, tcp_tx_buffer);
|
||||
|
||||
let handle = sockets.add(tcp_socket);
|
||||
let cx = iface.context();
|
||||
let tcp_socket = sockets.get_mut::<tcp::Socket>(handle);
|
||||
|
||||
loop {
|
||||
|
|
@ -55,7 +54,6 @@ pub(crate) fn std_tcp_listen(
|
|||
.map_err(|e| match e {
|
||||
smoltcp::socket::tcp::ListenError::InvalidState => NetError::SocketInUse,
|
||||
smoltcp::socket::tcp::ListenError::Unaddressable => NetError::Unaddressable,
|
||||
_ => NetError::LibraryError,
|
||||
})
|
||||
{
|
||||
match e {
|
||||
|
|
@ -97,7 +95,7 @@ pub(crate) fn std_tcp_listen(
|
|||
|
||||
pub(crate) fn std_tcp_accept(
|
||||
mut msg: xous::MessageEnvelope,
|
||||
iface: &mut Interface,
|
||||
_iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
tcp_accept_waiting: &mut Vec<Option<AcceptingSocket>>,
|
||||
tcp_server_remote_close_poll: &mut Vec<SocketHandle>,
|
||||
|
|
@ -174,9 +172,6 @@ pub(crate) fn tcp_accept_success(buf: &mut [u8], fd: u16, ep: IpEndpoint) {
|
|||
*d = s;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
buf[3] = 0; // this is the invalid/error type
|
||||
}
|
||||
}
|
||||
let port = ep.port.to_le_bytes();
|
||||
buf[20] = port[0];
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ pub(crate) fn std_tcp_connect(
|
|||
.map_err(|e| match e {
|
||||
smoltcp::socket::tcp::ConnectError::InvalidState => NetError::SocketInUse,
|
||||
smoltcp::socket::tcp::ConnectError::Unaddressable => NetError::Unaddressable,
|
||||
_ => NetError::LibraryError,
|
||||
})
|
||||
{
|
||||
log::debug!("couldn't connect: {:?}", e);
|
||||
|
|
@ -76,7 +75,7 @@ pub(crate) fn std_tcp_connect(
|
|||
pub(crate) fn std_tcp_tx(
|
||||
mut msg: xous::MessageEnvelope,
|
||||
timer: &Ticktimer,
|
||||
iface: &mut Interface,
|
||||
_iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
tcp_tx_waiting: &mut Vec<Option<WaitingSocket>>,
|
||||
our_sockets: &Vec<Option<SocketHandle>>,
|
||||
|
|
@ -150,7 +149,7 @@ pub(crate) fn std_tcp_tx(
|
|||
pub(crate) fn std_tcp_rx(
|
||||
mut msg: xous::MessageEnvelope,
|
||||
timer: &Ticktimer,
|
||||
iface: &mut Interface,
|
||||
_iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
tcp_rx_waiting: &mut Vec<Option<WaitingSocket>>,
|
||||
our_sockets: &Vec<Option<SocketHandle>>,
|
||||
|
|
@ -228,7 +227,7 @@ pub(crate) fn std_tcp_rx(
|
|||
pub(crate) fn std_tcp_peek(
|
||||
mut msg: xous::MessageEnvelope,
|
||||
timer: &Ticktimer,
|
||||
iface: &mut Interface,
|
||||
_iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
our_sockets: &Vec<Option<SocketHandle>>,
|
||||
tcp_peek_waiting: &mut Vec<Option<WaitingSocket>>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::*;
|
||||
use crate::device::NetPhy;
|
||||
use smoltcp::wire::{IpEndpoint, IpAddress};
|
||||
use ticktimer_server::Ticktimer;
|
||||
|
||||
|
|
@ -8,11 +7,9 @@ use ticktimer_server::Ticktimer;
|
|||
/// Sockets are stored in the PID/SocketHandle HashMap `process_sockets` (this is shared with TCP)
|
||||
/// `recv` requests create `UpdStdState` objects, that are stored in a `udp_rx` Vec.
|
||||
|
||||
const BUFLEN: usize = NET_MTU as usize;
|
||||
|
||||
pub(crate) fn std_udp_bind(
|
||||
mut msg: xous::MessageEnvelope,
|
||||
iface: &mut Interface,
|
||||
_iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
our_sockets: &mut Vec<Option<SocketHandle>>,
|
||||
) {
|
||||
|
|
@ -55,7 +52,6 @@ pub(crate) fn std_udp_bind(
|
|||
.map_err(|e| match e {
|
||||
smoltcp::socket::udp::BindError::InvalidState => NetError::SocketInUse,
|
||||
smoltcp::socket::udp::BindError::Unaddressable => NetError::Unaddressable,
|
||||
_ => NetError::LibraryError,
|
||||
})
|
||||
{
|
||||
log::trace!("couldn't connect: {:?}", e);
|
||||
|
|
@ -249,7 +245,6 @@ pub(crate) fn std_udp_tx(
|
|||
.map_err(|e| match e {
|
||||
smoltcp::socket::udp::BindError::InvalidState => NetError::WouldBlock,
|
||||
smoltcp::socket::udp::BindError::Unaddressable => NetError::Unaddressable,
|
||||
_ => NetError::LibraryError,
|
||||
}) {
|
||||
std_failure(msg, e);
|
||||
return;
|
||||
|
|
@ -286,9 +281,6 @@ pub(crate) fn udp_rx_success(buf: &mut [u8], rx: &[u8], ep: IpEndpoint) {
|
|||
*d = s;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
buf[3] = 0; // this is the invalid/error type
|
||||
}
|
||||
}
|
||||
let port = ep.port.to_le_bytes();
|
||||
buf[20] = port[0];
|
||||
|
|
|
|||
Loading…
Reference in a new issue