lwip: refractor for lwip

1. All espressif specific code are prefix with ESP_
2. Define all ESP_ options in lwipopts.h
3. Remove useless code added in 8266
This commit is contained in:
Liu Zhi Fu 2016-10-27 14:11:01 +08:00
parent 8dcd78d52f
commit 6e6e51426f
46 changed files with 142 additions and 475 deletions

View File

@ -55,11 +55,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#define API_MSG_VAR_REF(name) API_VAR_REF(name)
#define API_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct api_msg, name)
#define API_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name)
@ -178,8 +173,8 @@ netconn_delete(struct netconn *conn)
return err;
}
#if !LWIP_THREAD_SAFE
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("netconn_delete - free conn\n"));
#if !ESP_THREAD_SAFE
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("netconn_delete - free conn\n"));
netconn_free(conn);
#endif
@ -502,7 +497,7 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */
#if (LWIP_UDP || LWIP_RAW)
{
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
if (buf == NULL){
API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
return ERR_CLSD;
@ -710,17 +705,7 @@ netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
}
dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK);
#ifdef LWIP_ESP8266
#ifdef FOR_XIAOMI
if (dontblock && bytes_written) {
#else
if (dontblock && !bytes_written) {
#endif
#else
if (dontblock && !bytes_written) {
#endif
/* This implies netconn_write() cannot be used for non-blocking send, since
it has no way to return the number of bytes written. */
return ERR_VAL;

View File

@ -55,10 +55,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/* netconns are polled once per second (e.g. continue write on memory error) */
#define NETCONN_TCP_POLL_INTERVAL 2
@ -1216,16 +1212,7 @@ lwip_netconn_do_connect(void *m)
if (msg->conn->state == NETCONN_CONNECT) {
msg->err = ERR_ALREADY;
} else if (msg->conn->state != NETCONN_NONE) {
#ifdef LWIP_ESP8266
if( msg->conn->pcb.tcp->state == ESTABLISHED )
msg->err = ERR_ISCONN;
else
msg->err = ERR_ALREADY;
#else
msg->err = ERR_ISCONN;
#endif
} else {
setup_tcp(msg->conn);
msg->err = tcp_connect(msg->conn->pcb.tcp, API_EXPR_REF(msg->msg.bc.ipaddr),
@ -1646,14 +1633,7 @@ lwip_netconn_do_write(void *m)
if (lwip_netconn_do_writemore(msg->conn, 0) != ERR_OK) {
LWIP_ASSERT("state!", msg->conn->state == NETCONN_WRITE);
UNLOCK_TCPIP_CORE();
#ifdef LWIP_ESP8266
//#if 0
sys_arch_sem_wait( LWIP_API_MSG_SND_SEM(msg), 0);
#else
sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0);
#endif
sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0);
LOCK_TCPIP_CORE();
LWIP_ASSERT("state!", msg->conn->state != NETCONN_WRITE);
}

View File

@ -45,11 +45,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/**
* Create (allocate) and initialize a new netbuf.
* The netbuf doesn't yet contain a packet buffer!

View File

@ -47,11 +47,6 @@
#include <string.h>
#include <stdlib.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** helper struct for gethostbyname_r to access the char* buffer */
struct gethostbyname_r_helper {
ip_addr_t *addr_list[2];

View File

@ -61,11 +61,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/* If the netconn API is not required publicly, then we include the necessary
files here to get the implementation */
#if !LWIP_NETCONN
@ -216,7 +211,7 @@ struct lwip_sock {
/** last error that occurred on this socket (in fact, all our errnos fit into an u8_t) */
u8_t err;
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
/* lock is used to protect state/ref field, however this lock is not a perfect lock, e.g
* taskA and taskB can access sock X, then taskA freed sock X, before taskB detect
* this, taskC reuse sock X, then when taskB try to access sock X, problem may happen.
@ -239,7 +234,7 @@ struct lwip_sock {
SELWAIT_T select_waiting;
};
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
#define LWIP_SOCK_OPEN 0
#define LWIP_SOCK_CLOSING 1
@ -247,25 +242,25 @@ struct lwip_sock {
#define LWIP_SOCK_LOCK(sock) \
do{\
/*LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("l\n"));*/\
/*LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("l\n"));*/\
sys_mutex_lock(&sock->lock);\
/*LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("l ok\n"));*/\
/*LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("l ok\n"));*/\
}while(0)
#define LWIP_SOCK_UNLOCK(sock) \
do{\
sys_mutex_unlock(&sock->lock);\
/*LWIP_DEBUGF(THREAD_SAFE_DEBUG1, ("unl\n"));*/\
/*LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG1, ("unl\n"));*/\
}while(0)
#define LWIP_FREE_SOCK(sock) \
do{\
if(sock->conn && NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP){\
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("LWIP_FREE_SOCK:free tcp sock\n"));\
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("LWIP_FREE_SOCK:free tcp sock\n"));\
free_socket(sock, 1);\
} else {\
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("LWIP_FREE_SOCK:free non-tcp sock\n"));\
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("LWIP_FREE_SOCK:free non-tcp sock\n"));\
free_socket(sock, 0);\
}\
}while(0)
@ -273,7 +268,7 @@ do{\
#define LWIP_SET_CLOSE_FLAG() \
do{\
LWIP_SOCK_LOCK(__sock);\
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("mark sock closing\n"));\
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("mark sock closing\n"));\
__sock->state = LWIP_SOCK_CLOSING;\
LWIP_SOCK_UNLOCK(__sock);\
}while(0)
@ -291,7 +286,7 @@ do{\
LWIP_SOCK_LOCK(__sock);\
__sock->ref ++;\
if (__sock->state != LWIP_SOCK_OPEN) {\
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("LWIP_API_LOCK:soc is %d, return\n", __sock->state));\
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("LWIP_API_LOCK:soc is %d, return\n", __sock->state));\
__sock->ref --;\
LWIP_SOCK_UNLOCK(__sock);\
return -1;\
@ -306,12 +301,12 @@ do{\
__sock->ref --;\
if (__sock->state == LWIP_SOCK_CLOSING) {\
if (__sock->ref == 0){\
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("LWIP_API_UNLOCK:ref 0, free __sock\n"));\
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("LWIP_API_UNLOCK:ref 0, free __sock\n"));\
LWIP_FREE_SOCK(__sock);\
LWIP_SOCK_UNLOCK(__sock);\
return __ret;\
}\
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("LWIP_API_UNLOCK: soc state is closing, return\n"));\
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("LWIP_API_UNLOCK: soc state is closing, return\n"));\
LWIP_SOCK_UNLOCK(__sock);\
return __ret;\
}\
@ -387,7 +382,7 @@ static void lwip_socket_unregister_membership(int s, const ip4_addr_t *if_addr,
static void lwip_socket_drop_registered_memberships(int s);
#endif /* LWIP_IGMP */
#ifdef LWIP_ESP8266
#if ESP_LWIP
#include "esp_wifi_internal.h"
#include "esp_system.h"
@ -414,7 +409,7 @@ static inline void esp32_tx_flow_ctrl(void)
/** The global array of available sockets */
static struct lwip_sock sockets[NUM_SOCKETS];
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
static bool sockets_init_flag = false;
#endif
/** The global list of tasks waiting for select */
@ -425,13 +420,7 @@ static volatile int select_cb_ctr;
/** Table to quickly map an lwIP error (err_t) to a socket error
* by using -err as an index */
#ifdef LWIP_ESP8266
//TO_DO
//static const int err_to_errno_table[] ICACHE_RODATA_ATTR STORE_ATTR = {
static const int err_to_errno_table[] = {
#else
static const int err_to_errno_table[] = {
#endif
0, /* ERR_OK 0 No error, everything OK. */
ENOMEM, /* ERR_MEM -1 Out of memory error. */
ENOBUFS, /* ERR_BUF -2 Buffer error. */
@ -442,7 +431,7 @@ static const int err_to_errno_table[] = {
EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */
EADDRINUSE, /* ERR_USE -8 Address in use. */
#ifdef LWIP_ESP8266
#if ESP_LWIP
EALREADY, /* ERR_ALREADY -9 Already connected. */
EISCONN, /* ERR_ISCONN -10 Conn already established */
ECONNABORTED, /* ERR_ABRT -11 Connection aborted. */
@ -583,7 +572,7 @@ alloc_socket(struct netconn *newconn, int accepted)
int i;
SYS_ARCH_DECL_PROTECT(lev);
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
bool found = false;
int oldest = -1;
@ -639,16 +628,16 @@ alloc_socket(struct netconn *newconn, int accepted)
if (!sockets[oldest].lock){
/* one time init and never free */
if (sys_mutex_new(&sockets[oldest].lock) != ERR_OK){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("new sock lock fail\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("new sock lock fail\n"));
return -1;
}
}
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("alloc_socket: alloc %d ok\n", oldest));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("alloc_socket: alloc %d ok\n", oldest));
return oldest + LWIP_SOCKET_OFFSET;
}
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("alloc_socket: failed\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("alloc_socket: failed\n"));
#else
@ -693,12 +682,12 @@ free_socket(struct lwip_sock *sock, int is_tcp)
void *lastdata;
SYS_ARCH_DECL_PROTECT(lev);
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("free_sockset:free socket s=%p is_tcp=%d\n", sock, is_tcp));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("free_sockset:free socket s=%p is_tcp=%d\n", sock, is_tcp));
lastdata = sock->lastdata;
sock->lastdata = NULL;
sock->lastoffset = 0;
sock->err = 0;
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
if (sock->conn){
netconn_free(sock->conn);
}
@ -716,10 +705,10 @@ free_socket(struct lwip_sock *sock, int is_tcp)
if (lastdata != NULL) {
if (is_tcp) {
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("free_sockset:free lastdata pbuf=%p\n", lastdata));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("free_sockset:free lastdata pbuf=%p\n", lastdata));
pbuf_free((struct pbuf *)lastdata);
} else {
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("free_sockset:free lastdata, netbuf=%p\n", lastdata));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("free_sockset:free lastdata, netbuf=%p\n", lastdata));
netbuf_delete((struct netbuf *)lastdata);
}
}
@ -872,19 +861,19 @@ lwip_close(int s)
int is_tcp = 0;
err_t err;
LWIP_DEBUGF(SOCKETS_DEBUG|THREAD_SAFE_DEBUG, ("lwip_close: (%d)\n", s));
LWIP_DEBUGF(SOCKETS_DEBUG|ESP_THREAD_SAFE_DEBUG, ("lwip_close: (%d)\n", s));
sock = get_socket(s);
if (!sock) {
LWIP_DEBUGF(SOCKETS_DEBUG|THREAD_SAFE_DEBUG, ("lwip_close: sock is null, return -1\n"));
LWIP_DEBUGF(SOCKETS_DEBUG|ESP_THREAD_SAFE_DEBUG, ("lwip_close: sock is null, return -1\n"));
return -1;
}
if (sock->conn != NULL) {
is_tcp = NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP;
LWIP_DEBUGF(SOCKETS_DEBUG|THREAD_SAFE_DEBUG, ("lwip_close: is_tcp=%d\n", is_tcp));
LWIP_DEBUGF(SOCKETS_DEBUG|ESP_THREAD_SAFE_DEBUG, ("lwip_close: is_tcp=%d\n", is_tcp));
} else {
LWIP_DEBUGF(SOCKETS_DEBUG|THREAD_SAFE_DEBUG, ("conn is null\n"));
LWIP_DEBUGF(SOCKETS_DEBUG|ESP_THREAD_SAFE_DEBUG, ("conn is null\n"));
LWIP_ASSERT("lwip_close: sock->lastdata == NULL", sock->lastdata == NULL);
}
@ -895,12 +884,12 @@ lwip_close(int s)
err = netconn_delete(sock->conn);
if (err != ERR_OK) {
LWIP_DEBUGF(SOCKETS_DEBUG|THREAD_SAFE_DEBUG, ("netconn_delete fail, ret=%d\n", err));
LWIP_DEBUGF(SOCKETS_DEBUG|ESP_THREAD_SAFE_DEBUG, ("netconn_delete fail, ret=%d\n", err));
sock_set_errno(sock, err_to_errno(err));
return -1;
}
#if !LWIP_THREAD_SAFE
#if !ESP_THREAD_SAFE
free_socket(sock, is_tcp);
#endif
@ -1130,22 +1119,13 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
ip_addr_debug_print(SOCKETS_DEBUG, fromaddr);
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off));
#ifdef LWIP_ESP8266
if (from && fromlen)
#else
#if SOCKETS_DEBUG
if (from && fromlen)
#endif /* SOCKETS_DEBUG */
#endif
{
if (*fromlen > saddr.sa.sa_len) {
*fromlen = saddr.sa.sa_len;
}
MEMCPY(from, &saddr, *fromlen);
#ifdef LWIP_ESP8266
#if ESP_LWIP
} else {
/*fix the code for setting the UDP PROTO's remote infomation by liuh at 2014.8.27*/
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_UDP){
@ -1437,7 +1417,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
SOCKADDR_TO_IPADDR_PORT(to, &buf.addr, remote_port);
} else {
#ifdef LWIP_ESP8266
#if ESP_LWIP
/*fix the code for getting the UDP proto's remote information by liuh at 2014.8.27*/
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_UDP){
if(NETCONNTYPE_ISIPV6(netconn_type(sock->conn))) {
@ -1453,7 +1433,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
#endif
remote_port = 0;
ip_addr_set_any(NETCONNTYPE_ISIPV6(netconn_type(sock->conn)), &buf.addr);
#ifdef LWIP_ESP8266
#if ESP_LWIP
}
#endif
@ -1986,7 +1966,7 @@ again:
int
lwip_shutdown(int s, int how)
{
#ifndef LWIP_ESP8266
#if ! ESP_LWIP
struct lwip_sock *sock;
err_t err;
@ -3126,7 +3106,7 @@ static void lwip_socket_drop_registered_memberships(int s)
}
#endif /* LWIP_IGMP */
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
int
lwip_sendto_r(int s, const void *data, size_t size, int flags,

View File

@ -50,18 +50,13 @@
#include "lwip/pbuf.h"
#include "netif/etharp.h"
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#define TCPIP_MSG_VAR_REF(name) API_VAR_REF(name)
#define TCPIP_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct tcpip_msg, name)
#define TCPIP_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct tcpip_msg, MEMP_TCPIP_MSG_API, name)
#define TCPIP_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_TCPIP_MSG_API, name)
/* global variables */
#ifdef PERF
#if ESP_PERF
uint32_t g_rx_post_mbox_fail_cnt = 0;
#endif
static tcpip_init_done_fn tcpip_init_done;
@ -144,13 +139,11 @@ tcpip_thread(void *arg)
case TCPIP_MSG_INPKT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg));
#ifdef LWIP_ESP8266
//#if 0
#if ESP_LWIP
if(msg->msg.inp.p != NULL && msg->msg.inp.netif != NULL) {
#endif
msg->msg.inp.input_fn(msg->msg.inp.p, msg->msg.inp.netif);
#ifdef LWIP_ESP8266
//#if 0
#if ESP_LWIP
}
#endif
@ -230,7 +223,7 @@ tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
msg->msg.inp.netif = inp;
msg->msg.inp.input_fn = input_fn;
if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
#ifdef PERF
#if ESP_PERF
g_rx_post_mbox_fail_cnt ++;
#endif
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
@ -503,7 +496,7 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
#endif /* LWIP_TCPIP_CORE_LOCKING */
#ifdef LWIP_ESP8266
#if ESP_LWIP
sys_thread_t xLwipTaskHandle = sys_thread_new(TCPIP_THREAD_NAME
, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
@ -548,8 +541,7 @@ pbuf_free_callback(struct pbuf *p)
* @return ERR_OK if callback could be enqueued, an err_t if not
*/
#ifdef LWIP_ESP8266
//#if 0
#if ESP_LWIP
static void mem_free_local(void *arg)
{
mem_free(arg);

View File

@ -24,7 +24,7 @@
#include "apps/dhcpserver.h"
#ifdef LWIP_ESP8266
#if ESP_DHCP
#define BOOTP_BROADCAST 0x8000
@ -71,10 +71,6 @@
#define DHCPS_STATE_IDLE 5
#define DHCPS_STATE_RELEASE 6
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////////////
static const u32_t magic_cookie = 0x63538263;

View File

@ -85,10 +85,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** Random generator function to create random TXIDs and source ports for queries */
#ifndef DNS_RAND_TXID
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_XID) != 0)
@ -1091,7 +1087,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
u8_t dns_err;
/* This entry is now completed. */
#ifndef LWIP_ESP8266
#if ! ESP_DNS
entry->state = DNS_STATE_DONE;
#endif
dns_err = hdr.flags2 & DNS_FLAG2_ERR_MASK;
@ -1105,7 +1101,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
if (((hdr.flags1 & DNS_FLAG1_RESPONSE) == 0) || (dns_err != 0) || (nquestions != 1)) {
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", entry->name));
/* call callback to indicate error, clean up memory and return */
#ifndef LWIP_ESP8266
#if ! ESP_DNS
goto responseerr;
}
#else

