01Introduction to Network InterfaceIn the TCP/IP reference model, the network is divided into four layers: application layer, transport layer, network layer and network interface layer. The network interface layer corresponds to our actual network card. LWIP supports multi-port design. LWIP uses netif to describe the characteristics of each network interface, such as the IP address of the interface, interface status, etc. So if there are multiple network cards, how does LWIP organize these network cards? In LWIP, the linked list netif_list is used to manage many network cards. When the upper layer has data to send, LWIP will select a suitable network card from the netif_list linked list to send the data. 02netif structureThe netif structure is defined in the file netif.h. The meaning of each member variable in the netif structure is as follows: next : This field points to the next neitif type structure. Because LWIP can support multiple network interfaces, when the device has multiple network interfaces, LWIP will organize all netif structures into a linked list to manage these network interfaces. ipaddr, netmask and gw : the IP address, subnet mask and default gateway of the network interface respectively. input : This field is a function that passes the data received by the network card to the IP layer. output : This field is a function that is called when the IP layer sends a data packet to the interface. This function usually resolves the hardware address first and then sends the data packet. For this field, we generally use the etharp_output() function in etharp.c. linkoutput : This field is a function that is called by the ARP module to complete the transmission of network data. After the etharp_output function mentioned above encapsulates the IP data packet into an Ethernet data frame, it will call the linkoutput function to send the data out. state : used to define some information about the interface, which can be set by the user. mtu : The maximum data length that the network interface can transmit, usually set to 1500. hwaddr_len : Network card MAC address length, 6 bytes. hwaddr : MAC address. flags : Network interface status, attribute information field. name : The name of the network card. num : This field is a number set by the protocol stack for each network interface, starting from 0. The value of flags: in In network initialization, in ethernetif.c They all correspond to a function etharp_output : IP layer sends data packet function low_level_output : ARP module sending function, a lower-level function, in fact, etharp_output still calls this function 03 Related functions3.1、netif_add
That is, add the netif network interface to the network list queue and add a network card to the network card list 3.2, netif_set_default
Set this network card as the default network card 3.3, netif_set_up
Open the network card |
>>: Z-Wave not concerned about potential threats from Project CHIP
During MWC22 Barcelona, Huawei, with the theme ...
[51CTO.com original article] The socialization, i...
1. Basic concepts of ubiquitous network Ubiquitou...
Tencent Cloud's Double 11 event is still vali...
US court rules to temporarily suspend TikTok'...
From the first three-wheeled vehicle developed by...
[[261281]] As an investor in emerging technologie...
The 2016 Huawei Dalian Software Development Cloud...
Maxthon Host is a long-established foreign hostin...
The 5G era is just around the corner, and it prom...
Gartner, the world's leading information tech...
Riverbed Technology recently announced that the l...
With the rapid development of information technol...
At 14:30 on July 31, 2020, the Kunpeng Applicatio...
[[395563]] The State Council Information Office h...