Deleted Added
full compact
ieee80211_proto.c (170360) ieee80211_proto.c (170530)
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_proto.c 170360 2007-06-06 04:56:04Z sam $");
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_proto.c 170530 2007-06-11 03:36:55Z sam $");
29
30/*
31 * IEEE 802.11 protocol support.
32 */
33
34#include "opt_inet.h"
35
36#include <sys/param.h>
37#include <sys/kernel.h>
29
30/*
31 * IEEE 802.11 protocol support.
32 */
33
34#include "opt_inet.h"
35
36#include <sys/param.h>
37#include <sys/kernel.h>
38#include <sys/systm.h>
39
38#include
39
40#include <sys/socket.h>
41
42#include <net/if.h>
43#include <net/if_media.h>
44#include <net/ethernet.h> /* XXX for ether_sprintf */
45
46#include <net80211/ieee80211_var.h>
47

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

98 /* XXX room for crypto */
99 ifp->if_hdrlen = sizeof(struct ieee80211_qosframe_addr4);
100
101 ic->ic_rtsthreshold = IEEE80211_RTS_DEFAULT;
102 ic->ic_fragthreshold = IEEE80211_FRAG_DEFAULT;
103 ic->ic_fixed_rate = IEEE80211_FIXED_RATE_NONE;
104 ic->ic_bmiss_max = IEEE80211_BMISS_MAX;
105 callout_init(&ic->ic_swbmiss, CALLOUT_MPSAFE);
40#include <sys/socket.h>
41
42#include <net/if.h>
43#include <net/if_media.h>
44#include <net/ethernet.h> /* XXX for ether_sprintf */
45
46#include <net80211/ieee80211_var.h>
47

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

98 /* XXX room for crypto */
99 ifp->if_hdrlen = sizeof(struct ieee80211_qosframe_addr4);
100
101 ic->ic_rtsthreshold = IEEE80211_RTS_DEFAULT;
102 ic->ic_fragthreshold = IEEE80211_FRAG_DEFAULT;
103 ic->ic_fixed_rate = IEEE80211_FIXED_RATE_NONE;
104 ic->ic_bmiss_max = IEEE80211_BMISS_MAX;
105 callout_init(&ic->ic_swbmiss, CALLOUT_MPSAFE);
106 callout_init(&ic->ic_mgtsend, CALLOUT_MPSAFE);
106 ic->ic_mcast_rate = IEEE80211_MCAST_RATE_DEFAULT;
107 ic->ic_protmode = IEEE80211_PROT_CTSONLY;
108 ic->ic_roaming = IEEE80211_ROAMING_AUTO;
109
110 ic->ic_wme.wme_hipri_switch_hysteresis =
111 AGGRESSIVE_MODE_SWITCH_HYSTERESIS;
112
113 mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF);

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

232ieee80211_aclator_get(const char *name)
233{
234 if (acl == NULL)
235 ieee80211_load_module("wlan_acl");
236 return acl != NULL && strcmp(acl->iac_name, name) == 0 ? acl : NULL;
237}
238
239void
107 ic->ic_mcast_rate = IEEE80211_MCAST_RATE_DEFAULT;
108 ic->ic_protmode = IEEE80211_PROT_CTSONLY;
109 ic->ic_roaming = IEEE80211_ROAMING_AUTO;
110
111 ic->ic_wme.wme_hipri_switch_hysteresis =
112 AGGRESSIVE_MODE_SWITCH_HYSTERESIS;
113
114 mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF);

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

