Loading...
Searching...
No Matches
eui_provider.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 ML!PA Consulting GmbH
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
97
98#include "net/eui48.h"
99#include "net/eui64.h"
100#include "net/netdev.h"
101
102#ifdef __cplusplus
103extern "C" {
104#endif
105
116typedef int (*netdev_get_eui48_cb_t)(uint8_t index, eui48_t *addr);
117
128typedef int (*netdev_get_eui64_cb_t)(uint8_t index, eui64_t *addr);
129
138
147
162
177
188static inline void eui_short_from_eui64(eui64_t *addr_long,
189 network_uint16_t *addr_short)
190{
191 /* https://tools.ietf.org/html/rfc4944#section-12 requires the first bit to
192 * 0 for unicast addresses */
193 addr_short->u8[0] = addr_long->uint8[6] & 0x7F;
194 addr_short->u8[1] = addr_long->uint8[7];
195}
196
197#ifdef __cplusplus
198}
199#endif
200
be_uint16_t network_uint16_t
A 16 bit integer in network byte order.
Definition byteorder.h:104
Definitions low-level network driver interface.
Definition and IPv6 IID conversion for IEEE EUI-48 identifiers.
EUI-64 data type definition.
struct netdev netdev_t
Forward declaration for netdev struct.
Definition netdev.h:285
netdev_type_t
Driver types for netdev.
Definition netdev.h:303
int(* netdev_get_eui48_cb_t)(uint8_t index, eui48_t *addr)
Function for providing a EUI-48 to a device.
static void eui_short_from_eui64(eui64_t *addr_long, network_uint16_t *addr_short)
Get a short unicast address from an EUI-64.
void netdev_eui48_get(netdev_t *netdev, eui48_t *addr)
Generates an EUI-48 address for the netdev interface.
int(* netdev_get_eui64_cb_t)(uint8_t index, eui64_t *addr)
Function for providing a EUI-64 to a device.
void netdev_eui64_get(netdev_t *netdev, eui64_t *addr)
Generates an EUI-64 address for the netdev interface.
Structure to hold providers for EUI-48 addresses.
netdev_type_t type
device type to match
uint8_t index
device index to match or NETDEV_INDEX_ANY
netdev_get_eui48_cb_t provider
function to provide an EUI-48
Data type to represent an EUI-48.
Definition eui48.h:31
Structure to hold providers for EUI-64 addresses.
netdev_type_t type
device type to match
uint8_t index
device index to match or NETDEV_INDEX_ANY
netdev_get_eui64_cb_t provider
function to provide an EUI-64
Structure to hold driver state.
Definition netdev.h:363
uint8_t u8[2]
8 bit representation
Definition byteorder.h:72
Data type to represent an EUI-64.
Definition eui64.h:52
uint8_t uint8[8]
split into 8 8-bit words.
Definition eui64.h:54