diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-08 10:40:36 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-11 15:53:35 -0400 |
commit | 37ffc8da803a1151e887f2a80f08f0c49d1dc1d5 (patch) | |
tree | 9d7a5e76210cfbf33b9187287cbc0b2f7ee80cb4 /net/mac80211/util.c | |
parent | 5fd12d4da198647e834f93f163e20bfcdd33bad8 (diff) |
mac80211: move IE parsing to util file
Since IE parsing is required for the mlme and mesh code, it's
not a static function anyway, and it's much better to have it
in util rather than the overly large mlme.c
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r-- | net/mac80211/util.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index f40c060341ae..e19c74cada39 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -428,3 +428,147 @@ void ieee80211_iterate_active_interfaces_atomic( | |||
428 | rcu_read_unlock(); | 428 | rcu_read_unlock(); |
429 | } | 429 | } |
430 | EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic); | 430 | EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic); |
431 | |||
432 | void ieee802_11_parse_elems(u8 *start, size_t len, | ||
433 | struct ieee802_11_elems *elems) | ||
434 | { | ||
435 | size_t left = len; | ||
436 | u8 *pos = start; | ||
437 | |||
438 | memset(elems, 0, sizeof(*elems)); | ||
439 | elems->ie_start = start; | ||
440 | elems->total_len = len; | ||
441 | |||
442 | while (left >= 2) { | ||
443 | u8 id, elen; | ||
444 | |||
445 | id = *pos++; | ||
446 | elen = *pos++; | ||
447 | left -= 2; | ||
448 | |||
449 | if (elen > left) | ||
450 | return; | ||
451 | |||
452 | switch (id) { | ||
453 | case WLAN_EID_SSID: | ||
454 | elems->ssid = pos; | ||
455 | elems->ssid_len = elen; | ||
456 | break; | ||
457 | case WLAN_EID_SUPP_RATES: | ||
458 | elems->supp_rates = pos; | ||
459 | elems->supp_rates_len = elen; | ||
460 | break; | ||
461 | case WLAN_EID_FH_PARAMS: | ||
462 | elems->fh_params = pos; | ||
463 | elems->fh_params_len = elen; | ||
464 | break; | ||
465 | case WLAN_EID_DS_PARAMS: | ||
466 | elems->ds_params = pos; | ||
467 | elems->ds_params_len = elen; | ||
468 | break; | ||
469 | case WLAN_EID_CF_PARAMS: | ||
470 | elems->cf_params = pos; | ||
471 | elems->cf_params_len = elen; | ||
472 | break; | ||
473 | case WLAN_EID_TIM: | ||
474 | elems->tim = pos; | ||
475 | elems->tim_len = elen; | ||
476 | break; | ||
477 | case WLAN_EID_IBSS_PARAMS: | ||
478 | elems->ibss_params = pos; | ||
479 | elems->ibss_params_len = elen; | ||
480 | break; | ||
481 | case WLAN_EID_CHALLENGE: | ||
482 | elems->challenge = pos; | ||
483 | elems->challenge_len = elen; | ||
484 | break; | ||
485 | case WLAN_EID_WPA: | ||
486 | if (elen >= 4 && pos[0] == 0x00 && pos[1] == 0x50 && | ||
487 | pos[2] == 0xf2) { | ||
488 | /* Microsoft OUI (00:50:F2) */ | ||
489 | if (pos[3] == 1) { | ||
490 | /* OUI Type 1 - WPA IE */ | ||
491 | elems->wpa = pos; | ||
492 | elems->wpa_len = elen; | ||
493 | } else if (elen >= 5 && pos[3] == 2) { | ||
494 | if (pos[4] == 0) { | ||
495 | elems->wmm_info = pos; | ||
496 | elems->wmm_info_len = elen; | ||
497 | } else if (pos[4] == 1) { | ||
498 | elems->wmm_param = pos; | ||
499 | elems->wmm_param_len = elen; | ||
500 | } | ||
501 | } | ||
502 | } | ||
503 | break; | ||
504 | case WLAN_EID_RSN: | ||
505 | elems->rsn = pos; | ||
506 | elems->rsn_len = elen; | ||
507 | break; | ||
508 | case WLAN_EID_ERP_INFO: | ||
509 | elems->erp_info = pos; | ||
510 | elems->erp_info_len = elen; | ||
511 | break; | ||
512 | case WLAN_EID_EXT_SUPP_RATES: | ||
513 | elems->ext_supp_rates = pos; | ||
514 | elems->ext_supp_rates_len = elen; | ||
515 | break; | ||
516 | case WLAN_EID_HT_CAPABILITY: | ||
517 | elems->ht_cap_elem = pos; | ||
518 | elems->ht_cap_elem_len = elen; | ||
519 | break; | ||
520 | case WLAN_EID_HT_EXTRA_INFO: | ||
521 | elems->ht_info_elem = pos; | ||
522 | elems->ht_info_elem_len = elen; | ||
523 | break; | ||
524 | case WLAN_EID_MESH_ID: | ||
525 | elems->mesh_id = pos; | ||
526 | elems->mesh_id_len = elen; | ||
527 | break; | ||
528 | case WLAN_EID_MESH_CONFIG: | ||
529 | elems->mesh_config = pos; | ||
530 | elems->mesh_config_len = elen; | ||
531 | break; | ||
532 | case WLAN_EID_PEER_LINK: | ||
533 | elems->peer_link = pos; | ||
534 | elems->peer_link_len = elen; | ||
535 | break; | ||
536 | case WLAN_EID_PREQ: | ||
537 | elems->preq = pos; | ||
538 | elems->preq_len = elen; | ||
539 | break; | ||
540 | case WLAN_EID_PREP: | ||
541 | elems->prep = pos; | ||
542 | elems->prep_len = elen; | ||
543 | break; | ||
544 | case WLAN_EID_PERR: | ||
545 | elems->perr = pos; | ||
546 | elems->perr_len = elen; | ||
547 | break; | ||
548 | case WLAN_EID_CHANNEL_SWITCH: | ||
549 | elems->ch_switch_elem = pos; | ||
550 | elems->ch_switch_elem_len = elen; | ||
551 | break; | ||
552 | case WLAN_EID_QUIET: | ||
553 | if (!elems->quiet_elem) { | ||
554 | elems->quiet_elem = pos; | ||
555 | elems->quiet_elem_len = elen; | ||
556 | } | ||
557 | elems->num_of_quiet_elem++; | ||
558 | break; | ||
559 | case WLAN_EID_COUNTRY: | ||
560 | elems->country_elem = pos; | ||
561 | elems->country_elem_len = elen; | ||
562 | break; | ||
563 | case WLAN_EID_PWR_CONSTRAINT: | ||
564 | elems->pwr_constr_elem = pos; | ||
565 | elems->pwr_constr_elem_len = elen; | ||
566 | break; | ||
567 | default: | ||
568 | break; | ||
569 | } | ||
570 | |||
571 | left -= elen; | ||
572 | pos += elen; | ||
573 | } | ||
574 | } | ||