42 #include "lwip/ip_addr.h"
51 #if LWIP_NETIF_LOOPBACK_MULTITHREADING
63 #if LWIP_NETIF_STATUS_CALLBACK
64 #define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0)
66 #define NETIF_STATUS_CALLBACK(n)
69 #if LWIP_NETIF_LINK_CALLBACK
70 #define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0)
72 #define NETIF_LINK_CALLBACK(n)
79 static struct netif loop_netif;
98 netif->
output = netif_loop_output;
107 ip_addr_t loop_ipaddr, loop_netmask, loop_gw;
140 static u8_t netifnum = 0;
155 netif->autoip =
NULL;
157 #if LWIP_NETIF_STATUS_CALLBACK
158 netif->status_callback =
NULL;
160 #if LWIP_NETIF_LINK_CALLBACK
161 netif->link_callback =
NULL;
164 netif->igmp_mac_filter =
NULL;
167 netif->loop_first =
NULL;
168 netif->loop_last =
NULL;
173 netif->
num = netifnum++;
175 #if LWIP_NETIF_HWADDRHINT
176 netif->addr_hint =
NULL;
178 #if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
179 netif->loop_cnt_current = 0;
185 if (init(netif) !=
ERR_OK) {
256 if (netif_list == netif) {
257 netif_list = netif->
next;
260 struct netif * tmpNetif;
261 for (tmpNetif = netif_list; tmpNetif !=
NULL; tmpNetif = tmpNetif->
next) {
262 if (tmpNetif->
next == netif) {
267 if (tmpNetif ==
NULL)
272 if (netif_default == netif) {
297 for(netif = netif_list; netif !=
NULL; netif = netif->
next) {
298 if (num == netif->
num &&
299 name[0] == netif->
name[0] &&
300 name[1] == netif->
name[1]) {
325 struct tcp_pcb_listen *lpcb;
331 pcb = tcp_active_pcbs;
332 while (pcb !=
NULL) {
341 struct tcp_pcb *next = pcb->next;
349 for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb !=
NULL; lpcb = lpcb->next) {
435 netif_default = netif;
437 netif ? netif->
name[0] :
'\'', netif ? netif->
name[1] :
'\''));
464 etharp_gratuitous(netif);
471 igmp_report_groups( netif);
498 #if LWIP_NETIF_STATUS_CALLBACK
505 netif->status_callback = status_callback;
520 dhcp_network_changed(netif);
526 autoip_network_changed(netif);
534 etharp_gratuitous(netif);
541 igmp_report_groups( netif);
560 #if LWIP_NETIF_LINK_CALLBACK
567 netif->link_callback = link_callback;
588 netif_loop_output(
struct netif *netif,
struct pbuf *p,
594 #if LWIP_LOOPBACK_MAX_PBUFS
601 struct netif *stats_if = &loop_netif;
603 struct netif *stats_if = netif;
617 #if LWIP_LOOPBACK_MAX_PBUFS
620 if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
628 netif->loop_cnt_current += clen;
647 if(netif->loop_first !=
NULL) {
648 LWIP_ASSERT(
"if first != NULL, last must also be != NULL", netif->loop_last !=
NULL);
649 netif->loop_last->
next = r;
650 netif->loop_last = last;
652 netif->loop_first = r;
653 netif->loop_last = last;
661 #if LWIP_NETIF_LOOPBACK_MULTITHREADING
676 netif_poll(
struct netif *netif)
683 struct netif *stats_if = &loop_netif;
685 struct netif *stats_if = netif;
693 in = netif->loop_first;
695 struct pbuf *in_end = in;
696 #if LWIP_LOOPBACK_MAX_PBUFS
700 ((netif->loop_cnt_current - clen) < netif->loop_cnt_current));
701 netif->loop_cnt_current -= clen;
705 in_end = in_end->
next;
708 if (in_end == netif->loop_last) {
710 netif->loop_first = netif->loop_last =
NULL;
713 netif->loop_first = in_end->
next;
714 LWIP_ASSERT(
"should not be null since first != last!", netif->loop_first !=
NULL);
733 }
while (netif->loop_first !=
NULL);
736 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
745 while (netif !=
NULL) {