Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys/dev/ic Pull up revision 1.20, 1.24 (approved by thor...
details: https://anonhg.NetBSD.org/src/rev/c0954424b110
branches: netbsd-1-5
changeset: 488506:c0954424b110
user: onoe <onoe%NetBSD.org@localhost>
date: Fri Jul 14 14:36:59 2000 +0000
description:
Pull up revision 1.20,1.24 (approved by thorpej)
Add WEP support for awi driver.
diffstat:
sys/dev/ic/awi.c | 338 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 254 insertions(+), 84 deletions(-)
diffs (truncated from 742 to 300 lines):
diff -r 37081d7ecc6c -r c0954424b110 sys/dev/ic/awi.c
--- a/sys/dev/ic/awi.c Fri Jul 14 14:36:45 2000 +0000
+++ b/sys/dev/ic/awi.c Fri Jul 14 14:36:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awi.c,v 1.19 2000/06/09 14:36:25 onoe Exp $ */
+/* $NetBSD: awi.c,v 1.19.2.1 2000/07/14 14:36:59 onoe Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -84,9 +84,10 @@
* and to support adhoc mode by Atsushi Onoe <onoe%netbsd.org@localhost>
*/
-#include "opt_awi.h"
#include "opt_inet.h"
#if defined(__FreeBSD__) && __FreeBSD__ >= 4
+#define NBPFILTER 1
+#elif defined(__FreeBSD__) && __FreeBSD__ >= 3
#include "bpf.h"
#define NBPFILTER NBPF
#else
@@ -186,7 +187,7 @@
static void awi_try_sync __P((struct awi_softc *sc));
static void awi_sync_done __P((struct awi_softc *sc));
static void awi_send_deauth __P((struct awi_softc *sc));
-static void awi_send_auth __P((struct awi_softc *sc));
+static void awi_send_auth __P((struct awi_softc *sc, int seq));
static void awi_recv_auth __P((struct awi_softc *sc, struct mbuf *m0));
static void awi_send_asreq __P((struct awi_softc *sc, int reassoc));
static void awi_recv_asresp __P((struct awi_softc *sc, struct mbuf *m0));
@@ -200,9 +201,10 @@
static int awi_intr_lock __P((struct awi_softc *sc));
static void awi_intr_unlock __P((struct awi_softc *sc));
static int awi_cmd_wait __P((struct awi_softc *sc));
+static void awi_print_essid __P((u_int8_t *essid));
#ifdef AWI_DEBUG
-static void awi_dump_pkt __P((struct awi_softc *sc, struct mbuf *m, u_int8_t rssi));
+static void awi_dump_pkt __P((struct awi_softc *sc, struct mbuf *m, int rssi));
int awi_verbose = 0;
int awi_dump = 0;
#define AWI_DUMP_MASK(fc0) (1 << (((fc0) & IEEE80211_FC0_SUBTYPE_MASK) >> 4))
@@ -309,7 +311,6 @@
ETHER_ADDR_LEN);
#endif
- awi_read_bytes(sc, AWI_BANNER, sc->sc_banner, AWI_BANNER_LEN);
printf("%s: IEEE802.11 %s %dMbps (firmware %s)\n",
sc->sc_dev.dv_xname,
sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH ? "FH" : "DS",
@@ -340,8 +341,9 @@
ifmedia_add(&sc->sc_media, mword, 0, NULL);
ifmedia_add(&sc->sc_media,
mword | IFM_IEEE80211_ADHOC, 0, NULL);
- ifmedia_add(&sc->sc_media,
- mword | IFM_IEEE80211_ADHOC | IFM_FLAG0, 0, NULL);
+ if (sc->sc_mib_phy.IEEE_PHY_Type != AWI_PHY_TYPE_FH)
+ ifmedia_add(&sc->sc_media,
+ mword | IFM_IEEE80211_ADHOC | IFM_FLAG0, 0, NULL);
}
awi_media_status(ifp, &imr);
ifmedia_set(&sc->sc_media, imr.ifm_active);
@@ -667,7 +669,10 @@
}
if (ime->ifm_media & IFM_IEEE80211_ADHOC) {
sc->sc_mib_local.Network_Mode = 0;
- sc->sc_no_bssid = (ime->ifm_media & IFM_FLAG0) ? 1 : 0;
+ if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH)
+ sc->sc_no_bssid = 0;
+ else
+ sc->sc_no_bssid = (ime->ifm_media & IFM_FLAG0) ? 1 : 0;
} else {
sc->sc_mib_local.Network_Mode = 1;
}
@@ -805,6 +810,9 @@
sc->sc_mib_local.Accept_All_Multicast_Dis = 1;
set_mib:
+#ifdef notdef /* allow non-encrypted frame for receiving. */
+ sc->sc_mib_mgt.Wep_Required = sc->sc_wep_algo != NULL ? 1 : 0;
+#endif
if (!sc->sc_enabled) {
sc->sc_enabled = 1;
if (sc->sc_enable)
@@ -895,6 +903,7 @@
if (sc->sc_rx_timer && --sc->sc_rx_timer == 0) {
printf("%s: no recent beacons from %s; rescanning\n",
sc->sc_dev.dv_xname, ether_sprintf(sc->sc_bss.bssid));
+ ifp->if_flags &= ~IFF_RUNNING;
awi_start_scan(sc);
}
if (sc->sc_mgt_timer && --sc->sc_mgt_timer == 0) {
@@ -967,6 +976,10 @@
}
ifp->if_opackets++;
}
+#ifdef AWI_DEBUG
+ if (awi_dump)
+ awi_dump_pkt(sc, m0, -1);
+#endif
AWI_BPF_MTAP(sc, m0, AWI_BPF_RAW);
len = 0;
for (m = m0; m != NULL; m = m->m_next) {
@@ -1114,6 +1127,57 @@
/* assuming ethernet encapsulation, just strip 802.11 header */
m_adj(m0, sizeof(wh));
}
+ if (ALIGN(mtod(m0, caddr_t) + sizeof(struct ether_header)) !=
+ (u_int)(mtod(m0, caddr_t) + sizeof(struct ether_header))) {
+ /* XXX: we loose to estimate the type of encapsulation */
+ struct mbuf *n, *n0, **np;
+ caddr_t newdata;
+ int off;
+
+ n0 = NULL;
+ np = &n0;
+ off = 0;
+ while (m0->m_pkthdr.len > off) {
+ if (n0 == NULL) {
+ MGETHDR(n, M_DONTWAIT, MT_DATA);
+ if (n == NULL) {
+ m_freem(m0);
+ return NULL;
+ }
+ M_COPY_PKTHDR(n, m0);
+ n->m_len = MHLEN;
+ } else {
+ MGET(n, M_DONTWAIT, MT_DATA);
+ if (n == NULL) {
+ m_freem(m0);
+ m_freem(n0);
+ return NULL;
+ }
+ n->m_len = MLEN;
+ }
+ if (m0->m_pkthdr.len - off >= MINCLSIZE) {
+ MCLGET(n, M_DONTWAIT);
+ if (n->m_flags & M_EXT)
+ n->m_len = n->m_ext.ext_size;
+ }
+ if (n0 == NULL) {
+ newdata = (caddr_t)
+ ALIGN(n->m_data
+ + sizeof(struct ether_header))
+ - sizeof(struct ether_header);
+ n->m_len -= newdata - n->m_data;
+ n->m_data = newdata;
+ }
+ if (n->m_len > m0->m_pkthdr.len - off)
+ n->m_len = m0->m_pkthdr.len - off;
+ m_copydata(m0, off, n->m_len, mtod(n, caddr_t));
+ off += n->m_len;
+ *np = n;
+ np = &n->m_next;
+ }
+ m_freem(m0);
+ m0 = n0;
+ }
return m0;
}
@@ -1214,7 +1278,7 @@
break;
case IEEE80211_FC0_SUBTYPE_DEAUTH:
if (sc->sc_mib_local.Network_Mode)
- awi_send_auth(sc);
+ awi_send_auth(sc, 1);
break;
case IEEE80211_FC0_SUBTYPE_DISASSOC:
if (sc->sc_mib_local.Network_Mode)
@@ -1291,6 +1355,7 @@
if (top != NULL) {
sc->sc_rxpend = NULL;
top->m_pkthdr.len += len;
+ m = top;
while (*mp != NULL) {
m = *mp;
mp = &m->m_next;
@@ -1330,6 +1395,15 @@
if (m->m_flags & M_EXT)
m->m_len = m->m_ext.ext_size;
}
+ if (top == NULL) {
+ int hdrlen = sizeof(struct ieee80211_frame) +
+ (sc->sc_format_llc ? sizeof(struct llc) :
+ sizeof(struct ether_header));
+ caddr_t newdata = (caddr_t)
+ ALIGN(m->m_data + hdrlen) - hdrlen;
+ m->m_len -= newdata - m->m_data;
+ m->m_data = newdata;
+ }
if (m->m_len > len)
m->m_len = len;
awi_read_bytes(sc, off, mtod(m, u_int8_t *), m->m_len);
@@ -1355,12 +1429,15 @@
int i, error;
sc->sc_enab_intr = 0;
+ sc->sc_invalid = 0; /* XXX: really? */
awi_drvstate(sc, AWI_DRV_RESET);
/* reset firmware */
am79c930_gcr_setbits(&sc->sc_chip, AM79C930_GCR_CORESET);
DELAY(100);
awi_write_1(sc, AWI_SELFTEST, 0);
+ awi_write_1(sc, AWI_CMD, 0);
+ awi_write_1(sc, AWI_BANNER, 0);
am79c930_gcr_clearbits(&sc->sc_chip, AM79C930_GCR_CORESET);
DELAY(100);
@@ -1417,7 +1494,9 @@
error = awi_cmd(sc, AWI_CMD_NOP);
if (error) {
printf("%s: failed to complete selftest", sc->sc_dev.dv_xname);
- if (error != EWOULDBLOCK)
+ if (error == ENXIO)
+ printf(" (no hardware)\n");
+ else if (error != EWOULDBLOCK)
printf(" (error %d)\n", error);
else if (sc->sc_cansleep)
printf(" (lost interrupt)\n");
@@ -1461,6 +1540,7 @@
sc->sc_mib_mac.aDesired_ESS_ID[0] = IEEE80211_ELEMID_SSID;
sc->sc_mib_local.Fragmentation_Dis = 1;
sc->sc_mib_local.Accept_All_Multicast_Dis = 1;
+ sc->sc_mib_local.Power_Saving_Mode_Dis = 1;
/* allocate buffers */
sc->sc_txbase = AWI_BUFFERS;
@@ -1525,13 +1605,18 @@
struct awi_softc *sc;
{
+ if (sc->sc_cmd_inprog)
+ (void)awi_cmd_wait(sc);
(void)awi_cmd(sc, AWI_CMD_KILL_RX);
+ (void)awi_cmd_wait(sc);
+ sc->sc_cmd_inprog = AWI_CMD_FLUSH_TX;
awi_write_1(sc, AWI_CMD_PARAMS+AWI_CA_FTX_DATA, 1);
awi_write_1(sc, AWI_CMD_PARAMS+AWI_CA_FTX_MGT, 0);
awi_write_1(sc, AWI_CMD_PARAMS+AWI_CA_FTX_BCAST, 0);
awi_write_1(sc, AWI_CMD_PARAMS+AWI_CA_FTX_PS, 0);
awi_write_1(sc, AWI_CMD_PARAMS+AWI_CA_FTX_CF, 0);
(void)awi_cmd(sc, AWI_CMD_FLUSH_TX);
+ (void)awi_cmd_wait(sc);
}
int
@@ -1612,14 +1697,12 @@
}
if (!sc->sc_mib_local.Network_Mode && sc->sc_no_bssid) {
memset(&sc->sc_bss, 0, sizeof(sc->sc_bss));
- sc->sc_bss.rxtime = 0;
- memcpy(sc->sc_bss.essid, &sc->sc_mib_mac.aDesired_ESS_ID,
- sizeof(sc->sc_bss.essid));
+ sc->sc_bss.essid[0] = IEEE80211_ELEMID_SSID;
if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) {
sc->sc_bss.chanset = sc->sc_ownch % 3 + 1;
sc->sc_bss.pattern = sc->sc_ownch;
sc->sc_bss.index = 1;
- sc->sc_bss.dwell_time = 19; /*XXX*/
+ sc->sc_bss.dwell_time = 200; /*XXX*/
} else
sc->sc_bss.chanset = sc->sc_ownch;
sc->sc_status = AWI_ST_SETSS;
@@ -1658,7 +1741,7 @@
if (sc->sc_scan_cur > sc->sc_scan_max) {
sc->sc_scan_cur = sc->sc_scan_min;
if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH)
- sc->sc_scan_set = (sc->sc_scan_set + 1) % 3;
+ sc->sc_scan_set = sc->sc_scan_set % 3 + 1;
}
error = awi_cmd_scan(sc);
if (error != EINVAL)
@@ -1673,6 +1756,7 @@
{
struct ifnet *ifp = sc->sc_ifp;
struct awi_bss *bp, *sbp;
+ int fail;
bp = TAILQ_FIRST(&sc->sc_scan);
if (bp == NULL) {
@@ -1689,6 +1773,9 @@
return;
}
sbp = NULL;
+ if (ifp->if_flags & IFF_DEBUG)
+ printf("%s:\tmacaddr ch/pat sig flag wep essid\n",
+ sc->sc_dev.dv_xname);
for (; bp != NULL; bp = TAILQ_NEXT(bp, list)) {
if (bp->fails) {
/*
@@ -1700,10 +1787,7 @@
continue;
bp->fails = 0;
}
- if (sc->sc_mib_mac.aDesired_ESS_ID[1] != 0 &&
- memcmp(&sc->sc_mib_mac.aDesired_ESS_ID, bp->essid,
- sizeof(bp->essid)) != 0)
- continue;
Home |
Main Index |
Thread Index |
Old Index