Created
January 5, 2019 16:38
-
-
Save forkineye/4e9c3e4dd81c45e3f3ae9afd731987f6 to your computer and use it in GitHub Desktop.
joinMultcastGroup fix?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static esp_err_t joinMulticastGroup(const ip_addr_t *addr, bool join, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX) | |
{ | |
struct netif * netif = NULL; | |
if(tcpip_if < TCPIP_ADAPTER_IF_MAX){ | |
void * nif = NULL; | |
esp_err_t err = tcpip_adapter_get_netif(tcpip_if, &nif); | |
if (err) { | |
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; | |
} | |
} else { | |
if (igmp_leavegroup_netif(netif, (const ip4_addr *)&(addr->u_addr.ip4))) { | |
return ESP_ERR_INVALID_STATE; | |
} | |
} | |
} else { | |
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 (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(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; | |
} | |
} | |
} | |
} | |
return ESP_OK; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment