教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

LWIP之SOCKET的实现(6)

来源:网络收集 时间:2026-05-15
导读: #if LWIP_NETIF_LINK_CALLBACK /** This function is called when the netif link is set to up or down */ void (* link_callback)(struct netif *netif); #endif /* LWIP_NETIF_LINK_CALLBACK */ /** This field

#if LWIP_NETIF_LINK_CALLBACK

/** This function is called when the netif link is set to up or down */ 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

/** 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 */ char* hostname;

#endif /* LWIP_NETIF_HOSTNAME */

/** number of bytes used in hwaddr */ u8_t hwaddr_len;

/** link level hardware address of this interface */ u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; /** maximum transfer unit (in bytes) */ u16_t mtu;

/** flags (see NETIF_FLAG_ above) */ u8_t flags;

/** descriptive abbreviation */ char name[2];

/** number of this interface */

u8_t num;

#if LWIP_SNMP

/** link type (from \

u8_t link_type;

/** (estimate) link speed */ u32_t link_speed;

/** timestamp at last change made (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 */ };

该结构体实现在【src\\include\\lwip\\netif.h】,注意到该结构体成员中有3个函数指针变量。好了,这个结构体先做一大体了解。用到的时候再详细讲。

接下来先看下ip_route函数的实现:

* Finds the appropriate network interface for a given IP address. It * searches the list of network interfaces linearly. A match is found * if the masked IP address of the network interface equals the masked * IP address given to the function.

struct netif * ip_route(struct ip_addr *dest) {

struct netif *netif;

/* iterate through netifs */

for(netif = netif_list; netif != NULL; netif = netif->next) { /* network mask matches? */ if (netif_is_up(netif)) {

if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { /* return netif on which to forward IP packet */

…… 此处隐藏:324字,全部文档内容请下载后查看。喜欢就下载吧 ……
LWIP之SOCKET的实现(6).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/520675.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)