]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/net/ieee802154.h
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
[mirror_ubuntu-zesty-kernel.git] / include / net / ieee802154.h
CommitLineData
9ec76716
SL
1/*
2 * IEEE802.15.4-2003 specification
3 *
4 * Copyright (C) 2007, 2008 Siemens AG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Written by:
20 * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
21 * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
22 * Maxim Osipov <maxim.osipov@siemens.com>
23 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
719269af 24 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
9ec76716
SL
25 */
26
f0166e5e
DES
27#ifndef NET_IEEE802154_H
28#define NET_IEEE802154_H
9ec76716 29
719269af 30#define IEEE802154_MTU 127
31
9ec76716
SL
32#define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */
33#define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */
34#define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */
35#define IEEE802154_FC_TYPE_MAC_CMD 0x3 /* Frame is MAC command */
36
37#define IEEE802154_FC_TYPE_SHIFT 0
38#define IEEE802154_FC_TYPE_MASK ((1 << 3) - 1)
39#define IEEE802154_FC_TYPE(x) ((x & IEEE802154_FC_TYPE_MASK) >> IEEE802154_FC_TYPE_SHIFT)
40#define IEEE802154_FC_SET_TYPE(v, x) do { \
41 v = (((v) & ~IEEE802154_FC_TYPE_MASK) | \
42 (((x) << IEEE802154_FC_TYPE_SHIFT) & IEEE802154_FC_TYPE_MASK)); \
43 } while (0)
44
94b4f6c2
PB
45#define IEEE802154_FC_SECEN_SHIFT 3
46#define IEEE802154_FC_SECEN (1 << IEEE802154_FC_SECEN_SHIFT)
47#define IEEE802154_FC_FRPEND_SHIFT 4
48#define IEEE802154_FC_FRPEND (1 << IEEE802154_FC_FRPEND_SHIFT)
49#define IEEE802154_FC_ACK_REQ_SHIFT 5
50#define IEEE802154_FC_ACK_REQ (1 << IEEE802154_FC_ACK_REQ_SHIFT)
51#define IEEE802154_FC_INTRA_PAN_SHIFT 6
52#define IEEE802154_FC_INTRA_PAN (1 << IEEE802154_FC_INTRA_PAN_SHIFT)
9ec76716
SL
53
54#define IEEE802154_FC_SAMODE_SHIFT 14
55#define IEEE802154_FC_SAMODE_MASK (3 << IEEE802154_FC_SAMODE_SHIFT)
56#define IEEE802154_FC_DAMODE_SHIFT 10
57#define IEEE802154_FC_DAMODE_MASK (3 << IEEE802154_FC_DAMODE_SHIFT)
58
94b4f6c2
PB
59#define IEEE802154_FC_VERSION_SHIFT 12
60#define IEEE802154_FC_VERSION_MASK (3 << IEEE802154_FC_VERSION_SHIFT)
61#define IEEE802154_FC_VERSION(x) ((x & IEEE802154_FC_VERSION_MASK) >> IEEE802154_FC_VERSION_SHIFT)
62
9ec76716
SL
63#define IEEE802154_FC_SAMODE(x) \
64 (((x) & IEEE802154_FC_SAMODE_MASK) >> IEEE802154_FC_SAMODE_SHIFT)
65
66#define IEEE802154_FC_DAMODE(x) \
67 (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT)
68
94b4f6c2
PB
69#define IEEE802154_SCF_SECLEVEL_MASK 7
70#define IEEE802154_SCF_SECLEVEL_SHIFT 0
71#define IEEE802154_SCF_SECLEVEL(x) (x & IEEE802154_SCF_SECLEVEL_MASK)
72#define IEEE802154_SCF_KEY_ID_MODE_SHIFT 3
73#define IEEE802154_SCF_KEY_ID_MODE_MASK (3 << IEEE802154_SCF_KEY_ID_MODE_SHIFT)
74#define IEEE802154_SCF_KEY_ID_MODE(x) \
75 ((x & IEEE802154_SCF_KEY_ID_MODE_MASK) >> IEEE802154_SCF_KEY_ID_MODE_SHIFT)
76
77#define IEEE802154_SCF_KEY_IMPLICIT 0
78#define IEEE802154_SCF_KEY_INDEX 1
79#define IEEE802154_SCF_KEY_SHORT_INDEX 2
80#define IEEE802154_SCF_KEY_HW_INDEX 3
9ec76716 81
c3a6114f
PB
82#define IEEE802154_SCF_SECLEVEL_NONE 0
83#define IEEE802154_SCF_SECLEVEL_MIC32 1
84#define IEEE802154_SCF_SECLEVEL_MIC64 2
85#define IEEE802154_SCF_SECLEVEL_MIC128 3
86#define IEEE802154_SCF_SECLEVEL_ENC 4
87#define IEEE802154_SCF_SECLEVEL_ENC_MIC32 5
88#define IEEE802154_SCF_SECLEVEL_ENC_MIC64 6
89#define IEEE802154_SCF_SECLEVEL_ENC_MIC128 7
90
719269af 91/* MAC footer size */
92#define IEEE802154_MFR_SIZE 2 /* 2 octets */
93
9ec76716
SL
94/* MAC's Command Frames Identifiers */
95#define IEEE802154_CMD_ASSOCIATION_REQ 0x01
96#define IEEE802154_CMD_ASSOCIATION_RESP 0x02
97#define IEEE802154_CMD_DISASSOCIATION_NOTIFY 0x03
98#define IEEE802154_CMD_DATA_REQ 0x04
99#define IEEE802154_CMD_PANID_CONFLICT_NOTIFY 0x05
100#define IEEE802154_CMD_ORPHAN_NOTIFY 0x06
101#define IEEE802154_CMD_BEACON_REQ 0x07
102#define IEEE802154_CMD_COORD_REALIGN_NOTIFY 0x08
103#define IEEE802154_CMD_GTS_REQ 0x09
104
105/*
106 * The return values of MAC operations
107 */
108enum {
109 /*
110 * The requested operation was completed successfully.
111 * For a transmission request, this value indicates
112 * a successful transmission.
113 */
114 IEEE802154_SUCCESS = 0x0,
115
116 /* The beacon was lost following a synchronization request. */
117 IEEE802154_BEACON_LOSS = 0xe0,
118 /*
119 * A transmission could not take place due to activity on the
120 * channel, i.e., the CSMA-CA mechanism has failed.
121 */
122 IEEE802154_CHNL_ACCESS_FAIL = 0xe1,
123 /* The GTS request has been denied by the PAN coordinator. */
124 IEEE802154_DENINED = 0xe2,
125 /* The attempt to disable the transceiver has failed. */
126 IEEE802154_DISABLE_TRX_FAIL = 0xe3,
127 /*
128 * The received frame induces a failed security check according to
129 * the security suite.
130 */
131 IEEE802154_FAILED_SECURITY_CHECK = 0xe4,
132 /*
133 * The frame resulting from secure processing has a length that is
134 * greater than aMACMaxFrameSize.
135 */
136 IEEE802154_FRAME_TOO_LONG = 0xe5,
137 /*
138 * The requested GTS transmission failed because the specified GTS
139 * either did not have a transmit GTS direction or was not defined.
140 */
141 IEEE802154_INVALID_GTS = 0xe6,
142 /*
143 * A request to purge an MSDU from the transaction queue was made using
144 * an MSDU handle that was not found in the transaction table.
145 */
146 IEEE802154_INVALID_HANDLE = 0xe7,
147 /* A parameter in the primitive is out of the valid range.*/
148 IEEE802154_INVALID_PARAMETER = 0xe8,
149 /* No acknowledgment was received after aMaxFrameRetries. */
150 IEEE802154_NO_ACK = 0xe9,
151 /* A scan operation failed to find any network beacons.*/
152 IEEE802154_NO_BEACON = 0xea,
153 /* No response data were available following a request. */
154 IEEE802154_NO_DATA = 0xeb,
155 /* The operation failed because a short address was not allocated. */
156 IEEE802154_NO_SHORT_ADDRESS = 0xec,
157 /*
158 * A receiver enable request was unsuccessful because it could not be
159 * completed within the CAP.
160 */
161 IEEE802154_OUT_OF_CAP = 0xed,
162 /*
163 * A PAN identifier conflict has been detected and communicated to the
164 * PAN coordinator.
165 */
166 IEEE802154_PANID_CONFLICT = 0xee,
167 /* A coordinator realignment command has been received. */
168 IEEE802154_REALIGMENT = 0xef,
169 /* The transaction has expired and its information discarded. */
170 IEEE802154_TRANSACTION_EXPIRED = 0xf0,
171 /* There is no capacity to store the transaction. */
172 IEEE802154_TRANSACTION_OVERFLOW = 0xf1,
173 /*
174 * The transceiver was in the transmitter enabled state when the
175 * receiver was requested to be enabled.
176 */
177 IEEE802154_TX_ACTIVE = 0xf2,
178 /* The appropriate key is not available in the ACL. */
179 IEEE802154_UNAVAILABLE_KEY = 0xf3,
180 /*
181 * A SET/GET request was issued with the identifier of a PIB attribute
182 * that is not supported.
183 */
184 IEEE802154_UNSUPPORTED_ATTR = 0xf4,
185 /*
186 * A request to perform a scan operation failed because the MLME was
187 * in the process of performing a previously initiated scan operation.
188 */
189 IEEE802154_SCAN_IN_PROGRESS = 0xfc,
190};
191
192
193#endif
194
195