Skip to content

Commit 88c9dd8

Browse files
Arun SRyoheiHagimoto
authored andcommitted
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 7d1b2e2 commit 88c9dd8

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
@@ -565,6 +565,41 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
565565
#endif //LWIP_ETHERNET
566566
}
567567

568+
nsapi_error_t LWIP::remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out)
569+
{
570+
#if LWIP_ETHERNET
571+
572+
if ((interface_out != NULL) && (*interface_out != NULL)) {
573+
574+
Interface *lwip = static_cast<Interface *>(*interface_out);
575+
Interface *node = lwip->list;
576+
577+
if (lwip->list != NULL) {
578+
if (lwip->list == lwip) {
579+
lwip->list = lwip->list->next;
580+
netif_remove(&node->netif);
581+
*interface_out = NULL;
582+
delete node;
583+
} else {
584+
while (node->next != NULL && node->next != lwip) {
585+
node = node->next;
586+
}
587+
if (node->next != NULL && node->next == lwip) {
588+
Interface *remove = node->next;
589+
node->next = node->next->next;
590+
netif_remove(&remove->netif);
591+
*interface_out = NULL;
592+
delete remove;
593+
}
594+
}
595+
}
596+
}
597+
598+
return NSAPI_ERROR_OK;
599+
#else
600+
return NSAPI_ERROR_UNSUPPORTED;
601+
#endif //LWIP_ETHERNET
602+
}
568603

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

features/lwipstack/LWIPStack.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable<LWIP> {
288288
* @param[out] interface_out pointer to stack interface object controlling the L3IP
289289
* @return NSAPI_ERROR_OK on success, or error code
290290
*/
291+
virtual nsapi_error_t remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out);
292+
293+
/** Remove a network interface from IP stack
294+
*
295+
* Removes PPP objects,network interface from stack list, and shutdown device driver.
296+
* @param[out] interface_out pointer to stack interface object controlling the PPP
297+
* @return NSAPI_ERROR_OK on success, or error code
298+
*/
291299
virtual nsapi_error_t remove_l3ip_interface(OnboardNetworkStack::Interface **interface_out);
292300

293301
/** 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
@@ -169,6 +169,11 @@ class OnboardNetworkStack : public NetworkStack {
169169
return NSAPI_ERROR_UNSUPPORTED;
170170
};
171171

172+
virtual nsapi_error_t remove_ethernet_interface(Interface **interface_out)
173+
{
174+
return NSAPI_ERROR_OK;
175+
};
176+
172177
virtual nsapi_error_t remove_l3ip_interface(Interface **interface_out)
173178
{
174179
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)