233ieee80211_aclator_get(const char *name)
234{
235 if (acl == NULL)
236 ieee80211_load_module("wlan_acl");
237 return acl != NULL && strcmp(acl->iac_name, name) == 0 ? acl : NULL;
238}
239
240void
240ieee80211_print_essid(const u_int8_t *essid, int len)
241ieee80211_print_essid(const uint8_t *essid, int len)
241{
242{
242 const u_int8_t *p;
243 const uint8_t *p;
243 int i;
244
245 if (len > IEEE80211_NWID_LEN)
246 len = IEEE80211_NWID_LEN;
247 /* determine printable or not */
248 for (i = 0, p = essid; i < len; i++, p++) {
249 if (*p < ' ' || *p > 0x7e)
250 break;

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

257 } else {
258 printf("0x");
259 for (i = 0, p = essid; i < len; i++, p++)
260 printf("%02x", *p);
261 }
262}
263
264void
244 int i;
245
246 if (len > IEEE80211_NWID_LEN)
247 len = IEEE80211_NWID_LEN;
248 /* determine printable or not */
249 for (i = 0, p = essid; i < len; i++, p++) {
250 if (*p < ' ' || *p > 0x7e)
251 break;

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

258 } else {
259 printf("0x");
260 for (i = 0, p = essid; i < len; i++, p++)
261 printf("%02x", *p);
262 }
263}
264
265void
265ieee80211_dump_pkt(const u_int8_t *buf, int len, int rate, int rssi)
266ieee80211_dump_pkt(struct ieee80211com *ic,
267 const uint8_t *buf, int len, int rate, int rssi)
266{
267 const struct ieee80211_frame *wh;
268 int i;
269
270 wh = (const struct ieee80211_frame *)buf;
271 switch (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) {
272 case IEEE80211_FC1_DIR_NODS:
273 printf("NODS %s", ether_sprintf(wh->i_addr2));

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

280 printf("(%s)", ether_sprintf(wh->i_addr1));
281 break;
282 case IEEE80211_FC1_DIR_FROMDS:
283 printf("FRDS %s", ether_sprintf(wh->i_addr3));
284 printf("->%s", ether_sprintf(wh->i_addr1));
285 printf("(%s)", ether_sprintf(wh->i_addr2));
286 break;
287 case IEEE80211_FC1_DIR_DSTODS:
268{
269 const struct ieee80211_frame *wh;
270 int i;
271
272 wh = (const struct ieee80211_frame *)buf;
273 switch (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) {
274 case IEEE80211_FC1_DIR_NODS:
275 printf("NODS %s", ether_sprintf(wh->i_addr2));

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

282 printf("(%s)", ether_sprintf(wh->i_addr1));
283 break;
284 case IEEE80211_FC1_DIR_FROMDS:
285 printf("FRDS %s", ether_sprintf(wh->i_addr3));
286 printf("->%s", ether_sprintf(wh->i_addr1));
287 printf("(%s)", ether_sprintf(wh->i_addr2));
288 break;
289 case IEEE80211_FC1_DIR_DSTODS:
288 printf("DSDS %s", ether_sprintf((const u_int8_t *)&wh[1]));
290 printf("DSDS %s", ether_sprintf((const uint8_t *)&wh[1]));
289 printf("->%s", ether_sprintf(wh->i_addr3));
290 printf("(%s", ether_sprintf(wh->i_addr2));
291 printf("->%s)", ether_sprintf(wh->i_addr1));
292 break;
293 }
294 switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) {
295 case IEEE80211_FC0_TYPE_DATA:
296 printf(" data");
297 break;
298 case IEEE80211_FC0_TYPE_MGT:
299 printf(" %s", ieee80211_mgt_subtype_name[
300 (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK)
301 >> IEEE80211_FC0_SUBTYPE_SHIFT]);
302 break;
303 default:
304 printf(" type#%d", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK);
305 break;
306 }
291 printf("->%s", ether_sprintf(wh->i_addr3));
292 printf("(%s", ether_sprintf(wh->i_addr2));
293 printf("->%s)", ether_sprintf(wh->i_addr1));
294 break;
295 }
296 switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) {
297 case IEEE80211_FC0_TYPE_DATA:
298 printf(" data");
299 break;
300 case IEEE80211_FC0_TYPE_MGT:
301 printf(" %s", ieee80211_mgt_subtype_name[
302 (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK)
303 >> IEEE80211_FC0_SUBTYPE_SHIFT]);
304 break;
305 default:
306 printf(" type#%d", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK);
307 break;
308 }
309 if (IEEE80211_QOS_HAS_SEQ(wh)) {
310 const struct ieee80211_qosframe *qwh =
311 (const struct ieee80211_qosframe *)buf;
312 printf(" QoS [TID %u%s]", qwh->i_qos[0] & IEEE80211_QOS_TID,
313 qwh->i_qos[0] & IEEE80211_QOS_ACKPOLICY ? " ACM" : "");
314 }
307 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
315 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
308 int i;
309 printf(" WEP [IV");
310 for (i = 0; i < IEEE80211_WEP_IVLEN; i++)
311 printf(" %.02x", buf[sizeof(*wh)+i]);
312 printf(" KID %u]", buf[sizeof(*wh)+i] >> 6);
316 int off;
317
318 off = ieee80211_anyhdrspace(ic, wh);
319 printf(" WEP [IV %.02x %.02x %.02x",
320 buf[off+0], buf[off+1], buf[off+2]);
321 if (buf[off+IEEE80211_WEP_IVLEN] & IEEE80211_WEP_EXTIV)
322 printf(" %.02x %.02x %.02x",
323 buf[off+4], buf[off+5], buf[off+6]);
324 printf(" KID %u]", buf[off+IEEE80211_WEP_IVLEN] >> 6);
313 }
314 if (rate >= 0)
315 printf(" %dM", rate / 2);
316 if (rssi >= 0)
317 printf(" +%d", rssi);
318 printf("\n");
319 if (len > 0) {
320 for (i = 0; i < len; i++) {

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

341ieee80211_fix_rate(struct ieee80211_node *ni,
342 struct ieee80211_rateset *nrs, int flags)
343{
344#define RV(v) ((v) & IEEE80211_RATE_VAL)
345 struct ieee80211com *ic = ni->ni_ic;
346 int i, j, rix, error;
347 int okrate, badrate, fixedrate;
348 const struct ieee80211_rateset *srs;
325 }
326 if (rate >= 0)
327 printf(" %dM", rate / 2);
328 if (rssi >= 0)
329 printf(" +%d", rssi);
330 printf("\n");
331 if (len > 0) {
332 for (i = 0; i < len; i++) {

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

353ieee80211_fix_rate(struct ieee80211_node *ni,
354 struct ieee80211_rateset *nrs, int flags)
355{
356#define RV(v) ((v) & IEEE80211_RATE_VAL)
357 struct ieee80211com *ic = ni->ni_ic;
358 int i, j, rix, error;
359 int okrate, badrate, fixedrate;
360 const struct ieee80211_rateset *srs;
349 u_int8_t r;
361 uint8_t r;
350
362
351 /*
352 * If the fixed rate check was requested but no
353 * fixed has been defined then just remove it.
354 */
355 if ((flags & IEEE80211_F_DOFRATE) &&
356 ic->ic_fixed_rate == IEEE80211_FIXED_RATE_NONE)
357 flags &= ~IEEE80211_F_DOFRATE;
358 error = 0;
363 error = 0;
359 okrate = badrate = fixedrate = 0;
364 okrate = badrate = 0;
365 fixedrate = IEEE80211_FIXED_RATE_NONE;
360 srs = ieee80211_get_suprates(ic, ni->ni_chan);
361 for (i = 0; i < nrs->rs_nrates; ) {
362 if (flags & IEEE80211_F_DOSORT) {
363 /*
364 * Sort rates.
365 */
366 for (j = i + 1; j < nrs->rs_nrates; j++) {
367 if (RV(nrs->rs_rates[i]) > RV(nrs->rs_rates[j])) {
368 r = nrs->rs_rates[i];
369 nrs->rs_rates[i] = nrs->rs_rates[j];
370 nrs->rs_rates[j] = r;
371 }
372 }
373 }
374 r = nrs->rs_rates[i] & IEEE80211_RATE_VAL;
375 badrate = r;
366 srs = ieee80211_get_suprates(ic, ni->ni_chan);
367 for (i = 0; i < nrs->rs_nrates; ) {
368 if (flags & IEEE80211_F_DOSORT) {
369 /*
370 * Sort rates.
371 */
372 for (j = i + 1; j < nrs->rs_nrates; j++) {
373 if (RV(nrs->rs_rates[i]) > RV(nrs->rs_rates[j])) {
374 r = nrs->rs_rates[i];
375 nrs->rs_rates[i] = nrs->rs_rates[j];
376 nrs->rs_rates[j] = r;
377 }
378 }
379 }
380 r = nrs->rs_rates[i] & IEEE80211_RATE_VAL;
381 badrate = r;
376 if (flags & IEEE80211_F_DOFRATE) {
377 /*
378 * Check any fixed rate is included.
379 */
380 if (r == RV(srs->rs_rates[ic->ic_fixed_rate]))
381 fixedrate = r;
382 }
383 /*
382 /*
383 * Check for fixed rate.
384 */
385 if (r == ic->ic_fixed_rate)
386 fixedrate = r;
387 /*
384 * Check against supported rates.
385 */
386 rix = findrix(srs, r);
387 if (flags & IEEE80211_F_DONEGO) {
388 if (rix < 0) {
389 /*
390 * A rate in the node's rate set is not
391 * supported. If this is a basic rate and we

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

413 nrs->rs_rates[j] = 0;
414 continue;
415 }
416 if (rix >= 0)
417 okrate = nrs->rs_rates[i];
418 i++;
419 }
420 if (okrate == 0 || error != 0 ||
388 * Check against supported rates.
389 */
390 rix = findrix(srs, r);
391 if (flags & IEEE80211_F_DONEGO) {
392 if (rix < 0) {
393 /*
394 * A rate in the node's rate set is not
395 * supported. If this is a basic rate and we

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

417 nrs->rs_rates[j] = 0;
418 continue;
419 }
420 if (rix >= 0)
421 okrate = nrs->rs_rates[i];
422 i++;
423 }
424 if (okrate == 0 || error != 0 ||
421 ((flags & IEEE80211_F_DOFRATE) && fixedrate == 0))
425 ((flags & IEEE80211_F_DOFRATE) && fixedrate != ic->ic_fixed_rate))
422 return badrate | IEEE80211_RATE_BASIC;
423 else
424 return RV(okrate);
425#undef RV
426}
427
428/*
429 * Reset 11g-related state.

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

435 ic->ic_nonerpsta = 0;
436 ic->ic_longslotsta = 0;
437 /*
438 * Short slot time is enabled only when operating in 11g
439 * and not in an IBSS. We must also honor whether or not
440 * the driver is capable of doing it.
441 */
442 ieee80211_set_shortslottime(ic,
426 return badrate | IEEE80211_RATE_BASIC;
427 else
428 return RV(okrate);
429#undef RV
430}
431
432/*
433 * Reset 11g-related state.

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

439 ic->ic_nonerpsta = 0;
440 ic->ic_longslotsta = 0;
441 /*
442 * Short slot time is enabled only when operating in 11g
443 * and not in an IBSS. We must also honor whether or not
444 * the driver is capable of doing it.
445 */
446 ieee80211_set_shortslottime(ic,
443 ic->ic_curmode == IEEE80211_MODE_11A ||
444 (ic->ic_curmode == IEEE80211_MODE_11G &&
447 IEEE80211_IS_CHAN_A(ic->ic_curchan) ||
448 IEEE80211_IS_CHAN_HT(ic->ic_curchan) ||
449 (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan) &&
445 ic->ic_opmode == IEEE80211_M_HOSTAP &&
446 (ic->ic_caps & IEEE80211_C_SHSLOT)));
447 /*
448 * Set short preamble and ERP barker-preamble flags.
449 */
450 ic->ic_opmode == IEEE80211_M_HOSTAP &&
451 (ic->ic_caps & IEEE80211_C_SHSLOT)));
452 /*
453 * Set short preamble and ERP barker-preamble flags.
454 */
450 if (ic->ic_curmode == IEEE80211_MODE_11A ||
455 if (IEEE80211_IS_CHAN_A(ic->ic_curchan) ||
451 (ic->ic_caps & IEEE80211_C_SHPREAMBLE)) {
452 ic->ic_flags |= IEEE80211_F_SHPREAMBLE;
453 ic->ic_flags &= ~IEEE80211_F_USEBARKER;
454 } else {
455 ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE;
456 ic->ic_flags |= IEEE80211_F_USEBARKER;
457 }
458}

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

506 * operating mode. For real 11g we mark all the 11b rates
507 * and 6, 12, and 24 OFDM. For 11b compatibility we mark only
508 * 11b rates. There's also a pseudo 11a-mode used to mark only
509 * the basic OFDM rates.
510 */
511void
512ieee80211_set11gbasicrates(struct ieee80211_rateset *rs, enum ieee80211_phymode mode)
513{
456 (ic->ic_caps & IEEE80211_C_SHPREAMBLE)) {
457 ic->ic_flags |= IEEE80211_F_SHPREAMBLE;
458 ic->ic_flags &= ~IEEE80211_F_USEBARKER;
459 } else {
460 ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE;
461 ic->ic_flags |= IEEE80211_F_USEBARKER;
462 }
463}

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

511 * operating mode. For real 11g we mark all the 11b rates
512 * and 6, 12, and 24 OFDM. For 11b compatibility we mark only
513 * 11b rates. There's also a pseudo 11a-mode used to mark only
514 * the basic OFDM rates.
515 */
516void
517ieee80211_set11gbasicrates(struct ieee80211_rateset *rs, enum ieee80211_phymode mode)
518{
514 static const struct ieee80211_rateset basic[] = {
515 { 0 }, /* IEEE80211_MODE_AUTO */
519 static const struct ieee80211_rateset basic[IEEE80211_MODE_MAX] = {
520 { .rs_nrates = 0 }, /* IEEE80211_MODE_AUTO */
516 { 3, { 12, 24, 48 } }, /* IEEE80211_MODE_11A */
517 { 2, { 2, 4 } }, /* IEEE80211_MODE_11B */
518 { 4, { 2, 4, 11, 22 } }, /* IEEE80211_MODE_11G (mixed b/g) */
521 { 3, { 12, 24, 48 } }, /* IEEE80211_MODE_11A */
522 { 2, { 2, 4 } }, /* IEEE80211_MODE_11B */
523 { 4, { 2, 4, 11, 22 } }, /* IEEE80211_MODE_11G (mixed b/g) */
519 { 0 }, /* IEEE80211_MODE_FH */
524 { .rs_nrates = 0 }, /* IEEE80211_MODE_FH */
520 /* IEEE80211_MODE_PUREG (not yet) */
521 { 7, { 2, 4, 11, 22, 12, 24, 48 } },
525 /* IEEE80211_MODE_PUREG (not yet) */
526 { 7, { 2, 4, 11, 22, 12, 24, 48 } },
527 { 3, { 12, 24, 48 } }, /* IEEE80211_MODE_11NA */
528 /* IEEE80211_MODE_11NG (mixed b/g) */
529 { 7, { 2, 4, 11, 22, 12, 24, 48 } },
522 };
523 int i, j;
524
525 for (i = 0; i < rs->rs_nrates; i++) {
526 rs->rs_rates[i] &= IEEE80211_RATE_VAL;
527 for (j = 0; j < basic[mode].rs_nrates; j++)
528 if (basic[mode].rs_rates[j] == rs->rs_rates[i]) {
529 rs->rs_rates[i] |= IEEE80211_RATE_BASIC;
530 break;
531 }
532 }
533}
534
535/*
536 * WME protocol support. The following parameters come from the spec.
537 */
538typedef struct phyParamType {
530 };
531 int i, j;
532
533 for (i = 0; i < rs->rs_nrates; i++) {
534 rs->rs_rates[i] &= IEEE80211_RATE_VAL;
535 for (j = 0; j < basic[mode].rs_nrates; j++)
536 if (basic[mode].rs_rates[j] == rs->rs_rates[i]) {
537 rs->rs_rates[i] |= IEEE80211_RATE_BASIC;
538 break;
539 }
540 }
541}
542
543/*
544 * WME protocol support. The following parameters come from the spec.
545 */
546typedef struct phyParamType {
539 u_int8_t aifsn;
540 u_int8_t logcwmin;
541 u_int8_t logcwmax;
542 u_int16_t txopLimit;
543 u_int8_t acm;
547 uint8_t aifsn;
548 uint8_t logcwmin;
549 uint8_t logcwmax;
550 uint16_t txopLimit;
551 uint8_t acm;
544} paramType;
545
546static const struct phyParamType phyParamForAC_BE[IEEE80211_MODE_MAX] = {
552} paramType;
553
554static const struct phyParamType phyParamForAC_BE[IEEE80211_MODE_MAX] = {
547 { 3, 4, 6 }, /* IEEE80211_MODE_AUTO */
548 { 3, 4, 6 }, /* IEEE80211_MODE_11A */
549 { 3, 5, 7 }, /* IEEE80211_MODE_11B */
550 { 3, 4, 6 }, /* IEEE80211_MODE_11G */
551 { 3, 5, 7 }, /* IEEE80211_MODE_FH */
552 { 2, 3, 5 }, /* IEEE80211_MODE_TURBO_A */
553 { 2, 3, 5 }, /* IEEE80211_MODE_TURBO_G */
555 { 3, 4, 6, 0, 0 }, /* IEEE80211_MODE_AUTO */
556 { 3, 4, 6, 0, 0 }, /* IEEE80211_MODE_11A */
557 { 3, 5, 7, 0, 0 }, /* IEEE80211_MODE_11B */
558 { 3, 4, 6, 0, 0 }, /* IEEE80211_MODE_11G */
559 { 3, 5, 7, 0, 0 }, /* IEEE80211_MODE_FH */
560 { 2, 3, 5, 0, 0 }, /* IEEE80211_MODE_TURBO_A */
561 { 2, 3, 5, 0, 0 }, /* IEEE80211_MODE_TURBO_G */
562 { 2, 3, 5, 0, 0 }, /* IEEE80211_MODE_STURBO_A */
563 { 3, 4, 6, 0, 0 }, /* IEEE80211_MODE_11NA */ /* XXXcheck*/
564 { 3, 4, 6, 0, 0 }, /* IEEE80211_MODE_11NG */ /* XXXcheck*/
554};
555static const struct phyParamType phyParamForAC_BK[IEEE80211_MODE_MAX] = {
565};
566static const struct phyParamType phyParamForAC_BK[IEEE80211_MODE_MAX] = {
556 { 7, 4, 10 }, /* IEEE80211_MODE_AUTO */
557 { 7, 4, 10 }, /* IEEE80211_MODE_11A */
558 { 7, 5, 10 }, /* IEEE80211_MODE_11B */
559 { 7, 4, 10 }, /* IEEE80211_MODE_11G */
560 { 7, 5, 10 }, /* IEEE80211_MODE_FH */
561 { 7, 3, 10 }, /* IEEE80211_MODE_TURBO_A */
562 { 7, 3, 10 }, /* IEEE80211_MODE_TURBO_G */
567 { 7, 4, 10, 0, 0 }, /* IEEE80211_MODE_AUTO */
568 { 7, 4, 10, 0, 0 }, /* IEEE80211_MODE_11A */
569 { 7, 5, 10, 0, 0 }, /* IEEE80211_MODE_11B */
570 { 7, 4, 10, 0, 0 }, /* IEEE80211_MODE_11G */
571 { 7, 5, 10, 0, 0 }, /* IEEE80211_MODE_FH */
572 { 7, 3, 10, 0, 0 }, /* IEEE80211_MODE_TURBO_A */
573 { 7, 3, 10, 0, 0 }, /* IEEE80211_MODE_TURBO_G */
574 { 7, 3, 10, 0, 0 }, /* IEEE80211_MODE_STURBO_A */
575 { 7, 4, 10, 0, 0 }, /* IEEE80211_MODE_11NA */
576 { 7, 4, 10, 0, 0 }, /* IEEE80211_MODE_11NG */
563};
564static const struct phyParamType phyParamForAC_VI[IEEE80211_MODE_MAX] = {
577};
578static const struct phyParamType phyParamForAC_VI[IEEE80211_MODE_MAX] = {
565 { 1, 3, 4, 94 }, /* IEEE80211_MODE_AUTO */
566 { 1, 3, 4, 94 }, /* IEEE80211_MODE_11A */
567 { 1, 4, 5, 188 }, /* IEEE80211_MODE_11B */
568 { 1, 3, 4, 94 }, /* IEEE80211_MODE_11G */
569 { 1, 4, 5, 188 }, /* IEEE80211_MODE_FH */
570 { 1, 2, 3, 94 }, /* IEEE80211_MODE_TURBO_A */
571 { 1, 2, 3, 94 }, /* IEEE80211_MODE_TURBO_G */
579 { 1, 3, 4, 94, 0 }, /* IEEE80211_MODE_AUTO */
580 { 1, 3, 4, 94, 0 }, /* IEEE80211_MODE_11A */
581 { 1, 4, 5, 188, 0 }, /* IEEE80211_MODE_11B */
582 { 1, 3, 4, 94, 0 }, /* IEEE80211_MODE_11G */
583 { 1, 4, 5, 188, 0 }, /* IEEE80211_MODE_FH */
584 { 1, 2, 3, 94, 0 }, /* IEEE80211_MODE_TURBO_A */
585 { 1, 2, 3, 94, 0 }, /* IEEE80211_MODE_TURBO_G */
586 { 1, 2, 3, 94, 0 }, /* IEEE80211_MODE_STURBO_A */
587 { 1, 3, 4, 94, 0 }, /* IEEE80211_MODE_11NA */
588 { 1, 3, 4, 94, 0 }, /* IEEE80211_MODE_11NG */
572};
573static const struct phyParamType phyParamForAC_VO[IEEE80211_MODE_MAX] = {
589};
590static const struct phyParamType phyParamForAC_VO[IEEE80211_MODE_MAX] = {
574 { 1, 2, 3, 47 }, /* IEEE80211_MODE_AUTO */
575 { 1, 2, 3, 47 }, /* IEEE80211_MODE_11A */
576 { 1, 3, 4, 102 }, /* IEEE80211_MODE_11B */
577 { 1, 2, 3, 47 }, /* IEEE80211_MODE_11G */
578 { 1, 3, 4, 102 }, /* IEEE80211_MODE_FH */
579 { 1, 2, 2, 47 }, /* IEEE80211_MODE_TURBO_A */
580 { 1, 2, 2, 47 }, /* IEEE80211_MODE_TURBO_G */
591 { 1, 2, 3, 47, 0 }, /* IEEE80211_MODE_AUTO */
592 { 1, 2, 3, 47, 0 }, /* IEEE80211_MODE_11A */
593 { 1, 3, 4, 102, 0 }, /* IEEE80211_MODE_11B */
594 { 1, 2, 3, 47, 0 }, /* IEEE80211_MODE_11G */
595 { 1, 3, 4, 102, 0 }, /* IEEE80211_MODE_FH */
596 { 1, 2, 2, 47, 0 }, /* IEEE80211_MODE_TURBO_A */
597 { 1, 2, 2, 47, 0 }, /* IEEE80211_MODE_TURBO_G */
598 { 1, 2, 2, 47, 0 }, /* IEEE80211_MODE_STURBO_A */
599 { 1, 2, 3, 47, 0 }, /* IEEE80211_MODE_11NA */
600 { 1, 2, 3, 47, 0 }, /* IEEE80211_MODE_11NG */
581};
582
583static const struct phyParamType bssPhyParamForAC_BE[IEEE80211_MODE_MAX] = {
601};
602
603static const struct phyParamType bssPhyParamForAC_BE[IEEE80211_MODE_MAX] = {
584 { 3, 4, 10 }, /* IEEE80211_MODE_AUTO */
585 { 3, 4, 10 }, /* IEEE80211_MODE_11A */
586 { 3, 5, 10 }, /* IEEE80211_MODE_11B */
587 { 3, 4, 10 }, /* IEEE80211_MODE_11G */
588 { 3, 5, 10 }, /* IEEE80211_MODE_FH */
589 { 2, 3, 10 }, /* IEEE80211_MODE_TURBO_A */
590 { 2, 3, 10 }, /* IEEE80211_MODE_TURBO_G */
604 { 3, 4, 10, 0, 0 }, /* IEEE80211_MODE_AUTO */
605 { 3, 4, 10, 0, 0 }, /* IEEE80211_MODE_11A */
606 { 3, 5, 10, 0, 0 }, /* IEEE80211_MODE_11B */
607 { 3, 4, 10, 0, 0 }, /* IEEE80211_MODE_11G */
608 { 3, 5, 10, 0, 0 }, /* IEEE80211_MODE_FH */
609 { 2, 3, 10, 0, 0 }, /* IEEE80211_MODE_TURBO_A */
610 { 2, 3, 10, 0, 0 }, /* IEEE80211_MODE_TURBO_G */
611 { 2, 3, 10, 0, 0 }, /* IEEE80211_MODE_STURBO_A */
612 { 1, 4, 10, 0, 0 }, /* IEEE80211_MODE_11NA */
613 { 1, 4, 10, 0, 0 }, /* IEEE80211_MODE_11NG */
591};
592static const struct phyParamType bssPhyParamForAC_VI[IEEE80211_MODE_MAX] = {
614};
615static const struct phyParamType bssPhyParamForAC_VI[IEEE80211_MODE_MAX] = {
593 { 2, 3, 4, 94 }, /* IEEE80211_MODE_AUTO */
594 { 2, 3, 4, 94 }, /* IEEE80211_MODE_11A */
595 { 2, 4, 5, 188 }, /* IEEE80211_MODE_11B */
596 { 2, 3, 4, 94 }, /* IEEE80211_MODE_11G */
597 { 2, 4, 5, 188 }, /* IEEE80211_MODE_FH */
598 { 2, 2, 3, 94 }, /* IEEE80211_MODE_TURBO_A */
599 { 2, 2, 3, 94 }, /* IEEE80211_MODE_TURBO_G */
616 { 2, 3, 4, 94, 0 }, /* IEEE80211_MODE_AUTO */
617 { 2, 3, 4, 94, 0 }, /* IEEE80211_MODE_11A */
618 { 2, 4, 5, 188, 0 }, /* IEEE80211_MODE_11B */
619 { 2, 3, 4, 94, 0 }, /* IEEE80211_MODE_11G */
620 { 2, 4, 5, 188, 0 }, /* IEEE80211_MODE_FH */
621 { 2, 2, 3, 94, 0 }, /* IEEE80211_MODE_TURBO_A */
622 { 2, 2, 3, 94, 0 }, /* IEEE80211_MODE_TURBO_G */
623 { 2, 2, 3, 94, 0 }, /* IEEE80211_MODE_STURBO_A */
624 { 2, 3, 4, 94, 0 }, /* IEEE80211_MODE_11NA */
625 { 2, 3, 4, 94, 0 }, /* IEEE80211_MODE_11NG */
600};
601static const struct phyParamType bssPhyParamForAC_VO[IEEE80211_MODE_MAX] = {
626};
627static const struct phyParamType bssPhyParamForAC_VO[IEEE80211_MODE_MAX] = {
602 { 2, 2, 3, 47 }, /* IEEE80211_MODE_AUTO */
603 { 2, 2, 3, 47 }, /* IEEE80211_MODE_11A */
604 { 2, 3, 4, 102 }, /* IEEE80211_MODE_11B */
605 { 2, 2, 3, 47 }, /* IEEE80211_MODE_11G */
606 { 2, 3, 4, 102 }, /* IEEE80211_MODE_FH */
607 { 1, 2, 2, 47 }, /* IEEE80211_MODE_TURBO_A */
608 { 1, 2, 2, 47 }, /* IEEE80211_MODE_TURBO_G */
628 { 2, 2, 3, 47, 0 }, /* IEEE80211_MODE_AUTO */
629 { 2, 2, 3, 47, 0 }, /* IEEE80211_MODE_11A */
630 { 2, 3, 4, 102, 0 }, /* IEEE80211_MODE_11B */
631 { 2, 2, 3, 47, 0 }, /* IEEE80211_MODE_11G */
632 { 2, 3, 4, 102, 0 }, /* IEEE80211_MODE_FH */
633 { 1, 2, 2, 47, 0 }, /* IEEE80211_MODE_TURBO_A */
634 { 1, 2, 2, 47, 0 }, /* IEEE80211_MODE_TURBO_G */
635 { 1, 2, 2, 47, 0 }, /* IEEE80211_MODE_STURBO_A */
636 { 2, 2, 3, 47, 0 }, /* IEEE80211_MODE_11NA */
637 { 2, 2, 3, 47, 0 }, /* IEEE80211_MODE_11NG */
609};
610
611void
612ieee80211_wme_initparams(struct ieee80211com *ic)
613{
614 struct ieee80211_wme_state *wme = &ic->ic_wme;
615 const paramType *pPhyParam, *pBssPhyParam;
616 struct wmeParams *wmep;
638};
639
640void
641ieee80211_wme_initparams(struct ieee80211com *ic)
642{
643 struct ieee80211_wme_state *wme = &ic->ic_wme;
644 const paramType *pPhyParam, *pBssPhyParam;
645 struct wmeParams *wmep;
646 enum ieee80211_phymode mode;
617 int i;
618
619 if ((ic->ic_caps & IEEE80211_C_WME) == 0)
620 return;
621
647 int i;
648
649 if ((ic->ic_caps & IEEE80211_C_WME) == 0)
650 return;
651
652 /*
653 * Select mode; we can be called early in which case we
654 * always use auto mode. We know we'll be called when
655 * entering the RUN state with bsschan setup properly
656 * so state will eventually get set correctly
657 */
658 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC)
659 mode = ieee80211_chan2mode(ic->ic_bsschan);
660 else
661 mode = IEEE80211_MODE_AUTO;
622 for (i = 0; i < WME_NUM_AC; i++) {
623 switch (i) {
624 case WME_AC_BK:
662 for (i = 0; i < WME_NUM_AC; i++) {
663 switch (i) {
664 case WME_AC_BK:
625 pPhyParam = &phyParamForAC_BK[ic->ic_curmode];
626 pBssPhyParam = &phyParamForAC_BK[ic->ic_curmode];
665 pPhyParam = &phyParamForAC_BK[mode];
666 pBssPhyParam = &phyParamForAC_BK[mode];
627 break;
628 case WME_AC_VI:
667 break;
668 case WME_AC_VI:
629 pPhyParam = &phyParamForAC_VI[ic->ic_curmode];
630 pBssPhyParam = &bssPhyParamForAC_VI[ic->ic_curmode];
669 pPhyParam = &phyParamForAC_VI[mode];
670 pBssPhyParam = &bssPhyParamForAC_VI[mode];
631 break;
632 case WME_AC_VO:
671 break;
672 case WME_AC_VO:
633 pPhyParam = &phyParamForAC_VO[ic->ic_curmode];
634 pBssPhyParam = &bssPhyParamForAC_VO[ic->ic_curmode];
673 pPhyParam = &phyParamForAC_VO[mode];
674 pBssPhyParam = &bssPhyParamForAC_VO[mode];
635 break;
636 case WME_AC_BE:
637 default:
675 break;
676 case WME_AC_BE:
677 default:
638 pPhyParam = &phyParamForAC_BE[ic->ic_curmode];
639 pBssPhyParam = &bssPhyParamForAC_BE[ic->ic_curmode];
678 pPhyParam = &phyParamForAC_BE[mode];
679 pBssPhyParam = &bssPhyParamForAC_BE[mode];
640 break;
641 }
642
643 wmep = &wme->wme_wmeChanParams.cap_wmeParams[i];
644 if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
645 wmep->wmep_acm = pPhyParam->acm;
646 wmep->wmep_aifsn = pPhyParam->aifsn;
647 wmep->wmep_logcwmin = pPhyParam->logcwmin;

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

699
700/*
701 * Update WME parameters for ourself and the BSS.
702 */
703void
704ieee80211_wme_updateparams_locked(struct ieee80211com *ic)
705{
706 static const paramType phyParam[IEEE80211_MODE_MAX] = {
680 break;
681 }
682
683 wmep = &wme->wme_wmeChanParams.cap_wmeParams[i];
684 if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
685 wmep->wmep_acm = pPhyParam->acm;
686 wmep->wmep_aifsn = pPhyParam->aifsn;
687 wmep->wmep_logcwmin = pPhyParam->logcwmin;

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

739
740/*
741 * Update WME parameters for ourself and the BSS.
742 */
743void
744ieee80211_wme_updateparams_locked(struct ieee80211com *ic)
745{
746 static const paramType phyParam[IEEE80211_MODE_MAX] = {
707 { 2, 4, 10, 64 }, /* IEEE80211_MODE_AUTO */
708 { 2, 4, 10, 64 }, /* IEEE80211_MODE_11A */
709 { 2, 5, 10, 64 }, /* IEEE80211_MODE_11B */
710 { 2, 4, 10, 64 }, /* IEEE80211_MODE_11G */
711 { 2, 5, 10, 64 }, /* IEEE80211_MODE_FH */
712 { 1, 3, 10, 64 }, /* IEEE80211_MODE_TURBO_A */
713 { 1, 3, 10, 64 }, /* IEEE80211_MODE_TURBO_G */
747 { 2, 4, 10, 64, 0 }, /* IEEE80211_MODE_AUTO */
748 { 2, 4, 10, 64, 0 }, /* IEEE80211_MODE_11A */
749 { 2, 5, 10, 64, 0 }, /* IEEE80211_MODE_11B */
750 { 2, 4, 10, 64, 0 }, /* IEEE80211_MODE_11G */
751 { 2, 5, 10, 64, 0 }, /* IEEE80211_MODE_FH */
752 { 1, 3, 10, 64, 0 }, /* IEEE80211_MODE_TURBO_A */
753 { 1, 3, 10, 64, 0 }, /* IEEE80211_MODE_TURBO_G */
754 { 1, 3, 10, 64, 0 }, /* IEEE80211_MODE_STURBO_A */
755 { 2, 4, 10, 64, 0 }, /* IEEE80211_MODE_11NA */ /*XXXcheck*/
756 { 2, 4, 10, 64, 0 }, /* IEEE80211_MODE_11NG */ /*XXXcheck*/
714 };
715 struct ieee80211_wme_state *wme = &ic->ic_wme;
716 const struct wmeParams *wmep;
717 struct wmeParams *chanp, *bssp;
757 };
758 struct ieee80211_wme_state *wme = &ic->ic_wme;
759 const struct wmeParams *wmep;
760 struct wmeParams *chanp, *bssp;
761 enum ieee80211_phymode mode;
718 int i;
719
720 /* set up the channel access parameters for the physical device */
721 for (i = 0; i < WME_NUM_AC; i++) {
722 chanp = &wme->wme_chanParams.cap_wmeParams[i];
723 wmep = &wme->wme_wmeChanParams.cap_wmeParams[i];
724 chanp->wmep_aifsn = wmep->wmep_aifsn;
725 chanp->wmep_logcwmin = wmep->wmep_logcwmin;

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

730 wmep = &wme->wme_wmeBssChanParams.cap_wmeParams[i];
731 chanp->wmep_aifsn = wmep->wmep_aifsn;
732 chanp->wmep_logcwmin = wmep->wmep_logcwmin;
733 chanp->wmep_logcwmax = wmep->wmep_logcwmax;
734 chanp->wmep_txopLimit = wmep->wmep_txopLimit;
735 }
736
737 /*
762 int i;
763
764 /* set up the channel access parameters for the physical device */
765 for (i = 0; i < WME_NUM_AC; i++) {
766 chanp = &wme->wme_chanParams.cap_wmeParams[i];
767 wmep = &wme->wme_wmeChanParams.cap_wmeParams[i];
768 chanp->wmep_aifsn = wmep->wmep_aifsn;
769 chanp->wmep_logcwmin = wmep->wmep_logcwmin;

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

774 wmep = &wme->wme_wmeBssChanParams.cap_wmeParams[i];
775 chanp->wmep_aifsn = wmep->wmep_aifsn;
776 chanp->wmep_logcwmin = wmep->wmep_logcwmin;
777 chanp->wmep_logcwmax = wmep->wmep_logcwmax;
778 chanp->wmep_txopLimit = wmep->wmep_txopLimit;
779 }
780
781 /*
782 * Select mode; we can be called early in which case we
783 * always use auto mode. We know we'll be called when
784 * entering the RUN state with bsschan setup properly
785 * so state will eventually get set correctly
786 */
787 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC)
788 mode = ieee80211_chan2mode(ic->ic_bsschan);
789 else
790 mode = IEEE80211_MODE_AUTO;
791
792 /*
738 * This implements agressive mode as found in certain
739 * vendors' AP's. When there is significant high
740 * priority (VI/VO) traffic in the BSS throttle back BE
741 * traffic by using conservative parameters. Otherwise
742 * BE uses agressive params to optimize performance of
743 * legacy/non-QoS traffic.
744 */
745 if ((ic->ic_opmode == IEEE80211_M_HOSTAP &&
746 (wme->wme_flags & WME_F_AGGRMODE) != 0) ||
747 (ic->ic_opmode == IEEE80211_M_STA &&
748 (ic->ic_bss->ni_flags & IEEE80211_NODE_QOS) == 0) ||
749 (ic->ic_flags & IEEE80211_F_WME) == 0) {
750 chanp = &wme->wme_chanParams.cap_wmeParams[WME_AC_BE];
751 bssp = &wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE];
752
793 * This implements agressive mode as found in certain
794 * vendors' AP's. When there is significant high
795 * priority (VI/VO) traffic in the BSS throttle back BE
796 * traffic by using conservative parameters. Otherwise
797 * BE uses agressive params to optimize performance of
798 * legacy/non-QoS traffic.
799 */
800 if ((ic->ic_opmode == IEEE80211_M_HOSTAP &&
801 (wme->wme_flags & WME_F_AGGRMODE) != 0) ||
802 (ic->ic_opmode == IEEE80211_M_STA &&
803 (ic->ic_bss->ni_flags & IEEE80211_NODE_QOS) == 0) ||
804 (ic->ic_flags & IEEE80211_F_WME) == 0) {
805 chanp = &wme->wme_chanParams.cap_wmeParams[WME_AC_BE];
806 bssp = &wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE];
807
753 chanp->wmep_aifsn = bssp->wmep_aifsn =
754 phyParam[ic->ic_curmode].aifsn;
808 chanp->wmep_aifsn = bssp->wmep_aifsn = phyParam[mode].aifsn;
755 chanp->wmep_logcwmin = bssp->wmep_logcwmin =
809 chanp->wmep_logcwmin = bssp->wmep_logcwmin =
756 phyParam[ic->ic_curmode].logcwmin;
810 phyParam[mode].logcwmin;
757 chanp->wmep_logcwmax = bssp->wmep_logcwmax =
811 chanp->wmep_logcwmax = bssp->wmep_logcwmax =
758 phyParam[ic->ic_curmode].logcwmax;
812 phyParam[mode].logcwmax;
759 chanp->wmep_txopLimit = bssp->wmep_txopLimit =
760 (ic->ic_flags & IEEE80211_F_BURST) ?
813 chanp->wmep_txopLimit = bssp->wmep_txopLimit =
814 (ic->ic_flags & IEEE80211_F_BURST) ?
761 phyParam[ic->ic_curmode].txopLimit : 0;
815 phyParam[mode].txopLimit : 0;
762 IEEE80211_DPRINTF(ic, IEEE80211_MSG_WME,
763 "%s: %s [acm %u aifsn %u log2(cwmin) %u "
764 "log2(cwmax) %u txpoLimit %u]\n", __func__
765 , ieee80211_wme_acnames[WME_AC_BE]
766 , chanp->wmep_acm
767 , chanp->wmep_aifsn
768 , chanp->wmep_logcwmin
769 , chanp->wmep_logcwmax
770 , chanp->wmep_txopLimit
771 );
772 }
773
774 if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
775 ic->ic_sta_assoc < 2 && (wme->wme_flags & WME_F_AGGRMODE) != 0) {
816 IEEE80211_DPRINTF(ic, IEEE80211_MSG_WME,
817 "%s: %s [acm %u aifsn %u log2(cwmin) %u "
818 "log2(cwmax) %u txpoLimit %u]\n", __func__
819 , ieee80211_wme_acnames[WME_AC_BE]
820 , chanp->wmep_acm
821 , chanp->wmep_aifsn
822 , chanp->wmep_logcwmin
823 , chanp->wmep_logcwmax
824 , chanp->wmep_txopLimit
825 );
826 }
827
828 if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
829 ic->ic_sta_assoc < 2 && (wme->wme_flags & WME_F_AGGRMODE) != 0) {
776 static const u_int8_t logCwMin[IEEE80211_MODE_MAX] = {
830 static const uint8_t logCwMin[IEEE80211_MODE_MAX] = {
777 3, /* IEEE80211_MODE_AUTO */
778 3, /* IEEE80211_MODE_11A */
779 4, /* IEEE80211_MODE_11B */
780 3, /* IEEE80211_MODE_11G */
781 4, /* IEEE80211_MODE_FH */
782 3, /* IEEE80211_MODE_TURBO_A */
783 3, /* IEEE80211_MODE_TURBO_G */
831 3, /* IEEE80211_MODE_AUTO */
832 3, /* IEEE80211_MODE_11A */
833 4, /* IEEE80211_MODE_11B */
834 3, /* IEEE80211_MODE_11G */
835 4, /* IEEE80211_MODE_FH */
836 3, /* IEEE80211_MODE_TURBO_A */
837 3, /* IEEE80211_MODE_TURBO_G */
838 3, /* IEEE80211_MODE_STURBO_A */
839 3, /* IEEE80211_MODE_11NA */
840 3, /* IEEE80211_MODE_11NG */
784 };
785 chanp = &wme->wme_chanParams.cap_wmeParams[WME_AC_BE];
786 bssp = &wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE];
787
841 };
842 chanp = &wme->wme_chanParams.cap_wmeParams[WME_AC_BE];
843 bssp = &wme->wme_bssChanParams.cap_wmeParams[WME_AC_BE];
844
788 chanp->wmep_logcwmin = bssp->wmep_logcwmin =
789 logCwMin[ic->ic_curmode];
845 chanp->wmep_logcwmin = bssp->wmep_logcwmin = logCwMin[mode];
790 IEEE80211_DPRINTF(ic, IEEE80211_MSG_WME,
791 "%s: %s log2(cwmin) %u\n", __func__
792 , ieee80211_wme_acnames[WME_AC_BE]
793 , chanp->wmep_logcwmin
794 );
795 }
796 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* XXX ibss? */
797 /*

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

818
819 if (ic->ic_caps & IEEE80211_C_WME) {
820 IEEE80211_BEACON_LOCK(ic);
821 ieee80211_wme_updateparams_locked(ic);
822 IEEE80211_BEACON_UNLOCK(ic);
823 }
824}
825
846 IEEE80211_DPRINTF(ic, IEEE80211_MSG_WME,
847 "%s: %s log2(cwmin) %u\n", __func__
848 , ieee80211_wme_acnames[WME_AC_BE]
849 , chanp->wmep_logcwmin
850 );
851 }
852 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* XXX ibss? */
853 /*

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

874
875 if (ic->ic_caps & IEEE80211_C_WME) {
876 IEEE80211_BEACON_LOCK(ic);
877 ieee80211_wme_updateparams_locked(ic);
878 IEEE80211_BEACON_UNLOCK(ic);
879 }
880}
881
882/*
883 * Start a device. If this is the first vap running on the
884 * underlying device then we first bring it up.
885 */
886int
887ieee80211_init(struct ieee80211com *ic, int forcescan)
888{
889
890 IEEE80211_DPRINTF(ic,
891 IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
892 "%s\n", "start running");
893
894 /*
895 * Kick the 802.11 state machine as appropriate.
896 */
897 if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL) {
898 if (ic->ic_opmode == IEEE80211_M_STA) {
899 /*
900 * Try to be intelligent about clocking the state
901 * machine. If we're currently in RUN state then
902 * we should be able to apply any new state/parameters
903 * simply by re-associating. Otherwise we need to
904 * re-scan to select an appropriate ap.
905 */
906 if (ic->ic_state != IEEE80211_S_RUN || forcescan)
907 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0);
908 else
909 ieee80211_new_state(ic, IEEE80211_S_ASSOC, 1);
910 } else {
911 /*
912 * For monitor+wds modes there's nothing to do but
913 * start running. Otherwise, if this is the first
914 * vap to be brought up, start a scan which may be
915 * preempted if the station is locked to a particular
916 * channel.
917 */
918 if (ic->ic_opmode == IEEE80211_M_MONITOR ||
919 ic->ic_opmode == IEEE80211_M_WDS) {
920 ic->ic_state = IEEE80211_S_INIT; /* XXX*/
921 ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
922 } else
923 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0);
924 }
925 }
926 return 0;
927}
928
929/*
930 * Switch between turbo and non-turbo operating modes.
931 * Use the specified channel flags to locate the new
932 * channel, update 802.11 state, and then call back into
933 * the driver to effect the change.
934 */
826void
935void
936ieee80211_dturbo_switch(struct ieee80211com *ic, int newflags)
937{
938 struct ieee80211_channel *chan;
939
940 chan = ieee80211_find_channel(ic, ic->ic_bsschan->ic_freq, newflags);
941 if (chan == NULL) { /* XXX should not happen */
942 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SUPERG,
943 "%s: no channel with freq %u flags 0x%x\n",
944 __func__, ic->ic_bsschan->ic_freq, newflags);
945 return;
946 }
947
948 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SUPERG,
949 "%s: %s -> %s (freq %u flags 0x%x)\n", __func__,
950 ieee80211_phymode_name[ieee80211_chan2mode(ic->ic_bsschan)],
951 ieee80211_phymode_name[ieee80211_chan2mode(chan)],
952 chan->ic_freq, chan->ic_flags);
953
954 ic->ic_bsschan = chan;
955 ic->ic_prevchan = ic->ic_curchan;
956 ic->ic_curchan = chan;
957 ic->ic_set_channel(ic);
958 /* NB: do not need to reset ERP state 'cuz we're in sta mode */
959}
960
961void
827ieee80211_beacon_miss(struct ieee80211com *ic)
828{
829
830 if (ic->ic_flags & IEEE80211_F_SCAN) {
831 /* XXX check ic_curchan != ic_bsschan? */
832 return;
833 }
962ieee80211_beacon_miss(struct ieee80211com *ic)
963{
964
965 if (ic->ic_flags & IEEE80211_F_SCAN) {
966 /* XXX check ic_curchan != ic_bsschan? */
967 return;
968 }
834 IEEE80211_DPRINTF(ic,
835 IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
969 IEEE80211_DPRINTF(ic, IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
836 "%s\n", "beacon miss");
837
838 /*
839 * Our handling is only meaningful for stations that are
840 * associated; any other conditions else will be handled
841 * through different means (e.g. the tx timeout on mgt frames).
842 */
843 if (ic->ic_opmode != IEEE80211_M_STA || ic->ic_state != IEEE80211_S_RUN)

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

852 */
853 ieee80211_send_probereq(ic->ic_bss, ic->ic_myaddr,
854 ic->ic_bss->ni_bssid, ic->ic_bss->ni_bssid,
855 ic->ic_bss->ni_essid, ic->ic_bss->ni_esslen,
856 ic->ic_opt_ie, ic->ic_opt_ie_len);
857 return;
858 }
859 ic->ic_bmiss_count = 0;
970 "%s\n", "beacon miss");
971
972 /*
973 * Our handling is only meaningful for stations that are
974 * associated; any other conditions else will be handled
975 * through different means (e.g. the tx timeout on mgt frames).
976 */
977 if (ic->ic_opmode != IEEE80211_M_STA || ic->ic_state != IEEE80211_S_RUN)

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

986 */
987 ieee80211_send_probereq(ic->ic_bss, ic->ic_myaddr,
988 ic->ic_bss->ni_bssid, ic->ic_bss->ni_bssid,
989 ic->ic_bss->ni_essid, ic->ic_bss->ni_esslen,
990 ic->ic_opt_ie, ic->ic_opt_ie_len);
991 return;
992 }
993 ic->ic_bmiss_count = 0;
860 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0);
994 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
995 /*
996 * If we receive a beacon miss interrupt when using
997 * dynamic turbo, attempt to switch modes before
998 * reassociating.
999 */
1000 if (IEEE80211_ATH_CAP(ic, ic->ic_bss, IEEE80211_NODE_TURBOP))
1001 ieee80211_dturbo_switch(ic,
1002 ic->ic_bsschan->ic_flags ^ IEEE80211_CHAN_TURBO);
1003 /*
1004 * Try to reassociate before scanning for a new ap.
1005 */
1006 ieee80211_new_state(ic, IEEE80211_S_ASSOC, 1);
1007 } else {
1008 /*
1009 * Somebody else is controlling state changes (e.g.
1010 * a user-mode app) don't do anything that would
1011 * confuse them; just drop into scan mode so they'll
1012 * notified of the state change and given control.
1013 */
1014 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0);
1015 }
861}
862
863/*
864 * Software beacon miss handling. Check if any beacons
865 * were received in the last period. If not post a
866 * beacon miss; otherwise reset the counter.
867 */
868static void

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

