Files
DragonOS/kernel/src/net/mod.rs
Samuel Dai 40d9375b6b ready for merge in master (#964)
uevent should be format

Enum of smoltcp socket should be optimized.

need to add interface for routing subsys

actix is still not abled to run.

clean some casual added code to other places
2024-10-10 17:53:39 +08:00

31 lines
930 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! # 网络模块
//! 注意net模块下为了方便导入模块细分且共用部分模块直接使用
//! `pub use`导出,导入时也常见`use crate::net::socket::*`的写法,
//! 敬请注意。
use core::{
fmt::{self, Debug},
sync::atomic::AtomicUsize,
};
use alloc::{collections::BTreeMap, sync::Arc};
use crate::{driver::net::Iface, libs::rwlock::RwLock};
pub mod event_poll;
pub mod net_core;
pub mod socket;
pub mod syscall;
pub mod syscall_util;
lazy_static! {
/// # 所有网络接口的列表
/// 这个列表在中断上下文会使用到因此需要irqsave
pub static ref NET_DEVICES: RwLock<BTreeMap<usize, Arc<dyn Iface>>> = RwLock::new(BTreeMap::new());
}
/// 生成网络接口的id (全局自增)
pub fn generate_iface_id() -> usize {
static IFACE_ID: AtomicUsize = AtomicUsize::new(0);
return IFACE_ID.fetch_add(1, core::sync::atomic::Ordering::SeqCst);
}