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.
26 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
32 * IEEE 802.11 send/recv action frame support.
38 #include <sys/param.h>
39 #include <sys/kernel.h>
40 #include <sys/systm.h>
42 #include <sys/socket.h>
45 #include <net/if_media.h>
46 #include <net/ethernet.h>
48 #include <net80211/ieee80211_var.h>
49 #include <net80211/ieee80211_action.h>
50 #include <net80211/ieee80211_mesh.h>
53 send_inval(struct ieee80211_node *ni, int cat, int act, void *sa)
58 static ieee80211_send_action_func *ba_send_action[8] = {
59 send_inval, send_inval, send_inval, send_inval,
60 send_inval, send_inval, send_inval, send_inval,
62 static ieee80211_send_action_func *ht_send_action[8] = {
63 send_inval, send_inval, send_inval, send_inval,
64 send_inval, send_inval, send_inval, send_inval,
66 static ieee80211_send_action_func *meshpl_send_action[8] = {
67 send_inval, send_inval, send_inval, send_inval,
68 send_inval, send_inval, send_inval, send_inval,
70 static ieee80211_send_action_func *meshlm_send_action[4] = {
71 send_inval, send_inval, send_inval, send_inval,
73 static ieee80211_send_action_func *hwmp_send_action[8] = {
74 send_inval, send_inval, send_inval, send_inval,
75 send_inval, send_inval, send_inval, send_inval,
77 static ieee80211_send_action_func *vendor_send_action[8] = {
78 send_inval, send_inval, send_inval, send_inval,
79 send_inval, send_inval, send_inval, send_inval,
83 ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f)
85 #define N(a) (sizeof(a) / sizeof(a[0]))
87 case IEEE80211_ACTION_CAT_BA:
88 if (act >= N(ba_send_action))
90 ba_send_action[act] = f;
92 case IEEE80211_ACTION_CAT_HT:
93 if (act >= N(ht_send_action))
95 ht_send_action[act] = f;
97 case IEEE80211_ACTION_CAT_MESHPEERING:
98 if (act >= N(meshpl_send_action))
100 meshpl_send_action[act] = f;
102 case IEEE80211_ACTION_CAT_MESHLMETRIC:
103 if (act >= N(meshlm_send_action))
105 meshlm_send_action[act] = f;
107 case IEEE80211_ACTION_CAT_MESHPATH:
108 if (act >= N(hwmp_send_action))
110 hwmp_send_action[act] = f;
112 case IEEE80211_ACTION_CAT_VENDOR:
113 if (act >= N(vendor_send_action))
115 vendor_send_action[act] = f;
123 ieee80211_send_action_unregister(int cat, int act)
125 ieee80211_send_action_register(cat, act, send_inval);
129 ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa)
131 #define N(a) (sizeof(a) / sizeof(a[0]))
132 ieee80211_send_action_func *f = send_inval;
135 case IEEE80211_ACTION_CAT_BA:
136 if (act < N(ba_send_action))
137 f = ba_send_action[act];
139 case IEEE80211_ACTION_CAT_HT:
140 if (act < N(ht_send_action))
141 f = ht_send_action[act];
143 case IEEE80211_ACTION_CAT_MESHPEERING:
144 if (act < N(meshpl_send_action))
145 f = meshpl_send_action[act];
147 case IEEE80211_ACTION_CAT_MESHLMETRIC:
148 if (act < N(meshlm_send_action))
149 f = meshlm_send_action[act];
151 case IEEE80211_ACTION_CAT_MESHPATH:
152 if (act < N(hwmp_send_action))
153 f = hwmp_send_action[act];
155 case IEEE80211_ACTION_CAT_VENDOR:
156 if (act < N(vendor_send_action))
157 f = vendor_send_action[act];
160 return f(ni, cat, act, sa);
165 recv_inval(struct ieee80211_node *ni, const struct ieee80211_frame *wh,
166 const uint8_t *frm, const uint8_t *efrm)
171 static ieee80211_recv_action_func *ba_recv_action[8] = {
172 recv_inval, recv_inval, recv_inval, recv_inval,
173 recv_inval, recv_inval, recv_inval, recv_inval,
175 static ieee80211_recv_action_func *ht_recv_action[8] = {
176 recv_inval, recv_inval, recv_inval, recv_inval,
177 recv_inval, recv_inval, recv_inval, recv_inval,
179 static ieee80211_recv_action_func *meshpl_recv_action[8] = {
180 recv_inval, recv_inval, recv_inval, recv_inval,
181 recv_inval, recv_inval, recv_inval, recv_inval,
183 static ieee80211_recv_action_func *meshlm_recv_action[4] = {
184 recv_inval, recv_inval, recv_inval, recv_inval,
186 static ieee80211_recv_action_func *hwmp_recv_action[8] = {
187 recv_inval, recv_inval, recv_inval, recv_inval,
188 recv_inval, recv_inval, recv_inval, recv_inval,
190 static ieee80211_recv_action_func *vendor_recv_action[8] = {
191 recv_inval, recv_inval, recv_inval, recv_inval,
192 recv_inval, recv_inval, recv_inval, recv_inval,
196 ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f)
198 #define N(a) (sizeof(a) / sizeof(a[0]))
200 case IEEE80211_ACTION_CAT_BA:
201 if (act >= N(ba_recv_action))
203 ba_recv_action[act] = f;
205 case IEEE80211_ACTION_CAT_HT:
206 if (act >= N(ht_recv_action))
208 ht_recv_action[act] = f;
210 case IEEE80211_ACTION_CAT_MESHPEERING:
211 if (act >= N(meshpl_recv_action))
213 meshpl_recv_action[act] = f;
215 case IEEE80211_ACTION_CAT_MESHLMETRIC:
216 if (act >= N(meshlm_recv_action))
218 meshlm_recv_action[act] = f;
220 case IEEE80211_ACTION_CAT_MESHPATH:
221 if (act >= N(hwmp_recv_action))
223 hwmp_recv_action[act] = f;
225 case IEEE80211_ACTION_CAT_VENDOR:
226 if (act >= N(vendor_recv_action))
228 vendor_recv_action[act] = f;
236 ieee80211_recv_action_unregister(int cat, int act)
238 ieee80211_recv_action_register(cat, act, recv_inval);
242 ieee80211_recv_action(struct ieee80211_node *ni,
243 const struct ieee80211_frame *wh,
244 const uint8_t *frm, const uint8_t *efrm)
246 #define N(a) (sizeof(a) / sizeof(a[0]))
247 ieee80211_recv_action_func *f = recv_inval;
248 const struct ieee80211_action *ia =
249 (const struct ieee80211_action *) frm;
251 switch (ia->ia_category) {
252 case IEEE80211_ACTION_CAT_BA:
253 if (ia->ia_action < N(ba_recv_action))
254 f = ba_recv_action[ia->ia_action];
256 case IEEE80211_ACTION_CAT_HT:
257 if (ia->ia_action < N(ht_recv_action))
258 f = ht_recv_action[ia->ia_action];
260 case IEEE80211_ACTION_CAT_MESHPEERING:
261 if (ia->ia_action < N(meshpl_recv_action))
262 f = meshpl_recv_action[ia->ia_action];
264 case IEEE80211_ACTION_CAT_MESHLMETRIC:
265 if (ia->ia_action < N(meshlm_recv_action))
266 f = meshlm_recv_action[ia->ia_action];
268 case IEEE80211_ACTION_CAT_MESHPATH:
269 if (ia->ia_action < N(hwmp_recv_action))
270 f = hwmp_recv_action[ia->ia_action];
272 case IEEE80211_ACTION_CAT_VENDOR:
273 if (ia->ia_action < N(vendor_recv_action))
274 f = vendor_recv_action[ia->ia_action];
277 return f(ni, wh, frm, efrm);