⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

NetworkDevice

Trait NetworkDevice 

Source
pub trait NetworkDevice: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn get_config(&self) -> InterfaceConfig;
    fn set_config(&mut self, config: InterfaceConfig) -> Result<(), KernelError>;
    fn up(&mut self) -> Result<(), KernelError>;
    fn down(&mut self) -> Result<(), KernelError>;
    fn send_packet(&mut self, packet: NetworkPacket) -> Result<(), KernelError>;
    fn receive_packet(&mut self) -> Result<Option<NetworkPacket>, KernelError>;
    fn get_stats(&self) -> NetworkStats;
    fn reset_stats(&mut self);
    fn link_up(&self) -> bool;
    fn link_speed(&self) -> u32;
}
Expand description

Network device trait

Required Methods§

Source

fn name(&self) -> &str

Get device name

Source

fn get_config(&self) -> InterfaceConfig

Get interface configuration

Source

fn set_config(&mut self, config: InterfaceConfig) -> Result<(), KernelError>

Set interface configuration

Source

fn up(&mut self) -> Result<(), KernelError>

Bring interface up

Source

fn down(&mut self) -> Result<(), KernelError>

Bring interface down

Source

fn send_packet(&mut self, packet: NetworkPacket) -> Result<(), KernelError>

Send a packet

Source

fn receive_packet(&mut self) -> Result<Option<NetworkPacket>, KernelError>

Receive a packet (non-blocking)

Source

fn get_stats(&self) -> NetworkStats

Get interface statistics

Source

fn reset_stats(&mut self)

Reset interface statistics

Check if link is up

Get link speed in Mbps

Implementors§