1use crate::device::NetDevice;
6use crate::sync::SpinLock;
7use alloc::{sync::Arc, vec::Vec};
8
9pub mod net_device;
10pub mod virtio_net;
11
12use lazy_static::lazy_static;
13lazy_static! {
14 pub static ref NETWORK_DEVICES: SpinLock<Vec<Arc<dyn NetDevice>>> = SpinLock::new(Vec::new());
17}
18
19pub fn add_network_device(device: Arc<dyn NetDevice>) {
21 NETWORK_DEVICES.lock().push(device);
22}
23pub fn get_net_devices() -> Vec<alloc::sync::Arc<dyn NetDevice>> {
25 NETWORK_DEVICES.lock().clone()
26}
27
28fn format_mac_address(mac: [u8; 6]) -> alloc::string::String {
30 use alloc::format;
31 format!(
32 "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
33 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
34 )
35}