Merge branch 'feature/lwip_2.1.2_idf' into 'master'

lwip_2.1.2 for idf_4.0

See merge request espressif/esp-idf!5374
This commit is contained in:
Jiang Jiang Jian 2019-07-07 13:33:41 +08:00
commit 274d7fe12a
21 changed files with 129 additions and 198 deletions

View File

@ -714,11 +714,6 @@ struct in6_pktinfo {
unsigned int ipi6_ifindex; /* send/recv interface index */ unsigned int ipi6_ifindex; /* send/recv interface index */
}; };
struct in_pktinfo {
int ipi_ifindex;
struct in_addr ipi_spec_dst;
struct in_addr ipi_addr;
};
#endif #endif
#if !defined(WITH_CONTIKI) && !defined(SOL_IP) #if !defined(WITH_CONTIKI) && !defined(SOL_IP)

View File

@ -27,7 +27,6 @@
#define HAVE_ARPA_INET_H #define HAVE_ARPA_INET_H
#define HAVE_TIME_H #define HAVE_TIME_H
#define IP_PKTINFO IP_MULTICAST_IF
#define IPV6_PKTINFO IPV6_V6ONLY #define IPV6_PKTINFO IPV6_V6ONLY
#define PACKAGE_NAME "libcoap-posix" #define PACKAGE_NAME "libcoap-posix"

View File

