Skip to content

Commit 18285e1

Browse files
author
Arun S
committed
Pairing fails when IPv6 enabled in SoftAP intf
Issue: udp_sendto() Fails for multicast IPV6 packet when interface is switched from SoftAP to STA mode. When SoftAP start is called, add_ethernet_interface() will be called internally to add interface details into netif_list. When switching from SoftAP to STA mode, add_ethernet_interface() will be called again to append the interace details into netif_list. When udp_sendto() is called, ip6_route() will return interface as NULL since it consider device as single interface. Fix: SoftAP mode Stop, call remove_ethernet_interface() to remove the interface from the netif_list.
1 parent fd22997 commit 18285e1

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

features/lwipstack/LWIPInterface.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,41 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
465465
#endif //LWIP_ETHERNET
466466
}
467467

468+
nsapi_error_t LWIP::remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out)
469+
{
470+
#if LWIP_ETHERNET
471+
472+
if ((interface_out != NULL) && (*interface_out != NULL)) {
473+
474+
Interface *lwip = static_cast<Interface *>(*interface_out);
475+
Interface *node = lwip->list;
476+
477+
if (lwip->list != NULL) {
478+
if (lwip->list == lwip) {
479+
lwip->list = lwip->list->next;
480+
netif_remove(&node->netif);
481+
*interface_out = NULL;
482+
delete node;
483+
} else {
484+
while (node->next != NULL && node->next != lwip) {
485+
node = node->next;
486+
}
487+
if (node->next != NULL && node->next == lwip) {
488+
Interface *remove = node->next;
489+
node->next = node->next->next;
490+
netif_remove(&remove->netif);
491+
*interface_out = NULL;
492+
delete remove;
493+
}
494+
}
495+
}
496+
}
497+
498+
return NSAPI_ERROR_OK;
499+
#else
500+
return NSAPI_ERROR_UNSUPPORTED;
501+
#endif //LWIP_ETHERNET
502+
}
468503

469504
nsapi_error_t LWIP::add_l3ip_interface(L3IP &l3ip, bool default_if, OnboardNetworkStack::Interface **interface_out)
470505
{

features/lwipstack/LWIPStack.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable<LWIP> {
281281
* @param[out] interface_out pointer to stack interface object controlling the L3IP
282282
* @return NSAPI_ERROR_OK on success, or error code
283283
*/
284+
virtual nsapi_error_t remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out);
285+
286+
/** Remove a network interface from IP stack
287+
*
288+
* Removes PPP objects,network interface from stack list, and shutdown device driver.
289+
* @param[out] interface_out pointer to stack interface object controlling the PPP
290+
* @return NSAPI_ERROR_OK on success, or error code
291+
*/
284292
virtual nsapi_error_t remove_l3ip_interface(OnboardNetworkStack::Interface **interface_out);
285293

286294
/** Remove a network interface from IP stack

features/netsocket/OnboardNetworkStack.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ class OnboardNetworkStack : public NetworkStack {
181181
return NSAPI_ERROR_UNSUPPORTED;
182182
};
183183

184+
virtual nsapi_error_t remove_ethernet_interface(Interface **interface_out)
185+
{
186+
return NSAPI_ERROR_OK;
187+
};
188+
184189
virtual nsapi_error_t remove_l3ip_interface(Interface **interface_out)
185190
{
186191
return NSAPI_ERROR_OK;

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,15 @@ nsapi_error_t WhdSTAInterface::disconnect()
355355
}
356356
whd_emac_wifi_link_state_changed(_whd_emac.ifp, WHD_FALSE);
357357

358+
// remove the interface added in connect
359+
if (_interface) {
360+
nsapi_error_t err = _stack.remove_ethernet_interface(&_interface);
361+
if (err != NSAPI_ERROR_OK) {
362+
return err;
363+
}
364+
_iface_shared.iface_sta = NULL;
365+
}
366+
358367
res = whd_wifi_deregister_event_handler(_whd_emac.ifp, sta_link_update_entry);
359368
if (res != WHD_SUCCESS) {
360369
return whd_toerror(res);

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSoftAPInterface.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ int WhdSoftAPInterface::stop(void)
201201
if (res != WHD_SUCCESS) {
202202
return whd_toerror(res);
203203
}
204+
205+
// remove the interface added in start
206+
if (_interface) {
207+
nsapi_error_t err = _stack.remove_ethernet_interface(&_interface);
208+
if (err != NSAPI_ERROR_OK) {
209+
return err;
210+
}
211+
_iface_shared.iface_softap = NULL;
212+
}
213+
204214
return NSAPI_ERROR_OK;
205215
}
206216

0 commit comments

Comments
 (0)