ConOpSys V2970  P004.07
ANVILEX control operating system
ieee802154.h
Go to the documentation of this file.
1 /**
2  * @file
3  * Definitions for IEEE 802.15.4 MAC frames
4  */
5 
6 /*
7  * Copyright (c) 2018 Simon Goldschmidt.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  * derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30  * OF SUCH DAMAGE.
31  *
32  * This file is part of the lwIP TCP/IP stack.
33  *
34  * Author: Simon Goldschmidt <goldsimon@gmx.de>
35  *
36  */
37 #ifndef LWIP_HDR_NETIF_IEEE802154_H
38 #define LWIP_HDR_NETIF_IEEE802154_H
39 
40 #include "lwip/opt.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #ifdef PACK_STRUCT_USE_INCLUDES
47 # include "arch/bpstruct.h"
48 #endif
50 /** General MAC frame format
51  * This shows the full featured header, mainly for documentation.
52  * Some fields are omitted or shortened to achieve frame compression.
53  */
55  /** See IEEE_802154_FC_* defines */
56  PACK_STRUCT_FIELD(u16_t frame_control);
57  /** Sequence number is omitted if IEEE_802154_FC_SEQNO_SUPPR is set in frame_control */
58  PACK_STRUCT_FLD_8(u8_t sequence_number);
59  /** Destination PAN ID is omitted if Destination Addressing Mode is 0 */
60  PACK_STRUCT_FIELD(u16_t destination_pan_id);
61  /** Destination Address is omitted if Destination Addressing Mode is 0 */
62  PACK_STRUCT_FLD_8(u8_t destination_address[8]);
63  /** Source PAN ID is omitted if Source Addressing Mode is 0
64  or if IEEE_802154_FC_PANID_COMPR is set in frame control*/
65  PACK_STRUCT_FIELD(u16_t source_pan_id);
66  /** Source Address is omitted if Source Addressing Mode is 0 */
67  PACK_STRUCT_FLD_8(u8_t source_address[8]);
68  /* The rest is variable */
71 #ifdef PACK_STRUCT_USE_INCLUDES
72 # include "arch/epstruct.h"
73 #endif
74 
75 /* Addressing modes (2 bits) */
76 #define IEEE_802154_ADDR_MODE_NO_ADDR 0x00 /* PAN ID and address fields are not present */
77 #define IEEE_802154_ADDR_MODE_RESERVED 0x01 /* Reserved */
78 #define IEEE_802154_ADDR_MODE_SHORT 0x02 /* Address field contains a short address (16 bit) */
79 #define IEEE_802154_ADDR_MODE_EXT 0x03 /* Address field contains an extended address (64 bit) */
80 
81 /* IEEE 802.15.4 Frame Control definitions (2 bytes; see IEEE 802.15.4-2015 ch. 7.2.1) */
82 #define IEEE_802154_FC_FT_MASK 0x0007 /* bits 0..2: Frame Type */
83 #define IEEE_802154_FC_FT_BEACON 0x00
84 #define IEEE_802154_FC_FT_DATA 0x01
85 #define IEEE_802154_FC_FT_ACK 0x02
86 #define IEEE_802154_FC_FT_MAC_CMD 0x03
87 #define IEEE_802154_FC_FT_RESERVED 0x04
88 #define IEEE_802154_FC_FT_MULTIPURPOSE 0x05
89 #define IEEE_802154_FC_FT_FRAG 0x06
90 #define IEEE_802154_FC_FT_EXT 0x07
91 #define IEEE_802154_FC_SEC_EN 0x0008 /* bit 3: Security Enabled */
92 #define IEEE_802154_FC_FRAME_PEND 0x0010 /* bit 4: Frame Pending */
93 #define IEEE_802154_FC_ACK_REQ 0x0020 /* bit 5: AR (ACK required) */
94 #define IEEE_802154_FC_PANID_COMPR 0x0040 /* bit 6: PAN ID Compression (src and dst are equal, src PAN ID omitted) */
95 #define IEEE_802154_FC_RESERVED 0x0080
96 #define IEEE_802154_FC_SEQNO_SUPPR 0x0100 /* bit 8: Sequence Number Suppression */
97 #define IEEE_802154_FC_IE_PRESENT 0x0200 /* bit 9: IE Present */
98 #define IEEE_802154_FC_DST_ADDR_MODE_MASK 0x0c00 /* bits 10..11: Destination Addressing Mode */
99 #define IEEE_802154_FC_DST_ADDR_MODE_NO_ADDR (IEEE_802154_ADDR_MODE_NO_ADDR << 10)
100 #define IEEE_802154_FC_DST_ADDR_MODE_SHORT (IEEE_802154_ADDR_MODE_SHORT << 10)
101 #define IEEE_802154_FC_DST_ADDR_MODE_EXT (IEEE_802154_ADDR_MODE_EXT << 10)
102 #define IEEE_802154_FC_FRAME_VERSION_MASK 0x3000 /* bits 12..13: Frame Version */
103 #define IEEE_802154_FC_FRAME_VERSION_GET(x) (((x) & IEEE_802154_FC_FRAME_VERSION_MASK) >> 12)
104 #define IEEE_802154_FC_SRC_ADDR_MODE_MASK 0xc000 /* bits 14..15: Source Addressing Mode */
105 #define IEEE_802154_FC_SRC_ADDR_MODE_SHORT (IEEE_802154_ADDR_MODE_SHORT << 14)
106 #define IEEE_802154_FC_SRC_ADDR_MODE_EXT (IEEE_802154_ADDR_MODE_EXT << 14)
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* LWIP_HDR_NETIF_IEEE802154_H */
#define PACK_STRUCT_END
Definition: arch.h:316
uint8_t u8_t
Definition: arch.h:125
#define PACK_STRUCT_BEGIN
Definition: arch.h:307
uint16_t u16_t
Definition: arch.h:127
PACK_STRUCT_BEGIN struct ieee_802154_hdr PACK_STRUCT_STRUCT
Definition: ieee802154.h:54
PACK_STRUCT_FLD_8(u8_t source_address[8])
PACK_STRUCT_FLD_8(u8_t sequence_number)
PACK_STRUCT_FIELD(u16_t frame_control)
PACK_STRUCT_FIELD(u16_t destination_pan_id)
PACK_STRUCT_FIELD(u16_t source_pan_id)
PACK_STRUCT_FLD_8(u8_t destination_address[8])