mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
drivers/slipdev: report NETOPT_ADDRESS to simulate l2 address
A lot of things break if `GNRC_NETIF_FLAGS_HAS_L2ADDR` is not set. In order to handle router advertisements and auto-configureation, generate a faux l2 address based on the netdev ID.
This commit is contained in:
parent
2a1a2ee1d5
commit
9fbab8f0f8
@ -1,4 +1,5 @@
|
||||
USEMODULE += tsrb
|
||||
USEMODULE += eui_provider
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
|
||||
ifneq (,$(filter slipdev_stdio,$(USEMODULE)))
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "log.h"
|
||||
#include "slipdev.h"
|
||||
#include "slipdev_internal.h"
|
||||
#include "net/eui_provider.h"
|
||||
|
||||
/* XXX: BE CAREFUL ABOUT USING OUTPUT WITH MODULE_SLIPDEV_STDIO IN SENDING
|
||||
* FUNCTIONALITY! MIGHT CAUSE DEADLOCK!!!1!! */
|
||||
@ -231,6 +232,12 @@ static int _get(netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
||||
assert(max_len == sizeof(uint16_t));
|
||||
*((uint16_t *)value) = NETDEV_TYPE_SLIP;
|
||||
return sizeof(uint16_t);
|
||||
#if IS_USED(MODULE_SLIPDEV_L2ADDR)
|
||||
case NETOPT_ADDRESS_LONG:
|
||||
assert(max_len == sizeof(eui64_t));
|
||||
netdev_eui64_get(netdev, value);
|
||||
return sizeof(eui64_t);
|
||||
#endif
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ PSEUDOMODULES += sched_cb
|
||||
PSEUDOMODULES += semtech_loramac_rx
|
||||
PSEUDOMODULES += shell_hooks
|
||||
PSEUDOMODULES += slipdev_stdio
|
||||
PSEUDOMODULES += slipdev_l2addr
|
||||
PSEUDOMODULES += sock
|
||||
PSEUDOMODULES += sock_async
|
||||
PSEUDOMODULES += sock_aux_local
|
||||
|
@ -143,7 +143,7 @@ extern "C" {
|
||||
* address types are included
|
||||
*/
|
||||
#ifndef GNRC_NETIF_L2ADDR_MAXLEN
|
||||
#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE)
|
||||
#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE) || defined(MODULE_SLIPDEV_L2ADDR)
|
||||
#define GNRC_NETIF_L2ADDR_MAXLEN (IEEE802154_LONG_ADDRESS_LEN)
|
||||
#elif MODULE_NETDEV_ETH
|
||||
#define GNRC_NETIF_L2ADDR_MAXLEN (ETHERNET_ADDR_LEN)
|
||||
|
@ -1364,8 +1364,13 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
assert(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR);
|
||||
assert(netif->l2addr_len >= 3U && netif->l2addr_len <= 5U);
|
||||
break;
|
||||
case NETDEV_TYPE_LORA: /* LoRa doesn't provide L2 ADDR */
|
||||
case NETDEV_TYPE_SLIP:
|
||||
#if IS_USED(MODULE_SLIPDEV_L2ADDR)
|
||||
assert(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR);
|
||||
assert(8U == netif->l2addr_len);
|
||||
break;
|
||||
#endif /* IS_USED(MODULE_SLIPDEV_L2ADDR) */
|
||||
case NETDEV_TYPE_LORA: /* LoRa doesn't provide L2 ADDR */
|
||||
assert(!(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR));
|
||||
assert(0U == netif->l2addr_len);
|
||||
/* don't check MTU here for now since I'm not sure the current
|
||||
|
@ -56,6 +56,11 @@ netopt_t gnrc_netif_get_l2addr_opt(const gnrc_netif_t *netif)
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(MODULE_SLIPDEV_L2ADDR)
|
||||
case NETDEV_TYPE_SLIP:
|
||||
res = NETOPT_ADDRESS_LONG;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
|
@ -123,6 +123,11 @@ int l2util_eui64_from_addr(int dev_type, const uint8_t *addr, size_t addr_len,
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* defined (MODULE_NRF24L01P_NG) */
|
||||
#if defined(MODULE_SLIPDEV_L2ADDR)
|
||||
case NETDEV_TYPE_SLIP:
|
||||
memcpy(eui64, addr, addr_len);
|
||||
return sizeof(eui64_t);
|
||||
#endif /* defined(MODULE_SLIPDEV_L2ADDR) */
|
||||
default:
|
||||
(void)addr;
|
||||
(void)addr_len;
|
||||
@ -230,6 +235,11 @@ int l2util_ipv6_iid_to_addr(int dev_type, const eui64_t *iid, uint8_t *addr)
|
||||
memcpy(&addr[addr_len - 3], &iid->uint8[5], 3);
|
||||
return addr_len;
|
||||
#endif /* defined(MODULE_NRF24L01P_NG) */
|
||||
#if defined(MODULE_SLIPDEV_L2ADDR)
|
||||
case NETDEV_TYPE_SLIP:
|
||||
memcpy(addr, iid, sizeof(eui64_t));
|
||||
return sizeof(eui64_t);
|
||||
#endif /* defined(MODULE_SLIP) */
|
||||
default:
|
||||
(void)iid;
|
||||
(void)addr;
|
||||
@ -288,6 +298,10 @@ int l2util_ndp_addr_len_from_l2ao(int dev_type,
|
||||
(void)opt;
|
||||
return 5; /* maximum length */
|
||||
#endif /* defined(MODULE_NRF24L01P_NG) */
|
||||
#if defined(MODULE_SLIPDEV_L2ADDR)
|
||||
case NETDEV_TYPE_SLIP:
|
||||
return sizeof(eui64_t);
|
||||
#endif /* defined(MODULE_SLIPDEV_L2ADDR) */
|
||||
default:
|
||||
(void)opt;
|
||||
#ifdef DEVELHELP
|
||||
|
Loading…
Reference in New Issue
Block a user