mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-16 08:43:17 +00:00
mld6: Simplify join/leavegroup()
Use netif_get_ip6_addr_match() helper to shorten the code.
This commit is contained in:
parent
1fdab5ac0e
commit
82fcc307ef
@ -322,26 +322,13 @@ mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr)
|
|||||||
{
|
{
|
||||||
err_t err = ERR_VAL; /* no matching interface */
|
err_t err = ERR_VAL; /* no matching interface */
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
u8_t match;
|
|
||||||
u8_t i;
|
|
||||||
|
|
||||||
/* loop through netif's */
|
/* loop through netif's */
|
||||||
netif = netif_list;
|
netif = netif_list;
|
||||||
while (netif != NULL) {
|
while (netif != NULL) {
|
||||||
/* Should we join this interface ? */
|
/* Should we join this interface ? */
|
||||||
match = 0;
|
if (ip6_addr_isany(srcaddr) ||
|
||||||
if (ip6_addr_isany(srcaddr)) {
|
netif_get_ip6_addr_match(netif, srcaddr) >= 0) {
|
||||||
match = 1;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
|
||||||
if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) &&
|
|
||||||
ip6_addr_cmp(srcaddr, netif_ip6_addr(netif, i))) {
|
|
||||||
match = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (match) {
|
|
||||||
err = mld6_joingroup_netif(netif, groupaddr);
|
err = mld6_joingroup_netif(netif, groupaddr);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
return err;
|
return err;
|
||||||
@ -406,26 +393,13 @@ mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr)
|
|||||||
{
|
{
|
||||||
err_t err = ERR_VAL; /* no matching interface */
|
err_t err = ERR_VAL; /* no matching interface */
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
u8_t match;
|
|
||||||
u8_t i;
|
|
||||||
|
|
||||||
/* loop through netif's */
|
/* loop through netif's */
|
||||||
netif = netif_list;
|
netif = netif_list;
|
||||||
while (netif != NULL) {
|
while (netif != NULL) {
|
||||||
/* Should we leave this interface ? */
|
/* Should we leave this interface ? */
|
||||||
match = 0;
|
if (ip6_addr_isany(srcaddr) ||
|
||||||
if (ip6_addr_isany(srcaddr)) {
|
netif_get_ip6_addr_match(netif, srcaddr) >= 0) {
|
||||||
match = 1;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
|
||||||
if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) &&
|
|
||||||
ip6_addr_cmp(srcaddr, netif_ip6_addr(netif, i))) {
|
|
||||||
match = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (match) {
|
|
||||||
err_t res = mld6_leavegroup_netif(netif, groupaddr);
|
err_t res = mld6_leavegroup_netif(netif, groupaddr);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
/* Store this result if we have not yet gotten a success */
|
/* Store this result if we have not yet gotten a success */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user