xref: /DragonOS/kernel/src/driver/net/sysfs.rs (revision 28fe4ad2a0b0d8b5abf1f0cb402b1c3204b42242)
1*28fe4ad2S黄铭涛 use crate::{
2*28fe4ad2S黄铭涛     driver::base::{
3*28fe4ad2S黄铭涛         class::Class,
4*28fe4ad2S黄铭涛         device::{device_manager, Device},
5*28fe4ad2S黄铭涛         kobject::KObject,
6*28fe4ad2S黄铭涛     },
7*28fe4ad2S黄铭涛     filesystem::{
8*28fe4ad2S黄铭涛         sysfs::{
9*28fe4ad2S黄铭涛             file::sysfs_emit_str, Attribute, AttributeGroup, SysFSOpsSupport, SYSFS_ATTR_MODE_RO,
10*28fe4ad2S黄铭涛             SYSFS_ATTR_MODE_RW,
11*28fe4ad2S黄铭涛         },
12*28fe4ad2S黄铭涛         vfs::syscall::ModeType,
13*28fe4ad2S黄铭涛     },
14*28fe4ad2S黄铭涛 };
15*28fe4ad2S黄铭涛 use alloc::sync::Arc;
16*28fe4ad2S黄铭涛 use intertrait::cast::CastArc;
17*28fe4ad2S黄铭涛 use log::error;
18*28fe4ad2S黄铭涛 use system_error::SystemError;
19*28fe4ad2S黄铭涛 
20*28fe4ad2S黄铭涛 use super::{class::sys_class_net_instance, NetDeivceState, NetDevice, Operstate};
21*28fe4ad2S黄铭涛 
22*28fe4ad2S黄铭涛 /// 将设备注册到`/sys/class/net`目录下
23*28fe4ad2S黄铭涛 /// 参考:https://code.dragonos.org.cn/xref/linux-2.6.39/net/core/net-sysfs.c?fi=netdev_register_kobject#1311
netdev_register_kobject(dev: Arc<dyn NetDevice>) -> Result<(), SystemError>24*28fe4ad2S黄铭涛 pub fn netdev_register_kobject(dev: Arc<dyn NetDevice>) -> Result<(), SystemError> {
25*28fe4ad2S黄铭涛     // 初始化设备
26*28fe4ad2S黄铭涛     device_manager().device_default_initialize(&(dev.clone() as Arc<dyn Device>));
27*28fe4ad2S黄铭涛 
28*28fe4ad2S黄铭涛     // 设置dev的class为net
29*28fe4ad2S黄铭涛     dev.set_class(Some(Arc::downgrade(
30*28fe4ad2S黄铭涛         &(sys_class_net_instance().cloned().unwrap() as Arc<dyn Class>),
31*28fe4ad2S黄铭涛     )));
32*28fe4ad2S黄铭涛 
33*28fe4ad2S黄铭涛     // 设置设备的kobject名
34*28fe4ad2S黄铭涛     dev.set_name(dev.iface_name().clone());
35*28fe4ad2S黄铭涛 
36*28fe4ad2S黄铭涛     device_manager().add_device(dev.clone() as Arc<dyn Device>)?;
37*28fe4ad2S黄铭涛 
38*28fe4ad2S黄铭涛     return Ok(());
39*28fe4ad2S黄铭涛 }
40*28fe4ad2S黄铭涛 
41*28fe4ad2S黄铭涛 // 参考:https://code.dragonos.org.cn/xref/linux-6.6.21/net/core/net-sysfs.c
42*28fe4ad2S黄铭涛 #[derive(Debug)]
43*28fe4ad2S黄铭涛 pub struct NetAttrGroup;
44*28fe4ad2S黄铭涛 
45*28fe4ad2S黄铭涛 impl AttributeGroup for NetAttrGroup {
name(&self) -> Option<&str>46*28fe4ad2S黄铭涛     fn name(&self) -> Option<&str> {
47*28fe4ad2S黄铭涛         None
48*28fe4ad2S黄铭涛     }
49*28fe4ad2S黄铭涛 
attrs(&self) -> &[&'static dyn Attribute]50*28fe4ad2S黄铭涛     fn attrs(&self) -> &[&'static dyn Attribute] {
51*28fe4ad2S黄铭涛         &[
52*28fe4ad2S黄铭涛             &AttrAddrAssignType,
53*28fe4ad2S黄铭涛             &AttrAddrLen,
54*28fe4ad2S黄铭涛             &AttrDevId,
55*28fe4ad2S黄铭涛             &AttrIfalias,
56*28fe4ad2S黄铭涛             &AttrIflink,
57*28fe4ad2S黄铭涛             &AttrIfindex,
58*28fe4ad2S黄铭涛             &AttrFeatrues,
59*28fe4ad2S黄铭涛             &AttrType,
60*28fe4ad2S黄铭涛             &AttrLinkMode,
61*28fe4ad2S黄铭涛             &AttrAddress,
62*28fe4ad2S黄铭涛             &AttrBroadcast,
63*28fe4ad2S黄铭涛             &AttrCarrier,
64*28fe4ad2S黄铭涛             &AttrSpeed,
65*28fe4ad2S黄铭涛             &AttrDuplex,
66*28fe4ad2S黄铭涛             &AttrDormant,
67*28fe4ad2S黄铭涛             &AttrOperstate,
68*28fe4ad2S黄铭涛             &AttrMtu,
69*28fe4ad2S黄铭涛             &AttrFlags,
70*28fe4ad2S黄铭涛             &AttrTxQueueLen,
71*28fe4ad2S黄铭涛             &AttrNetdevGroup,
72*28fe4ad2S黄铭涛         ]
73*28fe4ad2S黄铭涛     }
74*28fe4ad2S黄铭涛 
is_visible( &self, _kobj: Arc<dyn KObject>, attr: &'static dyn Attribute, ) -> Option<ModeType>75*28fe4ad2S黄铭涛     fn is_visible(
76*28fe4ad2S黄铭涛         &self,
77*28fe4ad2S黄铭涛         _kobj: Arc<dyn KObject>,
78*28fe4ad2S黄铭涛         attr: &'static dyn Attribute,
79*28fe4ad2S黄铭涛     ) -> Option<ModeType> {
80*28fe4ad2S黄铭涛         return Some(attr.mode());
81*28fe4ad2S黄铭涛     }
82*28fe4ad2S黄铭涛 }
83*28fe4ad2S黄铭涛 
84*28fe4ad2S黄铭涛 /// # 表示网络接口的MAC地址是如何分配的
85*28fe4ad2S黄铭涛 /// - 0(NET_ADDR_PERM): 永久的MAC地址(默认值)
86*28fe4ad2S黄铭涛 /// - 1(NET_ADDR_RANDOM): 随机生成的MAC地址
87*28fe4ad2S黄铭涛 /// - 2(NET_ADDR_STOLEN): 从其他设备中获取的MAC地址
88*28fe4ad2S黄铭涛 /// - 3(NET_ADDR_SET): 由用户设置的MAC地址
89*28fe4ad2S黄铭涛 #[derive(Debug)]
90*28fe4ad2S黄铭涛 struct AttrAddrAssignType;
91*28fe4ad2S黄铭涛 
92*28fe4ad2S黄铭涛 impl Attribute for AttrAddrAssignType {
name(&self) -> &str93*28fe4ad2S黄铭涛     fn name(&self) -> &str {
94*28fe4ad2S黄铭涛         "addr_assign_type"
95*28fe4ad2S黄铭涛     }
96*28fe4ad2S黄铭涛 
mode(&self) -> ModeType97*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
98*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
99*28fe4ad2S黄铭涛     }
100*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport101*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
102*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
103*28fe4ad2S黄铭涛     }
104*28fe4ad2S黄铭涛 
show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError>105*28fe4ad2S黄铭涛     fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
106*28fe4ad2S黄铭涛         let net_device = kobj.cast::<dyn NetDevice>().map_err(|_| {
107*28fe4ad2S黄铭涛             error!("AttrAddrAssignType::show() failed: kobj is not a NetDevice");
108*28fe4ad2S黄铭涛             SystemError::EINVAL
109*28fe4ad2S黄铭涛         })?;
110*28fe4ad2S黄铭涛         let addr_assign_type = net_device.addr_assign_type();
111*28fe4ad2S黄铭涛         sysfs_emit_str(buf, &format!("{}\n", addr_assign_type))
112*28fe4ad2S黄铭涛     }
113*28fe4ad2S黄铭涛 }
114*28fe4ad2S黄铭涛 
115*28fe4ad2S黄铭涛 /// # 表示网络接口的MAC地址的长度,以字节为单位
116*28fe4ad2S黄铭涛 #[derive(Debug)]
117*28fe4ad2S黄铭涛 struct AttrAddrLen;
118*28fe4ad2S黄铭涛 
119*28fe4ad2S黄铭涛 impl Attribute for AttrAddrLen {
name(&self) -> &str120*28fe4ad2S黄铭涛     fn name(&self) -> &str {
121*28fe4ad2S黄铭涛         "addr_len"
122*28fe4ad2S黄铭涛     }
123*28fe4ad2S黄铭涛 
mode(&self) -> ModeType124*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
125*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
126*28fe4ad2S黄铭涛     }
127*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport128*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
129*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
130*28fe4ad2S黄铭涛     }
131*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>132*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
133*28fe4ad2S黄铭涛         todo!("AttrAddrLen::show")
134*28fe4ad2S黄铭涛     }
135*28fe4ad2S黄铭涛 }
136*28fe4ad2S黄铭涛 
137*28fe4ad2S黄铭涛 /// # 表示网络接口的设备ID,是一个十六进制数
138*28fe4ad2S黄铭涛 #[derive(Debug)]
139*28fe4ad2S黄铭涛 struct AttrDevId;
140*28fe4ad2S黄铭涛 
141*28fe4ad2S黄铭涛 impl Attribute for AttrDevId {
name(&self) -> &str142*28fe4ad2S黄铭涛     fn name(&self) -> &str {
143*28fe4ad2S黄铭涛         "dev_id"
144*28fe4ad2S黄铭涛     }
145*28fe4ad2S黄铭涛 
mode(&self) -> ModeType146*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
147*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
148*28fe4ad2S黄铭涛     }
149*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport150*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
151*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
152*28fe4ad2S黄铭涛     }
153*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>154*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
155*28fe4ad2S黄铭涛         todo!("AttrDevId::show")
156*28fe4ad2S黄铭涛     }
157*28fe4ad2S黄铭涛 }
158*28fe4ad2S黄铭涛 
159*28fe4ad2S黄铭涛 /// # 表示网络接口的别名,可以设置
160*28fe4ad2S黄铭涛 #[derive(Debug)]
161*28fe4ad2S黄铭涛 struct AttrIfalias;
162*28fe4ad2S黄铭涛 
163*28fe4ad2S黄铭涛 impl Attribute for AttrIfalias {
name(&self) -> &str164*28fe4ad2S黄铭涛     fn name(&self) -> &str {
165*28fe4ad2S黄铭涛         "ifalias"
166*28fe4ad2S黄铭涛     }
167*28fe4ad2S黄铭涛 
mode(&self) -> ModeType168*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
169*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RW
170*28fe4ad2S黄铭涛     }
171*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport172*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
173*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW | SysFSOpsSupport::ATTR_STORE
174*28fe4ad2S黄铭涛     }
175*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>176*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
177*28fe4ad2S黄铭涛         todo!("AttrIfalias::show")
178*28fe4ad2S黄铭涛     }
179*28fe4ad2S黄铭涛 
store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError>180*28fe4ad2S黄铭涛     fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> {
181*28fe4ad2S黄铭涛         todo!("AttrIfalias::store")
182*28fe4ad2S黄铭涛     }
183*28fe4ad2S黄铭涛 }
184*28fe4ad2S黄铭涛 
185*28fe4ad2S黄铭涛 /// # 表示网络接口的链路索引,用于表示网络接口在系统中的位置
186*28fe4ad2S黄铭涛 #[derive(Debug)]
187*28fe4ad2S黄铭涛 struct AttrIflink;
188*28fe4ad2S黄铭涛 
189*28fe4ad2S黄铭涛 impl Attribute for AttrIflink {
name(&self) -> &str190*28fe4ad2S黄铭涛     fn name(&self) -> &str {
191*28fe4ad2S黄铭涛         "iflink"
192*28fe4ad2S黄铭涛     }
193*28fe4ad2S黄铭涛 
mode(&self) -> ModeType194*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
195*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
196*28fe4ad2S黄铭涛     }
197*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport198*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
199*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
200*28fe4ad2S黄铭涛     }
201*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>202*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
203*28fe4ad2S黄铭涛         todo!("AttrIflink::show")
204*28fe4ad2S黄铭涛     }
205*28fe4ad2S黄铭涛 }
206*28fe4ad2S黄铭涛 
207*28fe4ad2S黄铭涛 /// # 标识网络接口的索引
208*28fe4ad2S黄铭涛 #[derive(Debug)]
209*28fe4ad2S黄铭涛 struct AttrIfindex;
210*28fe4ad2S黄铭涛 
211*28fe4ad2S黄铭涛 impl Attribute for AttrIfindex {
name(&self) -> &str212*28fe4ad2S黄铭涛     fn name(&self) -> &str {
213*28fe4ad2S黄铭涛         "ifindex"
214*28fe4ad2S黄铭涛     }
215*28fe4ad2S黄铭涛 
mode(&self) -> ModeType216*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
217*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
218*28fe4ad2S黄铭涛     }
219*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport220*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
221*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
222*28fe4ad2S黄铭涛     }
223*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>224*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
225*28fe4ad2S黄铭涛         todo!("AttrIfindex::show")
226*28fe4ad2S黄铭涛     }
227*28fe4ad2S黄铭涛 }
228*28fe4ad2S黄铭涛 
229*28fe4ad2S黄铭涛 /// # 用于显示网络接口支持的特性,这些特性通常由网络驱动程序和硬件能力决定
230*28fe4ad2S黄铭涛 #[derive(Debug)]
231*28fe4ad2S黄铭涛 struct AttrFeatrues;
232*28fe4ad2S黄铭涛 
233*28fe4ad2S黄铭涛 impl Attribute for AttrFeatrues {
name(&self) -> &str234*28fe4ad2S黄铭涛     fn name(&self) -> &str {
235*28fe4ad2S黄铭涛         "features"
236*28fe4ad2S黄铭涛     }
237*28fe4ad2S黄铭涛 
mode(&self) -> ModeType238*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
239*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
240*28fe4ad2S黄铭涛     }
241*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport242*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
243*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
244*28fe4ad2S黄铭涛     }
245*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>246*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
247*28fe4ad2S黄铭涛         todo!("AttrFeatrues::show")
248*28fe4ad2S黄铭涛     }
249*28fe4ad2S黄铭涛 }
250*28fe4ad2S黄铭涛 
251*28fe4ad2S黄铭涛 /// # 用于表示网络接口的类型
252*28fe4ad2S黄铭涛 /// - 1:ARPHRD_ETHER 以太网接口
253*28fe4ad2S黄铭涛 /// - 24:ARPHRD_LOOPBACK 回环接口
254*28fe4ad2S黄铭涛 /// - 512:ARPHRD_IEEE80211_RADIOTAP IEEE 802.11 无线接口
255*28fe4ad2S黄铭涛 /// - 768:ARPHRD_IEEE802154 IEEE 802.15.4 无线接口
256*28fe4ad2S黄铭涛 /// - 769:ARPHRD_6LOWPAN 6LoWPAN接口
257*28fe4ad2S黄铭涛 #[derive(Debug)]
258*28fe4ad2S黄铭涛 struct AttrType;
259*28fe4ad2S黄铭涛 
260*28fe4ad2S黄铭涛 impl Attribute for AttrType {
name(&self) -> &str261*28fe4ad2S黄铭涛     fn name(&self) -> &str {
262*28fe4ad2S黄铭涛         "type"
263*28fe4ad2S黄铭涛     }
264*28fe4ad2S黄铭涛 
mode(&self) -> ModeType265*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
266*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
267*28fe4ad2S黄铭涛     }
268*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport269*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
270*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
271*28fe4ad2S黄铭涛     }
272*28fe4ad2S黄铭涛 
show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError>273*28fe4ad2S黄铭涛     fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
274*28fe4ad2S黄铭涛         let net_deive = kobj.cast::<dyn NetDevice>().map_err(|_| {
275*28fe4ad2S黄铭涛             error!("AttrType::show() failed: kobj is not a NetDevice");
276*28fe4ad2S黄铭涛             SystemError::EINVAL
277*28fe4ad2S黄铭涛         })?;
278*28fe4ad2S黄铭涛         let net_type = net_deive.net_device_type();
279*28fe4ad2S黄铭涛         sysfs_emit_str(buf, &format!("{}\n", net_type))
280*28fe4ad2S黄铭涛     }
281*28fe4ad2S黄铭涛 }
282*28fe4ad2S黄铭涛 
283*28fe4ad2S黄铭涛 /// # 表示网络接口的链路模式,用于指示网络接口是否处于自动协商模式
284*28fe4ad2S黄铭涛 /// - 0:表示网络接口处于自动协商模式
285*28fe4ad2S黄铭涛 /// - 1:表示网络接口处于强制模式,即链路参数(如速度和双工模式)是手动配置的,而不是通过自动协商确定的
286*28fe4ad2S黄铭涛 #[derive(Debug)]
287*28fe4ad2S黄铭涛 struct AttrLinkMode;
288*28fe4ad2S黄铭涛 
289*28fe4ad2S黄铭涛 impl Attribute for AttrLinkMode {
name(&self) -> &str290*28fe4ad2S黄铭涛     fn name(&self) -> &str {
291*28fe4ad2S黄铭涛         "link_mode"
292*28fe4ad2S黄铭涛     }
293*28fe4ad2S黄铭涛 
mode(&self) -> ModeType294*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
295*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
296*28fe4ad2S黄铭涛     }
297*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport298*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
299*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
300*28fe4ad2S黄铭涛     }
301*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>302*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
303*28fe4ad2S黄铭涛         todo!("AttrLinkMode::show")
304*28fe4ad2S黄铭涛     }
305*28fe4ad2S黄铭涛 }
306*28fe4ad2S黄铭涛 
307*28fe4ad2S黄铭涛 /// # 表示网络接口的MAC地址
308*28fe4ad2S黄铭涛 #[derive(Debug)]
309*28fe4ad2S黄铭涛 struct AttrAddress;
310*28fe4ad2S黄铭涛 
311*28fe4ad2S黄铭涛 impl Attribute for AttrAddress {
name(&self) -> &str312*28fe4ad2S黄铭涛     fn name(&self) -> &str {
313*28fe4ad2S黄铭涛         "address"
314*28fe4ad2S黄铭涛     }
315*28fe4ad2S黄铭涛 
mode(&self) -> ModeType316*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
317*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
318*28fe4ad2S黄铭涛     }
319*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport320*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
321*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
322*28fe4ad2S黄铭涛     }
323*28fe4ad2S黄铭涛 
show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError>324*28fe4ad2S黄铭涛     fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
325*28fe4ad2S黄铭涛         let net_device = kobj.cast::<dyn NetDevice>().map_err(|_| {
326*28fe4ad2S黄铭涛             error!("AttrAddress::show() failed: kobj is not a NetDevice");
327*28fe4ad2S黄铭涛             SystemError::EINVAL
328*28fe4ad2S黄铭涛         })?;
329*28fe4ad2S黄铭涛         let mac_addr = net_device.mac();
330*28fe4ad2S黄铭涛         sysfs_emit_str(buf, &format!("{}\n", mac_addr))
331*28fe4ad2S黄铭涛     }
332*28fe4ad2S黄铭涛 }
333*28fe4ad2S黄铭涛 
334*28fe4ad2S黄铭涛 /// # 表示网络接口的广播地址
335*28fe4ad2S黄铭涛 #[derive(Debug)]
336*28fe4ad2S黄铭涛 struct AttrBroadcast;
337*28fe4ad2S黄铭涛 
338*28fe4ad2S黄铭涛 impl Attribute for AttrBroadcast {
name(&self) -> &str339*28fe4ad2S黄铭涛     fn name(&self) -> &str {
340*28fe4ad2S黄铭涛         "broadcast"
341*28fe4ad2S黄铭涛     }
342*28fe4ad2S黄铭涛 
mode(&self) -> ModeType343*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
344*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
345*28fe4ad2S黄铭涛     }
346*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport347*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
348*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
349*28fe4ad2S黄铭涛     }
350*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>351*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
352*28fe4ad2S黄铭涛         todo!("AttrBroadcast::show")
353*28fe4ad2S黄铭涛     }
354*28fe4ad2S黄铭涛 }
355*28fe4ad2S黄铭涛 
356*28fe4ad2S黄铭涛 /// # 表示网络接口的物理链路状态
357*28fe4ad2S黄铭涛 /// - 0:表示网络接口处于关闭状态
358*28fe4ad2S黄铭涛 /// - 1:表示网络接口处于打开状态
359*28fe4ad2S黄铭涛 #[derive(Debug)]
360*28fe4ad2S黄铭涛 struct AttrCarrier;
361*28fe4ad2S黄铭涛 
362*28fe4ad2S黄铭涛 impl Attribute for AttrCarrier {
name(&self) -> &str363*28fe4ad2S黄铭涛     fn name(&self) -> &str {
364*28fe4ad2S黄铭涛         "carrier"
365*28fe4ad2S黄铭涛     }
366*28fe4ad2S黄铭涛 
mode(&self) -> ModeType367*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
368*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
369*28fe4ad2S黄铭涛     }
370*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport371*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
372*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
373*28fe4ad2S黄铭涛     }
374*28fe4ad2S黄铭涛 
show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError>375*28fe4ad2S黄铭涛     fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> {
376*28fe4ad2S黄铭涛         let net_device = kobj.cast::<dyn NetDevice>().map_err(|_| {
377*28fe4ad2S黄铭涛             error!("AttrCarrier::show() failed: kobj is not a NetDevice");
378*28fe4ad2S黄铭涛             SystemError::EINVAL
379*28fe4ad2S黄铭涛         })?;
380*28fe4ad2S黄铭涛         if net_device
381*28fe4ad2S黄铭涛             .net_state()
382*28fe4ad2S黄铭涛             .contains(NetDeivceState::__LINK_STATE_START)
383*28fe4ad2S黄铭涛             && !net_device
384*28fe4ad2S黄铭涛                 .net_state()
385*28fe4ad2S黄铭涛                 .contains(NetDeivceState::__LINK_STATE_NOCARRIER)
386*28fe4ad2S黄铭涛         {
387*28fe4ad2S黄铭涛             sysfs_emit_str(buf, "1\n")
388*28fe4ad2S黄铭涛         } else {
389*28fe4ad2S黄铭涛             sysfs_emit_str(buf, "0\n")
390*28fe4ad2S黄铭涛         }
391*28fe4ad2S黄铭涛     }
392*28fe4ad2S黄铭涛 }
393*28fe4ad2S黄铭涛 
394*28fe4ad2S黄铭涛 /// # 表示网络接口的当前连接速度,单位为Mbps
395*28fe4ad2S黄铭涛 /// - 特殊值:-1,表示无法确定,通常是因为接口不支持查询速度或接口未连接
396*28fe4ad2S黄铭涛 #[derive(Debug)]
397*28fe4ad2S黄铭涛 struct AttrSpeed;
398*28fe4ad2S黄铭涛 
399*28fe4ad2S黄铭涛 impl Attribute for AttrSpeed {
name(&self) -> &str400*28fe4ad2S黄铭涛     fn name(&self) -> &str {
401*28fe4ad2S黄铭涛         "speed"
402*28fe4ad2S黄铭涛     }
403*28fe4ad2S黄铭涛 
mode(&self) -> ModeType404*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
405*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
406*28fe4ad2S黄铭涛     }
407*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport408*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
409*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
410*28fe4ad2S黄铭涛     }
411*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>412*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
413*28fe4ad2S黄铭涛         todo!("AttrSpeed::show")
414*28fe4ad2S黄铭涛     }
415*28fe4ad2S黄铭涛 }
416*28fe4ad2S黄铭涛 
417*28fe4ad2S黄铭涛 /// # 表示网络接口的双工模式
418*28fe4ad2S黄铭涛 /// - half:半双工,网络接口不能同时发送和接收数据
419*28fe4ad2S黄铭涛 /// - full:全双工,网络接口可以同时发送和接收数据
420*28fe4ad2S黄铭涛 /// - unknown:未知,通常表示接口未连接或无法确定双工模式
421*28fe4ad2S黄铭涛 #[derive(Debug)]
422*28fe4ad2S黄铭涛 struct AttrDuplex;
423*28fe4ad2S黄铭涛 
424*28fe4ad2S黄铭涛 impl Attribute for AttrDuplex {
name(&self) -> &str425*28fe4ad2S黄铭涛     fn name(&self) -> &str {
426*28fe4ad2S黄铭涛         "duplex"
427*28fe4ad2S黄铭涛     }
428*28fe4ad2S黄铭涛 
mode(&self) -> ModeType429*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
430*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
431*28fe4ad2S黄铭涛     }
432*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport433*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
434*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
435*28fe4ad2S黄铭涛     }
436*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>437*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
438*28fe4ad2S黄铭涛         todo!("AttrDuplex::show")
439*28fe4ad2S黄铭涛     }
440*28fe4ad2S黄铭涛 }
441*28fe4ad2S黄铭涛 
442*28fe4ad2S黄铭涛 /// 表示网络接口是否处于休眠状态
443*28fe4ad2S黄铭涛 /// - 0:表示网络接口未处于休眠状态
444*28fe4ad2S黄铭涛 /// - 1:表示网络接口处于休眠状态
445*28fe4ad2S黄铭涛 #[derive(Debug)]
446*28fe4ad2S黄铭涛 struct AttrDormant;
447*28fe4ad2S黄铭涛 
448*28fe4ad2S黄铭涛 impl Attribute for AttrDormant {
name(&self) -> &str449*28fe4ad2S黄铭涛     fn name(&self) -> &str {
450*28fe4ad2S黄铭涛         "dormant"
451*28fe4ad2S黄铭涛     }
452*28fe4ad2S黄铭涛 
mode(&self) -> ModeType453*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
454*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
455*28fe4ad2S黄铭涛     }
456*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport457*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
458*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
459*28fe4ad2S黄铭涛     }
460*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>461*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
462*28fe4ad2S黄铭涛         todo!("AttrDormant::show")
463*28fe4ad2S黄铭涛     }
464*28fe4ad2S黄铭涛 }
465*28fe4ad2S黄铭涛 
466*28fe4ad2S黄铭涛 /// # 表示网络接口的操作状态
467*28fe4ad2S黄铭涛 /// - up:网络接口已启用并且正在运行
468*28fe4ad2S黄铭涛 /// - down:网络接口已禁用或未连接
469*28fe4ad2S黄铭涛 /// - dormant:网络接口处于休眠状态,等待某些条件满足后激活
470*28fe4ad2S黄铭涛 /// - testing:网络接口正在测试中
471*28fe4ad2S黄铭涛 /// - unknown:网络接口的状态未知
472*28fe4ad2S黄铭涛 /// - notpresent:网络接口硬件不存在
473*28fe4ad2S黄铭涛 /// - lowerlayerdown:网络接口的底层设备未启用
474*28fe4ad2S黄铭涛 /// - inactive:网络接口未激活
475*28fe4ad2S黄铭涛 #[derive(Debug)]
476*28fe4ad2S黄铭涛 struct AttrOperstate;
477*28fe4ad2S黄铭涛 
478*28fe4ad2S黄铭涛 impl Attribute for AttrOperstate {
name(&self) -> &str479*28fe4ad2S黄铭涛     fn name(&self) -> &str {
480*28fe4ad2S黄铭涛         "operstate"
481*28fe4ad2S黄铭涛     }
482*28fe4ad2S黄铭涛 
mode(&self) -> ModeType483*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
484*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
485*28fe4ad2S黄铭涛     }
486*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport487*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
488*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
489*28fe4ad2S黄铭涛     }
490*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>491*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
492*28fe4ad2S黄铭涛         let net_device = _kobj.cast::<dyn NetDevice>().map_err(|_| {
493*28fe4ad2S黄铭涛             error!("AttrOperstate::show() failed: kobj is not a NetDevice");
494*28fe4ad2S黄铭涛             SystemError::EINVAL
495*28fe4ad2S黄铭涛         })?;
496*28fe4ad2S黄铭涛         if !net_device
497*28fe4ad2S黄铭涛             .net_state()
498*28fe4ad2S黄铭涛             .contains(NetDeivceState::__LINK_STATE_START)
499*28fe4ad2S黄铭涛         {
500*28fe4ad2S黄铭涛             net_device.set_operstate(Operstate::IF_OPER_DOWN);
501*28fe4ad2S黄铭涛         }
502*28fe4ad2S黄铭涛 
503*28fe4ad2S黄铭涛         let operstate_str = match net_device.operstate() {
504*28fe4ad2S黄铭涛             Operstate::IF_OPER_UP => "up",
505*28fe4ad2S黄铭涛             Operstate::IF_OPER_DOWN => "down",
506*28fe4ad2S黄铭涛             Operstate::IF_OPER_DORMANT => "dormant",
507*28fe4ad2S黄铭涛             Operstate::IF_OPER_TESTING => "testing",
508*28fe4ad2S黄铭涛             Operstate::IF_OPER_UNKNOWN => "unknown",
509*28fe4ad2S黄铭涛             Operstate::IF_OPER_NOTPRESENT => "notpresent",
510*28fe4ad2S黄铭涛             Operstate::IF_OPER_LOWERLAYERDOWN => "lowerlayerdown",
511*28fe4ad2S黄铭涛         };
512*28fe4ad2S黄铭涛 
513*28fe4ad2S黄铭涛         sysfs_emit_str(_buf, &format!("{}\n", operstate_str))
514*28fe4ad2S黄铭涛     }
515*28fe4ad2S黄铭涛 }
516*28fe4ad2S黄铭涛 
517*28fe4ad2S黄铭涛 /// # 表示网络接口的最大传输单元
518*28fe4ad2S黄铭涛 #[derive(Debug)]
519*28fe4ad2S黄铭涛 struct AttrMtu;
520*28fe4ad2S黄铭涛 
521*28fe4ad2S黄铭涛 impl Attribute for AttrMtu {
name(&self) -> &str522*28fe4ad2S黄铭涛     fn name(&self) -> &str {
523*28fe4ad2S黄铭涛         "mtu"
524*28fe4ad2S黄铭涛     }
525*28fe4ad2S黄铭涛 
mode(&self) -> ModeType526*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
527*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
528*28fe4ad2S黄铭涛     }
529*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport530*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
531*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
532*28fe4ad2S黄铭涛     }
533*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>534*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
535*28fe4ad2S黄铭涛         todo!("AttrMtu::show")
536*28fe4ad2S黄铭涛     }
537*28fe4ad2S黄铭涛 
store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError>538*28fe4ad2S黄铭涛     fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> {
539*28fe4ad2S黄铭涛         todo!("AttrMtu::store")
540*28fe4ad2S黄铭涛     }
541*28fe4ad2S黄铭涛 }
542*28fe4ad2S黄铭涛 
543*28fe4ad2S黄铭涛 /// # 表示网络接口的标志,这些标志提供了关于网络接口状态和配置的详细信息
544*28fe4ad2S黄铭涛 /// - IFF_UP(0x1):接口已启用
545*28fe4ad2S黄铭涛 /// - IFF_BROADCAST(0x2):支持广播
546*28fe4ad2S黄铭涛 /// - IFF_DEBUG(0x4):调试模式
547*28fe4ad2S黄铭涛 /// - IFF_LOOPBACK(0x8):环回接口
548*28fe4ad2S黄铭涛 /// - IFF_POINTOPOINT(0x10):点对点链路
549*28fe4ad2S黄铭涛 /// - IFF_NOTRAILERS(0x20):禁用拖尾
550*28fe4ad2S黄铭涛 /// - IFF_RUNNING(0x40):资源已分配
551*28fe4ad2S黄铭涛 /// - IFF_NOARP(0x80):无ARP协议
552*28fe4ad2S黄铭涛 /// - IFF_PROMISC(0x100):混杂模式
553*28fe4ad2S黄铭涛 /// - IFF_ALLMULTI(0x200):接收所有多播放数据包
554*28fe4ad2S黄铭涛 /// - IFF_ MASTER(0x400):主设备
555*28fe4ad2S黄铭涛 /// - IFF_SLAVE(0x800):从设备
556*28fe4ad2S黄铭涛 /// - IFF_MULTICAST(0x1000):支持多播
557*28fe4ad2S黄铭涛 /// - IFF_PORTSEL(0x2000):可以选择媒体类型
558*28fe4ad2S黄铭涛 /// - IFF_AUTOMEDIA(0x4000):自动选择媒体类型
559*28fe4ad2S黄铭涛 /// - IFF_DYNAMIC(0x8000):动态接口
560*28fe4ad2S黄铭涛 #[derive(Debug)]
561*28fe4ad2S黄铭涛 struct AttrFlags;
562*28fe4ad2S黄铭涛 
563*28fe4ad2S黄铭涛 impl Attribute for AttrFlags {
name(&self) -> &str564*28fe4ad2S黄铭涛     fn name(&self) -> &str {
565*28fe4ad2S黄铭涛         "flags"
566*28fe4ad2S黄铭涛     }
567*28fe4ad2S黄铭涛 
mode(&self) -> ModeType568*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
569*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
570*28fe4ad2S黄铭涛     }
571*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport572*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
573*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
574*28fe4ad2S黄铭涛     }
575*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>576*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
577*28fe4ad2S黄铭涛         todo!("AttrFlags::show")
578*28fe4ad2S黄铭涛     }
579*28fe4ad2S黄铭涛 
store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError>580*28fe4ad2S黄铭涛     fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> {
581*28fe4ad2S黄铭涛         todo!("AttrFlags::store")
582*28fe4ad2S黄铭涛     }
583*28fe4ad2S黄铭涛 }
584*28fe4ad2S黄铭涛 
585*28fe4ad2S黄铭涛 /// # 表示网络接口的传输队列长度
586*28fe4ad2S黄铭涛 #[derive(Debug)]
587*28fe4ad2S黄铭涛 struct AttrTxQueueLen;
588*28fe4ad2S黄铭涛 
589*28fe4ad2S黄铭涛 impl Attribute for AttrTxQueueLen {
name(&self) -> &str590*28fe4ad2S黄铭涛     fn name(&self) -> &str {
591*28fe4ad2S黄铭涛         "tx_queue_len"
592*28fe4ad2S黄铭涛     }
593*28fe4ad2S黄铭涛 
mode(&self) -> ModeType594*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
595*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
596*28fe4ad2S黄铭涛     }
597*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport598*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
599*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
600*28fe4ad2S黄铭涛     }
601*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>602*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
603*28fe4ad2S黄铭涛         todo!("AttrTxQueueLen::show")
604*28fe4ad2S黄铭涛     }
605*28fe4ad2S黄铭涛 
store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError>606*28fe4ad2S黄铭涛     fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> {
607*28fe4ad2S黄铭涛         todo!("AttrTxQueueLen::store")
608*28fe4ad2S黄铭涛     }
609*28fe4ad2S黄铭涛 }
610*28fe4ad2S黄铭涛 
611*28fe4ad2S黄铭涛 /// # 表示网络设备所属的设备组
612*28fe4ad2S黄铭涛 #[derive(Debug)]
613*28fe4ad2S黄铭涛 struct AttrNetdevGroup;
614*28fe4ad2S黄铭涛 
615*28fe4ad2S黄铭涛 impl Attribute for AttrNetdevGroup {
name(&self) -> &str616*28fe4ad2S黄铭涛     fn name(&self) -> &str {
617*28fe4ad2S黄铭涛         "netdev_group"
618*28fe4ad2S黄铭涛     }
619*28fe4ad2S黄铭涛 
mode(&self) -> ModeType620*28fe4ad2S黄铭涛     fn mode(&self) -> ModeType {
621*28fe4ad2S黄铭涛         SYSFS_ATTR_MODE_RO
622*28fe4ad2S黄铭涛     }
623*28fe4ad2S黄铭涛 
support(&self) -> SysFSOpsSupport624*28fe4ad2S黄铭涛     fn support(&self) -> SysFSOpsSupport {
625*28fe4ad2S黄铭涛         SysFSOpsSupport::ATTR_SHOW
626*28fe4ad2S黄铭涛     }
627*28fe4ad2S黄铭涛 
show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError>628*28fe4ad2S黄铭涛     fn show(&self, _kobj: Arc<dyn KObject>, _buf: &mut [u8]) -> Result<usize, SystemError> {
629*28fe4ad2S黄铭涛         todo!("AttrNetdevGroup::show")
630*28fe4ad2S黄铭涛     }
631*28fe4ad2S黄铭涛 
store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError>632*28fe4ad2S黄铭涛     fn store(&self, _kobj: Arc<dyn KObject>, _buf: &[u8]) -> Result<usize, SystemError> {
633*28fe4ad2S黄铭涛         todo!("AttrNetdevGroup::store")
634*28fe4ad2S黄铭涛     }
635*28fe4ad2S黄铭涛 }
636