Skip to content

Commit 8b829e5

Browse files
authored
Merge pull request #12312 from cy-arsm/cy-arsm/pr/ipv6-fix-SoftAPmode
Fix to sending IPV6 UPD packet fails IPv6 enabled in SoftAP intf
2 parents 250e581 + 18285e1 commit 8b829e5

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

Diff for: features/lwipstack/LWIPInterface.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,41 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
508508
#endif //LWIP_ETHERNET
509509
}
510510

511+
nsapi_error_t LWIP::remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out)
512+
{
513+
#if LWIP_ETHERNET
514+
515+
if ((interface_out != NULL) && (*interface_out != NULL)) {
516+
517+
Interface *lwip = static_cast<Interface *>(*interface_out);
518+
Interface *node = lwip->list;
519+
520+
if (lwip->list != NULL) {
521+
if (lwip->list == lwip) {
522+
lwip->list = lwip->list->next;
523+
netif_remove(&node->netif);
524+
*interface_out = NULL;
525+
delete node;
526+
} else {
527+
while (node->next != NULL && node->next != lwip) {
528+
node = node->next;
529+
}
530+
if (node->next != NULL && node->next == lwip) {
531+
Interface *remove = node->next;
532+
node->next = node->next->next;
533+
netif_remove(&remove->netif);
534+
*interface_out = NULL;
535+
delete remove;
536+
}
537+
}
538+
}
539+
}
540+
541+
return NSAPI_ERROR_OK;
542+
#else
543+
return NSAPI_ERROR_UNSUPPORTED;
544+
#endif //LWIP_ETHERNET
545+
}
511546

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

Diff for: features/lwipstack/LWIPStack.h

+8
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable<LWIP> {
276276
* @param[out] interface_out pointer to stack interface object controlling the L3IP
277277
* @return NSAPI_ERROR_OK on success, or error code
278278
*/
279+
virtual nsapi_error_t remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out);
280+
281+
/** Remove a network interface from IP stack
282+
*
283+
* Removes PPP objects,network interface from stack list, and shutdown device driver.
284+
* @param[out] interface_out pointer to stack interface object controlling the PPP
285+
* @return NSAPI_ERROR_OK on success, or error code
286+
*/
279287
virtual nsapi_error_t remove_l3ip_interface(OnboardNetworkStack::Interface **interface_out);
280288

281289
/** Remove a network interface from IP stack

Diff for: features/netsocket/OnboardNetworkStack.h

+5
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ class OnboardNetworkStack : public NetworkStack {
157157
return NSAPI_ERROR_UNSUPPORTED;
158158
};
159159

160+
virtual nsapi_error_t remove_ethernet_interface(Interface **interface_out)
161+
{
162+
return NSAPI_ERROR_OK;
163+
};
164+
160165
virtual nsapi_error_t remove_l3ip_interface(Interface **interface_out)
161166
{
162167
return NSAPI_ERROR_OK;

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

+9
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);

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

+10
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)