]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/blob - src/core/netif.c
fixed bug #26507: "Gratuitous ARP depends on arp_table / uses etharp_query" by adding...
[pes-rpp/rpp-lwip.git] / src / core / netif.c
1 /**
2  * @file
3  * lwIP network interface abstraction
4  *
5  */
6
7 /*
8  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification,
12  * are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  *    this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  *    this list of conditions and the following disclaimer in the documentation
18  *    and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31  * OF SUCH DAMAGE.
32  *
33  * This file is part of the lwIP TCP/IP stack.
34  *
35  * Author: Adam Dunkels <adam@sics.se>
36  *
37  */
38
39 #include "lwip/opt.h"
40
41 #include "lwip/def.h"
42 #include "lwip/ip_addr.h"
43 #include "lwip/netif.h"
44 #include "lwip/tcp.h"
45 #include "lwip/snmp.h"
46 #include "lwip/igmp.h"
47 #include "netif/etharp.h"
48 #if ENABLE_LOOPBACK
49 #include "lwip/sys.h"
50 #if LWIP_NETIF_LOOPBACK_MULTITHREADING
51 #include "lwip/tcpip.h"
52 #endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
53 #endif /* ENABLE_LOOPBACK */
54
55 #if LWIP_NETIF_STATUS_CALLBACK
56 #define NETIF_STATUS_CALLBACK(n) { if (n->status_callback) (n->status_callback)(n); }
57 #else
58 #define NETIF_STATUS_CALLBACK(n) { /* NOP */ }
59 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 
60
61 #if LWIP_NETIF_LINK_CALLBACK
62 #define NETIF_LINK_CALLBACK(n) { if (n->link_callback) (n->link_callback)(n); }
63 #else
64 #define NETIF_LINK_CALLBACK(n) { /* NOP */ }
65 #endif /* LWIP_NETIF_LINK_CALLBACK */ 
66
67 struct netif *netif_list;
68 struct netif *netif_default;
69
70 /**
71  * Add a network interface to the list of lwIP netifs.
72  *
73  * @param netif a pre-allocated netif structure
74  * @param ipaddr IP address for the new netif
75  * @param netmask network mask for the new netif
76  * @param gw default gateway IP address for the new netif
77  * @param state opaque data passed to the new netif
78  * @param init callback function that initializes the interface
79  * @param input callback function that is called to pass
80  * ingress packets up in the protocol layer stack.
81  *
82  * @return netif, or NULL if failed.
83  */
84 struct netif *
85 netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
86   struct ip_addr *gw,
87   void *state,
88   err_t (* init)(struct netif *netif),
89   err_t (* input)(struct pbuf *p, struct netif *netif))
90 {
91   static u8_t netifnum = 0;
92
93   /* reset new interface configuration state */
94   netif->ip_addr.addr = 0;
95   netif->netmask.addr = 0;
96   netif->gw.addr = 0;
97   netif->flags = 0;
98 #if LWIP_DHCP
99   /* netif not under DHCP control by default */
100   netif->dhcp = NULL;
101 #endif /* LWIP_DHCP */
102 #if LWIP_AUTOIP
103   /* netif not under AutoIP control by default */
104   netif->autoip = NULL;
105 #endif /* LWIP_AUTOIP */
106 #if LWIP_NETIF_STATUS_CALLBACK
107   netif->status_callback = NULL;
108 #endif /* LWIP_NETIF_STATUS_CALLBACK */
109 #if LWIP_NETIF_LINK_CALLBACK
110   netif->link_callback = NULL;
111 #endif /* LWIP_NETIF_LINK_CALLBACK */
112 #if LWIP_IGMP
113   netif->igmp_mac_filter = NULL;
114 #endif /* LWIP_IGMP */
115 #if ENABLE_LOOPBACK
116   netif->loop_first = NULL;
117   netif->loop_last = NULL;
118 #endif /* ENABLE_LOOPBACK */
119
120   /* remember netif specific state information data */
121   netif->state = state;
122   netif->num = netifnum++;
123   netif->input = input;
124 #if LWIP_NETIF_HWADDRHINT
125   netif->addr_hint = NULL;
126 #endif /* LWIP_NETIF_HWADDRHINT*/
127 #if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
128   netif->loop_cnt_current = 0;
129 #endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */
130
131   netif_set_addr(netif, ipaddr, netmask, gw);
132
133   /* call user specified initialization function for netif */
134   if (init(netif) != ERR_OK) {
135     return NULL;
136   }
137
138   /* add this netif to the list */
139   netif->next = netif_list;
140   netif_list = netif;
141   snmp_inc_iflist();
142
143 #if LWIP_IGMP
144   /* start IGMP processing */
145   if (netif->flags & NETIF_FLAG_IGMP) {
146     igmp_start( netif);
147   }
148 #endif /* LWIP_IGMP */
149
150   LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
151     netif->name[0], netif->name[1]));
152   ip_addr_debug_print(NETIF_DEBUG, ipaddr);
153   LWIP_DEBUGF(NETIF_DEBUG, (" netmask "));
154   ip_addr_debug_print(NETIF_DEBUG, netmask);
155   LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
156   ip_addr_debug_print(NETIF_DEBUG, gw);
157   LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
158   return netif;
159 }
160
161 /**
162  * Change IP address configuration for a network interface (including netmask
163  * and default gateway).
164  *
165  * @param netif the network interface to change
166  * @param ipaddr the new IP address
167  * @param netmask the new netmask
168  * @param gw the new default gateway
169  */
170 void
171 netif_set_addr(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
172     struct ip_addr *gw)
173 {
174   netif_set_ipaddr(netif, ipaddr);
175   netif_set_netmask(netif, netmask);
176   netif_set_gw(netif, gw);
177 }
178
179 /**
180  * Remove a network interface from the list of lwIP netifs.
181  *
182  * @param netif the network interface to remove
183  */
184 void netif_remove(struct netif * netif)
185 {
186   if ( netif == NULL ) return;
187
188 #if LWIP_IGMP
189   /* stop IGMP processing */
190   if (netif->flags & NETIF_FLAG_IGMP) {
191     igmp_stop( netif);
192   }
193 #endif /* LWIP_IGMP */
194
195   snmp_delete_ipaddridx_tree(netif);
196
197   /*  is it the first netif? */
198   if (netif_list == netif) {
199     netif_list = netif->next;
200     snmp_dec_iflist();
201   }
202   else {
203     /*  look for netif further down the list */
204     struct netif * tmpNetif;
205     for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
206       if (tmpNetif->next == netif) {
207         tmpNetif->next = netif->next;
208         snmp_dec_iflist();
209         break;
210       }
211     }
212     if (tmpNetif == NULL)
213       return; /*  we didn't find any netif today */
214   }
215   /* this netif is default? */
216   if (netif_default == netif)
217     /* reset default netif */
218     netif_set_default(NULL);
219   LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
220 }
221
222 /**
223  * Find a network interface by searching for its name
224  *
225  * @param name the name of the netif (like netif->name) plus concatenated number
226  * in ascii representation (e.g. 'en0')
227  */
228 struct netif *
229 netif_find(char *name)
230 {
231   struct netif *netif;
232   u8_t num;
233
234   if (name == NULL) {
235     return NULL;
236   }
237
238   num = name[2] - '0';
239
240   for(netif = netif_list; netif != NULL; netif = netif->next) {
241     if (num == netif->num &&
242        name[0] == netif->name[0] &&
243        name[1] == netif->name[1]) {
244       LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
245       return netif;
246     }
247   }
248   LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
249   return NULL;
250 }
251
252 /**
253  * Change the IP address of a network interface
254  *
255  * @param netif the network interface to change
256  * @param ipaddr the new IP address
257  *
258  * @note call netif_set_addr() if you also want to change netmask and
259  * default gateway
260  */
261 void
262 netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
263 {
264   /* TODO: Handling of obsolete pcbs */
265   /* See:  http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */
266 #if LWIP_TCP
267   struct tcp_pcb *pcb;
268   struct tcp_pcb_listen *lpcb;
269
270   /* address is actually being changed? */
271   if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0)
272   {
273     /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */
274     LWIP_DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: netif address being changed\n"));
275     pcb = tcp_active_pcbs;
276     while (pcb != NULL) {
277       /* PCB bound to current local interface address? */
278       if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) {
279         /* this connection must be aborted */
280         struct tcp_pcb *next = pcb->next;
281         LWIP_DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb));
282         tcp_abort(pcb);
283         pcb = next;
284       } else {
285         pcb = pcb->next;
286       }
287     }
288     for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
289       /* PCB bound to current local interface address? */
290       if ((!(ip_addr_isany(&(lpcb->local_ip)))) &&
291           (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr)))) {
292         /* The PCB is listening to the old ipaddr and
293          * is set to listen to the new one instead */
294         ip_addr_set(&(lpcb->local_ip), ipaddr);
295       }
296     }
297   }
298 #endif
299   snmp_delete_ipaddridx_tree(netif);
300   snmp_delete_iprteidx_tree(0,netif);
301   /* set new IP address to netif */
302   ip_addr_set(&(netif->ip_addr), ipaddr);
303   snmp_insert_ipaddridx_tree(netif);
304   snmp_insert_iprteidx_tree(0,netif);
305
306   LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
307     netif->name[0], netif->name[1],
308     ip4_addr1(&netif->ip_addr),
309     ip4_addr2(&netif->ip_addr),
310     ip4_addr3(&netif->ip_addr),
311     ip4_addr4(&netif->ip_addr)));
312 }
313
314 /**
315  * Change the default gateway for a network interface
316  *
317  * @param netif the network interface to change
318  * @param gw the new default gateway
319  *
320  * @note call netif_set_addr() if you also want to change ip address and netmask
321  */
322 void
323 netif_set_gw(struct netif *netif, struct ip_addr *gw)
324 {
325   ip_addr_set(&(netif->gw), gw);
326   LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
327     netif->name[0], netif->name[1],
328     ip4_addr1(&netif->gw),
329     ip4_addr2(&netif->gw),
330     ip4_addr3(&netif->gw),
331     ip4_addr4(&netif->gw)));
332 }
333
334 /**
335  * Change the netmask of a network interface
336  *
337  * @param netif the network interface to change
338  * @param netmask the new netmask
339  *
340  * @note call netif_set_addr() if you also want to change ip address and
341  * default gateway
342  */
343 void
344 netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
345 {
346   snmp_delete_iprteidx_tree(0, netif);
347   /* set new netmask to netif */
348   ip_addr_set(&(netif->netmask), netmask);
349   snmp_insert_iprteidx_tree(0, netif);
350   LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 3, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
351     netif->name[0], netif->name[1],
352     ip4_addr1(&netif->netmask),
353     ip4_addr2(&netif->netmask),
354     ip4_addr3(&netif->netmask),
355     ip4_addr4(&netif->netmask)));
356 }
357
358 /**
359  * Set a network interface as the default network interface
360  * (used to output all packets for which no specific route is found)
361  *
362  * @param netif the default network interface
363  */
364 void
365 netif_set_default(struct netif *netif)
366 {
367   if (netif == NULL)
368   {
369     /* remove default route */
370     snmp_delete_iprteidx_tree(1, netif);
371   }
372   else
373   {
374     /* install default route */
375     snmp_insert_iprteidx_tree(1, netif);
376   }
377   netif_default = netif;
378   LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
379            netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
380 }
381
382 /**
383  * Bring an interface up, available for processing
384  * traffic.
385  * 
386  * @note: Enabling DHCP on a down interface will make it come
387  * up once configured.
388  * 
389  * @see dhcp_start()
390  */ 
391 void netif_set_up(struct netif *netif)
392 {
393   if ( !(netif->flags & NETIF_FLAG_UP )) {
394     netif->flags |= NETIF_FLAG_UP;
395     
396 #if LWIP_SNMP
397     snmp_get_sysuptime(&netif->ts);
398 #endif /* LWIP_SNMP */
399
400     NETIF_LINK_CALLBACK(netif);
401     NETIF_STATUS_CALLBACK(netif);
402
403 #if LWIP_ARP
404     /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ 
405     if (netif->flags & NETIF_FLAG_ETHARP) {
406       etharp_gratuitous(netif);
407     }
408 #endif /* LWIP_ARP */
409     
410   }
411 }
412
413 /**
414  * Bring an interface down, disabling any traffic processing.
415  *
416  * @note: Enabling DHCP on a down interface will make it come
417  * up once configured.
418  * 
419  * @see dhcp_start()
420  */ 
421 void netif_set_down(struct netif *netif)
422 {
423   if ( netif->flags & NETIF_FLAG_UP )
424     {
425       netif->flags &= ~NETIF_FLAG_UP;
426 #if LWIP_SNMP
427       snmp_get_sysuptime(&netif->ts);
428 #endif
429       
430       NETIF_LINK_CALLBACK(netif);
431       NETIF_STATUS_CALLBACK(netif);
432     }
433 }
434
435 /**
436  * Ask if an interface is up
437  */ 
438 u8_t netif_is_up(struct netif *netif)
439 {
440   return (netif->flags & NETIF_FLAG_UP)?1:0;
441 }
442
443 #if LWIP_NETIF_STATUS_CALLBACK
444 /**
445  * Set callback to be called when interface is brought up/down
446  */
447 void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif ))
448 {
449     if ( netif )
450         netif->status_callback = status_callback;
451 }
452 #endif /* LWIP_NETIF_STATUS_CALLBACK */
453
454 #if LWIP_NETIF_LINK_CALLBACK
455 /**
456  * Called by a driver when its link goes up
457  */
458 void netif_set_link_up(struct netif *netif )
459 {
460   netif->flags |= NETIF_FLAG_LINK_UP;
461
462 #if LWIP_ARP
463     /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ 
464     if (netif->flags & NETIF_FLAG_ETHARP) {
465       etharp_gratuitous(netif);
466     }
467 #endif /* LWIP_ARP */
468
469 #if LWIP_IGMP
470   /* resend IGMP memberships */
471   if (netif->flags & NETIF_FLAG_IGMP) {
472     igmp_report_groups( netif);
473   }
474 #endif /* LWIP_IGMP */
475
476   NETIF_LINK_CALLBACK(netif);
477 }
478
479 /**
480  * Called by a driver when its link goes down
481  */
482 void netif_set_link_down(struct netif *netif )
483 {
484   netif->flags &= ~NETIF_FLAG_LINK_UP;
485   NETIF_LINK_CALLBACK(netif);
486 }
487
488 /**
489  * Ask if a link is up
490  */ 
491 u8_t netif_is_link_up(struct netif *netif)
492 {
493   return (netif->flags & NETIF_FLAG_LINK_UP) ? 1 : 0;
494 }
495
496 /**
497  * Set callback to be called when link is brought up/down
498  */
499 void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif ))
500 {
501   if (netif) {
502     netif->link_callback = link_callback;
503   }
504 }
505 #endif /* LWIP_NETIF_LINK_CALLBACK */
506
507 #if ENABLE_LOOPBACK
508 /**
509  * Send an IP packet to be received on the same netif (loopif-like).
510  * The pbuf is simply copied and handed back to netif->input.
511  * In multithreaded mode, this is done directly since netif->input must put
512  * the packet on a queue.
513  * In callback mode, the packet is put on an internal queue and is fed to
514  * netif->input by netif_poll().
515  *
516  * @param netif the lwip network interface structure
517  * @param p the (IP) packet to 'send'
518  * @param ipaddr the ip address to send the packet to (not used)
519  * @return ERR_OK if the packet has been sent
520  *         ERR_MEM if the pbuf used to copy the packet couldn't be allocated
521  */
522 err_t
523 netif_loop_output(struct netif *netif, struct pbuf *p,
524        struct ip_addr *ipaddr)
525 {
526   struct pbuf *r;
527   err_t err;
528   struct pbuf *last;
529 #if LWIP_LOOPBACK_MAX_PBUFS
530   u8_t clen = 0;
531 #endif /* LWIP_LOOPBACK_MAX_PBUFS */
532   SYS_ARCH_DECL_PROTECT(lev);
533   LWIP_UNUSED_ARG(ipaddr);
534
535   /* Allocate a new pbuf */
536   r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
537   if (r == NULL) {
538     return ERR_MEM;
539   }
540 #if LWIP_LOOPBACK_MAX_PBUFS
541   clen = pbuf_clen(r);
542   /* check for overflow or too many pbuf on queue */
543   if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
544     ((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) {
545       pbuf_free(r);
546       r = NULL;
547       return ERR_MEM;
548   }
549   netif->loop_cnt_current += clen;
550 #endif /* LWIP_LOOPBACK_MAX_PBUFS */
551
552   /* Copy the whole pbuf queue p into the single pbuf r */
553   if ((err = pbuf_copy(r, p)) != ERR_OK) {
554     pbuf_free(r);
555     r = NULL;
556     return err;
557   }
558
559   /* Put the packet on a linked list which gets emptied through calling
560      netif_poll(). */
561
562   /* let last point to the last pbuf in chain r */
563   for (last = r; last->next != NULL; last = last->next);
564
565   SYS_ARCH_PROTECT(lev);
566   if(netif->loop_first != NULL) {
567     LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL);
568     netif->loop_last->next = r;
569     netif->loop_last = last;
570   } else {
571     netif->loop_first = r;
572     netif->loop_last = last;
573   }
574   SYS_ARCH_UNPROTECT(lev);
575
576 #if LWIP_NETIF_LOOPBACK_MULTITHREADING
577   /* For multithreading environment, schedule a call to netif_poll */
578   tcpip_callback((void (*)(void *))(netif_poll), netif);
579 #endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
580
581   return ERR_OK;
582 }
583
584 /**
585  * Call netif_poll() in the main loop of your application. This is to prevent
586  * reentering non-reentrant functions like tcp_input(). Packets passed to
587  * netif_loop_output() are put on a list that is passed to netif->input() by
588  * netif_poll().
589  */
590 void
591 netif_poll(struct netif *netif)
592 {
593   struct pbuf *in;
594   SYS_ARCH_DECL_PROTECT(lev);
595
596   do {
597     /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */
598     SYS_ARCH_PROTECT(lev);
599     in = netif->loop_first;
600     if(in != NULL) {
601       struct pbuf *in_end = in;
602 #if LWIP_LOOPBACK_MAX_PBUFS
603       u8_t clen = pbuf_clen(in);
604       /* adjust the number of pbufs on queue */
605       LWIP_ASSERT("netif->loop_cnt_current underflow",
606         ((netif->loop_cnt_current - clen) < netif->loop_cnt_current));
607       netif->loop_cnt_current -= clen;
608 #endif /* LWIP_LOOPBACK_MAX_PBUFS */
609       while(in_end->len != in_end->tot_len) {
610         LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL);
611         in_end = in_end->next;
612       }
613       /* 'in_end' now points to the last pbuf from 'in' */
614       if(in_end == netif->loop_last) {
615         /* this was the last pbuf in the list */
616         netif->loop_first = netif->loop_last = NULL;
617       } else {
618         /* pop the pbuf off the list */
619         netif->loop_first = in_end->next;
620         LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL);
621       }
622       /* De-queue the pbuf from its successors on the 'loop_' list. */
623       in_end->next = NULL;
624     }
625     SYS_ARCH_UNPROTECT(lev);
626
627     if(in != NULL) {
628       /* loopback packets are always IP packets! */
629       if(ip_input(in, netif) != ERR_OK) {
630         pbuf_free(in);
631       }
632       /* Don't reference the packet any more! */
633       in = NULL;
634     }
635   /* go on while there is a packet on the list */
636   } while(netif->loop_first != NULL);
637 }
638
639 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
640 /**
641  * Calls netif_poll() for every netif on the netif_list.
642  */
643 void
644 netif_poll_all(void)
645 {
646   struct netif *netif = netif_list;
647   /* loop through netifs */
648   while (netif != NULL) {
649     netif_poll(netif);
650     /* proceed to next network interface */
651     netif = netif->next;
652   }
653 }
654 #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
655 #endif /* ENABLE_LOOPBACK */