Checked in slightly modified version of patch # 6370: Moved loopif code to netif.c so that loopback traffic is supported on all netifs (all local IPs).

This commit is contained in:
goldsimon
2008-06-12 20:10:08 +00:00
parent 24e0b25215
commit 88ff8c83e9
7 changed files with 202 additions and 172 deletions

View File

@@ -34,6 +34,8 @@
#include "lwip/opt.h"
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
#include "lwip/err.h"
#include "lwip/ip_addr.h"
@@ -165,6 +167,11 @@ struct netif {
#if LWIP_NETIF_HWADDRHINT
u8_t *addr_hint;
#endif /* LWIP_NETIF_HWADDRHINT */
#if ENABLE_LOOPBACK && !LWIP_NETIF_LOOPBACK_MULTITHREADING
/* List of packets to be queued for ourselves. */
struct pbuf *loop_first;
struct pbuf *loop_last;
#endif /* ENABLE_LOOPBACK && !LWIP_NETIF_LOOPBACK_MULTITHREADING */
};
#if LWIP_SNMP
@@ -242,4 +249,12 @@ void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct
}
#endif
#if ENABLE_LOOPBACK
err_t netif_loop_output(struct netif *netif, struct pbuf *p, struct ip_addr *dest_ip);
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
void netif_poll_all(void);
void netif_poll(struct netif *netif);
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
#endif /* ENABLE_LOOPBACK */
#endif /* __LWIP_NETIF_H__ */

View File

@@ -832,6 +832,31 @@
#define LWIP_NETIF_HWADDRHINT 0
#endif
/**
* LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
* address equal to the netif IP address, looping them back up the stack.
*/
#ifndef LWIP_NETIF_LOOPBACK
#define LWIP_NETIF_LOOPBACK 0
#endif
/**
* LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in
* the system, as netifs must change how they behave depending on this setting
* for the LWIP_NETIF_LOOPBACK option to work.
* Setting this is needed to avoid reentering non-reentrant functions like
* tcp_input().
* LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a
* multithreaded environment like tcpip.c. In this case, netif->input()
* is called directly.
* LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup.
* The packets are put on a list and netif_poll() must be called in
* the main application loop.
*/
#ifndef LWIP_NETIF_LOOPBACK_MULTITHREADING
#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
#endif
/*
------------------------------------
---------- LOOPIF options ----------
@@ -844,22 +869,6 @@
#define LWIP_HAVE_LOOPIF 0
#endif
/**
* LWIP_LOOPIF_MULTITHREADING: Indicates whether threading is enabled in
* the system, as LOOPIF must change how it behaves depending on this setting.
* Setting this is needed to avoid reentering non-reentrant functions like
* tcp_input().
* LWIP_LOOPIF_MULTITHREADING==1: Indicates that the user is using a
* multithreaded environment like tcpip.c. In this case, netif->input()
* is called directly.
* LWIP_LOOPIF_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup.
* The packets are put on a list and loopif_poll() must be called in
* the main application loop.
*/
#ifndef LWIP_LOOPIF_MULTITHREADING
#define LWIP_LOOPIF_MULTITHREADING 1
#endif
/*
------------------------------------
---------- Thread options ----------

View File

@@ -39,8 +39,8 @@
extern "C" {
#endif
#if !LWIP_LOOPIF_MULTITHREADING
void loopif_poll(struct netif *netif);
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
#define loopif_poll(netif) netif_poll()
#endif
err_t loopif_init(struct netif *netif);