View File

@ -61,7 +61,7 @@
#include "lwip/api.h"
#include "netif/ppp/ppp_impl.h"
#ifndef PERF
#if ! ESP_PERF
/* Compile-time sanity checks for configuration errors.
* These can be done independently of LWIP_DEBUG, without penalty.
*/
@ -313,7 +313,7 @@
#error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif
#ifndef LWIP_ESP8266
#if ! ESP_LWIP
#if !MEMP_MEM_MALLOC && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))))
#error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif

View File

@ -76,11 +76,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/* 169.254.0.0 */
#define AUTOIP_NET 0xA9FE0000
/* 169.254.1.0 */

View File

@ -82,10 +82,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** DHCP_CREATE_RAND_XID: if this is set to 1, the xid is created using
* LWIP_RAND() (this overrides DHCP_GLOBAL_XID)
*/
@ -146,7 +142,7 @@ static u8_t dhcp_discover_select_options[] = {
DHCP_OPTION_BROADCAST,
DHCP_OPTION_DNS_SERVER
#ifdef LWIP_ESP8266
#if ESP_DHCP
/**add options for support more router by liuHan**/
, DHCP_OPTION_DOMAIN_NAME,
DHCP_OPTION_NB_TINS,
@ -454,7 +450,7 @@ dhcp_fine_tmr(void)
/* only act on DHCP configured interfaces */
if (netif->dhcp != NULL) {
//#ifdef LWIP_ESP8266
//#if ESP_DHCP
/*add DHCP retries processing by LiuHan*/
#if 0
if (DHCP_MAXRTX != 0) {
@ -997,7 +993,7 @@ dhcp_discover(struct netif *netif)
dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN);
dhcp_option_short(dhcp, DHCP_MAX_MSG_LEN(netif));
#ifdef LWIP_ESP8266
#if ESP_DHCP
#if LWIP_NETIF_HOSTNAME
dhcp_option_hostname(dhcp, netif);
#endif /* LWIP_NETIF_HOSTNAME */

View File

@ -51,11 +51,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** Small optimization: set to 0 if incoming PBUF_POOL pbuf always can be
* used to modify and send a response packet (and to 1 if this is not the case,
* e.g. when link header is stripped of when receiving) */

View File

@ -92,11 +92,6 @@ Steve Reynolds
#include "string.h"
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/*
* IGMP constants
*/

View File

@ -59,11 +59,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** Set this to 0 in the rare case of wanting to call an extra function to
* generate the IP checksum (in contrast to calculating it on-the-fly). */
#ifndef LWIP_INLINE_IP_CHKSUM
@ -150,7 +145,7 @@ ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
struct netif *
ip4_route(const ip4_addr_t *dest)
{
#ifdef LWIP_ESP8266
#if ESP_LWIP
struct netif *non_default_netif = NULL;
#endif
struct netif *netif;
@ -183,7 +178,7 @@ ip4_route(const ip4_addr_t *dest)
}
}
#ifdef LWIP_ESP8266
#if ESP_LWIP
if (non_default_netif && !ip4_addr_isbroadcast(dest, non_default_netif)){
return non_default_netif;
}

View File

@ -45,17 +45,8 @@
/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */
#ifdef LWIP_ESP8266
//TO_DO
//const ip_addr_t ip_addr_any ICACHE_RODATA_ATTR STORE_ATTR = IPADDR4_INIT(IPADDR_ANY);
//const ip_addr_t ip_addr_broadcast ICACHE_RODATA_ATTR STORE_ATTR = IPADDR4_INIT(IPADDR_BROADCAST);
const ip_addr_t ip_addr_any = IPADDR4_INIT(IPADDR_ANY);
const ip_addr_t ip_addr_broadcast = IPADDR4_INIT(IPADDR_BROADCAST);
#else
const ip_addr_t ip_addr_any = IPADDR4_INIT(IPADDR_ANY);
const ip_addr_t ip_addr_broadcast = IPADDR4_INIT(IPADDR_BROADCAST);
#endif
/**
* Determine if an address is a broadcast address on a network interface
@ -170,7 +161,7 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
u32_t parts[4];
u32_t *pp = parts;
#ifdef LWIP_ESP8266
#if ESP_LWIP
//#if 0
char ch;
unsigned long cutoff;
@ -199,8 +190,7 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
}
}
#ifdef LWIP_ESP8266
//#if 0
#if ESP_IP4_ATON
cutoff =(unsigned long)0xffffffff / (unsigned long)base;
cutlim =(unsigned long)0xffffffff % (unsigned long)base;
for (;;) {

View File

@ -51,11 +51,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#if IP_REASSEMBLY
/**
* The IP reassembly code currently has the following limitations:

View File

@ -56,10 +56,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#ifndef LWIP_ICMP6_DATASIZE
#define LWIP_ICMP6_DATASIZE 8
#endif

View File

@ -59,10 +59,6 @@
#include "lwip/debug.h"
#include "lwip/stats.h"
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/**
* Finds the appropriate network interface for a given IPv6 address. It tries to select
* a netif following a sequence of heuristics:

View File

@ -52,11 +52,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */

View File

@ -59,11 +59,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/*
* MLD constants
*/

View File

@ -60,11 +60,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/* Router tables. */
struct nd6_neighbor_cache_entry neighbor_cache[LWIP_ND6_NUM_NEIGHBORS];
struct nd6_destination_cache_entry destination_cache[LWIP_ND6_NUM_DESTINATIONS];

View File

@ -65,10 +65,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#if MEM_USE_POOLS
#if MEMP_MEM_MALLOC

View File

@ -70,10 +70,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEMPOOL_DECLARE(name,num,size,desc)
#include "lwip/priv/memp_std.h"

View File

@ -81,10 +81,6 @@
#define NETIF_LINK_CALLBACK(n)
#endif /* LWIP_NETIF_LINK_CALLBACK */
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
struct netif *netif_list;
struct netif *netif_default;
@ -220,7 +216,7 @@ netif_add(struct netif *netif,
/* netif not under DHCP control by default */
netif->dhcp = NULL;
#ifdef LWIP_ESP8266
#if ESP_DHCP
netif->dhcps_pcb = NULL;
#endif
@ -233,8 +229,7 @@ netif_add(struct netif *netif,
#endif /* LWIP_AUTOIP */
#if LWIP_IPV6_AUTOCONFIG
#ifdef LWIP_ESP8266
//#if 0
#if ESP_IPV6_AUTOCONFIG
netif->ip6_autoconfig_enabled = 1;
#else
/* IPv6 address autoconfiguration not enabled by default */
@ -973,7 +968,7 @@ netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
}
}
#ifdef LWIP_ESP8266
#if ESP_LWIP
ip6_addr_set( ip_2_ip6(&netif->link_local_addr), ip_2_ip6(&netif->ip6_addr[0]) );
#endif
@ -1028,7 +1023,7 @@ netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chos
}
#ifdef LWIP_ESP8266
#if ESP_LWIP
void
netif_create_ip4_linklocal_address(struct netif * netif)
{

View File

@ -78,13 +78,8 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#ifdef LWIP_ESP8266
#if ESP_LWIP
#include "esp_wifi_internal.h"
#define EP_OFFSET 0
#endif
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
@ -208,12 +203,7 @@ struct pbuf *
pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
{
struct pbuf *p, *q, *r;
#ifdef LWIP_ESP8266
u16_t offset = 0;
#else
u16_t offset;
#endif
u16_t offset = 0;
s32_t rem_len; /* remaining length */
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F")\n", length));
@ -224,48 +214,16 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
/* add room for transport (often TCP) layer header */
offset = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN;
#ifdef LWIP_ESP8266 //TO_DO
offset += EP_OFFSET;
#endif
break;
case PBUF_IP:
/* add room for IP layer header */
offset = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN;
#ifdef LWIP_ESP8266 //TO_DO
offset += EP_OFFSET;
#endif
break;
case PBUF_LINK:
/* add room for link layer header */
offset = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN;
#ifdef LWIP_ESP8266 //TO_DO
/*
* 1. LINK_HLEN 14Byte will be remove in WLAN layer
* 2. IEEE80211_HDR_MAX_LEN needs 40 bytes.
* 3. encryption needs exra 4 bytes ahead of actual data payload, and require
* DAddr and SAddr to be 4-byte aligned.
* 4. TRANSPORT and IP are all 20, 4 bytes aligned, nice...
* 5. LCC add 6 bytes more, We don't consider WAPI yet...
* 6. define LWIP_MEM_ALIGN to be 4 Byte aligned, pbuf struct is 16B, Only thing may be
* matter is ether_hdr is not 4B aligned.
*
* So, we need extra (40 + 4 - 14) = 30 and it's happen to be 4-Byte aligned
*
* 1. lwip
* | empty 30B | eth_hdr (14B) | payload ...|
* total: 44B ahead payload
* 2. net80211
* | max 80211 hdr, 32B | ccmp/tkip iv (8B) | sec rsv(4B) | payload ...|
* total: 40B ahead sec_rsv and 44B ahead payload
*
*/
offset += EP_OFFSET; //remove LINK hdr in wlan
#endif
break;
case PBUF_RAW_TX:
/* add room for encapsulating link layer headers (e.g. 802.11) */
@ -274,10 +232,6 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
case PBUF_RAW:
offset = 0;
#ifdef LWIP_ESP8266 //TO_DO
offset += EP_OFFSET;
#endif
break;
default:
LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0);
@ -396,9 +350,10 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
/* set flags */
p->flags = 0;
#ifdef LWIP_ESP8266
#if ESP_LWIP
p->eb = NULL;
#endif
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
return p;
}
@ -764,7 +719,7 @@ pbuf_free(struct pbuf *p)
/* is this a ROM or RAM referencing pbuf? */
} else if (type == PBUF_ROM || type == PBUF_REF) {
#ifdef LWIP_ESP8266
#if ESP_LWIP
if (type == PBUF_REF && p->eb != NULL ) esp_wifi_internal_free_rx_buffer(p->eb);
#endif

View File

@ -54,10 +54,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** The list of RAW PCBs */
static struct raw_pcb *raw_pcbs;

View File

@ -47,10 +47,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
struct stats_ lwip_stats;
#if defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY

View File

@ -57,10 +57,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#ifndef TCP_LOCAL_PORT_RANGE_START
/* From http://www.iana.org/assignments/port-numbers:
"The Dynamic and/or Private Ports are those from 49152 through 65535" */
@ -77,14 +73,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#define TCP_KEEP_INTVL(pcb) TCP_KEEPINTVL_DEFAULT
#endif /* LWIP_TCP_KEEPALIVE */
#ifdef LWIP_ESP8266
//TO_DO
//char tcp_state_str[12];
//const char tcp_state_str_rodata[][12] ICACHE_RODATA_ATTR STORE_ATTR = {
const char * const tcp_state_str[] = {
#else
const char * const tcp_state_str[] = {
#endif
"CLOSED",
"LISTEN",
"SYN_SENT",
@ -100,27 +89,14 @@ const char * const tcp_state_str[] = {
/* last local TCP port */
#ifdef LWIP_ESP8266
static s16_t tcp_port = TCP_LOCAL_PORT_RANGE_START;
#else
static u16_t tcp_port = TCP_LOCAL_PORT_RANGE_START;
#endif
/* Incremented every coarse grained timer shot (typically every 500 ms). */
u32_t tcp_ticks;
#ifdef LWIP_ESP8266
//TO_DO
//const u8_t tcp_backoff[13] ICACHE_RODATA_ATTR STORE_ATTR ={ 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};
//const u8_t tcp_persist_backoff[7] ICACHE_RODATA_ATTR STORE_ATTR = { 3, 6, 12, 24, 48, 96, 120 };
const u8_t tcp_backoff[13] = { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};
const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 };
#else
const u8_t tcp_backoff[13] = { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};
/* Times per slowtmr hits */
const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 };
#endif
/* The TCP PCB lists. */
@ -136,19 +112,9 @@ struct tcp_pcb *tcp_active_pcbs;
struct tcp_pcb *tcp_tw_pcbs;
/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */
#ifdef LWIP_ESP8266
//TO_DO
//struct tcp_pcb ** const tcp_pcb_lists[] ICACHE_RODATA_ATTR STORE_ATTR = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
// &tcp_active_pcbs, &tcp_tw_pcbs};
struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
&tcp_active_pcbs, &tcp_tw_pcbs};
#else
struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
&tcp_active_pcbs, &tcp_tw_pcbs};
#endif
u8_t tcp_active_pcbs_changed;
/** Timer counter to handle calling slow-timer from tcp_tmr() */
@ -720,7 +686,7 @@ tcp_new_port(void)
again:
#ifdef LWIP_ESP8266
#if ESP_RANDOM_TCP_PORT
tcp_port = system_get_time();
if (tcp_port < 0)
tcp_port = LWIP_RAND() - tcp_port;
@ -915,13 +881,7 @@ tcp_slowtmr_start:
/* If snd_wnd is zero, use persist timer to send 1 byte probes
* instead of using the standard retransmission mechanism. */
#ifdef LWIP_ESP8266
//NEED TO DO
//u8_t backoff_cnt = system_get_data_of_array_8(tcp_persist_backoff, pcb->persist_backoff-1);
u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff-1];
#else
u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff-1];
#endif
if (pcb->persist_cnt < backoff_cnt) {
pcb->persist_cnt++;
@ -949,15 +909,7 @@ tcp_slowtmr_start:
/* Double retransmission time-out unless we are trying to
* connect to somebody (i.e., we are in SYN_SENT). */
if (pcb->state != SYN_SENT) {
#ifdef LWIP_ESP8266
//TO_DO
// pcb->rto = ((pcb->sa >> 3) + pcb->sv) << system_get_data_of_array_8(tcp_backoff, pcb->nrtx);
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
#else
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx];
#endif
}
/* Reset the retransmission timer. */
@ -1436,7 +1388,7 @@ tcp_kill_timewait(void)
}
}
#ifdef LWIP_ESP8266
#if ESP_LWIP
/**
* Kills the oldest connection that is in FIN_WAIT_2 state.
* Called from tcp_alloc() if no more connections are available.
@ -1502,7 +1454,7 @@ tcp_alloc(u8_t prio)
struct tcp_pcb *pcb;
u32_t iss;
#ifdef LWIP_ESP8266
#if ESP_LWIP
/*Kills the oldest connection that is in TIME_WAIT state.*/
u8_t time_wait_num = 0;
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
@ -2015,14 +1967,7 @@ void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* n
const char*
tcp_debug_state_str(enum tcp_state s)
{
#ifdef LWIP_ESP8266
//TO_DO
//system_get_string_from_flash(tcp_state_str_rodata[s], tcp_state_str, 12);
//return tcp_state_str;
return tcp_state_str[s];
#else
return tcp_state_str[s];
#endif
}
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG

