ieee802154.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2019 Freie Universität Berlin
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 
20 #ifndef NET_NETDEV_IEEE802154_H
21 #define NET_NETDEV_IEEE802154_H
22 
23 #include "net/eui_provider.h"
24 #include "net/ieee802154.h"
25 #include "net/gnrc/nettype.h"
26 #include "net/netopt.h"
27 #include "net/netdev.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
43 #define NETDEV_IEEE802154_SEND_MASK (0x0028)
44 #define NETDEV_IEEE802154_RAW (0x0002)
48 #define NETDEV_IEEE802154_SRC_MODE_LONG (0x0004)
49 
52 #define NETDEV_IEEE802154_SECURITY_EN (IEEE802154_FCF_SECURITY_EN)
53 
57 #define NETDEV_IEEE802154_ACK_REQ (IEEE802154_FCF_ACK_REQ)
58 
62 #define NETDEV_IEEE802154_FRAME_PEND (IEEE802154_FCF_FRAME_PEND)
63 
72 typedef enum {
81 
90 typedef struct {
96 #ifdef MODULE_GNRC
97  gnrc_nettype_t proto;
98 #endif
99 
103  uint16_t pan;
104 
108  uint8_t short_addr[IEEE802154_SHORT_ADDRESS_LEN];
109 
113  uint8_t long_addr[IEEE802154_LONG_ADDRESS_LEN];
114  uint8_t seq;
115  uint8_t chan;
116  uint8_t page;
117  uint16_t flags;
118  int16_t txpower;
121 
126 
136 
137 
151 int netdev_ieee802154_get(netdev_ieee802154_t *dev, netopt_t opt, void *value,
152  size_t max_len);
153 
180 int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *value,
181  size_t value_len);
182 
196 int netdev_ieee802154_dst_filter(netdev_ieee802154_t *dev, const uint8_t *mhr);
197 
210 {
211  /* generate EUI-64 and short address */
212  netdev_eui64_get(&dev->netdev, (eui64_t *)&dev->long_addr);
214  (network_uint16_t *)&dev->short_addr);
215 }
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* NET_NETDEV_IEEE802154_H */
222 
netdev_ieee802154_t::short_addr
uint8_t short_addr[IEEE802154_SHORT_ADDRESS_LEN]
Short address in network byte order.
Definition: ieee802154.h:108
netopt_t
netopt_t
Global list of configuration options available throughout the network stack, e.g.
Definition: netopt.h:50
netdev_ieee802154_reset
void netdev_ieee802154_reset(netdev_ieee802154_t *dev)
Reset function for ieee802154 common fields.
ieee802154.h
IEEE 802.15.4 header definitions.
netdev_ieee802154_t::long_addr
uint8_t long_addr[IEEE802154_LONG_ADDRESS_LEN]
Long address in network byte order.
Definition: ieee802154.h:113
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
eui_provider.h
EUI-48 and EUI-64 address provider.
be_uint16_t
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
netdev_ieee802154_t::pan
uint16_t pan
IEEE 802.15.4 specific fields.
Definition: ieee802154.h:103
netopt.h
Definition of global configuration options.
netdev_ieee802154_t::seq
uint8_t seq
sequence number
Definition: ieee802154.h:114
NETDEV_IEEE802154_CCA_MODE_1
@ NETDEV_IEEE802154_CCA_MODE_1
Energy above threshold.
Definition: ieee802154.h:73
netdev_ieee802154_setup
static void netdev_ieee802154_setup(netdev_ieee802154_t *dev)
Configure the hardware address of a IEEE 802.15.4 devices.
Definition: ieee802154.h:209
netdev_ieee802154_set
int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *value, size_t value_len)
Fallback function for netdev IEEE 802.15.4 devices' _set function.
netdev.h
Definitions low-level network driver interface.
IEEE802154_SHORT_ADDRESS_LEN
#define IEEE802154_SHORT_ADDRESS_LEN
IEEE 802.15.4 address lengths.
Definition: ieee802154.h:43
nettype.h
Protocol type definitions.
netdev_ieee802154_t::netdev
netdev_t netdev
netdev_t base class
Definition: ieee802154.h:91
netdev_ieee802154_t::flags
uint16_t flags
flags as defined above
Definition: ieee802154.h:117
netdev
Structure to hold driver state.
Definition: netdev.h:302
gnrc_nettype_t
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:50
NETDEV_IEEE802154_CCA_MODE_2
@ NETDEV_IEEE802154_CCA_MODE_2
Carrier sense only.
Definition: ieee802154.h:74
netdev_ieee802154_t
Extended structure to hold IEEE 802.15.4 driver state.
Definition: ieee802154.h:90
IEEE802154_LONG_ADDRESS_LEN
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Definition: ieee802154.h:44
netdev_ieee802154_dst_filter
int netdev_ieee802154_dst_filter(netdev_ieee802154_t *dev, const uint8_t *mhr)
This function compares destination address and pan id with addresses and pan id of the device.
netdev_ieee802154_t::page
uint8_t page
channel page
Definition: ieee802154.h:116
NETDEV_IEEE802154_CCA_MODE_4
@ NETDEV_IEEE802154_CCA_MODE_4
ALOHA.
Definition: ieee802154.h:76
netdev_ieee802154_cca_mode_t
netdev_ieee802154_cca_mode_t
Option parameter to be used with NETOPT_CCA_MODE to set the mode of the clear channel assessment (CCA...
Definition: ieee802154.h:72
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
netdev_ieee802154_t::chan
uint8_t chan
channel
Definition: ieee802154.h:115
netdev_ieee802154_t::txpower
int16_t txpower
tx power in dBm
Definition: ieee802154.h:118
netdev_radio_rx_info
Received frame status information for most radios.
Definition: netdev.h:258
NETDEV_IEEE802154_CCA_MODE_6
@ NETDEV_IEEE802154_CCA_MODE_6
UWB preamble sense based on the packet with the multiplexed preamble.
Definition: ieee802154.h:78
netdev_ieee802154_get
int netdev_ieee802154_get(netdev_ieee802154_t *dev, netopt_t opt, void *value, size_t max_len)
Fallback function for netdev IEEE 802.15.4 devices' _get function.
NETDEV_IEEE802154_CCA_MODE_3
@ NETDEV_IEEE802154_CCA_MODE_3
Carrier sense with energy above threshold.
Definition: ieee802154.h:75
NETDEV_IEEE802154_CCA_MODE_5
@ NETDEV_IEEE802154_CCA_MODE_5
UWB preamble sense based on the SHR of a frame.
Definition: ieee802154.h:77