ethernet.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for
6  * more details.
7  */
8 
22 #ifndef ETHERNET_H
23 #define ETHERNET_H
24 
25 #include <stdint.h>
26 
27 #include "net/ethernet/hdr.h"
28 #include "net/eui64.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define ETHERNET_DATA_LEN (1500)
35 #define ETHERNET_FCS_LEN (4)
41 #define ETHERNET_FRAME_LEN (ETHERNET_DATA_LEN + sizeof(ethernet_hdr_t))
42 #define ETHERNET_MIN_LEN (64)
48 #define ETHERNET_MAX_LEN (ETHERNET_FRAME_LEN + ETHERNET_FCS_LEN)
49 
61 static inline void ethernet_get_iid(eui64_t *eui64, uint8_t *mac)
62 {
63  eui64->uint8[0] = mac[0] ^ 0x02;
64  eui64->uint8[1] = mac[1];
65  eui64->uint8[2] = mac[2];
66  eui64->uint8[3] = 0xff;
67  eui64->uint8[4] = 0xfe;
68  eui64->uint8[5] = mac[3];
69  eui64->uint8[6] = mac[4];
70  eui64->uint8[7] = mac[5];
71 }
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif /* ETHERNET_H */
78 
EUI-64 data type definition.
static void ethernet_get_iid(eui64_t *eui64, uint8_t *mac)
Generates an IPv6 interface identifier from a 48-bit MAC address.
Definition: ethernet.h:63
uint8_t uint8[8]
split into 8 8-bit words.
Definition: eui64.h:39
Ethernet header definitions.
Data type to represent an EUI-64.
Definition: eui64.h:37