Skip to main content

NetworkStrate

Struct NetworkStrate 

Source
pub(crate) struct NetworkStrate {
Show 17 fields pub(crate) device: Strat9NetDevice, pub(crate) interface: Interface, pub(crate) sockets: SocketSet<'static>, pub(crate) dhcp_handle: SocketHandle, pub(crate) dns_handle: SocketHandle, pub(crate) icmp_handle: SocketHandle, pub(crate) ip_config: Option<IpConfig>, pub(crate) open_handles: BTreeMap<u64, String>, pub(crate) tcp_listeners: BTreeMap<u64, TcpListenerState>, pub(crate) tcp_connections: BTreeMap<u64, TcpConnState>, pub(crate) udp_bound: BTreeMap<u64, UdpBoundState>, pub(crate) udp_connections: BTreeMap<u64, UdpConnState>, pub(crate) next_fid: u64, pub(crate) pending_ping: Option<PendingPing>, pub(crate) ping_reply: Option<(u16, u64)>, pub(crate) ping_ident: u16, pub(crate) dhcp_enabled: bool,
}

Fields§

§device: Strat9NetDevice§interface: Interface§sockets: SocketSet<'static>§dhcp_handle: SocketHandle§dns_handle: SocketHandle§icmp_handle: SocketHandle§ip_config: Option<IpConfig>§open_handles: BTreeMap<u64, String>

VFS handles: file_id → virtual path (“/net/*”)

§tcp_listeners: BTreeMap<u64, TcpListenerState>§tcp_connections: BTreeMap<u64, TcpConnState>§udp_bound: BTreeMap<u64, UdpBoundState>§udp_connections: BTreeMap<u64, UdpConnState>§next_fid: u64§pending_ping: Option<PendingPing>

Last ping that was sent, waiting for reply

§ping_reply: Option<(u16, u64)>

Received reply: (seq, rtt_us)

§ping_ident: u16§dhcp_enabled: bool

Implementations§

Source§

impl NetworkStrate

Source

pub(crate) fn new(mac: [u8; 6]) -> Self

Creates a new instance.

Source

pub(crate) fn udp_port_in_use(&self, port: u16) -> bool

Returns true if a local UDP port is already in use by an opened UDP handle.

Source

pub(crate) fn alloc_udp_ephemeral_port(&self) -> Option<u16>

Allocates an ephemeral UDP local port from the dynamic range.

Source

pub(crate) fn create_udp_socket( &mut self, local_port: u16, ) -> Result<SocketHandle, i32>

Creates and binds an internal UDP transport endpoint on local_port, then registers it in the smoltcp socket set.

Source

pub(crate) fn tcp_state_name(state: State) -> &'static str

Returns a textual name for a TCP state.

Source

pub(crate) fn process_dhcp(&mut self)

Implements process dhcp.

Source

pub(crate) fn refresh_dns_servers(&mut self)

Implements refresh dns servers.

Source

pub(crate) fn apply_ipv4_config( &mut self, address: Ipv4Cidr, gateway: Option<Ipv4Address>, dns: [Option<Ipv4Address>; 3], )

Implements apply ipv4 config.

Source

pub(crate) fn resolve_hostname_blocking( &mut self, name: &str, ) -> Result<Ipv4Address, i32>

Implements resolve hostname blocking.

Source

pub(crate) fn process_icmp(&mut self)

Implements process icmp.

Source

pub(crate) fn send_ping(&mut self, target: Ipv4Address, seq: u16) -> bool

Implements send ping.

Source

pub(crate) fn handle_open(&mut self, msg: &IpcMessage) -> IpcMessage

Implements handle open.

Source

pub(crate) fn handle_tcp_read( &mut self, sender: u64, listener: TcpListenerState, ) -> IpcMessage

Implements handle tcp read.

Source

pub(crate) fn handle_tcp_write( &mut self, sender: u64, listener: TcpListenerState, msg: &IpcMessage, ) -> IpcMessage

Implements handle tcp write.

Source

pub(crate) fn handle_tcp_conn_read( &mut self, sender: u64, conn: TcpConnState, ) -> IpcMessage

Read from an outgoing TCP connection.

Source

pub(crate) fn handle_tcp_conn_write( &mut self, sender: u64, conn: TcpConnState, msg: &IpcMessage, ) -> IpcMessage

Write to an outgoing TCP connection.

Source

pub(crate) fn handle_udp_bound_read( &mut self, sender: u64, state: UdpBoundState, ) -> IpcMessage

Read from a UDP scheme handle bound on a local port.

Returned bytes are encoded as:

  • [0..4] source IPv4
  • [4..6] source UDP port (big-endian)
  • [6..] datagram payload (truncated to fit inline IPC reply)
Source

pub(crate) fn handle_udp_bound_write( &mut self, sender: u64, state: UdpBoundState, msg: &IpcMessage, ) -> IpcMessage

Write to a bound UDP scheme handle is not supported directly.

Use /net/udp/connect/<ip>/<port> for bidirectional traffic or /net/udp/send/<ip>/<port> for datagram sends with a fixed peer.

Source

pub(crate) fn handle_udp_conn_read( &mut self, sender: u64, conn: UdpConnState, ) -> IpcMessage

Read from a connected UDP scheme handle.

Source

pub(crate) fn handle_udp_conn_write( &mut self, sender: u64, conn: UdpConnState, msg: &IpcMessage, ) -> IpcMessage

Write to a connected UDP scheme handle.

Source

pub(crate) fn handle_read(&mut self, msg: &IpcMessage) -> IpcMessage

Implements handle read.

Source

pub(crate) fn handle_write(&mut self, msg: &IpcMessage) -> IpcMessage

Implements handle write.

Source

pub(crate) fn handle_close(&mut self, msg: &IpcMessage) -> IpcMessage

Implements handle close.

Source

pub(crate) fn alloc_fid(&mut self) -> u64

Implements alloc fid.

Source

pub(crate) fn serve(&mut self, port: u64) -> !

Implements serve.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.