更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
netif.h 文件参考

浏览源代码.

函数

err_t driverif_init (struct netif *netif)
 
void driverif_input (struct netif *netif, struct pbuf *p)
 

函数说明

◆ driverif_init()

err_t driverif_init ( struct netif *  netif)

◆ driverif_input()

void driverif_input ( struct netif *  netif,
struct pbuf *  p 
)

在文件 driverif.c134 行定义.

135{
136#if PF_PKT_SUPPORT
137#if (DRIVERIF_DEBUG & LWIP_DBG_OFF)
138 u16_t ethhdr_type;
139 struct eth_hdr* ethhdr = NULL;
140#endif
141#else
142 u16_t ethhdr_type;
143 struct eth_hdr *ethhdr = NULL;
144#endif
145 err_t ret = ERR_VAL;
146
147 LWIP_ERROR("driverif_input : invalid arguments", ((netif != NULL) && (p != NULL)), return);
148
149 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : going to receive input packet. netif 0x%p, pbuf 0x%p, \
150 packet_length %"U16_F"\n", (void *)netif, (void *)p, p->tot_len));
151
152 /* points to packet payload, which starts with an Ethernet header */
153 MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
154 if (p->len < SIZEOF_ETH_HDR) {
155 (void)pbuf_free(p);
156 LINK_STATS_INC(link.drop);
157 LINK_STATS_INC(link.link_rx_drop);
158 return;
159 }
160
161#if PF_PKT_SUPPORT
162#if (DRIVERIF_DEBUG & LWIP_DBG_OFF)
163 ethhdr = (struct eth_hdr *)p->payload;
164 ethhdr_type = ntohs(ethhdr->type);
165 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet of type %"U16_F" netif->input=%p\n", ethhdr_type, netif->input));
166#endif
167
168 /* full packet send to tcpip_thread to process */
169 if (netif->input) {
170 ret = netif->input(p, netif);
171 }
172 if (ret != ERR_OK) {
173 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input: IP input error\n"));
174 (void)pbuf_free(p);
175 LINK_STATS_INC(link.drop);
176 LINK_STATS_INC(link.link_rx_drop);
177 if (ret == ERR_MEM) {
178 LINK_STATS_INC(link.link_rx_overrun);
179 }
180 } else {
181 LINK_STATS_INC(link.recv);
182 }
183
184#else
185 ethhdr = (struct eth_hdr *)p->payload;
186 ethhdr_type = ntohs(ethhdr->type);
187
188 switch (ethhdr_type) {
189 /* IP or ARP packet? */
190 case ETHTYPE_IP:
191 case ETHTYPE_IPV6:
192 case ETHTYPE_ARP:
193#if ETHARP_SUPPORT_VLAN
194 case ETHTYPE_VLAN:
195#endif /* ETHARP_SUPPORT_VLAN */
196 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet of type %"U16_F"\n", ethhdr_type));
197 /* full packet send to tcpip_thread to process */
198 if (netif->input != NULL) {
199 ret = netif->input(p, netif);
200 }
201
202 if (ret != ERR_OK) {
203 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input: IP input error\n"));
204 (void)pbuf_free(p);
205 LINK_STATS_INC(link.drop);
206 LINK_STATS_INC(link.link_rx_drop);
207 if (ret == ERR_MEM) {
208 MIB2_STATS_NETIF_INC(netif, ifinoverruns);
209 LINK_STATS_INC(link.link_rx_overrun);
210 }
211 } else {
212 LINK_STATS_INC(link.recv);
213 }
214 break;
215
216 default:
217 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet is of unsupported type %"U16_F"\n", ethhdr_type));
218 (void)pbuf_free(p);
219 LINK_STATS_INC(link.drop);
220 LINK_STATS_INC(link.link_rx_drop);
221 break;
222 }
223#endif
224
225 LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet is processed\n"));
226}
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void