@ -553,16 +553,9 @@ int httpd_req_to_sockfd(httpd_req_t *r)
static int httpd_sock_err(const char *ctx, int sockfd) static int httpd_sock_err(const char *ctx, int sockfd)
{ {
int errval; int errval;
int sock_err; ESP_LOGW(TAG, LOG_FMT("error in %s : %d"), ctx, errno);
size_t sock_err_len = sizeof(sock_err);
if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &sock_err, &sock_err_len) < 0) { switch(errno) {
ESP_LOGE(TAG, LOG_FMT("error calling getsockopt : %d"), errno);
return HTTPD_SOCK_ERR_FAIL;
}
ESP_LOGW(TAG, LOG_FMT("error in %s : %d"), ctx, sock_err);
switch(sock_err) {
case EAGAIN: case EAGAIN:
case EINTR: case EINTR:
errval = HTTPD_SOCK_ERR_TIMEOUT; errval = HTTPD_SOCK_ERR_TIMEOUT;

View File

@ -15,9 +15,9 @@
#define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME 20000 #define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME 20000
#define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME_PSRAM 25000 #define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME_PSRAM 25000
// throughput performance by iperf // throughput performance by iperf
#define IDF_PERFORMANCE_MIN_TCP_RX_THROUGHPUT 50 #define IDF_PERFORMANCE_MIN_TCP_RX_THROUGHPUT 45
#define IDF_PERFORMANCE_MIN_TCP_TX_THROUGHPUT 40 #define IDF_PERFORMANCE_MIN_TCP_TX_THROUGHPUT 40
#define IDF_PERFORMANCE_MIN_UDP_RX_THROUGHPUT 80 #define IDF_PERFORMANCE_MIN_UDP_RX_THROUGHPUT 64
#define IDF_PERFORMANCE_MIN_UDP_TX_THROUGHPUT 50 #define IDF_PERFORMANCE_MIN_UDP_TX_THROUGHPUT 50
// events dispatched per second by event loop library // events dispatched per second by event loop library
#define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000 #define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000

View File

@ -55,7 +55,6 @@ set(srcs
"lwip/src/core/ipv6/mld6.c" "lwip/src/core/ipv6/mld6.c"
"lwip/src/core/ipv6/nd6.c" "lwip/src/core/ipv6/nd6.c"
"lwip/src/netif/ethernet.c" "lwip/src/netif/ethernet.c"
"lwip/src/netif/ethernetif.c"
"lwip/src/netif/lowpan6.c" "lwip/src/netif/lowpan6.c"
"lwip/src/netif/slipif.c" "lwip/src/netif/slipif.c"
"lwip/src/netif/ppp/auth.c" "lwip/src/netif/ppp/auth.c"

View File

@ -2,10 +2,72 @@
archive: liblwip.a archive: liblwip.a
entries: entries:
if LWIP_IRAM_OPTIMIZATION = y: if LWIP_IRAM_OPTIMIZATION = y:
ethernetif:ethernet_low_level_output (noflash_text) sockets:get_socket (noflash_text)
ethernetif:ethernetif_input (noflash_text) sockets:tryget_socket (noflash_text)
wlanif:low_level_output (noflash_text) sockets:tryget_socket_unconn (noflash_text)
wlanif:wlanif_input (noflash_text) sockets:sock_inc_used (noflash_text)
sockets:tryget_socket_unconn_nouse (noflash_text)
sockets:done_socket (noflash_text)
sockets:lwip_recvfrom (noflash_text)
sockets:lwip_recv_tcp (noflash_text)
sockets:lwip_recv_tcp_from (noflash_text)
sockets:lwip_recvfrom_udp_raw (noflash_text)
sockets:lwip_send (noflash_text)
sockets:lwip_sendto (noflash_text)
sockets:event_callback (noflash_text)
api_lib:netconn_apimsg (noflash_text)
api_lib:netconn_recv_data (noflash_text)
api_lib:netconn_tcp_recvd_msg (noflash_text)
api_lib:netconn_tcp_recvd (noflash_text)
api_lib:netconn_recv_data_tcp (noflash_text)
api_lib:netconn_recv_tcp_pbuf_flags (noflash_text)
api_lib:netconn_recv_udp_raw_netbuf_flags (noflash_text)
api_lib:netconn_recv (noflash_text)
api_lib:netconn_sendto (noflash_text)
api_lib:netconn_send (noflash_text)
api_lib:netconn_write_partly (noflash_text)
api_lib:netconn_write_vectors_partly (noflash_text)
api_msg:lwip_netconn_do_send (noflash_text)
api_msg:lwip_netconn_do_write (noflash_text)
netbuf:netbuf_alloc (noflash_text)
netbuf:netbuf_free (noflash_text)
tcpip:tcpip_thread (noflash_text)
tcpip:tcpip_thread_handle_msg (noflash_text)
tcpip:tcpip_inpkt (noflash_text)
tcpip:tcpip_input (noflash_text)
tcpip:tcpip_callback (noflash_text)
tcpip:tcpip_try_callback (noflash_text)
tcpip:tcpip_send_msg_wait_sem (noflash_text)
inet_chksum:inet_cksum_pseudo_base (noflash_text)
inet_chksum:inet_chksum_pseudo (noflash_text)
etharp:etharp_output_to_arp_index (noflash_text)
etharp:etharp_output (noflash_text)
ip4_addr:ip4_addr_isbroadcast_u32 (noflash_text)
ip4:ip4_route_src_hook (noflash_text)
ip4:ip4_route_src (noflash_text)
ip4:ip4_route (noflash_text)
ip4:ip4_input (noflash_text)
ip4:ip4_output_if (noflash_text)
ip4:ip4_output_if_opt (noflash_text)
ip4:ip4_output_if_src (noflash_text)
ip4:ip4_output_if_opt_src (noflash_text)
ip4:ip4_output (noflash_text)
pbuf:pbuf_alloc (noflash_text)
pbuf:pbuf_add_header_impl (noflash_text)
pbuf:pbuf_add_header (noflash_text)
pbuf:pbuf_remove_header (noflash_text)
pbuf:pbuf_header_impl (noflash_text)
pbuf:pbuf_header (noflash_text)
pbuf:pbuf_free (noflash_text)
timeouts:sys_timeouts_mbox_fetch (noflash_text)
udp:udp_input_local_match (noflash_text)
udp:udp_input (noflash_text)
udp:udp_send (noflash_text)
udp:udp_sendto (noflash_text)
udp:udp_sendto_if (noflash_text)
udp:udp_sendto_if_src (noflash_text)
ethernet:ethernet_input (noflash_text)
ethernet:ethernet_output (noflash_text)
sys_arch:sys_mutex_lock (noflash_text) sys_arch:sys_mutex_lock (noflash_text)
sys_arch:sys_mutex_unlock (noflash_text) sys_arch:sys_mutex_unlock (noflash_text)
sys_arch:sys_sem_signal (noflash_text) sys_arch:sys_sem_signal (noflash_text)
@ -13,47 +75,10 @@ entries:
sys_arch:sys_mbox_post (noflash_text) sys_arch:sys_mbox_post (noflash_text)
sys_arch:sys_mbox_trypost (noflash_text) sys_arch:sys_mbox_trypost (noflash_text)
sys_arch:sys_arch_mbox_fetch (noflash_text) sys_arch:sys_arch_mbox_fetch (noflash_text)
sockets:get_socket (noflash_text) ethernetif:ethernet_low_level_output (noflash_text)
sockets:lwip_recvfrom (noflash_text) ethernetif:ethernetif_input (noflash_text)
sockets:lwip_sendto (noflash_text) wlanif:low_level_output (noflash_text)
sockets:event_callback (noflash_text) wlanif:wlanif_input (noflash_text)
sockets:lwip_sendto_r (noflash_text)
sockets:lwip_recvfrom_r (noflash_text)
sockets:lwip_recv_r (noflash_text)
api_lib:netconn_apimsg (noflash_text)
api_lib:netconn_recv_data (noflash_text)
api_lib:netconn_recv_tcp_pbuf (noflash_text)
api_lib:netconn_recv (noflash_text)
api_lib:netconn_send (noflash_text)
api_lib:netconn_write_partly (noflash_text)
tcpip:tcpip_thread (noflash_text)
tcpip:tcpip_inpkt (noflash_text)
tcpip:tcpip_input (noflash_text)
tcpip:tcpip_send_msg_wait_sem (noflash_text)
netbuf:netbuf_alloc (noflash_text)
netbuf:netbuf_free (noflash_text)
timeouts:sys_timeouts_mbox_fetch (noflash_text)
inet_chksum:inet_cksum_pseudo_base (noflash_text)
inet_chksum:inet_chksum_pseudo (noflash_text)
inet_chksum:ip_chksum_pseudo (noflash_text)
etharp:etharp_output_to_arp_index (noflash_text)
etharp:etharp_output (noflash_text)
ip4_addr:ip4_addr_isbroadcast_u32 (noflash_text)
ip4:ip4_route_src (noflash_text)
ip4:ip4_route_src_hook (noflash_text)
ip4:ip4_route (noflash_text)
ip4:ip4_input (noflash_text)
ip4:ip4_output_if_src (noflash_text)
ip4:ip4_output_if_opt_src (noflash_text)
udp:udp_input_local_match (noflash_text)
udp:udp_input (noflash_text)
udp:udp_send (noflash_text)
udp:udp_sendto (noflash_text)
udp:udp_sendto_if (noflash_text)
udp:udp_sendto_if_src (noflash_text)
pbuf:pbuf_alloc (noflash_text)
pbuf:pbuf_header_impl (noflash_text)
pbuf:pbuf_header (noflash_text)
ethernet:ethernet_input (noflash_text)
else: else:
* (default) * (default)

@ -1 +1 @@
Subproject commit 5d9fce09e352a7b11949b79f386c907ce8d09fa8 Subproject commit bafc54f69b671f368d7b996d1668b7bd4be55193

View File

@ -191,7 +191,6 @@ void dbg_lwip_stats_show(void)
IP6_FRAG_STATS_DISPLAY(); IP6_FRAG_STATS_DISPLAY();
MLD6_STATS_DISPLAY(); MLD6_STATS_DISPLAY();
ND6_STATS_DISPLAY(); ND6_STATS_DISPLAY();
ESP_STATS_DROP_DISPLAY();
} }
#if (ESP_STATS_MEM == 1) #if (ESP_STATS_MEM == 1)

View File

@ -320,7 +320,6 @@ sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
if (msg == NULL) { if (msg == NULL) {
msg = &pvDummy; msg = &pvDummy;
} }
if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), 0)) { if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), 0)) {
ulReturn = ERR_OK; ulReturn = ERR_OK;
} else { } else {
@ -349,53 +348,13 @@ sys_mbox_set_owner(sys_mbox_t *mbox, void* owner)
void void
sys_mbox_free(sys_mbox_t *mbox) sys_mbox_free(sys_mbox_t *mbox)
{ {
uint32_t mbox_message_num = 0;
if ( (NULL == mbox) || (NULL == *mbox) ) { if ( (NULL == mbox) || (NULL == *mbox) ) {
return; return;
} }
mbox_message_num = uxQueueMessagesWaiting((*mbox)->os_mbox);
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("mbox free: mbox=%p os_mbox=%p owner=%p msg_num=%d\n",
*mbox, (*mbox)->os_mbox, (*mbox)->owner, mbox_message_num));
#if ESP_THREAD_SAFE
if ((*mbox)->owner) {
if (0 == mbox_message_num) {
/*
* If mbox->owner is not NULL, it indicates the mbox is recvmbox or acceptmbox,
* we need to post a NULL message to mbox in case some application tasks are blocked
* on this mbox
*/
if (sys_mbox_trypost(mbox, NULL) != ERR_OK) {
/* Should never be here because post a message to empty mbox should always be successful */
ESP_LOGW(TAG, "WARNING: failed to post NULL msg to mbox\n");
} else {
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("mbox free: post null successfully\n"));
}
}
(*mbox)->owner = NULL;
} else {
if (mbox_message_num > 1) {
ESP_LOGW(TAG, "WARNING: mbox has %d message, potential memory leaking\n", mbox_message_num);
}
if (mbox_message_num > 0) {
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("mbox free: reset mbox queue\n"));
xQueueReset((*mbox)->os_mbox);
}
/* For recvmbox or acceptmbox, free them in netconn_free() when all sockets' API are returned */
vQueueDelete((*mbox)->os_mbox);
free(*mbox);
*mbox = NULL;
}
#else
vQueueDelete((*mbox)->os_mbox); vQueueDelete((*mbox)->os_mbox);
free(*mbox); free(*mbox);
*mbox = NULL; *mbox = NULL;
#endif
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -52,7 +52,7 @@ typedef int16_t s16_t;
typedef uint32_t u32_t; typedef uint32_t u32_t;
typedef int32_t s32_t; typedef int32_t s32_t;
typedef unsigned long mem_ptr_t;
typedef int sys_prot_t; typedef int sys_prot_t;
#define S16_F "d" #define S16_F "d"

