Deleted Added
full compact
ieee80211_action.c (246503) ieee80211_action.c (254315)
1/*-
2 * Copyright (c) 2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

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.
24 */
25
26#include <sys/cdefs.h>
27#ifdef __FreeBSD__
1/*-
2 * Copyright (c) 2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

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.
24 */
25
26#include <sys/cdefs.h>
27#ifdef __FreeBSD__
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_action.c 246503 2013-02-07 21:21:40Z monthadar $");
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_action.c 254315 2013-08-14 04:24:25Z rpaulo $");
29#endif
30
31/*
32 * IEEE 802.11 send/recv action frame support.
33 */
34
35#include "opt_inet.h"
36#include "opt_wlan.h"

--- 38 unchanged lines hidden (view full) ---

75static ieee80211_send_action_func *vendor_send_action[8] = {
76 send_inval, send_inval, send_inval, send_inval,
77 send_inval, send_inval, send_inval, send_inval,
78};
79
80int
81ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f)
82{
29#endif
30
31/*
32 * IEEE 802.11 send/recv action frame support.
33 */
34
35#include "opt_inet.h"
36#include "opt_wlan.h"

--- 38 unchanged lines hidden (view full) ---

75static ieee80211_send_action_func *vendor_send_action[8] = {
76 send_inval, send_inval, send_inval, send_inval,
77 send_inval, send_inval, send_inval, send_inval,
78};
79
80int
81ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f)
82{
83#define N(a) (sizeof(a) / sizeof(a[0]))
84 switch (cat) {
85 case IEEE80211_ACTION_CAT_BA:
83 switch (cat) {
84 case IEEE80211_ACTION_CAT_BA:
86 if (act >= N(ba_send_action))
85 if (act >= nitems(ba_send_action))
87 break;
88 ba_send_action[act] = f;
89 return 0;
90 case IEEE80211_ACTION_CAT_HT:
86 break;
87 ba_send_action[act] = f;
88 return 0;
89 case IEEE80211_ACTION_CAT_HT:
91 if (act >= N(ht_send_action))
90 if (act >= nitems(ht_send_action))
92 break;
93 ht_send_action[act] = f;
94 return 0;
95 case IEEE80211_ACTION_CAT_SELF_PROT:
91 break;
92 ht_send_action[act] = f;
93 return 0;
94 case IEEE80211_ACTION_CAT_SELF_PROT:
96 if (act >= N(meshpl_send_action))
95 if (act >= nitems(meshpl_send_action))
97 break;
98 meshpl_send_action[act] = f;
99 return 0;
100 case IEEE80211_ACTION_CAT_MESH:
96 break;
97 meshpl_send_action[act] = f;
98 return 0;
99 case IEEE80211_ACTION_CAT_MESH:
101 if (act >= N(meshaction_send_action))
100 if (act >= nitems(meshaction_send_action))
102 break;
103 meshaction_send_action[act] = f;
104 return 0;
105 break;
106 case IEEE80211_ACTION_CAT_VENDOR:
101 break;
102 meshaction_send_action[act] = f;
103 return 0;
104 break;
105 case IEEE80211_ACTION_CAT_VENDOR:
107 if (act >= N(vendor_send_action))
106 if (act >= nitems(vendor_send_action))
108 break;
109 vendor_send_action[act] = f;
110 return 0;
111 }
112 return EINVAL;
107 break;
108 vendor_send_action[act] = f;
109 return 0;
110 }
111 return EINVAL;
113#undef N
114}
115
116void
117ieee80211_send_action_unregister(int cat, int act)
118{
119 ieee80211_send_action_register(cat, act, send_inval);
120}
121
122int
123ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa)
124{
112}
113
114void
115ieee80211_send_action_unregister(int cat, int act)
116{
117 ieee80211_send_action_register(cat, act, send_inval);
118}
119
120int
121ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa)
122{
125#define N(a) (sizeof(a) / sizeof(a[0]))
126 ieee80211_send_action_func *f = send_inval;
127
128 switch (cat) {
129 case IEEE80211_ACTION_CAT_BA:
123 ieee80211_send_action_func *f = send_inval;
124
125 switch (cat) {
126 case IEEE80211_ACTION_CAT_BA:
130 if (act < N(ba_send_action))
127 if (act < nitems(ba_send_action))
131 f = ba_send_action[act];
132 break;
133 case IEEE80211_ACTION_CAT_HT:
128 f = ba_send_action[act];
129 break;
130 case IEEE80211_ACTION_CAT_HT:
134 if (act < N(ht_send_action))
131 if (act < nitems(ht_send_action))
135 f = ht_send_action[act];
136 break;
137 case IEEE80211_ACTION_CAT_SELF_PROT:
132 f = ht_send_action[act];
133 break;
134 case IEEE80211_ACTION_CAT_SELF_PROT:
138 if (act < N(meshpl_send_action))
135 if (act < nitems(meshpl_send_action))
139 f = meshpl_send_action[act];
140 break;
141 case IEEE80211_ACTION_CAT_MESH:
136 f = meshpl_send_action[act];
137 break;
138 case IEEE80211_ACTION_CAT_MESH:
142 if (act < N(meshaction_send_action))
139 if (act < nitems(meshaction_send_action))
143 f = meshaction_send_action[act];
144 break;
145 case IEEE80211_ACTION_CAT_VENDOR:
140 f = meshaction_send_action[act];
141 break;
142 case IEEE80211_ACTION_CAT_VENDOR:
146 if (act < N(vendor_send_action))
143 if (act < nitems(vendor_send_action))
147 f = vendor_send_action[act];
148 break;
149 }
150 return f(ni, cat, act, sa);
144 f = vendor_send_action[act];
145 break;
146 }
147 return f(ni, cat, act, sa);
151#undef N
152}
153
154static int
155recv_inval(struct ieee80211_node *ni, const struct ieee80211_frame *wh,
156 const uint8_t *frm, const uint8_t *efrm)
157{
158 return EINVAL;
159}

