#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)
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
#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;
}
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;
#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
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),
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);
}
#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!
#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];
#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
/** 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.
SELWAIT_T select_waiting;
};
-#if LWIP_THREAD_SAFE
+#if ESP_THREAD_SAFE
#define LWIP_SOCK_OPEN 0
#define LWIP_SOCK_CLOSING 1
#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)
#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)
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;\
__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;\
}\
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"
/** 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 */
/** 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. */
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. */
int i;
SYS_ARCH_DECL_PROTECT(lev);
-#if LWIP_THREAD_SAFE
+#if ESP_THREAD_SAFE
bool found = false;
int oldest = -1;
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
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);
}
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);
}
}
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);
}
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
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){
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))) {
#endif
remote_port = 0;
ip_addr_set_any(NETCONNTYPE_ISIPV6(netconn_type(sock->conn)), &buf.addr);
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
}
#endif
int
lwip_shutdown(int s, int how)
{
-#ifndef LWIP_ESP8266
+#if ! ESP_LWIP
struct lwip_sock *sock;
err_t err;
}
#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,
#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;
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
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);
#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);
* @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);
#include "apps/dhcpserver.h"
-#ifdef LWIP_ESP8266
+#if ESP_DHCP
#define BOOTP_BROADCAST 0x8000
#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;
#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)
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;
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
#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.
*/
#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
#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 */
#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)
*/
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,
/* 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) {
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 */
#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) */
#include "string.h"
-#ifdef MEMLEAK_DEBUG
-static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
-#endif
-
-
/*
* IGMP constants
*/
#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
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;
}
}
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
if (non_default_netif && !ip4_addr_isbroadcast(dest, non_default_netif)){
return non_default_netif;
}
/* 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
u32_t parts[4];
u32_t *pp = parts;
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
//#if 0
char ch;
unsigned long cutoff;
}
}
-#ifdef LWIP_ESP8266
-//#if 0
+#if ESP_IP4_ATON
cutoff =(unsigned long)0xffffffff / (unsigned long)base;
cutlim =(unsigned long)0xffffffff % (unsigned long)base;
for (;;) {
#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:
#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
#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:
#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 */
#include <string.h>
-#ifdef MEMLEAK_DEBUG
-static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
-#endif
-
-
/*
* MLD constants
*/
#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];
#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
#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"
#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;
/* netif not under DHCP control by default */
netif->dhcp = NULL;
-#ifdef LWIP_ESP8266
+#if ESP_DHCP
netif->dhcps_pcb = NULL;
#endif
#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 */
}
}
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
ip6_addr_set( ip_2_ip6(&netif->link_local_addr), ip_2_ip6(&netif->ip6_addr[0]) );
#endif
}
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
void
netif_create_ip4_linklocal_address(struct netif * netif)
{
#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))
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));
/* 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) */
case PBUF_RAW:
offset = 0;
-#ifdef LWIP_ESP8266 //TO_DO
- offset += EP_OFFSET;
-#endif
-
break;
default:
LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0);
/* 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;
}
/* 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
#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;
#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
#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" */
#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",
/* 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. */
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() */
again:
-#ifdef LWIP_ESP8266
+#if ESP_RANDOM_TCP_PORT
tcp_port = system_get_time();
if (tcp_port < 0)
tcp_port = LWIP_RAND() - tcp_port;
/* 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++;
/* 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. */
}
}
-#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.
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) {
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
#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 */
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);
#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
#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
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
#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 */
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
timeout->h = handler;
timeout->arg = arg;
-#ifdef LWIP_ESP8266
+#if ESP_LIGHT_SLEEP
if(msecs < LwipTimOutLim)
msecs = LwipTimOutLim;
#endif
#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" */
/** 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
#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
#include "lwip/opt.h"
-#ifdef LWIP_ESP8266
+#if ESP_DNS
#include "lwip/err.h"
#endif
#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)
* allow these defines to be overridden.
*/
-#ifndef MEMLEAK_DEBUG
-
#ifndef mem_free
#define mem_free free
#endif
#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
#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
/** 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
/** 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
#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 */
*/
u16_t ref;
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
void *eb;
#endif
};
#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()
#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);
#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);
#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 */
#include "sdkconfig.h"
/* Enable all Espressif-only options */
-#define LWIP_ESP8266
/*
-----------------------------------------------
*/
#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
#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
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;
}
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
{
*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;
(*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;
}
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;
}
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;
}
} 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;
}
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"));
}
}
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);
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;
}
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);
}
}
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;
#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
/* 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
return ERR_IF;
}
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
q = p;
u16_t pbuf_x_len = 0;
pbuf_x_len = q->len;
* @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)
{
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;
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
-#ifdef LWIP_ESP8266
+#if ESP_LWIP
//TO_DO
/*
if ((struct netif *)wifi_get_netif(STATION_IF) == netif) {