Loading...
Searching...
No Matches
IEEE EUI-48/64 provider

MAC address management. More...

Detailed Description

MAC address management.

About

An EUI provider provides an Extended Unique Identifier, that is a hardware address for a network device.

A board may have an EEPROM with a unique ID (e.g. AT24MAC unique ID chip) that is used to store an address, a unique address is stored in a config area of the board's flash during production, etc.

The EUI provider is connected to a network device that will then use this address.

How it works

If there is only one EUI provider on the board, the configuration is done through three defines:

If more than one EUI provider is present on the board, an array of euiXX_conf_t has to be provided to EUI64_PROVIDER_PARAMS:

#define EUI64_PROVIDER_PARAMS { \
.provider = _board_get_eui, \
.arg = BOARD_ADDR_SUBGHZ, \
.type = NETDEV_AT86RF215, \
.index = 0, }, \
{ \
.provider = _board_get_eui, \
.arg = BOARD_ADDR_24GHZ, \
.type = NETDEV_AT86RF215, \
.index = 1, }

This also assumes a _board_get_eui() function to provide the EUI. For example, it could read an EUI from a config region on the flash that is provided with the memory-mapped addresses BOARD_ADDR_SUBGHZ and BOARD_ADDR_24GHZ. The function would then do

static inline int _board_get_eui(const void *src, eui64_t *addr)
{
memcpy(addr, src, sizeof(*addr));
return 0;
}
Data type to represent an EUI-64.
Definition eui64.h:55

Recommendations

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 the second interface will now use the first slot / index and therefore also use the EUI provider that was previously used by interface in the first slot.

Files

file  eui_provider.h
 EUI-48 and EUI-64 address provider.
 
file  eui48_provider_params.h
 EUI-48 address provider default values.
 
file  eui64_provider_params.h
 EUI-64 address provider default values.
 

Data Structures

struct  eui48_conf_t
 Structure to hold providers for EUI-48 addresses. More...
 
struct  eui64_conf_t
 Structure to hold providers for EUI-64 addresses. More...
 

Typedefs

typedef int(* netdev_get_eui48_cb_t) (uint8_t index, eui48_t *addr)
 Function for providing a EUI-48 to a device.
 
typedef int(* netdev_get_eui64_cb_t) (uint8_t index, eui64_t *addr)
 Function for providing a EUI-64 to a device.
 

Functions

void netdev_eui48_get (netdev_t *netdev, eui48_t *addr)
 Generates an EUI-48 address for the netdev interface.
 
void netdev_eui64_get (netdev_t *netdev, eui64_t *addr)
 Generates an EUI-64 address for the netdev interface.
 
static void eui_short_from_eui64 (eui64_t *addr_long, network_uint16_t *addr_short)
 Get a short unicast address from an EUI-64.
 

Typedef Documentation

◆ netdev_get_eui48_cb_t

typedef int(* netdev_get_eui48_cb_t) (uint8_t index, eui48_t *addr)

Function for providing a EUI-48 to a device.

Parameters
[in]indexindex of the netdev
[out]addrDestination pointer for the EUI-48 address
Returns
0 on success, next provider in eui48_conf_t will be used otherwise. Will fall back to
See also
luid_get_eui48 eventually.

Definition at line 119 of file eui_provider.h.

◆ netdev_get_eui64_cb_t

typedef int(* netdev_get_eui64_cb_t) (uint8_t index, eui64_t *addr)

Function for providing a EUI-64 to a device.

Parameters
[in]indexindex of the netdev
[out]addrDestination pointer for the EUI-64 address
Returns
0 on success, next provider in eui64_conf_t will be used otherwise. Will fall back to
See also
luid_get_eui64 eventually.

Definition at line 131 of file eui_provider.h.

Function Documentation

◆ eui_short_from_eui64()

static void eui_short_from_eui64 ( eui64_t addr_long,
network_uint16_t addr_short 
)
inlinestatic

Get a short unicast address from an EUI-64.

The resulting address is built from the provided long address. The last two bytes of the long address will be used as the short address with the first bit cleared.

Parameters
[in]addr_longthe address to base the short address on
[out]addr_shortmemory location to copy the address into.

Definition at line 191 of file eui_provider.h.

◆ netdev_eui48_get()

void netdev_eui48_get ( netdev_t netdev,
eui48_t addr 
)

Generates an EUI-48 address for the netdev interface.

Note
It is possible to supply a board-specific, constant address by implementing a EUI-48 provider function. If no such function is available, this will fall back to luid_get_eui48.
Parameters
[in]netdevThe network device for which the address is generated.
[out]addrThe generated EUI-48 address

◆ netdev_eui64_get()

void netdev_eui64_get ( netdev_t netdev,
eui64_t addr 
)

Generates an EUI-64 address for the netdev interface.

Note
It is possible to supply a board-specific, constant address by implementing a EUI-64 provider function. If no such function is available, this will fall back to luid_get_eui64.
Parameters
[in]netdevThe network device for which the address is generated.
[out]addrThe generated EUI-64 address