896sta_deauth(void *arg, struct ieee80211_node *ni)
897{
898 struct ieee80211com *ic = arg;
899
900 IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH,
901 IEEE80211_REASON_ASSOC_LEAVE);
902}
903
1016}
1017
1018/*
1019 * Software beacon miss handling. Check if any beacons
1020 * were received in the last period. If not post a
1021 * beacon miss; otherwise reset the counter.
1022 */
1023static void

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

1051sta_deauth(void *arg, struct ieee80211_node *ni)
1052{
1053 struct ieee80211com *ic = arg;
1054
1055 IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH,
1056 IEEE80211_REASON_ASSOC_LEAVE);
1057}
1058
1059/*
1060 * Handle deauth with reason. We retry only for
1061 * the cases where we might succeed. Otherwise
1062 * we downgrade the ap and scan.
1063 */
1064static void
1065sta_authretry(struct ieee80211com *ic, struct ieee80211_node *ni, int reason)
1066{
1067 switch (reason) {
1068 case IEEE80211_STATUS_TIMEOUT:
1069 case IEEE80211_REASON_ASSOC_EXPIRE:
1070 case IEEE80211_REASON_NOT_AUTHED:
1071 case IEEE80211_REASON_NOT_ASSOCED:
1072 case IEEE80211_REASON_ASSOC_LEAVE:
1073 case IEEE80211_REASON_ASSOC_NOT_AUTHED:
1074 IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_AUTH, 1);
1075 break;
1076 default:
1077 ieee80211_scan_assoc_fail(ic, ic->ic_bss->ni_macaddr, reason);
1078 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO)
1079 ieee80211_check_scan(ic,
1080 IEEE80211_SCAN_ACTIVE,
1081 IEEE80211_SCAN_FOREVER,
1082 ic->ic_des_nssid, ic->ic_des_ssid);
1083 break;
1084 }
1085}
1086
904static int
905ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
906{
907 struct ifnet *ifp = ic->ic_ifp;
908 struct ieee80211_node *ni;
909 enum ieee80211_state ostate;
910
911 ostate = ic->ic_state;
912 IEEE80211_DPRINTF(ic, IEEE80211_MSG_STATE, "%s: %s -> %s\n", __func__,
913 ieee80211_state_name[ostate], ieee80211_state_name[nstate]);
914 ic->ic_state = nstate; /* state transition */
1087static int
1088ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
1089{
1090 struct ifnet *ifp = ic->ic_ifp;
1091 struct ieee80211_node *ni;
1092 enum ieee80211_state ostate;
1093
1094 ostate = ic->ic_state;
1095 IEEE80211_DPRINTF(ic, IEEE80211_MSG_STATE, "%s: %s -> %s\n", __func__,
1096 ieee80211_state_name[ostate], ieee80211_state_name[nstate]);
1097 ic->ic_state = nstate; /* state transition */
1098 callout_stop(&ic->ic_mgtsend); /* XXX callout_drain */
1099 if (ostate != IEEE80211_S_SCAN)
1100 ieee80211_cancel_scan(ic); /* background scan */
915 ni = ic->ic_bss; /* NB: no reference held */
916 if (ic->ic_flags_ext & IEEE80211_FEXT_SWBMISS)
917 callout_stop(&ic->ic_swbmiss);
918 switch (nstate) {
919 case IEEE80211_S_INIT:
920 switch (ostate) {
921 case IEEE80211_S_INIT:
922 break;

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

954 case IEEE80211_S_SCAN:
955 ieee80211_cancel_scan(ic);
956 break;
957 case IEEE80211_S_AUTH:
958 break;
959 }
960 if (ostate != IEEE80211_S_INIT) {
961 /* NB: optimize INIT -> INIT case */
1101 ni = ic->ic_bss; /* NB: no reference held */
1102 if (ic->ic_flags_ext & IEEE80211_FEXT_SWBMISS)
1103 callout_stop(&ic->ic_swbmiss);
1104 switch (nstate) {
1105 case IEEE80211_S_INIT:
1106 switch (ostate) {
1107 case IEEE80211_S_INIT:
1108 break;

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

1140 case IEEE80211_S_SCAN:
1141 ieee80211_cancel_scan(ic);
1142 break;
1143 case IEEE80211_S_AUTH:
1144 break;
1145 }
1146 if (ostate != IEEE80211_S_INIT) {
1147 /* NB: optimize INIT -> INIT case */
962 ic->ic_mgt_timer = 0;
963 ieee80211_drain_ifq(&ic->ic_mgtq);
964 ieee80211_reset_bss(ic);
1148 ieee80211_drain_ifq(&ic->ic_mgtq);
1149 ieee80211_reset_bss(ic);
1150 ieee80211_scan_flush(ic);
965 }
966 if (ic->ic_auth->ia_detach != NULL)
967 ic->ic_auth->ia_detach(ic);
968 break;
969 case IEEE80211_S_SCAN:
970 switch (ostate) {
971 case IEEE80211_S_INIT:
1151 }
1152 if (ic->ic_auth->ia_detach != NULL)
1153 ic->ic_auth->ia_detach(ic);
1154 break;
1155 case IEEE80211_S_SCAN:
1156 switch (ostate) {
1157 case IEEE80211_S_INIT:
1158 createibss:
972 if ((ic->ic_opmode == IEEE80211_M_HOSTAP ||
973 ic->ic_opmode == IEEE80211_M_IBSS ||
974 ic->ic_opmode == IEEE80211_M_AHDEMO) &&
975 ic->ic_des_chan != IEEE80211_CHAN_ANYC) {
976 /*
1159 if ((ic->ic_opmode == IEEE80211_M_HOSTAP ||
1160 ic->ic_opmode == IEEE80211_M_IBSS ||
1161 ic->ic_opmode == IEEE80211_M_AHDEMO) &&
1162 ic->ic_des_chan != IEEE80211_CHAN_ANYC) {
1163 /*
977 * AP operation and we already have a channel;
978 * bypass the scan and startup immediately.
1164 * Already have a channel; bypass the
1165 * scan and startup immediately. Because
1166 * of this explicitly sync the scanner state.
979 */
1167 */
1168 ieee80211_scan_update(ic);
980 ieee80211_create_ibss(ic, ic->ic_des_chan);
981 } else {
1169 ieee80211_create_ibss(ic, ic->ic_des_chan);
1170 } else {
982 ieee80211_begin_scan(ic, arg);
1171 ieee80211_check_scan(ic,
1172 IEEE80211_SCAN_ACTIVE |
1173 IEEE80211_SCAN_FLUSH,
1174 IEEE80211_SCAN_FOREVER,
1175 ic->ic_des_nssid, ic->ic_des_ssid);
983 }
984 break;
985 case IEEE80211_S_SCAN:
1176 }
1177 break;
1178 case IEEE80211_S_SCAN:
1179 case IEEE80211_S_AUTH:
1180 case IEEE80211_S_ASSOC:
986 /*
1181 /*
987 * Scan next. If doing an active scan probe
988 * for the requested ap (if any).
1182 * These can happen either because of a timeout
1183 * on an assoc/auth response or because of a
1184 * change in state that requires a reset. For
1185 * the former we're called with a non-zero arg
1186 * that is the cause for the failure; pass this
1187 * to the scan code so it can update state.
1188 * Otherwise trigger a new scan unless we're in
1189 * manual roaming mode in which case an application
1190 * must issue an explicit scan request.
989 */
1191 */
990 if (ic->ic_flags & IEEE80211_F_ASCAN)
991 ieee80211_probe_curchan(ic, 0);
1192 if (arg != 0)
1193 ieee80211_scan_assoc_fail(ic,
1194 ic->ic_bss->ni_macaddr, arg);
1195 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO)
1196 ieee80211_check_scan(ic,
1197 IEEE80211_SCAN_ACTIVE,
1198 IEEE80211_SCAN_FOREVER,
1199 ic->ic_des_nssid, ic->ic_des_ssid);
992 break;
1200 break;
993 case IEEE80211_S_RUN:
994 /* beacon miss */
995 IEEE80211_DPRINTF(ic, IEEE80211_MSG_STATE,
996 "no recent beacons from %s; rescanning\n",
997 ether_sprintf(ic->ic_bss->ni_bssid));
998 ieee80211_sta_leave(ic, ni);
999 ic->ic_flags &= ~IEEE80211_F_SIBSS; /* XXX */
1000 /* FALLTHRU */
1001 case IEEE80211_S_AUTH:
1002 case IEEE80211_S_ASSOC:
1003 /* timeout restart scan */
1004 ni = ieee80211_find_node(&ic->ic_scan,
1005 ic->ic_bss->ni_macaddr);
1006 if (ni != NULL) {
1007 ni->ni_fails++;
1008 ieee80211_unref_node(&ni);
1201 case IEEE80211_S_RUN: /* beacon miss */
1202 if (ic->ic_opmode == IEEE80211_M_STA) {
1203 ieee80211_sta_leave(ic, ni);
1204 ic->ic_flags &= ~IEEE80211_F_SIBSS; /* XXX */
1205 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO)
1206 ieee80211_check_scan(ic,
1207 IEEE80211_SCAN_ACTIVE,
1208 IEEE80211_SCAN_FOREVER,
1209 ic->ic_des_nssid,
1210 ic->ic_des_ssid);
1211 } else {
1212 ieee80211_iterate_nodes(&ic->ic_sta,
1213 sta_disassoc, ic);
1214 goto createibss;
1009 }
1215 }
1010 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO)
1011 ieee80211_begin_scan(ic, arg);
1012 break;
1013 }
1014 break;
1015 case IEEE80211_S_AUTH:
1216 break;
1217 }
1218 break;
1219 case IEEE80211_S_AUTH:
1220 KASSERT(ic->ic_opmode == IEEE80211_M_STA,
1221 ("switch to %s state when operating in mode %u",
1222 ieee80211_state_name[nstate], ic->ic_opmode));
1016 switch (ostate) {
1017 case IEEE80211_S_INIT:
1018 case IEEE80211_S_SCAN:
1019 IEEE80211_SEND_MGMT(ic, ni,
1020 IEEE80211_FC0_SUBTYPE_AUTH, 1);
1021 break;
1022 case IEEE80211_S_AUTH:
1023 case IEEE80211_S_ASSOC:
1223 switch (ostate) {
1224 case IEEE80211_S_INIT:
1225 case IEEE80211_S_SCAN:
1226 IEEE80211_SEND_MGMT(ic, ni,
1227 IEEE80211_FC0_SUBTYPE_AUTH, 1);
1228 break;
1229 case IEEE80211_S_AUTH:
1230 case IEEE80211_S_ASSOC:
1024 switch (arg) {
1231 switch (arg & 0xff) {
1025 case IEEE80211_FC0_SUBTYPE_AUTH:
1026 /* ??? */
1027 IEEE80211_SEND_MGMT(ic, ni,
1028 IEEE80211_FC0_SUBTYPE_AUTH, 2);
1029 break;
1030 case IEEE80211_FC0_SUBTYPE_DEAUTH:
1232 case IEEE80211_FC0_SUBTYPE_AUTH:
1233 /* ??? */
1234 IEEE80211_SEND_MGMT(ic, ni,
1235 IEEE80211_FC0_SUBTYPE_AUTH, 2);
1236 break;
1237 case IEEE80211_FC0_SUBTYPE_DEAUTH:
1031 /* ignore and retry scan on timeout */
1238 sta_authretry(ic, ni, arg>>8);
1032 break;
1033 }
1034 break;
1035 case IEEE80211_S_RUN:
1239 break;
1240 }
1241 break;
1242 case IEEE80211_S_RUN:
1036 switch (arg) {
1243 switch (arg & 0xff) {
1037 case IEEE80211_FC0_SUBTYPE_AUTH:
1038 IEEE80211_SEND_MGMT(ic, ni,
1039 IEEE80211_FC0_SUBTYPE_AUTH, 2);
1040 ic->ic_state = ostate; /* stay RUN */
1041 break;
1042 case IEEE80211_FC0_SUBTYPE_DEAUTH:
1043 ieee80211_sta_leave(ic, ni);
1044 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
1045 /* try to reauth */
1046 IEEE80211_SEND_MGMT(ic, ni,
1047 IEEE80211_FC0_SUBTYPE_AUTH, 1);
1048 }
1049 break;
1050 }
1051 break;
1052 }
1053 break;
1054 case IEEE80211_S_ASSOC:
1244 case IEEE80211_FC0_SUBTYPE_AUTH:
1245 IEEE80211_SEND_MGMT(ic, ni,
1246 IEEE80211_FC0_SUBTYPE_AUTH, 2);
1247 ic->ic_state = ostate; /* stay RUN */
1248 break;
1249 case IEEE80211_FC0_SUBTYPE_DEAUTH:
1250 ieee80211_sta_leave(ic, ni);
1251 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
1252 /* try to reauth */
1253 IEEE80211_SEND_MGMT(ic, ni,
1254 IEEE80211_FC0_SUBTYPE_AUTH, 1);
1255 }
1256 break;
1257 }
1258 break;
1259 }
1260 break;
1261 case IEEE80211_S_ASSOC:
1262 KASSERT(ic->ic_opmode == IEEE80211_M_STA,
1263 ("switch to %s state when operating in mode %u",
1264 ieee80211_state_name[nstate], ic->ic_opmode));
1055 switch (ostate) {
1056 case IEEE80211_S_INIT:
1057 case IEEE80211_S_SCAN:
1265 switch (ostate) {
1266 case IEEE80211_S_INIT:
1267 case IEEE80211_S_SCAN:
1058 case IEEE80211_S_ASSOC:
1059 IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
1060 "%s: invalid transition\n", __func__);
1061 break;
1062 case IEEE80211_S_AUTH:
1268 IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
1269 "%s: invalid transition\n", __func__);
1270 break;
1271 case IEEE80211_S_AUTH:
1272 case IEEE80211_S_ASSOC:
1063 IEEE80211_SEND_MGMT(ic, ni,
1064 IEEE80211_FC0_SUBTYPE_ASSOC_REQ, 0);
1065 break;
1066 case IEEE80211_S_RUN:
1067 ieee80211_sta_leave(ic, ni);
1068 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
1273 IEEE80211_SEND_MGMT(ic, ni,
1274 IEEE80211_FC0_SUBTYPE_ASSOC_REQ, 0);
1275 break;
1276 case IEEE80211_S_RUN:
1277 ieee80211_sta_leave(ic, ni);
1278 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
1069 IEEE80211_SEND_MGMT(ic, ni,
1070 IEEE80211_FC0_SUBTYPE_ASSOC_REQ, 1);
1279 IEEE80211_SEND_MGMT(ic, ni, arg ?
1280 IEEE80211_FC0_SUBTYPE_REASSOC_REQ :
1281 IEEE80211_FC0_SUBTYPE_ASSOC_REQ, 0);
1071 }
1072 break;
1073 }
1074 break;
1075 case IEEE80211_S_RUN:
1076 if (ic->ic_flags & IEEE80211_F_WPA) {
1077 /* XXX validate prerequisites */
1078 }
1079 switch (ostate) {
1080 case IEEE80211_S_INIT:
1282 }
1283 break;
1284 }
1285 break;
1286 case IEEE80211_S_RUN:
1287 if (ic->ic_flags & IEEE80211_F_WPA) {
1288 /* XXX validate prerequisites */
1289 }
1290 switch (ostate) {
1291 case IEEE80211_S_INIT:
1081 if (ic->ic_opmode == IEEE80211_M_MONITOR)
1292 if (ic->ic_opmode == IEEE80211_M_MONITOR ||
1293 ic->ic_opmode == IEEE80211_M_WDS ||
1294 ic->ic_opmode == IEEE80211_M_HOSTAP) {
1295 /*
1296 * Already have a channel; bypass the
1297 * scan and startup immediately. Because
1298 * of this explicitly sync the scanner state.
1299 */
1300 ieee80211_scan_update(ic);
1301 ieee80211_create_ibss(ic, ic->ic_curchan);
1082 break;
1302 break;
1303 }
1083 /* fall thru... */
1084 case IEEE80211_S_AUTH:
1085 IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
1086 "%s: invalid transition\n", __func__);
1087 /* fall thru... */
1088 case IEEE80211_S_RUN:
1089 break;
1090 case IEEE80211_S_SCAN: /* adhoc/hostap mode */

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

