Subject: Re: kern/37249: Prism HOSTAP will not do WEP on mini-PCI card (ISL3874)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Dave J. Barnes <djb_netbsd@charter.net>
List: netbsd-bugs
Date: 12/10/2007 03:35:02
The following reply was made to PR kern/37249; it has been noted by GNATS.

From: "Dave J. Barnes" <djb_netbsd@charter.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/37249: Prism HOSTAP will not do WEP on mini-PCI card (ISL3874)
Date: Sun, 09 Dec 2007 21:05:01 -0600

 Actually HOSTAP + WEP is broken regardless of interface.
 
 From sys/dev/ic/wi.c
 /*
  * In HOSTAP mode, restore IEEE80211_F_DROPUNENC when operating
  * with WEP enabled so that the AP drops unencoded frames at the
  * 802.11 layer.
  *
 
 ... But that causes the IEEE80211 layer to drop all received packets in 
 HOSTAP + WEP mode!  Is that correct?
 
 The WEP bit is stripped earlier so the IEEE80211 layer has no way to 
 know that we are in HOSTAP + WEP mode
 and we just told the 80211 layer to drop unencoded packets.
 
 Here's the patch I've been using to get HOSTAP + WEP packets:
 ===============================
 --- dev/ic/wi.c.orig    2007-11-01 22:38:26.000000000 -0500
 +++ dev/ic/wi.c    2007-11-01 23:40:23.000000000 -0500
 @@ -3064,6 +3070,10 @@
   * In HOSTAP mode, restore IEEE80211_F_DROPUNENC when operating
   * with WEP enabled so that the AP drops unencoded frames at the
   * 802.11 layer.
 + * NO! We tell the hardware to decrypt the packet and clear the WEP
 + * flag above.  We also tell the hardware to EXCLUDE_UNENCRYPTED.
 + * Therefore we must also clear IEEE80211_F_DROPUNENC
 + * for HOSTAP otherwise the ieee80211 layer will drop good packets.
   *
   * In all other modes, clear IEEE80211_F_DROPUNENC when operating
   * with WEP enabled so we don't drop unencoded frames at the 802.11
 @@ -3078,8 +3088,7 @@
      struct ieee80211com *ic = &sc->sc_ic;
  
      if (nstate == IEEE80211_S_RUN &&
 -        (ic->ic_flags & IEEE80211_F_PRIVACY) != 0 &&
 -        ic->ic_opmode != IEEE80211_M_HOSTAP)
 +        (ic->ic_flags & IEEE80211_F_PRIVACY) != 0 )
          ic->ic_flags &= ~IEEE80211_F_DROPUNENC;
      else
          ic->ic_flags |= sc->sc_ic_flags;
 
 ==================================
 
 I have no idea what is the correct way to use the DROPUNENC flag with 
 the 80211 layer.
 
 ++++++++
 
 Also, there is some problem with transmitting packets while in HOSTAP + 
 WEP mode.  It looks like the packets
 are encrypted twice.  The encryption firmware was fixed with versions 
 later than 1.49, so I've been using the
 following patch to get transmitting working (should test for versions 
 newer than 1.49):
 ==================================
 --- dev/ic/wi.c.orig    2007-11-01 22:38:26.000000000 -0500
 +++ dev/ic/wi.c    2007-11-01 23:40:23.000000000 -0500
 @@ -1202,6 +1202,7 @@
  #ifndef    IEEE80211_NO_HOSTAP
          if (ic->ic_opmode == IEEE80211_M_HOSTAP)
              frmhdr.wi_tx_ctl |= htole16(WI_TXCNTL_ALTRTRY);
 +/*
          if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
              (wh->i_fc[1] & IEEE80211_FC1_WEP)) {
              if (ieee80211_crypto_encap(ic, ni, m0) == NULL) {
 @@ -1209,8 +1210,11 @@
                  ifp->if_oerrors++;
                  goto next;
              }
 +
              frmhdr.wi_tx_ctl |= htole16(WI_TXCNTL_NOCRYPT);
 +
          }
 +*/
  #endif /* !IEEE80211_NO_HOSTAP */
  
          rateidx = wi_choose_rate(ic, ni, wh, m0->m_pkthdr.len);
 @@ -2630,9 +2634,11 @@
              /*
               * Encryption firmware has a bug for HostAP mode.
               */
 +
              if (sc->sc_firmware_type == WI_INTERSIL &&
                  ic->ic_opmode == IEEE80211_M_HOSTAP)
 -                val |= HOST_ENCRYPT;
 +                val |= IV_EVERY_FRAME;
 +
  #endif /* !IEEE80211_NO_HOSTAP */
          } else {
              wi_write_val(sc, WI_RID_CNFAUTHMODE,
 =====================================