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 
98 #ifndef NET_EUI_PROVIDER_H
99 #define NET_EUI_PROVIDER_H
100 
101 #include "net/eui48.h"
102 #include "net/eui64.h"
103 #include "net/netdev.h"
104 
105 #ifdef __cplusplus
106 extern "C" {
107 #endif
108 
119 typedef int (*netdev_get_eui48_cb_t)(uint8_t index, eui48_t *addr);
120 
131 typedef int (*netdev_get_eui64_cb_t)(uint8_t index, eui64_t *addr);
132 
136 typedef struct {
139  uint8_t index;
140 } eui48_conf_t;
141 
145 typedef struct {
148  uint8_t index;
149 } eui64_conf_t;
150 
165 
180 
191 static inline void eui_short_from_eui64(eui64_t *addr_long,
192  network_uint16_t *addr_short)
193 {
194  /* https://tools.ietf.org/html/rfc4944#section-12 requires the first bit to
195  * 0 for unicast addresses */
196  addr_short->u8[0] = addr_long->uint8[6] & 0x7F;
197  addr_short->u8[1] = addr_long->uint8[7];
198 }
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* NET_EUI_PROVIDER_H */
Definitions low-level network driver interface.
Definition and IPv6 IID conversion for IEEE EUI-48 identifiers.
EUI-64 data type definition.
netdev_type_t
Driver types for netdev.
Definition: netdev.h:305
int(* netdev_get_eui48_cb_t)(uint8_t index, eui48_t *addr)
Function for providing a EUI-48 to a device.
Definition: eui_provider.h:119
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:191
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.
Definition: eui_provider.h:131
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.
Definition: eui_provider.h:136
netdev_type_t type
device type to match
Definition: eui_provider.h:138
uint8_t index
device index to match or NETDEV_INDEX_ANY
Definition: eui_provider.h:139
netdev_get_eui48_cb_t provider
function to provide an EUI-48
Definition: eui_provider.h:137
Data type to represent an EUI-48.
Definition: eui48.h:35
Structure to hold providers for EUI-64 addresses.
Definition: eui_provider.h:145
netdev_type_t type
device type to match
Definition: eui_provider.h:147
uint8_t index
device index to match or NETDEV_INDEX_ANY
Definition: eui_provider.h:148
netdev_get_eui64_cb_t provider
function to provide an EUI-64
Definition: eui_provider.h:146
Structure to hold driver state.
Definition: netdev.h:361
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
uint8_t u8[2]
8 bit representation
Definition: byteorder.h:79
Data type to represent an EUI-64.
Definition: eui64.h:55
uint8_t uint8[8]
split into 8 8-bit words.
Definition: eui64.h:57