1102 ether_sprintf(ni->ni_bssid));
1103 ieee80211_print_essid(ic->ic_bss->ni_essid,
1104 ni->ni_esslen);
1105 printf(" channel %d start %uMb\n",
1106 ieee80211_chan2ieee(ic, ic->ic_curchan),
1107 IEEE80211_RATE2MBS(ni->ni_rates.rs_rates[ni->ni_txrate]));
1108 }
1109#endif
1304 /* fall thru... */
1305 case IEEE80211_S_AUTH:
1306 IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
1307 "%s: invalid transition\n", __func__);
1308 /* fall thru... */
1309 case IEEE80211_S_RUN:
1310 break;
1311 case IEEE80211_S_SCAN: /* adhoc/hostap mode */

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

1323 ether_sprintf(ni->ni_bssid));
1324 ieee80211_print_essid(ic->ic_bss->ni_essid,
1325 ni->ni_esslen);
1326 printf(" channel %d start %uMb\n",
1327 ieee80211_chan2ieee(ic, ic->ic_curchan),
1328 IEEE80211_RATE2MBS(ni->ni_rates.rs_rates[ni->ni_txrate]));
1329 }
1330#endif
1110 ic->ic_mgt_timer = 0;
1111 if (ic->ic_opmode == IEEE80211_M_STA)
1331 if (ic->ic_opmode == IEEE80211_M_STA) {
1332 ieee80211_scan_assoc_success(ic,
1333 ni->ni_macaddr);
1112 ieee80211_notify_node_join(ic, ni,
1113 arg == IEEE80211_FC0_SUBTYPE_ASSOC_RESP);
1334 ieee80211_notify_node_join(ic, ni,
1335 arg == IEEE80211_FC0_SUBTYPE_ASSOC_RESP);
1336 }
1114 if_start(ifp); /* XXX not authorized yet */
1115 break;
1116 }
1117 if (ostate != IEEE80211_S_RUN &&
1118 ic->ic_opmode == IEEE80211_M_STA &&
1119 (ic->ic_flags_ext & IEEE80211_FEXT_SWBMISS)) {
1120 /*
1121 * Start s/w beacon miss timer for devices w/o

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

1145 * at this point so traffic can flow.
1146 */
1147 if (ni->ni_authmode != IEEE80211_AUTH_8021X)
1148 ieee80211_node_authorize(ni);
1149 /*
1150 * Enable inactivity processing.
1151 * XXX
1152 */
1337 if_start(ifp); /* XXX not authorized yet */
1338 break;
1339 }
1340 if (ostate != IEEE80211_S_RUN &&
1341 ic->ic_opmode == IEEE80211_M_STA &&
1342 (ic->ic_flags_ext & IEEE80211_FEXT_SWBMISS)) {
1343 /*
1344 * Start s/w beacon miss timer for devices w/o

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

1368 * at this point so traffic can flow.
1369 */
1370 if (ni->ni_authmode != IEEE80211_AUTH_8021X)
1371 ieee80211_node_authorize(ni);
1372 /*
1373 * Enable inactivity processing.
1374 * XXX
1375 */
1153 ic->ic_scan.nt_inact_timer = IEEE80211_INACT_WAIT;
1154 ic->ic_sta.nt_inact_timer = IEEE80211_INACT_WAIT;
1376 callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz,
1377 ieee80211_node_timeout, ic);
1155 break;
1156 }
1157 return 0;
1158}
1378 break;
1379 }
1380 return 0;
1381}