2 * Copyright (c) 2009 Sam Leffler, Errno Consulting
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * $FreeBSD: head/sys/net80211/ieee80211_action.c 199186 2009-11-11 14:58:48Z antoine $
30 * IEEE 802.11 send/recv action frame support.
36 #include <sys/param.h>
37 #include <sys/kernel.h>
38 #include <sys/systm.h>
40 #include <sys/socket.h>
43 #include <net/if_media.h>
44 #include <net/ethernet.h>
45 #include <net/route.h>
47 #include <netproto/802_11/ieee80211_var.h>
48 #include <netproto/802_11/ieee80211_action.h>
49 #include <netproto/802_11/ieee80211_mesh.h>
52 send_inval(struct ieee80211_node *ni, int cat, int act, void *sa)
57 static ieee80211_send_action_func *ba_send_action[8] = {
58 send_inval, send_inval, send_inval, send_inval,
59 send_inval, send_inval, send_inval, send_inval,
61 static ieee80211_send_action_func *ht_send_action[8] = {
62 send_inval, send_inval, send_inval, send_inval,
63 send_inval, send_inval, send_inval, send_inval,
65 static ieee80211_send_action_func *meshpl_send_action[8] = {
66 send_inval, send_inval, send_inval, send_inval,
67 send_inval, send_inval, send_inval, send_inval,
69 static ieee80211_send_action_func *meshlm_send_action[4] = {
70 send_inval, send_inval, send_inval, send_inval,
72 static ieee80211_send_action_func *hwmp_send_action[8] = {
73 send_inval, send_inval, send_inval, send_inval,
74 send_inval, send_inval, send_inval, send_inval,
76 static ieee80211_send_action_func *vendor_send_action[8] = {
77 send_inval, send_inval, send_inval, send_inval,
78 send_inval, send_inval, send_inval, send_inval,
82 ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f)
84 #define N(a) (sizeof(a) / sizeof(a[0]))
86 case IEEE80211_ACTION_CAT_BA:
87 if (act >= N(ba_send_action))
89 ba_send_action[act] = f;
91 case IEEE80211_ACTION_CAT_HT:
92 if (act >= N(ht_send_action))
94 ht_send_action[act] = f;
96 case IEEE80211_ACTION_CAT_MESHPEERING:
97 if (act >= N(meshpl_send_action))
99 meshpl_send_action[act] = f;
101 case IEEE80211_ACTION_CAT_MESHLMETRIC:
102 if (act >= N(meshlm_send_action))
104 meshlm_send_action[act] = f;
106 case IEEE80211_ACTION_CAT_MESHPATH:
107 if (act >= N(hwmp_send_action))
109 hwmp_send_action[act] = f;
111 case IEEE80211_ACTION_CAT_VENDOR:
112 if (act >= N(vendor_send_action))
114 vendor_send_action[act] = f;
122 ieee80211_send_action_unregister(int cat, int act)
124 ieee80211_send_action_register(cat, act, send_inval);
128 ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa)
130 #define N(a) (sizeof(a) / sizeof(a[0]))
131 ieee80211_send_action_func *f = send_inval;
134 case IEEE80211_ACTION_CAT_BA:
135 if (act < N(ba_send_action))
136 f = ba_send_action[act];
138 case IEEE80211_ACTION_CAT_HT:
139 if (act < N(ht_send_action))
140 f = ht_send_action[act];
142 case IEEE80211_ACTION_CAT_MESHPEERING:
143 if (act < N(meshpl_send_action))
144 f = meshpl_send_action[act];
146 case IEEE80211_ACTION_CAT_MESHLMETRIC:
147 if (act < N(meshlm_send_action))
148 f = meshlm_send_action[act];
150 case IEEE80211_ACTION_CAT_MESHPATH:
151 if (act < N(hwmp_send_action))
152 f = hwmp_send_action[act];
154 case IEEE80211_ACTION_CAT_VENDOR:
155 if (act < N(vendor_send_action))
156 f = vendor_send_action[act];
159 return f(ni, cat, act, sa);
164 recv_inval(struct ieee80211_node *ni, const struct ieee80211_frame *wh,
165 const uint8_t *frm, const uint8_t *efrm)
170 static ieee80211_recv_action_func *ba_recv_action[8] = {
171 recv_inval, recv_inval, recv_inval, recv_inval,
172 recv_inval, recv_inval, recv_inval, recv_inval,
174 static ieee80211_recv_action_func *ht_recv_action[8] = {
175 recv_inval, recv_inval, recv_inval, recv_inval,
176 recv_inval, recv_inval, recv_inval, recv_inval,
178 static ieee80211_recv_action_func *meshpl_recv_action[8] = {
179 recv_inval, recv_inval, recv_inval, recv_inval,
180 recv_inval, recv_inval, recv_inval, recv_inval,
182 static ieee80211_recv_action_func *meshlm_recv_action[4] = {
183 recv_inval, recv_inval, recv_inval, recv_inval,
185 static ieee80211_recv_action_func *hwmp_recv_action[8] = {
186 recv_inval, recv_inval, recv_inval, recv_inval,
187 recv_inval, recv_inval, recv_inval, recv_inval,
189 static ieee80211_recv_action_func *vendor_recv_action[8] = {
190 recv_inval, recv_inval, recv_inval, recv_inval,
191 recv_inval, recv_inval, recv_inval, recv_inval,
195 ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f)
197 #define N(a) (sizeof(a) / sizeof(a[0]))
199 case IEEE80211_ACTION_CAT_BA:
200 if (act >= N(ba_recv_action))
202 ba_recv_action[act] = f;
204 case IEEE80211_ACTION_CAT_HT:
205 if (act >= N(ht_recv_action))
207 ht_recv_action[act] = f;
209 case IEEE80211_ACTION_CAT_MESHPEERING:
210 if (act >= N(meshpl_recv_action))
212 meshpl_recv_action[act] = f;
214 case IEEE80211_ACTION_CAT_MESHLMETRIC:
215 if (act >= N(meshlm_recv_action))
217 meshlm_recv_action[act] = f;
219 case IEEE80211_ACTION_CAT_MESHPATH:
220 if (act >= N(hwmp_recv_action))
222 hwmp_recv_action[act] = f;
224 case IEEE80211_ACTION_CAT_VENDOR:
225 if (act >= N(vendor_recv_action))
227 vendor_recv_action[act] = f;
235 ieee80211_recv_action_unregister(int cat, int act)
237 ieee80211_recv_action_register(cat, act, recv_inval);
241 ieee80211_recv_action(struct ieee80211_node *ni,
242 const struct ieee80211_frame *wh,
243 const uint8_t *frm, const uint8_t *efrm)
245 #define N(a) (sizeof(a) / sizeof(a[0]))
246 ieee80211_recv_action_func *f = recv_inval;
247 const struct ieee80211_action *ia =
248 (const struct ieee80211_action *) frm;
250 switch (ia->ia_category) {
251 case IEEE80211_ACTION_CAT_BA:
252 if (ia->ia_action < N(ba_recv_action))
253 f = ba_recv_action[ia->ia_action];
255 case IEEE80211_ACTION_CAT_HT:
256 if (ia->ia_action < N(ht_recv_action))
257 f = ht_recv_action[ia->ia_action];
259 case IEEE80211_ACTION_CAT_MESHPEERING:
260 if (ia->ia_action < N(meshpl_recv_action))
261 f = meshpl_recv_action[ia->ia_action];
263 case IEEE80211_ACTION_CAT_MESHLMETRIC:
264 if (ia->ia_action < N(meshlm_recv_action))
265 f = meshlm_recv_action[ia->ia_action];
267 case IEEE80211_ACTION_CAT_MESHPATH:
268 if (ia->ia_action < N(hwmp_recv_action))
269 f = hwmp_recv_action[ia->ia_action];
271 case IEEE80211_ACTION_CAT_VENDOR:
272 if (ia->ia_action < N(vendor_recv_action))
273 f = vendor_recv_action[ia->ia_action];
276 return f(ni, wh, frm, efrm);