View File

@ -60,11 +60,6 @@
#include "lwip/nd6.h"
#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** Initial CWND calculation as defined RFC 2581 */
#define LWIP_TCP_CALC_INITIAL_CWND(mss) LWIP_MIN((4U * (mss)), LWIP_MAX((2U * (mss)), 4380U));
/** Initial slow start threshold value: we use the full window */
@ -329,20 +324,6 @@ tcp_input(struct pbuf *p, struct netif *inp)
if (pcb != NULL) {
#ifdef LWIP_ESP8266
//No Need Any more
/*
extern char RxNodeNum(void);
if(RxNodeNum() <= 2)
{
extern void pbuf_free_ooseq(void);
pbuf_free_ooseq();
}
*/
#endif
/* The incoming segment belongs to a connection. */
#if TCP_INPUT_DEBUG
tcp_debug_print_state(pcb->state);

View File

@ -59,10 +59,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/* Define some copy-macros for checksum-on-copy so that the code looks
nicer by preventing too many ifdef's. */
#if TCP_CHECKSUM_ON_COPY

View File

@ -62,11 +62,6 @@
#include "lwip/sys.h"
#include "lwip/pbuf.h"
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
/** The one and only timeout list */
static struct sys_timeo *next_timeout;
#if NO_SYS
@ -162,7 +157,7 @@ dhcp_timer_coarse(void *arg)
LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_coarse_tmr()\n"));
dhcp_coarse_tmr();
#ifdef LWIP_ESP8266
#if ESP_DHCP
extern void dhcps_coarse_tmr(void);
dhcps_coarse_tmr();
#endif
@ -294,12 +289,6 @@ void sys_timeouts_init(void)
#endif /* LWIP_ARP */
#if LWIP_DHCP
#ifdef LWIP_ESP8266
// DHCP_MAXRTX = 0;
#endif
sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL);
sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL);
#endif /* LWIP_DHCP */
@ -346,7 +335,7 @@ void
sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name)
#else /* LWIP_DEBUG_TIMERNAMES */
#ifdef LWIP_ESP8266
#if ESP_LIGHT_SLEEP
u32_t LwipTimOutLim = 0; // For light sleep. time out. limit is 3000ms
#endif
@ -379,7 +368,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)
timeout->h = handler;
timeout->arg = arg;
#ifdef LWIP_ESP8266
#if ESP_LIGHT_SLEEP
if(msecs < LwipTimOutLim)
msecs = LwipTimOutLim;
#endif

