/** Generic data structure used for all lwIP network interfaces. * The following fields should be filled in by the initialization * function for the device driver: hwaddr_len, hwaddr[], mtu, flags * 用于所有lwIP网络接口的通用数据结构体 * 设备驱动函数在初始化时应该填充以下数据域:hwaddr_len,hwaddr[],mtu,flags.*/struct netif { /** pointer to next in linked list */ struct netif *next; /** IP address configuration in network byte order */ struct ip_addr ip_addr; //IP地址 struct ip_addr netmask; //子网掩码 struct ip_addr gw; //默认网关 /** This function is called by the network device driver * to pass a packet up the TCP/IP stack. 这个函数由网络设备驱动所调用,从网卡中接收数据包并传递给TCP/IP协议栈*/ err_t (* input)(struct pbuf *p, struct netif *inp); //从网卡中接收一包数据 /** This function is called by the IP module when it wants * to send a packet on the interface. This function typically * first resolves the hardware address, then sends the packet. 当IP模块向接口发送一个数据包时调用此函数。这个函数通常首先解析 硬件地址,然后发送数据包*/ err_t (* output)(struct netif *netif, struct pbuf *p, //IP层调用此函数向网卡发送一包数据 struct ip_addr *ipaddr); /** This function is called by the ARP module when it wants * to send a packet on the interface. This function outputs * the pbuf as-is on the link medium. 当ARP模块向接口发送一个数据包时调用此函数。这个函数向链路输出一个pbuf。*/ err_t (* linkoutput)(struct netif *netif, struct pbuf *p); //ARP模块调用这个函数向网卡发送一包数据#if LWIP_NETIF_STATUS_CALLBACK //netif状态被改变时该函数被调用,未使用 /** This function is called when the netif state is set to up or down */ void (* status_callback)(struct netif *netif);#endif /* LWIP_NETIF_STATUS_CALLBACK */#if LWIP_NETIF_LINK_CALLBACK //未使用 /** This function is called when the netif link is set to up or down netif连接改变时调用 */ void (* link_callback)(struct netif *netif);#endif /* LWIP_NETIF_LINK_CALLBACK */ /** This field can be set by the device driver and could point * to state information for the device. * 这个域能够通过设备驱动设置并且能够指向设备的信息状态,供用户自行使用*/ void *state;#if LWIP_DHCP //使能DHCP /** the DHCP client state information for this netif */ struct dhcp *dhcp;#endif /* LWIP_DHCP */#if LWIP_AUTOIP /** the AutoIP client state information for this netif */ struct autoip *autoip;#endif#if LWIP_NETIF_HOSTNAME /* the hostname for this netif, NULL is a valid value NULL也是一个有效值*/ char* hostname;#endif /* LWIP_NETIF_HOSTNAME */ /** maximum transfer unit (in bytes) 最大发送单元(单位:字节)以太网为1500*/ u16_t mtu; /** number of bytes used in hwaddr 硬件地址长度*/ u8_t hwaddr_len; /** link level hardware address of this interface 接口的连接层硬件地址*/ u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; //=6 /** flags (see NETIF_FLAG_ above) 标志位*/ u8_t flags; /** descriptive abbreviation 描述缩写*/ char name[2]; /** number of this interface 接口号,如果两个网络接口具有相同的描述缩写(即上面的name字段),就用num字段来区分相同类型的不同网络接口*/ u8_t num;#if LWIP_SNMP /** link type (from "snmp_ifType" enum from snmp.h) 连接类型*/ u8_t link_type; /** (estimate) link speed (预计)连接速度*/ u32_t link_speed; /** timestamp at last change made (up/down) 最后up/down变化时间戳*/ u32_t ts; /** counters 计数器*/ u32_t ifinoctets; u32_t ifinucastpkts; u32_t ifinnucastpkts; u32_t ifindiscards; u32_t ifoutoctets; u32_t ifoutucastpkts; u32_t ifoutnucastpkts; u32_t ifoutdiscards;#endif /* LWIP_SNMP */#if LWIP_IGMP /* This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/ err_t (*igmp_mac_filter)( struct netif *netif, struct ip_addr *group, u8_t action);#endif /* LWIP_IGMP */#if LWIP_NETIF_HWADDRHINT u8_t *addr_hint;#endif /* LWIP_NETIF_HWADDRHINT */#if ENABLE_LOOPBACK /* List of packets to be queued for ourselves. */ struct pbuf *loop_first; struct pbuf *loop_last;#if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current;#endif /* LWIP_LOOPBACK_MAX_PBUFS */#endif /* ENABLE_LOOPBACK */}; // END struct netif