mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 14:03:55 +01:00
Merge pull request #16523 from benpicco/boards/same54-xpro-lock_eui
boards: lock EUI provider to interface type
This commit is contained in:
commit
c7d12733ea
@ -30,7 +30,9 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
#define EUI64_PROVIDER_FUNC native_cli_get_eui64
|
||||
#define EUI64_PROVIDER_TYPE NETDEV_ANY
|
||||
#ifndef EUI64_PROVIDER_TYPE
|
||||
#define EUI64_PROVIDER_TYPE NETDEV_SOCKET_ZEP
|
||||
#endif
|
||||
#define EUI64_PROVIDER_INDEX NETDEV_INDEX_ANY
|
||||
/** @} */
|
||||
|
||||
|
||||
@ -38,6 +38,9 @@ static inline int _at24mac_get_eui48(uint8_t index, eui48_t *addr)
|
||||
* @{
|
||||
*/
|
||||
#define EUI48_PROVIDER_FUNC _at24mac_get_eui48
|
||||
#ifndef EUI48_PROVIDER_TYPE
|
||||
#define EUI48_PROVIDER_TYPE NETDEV_SAM0_ETH
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -75,10 +75,13 @@
|
||||
* Recommendations
|
||||
* ===============
|
||||
*
|
||||
* While it is possible to match EUIs with any netdev in a first come, first serve
|
||||
* fashion (`NETDEV_ANY`, `NETDEV_INDEX_ANY`) it is recommended to fix the EUI
|
||||
* providers to a device and interface to avoid them being used for 'virtual'
|
||||
* interfaces.
|
||||
* Do not use `NETDEV_ANY` as EUI device type. Otherwise if you have two
|
||||
* interfaces both will match the same EUI.
|
||||
*
|
||||
* It is however possible to use `NETDEV_INDEX_ANY` if you have multiple
|
||||
* interfaces of the same type and your EUI provider function takes the index
|
||||
* into account (or returns error if the index is out of bounds with the
|
||||
* available ids).
|
||||
*
|
||||
* Fixed addresses are only guaranteed if the network devices are also fixed.
|
||||
* E.g. if you usually have two netdevs and disable the first one at compile-time
|
||||
@ -132,7 +135,7 @@ typedef int (*netdev_get_eui64_cb_t)(uint8_t index, eui64_t *addr);
|
||||
*/
|
||||
typedef struct {
|
||||
netdev_get_eui48_cb_t provider; /**< function to provide an EUI-48 */
|
||||
netdev_type_t type; /**< device type to match or `NETDEV_ANY` */
|
||||
netdev_type_t type; /**< device type to match */
|
||||
uint8_t index; /**< device index to match or `NETDEV_INDEX_ANY` */
|
||||
} eui48_conf_t;
|
||||
|
||||
@ -141,7 +144,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
netdev_get_eui64_cb_t provider; /**< function to provide an EUI-64 */
|
||||
netdev_type_t type; /**< device type to match or `NETDEV_ANY` */
|
||||
netdev_type_t type; /**< device type to match */
|
||||
uint8_t index; /**< device index to match or `NETDEV_INDEX_ANY` */
|
||||
} eui64_conf_t;
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
*/
|
||||
|
||||
#include "assert.h"
|
||||
#include "eui48_provider_params.h"
|
||||
#include "eui64_provider_params.h"
|
||||
#include "luid.h"
|
||||
@ -23,8 +24,13 @@ void netdev_eui48_get(netdev_t *netdev, eui48_t *addr)
|
||||
unsigned i = EUI48_PROVIDER_NUMOF;
|
||||
while (i--) {
|
||||
#ifdef MODULE_NETDEV_REGISTER
|
||||
if (eui48_conf[i].type != netdev->type &&
|
||||
eui48_conf[i].type != NETDEV_ANY) {
|
||||
/* using NETDEV_ANY causes conflicts if there is another interface
|
||||
* of a different type. Require EUI providers to be locked to an
|
||||
* interface type for uniqueness.
|
||||
*/
|
||||
assert(eui48_conf[i].type != NETDEV_ANY);
|
||||
|
||||
if (eui48_conf[i].type != netdev->type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -48,8 +54,13 @@ void netdev_eui64_get(netdev_t *netdev, eui64_t *addr)
|
||||
unsigned i = EUI64_PROVIDER_NUMOF;
|
||||
while (i--) {
|
||||
#ifdef MODULE_NETDEV_REGISTER
|
||||
if (eui64_conf[i].type != netdev->type &&
|
||||
eui64_conf[i].type != NETDEV_ANY) {
|
||||
/* using NETDEV_ANY causes conflicts if there is another interface
|
||||
* of a different type. Require EUI providers to be locked to an
|
||||
* interface type for uniqueness.
|
||||
*/
|
||||
assert(eui64_conf[i].type != NETDEV_ANY);
|
||||
|
||||
if (eui64_conf[i].type != netdev->type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user