diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-08 11:44:25 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-11 15:53:36 -0400 |
commit | 0a51b27e956bd9580296c48191b78175ed8b5971 (patch) | |
tree | fd48f13e3f8eb75675c1c8d32c7214df2af47814 /net/mac80211/mlme.c | |
parent | ee96d6ef82cc29421569b7cb7f7c7ee90168ec50 (diff) |
mac80211: start moving scan code from mlme
Here's a first patch to move some code from mlme.c to a
new file called scan.c. The end result will hopefully be
a more manageable mlme.c.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 559 |
1 files changed, 16 insertions, 543 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ba502ce132d9..2caea9759b7e 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -46,10 +46,6 @@ | |||
46 | #define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ) | 46 | #define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ) |
47 | #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) | 47 | #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) |
48 | 48 | ||
49 | #define IEEE80211_PROBE_DELAY (HZ / 33) | ||
50 | #define IEEE80211_CHANNEL_TIME (HZ / 33) | ||
51 | #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 5) | ||
52 | #define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ) | ||
53 | #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) | 49 | #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) |
54 | #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ) | 50 | #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ) |
55 | #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ) | 51 | #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ) |
@@ -341,8 +337,8 @@ static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
341 | ieee80211_sta_tx(sdata, skb, encrypt); | 337 | ieee80211_sta_tx(sdata, skb, encrypt); |
342 | } | 338 | } |
343 | 339 | ||
344 | static void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, | 340 | void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, |
345 | u8 *ssid, size_t ssid_len) | 341 | u8 *ssid, size_t ssid_len) |
346 | { | 342 | { |
347 | struct ieee80211_local *local = sdata->local; | 343 | struct ieee80211_local *local = sdata->local; |
348 | struct ieee80211_supported_band *sband; | 344 | struct ieee80211_supported_band *sband; |
@@ -3466,543 +3462,6 @@ int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) | |||
3466 | } | 3462 | } |
3467 | 3463 | ||
3468 | 3464 | ||
3469 | static void ieee80211_send_nullfunc(struct ieee80211_local *local, | ||
3470 | struct ieee80211_sub_if_data *sdata, | ||
3471 | int powersave) | ||
3472 | { | ||
3473 | struct sk_buff *skb; | ||
3474 | struct ieee80211_hdr *nullfunc; | ||
3475 | __le16 fc; | ||
3476 | |||
3477 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); | ||
3478 | if (!skb) { | ||
3479 | printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " | ||
3480 | "frame\n", sdata->dev->name); | ||
3481 | return; | ||
3482 | } | ||
3483 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
3484 | |||
3485 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); | ||
3486 | memset(nullfunc, 0, 24); | ||
3487 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | | ||
3488 | IEEE80211_FCTL_TODS); | ||
3489 | if (powersave) | ||
3490 | fc |= cpu_to_le16(IEEE80211_FCTL_PM); | ||
3491 | nullfunc->frame_control = fc; | ||
3492 | memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN); | ||
3493 | memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); | ||
3494 | memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN); | ||
3495 | |||
3496 | ieee80211_sta_tx(sdata, skb, 0); | ||
3497 | } | ||
3498 | |||
3499 | |||
3500 | static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata) | ||
3501 | { | ||
3502 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA || | ||
3503 | ieee80211_vif_is_mesh(&sdata->vif)) | ||
3504 | ieee80211_sta_timer((unsigned long)sdata); | ||
3505 | } | ||
3506 | |||
3507 | void ieee80211_scan_completed(struct ieee80211_hw *hw) | ||
3508 | { | ||
3509 | struct ieee80211_local *local = hw_to_local(hw); | ||
3510 | struct ieee80211_sub_if_data *sdata; | ||
3511 | union iwreq_data wrqu; | ||
3512 | |||
3513 | local->last_scan_completed = jiffies; | ||
3514 | memset(&wrqu, 0, sizeof(wrqu)); | ||
3515 | wireless_send_event(local->scan_sdata->dev, SIOCGIWSCAN, &wrqu, NULL); | ||
3516 | |||
3517 | if (local->sta_hw_scanning) { | ||
3518 | local->sta_hw_scanning = 0; | ||
3519 | if (ieee80211_hw_config(local)) | ||
3520 | printk(KERN_DEBUG "%s: failed to restore operational " | ||
3521 | "channel after scan\n", wiphy_name(local->hw.wiphy)); | ||
3522 | /* Restart STA timer for HW scan case */ | ||
3523 | rcu_read_lock(); | ||
3524 | list_for_each_entry_rcu(sdata, &local->interfaces, list) | ||
3525 | ieee80211_restart_sta_timer(sdata); | ||
3526 | rcu_read_unlock(); | ||
3527 | |||
3528 | goto done; | ||
3529 | } | ||
3530 | |||
3531 | local->sta_sw_scanning = 0; | ||
3532 | if (ieee80211_hw_config(local)) | ||
3533 | printk(KERN_DEBUG "%s: failed to restore operational " | ||
3534 | "channel after scan\n", wiphy_name(local->hw.wiphy)); | ||
3535 | |||
3536 | |||
3537 | netif_tx_lock_bh(local->mdev); | ||
3538 | netif_addr_lock(local->mdev); | ||
3539 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; | ||
3540 | local->ops->configure_filter(local_to_hw(local), | ||
3541 | FIF_BCN_PRBRESP_PROMISC, | ||
3542 | &local->filter_flags, | ||
3543 | local->mdev->mc_count, | ||
3544 | local->mdev->mc_list); | ||
3545 | |||
3546 | netif_addr_unlock(local->mdev); | ||
3547 | netif_tx_unlock_bh(local->mdev); | ||
3548 | |||
3549 | rcu_read_lock(); | ||
3550 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
3551 | /* Tell AP we're back */ | ||
3552 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA) { | ||
3553 | if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) { | ||
3554 | ieee80211_send_nullfunc(local, sdata, 0); | ||
3555 | netif_tx_wake_all_queues(sdata->dev); | ||
3556 | } | ||
3557 | } else | ||
3558 | netif_tx_wake_all_queues(sdata->dev); | ||
3559 | |||
3560 | ieee80211_restart_sta_timer(sdata); | ||
3561 | } | ||
3562 | rcu_read_unlock(); | ||
3563 | |||
3564 | done: | ||
3565 | sdata = local->scan_sdata; | ||
3566 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { | ||
3567 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
3568 | if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) || | ||
3569 | (!(ifsta->state == IEEE80211_STA_MLME_IBSS_JOINED) && | ||
3570 | !ieee80211_sta_active_ibss(sdata))) | ||
3571 | ieee80211_sta_find_ibss(sdata, ifsta); | ||
3572 | } | ||
3573 | } | ||
3574 | EXPORT_SYMBOL(ieee80211_scan_completed); | ||
3575 | |||
3576 | void ieee80211_sta_scan_work(struct work_struct *work) | ||
3577 | { | ||
3578 | struct ieee80211_local *local = | ||
3579 | container_of(work, struct ieee80211_local, scan_work.work); | ||
3580 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | ||
3581 | struct ieee80211_supported_band *sband; | ||
3582 | struct ieee80211_channel *chan; | ||
3583 | int skip; | ||
3584 | unsigned long next_delay = 0; | ||
3585 | |||
3586 | if (!local->sta_sw_scanning) | ||
3587 | return; | ||
3588 | |||
3589 | switch (local->scan_state) { | ||
3590 | case SCAN_SET_CHANNEL: | ||
3591 | /* | ||
3592 | * Get current scan band. scan_band may be IEEE80211_NUM_BANDS | ||
3593 | * after we successfully scanned the last channel of the last | ||
3594 | * band (and the last band is supported by the hw) | ||
3595 | */ | ||
3596 | if (local->scan_band < IEEE80211_NUM_BANDS) | ||
3597 | sband = local->hw.wiphy->bands[local->scan_band]; | ||
3598 | else | ||
3599 | sband = NULL; | ||
3600 | |||
3601 | /* | ||
3602 | * If we are at an unsupported band and have more bands | ||
3603 | * left to scan, advance to the next supported one. | ||
3604 | */ | ||
3605 | while (!sband && local->scan_band < IEEE80211_NUM_BANDS - 1) { | ||
3606 | local->scan_band++; | ||
3607 | sband = local->hw.wiphy->bands[local->scan_band]; | ||
3608 | local->scan_channel_idx = 0; | ||
3609 | } | ||
3610 | |||
3611 | /* if no more bands/channels left, complete scan */ | ||
3612 | if (!sband || local->scan_channel_idx >= sband->n_channels) { | ||
3613 | ieee80211_scan_completed(local_to_hw(local)); | ||
3614 | return; | ||
3615 | } | ||
3616 | skip = 0; | ||
3617 | chan = &sband->channels[local->scan_channel_idx]; | ||
3618 | |||
3619 | if (chan->flags & IEEE80211_CHAN_DISABLED || | ||
3620 | (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && | ||
3621 | chan->flags & IEEE80211_CHAN_NO_IBSS)) | ||
3622 | skip = 1; | ||
3623 | |||
3624 | if (!skip) { | ||
3625 | local->scan_channel = chan; | ||
3626 | if (ieee80211_hw_config(local)) { | ||
3627 | printk(KERN_DEBUG "%s: failed to set freq to " | ||
3628 | "%d MHz for scan\n", wiphy_name(local->hw.wiphy), | ||
3629 | chan->center_freq); | ||
3630 | skip = 1; | ||
3631 | } | ||
3632 | } | ||
3633 | |||
3634 | /* advance state machine to next channel/band */ | ||
3635 | local->scan_channel_idx++; | ||
3636 | if (local->scan_channel_idx >= sband->n_channels) { | ||
3637 | /* | ||
3638 | * scan_band may end up == IEEE80211_NUM_BANDS, but | ||
3639 | * we'll catch that case above and complete the scan | ||
3640 | * if that is the case. | ||
3641 | */ | ||
3642 | local->scan_band++; | ||
3643 | local->scan_channel_idx = 0; | ||
3644 | } | ||
3645 | |||
3646 | if (skip) | ||
3647 | break; | ||
3648 | |||
3649 | next_delay = IEEE80211_PROBE_DELAY + | ||
3650 | usecs_to_jiffies(local->hw.channel_change_time); | ||
3651 | local->scan_state = SCAN_SEND_PROBE; | ||
3652 | break; | ||
3653 | case SCAN_SEND_PROBE: | ||
3654 | next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; | ||
3655 | local->scan_state = SCAN_SET_CHANNEL; | ||
3656 | |||
3657 | if (local->scan_channel->flags & IEEE80211_CHAN_PASSIVE_SCAN) | ||
3658 | break; | ||
3659 | ieee80211_send_probe_req(sdata, NULL, local->scan_ssid, | ||
3660 | local->scan_ssid_len); | ||
3661 | next_delay = IEEE80211_CHANNEL_TIME; | ||
3662 | break; | ||
3663 | } | ||
3664 | |||
3665 | if (local->sta_sw_scanning) | ||
3666 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | ||
3667 | next_delay); | ||
3668 | } | ||
3669 | |||
3670 | |||
3671 | static int ieee80211_sta_start_scan(struct ieee80211_sub_if_data *scan_sdata, | ||
3672 | u8 *ssid, size_t ssid_len) | ||
3673 | { | ||
3674 | struct ieee80211_local *local = scan_sdata->local; | ||
3675 | struct ieee80211_sub_if_data *sdata; | ||
3676 | |||
3677 | if (ssid_len > IEEE80211_MAX_SSID_LEN) | ||
3678 | return -EINVAL; | ||
3679 | |||
3680 | /* MLME-SCAN.request (page 118) page 144 (11.1.3.1) | ||
3681 | * BSSType: INFRASTRUCTURE, INDEPENDENT, ANY_BSS | ||
3682 | * BSSID: MACAddress | ||
3683 | * SSID | ||
3684 | * ScanType: ACTIVE, PASSIVE | ||
3685 | * ProbeDelay: delay (in microseconds) to be used prior to transmitting | ||
3686 | * a Probe frame during active scanning | ||
3687 | * ChannelList | ||
3688 | * MinChannelTime (>= ProbeDelay), in TU | ||
3689 | * MaxChannelTime: (>= MinChannelTime), in TU | ||
3690 | */ | ||
3691 | |||
3692 | /* MLME-SCAN.confirm | ||
3693 | * BSSDescriptionSet | ||
3694 | * ResultCode: SUCCESS, INVALID_PARAMETERS | ||
3695 | */ | ||
3696 | |||
3697 | if (local->sta_sw_scanning || local->sta_hw_scanning) { | ||
3698 | if (local->scan_sdata == scan_sdata) | ||
3699 | return 0; | ||
3700 | return -EBUSY; | ||
3701 | } | ||
3702 | |||
3703 | if (local->ops->hw_scan) { | ||
3704 | int rc = local->ops->hw_scan(local_to_hw(local), | ||
3705 | ssid, ssid_len); | ||
3706 | if (!rc) { | ||
3707 | local->sta_hw_scanning = 1; | ||
3708 | local->scan_sdata = scan_sdata; | ||
3709 | } | ||
3710 | return rc; | ||
3711 | } | ||
3712 | |||
3713 | local->sta_sw_scanning = 1; | ||
3714 | |||
3715 | rcu_read_lock(); | ||
3716 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
3717 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA) { | ||
3718 | if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) { | ||
3719 | netif_tx_stop_all_queues(sdata->dev); | ||
3720 | ieee80211_send_nullfunc(local, sdata, 1); | ||
3721 | } | ||
3722 | } else | ||
3723 | netif_tx_stop_all_queues(sdata->dev); | ||
3724 | } | ||
3725 | rcu_read_unlock(); | ||
3726 | |||
3727 | if (ssid) { | ||
3728 | local->scan_ssid_len = ssid_len; | ||
3729 | memcpy(local->scan_ssid, ssid, ssid_len); | ||
3730 | } else | ||
3731 | local->scan_ssid_len = 0; | ||
3732 | local->scan_state = SCAN_SET_CHANNEL; | ||
3733 | local->scan_channel_idx = 0; | ||
3734 | local->scan_band = IEEE80211_BAND_2GHZ; | ||
3735 | local->scan_sdata = scan_sdata; | ||
3736 | |||
3737 | netif_addr_lock_bh(local->mdev); | ||
3738 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; | ||
3739 | local->ops->configure_filter(local_to_hw(local), | ||
3740 | FIF_BCN_PRBRESP_PROMISC, | ||
3741 | &local->filter_flags, | ||
3742 | local->mdev->mc_count, | ||
3743 | local->mdev->mc_list); | ||
3744 | netif_addr_unlock_bh(local->mdev); | ||
3745 | |||
3746 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | ||
3747 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | ||
3748 | IEEE80211_CHANNEL_TIME); | ||
3749 | |||
3750 | return 0; | ||
3751 | } | ||
3752 | |||
3753 | |||
3754 | int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t ssid_len) | ||
3755 | { | ||
3756 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
3757 | struct ieee80211_local *local = sdata->local; | ||
3758 | |||
3759 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA) | ||
3760 | return ieee80211_sta_start_scan(sdata, ssid, ssid_len); | ||
3761 | |||
3762 | if (local->sta_sw_scanning || local->sta_hw_scanning) { | ||
3763 | if (local->scan_sdata == sdata) | ||
3764 | return 0; | ||
3765 | return -EBUSY; | ||
3766 | } | ||
3767 | |||
3768 | ifsta->scan_ssid_len = ssid_len; | ||
3769 | if (ssid_len) | ||
3770 | memcpy(ifsta->scan_ssid, ssid, ssid_len); | ||
3771 | set_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request); | ||
3772 | queue_work(local->hw.workqueue, &ifsta->work); | ||
3773 | return 0; | ||
3774 | } | ||
3775 | |||
3776 | |||
3777 | static void ieee80211_sta_add_scan_ies(struct iw_request_info *info, | ||
3778 | struct ieee80211_sta_bss *bss, | ||
3779 | char **current_ev, char *end_buf) | ||
3780 | { | ||
3781 | u8 *pos, *end, *next; | ||
3782 | struct iw_event iwe; | ||
3783 | |||
3784 | if (bss == NULL || bss->ies == NULL) | ||
3785 | return; | ||
3786 | |||
3787 | /* | ||
3788 | * If needed, fragment the IEs buffer (at IE boundaries) into short | ||
3789 | * enough fragments to fit into IW_GENERIC_IE_MAX octet messages. | ||
3790 | */ | ||
3791 | pos = bss->ies; | ||
3792 | end = pos + bss->ies_len; | ||
3793 | |||
3794 | while (end - pos > IW_GENERIC_IE_MAX) { | ||
3795 | next = pos + 2 + pos[1]; | ||
3796 | while (next + 2 + next[1] - pos < IW_GENERIC_IE_MAX) | ||
3797 | next = next + 2 + next[1]; | ||
3798 | |||
3799 | memset(&iwe, 0, sizeof(iwe)); | ||
3800 | iwe.cmd = IWEVGENIE; | ||
3801 | iwe.u.data.length = next - pos; | ||
3802 | *current_ev = iwe_stream_add_point(info, *current_ev, | ||
3803 | end_buf, &iwe, pos); | ||
3804 | |||
3805 | pos = next; | ||
3806 | } | ||
3807 | |||
3808 | if (end > pos) { | ||
3809 | memset(&iwe, 0, sizeof(iwe)); | ||
3810 | iwe.cmd = IWEVGENIE; | ||
3811 | iwe.u.data.length = end - pos; | ||
3812 | *current_ev = iwe_stream_add_point(info, *current_ev, | ||
3813 | end_buf, &iwe, pos); | ||
3814 | } | ||
3815 | } | ||
3816 | |||
3817 | |||
3818 | static char * | ||
3819 | ieee80211_sta_scan_result(struct ieee80211_local *local, | ||
3820 | struct iw_request_info *info, | ||
3821 | struct ieee80211_sta_bss *bss, | ||
3822 | char *current_ev, char *end_buf) | ||
3823 | { | ||
3824 | struct iw_event iwe; | ||
3825 | char *buf; | ||
3826 | |||
3827 | if (time_after(jiffies, | ||
3828 | bss->last_update + IEEE80211_SCAN_RESULT_EXPIRE)) | ||
3829 | return current_ev; | ||
3830 | |||
3831 | memset(&iwe, 0, sizeof(iwe)); | ||
3832 | iwe.cmd = SIOCGIWAP; | ||
3833 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
3834 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); | ||
3835 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, | ||
3836 | IW_EV_ADDR_LEN); | ||
3837 | |||
3838 | memset(&iwe, 0, sizeof(iwe)); | ||
3839 | iwe.cmd = SIOCGIWESSID; | ||
3840 | if (bss_mesh_cfg(bss)) { | ||
3841 | iwe.u.data.length = bss_mesh_id_len(bss); | ||
3842 | iwe.u.data.flags = 1; | ||
3843 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
3844 | &iwe, bss_mesh_id(bss)); | ||
3845 | } else { | ||
3846 | iwe.u.data.length = bss->ssid_len; | ||
3847 | iwe.u.data.flags = 1; | ||
3848 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
3849 | &iwe, bss->ssid); | ||
3850 | } | ||
3851 | |||
3852 | if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) | ||
3853 | || bss_mesh_cfg(bss)) { | ||
3854 | memset(&iwe, 0, sizeof(iwe)); | ||
3855 | iwe.cmd = SIOCGIWMODE; | ||
3856 | if (bss_mesh_cfg(bss)) | ||
3857 | iwe.u.mode = IW_MODE_MESH; | ||
3858 | else if (bss->capability & WLAN_CAPABILITY_ESS) | ||
3859 | iwe.u.mode = IW_MODE_MASTER; | ||
3860 | else | ||
3861 | iwe.u.mode = IW_MODE_ADHOC; | ||
3862 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
3863 | &iwe, IW_EV_UINT_LEN); | ||
3864 | } | ||
3865 | |||
3866 | memset(&iwe, 0, sizeof(iwe)); | ||
3867 | iwe.cmd = SIOCGIWFREQ; | ||
3868 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); | ||
3869 | iwe.u.freq.e = 0; | ||
3870 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, | ||
3871 | IW_EV_FREQ_LEN); | ||
3872 | |||
3873 | memset(&iwe, 0, sizeof(iwe)); | ||
3874 | iwe.cmd = SIOCGIWFREQ; | ||
3875 | iwe.u.freq.m = bss->freq; | ||
3876 | iwe.u.freq.e = 6; | ||
3877 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, | ||
3878 | IW_EV_FREQ_LEN); | ||
3879 | memset(&iwe, 0, sizeof(iwe)); | ||
3880 | iwe.cmd = IWEVQUAL; | ||
3881 | iwe.u.qual.qual = bss->qual; | ||
3882 | iwe.u.qual.level = bss->signal; | ||
3883 | iwe.u.qual.noise = bss->noise; | ||
3884 | iwe.u.qual.updated = local->wstats_flags; | ||
3885 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, | ||
3886 | IW_EV_QUAL_LEN); | ||
3887 | |||
3888 | memset(&iwe, 0, sizeof(iwe)); | ||
3889 | iwe.cmd = SIOCGIWENCODE; | ||
3890 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) | ||
3891 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | ||
3892 | else | ||
3893 | iwe.u.data.flags = IW_ENCODE_DISABLED; | ||
3894 | iwe.u.data.length = 0; | ||
3895 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
3896 | &iwe, ""); | ||
3897 | |||
3898 | ieee80211_sta_add_scan_ies(info, bss, ¤t_ev, end_buf); | ||
3899 | |||
3900 | if (bss->supp_rates_len > 0) { | ||
3901 | /* display all supported rates in readable format */ | ||
3902 | char *p = current_ev + iwe_stream_lcp_len(info); | ||
3903 | int i; | ||
3904 | |||
3905 | memset(&iwe, 0, sizeof(iwe)); | ||
3906 | iwe.cmd = SIOCGIWRATE; | ||
3907 | /* Those two flags are ignored... */ | ||
3908 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; | ||
3909 | |||
3910 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
3911 | iwe.u.bitrate.value = ((bss->supp_rates[i] & | ||
3912 | 0x7f) * 500000); | ||
3913 | p = iwe_stream_add_value(info, current_ev, p, | ||
3914 | end_buf, &iwe, IW_EV_PARAM_LEN); | ||
3915 | } | ||
3916 | current_ev = p; | ||
3917 | } | ||
3918 | |||
3919 | buf = kmalloc(30, GFP_ATOMIC); | ||
3920 | if (buf) { | ||
3921 | memset(&iwe, 0, sizeof(iwe)); | ||
3922 | iwe.cmd = IWEVCUSTOM; | ||
3923 | sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->timestamp)); | ||
3924 | iwe.u.data.length = strlen(buf); | ||
3925 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
3926 | &iwe, buf); | ||
3927 | memset(&iwe, 0, sizeof(iwe)); | ||
3928 | iwe.cmd = IWEVCUSTOM; | ||
3929 | sprintf(buf, " Last beacon: %dms ago", | ||
3930 | jiffies_to_msecs(jiffies - bss->last_update)); | ||
3931 | iwe.u.data.length = strlen(buf); | ||
3932 | current_ev = iwe_stream_add_point(info, current_ev, | ||
3933 | end_buf, &iwe, buf); | ||
3934 | kfree(buf); | ||
3935 | } | ||
3936 | |||
3937 | if (bss_mesh_cfg(bss)) { | ||
3938 | u8 *cfg = bss_mesh_cfg(bss); | ||
3939 | buf = kmalloc(50, GFP_ATOMIC); | ||
3940 | if (buf) { | ||
3941 | memset(&iwe, 0, sizeof(iwe)); | ||
3942 | iwe.cmd = IWEVCUSTOM; | ||
3943 | sprintf(buf, "Mesh network (version %d)", cfg[0]); | ||
3944 | iwe.u.data.length = strlen(buf); | ||
3945 | current_ev = iwe_stream_add_point(info, current_ev, | ||
3946 | end_buf, | ||
3947 | &iwe, buf); | ||
3948 | sprintf(buf, "Path Selection Protocol ID: " | ||
3949 | "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3], | ||
3950 | cfg[4]); | ||
3951 | iwe.u.data.length = strlen(buf); | ||
3952 | current_ev = iwe_stream_add_point(info, current_ev, | ||
3953 | end_buf, | ||
3954 | &iwe, buf); | ||
3955 | sprintf(buf, "Path Selection Metric ID: " | ||
3956 | "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7], | ||
3957 | cfg[8]); | ||
3958 | iwe.u.data.length = strlen(buf); | ||
3959 | current_ev = iwe_stream_add_point(info, current_ev, | ||
3960 | end_buf, | ||
3961 | &iwe, buf); | ||
3962 | sprintf(buf, "Congestion Control Mode ID: " | ||
3963 | "0x%02X%02X%02X%02X", cfg[9], cfg[10], | ||
3964 | cfg[11], cfg[12]); | ||
3965 | iwe.u.data.length = strlen(buf); | ||
3966 | current_ev = iwe_stream_add_point(info, current_ev, | ||
3967 | end_buf, | ||
3968 | &iwe, buf); | ||
3969 | sprintf(buf, "Channel Precedence: " | ||
3970 | "0x%02X%02X%02X%02X", cfg[13], cfg[14], | ||
3971 | cfg[15], cfg[16]); | ||
3972 | iwe.u.data.length = strlen(buf); | ||
3973 | current_ev = iwe_stream_add_point(info, current_ev, | ||
3974 | end_buf, | ||
3975 | &iwe, buf); | ||
3976 | kfree(buf); | ||
3977 | } | ||
3978 | } | ||
3979 | |||
3980 | return current_ev; | ||
3981 | } | ||
3982 | |||
3983 | |||
3984 | int ieee80211_sta_scan_results(struct ieee80211_local *local, | ||
3985 | struct iw_request_info *info, | ||
3986 | char *buf, size_t len) | ||
3987 | { | ||
3988 | char *current_ev = buf; | ||
3989 | char *end_buf = buf + len; | ||
3990 | struct ieee80211_sta_bss *bss; | ||
3991 | |||
3992 | spin_lock_bh(&local->sta_bss_lock); | ||
3993 | list_for_each_entry(bss, &local->sta_bss_list, list) { | ||
3994 | if (buf + len - current_ev <= IW_EV_ADDR_LEN) { | ||
3995 | spin_unlock_bh(&local->sta_bss_lock); | ||
3996 | return -E2BIG; | ||
3997 | } | ||
3998 | current_ev = ieee80211_sta_scan_result(local, info, bss, | ||
3999 | current_ev, end_buf); | ||
4000 | } | ||
4001 | spin_unlock_bh(&local->sta_bss_lock); | ||
4002 | return current_ev - buf; | ||
4003 | } | ||
4004 | |||
4005 | |||
4006 | int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, char *ie, size_t len) | 3465 | int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, char *ie, size_t len) |
4007 | { | 3466 | { |
4008 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 3467 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
@@ -4290,3 +3749,17 @@ void ieee80211_sta_work(struct work_struct *work) | |||
4290 | WLAN_REASON_UNSPECIFIED); | 3749 | WLAN_REASON_UNSPECIFIED); |
4291 | } | 3750 | } |
4292 | } | 3751 | } |
3752 | |||
3753 | void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) | ||
3754 | { | ||
3755 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | ||
3756 | struct ieee80211_if_sta *ifsta; | ||
3757 | |||
3758 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { | ||
3759 | ifsta = &sdata->u.sta; | ||
3760 | if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) || | ||
3761 | (!(ifsta->state == IEEE80211_STA_MLME_IBSS_JOINED) && | ||
3762 | !ieee80211_sta_active_ibss(sdata))) | ||
3763 | ieee80211_sta_find_ibss(sdata, ifsta); | ||
3764 | } | ||
3765 | } | ||