Skip to content

Commit

Permalink
LWIP::get_ipv6_addr fixed to avoid returning NULL even if only linklo…
Browse files Browse the repository at this point in the history
…cal adress exits.
  • Loading branch information
tymoteuszblochmobica committed Nov 8, 2019
1 parent 9c82706 commit 686ec73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions features/lwipstack/LWIPInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,13 @@ void LWIP::Interface::netif_status_irq(struct netif *netif)

if (interface->has_addr_state & HAS_ANY_ADDR) {
interface->connected = NSAPI_STATUS_GLOBAL_UP;
#if LWIP_IPV6
if (ip6_addr_islinklocal(get_ipv6_addr(netif))) {
interface->connected = NSAPI_STATUS_LOCAL_UP;
}
#endif
}

} else if (!netif_is_up(&interface->netif) && netif_is_link_up(&interface->netif)) {
interface->connected = NSAPI_STATUS_DISCONNECTED;
}
Expand Down
6 changes: 6 additions & 0 deletions features/lwipstack/lwip_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ const ip_addr_t *LWIP::get_ipv6_addr(const struct netif *netif)
return netif_ip_addr6(netif, i);
}
}

for (int i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) {
return netif_ip_addr6(netif, i);
}
}
#endif
return NULL;
}
Expand Down

0 comments on commit 686ec73

Please sign in to comment.