View File

@ -67,11 +67,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#ifndef UDP_LOCAL_PORT_RANGE_START
/* From http://www.iana.org/assignments/port-numbers:
"The Dynamic and/or Private Ports are those from 49152 through 65535" */

View File

@ -185,10 +185,6 @@ struct netconn {
/** sem that is used to synchronously execute functions in the core context */
sys_sem_t op_completed;
#ifdef LWIP_ESP8266
sys_sem_t snd_op_completed; //only for snd semphore
#endif
#endif
/** mbox where received packets are stored until they are fetched

View File

@ -249,7 +249,7 @@ void dhcp_fine_tmr(void);
#define DHCP_OPTION_NTP 42
#define DHCP_OPTION_END 255
#ifdef LWIP_ESP8266
#if ESP_LWIP
/**add options for support more router by liuHan**/
#define DHCP_OPTION_DOMAIN_NAME 15
#define DHCP_OPTION_PRD 31

View File

@ -36,7 +36,7 @@
#include "lwip/opt.h"
#ifdef LWIP_ESP8266
#if ESP_DNS
#include "lwip/err.h"
#endif

View File

@ -60,7 +60,7 @@ typedef s8_t err_t;
#define ERR_USE -8 /* Address in use. */
#ifdef LWIP_ESP8266
#if ESP_LWIP
#define ERR_ALREADY -9 /* Already connected. */
#define ERR_ISCONN -10 /* Conn already established.*/
#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN)

View File

@ -51,8 +51,6 @@ typedef size_t mem_size_t;
* allow these defines to be overridden.
*/
#ifndef MEMLEAK_DEBUG
#ifndef mem_free
#define mem_free free
#endif
@ -63,41 +61,6 @@ typedef size_t mem_size_t;
#define mem_calloc calloc
#endif
/* DYC_NEED_TO_DO_LATER
#ifndef mem_realloc
#define mem_realloc
#endif
#ifndef mem_zalloc
#define mem_zalloc
#endif
*/
#else
/*
#ifndef mem_free
#define mem_free(s) \
do{\
const char *file = mem_debug_file;\
vPortFree(s, file, __LINE__);\
}while(0)
#endif
#ifndef mem_malloc
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#endif
#ifndef mem_calloc
#define mem_calloc(s) ({const char *file = mem_debug_file; pvPortCalloc(s, file, __LINE__);})
#endif
#ifndef mem_realloc
#define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
#endif
#ifndef mem_zalloc
#define mem_zalloc(s) ({const char *file = mem_debug_file; pvPortZalloc(s, file, __LINE__);})
#endif
*/
#endif
/* Since there is no C library allocation function to shrink memory without
moving it, define this to nothing. */
#ifndef mem_trim

View File

@ -177,7 +177,7 @@ typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif,
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
#ifdef LWIP_ESP8266
#if ESP_DHCP
/*add DHCP event processing by LiuHan*/
typedef void (*dhcp_event_fn)(void);
#endif
@ -190,7 +190,7 @@ struct netif {
/** pointer to next in linked list */
struct netif *next;
#ifdef LWIP_ESP8266
#if ESP_LWIP
//ip_addr_t is changed by marco IPV4, IPV6
ip_addr_t link_local_addr;
#endif
@ -248,7 +248,7 @@ struct netif {
/** the DHCP client state information for this netif */
struct dhcp *dhcp;
#ifdef LWIP_ESP8266
#if ESP_LWIP
struct udp_pcb *dhcps_pcb;
dhcp_event_fn dhcp_event;
#endif

View File

@ -3008,8 +3008,8 @@
#define LWIP_PERF 0
#endif
#ifndef THREAD_SAFE_DEBUG
#define THREAD_SAFE_DEBUG 0
#ifndef ESP_THREAD_SAFE_DEBUG
#define ESP_THREAD_SAFE_DEBUG 0
#endif
#endif /* LWIP_HDR_OPT_H */

View File

@ -137,7 +137,7 @@ struct pbuf {
*/
u16_t ref;
#ifdef LWIP_ESP8266
#if ESP_LWIP
void *eb;
#endif
};

View File

@ -187,7 +187,7 @@ struct dns_api_msg {
#endif /* LWIP_DNS */
#if LWIP_NETCONN_SEM_PER_THREAD
#ifdef LWIP_ESP8266
#if ESP_THREAD_SAFE
#define LWIP_NETCONN_THREAD_SEM_GET() sys_thread_sem_get()
#define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_thread_sem_init()
#define LWIP_NETCONN_THREAD_SEM_FREE() sys_thread_sem_deinit()
@ -222,10 +222,6 @@ struct dns_api_msg {
#define TCPIP_APIMSG(m,f,e) do { (m)->function = f; (e) = tcpip_apimsg(m); } while(0)
#define TCPIP_APIMSG_ACK(m) do { NETCONN_SET_SAFE_ERR((m)->conn, (m)->err); sys_sem_signal(LWIP_API_MSG_SEM(m)); } while(0)
#ifdef LWIP_ESP8266
#define TCPIP_APIMSG_ACK_SND(m) do { NETCONN_SET_SAFE_ERR((m)->conn, (m)->err); sys_sem_signal(LWIP_API_MSG_SND_SEM(m)); } while(0)
#endif
#endif /* LWIP_TCPIP_CORE_LOCKING */
void lwip_netconn_do_newconn (void *m);

View File

@ -509,7 +509,7 @@ int lwip_fcntl(int s, int cmd, int val);
#if LWIP_COMPAT_SOCKETS
#if LWIP_COMPAT_SOCKETS != 2
#if LWIP_THREAD_SAFE
#if ESP_THREAD_SAFE
int lwip_accept_r(int s, struct sockaddr *addr, socklen_t *addrlen);
int lwip_bind_r(int s, const struct sockaddr *name, socklen_t namelen);
@ -594,7 +594,7 @@ int lwip_fcntl_r(int s, int cmd, int val);
#define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val)
#define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp)
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
#endif /* LWIP_THREAD_SAFE */
#endif /* ESP_THREAD_SAFE */
#endif /* LWIP_COMPAT_SOCKETS != 2 */

View File

@ -37,7 +37,6 @@
#include "sdkconfig.h"
/* Enable all Espressif-only options */
#define LWIP_ESP8266
/*
-----------------------------------------------
@ -510,14 +509,42 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
*/
#define TCPIP_DEBUG LWIP_DBG_OFF
/* Enable all Espressif-only options */
#define ESP_LWIP 1
#define ESP_PER_SOC_TCP_WND 1
#define ESP_THREAD_SAFE 1
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
#define ESP_DHCP 1
#define ESP_DNS 1
#define ESP_IPV6_AUTOCONFIG 1
#define ESP_PERF 0
#define ESP_RANDOM_TCP_PORT 1
#define ESP_IP4_ATON 1
#define ESP_LIGHT_SLEEP 1
#if ESP_PER_SOC_TCP_WND
#define TCP_WND_DEFAULT (4*TCP_MSS)
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
#else
#if ESP_PERF
extern unsigned char misc_prof_get_tcpw(void);
extern unsigned char misc_prof_get_tcp_snd_buf(void);
#define TCP_WND(pcb) (misc_prof_get_tcpw()*TCP_MSS)
#define TCP_SND_BUF(pcb) (misc_prof_get_tcp_snd_buf()*TCP_MSS)
#endif
#endif
/**
* DHCP_DEBUG: Enable debugging in dhcp.c.
*/
#define DHCP_DEBUG LWIP_DBG_OFF
#define LWIP_DEBUG 0
#define TCP_DEBUG LWIP_DBG_OFF
#define THREAD_SAFE_DEBUG LWIP_DBG_OFF
#define LWIP_THREAD_SAFE 1
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_IP 0

View File

@ -55,10 +55,6 @@
#include <string.h>
#ifdef MEMLEAK_DEBUG
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
/** Re-request a used ARP entry 1 minute before it would expire to prevent

View File

@ -56,7 +56,7 @@ sys_mutex_new(sys_mutex_t *pxMutex)
xReturn = ERR_OK;
}
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mutex_new: m=%p\n", *pxMutex));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mutex_new: m=%p\n", *pxMutex));
return xReturn;
}
@ -89,7 +89,7 @@ sys_mutex_unlock(sys_mutex_t *pxMutex)
void
sys_mutex_free(sys_mutex_t *pxMutex)
{
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mutex_free: m=%p\n", *pxMutex));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mutex_free: m=%p\n", *pxMutex));
vQueueDelete(*pxMutex);
}
#endif
@ -192,20 +192,20 @@ sys_mbox_new(sys_mbox_t *mbox, int size)
{
*mbox = malloc(sizeof(struct sys_mbox_s));
if (*mbox == NULL){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("fail to new *mbox\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("fail to new *mbox\n"));
return ERR_MEM;
}
(*mbox)->os_mbox = xQueueCreate(size, sizeof(void *));
if ((*mbox)->os_mbox == NULL) {
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("fail to new *mbox->os_mbox\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("fail to new *mbox->os_mbox\n"));
free(*mbox);
return ERR_MEM;
}
if (sys_mutex_new(&((*mbox)->lock)) != ERR_OK){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("fail to new *mbox->lock\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("fail to new *mbox->lock\n"));
vQueueDelete((*mbox)->os_mbox);
free(*mbox);
return ERR_MEM;
@ -213,7 +213,7 @@ sys_mbox_new(sys_mbox_t *mbox, int size)
(*mbox)->alive = true;
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("new *mbox ok mbox=%p os_mbox=%p mbox_lock=%p\n", *mbox, (*mbox)->os_mbox, (*mbox)->lock));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("new *mbox ok mbox=%p os_mbox=%p mbox_lock=%p\n", *mbox, (*mbox)->os_mbox, (*mbox)->lock));
return ERR_OK;
}
@ -234,7 +234,7 @@ sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
if (xQueueSend((*mbox)->os_mbox, &msg, (portTickType)0) == pdPASS) {
xReturn = ERR_OK;
} else {
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("trypost mbox=%p fail\n", (*mbox)->os_mbox));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("trypost mbox=%p fail\n", (*mbox)->os_mbox));
xReturn = ERR_MEM;
}
@ -271,7 +271,7 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
if (*mbox == NULL){
*msg = NULL;
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch: null mbox\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch: null mbox\n"));
return -1;
}
@ -294,14 +294,14 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
} else { // block forever for a message.
while (1){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch: fetch mbox=%p os_mbox=%p lock=%p\n", mbox, (*mbox)->os_mbox, (*mbox)->lock));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch: fetch mbox=%p os_mbox=%p lock=%p\n", mbox, (*mbox)->os_mbox, (*mbox)->lock));
if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), portMAX_DELAY)){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch:mbox rx msg=%p\n", (*msg)));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch:mbox rx msg=%p\n", (*msg)));
break;
}
if ((*mbox)->alive == false){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch:mbox not alive\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch:mbox not alive\n"));
*msg = NULL;
break;
}
@ -356,24 +356,24 @@ sys_mbox_free(sys_mbox_t *mbox)
uint16_t count = 0;
bool post_null = true;
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free: set alive false\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: set alive false\n"));
(*mbox)->alive = false;
while ( count++ < MAX_POLL_CNT ){ //ESP32_WORKAROUND
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free:try lock=%d\n", count));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free:try lock=%d\n", count));
if (!sys_mutex_trylock( &(*mbox)->lock )){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free:get lock ok %d\n", count));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free:get lock ok %d\n", count));
sys_mutex_unlock( &(*mbox)->lock );
break;
}
if (post_null){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free: post null to mbox\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null to mbox\n"));
if (sys_mbox_trypost( mbox, NULL) != ERR_OK){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox fail\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox fail\n"));
} else {
post_null = false;
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox ok\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox ok\n"));
}
}
@ -383,7 +383,7 @@ sys_mbox_free(sys_mbox_t *mbox)
sys_delay_ms(PER_POLL_DELAY);
}
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free:free mbox\n"));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free:free mbox\n"));
if (uxQueueMessagesWaiting((*mbox)->os_mbox)) {
xQueueReset((*mbox)->os_mbox);
@ -491,7 +491,7 @@ sys_sem_t* sys_thread_sem_get(void)
if (!sem){
sem = sys_thread_sem_init();
}
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sem_get s=%p\n", sem));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sem_get s=%p\n", sem));
return sem;
}
@ -500,12 +500,12 @@ static void sys_thread_tls_free(int index, void* data)
sys_sem_t *sem = (sys_sem_t*)(data);
if (sem && *sem){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sem del, i=%d sem=%p\n", index, *sem));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sem del, i=%d sem=%p\n", index, *sem));
vSemaphoreDelete(*sem);
}
if (sem){
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sem pointer del, i=%d sem_p=%p\n", index, sem));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sem pointer del, i=%d sem_p=%p\n", index, sem));
free(sem);
}
}
@ -526,7 +526,7 @@ sys_sem_t* sys_thread_sem_init(void)
return 0;
}
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sem init sem_p=%p sem=%p cb=%p\n", sem, *sem, sys_thread_tls_free));
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sem init sem_p=%p sem=%p cb=%p\n", sem, *sem, sys_thread_tls_free));
vTaskSetThreadLocalStoragePointerAndDelCallback(xTaskGetCurrentTaskHandle(), SYS_TLS_INDEX, sem, (TlsDeleteCallbackFunction_t)sys_thread_tls_free);
return sem;

View File

@ -56,16 +56,8 @@
#define IFNAME0 'e'
#define IFNAME1 'n'
#ifdef LWIP_ESP8266
//TO_DO
//char *hostname;
//bool default_hostname = 1;
static char hostname[16];
#else
static char hostname[16];
#endif
#ifdef PERF
#if ESP_PERF
uint32_t g_rx_alloc_pbuf_fail_cnt = 0;
#endif
@ -95,7 +87,7 @@ low_level_init(struct netif *netif)
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
#ifdef LWIP_ESP8266
#if ESP_LWIP
#if LWIP_IGMP
@ -133,7 +125,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
return ERR_IF;
}
#ifdef LWIP_ESP8266
#if ESP_LWIP
q = p;
u16_t pbuf_x_len = 0;
pbuf_x_len = q->len;
@ -172,7 +164,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
* @param netif the lwip network interface structure for this ethernetif
*/
void
#ifdef LWIP_ESP8266
#if ESP_LWIP
wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
#else
wlanif_input(struct netif *netif, void *buffer, uint16 len)
@ -180,17 +172,17 @@ wlanif_input(struct netif *netif, void *buffer, uint16 len)
{
struct pbuf *p;
#ifdef LWIP_ESP8266
#if ESP_LWIP
if(buffer== NULL)
goto _exit;
if(netif == NULL)
goto _exit;
#endif
#ifdef LWIP_ESP8266
#if ESP_LWIP
p = pbuf_alloc(PBUF_RAW, len, PBUF_REF);
if (p == NULL){
#ifdef PERF
#if ESP_PERF
g_rx_alloc_pbuf_fail_cnt++;
#endif
return;
@ -236,7 +228,7 @@ wlanif_init(struct netif *netif)
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
#ifdef LWIP_ESP8266
#if ESP_LWIP
//TO_DO
/*
if ((struct netif *)wifi_get_netif(STATION_IF) == netif) {