Skip to content

Added clearing of ipv6 addresses to lwip bringdown function #3193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions features/FEATURE_LWIP/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,20 @@ static void mbed_lwip_netif_status_irq(struct netif *lwip_netif)
{
static bool any_addr = true;

// Indicates that has address
if (any_addr == true && mbed_lwip_get_ip_addr(true, lwip_netif)) {
sys_sem_signal(&lwip_netif_has_addr);
any_addr = false;
return;
}
if (netif_is_up(lwip_netif)) {
// Indicates that has address
if (any_addr == true && mbed_lwip_get_ip_addr(true, lwip_netif)) {
sys_sem_signal(&lwip_netif_has_addr);
any_addr = false;
return;
}

// Indicates that has preferred address
if (mbed_lwip_get_ip_addr(false, lwip_netif)) {
sys_sem_signal(&lwip_netif_has_addr);
// Indicates that has preferred address
if (mbed_lwip_get_ip_addr(false, lwip_netif)) {
sys_sem_signal(&lwip_netif_has_addr);
}
} else {
any_addr = true;
}
}

Expand Down Expand Up @@ -509,6 +513,15 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
return 0;
}

#if LWIP_IPV6
void mbed_lwip_clear_ipv6_addresses(struct netif *lwip_netif)
{
for (u8_t i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
netif_ip6_addr_set_state(lwip_netif, i, IP6_ADDR_INVALID);
}
}
#endif

nsapi_error_t mbed_lwip_bringdown(void)
{
// Check if we've connected
Expand All @@ -522,13 +535,18 @@ nsapi_error_t mbed_lwip_bringdown(void)
dhcp_release(&lwip_netif);
dhcp_stop(&lwip_netif);
lwip_dhcp = false;
} else {
netif_set_down(&lwip_netif);
}
#endif

netif_set_down(&lwip_netif);

#if LWIP_IPV6
mbed_lwip_clear_ipv6_addresses(&lwip_netif);
#endif

sys_sem_free(&lwip_netif_has_addr);
sys_sem_new(&lwip_netif_has_addr, 0);
lwip_connected = false;
// TO DO - actually remove addresses from stack, and shut down properly
return 0;
}

Expand Down