Return-path: Received: from yx-out-2324.google.com ([74.125.44.30]:63183 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753000AbYGRTFU (ORCPT ); Fri, 18 Jul 2008 15:05:20 -0400 Received: by yx-out-2324.google.com with SMTP id 8so162138yxm.1 for ; Fri, 18 Jul 2008 12:05:18 -0700 (PDT) Message-ID: <69e28c910807181205m6dd0cdcek83f9717bf1ac9dcc@mail.gmail.com> (sfid-20080718_210525_185062_4E518A75) Date: Fri, 18 Jul 2008 21:05:18 +0200 From: "=?ISO-8859-1?Q?Stefanik_G=E1bor?=" To: "Zhu Yi" , "John W. Linville" Subject: [PATCH] iwlwifi: Enable packet injection for iwl4965 Cc: linux-wireless , linux-kernel@vger.kernel.org, ipw3945-devel , "Tomas Winkler" , "Tomas Winkler" , "Johannes Berg" , "Marco Schuster" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_58245_22700195.1216407918154" Sender: linux-wireless-owner@vger.kernel.org List-ID: ------=_Part_58245_22700195.1216407918154 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Handle station IDs of transmitted packets when in monitor mode, and remove the various anti-injection checks from the iwl4965 driver. This makes injection work on IWL4965 and hopefully IWL50xx. Tested on IWL4965 with aircrack-ng, IWL50xx not tested because I don't have access to an IWL50xx card. Note: To inject management frames with this patch, HW crypto support must be disabled using the "swcrypto=3D1" modparam (or "swcrypto50=3D1" for IWL50xx). Otherwise most management frames won't be transmitted. Signed-off-by: G=E1bor Stefanik --- Patch also available as an attachment on this e-mail, as Gmail tends to whitespace-damage patches. diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index 6d1467d..78b1315 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c @@ -968,6 +968,11 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) =09=09iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); =09=09return priv->hw_params.bcast_sta_id; +=09/* If we are in monitor mode, use BCAST. This is required for +=09 * packet injection. */ +=09case IEEE80211_IF_TYPE_MNTR: +=09=09return priv->hw_params.bcast_sta_id; + =09default: =09=09IWL_WARNING("Unknown mode of operation: %d", priv->iw_mode); =09=09return priv->hw_params.bcast_sta_id; diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index 032641d..55149d4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c @@ -783,11 +783,6 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *= skb) =09=09goto drop_unlock; =09} -=09if (!priv->vif) { -=09=09IWL_DEBUG_DROP("Dropping - !priv->vif\n"); -=09=09goto drop_unlock; -=09} - =09if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) =3D=3D =09 IWL_INVALID_RATE) { =09=09IWL_ERROR("ERROR: No TX rate available.\n"); @@ -810,9 +805,11 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *= skb) =09/* drop all data frame if we are not associated */ =09if (ieee80211_is_data(fc) && -=09 (!iwl_is_associated(priv) || -=09 ((priv->iw_mode =3D=3D IEEE80211_IF_TYPE_STA) && !priv->assoc_id) |= | -=09 !priv->assoc_station_added)) { +=09 (priv->iw_mode !=3D IEEE80211_IF_TYPE_MNTR || +=09 !(info->flags & IEEE80211_TX_CTL_INJECTED)) && /* packet injection = */ +=09 (!iwl_is_associated(priv) || +=09 ((priv->iw_mode =3D=3D IEEE80211_IF_TYPE_STA) && !priv->assoc_id) = || +=09 !priv->assoc_station_added)) { =09=09IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n"); =09=09goto drop_unlock; =09} @@ -822,7 +819,10 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *= skb) =09hdr_len =3D ieee80211_get_hdrlen(le16_to_cpu(fc)); =09/* Find (or create) index into station table for destination station */ -=09sta_id =3D iwl_get_sta_id(priv, hdr); +=09if (info->flags & IEEE80211_TX_CTL_INJECTED) +=09=09sta_id =3D priv->hw_params.bcast_sta_id; +=09else +=09=09sta_id =3D iwl_get_sta_id(priv, hdr); =09if (sta_id =3D=3D IWL_INVALID_STATION) { =09=09DECLARE_MAC_BUF(mac); diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 60b7a64..380cc38 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c @@ -2680,12 +2680,6 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) =09IWL_DEBUG_MAC80211("enter\n"); -=09if (priv->iw_mode =3D=3D IEEE80211_IF_TYPE_MNTR) { -=09=09IWL_DEBUG_MAC80211("leave - monitor\n"); -=09=09dev_kfree_skb_any(skb); -=09=09return 0; -=09} - =09IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, =09=09 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); ------=_Part_58245_22700195.1216407918154 Content-Type: application/mbox; name=iwl4965-injection.patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_fit5uscy0 Content-Disposition: attachment; filename=iwl4965-injection.patch ZGlmZiAtLWdpdCBhL2RyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkvaXdsLXN0YS5jIGIvZHJp dmVycy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9pd2wtc3RhLmMKaW5kZXggNmQxNDY3ZC4uNzhiMTMx NSAxMDA2NDQKLS0tIGEvZHJpdmVycy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9pd2wtc3RhLmMKKysr IGIvZHJpdmVycy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9p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