Skip to content
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

Fix to sending IPV6 UPD packet fails IPv6 enabled in SoftAP intf #12312

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions features/lwipstack/LWIPInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,41 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
#endif //LWIP_ETHERNET
}

nsapi_error_t LWIP::remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out)
{
#if LWIP_ETHERNET

if ((interface_out != NULL) && (*interface_out != NULL)) {

Interface *lwip = static_cast<Interface *>(*interface_out);
Interface *node = lwip->list;

if (lwip->list != NULL) {
if (lwip->list == lwip) {
lwip->list = lwip->list->next;
netif_remove(&node->netif);
*interface_out = NULL;
delete node;
} else {
while (node->next != NULL && node->next != lwip) {
node = node->next;
}
if (node->next != NULL && node->next == lwip) {
Interface *remove = node->next;
node->next = node->next->next;
netif_remove(&remove->netif);
*interface_out = NULL;
delete remove;
}
}
}
}

return NSAPI_ERROR_OK;
#else
return NSAPI_ERROR_UNSUPPORTED;
#endif //LWIP_ETHERNET
}

nsapi_error_t LWIP::add_l3ip_interface(L3IP &l3ip, bool default_if, OnboardNetworkStack::Interface **interface_out)
{
Expand Down
8 changes: 8 additions & 0 deletions features/lwipstack/LWIPStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable<LWIP> {
* @param[out] interface_out pointer to stack interface object controlling the L3IP
* @return NSAPI_ERROR_OK on success, or error code
*/
virtual nsapi_error_t remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out);

/** Remove a network interface from IP stack
*
* Removes PPP objects,network interface from stack list, and shutdown device driver.
* @param[out] interface_out pointer to stack interface object controlling the PPP
* @return NSAPI_ERROR_OK on success, or error code
*/
virtual nsapi_error_t remove_l3ip_interface(OnboardNetworkStack::Interface **interface_out);

/** Remove a network interface from IP stack
Expand Down
5 changes: 5 additions & 0 deletions features/netsocket/OnboardNetworkStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ class OnboardNetworkStack : public NetworkStack {
return NSAPI_ERROR_UNSUPPORTED;
};

virtual nsapi_error_t remove_ethernet_interface(Interface **interface_out)
{
return NSAPI_ERROR_OK;
};

virtual nsapi_error_t remove_l3ip_interface(Interface **interface_out)
{
return NSAPI_ERROR_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ nsapi_error_t WhdSTAInterface::disconnect()
}
whd_emac_wifi_link_state_changed(_whd_emac.ifp, WHD_FALSE);

// remove the interface added in connect
if (_interface) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like this would prevent ever connecting again.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morser499 , local private member _interface is updated with the interface details in add_ehternet_interface()API call.
Hence _interface is updated to NULL inside remove_ethernet_interface()API call.
As part of connect interface is updated and as part of disconnect interface is removed. Hence reconnecting is not blocked.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have verified multiple time's connect -> disconnect -> connect to ensure re-connection is successful.

nsapi_error_t err = _stack.remove_ethernet_interface(&_interface);
if (err != NSAPI_ERROR_OK) {
return err;
}
_iface_shared.iface_sta = NULL;
}

res = whd_wifi_deregister_event_handler(_whd_emac.ifp, sta_link_update_entry);
if (res != WHD_SUCCESS) {
return whd_toerror(res);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ int WhdSoftAPInterface::stop(void)
if (res != WHD_SUCCESS) {
return whd_toerror(res);
}

// remove the interface added in start
if (_interface) {
nsapi_error_t err = _stack.remove_ethernet_interface(&_interface);
if (err != NSAPI_ERROR_OK) {
return err;
}
_iface_shared.iface_softap = NULL;
}

return NSAPI_ERROR_OK;
}

Expand Down