View File

@ -80,7 +80,7 @@ typedef struct sys_mbox_s {
* However, if the sys_mbox_set_invalid() is not called after sys_mbox_free(), e.g. in netconn_alloc(), * However, if the sys_mbox_set_invalid() is not called after sys_mbox_free(), e.g. in netconn_alloc(),
* we need to initialize the mbox to invalid explicitly since sys_mbox_set_invalid() now is empty. * we need to initialize the mbox to invalid explicitly since sys_mbox_set_invalid() now is empty.
*/ */
#define sys_mbox_set_invalid( x ) #define sys_mbox_set_invalid( x ) *x = NULL
#define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) #define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
#define sys_sem_set_invalid( x ) ( ( *x ) = NULL ) #define sys_sem_set_invalid( x ) ( ( *x ) = NULL )

View File

@ -766,13 +766,18 @@
#define ESP_STATS_MEM CONFIG_LWIP_STATS #define ESP_STATS_MEM CONFIG_LWIP_STATS
#define ESP_STATS_DROP CONFIG_LWIP_STATS #define ESP_STATS_DROP CONFIG_LWIP_STATS
#define ESP_STATS_TCP 0 #define ESP_STATS_TCP 0
#define ESP_DHCP_TIMER 1
#define ESP_DHCPS_TIMER 1 #define ESP_DHCPS_TIMER 1
#define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__) #define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__)
#define ESP_PING 1 #define ESP_PING 1
#define ESP_HAS_SELECT 1 #define ESP_HAS_SELECT 1
#define ESP_AUTO_RECV 1 #define ESP_AUTO_RECV 1
#define ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP #define ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
#define ESP_IP4_ROUTE 1
#define ESP_AUTO_IP 1
#define ESP_PBUF 1
#define ESP_PPP 1
#define ESP_IPV6 1
#define ESP_SOCKET 1
#ifdef ESP_IRAM_ATTR #ifdef ESP_IRAM_ATTR
#undef ESP_IRAM_ATTR #undef ESP_IRAM_ATTR
@ -787,44 +792,9 @@
#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 0 #define ESP_LWIP_MLD6_TIMERS_ONDEMAND 0
#endif #endif
#if ESP_PERF
#define DBG_PERF_PATH_SET(dir, point)
#define DBG_PERF_FILTER_LEN 1000
enum {
DBG_PERF_DIR_RX = 0,
DBG_PERF_DIR_TX,
};
enum {
DBG_PERF_POINT_INT = 0,
DBG_PERF_POINT_WIFI_IN = 1,
DBG_PERF_POINT_WIFI_OUT = 2,
DBG_PERF_POINT_LWIP_IN = 3,
DBG_PERF_POINT_LWIP_OUT = 4,
DBG_PERF_POINT_SOC_IN = 5,
DBG_PERF_POINT_SOC_OUT = 6,
};
#else
#define DBG_PERF_PATH_SET(dir, point)
#define DBG_PERF_FILTER_LEN 1000
#endif
#define TCP_SND_BUF CONFIG_LWIP_TCP_SND_BUF_DEFAULT #define TCP_SND_BUF CONFIG_LWIP_TCP_SND_BUF_DEFAULT
#define TCP_WND CONFIG_LWIP_TCP_WND_DEFAULT #define TCP_WND CONFIG_LWIP_TCP_WND_DEFAULT
#if ESP_PER_SOC_TCP_WND
#define TCP_WND_DEFAULT CONFIG_LWIP_TCP_WND_DEFAULT
#define TCP_SND_BUF_DEFAULT CONFIG_LWIP_TCP_SND_BUF_DEFAULT
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
#define TCP_SND_QUEUELEN(pcb) ((4 * (TCP_SND_BUF((pcb))) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SNDLOWAT(pcb) LWIP_MIN(LWIP_MAX(((TCP_SND_BUF((pcb)))/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF((pcb))) - 1)
#define TCP_SNDQUEUELOWAT(pcb) LWIP_MAX(((TCP_SND_QUEUELEN((pcb)))/2), 5)
#define TCP_WND_UPDATE_THRESHOLD(pcb) LWIP_MIN((TCP_WND((pcb)) / 4), (TCP_MSS * 4))
#endif
/** /**
* DHCP_DEBUG: Enable debugging in dhcp.c. * DHCP_DEBUG: Enable debugging in dhcp.c.
*/ */
@ -849,6 +819,12 @@ enum {
/* /*
* SNTP update delay - in milliseconds * SNTP update delay - in milliseconds
*/ */
/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers
* One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
* \#define SNTP_SERVER_ADDRESS "pool.ntp.org"
*/
#define SNTP_SERVER_DNS 1
#define SNTP_UPDATE_DELAY CONFIG_LWIP_SNTP_UPDATE_DELAY #define SNTP_UPDATE_DELAY CONFIG_LWIP_SNTP_UPDATE_DELAY
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \ #define SNTP_SET_SYSTEM_TIME_US(sec, us) \

View File

@ -154,7 +154,6 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
#if (ESP_L2_TO_L3_COPY == 1) #if (ESP_L2_TO_L3_COPY == 1)
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM); p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
if (p == NULL) { if (p == NULL) {
ESP_STATS_DROP_INC(esp.wlanif_input_pbuf_fail);
esp_wifi_internal_free_rx_buffer(eb); esp_wifi_internal_free_rx_buffer(eb);
return; return;
} }
@ -164,7 +163,6 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
#else #else
p = pbuf_alloc(PBUF_RAW, len, PBUF_REF); p = pbuf_alloc(PBUF_RAW, len, PBUF_REF);
if (p == NULL){ if (p == NULL){
ESP_STATS_DROP_INC(esp.wlanif_input_pbuf_fail);
esp_wifi_internal_free_rx_buffer(eb); esp_wifi_internal_free_rx_buffer(eb);
return; return;
} }

View File

@ -49,23 +49,23 @@ static void *lwip_get_socket_select_semaphore()
static int lwip_fcntl_r_wrapper(int fd, int cmd, int arg) static int lwip_fcntl_r_wrapper(int fd, int cmd, int arg)
{ {
return lwip_fcntl_r(fd, cmd, arg); return lwip_fcntl(fd, cmd, arg);
} }
static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args) static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args)
{ {
return lwip_ioctl_r(fd, cmd, va_arg(args, void *)); return lwip_ioctl(fd, cmd, va_arg(args, void *));
} }
void esp_vfs_lwip_sockets_register() void esp_vfs_lwip_sockets_register()
{ {
esp_vfs_t vfs = { esp_vfs_t vfs = {
.flags = ESP_VFS_FLAG_DEFAULT, .flags = ESP_VFS_FLAG_DEFAULT,
.write = &lwip_write_r, .write = &lwip_write,
.open = NULL, .open = NULL,
.fstat = NULL, .fstat = NULL,
.close = &lwip_close_r, .close = &lwip_close,
.read = &lwip_read_r, .read = &lwip_read,
.fcntl = &lwip_fcntl_r_wrapper, .fcntl = &lwip_fcntl_r_wrapper,
.ioctl = &lwip_ioctl_r_wrapper, .ioctl = &lwip_ioctl_r_wrapper,
.socket_select = &lwip_select, .socket_select = &lwip_select,

View File

@ -51,7 +51,7 @@
#endif #endif
#define PATH_MAX 1024 /* max bytes in pathname */ #define PATH_MAX 1024 /* max bytes in pathname */
#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ #define PIPE_BUF 512 /* max bytes for atomic pipe writes */
#define IOV_MAX 1024 /* max elements in i/o vector */
#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ #define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */
#define BC_DIM_MAX 2048 /* max array elements in bc(1) */ #define BC_DIM_MAX 2048 /* max array elements in bc(1) */

View File

@ -14,6 +14,8 @@
#ifndef _ESP_PLATFORM_NET_IF_H_ #ifndef _ESP_PLATFORM_NET_IF_H_
#define _ESP_PLATFORM_NET_IF_H_ #define _ESP_PLATFORM_NET_IF_H_
#include "lwip/sockets.h"
#define MSG_DONTROUTE 0x4 /* send without using routing tables */ #define MSG_DONTROUTE 0x4 /* send without using routing tables */
#define SOCK_SEQPACKET 5 /* sequenced packet stream */ #define SOCK_SEQPACKET 5 /* sequenced packet stream */
#define MSG_EOR 0x8 /* data completes record */ #define MSG_EOR 0x8 /* data completes record */
@ -29,12 +31,6 @@
#define NI_NUMERICSERV 0x00000008 #define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010 #define NI_DGRAM 0x00000010
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr;
unsigned int ipv6mr_interface;
};
typedef u32_t socklen_t; typedef u32_t socklen_t;

View File

@ -157,13 +157,13 @@ static int tcpip_adapter_ipc_check(tcpip_adapter_api_msg_t *msg)
static esp_err_t tcpip_adapter_update_default_netif(void) static esp_err_t tcpip_adapter_update_default_netif(void)
{ {
if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) { if (esp_netif[TCPIP_ADAPTER_IF_STA] != NULL && netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_STA]); netif_set_default(esp_netif[TCPIP_ADAPTER_IF_STA]);
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_ETH])) { } else if (esp_netif[TCPIP_ADAPTER_IF_ETH] != NULL && netif_is_up(esp_netif[TCPIP_ADAPTER_IF_ETH])) {
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_ETH]); netif_set_default(esp_netif[TCPIP_ADAPTER_IF_ETH]);
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_AP])) { } else if (esp_netif[TCPIP_ADAPTER_IF_AP] != NULL && netif_is_up(esp_netif[TCPIP_ADAPTER_IF_AP])) {
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_AP]); netif_set_default(esp_netif[TCPIP_ADAPTER_IF_AP]);
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_TEST])) { } else if(esp_netif[TCPIP_ADAPTER_IF_TEST] != NULL && netif_is_up(esp_netif[TCPIP_ADAPTER_IF_TEST])) {
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_TEST]); netif_set_default(esp_netif[TCPIP_ADAPTER_IF_TEST]);
} }
@ -193,6 +193,7 @@ static esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac,
netif_init = tcpip_if_to_netif_init_fn(tcpip_if); netif_init = tcpip_if_to_netif_init_fn(tcpip_if);
assert(netif_init != NULL); assert(netif_init != NULL);
netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, args, netif_init, tcpip_input); netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, args, netif_init, tcpip_input);
#if ESP_GRATUITOUS_ARP #if ESP_GRATUITOUS_ARP
if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) { if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) {
netif_set_garp_flag(esp_netif[tcpip_if]); netif_set_garp_flag(esp_netif[tcpip_if]);
@ -767,6 +768,8 @@ esp_err_t tcpip_adapter_get_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_
dns_param.dns_type = type; dns_param.dns_type = type;
dns_param.dns_info = dns; dns_param.dns_info = dns;
const ip_addr_t* dns_ip = NULL;
TCPIP_ADAPTER_IPC_CALL(tcpip_if, type, 0, &dns_param, tcpip_adapter_get_dns_info_api); TCPIP_ADAPTER_IPC_CALL(tcpip_if, type, 0, &dns_param, tcpip_adapter_get_dns_info_api);
if (!dns) { if (!dns) {
@ -785,7 +788,10 @@ esp_err_t tcpip_adapter_get_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_
} }
if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) { if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) {
dns->ip = dns_getserver(type); dns_ip = dns_getserver(type);
if(dns_ip != NULL){
dns->ip = *dns_ip;
}
} else { } else {
dns->ip.u_addr.ip4 = dhcps_dns_getserver(); dns->ip.u_addr.ip4 = dhcps_dns_getserver();
} }

