1*13776c11Slogin use alloc::string::String; 2*13776c11Slogin use smoltcp::{ 3*13776c11Slogin iface, 4*13776c11Slogin wire::{self, EthernetAddress}, 5*13776c11Slogin }; 6*13776c11Slogin 7*13776c11Slogin use crate::{libs::spinlock::SpinLock, syscall::SystemError}; 8*13776c11Slogin 9*13776c11Slogin use super::Driver; 10*13776c11Slogin 11*13776c11Slogin pub mod virtio_net; 12*13776c11Slogin 13*13776c11Slogin pub trait NetDriver: Driver { 14*13776c11Slogin /// @brief 获取网卡的MAC地址 15*13776c11Slogin fn mac(&self) -> EthernetAddress; 16*13776c11Slogin 17*13776c11Slogin fn name(&self) -> String; 18*13776c11Slogin 19*13776c11Slogin /// @brief 获取网卡的id 20*13776c11Slogin fn nic_id(&self) -> usize; 21*13776c11Slogin 22*13776c11Slogin fn poll(&self, sockets: &mut iface::SocketSet) -> Result<(), SystemError>; 23*13776c11Slogin 24*13776c11Slogin fn update_ip_addrs(&self, ip_addrs: &[wire::IpCidr]) -> Result<(), SystemError>; 25*13776c11Slogin 26*13776c11Slogin /// @brief 获取smoltcp的网卡接口类型 27*13776c11Slogin fn inner_iface(&self) -> &SpinLock<smoltcp::iface::Interface>; 28*13776c11Slogin // fn as_any_ref(&'static self) -> &'static dyn core::any::Any; 29*13776c11Slogin } 30