The friendly Operating System for the Internet of Things
types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Daniel Krebs
3  * 2016 INRIA
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
21 #ifndef GNRC_MAC_TYPES_H
22 #define GNRC_MAC_TYPES_H
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 #include <kernel_types.h>
27 #include <net/gnrc.h>
29 #include <net/ieee802154.h>
30 #include <net/gnrc/mac/mac.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 typedef enum {
45 
49 #define GNRC_MAC_TX_FEEDBACK_INIT { TX_FEEDBACK_UNDEF }
50 
51 #if ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
52 
59 typedef struct {
60 #if (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN)
63 #endif /* (GNRC_MAC_RX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
64 
65 #if (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN)
67 #endif /* (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN) */
69 
73 #if ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN)
74 #define GNRC_MAC_RX_INIT { \
75  PRIORITY_PKTQUEUE_INIT, \
76  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
77  { NULL }, \
78 }
79 #elif (GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE == 0) || defined(DOXYGEN)
80 #define GNRC_MAC_RX_INIT { \
81  PRIORITY_PKTQUEUE_INIT, \
82  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
83 }
84 #elif (GNRC_MAC_RX_QUEUE_SIZE == 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0) || defined(DOXYGEN)
85 #define GNRC_MAC_RX_INIT { \
86  { NULL }, \
87 }
88 #endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
89 #endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
90 
91 #if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
92 
95 typedef struct {
96  uint8_t l2_addr[IEEE802154_LONG_ADDRESS_LEN];
97  uint8_t l2_addr_len;
98  uint32_t phase;
100 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
102 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
104 
108 #define GNRC_MAC_PHASE_UNINITIALIZED (0)
109 
113 #define GNRC_MAC_PHASE_MAX (-1)
114 
118 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
119 #define GNRC_MAC_TX_NEIGHBOR_INIT { \
120  { 0 }, \
121  0, \
122  GNRC_MAC_PHASE_UNINITIALIZED, \
123  PRIORITY_PKTQUEUE_INIT, \
124 }
125 #else
126 #define GNRC_MAC_TX_NEIGHBOR_INIT { \
127  { 0 }, \
128  0, \
129  GNRC_MAC_PHASE_UNINITIALIZED, \
130 }
131 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
132 #endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
133 
134 #if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
135 
142 typedef struct {
143 #if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
148 #endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
149 
150 #if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
151 #if (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
154 #endif /* (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
155 
158 #endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
159 } gnrc_mac_tx_t;
160 
164 #if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
165 #define GNRC_MAC_TX_INIT { \
166  { GNRC_MAC_TX_NEIGHBOR_INIT }, \
167  NULL, \
168  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
169  NULL, \
170 }
171 #elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
172 #define GNRC_MAC_TX_INIT { \
173  PRIORITY_PKTQUEUE_INIT, \
174  { PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
175  NULL, \
176 }
177 #elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
178 #define GNRC_MAC_TX_INIT { \
179  { GNRC_MAC_TX_NEIGHBOR_INIT }, \
180  NULL, \
181 }
182 #endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
183 #endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif /* GNRC_MAC_TYPES_H */
190 
Types used by the kernel.
gnrc_priority_pktqueue_t queue
If neighbor queues is not used, define a single queue for managing TX packets.
Definition: types.h:152
#define GNRC_MAC_TX_QUEUE_SIZE
The default queue size for transmission packets coming from higher layers.
Definition: mac.h:56
uint8_t l2_addr_len
Neighbor address length.
Definition: types.h:97
data type for priority queues
uint32_t phase
Neighbor's wake-up Phase.
Definition: types.h:98
#define GNRC_MAC_DISPATCH_BUFFER_SIZE
The default buffer size for storing dispatching packets.
Definition: mac.h:42
IEEE 802.15.4 header definitions.
gnrc_priority_pktqueue_t queue
TX queue for this particular Neighbor.
Definition: types.h:101
type for storing states of TX neighbor node.
Definition: types.h:95
found medium busy when doing transmission
Definition: types.h:43
Includes all essential GNRC network stack base modules.
#define GNRC_MAC_NEIGHBOR_COUNT
Count of neighbor nodes in one-hop distance.
Definition: mac.h:49
gnrc_pktsnip_t * packet
currently scheduled packet for sending
Definition: types.h:157
#define GNRC_MAC_RX_QUEUE_SIZE
The default rx queue size for incoming packets.
Definition: mac.h:35
gnrc_mac_tx_feedback_t
definition for device transmission feedback types
Definition: types.h:39
gnrc_priority_pktqueue_t queue
RX packet queue.
Definition: types.h:61
gnrc priority packet queue API
MAC internal type for storing reception state parameters and state machines.
Definition: types.h:59
Type to represent parts (either headers or payload) of a packet, called snips.
Transmission just start, no Tx feedback yet.
Definition: types.h:40
data type for gnrc priority packet queue nodes
MAC internal type for storing transmission state parameters and state machines.
Definition: types.h:142
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
gnrc_mac_tx_neighbor_t * current_neighbor
Neighbor information unit of destination node to which the current packet will be sent...
Definition: types.h:146
Definitions of GNRC_MAC.
No ACK for the transmitted packet.
Definition: types.h:42
Transmission succeeded.
Definition: types.h:41