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§
Sourcefn get_interface_name(&self) -> &'static str
fn get_interface_name(&self) -> &'static str
Get the network interface name
Sourcefn get_mac_address(&self) -> Result<MacAddress, &'static str>
fn get_mac_address(&self) -> Result<MacAddress, &'static str>
Get the MAC address of the interface
Sourcefn get_mtu(&self) -> Result<usize, &'static str>
fn get_mtu(&self) -> Result<usize, &'static str>
Get the MTU (Maximum Transmission Unit) of the interface
Sourcefn get_interface_config(&self) -> Result<NetworkInterfaceConfig, &'static str>
fn get_interface_config(&self) -> Result<NetworkInterfaceConfig, &'static str>
Get the full interface configuration
Sourcefn send_packet(&self, packet: DevicePacket) -> Result<(), &'static str>
fn send_packet(&self, packet: DevicePacket) -> Result<(), &'static str>
Send a packet
Sourcefn receive_packets(&self) -> Result<Vec<DevicePacket>, &'static str>
fn receive_packets(&self) -> Result<Vec<DevicePacket>, &'static str>
Receive packets (non-blocking) Returns all currently available packets
Sourcefn set_promiscuous_mode(&self, enabled: bool) -> Result<(), &'static str>
fn set_promiscuous_mode(&self, enabled: bool) -> Result<(), &'static str>
Set promiscuous mode (receive all packets on the network)
Sourcefn init_network(&mut self) -> Result<(), &'static str>
fn init_network(&mut self) -> Result<(), &'static str>
Initialize the network device
Sourcefn is_link_up(&self) -> bool
fn is_link_up(&self) -> bool
Check if the link is up
Sourcefn get_stats(&self) -> NetworkStats
fn get_stats(&self) -> NetworkStats
Get network device statistics