View File

@ -55,23 +55,12 @@ inline static bool iperf_is_tcp_server(void)
int iperf_get_socket_error_code(int sockfd) int iperf_get_socket_error_code(int sockfd)
{ {
uint32_t optlen = sizeof(int); return errno;
int result;
int err;
err = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &optlen);
if (err == -1) {
ESP_LOGE(TAG, "getsockopt failed: ret=%d", err);
return -1;
}
return result;
} }
int iperf_show_socket_error_reason(const char *str, int sockfd) int iperf_show_socket_error_reason(const char *str, int sockfd)
{ {
int err = iperf_get_socket_error_code(sockfd); int err = errno;
if (err != 0) { if (err != 0) {
ESP_LOGW(TAG, "%s error, error code: %d, reason: %s", str, err, strerror(err)); ESP_LOGW(TAG, "%s error, error code: %d, reason: %s", str, err, strerror(err));
} }

View File

@ -454,6 +454,7 @@ esp_err_t esp_modem_remove_event_handler(modem_dte_t *dte, esp_event_handler_t h
static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx) static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx)
{ {
struct netif *pppif = ppp_netif(pcb); struct netif *pppif = ppp_netif(pcb);
const ip_addr_t *dest_ip = NULL;
modem_dte_t *dte = (modem_dte_t *)(ctx); modem_dte_t *dte = (modem_dte_t *)(ctx);
esp_modem_dte_t *esp_dte = __containerof(dte, esp_modem_dte_t, parent); esp_modem_dte_t *esp_dte = __containerof(dte, esp_modem_dte_t, parent);
ppp_client_ip_info_t ipinfo = {0}; ppp_client_ip_info_t ipinfo = {0};
@ -462,8 +463,14 @@ static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx)
ipinfo.ip = pppif->ip_addr.u_addr.ip4; ipinfo.ip = pppif->ip_addr.u_addr.ip4;
ipinfo.gw = pppif->gw.u_addr.ip4; ipinfo.gw = pppif->gw.u_addr.ip4;
ipinfo.netmask = pppif->netmask.u_addr.ip4; ipinfo.netmask = pppif->netmask.u_addr.ip4;
ipinfo.ns1 = dns_getserver(0).u_addr.ip4; dest_ip = dns_getserver(0);
ipinfo.ns2 = dns_getserver(1).u_addr.ip4; if(dest_ip != NULL){
ipinfo.ns1 = (*dest_ip).u_addr.ip4;
}
dest_ip = dns_getserver(1);
if(dest_ip != NULL){
ipinfo.ns2 = (*dest_ip).u_addr.ip4;
}
esp_event_post_to(esp_dte->event_loop_hdl, ESP_MODEM_EVENT, MODEM_EVENT_PPP_CONNECT, &ipinfo, sizeof(ipinfo), 0); esp_event_post_to(esp_dte->event_loop_hdl, ESP_MODEM_EVENT, MODEM_EVENT_PPP_CONNECT, &ipinfo, sizeof(ipinfo), 0);
break; break;
case PPPERR_PARAM: case PPPERR_PARAM:

View File

@ -170,9 +170,10 @@ err:
static int create_multicast_ipv6_socket() static int create_multicast_ipv6_socket()
{ {
struct sockaddr_in6 saddr = { 0 }; struct sockaddr_in6 saddr = { 0 };
u8_t netif_index = EXAMPLE_INTERFACE;
struct in6_addr if_inaddr = { 0 }; struct in6_addr if_inaddr = { 0 };
struct ip6_addr if_ipaddr = { 0 }; struct ip6_addr if_ipaddr = { 0 };
struct ip6_mreq v6imreq = { 0 }; struct ipv6_mreq v6imreq = { 0 };
int sock = -1; int sock = -1;
int err = 0; int err = 0;
@ -211,8 +212,7 @@ static int create_multicast_ipv6_socket()
#endif // LISTEN_ALL_IF #endif // LISTEN_ALL_IF
// Assign the multicast source interface, via its IP // Assign the multicast source interface, via its IP
err = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &if_inaddr, err = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &netif_index,sizeof(uint8_t));
sizeof(struct in6_addr));
if (err < 0) { if (err < 0) {
ESP_LOGE(V6TAG, "Failed to set IPV6_MULTICAST_IF. Error %d", errno); ESP_LOGE(V6TAG, "Failed to set IPV6_MULTICAST_IF. Error %d", errno);
goto err; goto err;
@ -245,7 +245,8 @@ static int create_multicast_ipv6_socket()
#if LISTEN_ALL_IF #if LISTEN_ALL_IF
v6imreq.imr_interface.s_addr = IPADDR_ANY; v6imreq.imr_interface.s_addr = IPADDR_ANY;
#else #else
inet6_addr_from_ip6addr(&v6imreq.ipv6mr_interface, &if_ipaddr); v6imreq.ipv6mr_interface = EXAMPLE_INTERFACE;
/* inet6_addr_from_ip6addr(&v6imreq.ipv6mr_interface, &if_ipaddr);*/
#endif // LISTEN_ALL_IF #endif // LISTEN_ALL_IF
#ifdef CONFIG_EXAMPLE_IPV6 #ifdef CONFIG_EXAMPLE_IPV6
// Configure multicast address to listen to // Configure multicast address to listen to
@ -262,7 +263,7 @@ static int create_multicast_ipv6_socket()
} }
err = setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, err = setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
&v6imreq, sizeof(struct ip6_mreq)); &v6imreq, sizeof(struct ipv6_mreq));
if (err < 0) { if (err < 0) {
ESP_LOGE(V6TAG, "Failed to set IPV6_ADD_MEMBERSHIP. Error %d", errno); ESP_LOGE(V6TAG, "Failed to set IPV6_ADD_MEMBERSHIP. Error %d", errno);
goto err; goto err;

View File

@ -56,24 +56,13 @@ inline static bool iperf_is_tcp_server(void)
static int iperf_get_socket_error_code(int sockfd) static int iperf_get_socket_error_code(int sockfd)
{ {
uint32_t optlen = sizeof(int);
int result;
int err;
/* get the error state, and clear it */ return errno;
err = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &optlen);
if (err == -1) {
ESP_LOGE(TAG, "getsockopt failed: ret=%d", err);
return -1;
}
return result;
} }
static int iperf_show_socket_error_reason(const char *str, int sockfd) static int iperf_show_socket_error_reason(const char *str, int sockfd)
{ {
int err = iperf_get_socket_error_code(sockfd); int err = errno;
if (err != 0) { if (err != 0) {
ESP_LOGW(TAG, "%s error, error code: %d, reason: %s", str, err, strerror(err)); ESP_LOGW(TAG, "%s error, error code: %d, reason: %s", str, err, strerror(err));
} }