From a6e3b29004b3905ac3e06b442e0f48c531f187fb Mon Sep 17 00:00:00 2001 From: Shelby Merrick Date: Sun, 6 Jan 2019 14:29:38 -0500 Subject: [PATCH] Added support for using TCPIP_ADAPTER_IF_MAX to join igmp groups on all (#2279) interfaces --- libraries/AsyncUDP/src/AsyncUDP.cpp | 48 +++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/libraries/AsyncUDP/src/AsyncUDP.cpp b/libraries/AsyncUDP/src/AsyncUDP.cpp index 313d7ed4..5faf4393 100644 --- a/libraries/AsyncUDP/src/AsyncUDP.cpp +++ b/libraries/AsyncUDP/src/AsyncUDP.cpp @@ -561,26 +561,48 @@ static esp_err_t joinMulticastGroup(const ip_addr_t *addr, bool join, tcpip_adap return ESP_ERR_INVALID_ARG; } netif = (struct netif *)nif; - } - if (addr->type == IPADDR_TYPE_V4) { - if(join){ - if (igmp_joingroup_netif(netif, (const ip4_addr *)&(addr->u_addr.ip4))) { - return ESP_ERR_INVALID_STATE; + if (addr->type == IPADDR_TYPE_V4) { + if(join){ + if (igmp_joingroup_netif(netif, (const ip4_addr *)&(addr->u_addr.ip4))) { + return ESP_ERR_INVALID_STATE; + } + } else { + if (igmp_leavegroup_netif(netif, (const ip4_addr *)&(addr->u_addr.ip4))) { + return ESP_ERR_INVALID_STATE; + } } } else { - if (igmp_leavegroup_netif(netif, (const ip4_addr *)&(addr->u_addr.ip4))) { - return ESP_ERR_INVALID_STATE; + if(join){ + if (mld6_joingroup_netif(netif, &(addr->u_addr.ip6))) { + return ESP_ERR_INVALID_STATE; + } + } else { + if (mld6_leavegroup_netif(netif, &(addr->u_addr.ip6))) { + return ESP_ERR_INVALID_STATE; + } } } - } else { - if(join){ - if (mld6_joingroup_netif(netif, &(addr->u_addr.ip6))) { - return ESP_ERR_INVALID_STATE; + } else { + if (addr->type == IPADDR_TYPE_V4) { + if(join){ + if (igmp_joingroup((const ip4_addr *)IP4_ADDR_ANY, (const ip4_addr *)&(addr->u_addr.ip4))) { + return ESP_ERR_INVALID_STATE; + } + } else { + if (igmp_leavegroup((const ip4_addr *)IP4_ADDR_ANY, (const ip4_addr *)&(addr->u_addr.ip4))) { + return ESP_ERR_INVALID_STATE; + } } } else { - if (mld6_leavegroup_netif(netif, &(addr->u_addr.ip6))) { - return ESP_ERR_INVALID_STATE; + if(join){ + if (mld6_joingroup((const ip6_addr *)IP6_ADDR_ANY, &(addr->u_addr.ip6))) { + return ESP_ERR_INVALID_STATE; + } + } else { + if (mld6_leavegroup((const ip6_addr *)IP6_ADDR_ANY, &(addr->u_addr.ip6))) { + return ESP_ERR_INVALID_STATE; + } } } }