diff --git a/components/coap/port/coap_io.c b/components/coap/port/coap_io.c index 58391add6..a8f35c180 100644 --- a/components/coap/port/coap_io.c +++ b/components/coap/port/coap_io.c @@ -714,11 +714,6 @@ struct in6_pktinfo { 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 #if !defined(WITH_CONTIKI) && !defined(SOL_IP) diff --git a/components/coap/port/include/coap_config_posix.h b/components/coap/port/include/coap_config_posix.h index d675b7a58..8f5a5cfb1 100644 --- a/components/coap/port/include/coap_config_posix.h +++ b/components/coap/port/include/coap_config_posix.h @@ -27,7 +27,6 @@ #define HAVE_ARPA_INET_H #define HAVE_TIME_H -#define IP_PKTINFO IP_MULTICAST_IF #define IPV6_PKTINFO IPV6_V6ONLY #define PACKAGE_NAME "libcoap-posix" diff --git a/components/esp_http_server/src/httpd_txrx.c b/components/esp_http_server/src/httpd_txrx.c index ab96550c8..8f81ae2b1 100644 --- a/components/esp_http_server/src/httpd_txrx.c +++ b/components/esp_http_server/src/httpd_txrx.c @@ -553,16 +553,9 @@ int httpd_req_to_sockfd(httpd_req_t *r) static int httpd_sock_err(const char *ctx, int sockfd) { int errval; - int sock_err; - size_t sock_err_len = sizeof(sock_err); + ESP_LOGW(TAG, LOG_FMT("error in %s : %d"), ctx, errno); - if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &sock_err, &sock_err_len) < 0) { - 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) { + switch(errno) { case EAGAIN: case EINTR: errval = HTTPD_SOCK_ERR_TIMEOUT; diff --git a/components/idf_test/include/idf_performance.h b/components/idf_test/include/idf_performance.h index 6cdb28823..137c1b74b 100644 --- a/components/idf_test/include/idf_performance.h +++ b/components/idf_test/include/idf_performance.h @@ -15,9 +15,9 @@ #define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME 20000 #define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME_PSRAM 25000 // 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_UDP_RX_THROUGHPUT 80 +#define IDF_PERFORMANCE_MIN_UDP_RX_THROUGHPUT 64 #define IDF_PERFORMANCE_MIN_UDP_TX_THROUGHPUT 50 // events dispatched per second by event loop library #define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000 diff --git a/components/lwip/CMakeLists.txt b/components/lwip/CMakeLists.txt index 3e1419e68..81e8f1505 100644 --- a/components/lwip/CMakeLists.txt +++ b/components/lwip/CMakeLists.txt @@ -55,7 +55,6 @@ set(srcs "lwip/src/core/ipv6/mld6.c" "lwip/src/core/ipv6/nd6.c" "lwip/src/netif/ethernet.c" - "lwip/src/netif/ethernetif.c" "lwip/src/netif/lowpan6.c" "lwip/src/netif/slipif.c" "lwip/src/netif/ppp/auth.c" diff --git a/components/lwip/linker.lf b/components/lwip/linker.lf index b4d47cb54..157e4b88b 100644 --- a/components/lwip/linker.lf +++ b/components/lwip/linker.lf @@ -2,10 +2,72 @@ archive: liblwip.a entries: if LWIP_IRAM_OPTIMIZATION = y: - ethernetif:ethernet_low_level_output (noflash_text) - ethernetif:ethernetif_input (noflash_text) - wlanif:low_level_output (noflash_text) - wlanif:wlanif_input (noflash_text) + sockets:get_socket (noflash_text) + sockets:tryget_socket (noflash_text) + sockets:tryget_socket_unconn (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_unlock (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_trypost (noflash_text) sys_arch:sys_arch_mbox_fetch (noflash_text) - sockets:get_socket (noflash_text) - sockets:lwip_recvfrom (noflash_text) - sockets:lwip_sendto (noflash_text) - sockets:event_callback (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) + ethernetif:ethernet_low_level_output (noflash_text) + ethernetif:ethernetif_input (noflash_text) + wlanif:low_level_output (noflash_text) + wlanif:wlanif_input (noflash_text) else: + * (default) diff --git a/components/lwip/lwip b/components/lwip/lwip index 5d9fce09e..bafc54f69 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 5d9fce09e352a7b11949b79f386c907ce8d09fa8 +Subproject commit bafc54f69b671f368d7b996d1668b7bd4be55193 diff --git a/components/lwip/port/esp32/debug/lwip_debug.c b/components/lwip/port/esp32/debug/lwip_debug.c index 8e1574548..c6c71b5f8 100644 --- a/components/lwip/port/esp32/debug/lwip_debug.c +++ b/components/lwip/port/esp32/debug/lwip_debug.c @@ -191,7 +191,6 @@ void dbg_lwip_stats_show(void) IP6_FRAG_STATS_DISPLAY(); MLD6_STATS_DISPLAY(); ND6_STATS_DISPLAY(); - ESP_STATS_DROP_DISPLAY(); } #if (ESP_STATS_MEM == 1) diff --git a/components/lwip/port/esp32/freertos/sys_arch.c b/components/lwip/port/esp32/freertos/sys_arch.c index fec80d1b9..a3776d59d 100644 --- a/components/lwip/port/esp32/freertos/sys_arch.c +++ b/components/lwip/port/esp32/freertos/sys_arch.c @@ -320,7 +320,6 @@ sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) if (msg == NULL) { msg = &pvDummy; } - if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), 0)) { ulReturn = ERR_OK; } else { @@ -349,53 +348,13 @@ sys_mbox_set_owner(sys_mbox_t *mbox, void* owner) void sys_mbox_free(sys_mbox_t *mbox) { - uint32_t mbox_message_num = 0; - if ( (NULL == mbox) || (NULL == *mbox) ) { 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); free(*mbox); *mbox = NULL; -#endif + } /*-----------------------------------------------------------------------------------*/ diff --git a/components/lwip/port/esp32/include/arch/cc.h b/components/lwip/port/esp32/include/arch/cc.h index 1841e3f45..300291f3b 100644 --- a/components/lwip/port/esp32/include/arch/cc.h +++ b/components/lwip/port/esp32/include/arch/cc.h @@ -52,7 +52,7 @@ typedef int16_t s16_t; typedef uint32_t u32_t; typedef int32_t s32_t; -typedef unsigned long mem_ptr_t; + typedef int sys_prot_t; #define S16_F "d" diff --git a/components/lwip/port/esp32/include/arch/sys_arch.h b/components/lwip/port/esp32/include/arch/sys_arch.h index 9638fdfd6..5fea8eb55 100644 --- a/components/lwip/port/esp32/include/arch/sys_arch.h +++ b/components/lwip/port/esp32/include/arch/sys_arch.h @@ -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(), * 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_set_invalid( x ) ( ( *x ) = NULL ) diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index 713d3ff09..e37d272cc 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -766,13 +766,18 @@ #define ESP_STATS_MEM CONFIG_LWIP_STATS #define ESP_STATS_DROP CONFIG_LWIP_STATS #define ESP_STATS_TCP 0 -#define ESP_DHCP_TIMER 1 #define ESP_DHCPS_TIMER 1 #define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__) #define ESP_PING 1 #define ESP_HAS_SELECT 1 #define ESP_AUTO_RECV 1 #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 #undef ESP_IRAM_ATTR @@ -787,44 +792,9 @@ #define ESP_LWIP_MLD6_TIMERS_ONDEMAND 0 #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_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. */ @@ -849,6 +819,12 @@ enum { /* * 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_SET_SYSTEM_TIME_US(sec, us) \ diff --git a/components/lwip/port/esp32/netif/wlanif.c b/components/lwip/port/esp32/netif/wlanif.c index cd2bdac8d..11e1fc857 100644 --- a/components/lwip/port/esp32/netif/wlanif.c +++ b/components/lwip/port/esp32/netif/wlanif.c @@ -154,7 +154,6 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb) #if (ESP_L2_TO_L3_COPY == 1) p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM); if (p == NULL) { - ESP_STATS_DROP_INC(esp.wlanif_input_pbuf_fail); esp_wifi_internal_free_rx_buffer(eb); return; } @@ -164,7 +163,6 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb) #else p = pbuf_alloc(PBUF_RAW, len, PBUF_REF); if (p == NULL){ - ESP_STATS_DROP_INC(esp.wlanif_input_pbuf_fail); esp_wifi_internal_free_rx_buffer(eb); return; } diff --git a/components/lwip/port/esp32/vfs_lwip.c b/components/lwip/port/esp32/vfs_lwip.c index 6b687a196..ffd3e79e1 100644 --- a/components/lwip/port/esp32/vfs_lwip.c +++ b/components/lwip/port/esp32/vfs_lwip.c @@ -49,23 +49,23 @@ static void *lwip_get_socket_select_semaphore() 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) { - 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() { esp_vfs_t vfs = { .flags = ESP_VFS_FLAG_DEFAULT, - .write = &lwip_write_r, + .write = &lwip_write, .open = NULL, .fstat = NULL, - .close = &lwip_close_r, - .read = &lwip_read_r, + .close = &lwip_close, + .read = &lwip_read, .fcntl = &lwip_fcntl_r_wrapper, .ioctl = &lwip_ioctl_r_wrapper, .socket_select = &lwip_select, diff --git a/components/newlib/include/sys/syslimits.h b/components/newlib/include/sys/syslimits.h index c0bb3a2ce..c778f0faf 100644 --- a/components/newlib/include/sys/syslimits.h +++ b/components/newlib/include/sys/syslimits.h @@ -51,7 +51,7 @@ #endif #define PATH_MAX 1024 /* max bytes in pathname */ #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_DIM_MAX 2048 /* max array elements in bc(1) */ diff --git a/components/newlib/platform_include/net/if.h b/components/newlib/platform_include/net/if.h index 8760bb156..e3d0a601a 100644 --- a/components/newlib/platform_include/net/if.h +++ b/components/newlib/platform_include/net/if.h @@ -14,6 +14,8 @@ #ifndef _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 SOCK_SEQPACKET 5 /* sequenced packet stream */ #define MSG_EOR 0x8 /* data completes record */ @@ -29,12 +31,6 @@ #define NI_NUMERICSERV 0x00000008 #define NI_DGRAM 0x00000010 - -struct ipv6_mreq { - struct in6_addr ipv6mr_multiaddr; - unsigned int ipv6mr_interface; -}; - typedef u32_t socklen_t; diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 8bc384e4c..88413d3a9 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -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) { - 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]); - } 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]); - } 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]); - } 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]); } @@ -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); assert(netif_init != NULL); 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 (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) { 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_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); 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) { - dns->ip = dns_getserver(type); + dns_ip = dns_getserver(type); + if(dns_ip != NULL){ + dns->ip = *dns_ip; + } } else { dns->ip.u_addr.ip4 = dhcps_dns_getserver(); } diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/iperf.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/iperf.c index d9822a377..70cfa272f 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/iperf.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/iperf.c @@ -55,23 +55,12 @@ inline static bool iperf_is_tcp_server(void) int iperf_get_socket_error_code(int sockfd) { - uint32_t optlen = sizeof(int); - 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; + return errno; } 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) { ESP_LOGW(TAG, "%s error, error code: %d, reason: %s", str, err, strerror(err)); } diff --git a/examples/protocols/pppos_client/components/modem/src/esp_modem.c b/examples/protocols/pppos_client/components/modem/src/esp_modem.c index 148d67473..979b73870 100644 --- a/examples/protocols/pppos_client/components/modem/src/esp_modem.c +++ b/examples/protocols/pppos_client/components/modem/src/esp_modem.c @@ -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) { struct netif *pppif = ppp_netif(pcb); + const ip_addr_t *dest_ip = NULL; modem_dte_t *dte = (modem_dte_t *)(ctx); esp_modem_dte_t *esp_dte = __containerof(dte, esp_modem_dte_t, parent); 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.gw = pppif->gw.u_addr.ip4; ipinfo.netmask = pppif->netmask.u_addr.ip4; - ipinfo.ns1 = dns_getserver(0).u_addr.ip4; - ipinfo.ns2 = dns_getserver(1).u_addr.ip4; + dest_ip = dns_getserver(0); + 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); break; case PPPERR_PARAM: diff --git a/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c b/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c index 03025125b..ee6878897 100644 --- a/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c +++ b/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c @@ -170,9 +170,10 @@ err: static int create_multicast_ipv6_socket() { struct sockaddr_in6 saddr = { 0 }; + u8_t netif_index = EXAMPLE_INTERFACE; struct in6_addr if_inaddr = { 0 }; struct ip6_addr if_ipaddr = { 0 }; - struct ip6_mreq v6imreq = { 0 }; + struct ipv6_mreq v6imreq = { 0 }; int sock = -1; int err = 0; @@ -211,8 +212,7 @@ static int create_multicast_ipv6_socket() #endif // LISTEN_ALL_IF // Assign the multicast source interface, via its IP - err = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &if_inaddr, - sizeof(struct in6_addr)); + err = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &netif_index,sizeof(uint8_t)); if (err < 0) { ESP_LOGE(V6TAG, "Failed to set IPV6_MULTICAST_IF. Error %d", errno); goto err; @@ -245,7 +245,8 @@ static int create_multicast_ipv6_socket() #if LISTEN_ALL_IF v6imreq.imr_interface.s_addr = IPADDR_ANY; #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 #ifdef CONFIG_EXAMPLE_IPV6 // Configure multicast address to listen to @@ -262,7 +263,7 @@ static int create_multicast_ipv6_socket() } err = setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, - &v6imreq, sizeof(struct ip6_mreq)); + &v6imreq, sizeof(struct ipv6_mreq)); if (err < 0) { ESP_LOGE(V6TAG, "Failed to set IPV6_ADD_MEMBERSHIP. Error %d", errno); goto err; diff --git a/examples/wifi/iperf/components/iperf/iperf.c b/examples/wifi/iperf/components/iperf/iperf.c index 52d247137..71d09fee7 100644 --- a/examples/wifi/iperf/components/iperf/iperf.c +++ b/examples/wifi/iperf/components/iperf/iperf.c @@ -56,24 +56,13 @@ inline static bool iperf_is_tcp_server(void) 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 */ - err = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &optlen); - if (err == -1) { - ESP_LOGE(TAG, "getsockopt failed: ret=%d", err); - return -1; - } - - return result; + return errno; } 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) { ESP_LOGW(TAG, "%s error, error code: %d, reason: %s", str, err, strerror(err)); }