pub(crate) struct NetworkStrate {Show 24 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) ipv6_config: Option<Ipv6Config>,
pub(crate) dns_servers: [Option<IpAddress>; 3],
pub(crate) dns_from_dhcp: bool,
pub(crate) link_local_addr: Ipv6Address,
pub(crate) open_handles: BTreeMap<u64, OpenedFile>,
pub(crate) handle_owners: BTreeMap<u64, u64>,
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) lingering_sockets: Vec<SocketHandle>,
pub(crate) next_fid: u64,
pub(crate) ping_ident: u16,
pub(crate) next_ping_token: u64,
pub(crate) pending_pings: Vec<PendingPing>,
pub(crate) ping_replies: Vec<(u16, u64)>,
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>§ipv6_config: Option<Ipv6Config>§dns_servers: [Option<IpAddress>; 3]§dns_from_dhcp: bool§link_local_addr: Ipv6Address§open_handles: BTreeMap<u64, OpenedFile>§handle_owners: BTreeMap<u64, u64>fid -> sender that opened it. See new_fid / is_owner:
sequential fids are guessable, so every operation must be checked
against the opener’s identity.
tcp_listeners: BTreeMap<u64, TcpListenerState>§tcp_connections: BTreeMap<u64, TcpConnState>§udp_bound: BTreeMap<u64, UdpBoundState>§udp_connections: BTreeMap<u64, UdpConnState>§lingering_sockets: Vec<SocketHandle>§next_fid: u64§ping_ident: u16§next_ping_token: u64§pending_pings: Vec<PendingPing>§ping_replies: Vec<(u16, u64)>§dhcp_enabled: boolImplementations§
Source§impl NetworkStrate
impl NetworkStrate
pub(crate) fn process_dhcp(&mut self)
pub(crate) fn refresh_dns_servers(&mut self)
pub(crate) fn apply_ipv4_config( &mut self, address: Ipv4Cidr, gateway: Option<Ipv4Address>, )
pub(crate) fn apply_ipv6_config( &mut self, address: Ipv6Cidr, gateway: Option<Ipv6Address>, )
pub(crate) fn resolve_hostname_query( &mut self, name: &str, q_type: DnsQueryType, ) -> Result<IpAddress, i32>
pub(crate) fn resolve_hostname_blocking( &mut self, name: &str, ) -> Result<IpAddress, i32>
pub(crate) fn process_ipv6_slaac(&mut self)
Source§impl NetworkStrate
impl NetworkStrate
Source§impl NetworkStrate
impl NetworkStrate
pub(crate) fn process_icmp(&mut self)
fn handle_echo_request_v4(&mut self, data: &[u8], addr: IpAddress)
fn handle_echo_request_v6(&mut self, data: &[u8], addr: IpAddress)
fn handle_echo_reply_v4(&mut self, data: &[u8])
fn handle_echo_reply_v6(&mut self, data: &[u8])
pub(crate) fn is_local_ipv4(&self, target: Ipv4Address) -> bool
pub(crate) fn is_local_ipv6(&self, target: Ipv6Address) -> bool
pub(crate) fn send_ping( &mut self, target: Ipv4Address, seq: u16, _file_id: u64, ) -> bool
pub(crate) fn send_ping6( &mut self, target: Ipv6Address, seq: u16, _file_id: u64, ) -> bool
Source§impl NetworkStrate
impl NetworkStrate
pub(crate) fn new(mac: [u8; 6]) -> Self
pub(crate) fn clear_ipv4_runtime_config(&mut self)
pub(crate) fn drain_spilled_read( &mut self, sender: u64, file_id: u64, requested: usize, ) -> Option<IpcMessage>
pub(crate) fn reply_read_spilling( &mut self, sender: u64, file_id: u64, requested: usize, data: Vec<u8>, ) -> IpcMessage
pub(crate) fn reset_dhcp_socket(&mut self)
pub(crate) fn enable_dhcp(&mut self)
pub(crate) fn alloc_ping_token(&mut self) -> u64
pub(crate) fn udp_port_in_use(&self, port: u16) -> bool
pub(crate) fn alloc_udp_ephemeral_port(&self) -> Option<u16>
pub(crate) fn create_udp_socket( &mut self, local_port: u16, ) -> Result<SocketHandle, i32>
pub(crate) fn tcp_state_name(state: State) -> &'static str
pub(crate) fn alloc_fid(&mut self) -> u64
Sourcepub(crate) fn new_fid(&mut self, owner: u64) -> u64
pub(crate) fn new_fid(&mut self, owner: u64) -> u64
Allocate the next fid and record its owner (the sender that opened it).
Fids are small sequential integers, trivially guessable: without this ownership record, any process could read another process’s TCP connection, hijack its UDP socket or reconfigure the IP stack by issuing operations on a guessed fid.
Sourcepub(crate) fn is_owner(&self, fid: u64, sender: u64) -> bool
pub(crate) fn is_owner(&self, fid: u64, sender: u64) -> bool
True when sender opened fid. Unknown fids belong to nobody:
every sender gets EBADF for them.
Sourcepub(crate) fn forget_handle(&mut self, fid: u64)
pub(crate) fn forget_handle(&mut self, fid: u64)
Drop the ownership record of a closed fid.
Source§impl NetworkStrate
impl NetworkStrate
pub(crate) fn handle_tcp_read( &mut self, sender: u64, listener: TcpListenerState, requested: usize, ) -> IpcMessage
pub(crate) fn handle_tcp_write( &mut self, sender: u64, listener: TcpListenerState, msg: &IpcMessage, ) -> IpcMessage
pub(crate) fn handle_tcp_conn_read( &mut self, sender: u64, conn: TcpConnState, requested: usize, ) -> IpcMessage
pub(crate) fn handle_tcp_conn_write( &mut self, sender: u64, conn: TcpConnState, msg: &IpcMessage, ) -> IpcMessage
pub(crate) fn handle_udp_bound_read( &mut self, sender: u64, file_id: u64, requested: usize, ) -> IpcMessage
pub(crate) fn handle_udp_bound_write( &mut self, sender: u64, file_id: u64, msg: &IpcMessage, ) -> IpcMessage
pub(crate) fn handle_udp_conn_read( &mut self, sender: u64, file_id: u64, conn: UdpConnState, requested: usize, ) -> IpcMessage
pub(crate) fn handle_udp_conn_write( &mut self, sender: u64, conn: UdpConnState, msg: &IpcMessage, ) -> IpcMessage
Source§impl NetworkStrate
impl NetworkStrate
fn insert_open_handle(&mut self, sender: u64, path: &str) -> u64
fn reply_open_path(&mut self, sender: u64, path: &str, flags: u32) -> IpcMessage
fn open_tcp_listener_handle( &mut self, sender: u64, path: &str, port: u16, auto_relisten: bool, ) -> IpcMessage
fn open_tcp_connection_handle( &mut self, sender: u64, path: &str, remote_ip: IpAddress, remote_port: u16, local_port: u16, ) -> IpcMessage
fn open_udp_connection_handle( &mut self, sender: u64, path: &str, remote: IpEndpoint, ) -> IpcMessage
pub(crate) fn handle_open(&mut self, msg: &IpcMessage) -> IpcMessage
pub(crate) fn handle_read(&mut self, msg: &IpcMessage) -> IpcMessage
pub(crate) fn handle_write(&mut self, msg: &IpcMessage) -> IpcMessage
pub(crate) fn handle_close(&mut self, msg: &IpcMessage) -> IpcMessage
Auto Trait Implementations§
impl !UnwindSafe for NetworkStrate
impl Freeze for NetworkStrate
impl RefUnwindSafe for NetworkStrate
impl Send for NetworkStrate
impl Sync for NetworkStrate
impl Unpin for NetworkStrate
impl UnsafeUnpin for NetworkStrate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more