既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
netif->name[1] = IFNAME1;
/* We directly use etharp_output() here to save a function call.
- You can instead declare your own function an call etharp_output()
- from it if you have to do some checks before sending (e.g. if link
- is available…) */
#if LWIP_IPV4
#if LWIP_ARP || LWIP_ETHERNET
#if LWIP_ARP
netif->output = etharp_output;
#else
/* The user should write ist own code in low_level_output_arp_off function /
netif->output = low_level_output_arp_off;
#endif / LWIP_ARP /
#endif / LWIP_ARP || LWIP_ETHERNET /
#endif / LWIP_IPV4 */
#if LWIP_IPV6
netif->output_ip6 = ethip6_output;
#endif /* LWIP_IPV6 */
netif->linkoutput = low_level_output;
/* initialize the hardware */
low_level_init(netif);
return ERR_OK;
}
* 由**lwip官方**下载的示例代码
err_t
ethernetif_init(struct netif *netif)
{
struct ethernetif *ethernetif;
LWIP_ASSERT(“netif != NULL”, (netif != NULL));
ethernetif = mem_malloc(sizeof(struct ethernetif));
if (ethernetif == NULL) {
LWIP_DEBUGF(NETIF_DEBUG, (“ethernetif_init: out of memory\n”));
return ERR_MEM;
}
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname /
netif->hostname = “lwip”;
#endif / LWIP_NETIF_HOSTNAME */
/*
- Initialize the snmp variables and counters inside the struct netif.
- The last argument should be replaced with your link speed, in units
- of bits per second.
*/
MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
netif->state = ethernetif;
netif->name[0] = IFNAME0;
netif->name[1] = IFNAME1;
/* We directly use etharp_output() here to save a function call.
- You can instead declare your own function an call etharp_output()
- from it if you have to do some checks before sending (e.g. if link
- is available…) /
#if LWIP_IPV4
netif->output = etharp_output;
#endif / LWIP_IPV4 /
#if LWIP_IPV6
netif->output_ip6 = ethip6_output;
#endif / LWIP_IPV6 */
netif->linkoutput = low_level_output;
ethernetif->ethaddr = (struct eth_addr *) & (netif->hwaddr[0]);
/* initialize the hardware */
low_level_init(netif);
return ERR_OK;
}
**小结:**由上面两种程序对比,可以看出大同小异。基本上都是对**netif 网卡结构体进行赋值**,然后**真正的初始化**交由**low\_level\_init**来进行。
#### (3)**