系统中每个网络设备都用一个设备数据结构来表示。
[b]struct device
{[/b]
/*
* This is the first field of the "visible" part of this structure
* (i.e. as seen by users in the "Space.c" file). It is the name
* the interface.
*/
[b]char *name;[/b]
/* I/O specific fields */
[b]unsigned long rmem_end; [/b] /* shmem "recv" end */
[b]unsigned long rmem_start;[/b] /* shmem "recv" start */
[b]unsigned long mem_end;[/b] /* shared mem end */
[b]unsigned long mem_start;[/b] /* shared mem start */
[b]unsigned long base_addr;[/b] /* device I/O address */
[b]unsigned char irq;[/b] /* device IRQ number */
/* Low-level status flags. */
[b]volatile unsigned char start, [/b] /* start an operation */
[b]interrupt; [/b] /* interrupt arrived */
[b]unsigned long tbusy; [/b] /* transmitter busy */
[b]struct device *next;[/b]
/* The device initialization function. Called only once. */
[b] int (*init)(struct device *dev);[/b]
/* Some hardware also needs these fields, but they are not part of
the usual set specified in Space.c. */
[b]unsigned char if_port;[/b] /* Selectable AUI,TP, */
[b]unsigned char dma; [/b] /* DMA channel */
[b]struct enet_statistics* (*get_stats)(struct device *dev);[/b]
/*
* This marks the end of the "visible" part of the structure. All
* fields hereafter are internal to the system, and may change at
* will (read: may be cleaned up at will).
*/
/* These may be needed for future network-power-down code. */
[b]unsigned long trans_start;[/b] /* Time (jiffies) of
last transmit */
[b]unsigned long last_rx;[/b] /* Time of last Rx */
[b] unsigned short flags; [/b] /* interface flags (BSD)*/
[b]unsigned short family;[/b] /* address family ID */
[b]unsigned short metric;[/b] /* routing metric */
[b]unsigned short mtu;[/b] /* MTU value */
[b]unsigned short type;[/b] /* hardware type */
[b]unsigned short hard_header_len; [/b]/* hardware hdr len */
[b]void *priv;[/b] /* private data */
/* Interface address info. */
[b]unsigned char broadcast[MAX_ADDR_LEN];
unsigned char pad;
unsigned char dev_addr[MAX_ADDR_LEN]; [/b]
[b]unsigned char addr_len; [/b] /* hardware addr len */
[b]unsigned long pa_addr;[/b] /* protocol address */
[b]unsigned long pa_brdaddr; [/b] /* protocol broadcast addr*/
[b]unsigned long pa_dstaddr;[/b] /* protocol P-P other addr*/
[b]unsigned long pa_mask; [/b] /* protocol netmask */
[b]unsigned short pa_alen;[/b] /* protocol address len */
[b]struct dev_mc_list *mc_list; [/b] /* M'cast mac addrs */
[b]int mc_count;[/b] /* No installed mcasts */
[b]struct ip_mc_list *ip_mc_list; [/b] /* IP m'cast filter chain */
[b]__u32 tx_queue_len;[/b] /* Max frames per queue */
/* For load balancing driver pair support */
[b]unsigned long pkt_queue; [/b] /* Packets queued */
[b]struct device *slave;[/b] /* Slave device */
[b]struct net_alias_info *alias_info; [/b] /* main dev alias info */
[b]struct net_alias *my_alias;[/b] /* alias devs */
/* Pointer to the interface buffers. */
[b]struct sk_buff_head buffs[DEV_NUMBUFFS];[/b]
/* Pointers to interface service routines. */
[b]int (*open)(struct device *dev);
int (*stop)(struct device *dev);
int (*hard_start_xmit) (struct sk_buff *skb,
struct device *dev);
int (*hard_header) (struct sk_buff *skb,
struct device *dev,
unsigned short type,
void *daddr,
void *saddr,
unsigned len);
int (*rebuild_header)(void *eth,
struct device *dev,
unsigned long raddr,
struct sk_buff *skb);
void (*set_multicast_list)(struct device *dev);
int (*set_mac_address)(struct device *dev,
void *addr);
int (*do_ioctl)(struct device *dev,
struct ifreq *ifr,
int cmd);
int (*set_config)(struct device *dev,
struct ifmap *map);
void (*header_cache_bind)(struct hh_cache **hhp,
struct device *dev,
unsigned short htype,
__u32 daddr);
void (*header_cache_update)(struct hh_cache *hh,
struct device *dev,
unsigned char * haddr);
int (*change_mtu)(struct device *dev,
int new_mtu);
struct iw_statistics* (*get_wireless_stats)(struct device *dev);
};[/b]
[b]struct device
{[/b]
/*
* This is the first field of the "visible" part of this structure
* (i.e. as seen by users in the "Space.c" file). It is the name
* the interface.
*/
[b]char *name;[/b]
/* I/O specific fields */
[b]unsigned long rmem_end; [/b] /* shmem "recv" end */
[b]unsigned long rmem_start;[/b] /* shmem "recv" start */
[b]unsigned long mem_end;[/b] /* shared mem end */
[b]unsigned long mem_start;[/b] /* shared mem start */
[b]unsigned long base_addr;[/b] /* device I/O address */
[b]unsigned char irq;[/b] /* device IRQ number */
/* Low-level status flags. */
[b]volatile unsigned char start, [/b] /* start an operation */
[b]interrupt; [/b] /* interrupt arrived */
[b]unsigned long tbusy; [/b] /* transmitter busy */
[b]struct device *next;[/b]
/* The device initialization function. Called only once. */
[b] int (*init)(struct device *dev);[/b]
/* Some hardware also needs these fields, but they are not part of
the usual set specified in Space.c. */
[b]unsigned char if_port;[/b] /* Selectable AUI,TP, */
[b]unsigned char dma; [/b] /* DMA channel */
[b]struct enet_statistics* (*get_stats)(struct device *dev);[/b]
/*
* This marks the end of the "visible" part of the structure. All
* fields hereafter are internal to the system, and may change at
* will (read: may be cleaned up at will).
*/
/* These may be needed for future network-power-down code. */
[b]unsigned long trans_start;[/b] /* Time (jiffies) of
last transmit */
[b]unsigned long last_rx;[/b] /* Time of last Rx */
[b] unsigned short flags; [/b] /* interface flags (BSD)*/
[b]unsigned short family;[/b] /* address family ID */
[b]unsigned short metric;[/b] /* routing metric */
[b]unsigned short mtu;[/b] /* MTU value */
[b]unsigned short type;[/b] /* hardware type */
[b]unsigned short hard_header_len; [/b]/* hardware hdr len */
[b]void *priv;[/b] /* private data */
/* Interface address info. */
[b]unsigned char broadcast[MAX_ADDR_LEN];
unsigned char pad;
unsigned char dev_addr[MAX_ADDR_LEN]; [/b]
[b]unsigned char addr_len; [/b] /* hardware addr len */
[b]unsigned long pa_addr;[/b] /* protocol address */
[b]unsigned long pa_brdaddr; [/b] /* protocol broadcast addr*/
[b]unsigned long pa_dstaddr;[/b] /* protocol P-P other addr*/
[b]unsigned long pa_mask; [/b] /* protocol netmask */
[b]unsigned short pa_alen;[/b] /* protocol address len */
[b]struct dev_mc_list *mc_list; [/b] /* M'cast mac addrs */
[b]int mc_count;[/b] /* No installed mcasts */
[b]struct ip_mc_list *ip_mc_list; [/b] /* IP m'cast filter chain */
[b]__u32 tx_queue_len;[/b] /* Max frames per queue */
/* For load balancing driver pair support */
[b]unsigned long pkt_queue; [/b] /* Packets queued */
[b]struct device *slave;[/b] /* Slave device */
[b]struct net_alias_info *alias_info; [/b] /* main dev alias info */
[b]struct net_alias *my_alias;[/b] /* alias devs */
/* Pointer to the interface buffers. */
[b]struct sk_buff_head buffs[DEV_NUMBUFFS];[/b]
/* Pointers to interface service routines. */
[b]int (*open)(struct device *dev);
int (*stop)(struct device *dev);
int (*hard_start_xmit) (struct sk_buff *skb,
struct device *dev);
int (*hard_header) (struct sk_buff *skb,
struct device *dev,
unsigned short type,
void *daddr,
void *saddr,
unsigned len);
int (*rebuild_header)(void *eth,
struct device *dev,
unsigned long raddr,
struct sk_buff *skb);
void (*set_multicast_list)(struct device *dev);
int (*set_mac_address)(struct device *dev,
void *addr);
int (*do_ioctl)(struct device *dev,
struct ifreq *ifr,
int cmd);
int (*set_config)(struct device *dev,
struct ifmap *map);
void (*header_cache_bind)(struct hh_cache **hhp,
struct device *dev,
unsigned short htype,
__u32 daddr);
void (*header_cache_update)(struct hh_cache *hh,
struct device *dev,
unsigned char * haddr);
int (*change_mtu)(struct device *dev,
int new_mtu);
struct iw_statistics* (*get_wireless_stats)(struct device *dev);
};[/b]