mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #16082 from yarrick/link_state
pkg/lwip: Set netif link state properly when supported
This commit is contained in:
commit
b0364941b5
@ -23,6 +23,7 @@
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ethip6.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/netifapi.h"
|
||||
#include "lwip/netif/netdev.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
@ -81,6 +82,7 @@ err_t lwip_netdev_init(struct netif *netif)
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
LWIP_ASSERT("netif->state != NULL", (netif->state != NULL));
|
||||
netdev_t *netdev;
|
||||
netopt_enable_t enabled = 0;
|
||||
uint16_t dev_type;
|
||||
err_t res = ERR_OK;
|
||||
|
||||
@ -186,7 +188,11 @@ err_t lwip_netdev_init(struct netif *netif)
|
||||
return ERR_IF; /* device type not supported yet */
|
||||
}
|
||||
netif->flags |= NETIF_FLAG_UP;
|
||||
netif->flags |= NETIF_FLAG_LINK_UP;
|
||||
/* Set link state up if link state is unsupported, or if it is up */
|
||||
if (netdev->driver->get(netdev, NETOPT_LINK, &enabled, sizeof(enabled)) <= 0 ||
|
||||
enabled) {
|
||||
netif->flags |= NETIF_FLAG_LINK_UP;
|
||||
}
|
||||
netif->flags |= NETIF_FLAG_IGMP;
|
||||
netif->flags |= NETIF_FLAG_MLD6;
|
||||
netdev->context = netif;
|
||||
@ -290,12 +296,17 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef MODULE_LWIP_DHCP_AUTO
|
||||
case NETDEV_EVENT_LINK_UP: {
|
||||
dhcp_start(netif);
|
||||
netifapi_netif_set_link_up(netif);
|
||||
#ifdef MODULE_LWIP_DHCP_AUTO
|
||||
netifapi_dhcp_start(netif);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case NETDEV_EVENT_LINK_DOWN: {
|
||||
netifapi_netif_set_link_down(netif);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -56,6 +56,12 @@ extern "C" {
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif /* MODULE_LWIP_ETHERNET */
|
||||
|
||||
#ifdef MODULE_LWIP_NETIF
|
||||
#define LWIP_NETIF_API 1
|
||||
#else /* MODULE_LWIP_NETIF */
|
||||
#define LWIP_NETIF_API 0
|
||||
#endif /* MODULE_LWIP_NETIF */
|
||||
|
||||
#ifdef MODULE_LWIP_IGMP
|
||||
#define LWIP_IGMP 1
|
||||
#else /* MODULE_LWIP_IGMP */
|
||||
|
Loading…
Reference in New Issue
Block a user