在linux内核中采用一个net_struct的实例来表示一个网络设备,这其中包括了虚拟网络设备和实际网络设备。该数据结构比较复杂,主要任务分为两部分:第一对上层协议屏蔽底层设备的区别,提供统一的操作接口。第二对下层设备,提供实际驱动方法。
strcut net_device{
//通用区域
char name[]// 名字
struct hlist_node name_hlist; // 设备散列
cahr *ifalias //snmp 别名
state 状态
struct list_head dev_list,napi_list,unreg_list; //链表 ?
destructor
//硬件区域
unsigned long mem_end, mem_start
unsigned long base_addr
unsigned int irq
/*不常见的*/
unsigned char if_port //stores the media type of the network adapter currently used.For Ethernet ,BNC,TP,AUI.
unsigned char dma;
//网络层参数
void *atalk_ptr,*ip_ptr,*dn_ptr,*ipv6_ptr,*ec_ptr,*ax25_ptr
struct wireless_dev *ieee80211_ptr
//操作指针
const struct net_device_ops *netdev_ops
const struct ethtool_ops *ethtool_ops
const struct header_ops *ethtool_ops
}
太大了,不解了,用到时再分析。