From owner-svn-src-head@FreeBSD.ORG Sun Mar 15 20:54:11 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4479551B; Sun, 15 Mar 2015 20:54:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1668E307; Sun, 15 Mar 2015 20:54:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2FKsAES074546; Sun, 15 Mar 2015 20:54:10 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2FKsAZE074545; Sun, 15 Mar 2015 20:54:10 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201503152054.t2FKsAZE074545@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 15 Mar 2015 20:54:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280087 - head/sys/dev/wpi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 20:54:11 -0000 Author: adrian Date: Sun Mar 15 20:54:10 2015 New Revision: 280087 URL: https://svnweb.freebsd.org/changeset/base/280087 Log: Encrypt frame if IEEE80211_BPF_CRYPTO is set. PR: kern/197143 Submitted by: Andriy Voskoboinyk Modified: head/sys/dev/wpi/if_wpi.c Modified: head/sys/dev/wpi/if_wpi.c ============================================================================== --- head/sys/dev/wpi/if_wpi.c Sun Mar 15 20:53:46 2015 (r280086) +++ head/sys/dev/wpi/if_wpi.c Sun Mar 15 20:54:10 2015 (r280087) @@ -2643,16 +2643,16 @@ wpi_tx_data_raw(struct wpi_softc *sc, st struct ieee80211_node *ni, const struct ieee80211_bpf_params *params) { struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_key *k = NULL; struct ieee80211_frame *wh; struct wpi_buf tx_data; struct wpi_cmd_data *tx = (struct wpi_cmd_data *)&tx_data.data; uint32_t flags; uint8_t type; - int ac, rate, totlen; + int ac, rate, swcrypt, totlen; wh = mtod(m, struct ieee80211_frame *); type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; - totlen = m->m_pkthdr.len; ac = params->ibp_pri & 3; @@ -2669,11 +2669,28 @@ wpi_tx_data_raw(struct wpi_softc *sc, st if (flags & (WPI_TX_NEED_RTS | WPI_TX_NEED_CTS)) flags |= WPI_TX_FULL_TXOP; + /* Encrypt the frame if need be. */ + if (params->ibp_flags & IEEE80211_BPF_CRYPTO) { + /* Retrieve key for TX. */ + k = ieee80211_crypto_encap(ni, m); + if (k == NULL) { + m_freem(m); + return ENOBUFS; + } + swcrypt = k->wk_flags & IEEE80211_KEY_SWCRYPT; + + /* 802.11 header may have moved. */ + wh = mtod(m, struct ieee80211_frame *); + } + totlen = m->m_pkthdr.len; + if (ieee80211_radiotap_active_vap(vap)) { struct wpi_tx_radiotap_header *tap = &sc->sc_txtap; tap->wt_flags = 0; tap->wt_rate = rate; + if (params->ibp_flags & IEEE80211_BPF_CRYPTO) + tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; ieee80211_radiotap_tx(vap, m); } @@ -2692,6 +2709,19 @@ wpi_tx_data_raw(struct wpi_softc *sc, st tx->timeout = htole16(2); } + if (k != NULL && !swcrypt) { + switch (k->wk_cipher->ic_cipher) { + case IEEE80211_CIPHER_AES_CCM: + tx->security = WPI_CIPHER_CCMP; + break; + + default: + break; + } + + memcpy(tx->key, k->wk_key, k->wk_keylen); + } + tx->len = htole16(totlen); tx->flags = htole32(flags); tx->plcp = rate2plcp(rate);