Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
- struct cfg80211_bss *cbss, bool assoc,
- bool override)
- {
- struct ieee80211_local *local = sdata->local;
- struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
- struct ieee80211_bss *bss = (void *)cbss->priv;
- struct sta_info *new_sta = NULL;
- struct ieee80211_supported_band *sband;
- bool have_sta = false;
- int err;
- printk(KERN_ERR "GP ieee80211_prep_connection 1\n");
- sband = local->hw.wiphy->bands[cbss->channel->band];
- if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data))
- return -EINVAL;
- printk(KERN_ERR "GP ieee80211_prep_connection 2\n");
- /* If a reconfig is happening, bail out */
- if (local->in_reconfig) {
- printk(KERN_ERR "GP bail out\n");
- return -EBUSY;
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 3\n");
- if (assoc) {
- rcu_read_lock();
- have_sta = sta_info_get(sdata, cbss->bssid);
- rcu_read_unlock();
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 4\n");
- if (!have_sta) {
- new_sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL);
- if (!new_sta)
- return -ENOMEM;
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 5\n");
- if (new_sta || override) {
- err = ieee80211_prep_channel(sdata, cbss);
- if (err) {
- if (new_sta)
- {
- sta_info_free(local, new_sta);
- }
- return -EINVAL;
- }
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 6\n");
- if (new_sta) {
- u32 rates = 0, basic_rates = 0;
- bool have_higher_than_11mbit;
- int min_rate = INT_MAX, min_rate_index = -1;
- struct ieee80211_chanctx_conf *chanctx_conf;
- const struct cfg80211_bss_ies *ies;
- int shift = ieee80211_vif_get_shift(&sdata->vif);
- u32 rate_flags;
- printk(KERN_ERR "GP ieee80211_prep_connection 7\n");
- rcu_read_lock();
- chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
- if (WARN_ON(!chanctx_conf)) {
- rcu_read_unlock();
- sta_info_free(local, new_sta);
- return -EINVAL;
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 8\n");
- rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def);
- rcu_read_unlock();
- ieee80211_get_rates(sband, bss->supp_rates,
- bss->supp_rates_len,
- &rates, &basic_rates,
- &have_higher_than_11mbit,
- &min_rate, &min_rate_index,
- shift, rate_flags);
- /*
- * This used to be a workaround for basic rates missing
- * in the association response frame. Now that we no
- * longer use the basic rates from there, it probably
- * doesn't happen any more, but keep the workaround so
- * in case some *other* APs are buggy in different ways
- * we can connect -- with a warning.
- */
- if (!basic_rates && min_rate_index >= 0) {
- sdata_info(sdata,
- "No basic rates, using min rate instead\n");
- basic_rates = BIT(min_rate_index);
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 9\n");
- new_sta->sta.supp_rates[cbss->channel->band] = rates;
- sdata->vif.bss_conf.basic_rates = basic_rates;
- /* cf. IEEE 802.11 9.2.12 */
- if (cbss->channel->band == NL80211_BAND_2GHZ &&
- have_higher_than_11mbit)
- sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
- else
- sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
- printk(KERN_ERR "GP ieee80211_prep_connection 10\n");
- memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN);
- /* set timing information */
- sdata->vif.bss_conf.beacon_int = cbss->beacon_interval;
- rcu_read_lock();
- ies = rcu_dereference(cbss->beacon_ies);
- if (ies) {
- const u8 *tim_ie;
- sdata->vif.bss_conf.sync_tsf = ies->tsf;
- sdata->vif.bss_conf.sync_device_ts =
- bss->device_ts_beacon;
- tim_ie = cfg80211_find_ie(WLAN_EID_TIM,
- ies->data, ies->len);
- if (tim_ie && tim_ie[1] >= 2)
- sdata->vif.bss_conf.sync_dtim_count = tim_ie[2];
- else
- sdata->vif.bss_conf.sync_dtim_count = 0;
- printk(KERN_ERR "GP ieee80211_prep_connection 11\n");
- } else if (!ieee80211_hw_check(&sdata->local->hw,
- TIMING_BEACON_ONLY)) {
- ies = rcu_dereference(cbss->proberesp_ies);
- /* must be non-NULL since beacon IEs were NULL */
- sdata->vif.bss_conf.sync_tsf = ies->tsf;
- sdata->vif.bss_conf.sync_device_ts =
- bss->device_ts_presp;
- sdata->vif.bss_conf.sync_dtim_count = 0;
- } else {
- sdata->vif.bss_conf.sync_tsf = 0;
- sdata->vif.bss_conf.sync_device_ts = 0;
- sdata->vif.bss_conf.sync_dtim_count = 0;
- }
- rcu_read_unlock();
- printk(KERN_ERR "GP ieee80211_prep_connection 12\n");
- /* tell driver about BSSID, basic rates and timing */
- ieee80211_bss_info_change_notify(sdata,
- BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES |
- BSS_CHANGED_BEACON_INT);
- if (assoc)
- sta_info_pre_move_state(new_sta, IEEE80211_STA_AUTH);
- printk(KERN_ERR "GP ieee80211_prep_connection 13\n");
- err = sta_info_insert(new_sta);
- new_sta = NULL;
- if (err) {
- sdata_info(sdata,
- "failed to insert STA entry for the AP (error %d)\n",
- err);
- return err;
- }
- printk(KERN_ERR "GP ieee80211_prep_connection 14\n");
- } else
- WARN_ON_ONCE(!ether_addr_equal(ifmgd->bssid, cbss->bssid));
- printk(KERN_ERR "GP ieee80211_prep_connection 15\n");
- /* Cancel scan to ensure that nothing interferes with connection */
- if (local->scanning)
- ieee80211_scan_cancel(local);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement