eui_provider.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 ML!PA Consulting GmbH
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
95 #ifndef NET_EUI_PROVIDER_H
96 #define NET_EUI_PROVIDER_H
97 
98 #include "net/eui48.h"
99 #include "net/eui64.h"
100 #include "net/netdev.h"
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
109 #define NETDEV_INDEX_ANY (0xFF)
110 
121 typedef int (*netdev_get_eui48_cb_t)(const void *arg, eui48_t *addr);
122 
133 typedef int (*netdev_get_eui64_cb_t)(const void *arg, eui64_t *addr);
134 
138 typedef struct {
140  const void *arg;
142  uint8_t index;
143 } eui48_conf_t;
144 
148 typedef struct {
150  const void *arg;
152  uint8_t index;
153 } eui64_conf_t;
154 
169 
184 
195 static inline void eui_short_from_eui64(eui64_t *addr_long,
196  network_uint16_t *addr_short)
197 {
198  /* https://tools.ietf.org/html/rfc4944#section-12 requires the first bit to
199  * 0 for unicast addresses */
200  addr_short->u8[0] = addr_long->uint8[6] & 0x7F;
201  addr_short->u8[1] = addr_long->uint8[7];
202 }
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif /* NET_EUI_PROVIDER_H */
209 
eui64_t::uint8
uint8_t uint8[8]
split into 8 8-bit words.
Definition: eui64.h:57
eui48_conf_t::provider
netdev_get_eui48_cb_t provider
function to provide an EUI-48
Definition: eui_provider.h:139
eui_short_from_eui64
static void eui_short_from_eui64(eui64_t *addr_long, network_uint16_t *addr_short)
Get a short unicast address from an EUI-64.
Definition: eui_provider.h:195
eui64_conf_t::arg
const void * arg
argument to the provider function
Definition: eui_provider.h:150
be_uint16_t
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
be_uint16_t::u8
uint8_t u8[2]
8 bit representation
Definition: byteorder.h:79
eui48_t
Data type to represent an EUI-48.
Definition: eui48.h:35
netdev_type_t
netdev_type_t
Driver types for netdev.
Definition: netdev.h:279
eui64_conf_t::type
netdev_type_t type
device type to match or NETDEV_ANY
Definition: eui_provider.h:151
eui48_conf_t::type
netdev_type_t type
device type to match or NETDEV_ANY
Definition: eui_provider.h:141
eui64_conf_t::provider
netdev_get_eui64_cb_t provider
function to provide an EUI-64
Definition: eui_provider.h:149
netdev.h
Definitions low-level network driver interface.
eui48_conf_t::index
uint8_t index
device index to match or NETDEV_INDEX_ANY
Definition: eui_provider.h:142
netdev_eui48_get
void netdev_eui48_get(netdev_t *netdev, eui48_t *addr)
Generates an EUI-48 address for the netdev interface.
netdev
Structure to hold driver state.
Definition: netdev.h:302
eui48_conf_t::arg
const void * arg
argument to the provider function
Definition: eui_provider.h:140
netdev_eui64_get
void netdev_eui64_get(netdev_t *netdev, eui64_t *addr)
Generates an EUI-64 address for the netdev interface.
eui64_t
Data type to represent an EUI-64.
Definition: eui64.h:55
eui64.h
EUI-64 data type definition.
netdev_get_eui64_cb_t
int(* netdev_get_eui64_cb_t)(const void *arg, eui64_t *addr)
Function for providing a EUI-64 to a device.
Definition: eui_provider.h:133
netdev_get_eui48_cb_t
int(* netdev_get_eui48_cb_t)(const void *arg, eui48_t *addr)
Function for providing a EUI-48 to a device.
Definition: eui_provider.h:121
eui64_conf_t
Structure to hold providers for EUI-64 addresses.
Definition: eui_provider.h:148
eui64_conf_t::index
uint8_t index
device index to match or NETDEV_INDEX_ANY
Definition: eui_provider.h:152
eui48_conf_t
Structure to hold providers for EUI-48 addresses.
Definition: eui_provider.h:138
eui48.h
Definition and IPv6 IID conversion for IEEE EUI-48 identifiers.