diff options
Diffstat (limited to 'include/linux/ieee802154.h')
-rw-r--r-- | include/linux/ieee802154.h | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h index 1dc1f4ed4001..d3e415674dac 100644 --- a/include/linux/ieee802154.h +++ b/include/linux/ieee802154.h | |||
@@ -25,12 +25,22 @@ | |||
25 | 25 | ||
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #include <linux/random.h> | 27 | #include <linux/random.h> |
28 | #include <asm/byteorder.h> | ||
29 | 28 | ||
30 | #define IEEE802154_MTU 127 | 29 | #define IEEE802154_MTU 127 |
31 | #define IEEE802154_ACK_PSDU_LEN 5 | 30 | #define IEEE802154_ACK_PSDU_LEN 5 |
32 | #define IEEE802154_MIN_PSDU_LEN 9 | 31 | #define IEEE802154_MIN_PSDU_LEN 9 |
33 | #define IEEE802154_FCS_LEN 2 | 32 | #define IEEE802154_FCS_LEN 2 |
33 | #define IEEE802154_MAX_AUTH_TAG_LEN 16 | ||
34 | |||
35 | /* General MAC frame format: | ||
36 | * 2 bytes: Frame Control | ||
37 | * 1 byte: Sequence Number | ||
38 | * 20 bytes: Addressing fields | ||
39 | * 14 bytes: Auxiliary Security Header | ||
40 | */ | ||
41 | #define IEEE802154_MAX_HEADER_LEN (2 + 1 + 20 + 14) | ||
42 | #define IEEE802154_MIN_HEADER_LEN (IEEE802154_ACK_PSDU_LEN - \ | ||
43 | IEEE802154_FCS_LEN) | ||
34 | 44 | ||
35 | #define IEEE802154_PAN_ID_BROADCAST 0xffff | 45 | #define IEEE802154_PAN_ID_BROADCAST 0xffff |
36 | #define IEEE802154_ADDR_SHORT_BROADCAST 0xffff | 46 | #define IEEE802154_ADDR_SHORT_BROADCAST 0xffff |
@@ -205,6 +215,41 @@ enum { | |||
205 | IEEE802154_SCAN_IN_PROGRESS = 0xfc, | 215 | IEEE802154_SCAN_IN_PROGRESS = 0xfc, |
206 | }; | 216 | }; |
207 | 217 | ||
218 | /* frame control handling */ | ||
219 | #define IEEE802154_FCTL_FTYPE 0x0003 | ||
220 | #define IEEE802154_FCTL_ACKREQ 0x0020 | ||
221 | #define IEEE802154_FCTL_INTRA_PAN 0x0040 | ||
222 | |||
223 | #define IEEE802154_FTYPE_DATA 0x0001 | ||
224 | |||
225 | /* | ||
226 | * ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA | ||
227 | * @fc: frame control bytes in little-endian byteorder | ||
228 | */ | ||
229 | static inline int ieee802154_is_data(__le16 fc) | ||
230 | { | ||
231 | return (fc & cpu_to_le16(IEEE802154_FCTL_FTYPE)) == | ||
232 | cpu_to_le16(IEEE802154_FTYPE_DATA); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * ieee802154_is_ackreq - check if acknowledgment request bit is set | ||
237 | * @fc: frame control bytes in little-endian byteorder | ||
238 | */ | ||
239 | static inline bool ieee802154_is_ackreq(__le16 fc) | ||
240 | { | ||
241 | return fc & cpu_to_le16(IEEE802154_FCTL_ACKREQ); | ||
242 | } | ||
243 | |||
244 | /** | ||
245 | * ieee802154_is_intra_pan - check if intra pan id communication | ||
246 | * @fc: frame control bytes in little-endian byteorder | ||
247 | */ | ||
248 | static inline bool ieee802154_is_intra_pan(__le16 fc) | ||
249 | { | ||
250 | return fc & cpu_to_le16(IEEE802154_FCTL_INTRA_PAN); | ||
251 | } | ||
252 | |||
208 | /** | 253 | /** |
209 | * ieee802154_is_valid_psdu_len - check if psdu len is valid | 254 | * ieee802154_is_valid_psdu_len - check if psdu len is valid |
210 | * available lengths: | 255 | * available lengths: |