mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-12-16 02:43:47 +08:00
feat(lwip): update lwip component from idf
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "protocol_examples_common.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "tcpip_adapter.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
@@ -161,9 +162,10 @@ err:
|
||||
static int create_multicast_ipv6_socket()
|
||||
{
|
||||
struct sockaddr_in6 saddr = { 0 };
|
||||
int netif_index;
|
||||
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;
|
||||
|
||||
@@ -201,9 +203,14 @@ static int create_multicast_ipv6_socket()
|
||||
}
|
||||
#endif
|
||||
|
||||
// search for netif index
|
||||
netif_index = tcpip_adapter_get_netif_index(TCPIP_ADAPTER_IF_STA);
|
||||
if(netif_index < 0) {
|
||||
ESP_LOGE(V6TAG, "Failed to get netif index");
|
||||
goto err;
|
||||
}
|
||||
// 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;
|
||||
@@ -231,13 +238,6 @@ static int create_multicast_ipv6_socket()
|
||||
|
||||
// this is also a listening socket, so add it to the multicast
|
||||
// group for listening...
|
||||
|
||||
// Configure source interface
|
||||
#if USE_DEFAULT_IF
|
||||
v6imreq.imr_interface.s_addr = IPADDR_ANY;
|
||||
#else
|
||||
inet6_addr_from_ip6addr(&v6imreq.ipv6mr_interface, &if_ipaddr);
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLE_IPV6
|
||||
// Configure multicast address to listen to
|
||||
err = inet6_aton(MULTICAST_IPV6_ADDR, &v6imreq.ipv6mr_multiaddr);
|
||||
@@ -251,9 +251,10 @@ static int create_multicast_ipv6_socket()
|
||||
if (!ip6_addr_ismulticast(&multi_addr)) {
|
||||
ESP_LOGW(V6TAG, "Configured IPV6 multicast address '%s' is not a valid multicast address. This will probably not work.", MULTICAST_IPV6_ADDR);
|
||||
}
|
||||
|
||||
// Configure source interface
|
||||
v6imreq.ipv6mr_interface = (unsigned int)netif_index;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user