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