--- 18 unchanged lines hidden (view full) ---

178static ieee80211_recv_action_func *vendor_recv_action[8] = {
179 recv_inval, recv_inval, recv_inval, recv_inval,
180 recv_inval, recv_inval, recv_inval, recv_inval,
181};
182
183int
184ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f)
185{
148}
149
150static int
151recv_inval(struct ieee80211_node *ni, const struct ieee80211_frame *wh,
152 const uint8_t *frm, const uint8_t *efrm)
153{
154 return EINVAL;
155}

--- 18 unchanged lines hidden (view full) ---

174static ieee80211_recv_action_func *vendor_recv_action[8] = {
175 recv_inval, recv_inval, recv_inval, recv_inval,
176 recv_inval, recv_inval, recv_inval, recv_inval,
177};
178
179int
180ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f)
181{
186#define N(a) (sizeof(a) / sizeof(a[0]))
187 switch (cat) {
188 case IEEE80211_ACTION_CAT_BA:
182 switch (cat) {
183 case IEEE80211_ACTION_CAT_BA:
189 if (act >= N(ba_recv_action))
184 if (act >= nitems(ba_recv_action))
190 break;
191 ba_recv_action[act] = f;
192 return 0;
193 case IEEE80211_ACTION_CAT_HT:
185 break;
186 ba_recv_action[act] = f;
187 return 0;
188 case IEEE80211_ACTION_CAT_HT:
194 if (act >= N(ht_recv_action))
189 if (act >= nitems(ht_recv_action))
195 break;
196 ht_recv_action[act] = f;
197 return 0;
198 case IEEE80211_ACTION_CAT_SELF_PROT:
190 break;
191 ht_recv_action[act] = f;
192 return 0;
193 case IEEE80211_ACTION_CAT_SELF_PROT:
199 if (act >= N(meshpl_recv_action))
194 if (act >= nitems(meshpl_recv_action))
200 break;
201 meshpl_recv_action[act] = f;
202 return 0;
203 case IEEE80211_ACTION_CAT_MESH:
195 break;
196 meshpl_recv_action[act] = f;
197 return 0;
198 case IEEE80211_ACTION_CAT_MESH:
204 if (act >= N(meshaction_recv_action))
199 if (act >= nitems(meshaction_recv_action))
205 break;
206 meshaction_recv_action[act] = f;
207 return 0;
208 case IEEE80211_ACTION_CAT_VENDOR:
200 break;
201 meshaction_recv_action[act] = f;
202 return 0;
203 case IEEE80211_ACTION_CAT_VENDOR:
209 if (act >= N(vendor_recv_action))
204 if (act >= nitems(vendor_recv_action))
210 break;
211 vendor_recv_action[act] = f;
212 return 0;
213 }
214 return EINVAL;
205 break;
206 vendor_recv_action[act] = f;
207 return 0;
208 }
209 return EINVAL;
215#undef N
216}
217
218void
219ieee80211_recv_action_unregister(int cat, int act)
220{
221 ieee80211_recv_action_register(cat, act, recv_inval);
222}
223
224int
225ieee80211_recv_action(struct ieee80211_node *ni,
226 const struct ieee80211_frame *wh,
227 const uint8_t *frm, const uint8_t *efrm)
228{
210}
211
212void
213ieee80211_recv_action_unregister(int cat, int act)
214{
215 ieee80211_recv_action_register(cat, act, recv_inval);
216}
217
218int
219ieee80211_recv_action(struct ieee80211_node *ni,
220 const struct ieee80211_frame *wh,
221 const uint8_t *frm, const uint8_t *efrm)
222{
229#define N(a) (sizeof(a) / sizeof(a[0]))
230 ieee80211_recv_action_func *f = recv_inval;
231 struct ieee80211vap *vap = ni->ni_vap;
232 const struct ieee80211_action *ia =
233 (const struct ieee80211_action *) frm;
234
235 switch (ia->ia_category) {
236 case IEEE80211_ACTION_CAT_BA:
223 ieee80211_recv_action_func *f = recv_inval;
224 struct ieee80211vap *vap = ni->ni_vap;
225 const struct ieee80211_action *ia =
226 (const struct ieee80211_action *) frm;
227
228 switch (ia->ia_category) {
229 case IEEE80211_ACTION_CAT_BA:
237 if (ia->ia_action < N(ba_recv_action))
230 if (ia->ia_action < nitems(ba_recv_action))
238 f = ba_recv_action[ia->ia_action];
239 break;
240 case IEEE80211_ACTION_CAT_HT:
231 f = ba_recv_action[ia->ia_action];
232 break;
233 case IEEE80211_ACTION_CAT_HT:
241 if (ia->ia_action < N(ht_recv_action))
234 if (ia->ia_action < nitems(ht_recv_action))
242 f = ht_recv_action[ia->ia_action];
243 break;
244 case IEEE80211_ACTION_CAT_SELF_PROT:
235 f = ht_recv_action[ia->ia_action];
236 break;
237 case IEEE80211_ACTION_CAT_SELF_PROT:
245 if (ia->ia_action < N(meshpl_recv_action))
238 if (ia->ia_action < nitems(meshpl_recv_action))
246 f = meshpl_recv_action[ia->ia_action];
247 break;
248 case IEEE80211_ACTION_CAT_MESH:
249 if (ni == vap->iv_bss ||
250 ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) {
251 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH,
252 ni->ni_macaddr, NULL,
253 "peer link not yet established (%d), cat %s act %u",
254 ni->ni_mlstate, "mesh action", ia->ia_action);
255 vap->iv_stats.is_mesh_nolink++;
256 break;
257 }
239 f = meshpl_recv_action[ia->ia_action];
240 break;
241 case IEEE80211_ACTION_CAT_MESH:
242 if (ni == vap->iv_bss ||
243 ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) {
244 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH,
245 ni->ni_macaddr, NULL,
246 "peer link not yet established (%d), cat %s act %u",
247 ni->ni_mlstate, "mesh action", ia->ia_action);
248 vap->iv_stats.is_mesh_nolink++;
249 break;
250 }
258 if (ia->ia_action < N(meshaction_recv_action))
251 if (ia->ia_action < nitems(meshaction_recv_action))
259 f = meshaction_recv_action[ia->ia_action];
260 break;
261 case IEEE80211_ACTION_CAT_VENDOR:
252 f = meshaction_recv_action[ia->ia_action];
253 break;
254 case IEEE80211_ACTION_CAT_VENDOR:
262 if (ia->ia_action < N(vendor_recv_action))
255 if (ia->ia_action < nitems(vendor_recv_action))
263 f = vendor_recv_action[ia->ia_action];
264 break;
265 }
266 return f(ni, wh, frm, efrm);
256 f = vendor_recv_action[ia->ia_action];
257 break;
258 }
259 return f(ni, wh, frm, efrm);
267#undef N
268}
260}