mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
Merge branch 'bufix/Backport_some_wifi_lwip_bugs_for_4.4_0711' into 'release/v4.4'
Backport some wifi&lwip bugs for 4.4 0711 See merge request espressif/esp-idf!18984
This commit is contained in:
@ -10,7 +10,7 @@ ppMapTxQueue = 0x400016d8;
|
|||||||
rcGetSched = 0x40001764;
|
rcGetSched = 0x40001764;
|
||||||
wDevCheckBlockError = 0x400017b4;
|
wDevCheckBlockError = 0x400017b4;
|
||||||
ppProcTxDone = 0x40001804;
|
ppProcTxDone = 0x40001804;
|
||||||
sta_input = rom_sta_input;
|
/*sta_input = rom_sta_input;*/
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
Group rom_phy
|
Group rom_phy
|
||||||
|
@ -1550,7 +1550,7 @@ pm_on_data_rx = 0x40001680;
|
|||||||
pm_on_tbtt = 0x40001684;
|
pm_on_tbtt = 0x40001684;
|
||||||
pm_parse_beacon = 0x40001688;
|
pm_parse_beacon = 0x40001688;
|
||||||
pm_process_tim = 0x4000168c;
|
pm_process_tim = 0x4000168c;
|
||||||
pm_rx_beacon_process = 0x40001690;
|
/*pm_rx_beacon_process = 0x40001690;*/
|
||||||
pm_rx_data_process = 0x40001694;
|
pm_rx_data_process = 0x40001694;
|
||||||
/*pm_sleep = 0x40001698;*/
|
/*pm_sleep = 0x40001698;*/
|
||||||
pm_sleep_for = 0x4000169c;
|
pm_sleep_for = 0x4000169c;
|
||||||
|
@ -1855,7 +1855,7 @@ pm_on_data_rx = 0x400054c0;
|
|||||||
pm_on_tbtt = 0x400054cc;
|
pm_on_tbtt = 0x400054cc;
|
||||||
pm_parse_beacon = 0x400054d8;
|
pm_parse_beacon = 0x400054d8;
|
||||||
pm_process_tim = 0x400054e4;
|
pm_process_tim = 0x400054e4;
|
||||||
pm_rx_beacon_process = 0x400054f0;
|
/*pm_rx_beacon_process = 0x400054f0;*/
|
||||||
pm_rx_data_process = 0x400054fc;
|
pm_rx_data_process = 0x400054fc;
|
||||||
/*pm_sleep = 0x40005508;*/
|
/*pm_sleep = 0x40005508;*/
|
||||||
pm_sleep_for = 0x40005514;
|
pm_sleep_for = 0x40005514;
|
||||||
@ -2032,7 +2032,7 @@ ieee80211_is_tx_allowed = 0x40005a78;
|
|||||||
ieee80211_output_pending_eb = 0x40005a84;
|
ieee80211_output_pending_eb = 0x40005a84;
|
||||||
ieee80211_output_process = 0x40005a90;
|
ieee80211_output_process = 0x40005a90;
|
||||||
ieee80211_set_tx_desc = 0x40005a9c;
|
ieee80211_set_tx_desc = 0x40005a9c;
|
||||||
sta_input = 0x40005aa8;
|
/*sta_input = 0x40005aa8;*/
|
||||||
wifi_get_macaddr = 0x40005ab4;
|
wifi_get_macaddr = 0x40005ab4;
|
||||||
wifi_rf_phy_disable = 0x40005ac0;
|
wifi_rf_phy_disable = 0x40005ac0;
|
||||||
wifi_rf_phy_enable = 0x40005acc;
|
wifi_rf_phy_enable = 0x40005acc;
|
||||||
|
Submodule components/esp_wifi/lib updated: b28a4656cf...dc92d42a73
@ -1018,6 +1018,13 @@ menu "LWIP"
|
|||||||
|
|
||||||
All lwIP debug features increase the size of the final binary.
|
All lwIP debug features increase the size of the final binary.
|
||||||
|
|
||||||
|
config LWIP_DEBUG_ESP_LOG
|
||||||
|
bool "Route LWIP debugs through ESP_LOG interface"
|
||||||
|
depends on LWIP_DEBUG
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Enabling this option routes all enabled LWIP debugs through ESP_LOGD.
|
||||||
|
|
||||||
config LWIP_NETIF_DEBUG
|
config LWIP_NETIF_DEBUG
|
||||||
bool "Enable netif debug messages"
|
bool "Enable netif debug messages"
|
||||||
depends on LWIP_DEBUG
|
depends on LWIP_DEBUG
|
||||||
|
@ -25,6 +25,7 @@ typedef struct _ping_option {
|
|||||||
size_t ping_data_len;
|
size_t ping_data_len;
|
||||||
uint16_t ping_id;
|
uint16_t ping_id;
|
||||||
u8_t ping_tos;
|
u8_t ping_tos;
|
||||||
|
u8_t ping_ttl;
|
||||||
esp_ping_found_fn ping_res_fn;
|
esp_ping_found_fn ping_res_fn;
|
||||||
esp_ping_found ping_res;
|
esp_ping_found ping_res;
|
||||||
void *ping_reserve;
|
void *ping_reserve;
|
||||||
|
@ -67,6 +67,7 @@ typedef struct {
|
|||||||
uint32_t elapsed_time_ms;
|
uint32_t elapsed_time_ms;
|
||||||
uint32_t total_time_ms;
|
uint32_t total_time_ms;
|
||||||
uint8_t ttl;
|
uint8_t ttl;
|
||||||
|
uint8_t tos;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
void (*on_ping_success)(esp_ping_handle_t hdl, void *args);
|
void (*on_ping_success)(esp_ping_handle_t hdl, void *args);
|
||||||
void (*on_ping_timeout)(esp_ping_handle_t hdl, void *args);
|
void (*on_ping_timeout)(esp_ping_handle_t hdl, void *args);
|
||||||
@ -131,6 +132,7 @@ static int esp_ping_receive(esp_ping_t *ep)
|
|||||||
if ((iecho->id == ep->packet_hdr->id) && (iecho->seqno == ep->packet_hdr->seqno)) {
|
if ((iecho->id == ep->packet_hdr->id) && (iecho->seqno == ep->packet_hdr->seqno)) {
|
||||||
ep->received++;
|
ep->received++;
|
||||||
ep->ttl = iphdr->_ttl;
|
ep->ttl = iphdr->_ttl;
|
||||||
|
ep->tos = iphdr->_tos;
|
||||||
ep->recv_len = lwip_ntohs(IPH_LEN(iphdr)) - data_head; // The data portion of ICMP
|
ep->recv_len = lwip_ntohs(IPH_LEN(iphdr)) - data_head; // The data portion of ICMP
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@ -289,6 +291,9 @@ esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_c
|
|||||||
/* set tos */
|
/* set tos */
|
||||||
setsockopt(ep->sock, IPPROTO_IP, IP_TOS, &config->tos, sizeof(config->tos));
|
setsockopt(ep->sock, IPPROTO_IP, IP_TOS, &config->tos, sizeof(config->tos));
|
||||||
|
|
||||||
|
/* set ttl */
|
||||||
|
setsockopt(ep->sock, IPPROTO_IP, IP_TTL, &config->ttl, sizeof(config->ttl));
|
||||||
|
|
||||||
/* set socket address */
|
/* set socket address */
|
||||||
if (IP_IS_V4(&config->target_addr)) {
|
if (IP_IS_V4(&config->target_addr)) {
|
||||||
struct sockaddr_in *to4 = (struct sockaddr_in *)&ep->target_addr;
|
struct sockaddr_in *to4 = (struct sockaddr_in *)&ep->target_addr;
|
||||||
@ -371,6 +376,10 @@ esp_err_t esp_ping_get_profile(esp_ping_handle_t hdl, esp_ping_profile_t profile
|
|||||||
from = &ep->packet_hdr->seqno;
|
from = &ep->packet_hdr->seqno;
|
||||||
copy_size = sizeof(ep->packet_hdr->seqno);
|
copy_size = sizeof(ep->packet_hdr->seqno);
|
||||||
break;
|
break;
|
||||||
|
case ESP_PING_PROF_TOS:
|
||||||
|
from = &ep->tos;
|
||||||
|
copy_size = sizeof(ep->tos);
|
||||||
|
break;
|
||||||
case ESP_PING_PROF_TTL:
|
case ESP_PING_PROF_TTL:
|
||||||
from = &ep->ttl;
|
from = &ep->ttl;
|
||||||
copy_size = sizeof(ep->ttl);
|
copy_size = sizeof(ep->ttl);
|
||||||
|
@ -67,7 +67,8 @@ typedef struct {
|
|||||||
uint32_t interval_ms; /*!< Milliseconds between each ping procedure */
|
uint32_t interval_ms; /*!< Milliseconds between each ping procedure */
|
||||||
uint32_t timeout_ms; /*!< Timeout value (in milliseconds) of each ping procedure */
|
uint32_t timeout_ms; /*!< Timeout value (in milliseconds) of each ping procedure */
|
||||||
uint32_t data_size; /*!< Size of the data next to ICMP packet header */
|
uint32_t data_size; /*!< Size of the data next to ICMP packet header */
|
||||||
uint8_t tos; /*!< Type of Service, a field specified in the IP header */
|
int tos; /*!< Type of Service, a field specified in the IP header */
|
||||||
|
int ttl; /*!< Time to Live,a field specified in the IP header */
|
||||||
ip_addr_t target_addr; /*!< Target IP address, either IPv4 or IPv6 */
|
ip_addr_t target_addr; /*!< Target IP address, either IPv4 or IPv6 */
|
||||||
uint32_t task_stack_size; /*!< Stack size of internal ping task */
|
uint32_t task_stack_size; /*!< Stack size of internal ping task */
|
||||||
uint32_t task_prio; /*!< Priority of internal ping task */
|
uint32_t task_prio; /*!< Priority of internal ping task */
|
||||||
@ -85,6 +86,7 @@ typedef struct {
|
|||||||
.timeout_ms = 1000, \
|
.timeout_ms = 1000, \
|
||||||
.data_size = 64, \
|
.data_size = 64, \
|
||||||
.tos = 0, \
|
.tos = 0, \
|
||||||
|
.ttl = IP_DEFAULT_TTL, \
|
||||||
.target_addr = *(IP_ANY_TYPE), \
|
.target_addr = *(IP_ANY_TYPE), \
|
||||||
.task_stack_size = 2048, \
|
.task_stack_size = 2048, \
|
||||||
.task_prio = 2, \
|
.task_prio = 2, \
|
||||||
@ -99,6 +101,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESP_PING_PROF_SEQNO, /*!< Sequence number of a ping procedure */
|
ESP_PING_PROF_SEQNO, /*!< Sequence number of a ping procedure */
|
||||||
|
ESP_PING_PROF_TOS, /*!< Type of service of a ping procedure */
|
||||||
ESP_PING_PROF_TTL, /*!< Time to live of a ping procedure */
|
ESP_PING_PROF_TTL, /*!< Time to live of a ping procedure */
|
||||||
ESP_PING_PROF_REQUEST, /*!< Number of request packets sent out */
|
ESP_PING_PROF_REQUEST, /*!< Number of request packets sent out */
|
||||||
ESP_PING_PROF_REPLY, /*!< Number of reply packets received */
|
ESP_PING_PROF_REPLY, /*!< Number of reply packets received */
|
||||||
|
@ -79,7 +79,15 @@ typedef int sys_prot_t;
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_LWIP_DEBUG_ESP_LOG
|
||||||
|
// lwip debugs routed to ESP_LOGD
|
||||||
|
#include "esp_log.h"
|
||||||
|
#define LWIP_ESP_LOG_FUNC(format, ...) ESP_LOG_LEVEL(ESP_LOG_DEBUG, "lwip", format, ##__VA_ARGS__)
|
||||||
|
#define LWIP_PLATFORM_DIAG(x) LWIP_ESP_LOG_FUNC x
|
||||||
|
#else
|
||||||
|
// lwip debugs routed to printf
|
||||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ static struct {
|
|||||||
struct arg_int *data_size;
|
struct arg_int *data_size;
|
||||||
struct arg_int *count;
|
struct arg_int *count;
|
||||||
struct arg_int *tos;
|
struct arg_int *tos;
|
||||||
|
struct arg_int *ttl;
|
||||||
struct arg_str *host;
|
struct arg_str *host;
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} ping_args;
|
} ping_args;
|
||||||
@ -107,6 +108,10 @@ static int do_ping_cmd(int argc, char **argv)
|
|||||||
config.tos = (uint32_t)(ping_args.tos->ival[0]);
|
config.tos = (uint32_t)(ping_args.tos->ival[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ping_args.ttl->count > 0) {
|
||||||
|
config.ttl = (uint32_t)(ping_args.ttl->ival[0]);
|
||||||
|
}
|
||||||
|
|
||||||
// parse IP address
|
// parse IP address
|
||||||
struct sockaddr_in6 sock_addr6;
|
struct sockaddr_in6 sock_addr6;
|
||||||
ip_addr_t target_addr;
|
ip_addr_t target_addr;
|
||||||
@ -156,6 +161,7 @@ static void register_ping(void)
|
|||||||
ping_args.data_size = arg_int0("s", "size", "<n>", "Specify the number of data bytes to be sent");
|
ping_args.data_size = arg_int0("s", "size", "<n>", "Specify the number of data bytes to be sent");
|
||||||
ping_args.count = arg_int0("c", "count", "<n>", "Stop after sending count packets");
|
ping_args.count = arg_int0("c", "count", "<n>", "Stop after sending count packets");
|
||||||
ping_args.tos = arg_int0("Q", "tos", "<n>", "Set Type of Service related bits in IP datagrams");
|
ping_args.tos = arg_int0("Q", "tos", "<n>", "Set Type of Service related bits in IP datagrams");
|
||||||
|
ping_args.ttl = arg_int0("T", "ttl", "<n>", "Set Time to Live related bits in IP datagrams");
|
||||||
ping_args.host = arg_str1(NULL, NULL, "<host>", "Host address");
|
ping_args.host = arg_str1(NULL, NULL, "<host>", "Host address");
|
||||||
ping_args.end = arg_end(1);
|
ping_args.end = arg_end(1);
|
||||||
const esp_console_cmd_t ping_cmd = {
|
const esp_console_cmd_t ping_cmd = {
|
||||||
|
@ -12,6 +12,7 @@ In order to create UDP client that communicates with UDP server example, choose
|
|||||||
There are many host-side tools which can be used to interact with the UDP/TCP server/client.
|
There are many host-side tools which can be used to interact with the UDP/TCP server/client.
|
||||||
One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets.
|
One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets.
|
||||||
Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands.
|
Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands.
|
||||||
|
If want to use this RECVINFO function, please enable LWIP_NETBUF_RECVINFO in menuconfig,this function can only resolve the destination address of IPV4.
|
||||||
|
|
||||||
In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples.
|
In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples.
|
||||||
|
|
||||||
|
@ -57,6 +57,11 @@ static void udp_server_task(void *pvParameters)
|
|||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Socket created");
|
ESP_LOGI(TAG, "Socket created");
|
||||||
|
|
||||||
|
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||||
|
int enable = 1;
|
||||||
|
lwip_setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &enable, sizeof(enable));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_EXAMPLE_IPV4) && defined(CONFIG_EXAMPLE_IPV6)
|
#if defined(CONFIG_EXAMPLE_IPV4) && defined(CONFIG_EXAMPLE_IPV6)
|
||||||
if (addr_family == AF_INET6) {
|
if (addr_family == AF_INET6) {
|
||||||
// Note that by default IPV6 binds to both protocols, it is must be disabled
|
// Note that by default IPV6 binds to both protocols, it is must be disabled
|
||||||
@ -73,13 +78,33 @@ static void udp_server_task(void *pvParameters)
|
|||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Socket bound, port %d", PORT);
|
ESP_LOGI(TAG, "Socket bound, port %d", PORT);
|
||||||
|
|
||||||
|
struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6
|
||||||
|
socklen_t socklen = sizeof(source_addr);
|
||||||
|
|
||||||
|
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||||
|
struct iovec iov;
|
||||||
|
struct msghdr msg;
|
||||||
|
struct cmsghdr *cmsgtmp;
|
||||||
|
u8_t cmsg_buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
||||||
|
|
||||||
|
iov.iov_base = rx_buffer;
|
||||||
|
iov.iov_len = sizeof(rx_buffer);
|
||||||
|
msg.msg_control = cmsg_buf;
|
||||||
|
msg.msg_controllen = sizeof(cmsg_buf);
|
||||||
|
msg.msg_flags = 0;
|
||||||
|
msg.msg_iov = &iov;
|
||||||
|
msg.msg_iovlen = 1;
|
||||||
|
msg.msg_name = (struct sockaddr *)&source_addr;
|
||||||
|
msg.msg_namelen = socklen;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Waiting for data");
|
ESP_LOGI(TAG, "Waiting for data");
|
||||||
struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6
|
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||||
socklen_t socklen = sizeof(source_addr);
|
int len = recvmsg(sock, &msg, 0);
|
||||||
|
#else
|
||||||
int len = recvfrom(sock, rx_buffer, sizeof(rx_buffer) - 1, 0, (struct sockaddr *)&source_addr, &socklen);
|
int len = recvfrom(sock, rx_buffer, sizeof(rx_buffer) - 1, 0, (struct sockaddr *)&source_addr, &socklen);
|
||||||
|
#endif
|
||||||
// Error occurred during receiving
|
// Error occurred during receiving
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
ESP_LOGE(TAG, "recvfrom failed: errno %d", errno);
|
ESP_LOGE(TAG, "recvfrom failed: errno %d", errno);
|
||||||
@ -90,6 +115,15 @@ static void udp_server_task(void *pvParameters)
|
|||||||
// Get the sender's ip address as string
|
// Get the sender's ip address as string
|
||||||
if (source_addr.ss_family == PF_INET) {
|
if (source_addr.ss_family == PF_INET) {
|
||||||
inet_ntoa_r(((struct sockaddr_in *)&source_addr)->sin_addr, addr_str, sizeof(addr_str) - 1);
|
inet_ntoa_r(((struct sockaddr_in *)&source_addr)->sin_addr, addr_str, sizeof(addr_str) - 1);
|
||||||
|
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||||
|
for ( cmsgtmp = CMSG_FIRSTHDR(&msg); cmsgtmp != NULL; cmsgtmp = CMSG_NXTHDR(&msg, cmsgtmp) ) {
|
||||||
|
if ( cmsgtmp->cmsg_level == IPPROTO_IP && cmsgtmp->cmsg_type == IP_PKTINFO ) {
|
||||||
|
struct in_pktinfo *pktinfo;
|
||||||
|
pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsgtmp);
|
||||||
|
ESP_LOGI(TAG, "dest ip: %s\n", inet_ntoa(pktinfo->ipi_addr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
} else if (source_addr.ss_family == PF_INET6) {
|
} else if (source_addr.ss_family == PF_INET6) {
|
||||||
inet6_ntoa_r(((struct sockaddr_in6 *)&source_addr)->sin6_addr, addr_str, sizeof(addr_str) - 1);
|
inet6_ntoa_r(((struct sockaddr_in6 *)&source_addr)->sin6_addr, addr_str, sizeof(addr_str) - 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user