NetworkDevice

Trait NetworkDevice 

Source
pub trait NetworkDevice: Device {
    // Required methods
    fn get_interface_name(&self) -> &'static str;
    fn get_mac_address(&self) -> Result<MacAddress, &'static str>;
    fn get_mtu(&self) -> Result<usize, &'static str>;
    fn get_interface_config(
        &self,
    ) -> Result<NetworkInterfaceConfig, &'static str>;
    fn send_packet(&self, packet: DevicePacket) -> Result<(), &'static str>;
    fn receive_packets(&self) -> Result<Vec<DevicePacket>, &'static str>;
    fn set_promiscuous_mode(&self, enabled: bool) -> Result<(), &'static str>;
    fn init_network(&mut self) -> Result<(), &'static str>;
    fn is_link_up(&self) -> bool;
    fn get_stats(&self) -> NetworkStats;
}
Expand description

Network device interface

This trait defines the interface for network devices. It provides methods for packet transmission, reception, and interface management.

Required Methods§

Source

fn get_interface_name(&self) -> &'static str

Get the network interface name

Source

fn get_mac_address(&self) -> Result<MacAddress, &'static str>

Get the MAC address of the interface

Source

fn get_mtu(&self) -> Result<usize, &'static str>

Get the MTU (Maximum Transmission Unit) of the interface

Source

fn get_interface_config(&self) -> Result<NetworkInterfaceConfig, &'static str>

Get the full interface configuration

Source

fn send_packet(&self, packet: DevicePacket) -> Result<(), &'static str>

Send a packet

Source

fn receive_packets(&self) -> Result<Vec<DevicePacket>, &'static str>

Receive packets (non-blocking) Returns all currently available packets

Source

fn set_promiscuous_mode(&self, enabled: bool) -> Result<(), &'static str>

Set promiscuous mode (receive all packets on the network)

Source

fn init_network(&mut self) -> Result<(), &'static str>

Initialize the network device

Check if the link is up

Source

fn get_stats(&self) -> NetworkStats

Get network device statistics

Implementors§