mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12791 from cy-arsm/cy-arsm/pr/IPv6_Dual_stack_fix
Fix for IPv6 Dual Stack supportpull/12815/head
commit
ac21ee90a8
|
@ -388,6 +388,10 @@ LWIP::Interface::Interface() :
|
|||
attr.cb_mem = &has_any_addr_sem;
|
||||
attr.cb_size = sizeof has_any_addr_sem;
|
||||
has_any_addr = osSemaphoreNew(UINT16_MAX, 0, &attr);
|
||||
|
||||
attr.cb_mem = &remove_interface_sem;
|
||||
attr.cb_size = sizeof remove_interface_sem;
|
||||
remove_interface = osSemaphoreNew(UINT16_MAX, 0, &attr);
|
||||
#if PREF_ADDR_TIMEOUT
|
||||
attr.cb_mem = &has_pref_addr_sem;
|
||||
attr.cb_size = sizeof has_pref_addr_sem;
|
||||
|
@ -459,6 +463,50 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
|
|||
#endif //LWIP_ETHERNET
|
||||
}
|
||||
|
||||
void LWIP::Interface::delete_interface(OnboardNetworkStack::Interface **interface_out)
|
||||
{
|
||||
#if LWIP_ETHERNET
|
||||
if ((interface_out != NULL) && (*interface_out != NULL)) {
|
||||
LWIP::Interface *lwip = static_cast<Interface *>(*interface_out);
|
||||
LWIP::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;
|
||||
}
|
||||
}
|
||||
}
|
||||
osSemaphoreRelease(lwip->remove_interface);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsapi_error_t LWIP::remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out)
|
||||
{
|
||||
#if LWIP_ETHERNET
|
||||
LWIP::Interface *lwip = static_cast<Interface *>(*interface_out);
|
||||
tcpip_callback_with_block((tcpip_callback_fn)&LWIP::Interface::delete_interface, interface_out, 1);
|
||||
osSemaphoreAcquire(lwip->remove_interface, osWaitForever);
|
||||
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)
|
||||
{
|
||||
#if LWIP_L3IP
|
||||
|
|
|
@ -161,6 +161,7 @@ public:
|
|||
static void netif_link_irq(struct netif *netif);
|
||||
static void netif_status_irq(struct netif *netif);
|
||||
static Interface *our_if_from_netif(struct netif *netif);
|
||||
static void delete_interface(OnboardNetworkStack::Interface **interface_out);
|
||||
|
||||
#if LWIP_ETHERNET
|
||||
static err_t emac_low_level_output(struct netif *netif, struct pbuf *p);
|
||||
|
@ -220,6 +221,8 @@ public:
|
|||
void *hw; /**< alternative implementation pointer - used for PPP */
|
||||
};
|
||||
|
||||
mbed_rtos_storage_semaphore_t remove_interface_sem;
|
||||
osSemaphoreId_t remove_interface;
|
||||
mbed_rtos_storage_semaphore_t linked_sem;
|
||||
osSemaphoreId_t linked;
|
||||
mbed_rtos_storage_semaphore_t unlinked_sem;
|
||||
|
@ -294,6 +297,14 @@ public:
|
|||
*/
|
||||
nsapi_error_t add_ppp_interface(PPP &ppp, bool default_if, OnboardNetworkStack::Interface **interface_out) override;
|
||||
|
||||
/** Remove a network interface from IP stack
|
||||
*
|
||||
* Removes layer 3 IP objects,network interface from stack list .
|
||||
* @param[out] interface_out pointer to stack interface object controlling the EMAC
|
||||
* @return NSAPI_ERROR_OK on success, or error code
|
||||
*/
|
||||
nsapi_error_t remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out) override;
|
||||
|
||||
/** Remove a network interface from IP stack
|
||||
*
|
||||
* Removes PPP objects,network interface from stack list, and shutdown device driver.
|
||||
|
|
|
@ -171,6 +171,11 @@ public:
|
|||
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;
|
||||
|
|
|
@ -381,6 +381,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) {
|
||||
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);
|
||||
|
|
|
@ -201,6 +201,15 @@ 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue