aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ieee802154
diff options
context:
space:
mode:
authorSergey Lapin <slapin@ossfans.org>2009-06-08 08:18:48 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-09 08:25:32 -0400
commit9ec7671603573ede31207eb5b0b3e1aa211b2854 (patch)
tree9cfb301ce6d1e1296a3a253feaa1a40d4c2b3bd9 /include/net/ieee802154
parentfcb94e422479da52ed90bab230c59617a0462416 (diff)
net: add IEEE 802.15.4 socket family implementation
Add support for communication over IEEE 802.15.4 networks. This implementation is neither certified nor complete, but aims to that goal. This commit contains only the socket interface for communication over IEEE 802.15.4 networks. One can either send RAW datagrams or use SOCK_DGRAM to encapsulate data inside normal IEEE 802.15.4 packets. Configuration interface, drivers and software MAC 802.15.4 implementation will follow. Initial implementation was done by Maxim Gorbachyov, Maxim Osipov and Pavel Smolensky as a research project at Siemens AG. Later the stack was heavily reworked to better suit the linux networking model, and is now maitained as an open project partially sponsored by Siemens. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Sergey Lapin <slapin@ossfans.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ieee802154')
-rw-r--r--include/net/ieee802154/af_ieee802154.h60
-rw-r--r--include/net/ieee802154/mac_def.h160
-rw-r--r--include/net/ieee802154/netdevice.h115
3 files changed, 335 insertions, 0 deletions
diff --git a/include/net/ieee802154/af_ieee802154.h b/include/net/ieee802154/af_ieee802154.h
new file mode 100644
index 000000000000..0d78605fb1a6
--- /dev/null
+++ b/include/net/ieee802154/af_ieee802154.h
@@ -0,0 +1,60 @@
1/*
2 * IEEE 802.15.4 inteface for userspace
3 *
4 * Copyright 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 * Sergey Lapin <slapin@ossfans.org>
21 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
22 */
23
24#ifndef _AF_IEEE802154_H
25#define _AF_IEEE802154_H
26
27#include <linux/socket.h> /* for sa_family_t */
28
29enum {
30 IEEE802154_ADDR_NONE = 0x0,
31 /* RESERVED = 0x01, */
32 IEEE802154_ADDR_SHORT = 0x2, /* 16-bit address + PANid */
33 IEEE802154_ADDR_LONG = 0x3, /* 64-bit address + PANid */
34};
35
36/* address length, octets */
37#define IEEE802154_ADDR_LEN 8
38
39struct ieee802154_addr {
40 int addr_type;
41 u16 pan_id;
42 union {
43 u8 hwaddr[IEEE802154_ADDR_LEN];
44 u16 short_addr;
45 };
46};
47
48#define IEEE802154_PANID_BROADCAST 0xffff
49#define IEEE802154_ADDR_BROADCAST 0xffff
50#define IEEE802154_ADDR_UNDEF 0xfffe
51
52struct sockaddr_ieee802154 {
53 sa_family_t family; /* AF_IEEE802154 */
54 struct ieee802154_addr addr;
55};
56
57/* master device */
58#define IEEE802154_SIOC_ADD_SLAVE (SIOCDEVPRIVATE + 0)
59
60#endif
diff --git a/include/net/ieee802154/mac_def.h b/include/net/ieee802154/mac_def.h
new file mode 100644
index 000000000000..8cb684635650
--- /dev/null
+++ b/include/net/ieee802154/mac_def.h
@@ -0,0 +1,160 @@
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>
24 */
25
26#ifndef IEEE802154_MAC_DEF_H
27#define IEEE802154_MAC_DEF_H
28
29#define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */
30#define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */
31#define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */
32#define IEEE802154_FC_TYPE_MAC_CMD 0x3 /* Frame is MAC command */
33
34#define IEEE802154_FC_TYPE_SHIFT 0
35#define IEEE802154_FC_TYPE_MASK ((1 << 3) - 1)
36#define IEEE802154_FC_TYPE(x) ((x & IEEE802154_FC_TYPE_MASK) >> IEEE802154_FC_TYPE_SHIFT)
37#define IEEE802154_FC_SET_TYPE(v, x) do { \
38 v = (((v) & ~IEEE802154_FC_TYPE_MASK) | \
39 (((x) << IEEE802154_FC_TYPE_SHIFT) & IEEE802154_FC_TYPE_MASK)); \
40 } while (0)
41
42#define IEEE802154_FC_SECEN (1 << 3)
43#define IEEE802154_FC_FRPEND (1 << 4)
44#define IEEE802154_FC_ACK_REQ (1 << 5)
45#define IEEE802154_FC_INTRA_PAN (1 << 6)
46
47#define IEEE802154_FC_SAMODE_SHIFT 14
48#define IEEE802154_FC_SAMODE_MASK (3 << IEEE802154_FC_SAMODE_SHIFT)
49#define IEEE802154_FC_DAMODE_SHIFT 10
50#define IEEE802154_FC_DAMODE_MASK (3 << IEEE802154_FC_DAMODE_SHIFT)
51
52#define IEEE802154_FC_SAMODE(x) \
53 (((x) & IEEE802154_FC_SAMODE_MASK) >> IEEE802154_FC_SAMODE_SHIFT)
54
55#define IEEE802154_FC_DAMODE(x) \
56 (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT)
57
58
59/* MAC's Command Frames Identifiers */
60#define IEEE802154_CMD_ASSOCIATION_REQ 0x01
61#define IEEE802154_CMD_ASSOCIATION_RESP 0x02
62#define IEEE802154_CMD_DISASSOCIATION_NOTIFY 0x03
63#define IEEE802154_CMD_DATA_REQ 0x04
64#define IEEE802154_CMD_PANID_CONFLICT_NOTIFY 0x05
65#define IEEE802154_CMD_ORPHAN_NOTIFY 0x06
66#define IEEE802154_CMD_BEACON_REQ 0x07
67#define IEEE802154_CMD_COORD_REALIGN_NOTIFY 0x08
68#define IEEE802154_CMD_GTS_REQ 0x09
69
70/*
71 * The return values of MAC operations
72 */
73enum {
74 /*
75 * The requested operation was completed successfully.
76 * For a transmission request, this value indicates
77 * a successful transmission.
78 */
79 IEEE802154_SUCCESS = 0x0,
80
81 /* The beacon was lost following a synchronization request. */
82 IEEE802154_BEACON_LOSS = 0xe0,
83 /*
84 * A transmission could not take place due to activity on the
85 * channel, i.e., the CSMA-CA mechanism has failed.
86 */
87 IEEE802154_CHNL_ACCESS_FAIL = 0xe1,
88 /* The GTS request has been denied by the PAN coordinator. */
89 IEEE802154_DENINED = 0xe2,
90 /* The attempt to disable the transceiver has failed. */
91 IEEE802154_DISABLE_TRX_FAIL = 0xe3,
92 /*
93 * The received frame induces a failed security check according to
94 * the security suite.
95 */
96 IEEE802154_FAILED_SECURITY_CHECK = 0xe4,
97 /*
98 * The frame resulting from secure processing has a length that is
99 * greater than aMACMaxFrameSize.
100 */
101 IEEE802154_FRAME_TOO_LONG = 0xe5,
102 /*
103 * The requested GTS transmission failed because the specified GTS
104 * either did not have a transmit GTS direction or was not defined.
105 */
106 IEEE802154_INVALID_GTS = 0xe6,
107 /*
108 * A request to purge an MSDU from the transaction queue was made using
109 * an MSDU handle that was not found in the transaction table.
110 */
111 IEEE802154_INVALID_HANDLE = 0xe7,
112 /* A parameter in the primitive is out of the valid range.*/
113 IEEE802154_INVALID_PARAMETER = 0xe8,
114 /* No acknowledgment was received after aMaxFrameRetries. */
115 IEEE802154_NO_ACK = 0xe9,
116 /* A scan operation failed to find any network beacons.*/
117 IEEE802154_NO_BEACON = 0xea,
118 /* No response data were available following a request. */
119 IEEE802154_NO_DATA = 0xeb,
120 /* The operation failed because a short address was not allocated. */
121 IEEE802154_NO_SHORT_ADDRESS = 0xec,
122 /*
123 * A receiver enable request was unsuccessful because it could not be
124 * completed within the CAP.
125 */
126 IEEE802154_OUT_OF_CAP = 0xed,
127 /*
128 * A PAN identifier conflict has been detected and communicated to the
129 * PAN coordinator.
130 */
131 IEEE802154_PANID_CONFLICT = 0xee,
132 /* A coordinator realignment command has been received. */
133 IEEE802154_REALIGMENT = 0xef,
134 /* The transaction has expired and its information discarded. */
135 IEEE802154_TRANSACTION_EXPIRED = 0xf0,
136 /* There is no capacity to store the transaction. */
137 IEEE802154_TRANSACTION_OVERFLOW = 0xf1,
138 /*
139 * The transceiver was in the transmitter enabled state when the
140 * receiver was requested to be enabled.
141 */
142 IEEE802154_TX_ACTIVE = 0xf2,
143 /* The appropriate key is not available in the ACL. */
144 IEEE802154_UNAVAILABLE_KEY = 0xf3,
145 /*
146 * A SET/GET request was issued with the identifier of a PIB attribute
147 * that is not supported.
148 */
149 IEEE802154_UNSUPPORTED_ATTR = 0xf4,
150 /*
151 * A request to perform a scan operation failed because the MLME was
152 * in the process of performing a previously initiated scan operation.
153 */
154 IEEE802154_SCAN_IN_PROGRESS = 0xfc,
155};
156
157
158#endif
159
160
diff --git a/include/net/ieee802154/netdevice.h b/include/net/ieee802154/netdevice.h
new file mode 100644
index 000000000000..e2506af3e7c8
--- /dev/null
+++ b/include/net/ieee802154/netdevice.h
@@ -0,0 +1,115 @@
1/*
2 * An interface between IEEE802.15.4 device and rest of the kernel.
3 *
4 * Copyright (C) 2007, 2008, 2009 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>
24 */
25
26#ifndef IEEE802154_NETDEVICE_H
27#define IEEE802154_NETDEVICE_H
28
29/*
30 * A control block of skb passed between the ARPHRD_IEEE802154 device
31 * and other stack parts.
32 */
33struct ieee802154_mac_cb {
34 u8 lqi;
35 struct ieee802154_addr sa;
36 struct ieee802154_addr da;
37 u8 flags;
38 u8 seq;
39};
40
41static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb)
42{
43 return (struct ieee802154_mac_cb *)skb->cb;
44}
45
46#define MAC_CB_FLAG_TYPEMASK ((1 << 3) - 1)
47
48#define MAC_CB_FLAG_ACKREQ (1 << 3)
49#define MAC_CB_FLAG_SECEN (1 << 4)
50#define MAC_CB_FLAG_INTRAPAN (1 << 5)
51
52static inline int mac_cb_is_ackreq(struct sk_buff *skb)
53{
54 return mac_cb(skb)->flags & MAC_CB_FLAG_ACKREQ;
55}
56
57static inline int mac_cb_is_secen(struct sk_buff *skb)
58{
59 return mac_cb(skb)->flags & MAC_CB_FLAG_SECEN;
60}
61
62static inline int mac_cb_is_intrapan(struct sk_buff *skb)
63{
64 return mac_cb(skb)->flags & MAC_CB_FLAG_INTRAPAN;
65}
66
67static inline int mac_cb_type(struct sk_buff *skb)
68{
69 return mac_cb(skb)->flags & MAC_CB_FLAG_TYPEMASK;
70}
71
72#define IEEE802154_MAC_SCAN_ED 0
73#define IEEE802154_MAC_SCAN_ACTIVE 1
74#define IEEE802154_MAC_SCAN_PASSIVE 2
75#define IEEE802154_MAC_SCAN_ORPHAN 3
76
77/*
78 * This should be located at net_device->ml_priv
79 */
80struct ieee802154_mlme_ops {
81 int (*assoc_req)(struct net_device *dev,
82 struct ieee802154_addr *addr,
83 u8 channel, u8 cap);
84 int (*assoc_resp)(struct net_device *dev,
85 struct ieee802154_addr *addr,
86 u16 short_addr, u8 status);
87 int (*disassoc_req)(struct net_device *dev,
88 struct ieee802154_addr *addr,
89 u8 reason);
90 int (*start_req)(struct net_device *dev,
91 struct ieee802154_addr *addr,
92 u8 channel, u8 bcn_ord, u8 sf_ord,
93 u8 pan_coord, u8 blx, u8 coord_realign);
94 int (*scan_req)(struct net_device *dev,
95 u8 type, u32 channels, u8 duration);
96
97 /*
98 * FIXME: these should become the part of PIB/MIB interface.
99 * However we still don't have IB interface of any kind
100 */
101 u16 (*get_pan_id)(struct net_device *dev);
102 u16 (*get_short_addr)(struct net_device *dev);
103 u8 (*get_dsn)(struct net_device *dev);
104 u8 (*get_bsn)(struct net_device *dev);
105};
106
107static inline struct ieee802154_mlme_ops *ieee802154_mlme_ops(
108 struct net_device *dev)
109{
110 return dev->ml_priv;
111}
112
113#endif
114
115