コード例 #1
0
ファイル: key.c プロジェクト: AppEngine/linux-2.6
static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{
	struct ieee80211_sub_if_data *sdata;
	struct ieee80211_sta *sta;
	int ret;

	assert_key_lock();
	might_sleep();

	if (!key->local->ops->set_key)
		return;

	sta = get_sta_for_key(key);

	sdata = key->sdata;
	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
		sdata = container_of(sdata->bss,
				     struct ieee80211_sub_if_data,
				     u.ap);

	ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);

	if (!ret) {
		spin_lock(&todo_lock);
		key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
		spin_unlock(&todo_lock);
	}

	if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
		printk(KERN_ERR "mac80211-%s: failed to set key "
		       "(%d, %pM) to hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
}
コード例 #2
0
ファイル: key.c プロジェクト: mikuhatsune001/linux2.6.32
static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
{
	struct ieee80211_sub_if_data *sdata;
	struct ieee80211_sta *sta;
	int ret;

	assert_key_lock();
	might_sleep();

	if (!key || !key->local->ops->set_key)
		return;

	spin_lock_bh(&todo_lock);
	if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
		spin_unlock_bh(&todo_lock);
		return;
	}
	spin_unlock_bh(&todo_lock);

	sta = get_sta_for_key(key);
	sdata = key->sdata;

	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
		sdata = container_of(sdata->bss,
				     struct ieee80211_sub_if_data,
				     u.ap);

	ret = drv_set_key(key->local, DISABLE_KEY, &sdata->vif,
			  sta, &key->conf);

	if (ret)
		printk(KERN_ERR "mac80211-%s: failed to remove key "
		       "(%d, %pM) from hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);

	spin_lock_bh(&todo_lock);
	key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
	spin_unlock_bh(&todo_lock);
}
コード例 #3
0
static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
{
    struct ieee80211_sub_if_data *sdata;
    struct ieee80211_sta *sta;
    int ret;

    might_sleep();

    if (!key || !key->local->ops->set_key)
        return;

    assert_key_lock(key->local);

    if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
        return;

    sta = get_sta_for_key(key);
    sdata = key->sdata;

    if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
            (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)))
        increment_tailroom_need_count(sdata);

    if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
        sdata = container_of(sdata->bss,
                             struct ieee80211_sub_if_data,
                             u.ap);

    ret = drv_set_key(key->local, DISABLE_KEY, sdata,
                      sta, &key->conf);

    if (ret)
        wiphy_err(key->local->hw.wiphy,
                  "failed to remove key (%d, %pM) from hardware (%d)\n",
                  key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);

    key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
}
コード例 #4
0
static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{
    struct ieee80211_sub_if_data *sdata;
    struct ieee80211_sta *sta;
    int ret;

    might_sleep();

    if (!key->local->ops->set_key)
        goto out_unsupported;

    assert_key_lock(key->local);

    sta = get_sta_for_key(key);

    /*
     * If this is a per-STA GTK, check if it
     * is supported; if not, return.
     */
    if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) &&
            !(key->local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK))
        goto out_unsupported;

    sdata = key->sdata;
    if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
        /*
         * The driver doesn't know anything about VLAN interfaces.
         * Hence, don't send GTKs for VLAN interfaces to the driver.
         */
        if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE))
            goto out_unsupported;
        sdata = container_of(sdata->bss,
                             struct ieee80211_sub_if_data,
                             u.ap);
    }

    ret = drv_set_key(key->local, SET_KEY, sdata, sta, &key->conf);

    if (!ret) {
        key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;

        if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
                (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)))
            sdata->crypto_tx_tailroom_needed_cnt--;

        return 0;
    }

    if (ret != -ENOSPC && ret != -EOPNOTSUPP)
        wiphy_err(key->local->hw.wiphy,
                  "failed to set key (%d, %pM) to hardware (%d)\n",
                  key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);

out_unsupported:
    switch (key->conf.cipher) {
    case WLAN_CIPHER_SUITE_WEP40:
    case WLAN_CIPHER_SUITE_WEP104:
    case WLAN_CIPHER_SUITE_TKIP:
    case WLAN_CIPHER_SUITE_CCMP:
    case WLAN_CIPHER_SUITE_AES_CMAC:
        /* all of these we can do in software */
        return 0;
    default:
        return -EINVAL;
    }
}