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 #if IS_USED(MODULE_IEEE802154_SECURITY)
27 #endif
28 #include "net/gnrc/nettype.h"
29 #include "net/netopt.h"
30 #include "net/netdev.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
46 #define NETDEV_IEEE802154_SEND_MASK (0x0028)
47 #define NETDEV_IEEE802154_RAW (0x0002)
51 #define NETDEV_IEEE802154_SRC_MODE_LONG (0x0004)
55 #define NETDEV_IEEE802154_SECURITY_EN (IEEE802154_FCF_SECURITY_EN)
56 
60 #define NETDEV_IEEE802154_ACK_REQ (IEEE802154_FCF_ACK_REQ)
61 
65 #define NETDEV_IEEE802154_FRAME_PEND (IEEE802154_FCF_FRAME_PEND)
74 #define NETDEV_RX_IEEE802154_INFO_FLAG_TIMESTAMP (0x01)
82 typedef enum {
91 
100 typedef struct {
106 #ifdef MODULE_GNRC
107  gnrc_nettype_t proto;
108 #endif
109 
113  uint16_t pan;
114 
118  uint8_t short_addr[IEEE802154_SHORT_ADDRESS_LEN];
119 
123  uint8_t long_addr[IEEE802154_LONG_ADDRESS_LEN];
124  uint8_t seq;
125  uint8_t chan;
126  uint8_t page;
127  uint16_t flags;
128  int16_t txpower;
129 #if IS_USED(MODULE_IEEE802154_SECURITY) || defined(DOXYGEN)
131 #endif
134 
139  uint64_t timestamp;
140  int16_t rssi;
141  uint8_t lqi;
142  uint8_t flags;
143 #if IS_USED(MODULE_SOCK_AUX_TIMESTAP)
144  uint64_t timestamp;
145 #endif
147 
157 
172  size_t max_len);
173 
200 int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *value,
201  size_t value_len);
202 
219 int netdev_ieee802154_dst_filter(netdev_ieee802154_t *dev, const uint8_t *mhr);
220 
233 {
234  /* generate EUI-64 and short address */
235  netdev_eui64_get(&dev->netdev, (eui64_t *)&dev->long_addr);
237  (network_uint16_t *)&dev->short_addr);
238 }
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif /* NET_NETDEV_IEEE802154_H */
Definitions low-level network driver interface.
EUI-48 and EUI-64 address provider.
struct netdev_ieee802154_rx_info netdev_ieee802154_rx_info_t
Received packet status information for IEEE 802.15.4 radios.
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:82
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.
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.
void netdev_ieee802154_reset(netdev_ieee802154_t *dev)
Reset function for ieee802154 common fields.
static void netdev_ieee802154_setup(netdev_ieee802154_t *dev)
Configure the hardware address of a IEEE 802.15.4 devices.
Definition: ieee802154.h:232
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_IEEE802154_CCA_MODE_4
ALOHA.
Definition: ieee802154.h:86
@ NETDEV_IEEE802154_CCA_MODE_2
Carrier sense only.
Definition: ieee802154.h:84
@ NETDEV_IEEE802154_CCA_MODE_1
Energy above threshold.
Definition: ieee802154.h:83
@ NETDEV_IEEE802154_CCA_MODE_6
UWB preamble sense based on the packet with the multiplexed preamble.
Definition: ieee802154.h:88
@ NETDEV_IEEE802154_CCA_MODE_5
UWB preamble sense based on the SHR of a frame.
Definition: ieee802154.h:87
@ NETDEV_IEEE802154_CCA_MODE_3
Carrier sense with energy above threshold.
Definition: ieee802154.h:85
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_eui64_get(netdev_t *netdev, eui64_t *addr)
Generates an EUI-64 address for the netdev interface.
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:50
#define IEEE802154_SHORT_ADDRESS_LEN
IEEE 802.15.4 address lengths.
Definition: ieee802154.h:44
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Definition: ieee802154.h:45
netopt_t
Global list of configuration options available throughout the network stack, e.g.
Definition: netopt.h:42
IEEE 802.15.4 security interface.
Definition of global configuration options.
Protocol type definitions.
Struct to hold IEEE 802.15.4 security information.
Received packet status information for IEEE 802.15.4 radios.
Definition: ieee802154.h:138
uint64_t timestamp
Timestamp value of a received frame in ns.
Definition: ieee802154.h:139
uint8_t flags
Flags e.g.
Definition: ieee802154.h:142
uint8_t lqi
LQI of a received frame.
Definition: ieee802154.h:141
int16_t rssi
RSSI of a received frame in dBm.
Definition: ieee802154.h:140
Extended structure to hold IEEE 802.15.4 driver state.
Definition: ieee802154.h:100
uint8_t long_addr[IEEE802154_LONG_ADDRESS_LEN]
Long address in network byte order.
Definition: ieee802154.h:123
uint8_t seq
sequence number
Definition: ieee802154.h:124
uint16_t pan
IEEE 802.15.4 specific fields.
Definition: ieee802154.h:113
uint8_t short_addr[IEEE802154_SHORT_ADDRESS_LEN]
Short address in network byte order.
Definition: ieee802154.h:118
ieee802154_sec_context_t sec_ctx
security context
Definition: ieee802154.h:130
netdev_t netdev
netdev_t base class
Definition: ieee802154.h:101
int16_t txpower
tx power in dBm
Definition: ieee802154.h:128
uint8_t chan
channel
Definition: ieee802154.h:125
uint16_t flags
flags as defined above
Definition: ieee802154.h:127
uint8_t page
channel page
Definition: ieee802154.h:126
Structure to hold driver state.
Definition: netdev.h:351
IEEE 802.15.4 header definitions.
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
Data type to represent an EUI-64.
Definition: eui64.h:55