net_device 結構分析


在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

}
太大了,不解了,用到時再分析。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章