From owner-p4-projects@FreeBSD.ORG Fri Jan 23 15:17:12 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9EEE216A4D0; Fri, 23 Jan 2004 15:17:12 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7777216A4CE for ; Fri, 23 Jan 2004 15:17:12 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3116343D5A for ; Fri, 23 Jan 2004 15:15:16 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i0NNFG0B036564 for ; Fri, 23 Jan 2004 15:15:16 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i0NNFEcp036561 for perforce@freebsd.org; Fri, 23 Jan 2004 15:15:14 -0800 (PST) (envelope-from sam@freebsd.org) Date: Fri, 23 Jan 2004 15:15:14 -0800 (PST) Message-Id: <200401232315.i0NNFEcp036561@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 45817 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jan 2004 23:17:13 -0000 http://perforce.freebsd.org/chv.cgi?CH=45817 Change 45817 by sam@sam_ebb on 2004/01/23 15:15:05 IFC Affected files ... .. //depot/projects/netperf+sockets/sys/dev/ath/if_ath.c#17 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211.c#6 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211.h#6 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_compat.c#2 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_compat.h#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_crypto.c#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_crypto.h#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_input.c#5 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_ioctl.c#9 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_ioctl.h#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_node.c#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_node.h#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_output.c#6 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_proto.c#4 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_proto.h#3 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_radiotap.h#4 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_var.h#6 edit .. //depot/projects/netperf/sys/alpha/alpha/support.s#3 integrate .. //depot/projects/netperf/sys/amd64/amd64/cpu_switch.S#4 integrate .. //depot/projects/netperf/sys/boot/i386/libi386/biosdisk.c#3 integrate .. //depot/projects/netperf/sys/compat/ndis/kern_ndis.c#12 integrate .. //depot/projects/netperf/sys/compat/ndis/ndis_var.h#11 integrate .. //depot/projects/netperf/sys/compat/ndis/ntoskrnl_var.h#5 integrate .. //depot/projects/netperf/sys/compat/ndis/subr_ndis.c#13 integrate .. //depot/projects/netperf/sys/compat/ndis/subr_ntoskrnl.c#10 integrate .. //depot/projects/netperf/sys/compat/svr4/svr4_misc.c#5 integrate .. //depot/projects/netperf/sys/conf/files.i386#11 integrate .. //depot/projects/netperf/sys/conf/files.pc98#9 integrate .. //depot/projects/netperf/sys/conf/files.powerpc#3 integrate .. //depot/projects/netperf/sys/conf/kern.post.mk#9 integrate .. //depot/projects/netperf/sys/conf/kern.pre.mk#8 integrate .. //depot/projects/netperf/sys/conf/options.i386#11 integrate .. //depot/projects/netperf/sys/conf/options.powerpc#2 integrate .. //depot/projects/netperf/sys/dev/acpica/acpi_pci_link.c#8 integrate .. //depot/projects/netperf/sys/dev/amd/amd.c#5 integrate .. //depot/projects/netperf/sys/dev/ata/ata-all.c#13 integrate .. //depot/projects/netperf/sys/dev/ata/ata-all.h#8 integrate .. //depot/projects/netperf/sys/dev/ata/ata-chipset.c#18 integrate .. //depot/projects/netperf/sys/dev/ata/ata-disk.c#9 integrate .. //depot/projects/netperf/sys/dev/ata/ata-pci.h#10 integrate .. //depot/projects/netperf/sys/dev/ata/ata-queue.c#10 integrate .. //depot/projects/netperf/sys/dev/ata/atapi-cd.c#18 integrate .. //depot/projects/netperf/sys/dev/fb/fbreg.h#4 integrate .. //depot/projects/netperf/sys/dev/firewire/fwdev.c#6 integrate .. //depot/projects/netperf/sys/dev/firewire/fwohci.c#11 integrate .. //depot/projects/netperf/sys/dev/firewire/fwohci_pci.c#8 integrate .. //depot/projects/netperf/sys/dev/firewire/sbp_targ.c#5 integrate .. //depot/projects/netperf/sys/dev/if_ndis/if_ndis.c#12 integrate .. //depot/projects/netperf/sys/dev/if_ndis/if_ndisvar.h#6 integrate .. //depot/projects/netperf/sys/dev/lnc/if_lnc_pci.c#5 integrate .. //depot/projects/netperf/sys/dev/pccard/pccarddevs#11 integrate .. //depot/projects/netperf/sys/dev/pccard/pccarddevs.h#11 integrate .. //depot/projects/netperf/sys/dev/sound/pcm/ac97.c#8 integrate .. //depot/projects/netperf/sys/dev/sound/pcm/dsp.c#6 integrate .. //depot/projects/netperf/sys/dev/sound/pcm/dsp.h#3 integrate .. //depot/projects/netperf/sys/dev/sound/pcm/sound.c#6 integrate .. //depot/projects/netperf/sys/dev/sound/pcm/sound.h#5 integrate .. //depot/projects/netperf/sys/dev/sound/pcm/vchan.c#4 integrate .. //depot/projects/netperf/sys/dev/syscons/scgfbrndr.c#4 integrate .. //depot/projects/netperf/sys/dev/syscons/schistory.c#3 integrate .. //depot/projects/netperf/sys/dev/syscons/scterm-dumb.c#3 integrate .. //depot/projects/netperf/sys/dev/syscons/scterm-sc.c#3 integrate .. //depot/projects/netperf/sys/dev/syscons/syscons.c#6 integrate .. //depot/projects/netperf/sys/dev/usb/umass.c#9 integrate .. //depot/projects/netperf/sys/dev/usb/usbdevs#15 integrate .. //depot/projects/netperf/sys/dev/usb/usbdevs.h#15 integrate .. //depot/projects/netperf/sys/dev/usb/usbdevs_data.h#15 integrate .. //depot/projects/netperf/sys/fs/devfs/devfs_rule.c#2 integrate .. //depot/projects/netperf/sys/geom/bde/g_bde_crypt.c#3 integrate .. //depot/projects/netperf/sys/geom/geom_dev.c#8 integrate .. //depot/projects/netperf/sys/geom/geom_disk.c#7 integrate .. //depot/projects/netperf/sys/geom/geom_event.c#6 integrate .. //depot/projects/netperf/sys/geom/geom_subr.c#6 integrate .. //depot/projects/netperf/sys/gnu/ext2fs/ext2_readwrite.c#2 integrate .. //depot/projects/netperf/sys/i386/conf/NOTES#15 integrate .. //depot/projects/netperf/sys/i386/i386/p4tcc.c#1 branch .. //depot/projects/netperf/sys/i386/i386/swtch.s#3 integrate .. //depot/projects/netperf/sys/i386/include/specialreg.h#3 integrate .. //depot/projects/netperf/sys/ia64/ia64/interrupt.c#7 integrate .. //depot/projects/netperf/sys/ia64/ia64/trap.c#11 integrate .. //depot/projects/netperf/sys/isofs/cd9660/cd9660_vnops.c#4 integrate .. //depot/projects/netperf/sys/kern/kern_exit.c#3 integrate .. //depot/projects/netperf/sys/kern/kern_fork.c#9 integrate .. //depot/projects/netperf/sys/kern/kern_jail.c#2 integrate .. //depot/projects/netperf/sys/kern/kern_ktrace.c#5 integrate .. //depot/projects/netperf/sys/kern/kern_prot.c#6 integrate .. //depot/projects/netperf/sys/kern/kern_shutdown.c#3 integrate .. //depot/projects/netperf/sys/kern/kern_tc.c#6 integrate .. //depot/projects/netperf/sys/kern/kern_thread.c#12 integrate .. //depot/projects/netperf/sys/kern/kern_uuid.c#2 integrate .. //depot/projects/netperf/sys/kern/sys_generic.c#5 integrate .. //depot/projects/netperf/sys/kern/uipc_sem.c#2 integrate .. //depot/projects/netperf/sys/kern/uipc_syscalls.c#13 integrate .. //depot/projects/netperf/sys/modules/firewire/Makefile#3 integrate .. //depot/projects/netperf/sys/modules/if_ef/Makefile#2 integrate .. //depot/projects/netperf/sys/modules/ncp/Makefile#2 integrate .. //depot/projects/netperf/sys/modules/netgraph/Makefile#2 integrate .. //depot/projects/netperf/sys/modules/nwfs/Makefile#3 integrate .. //depot/projects/netperf/sys/modules/smbfs/Makefile#3 integrate .. //depot/projects/netperf/sys/modules/syscons/Makefile#2 integrate .. //depot/projects/netperf/sys/net/if.c#13 integrate .. //depot/projects/netperf/sys/net/if_media.h#5 integrate .. //depot/projects/netperf/sys/net/if_ppp.c#9 integrate .. //depot/projects/netperf/sys/net/if_spppsubr.c#4 integrate .. //depot/projects/netperf/sys/net/if_vlan_var.h#3 integrate .. //depot/projects/netperf/sys/net80211/ieee80211_ioctl.c#13 integrate .. //depot/projects/netperf/sys/netgraph/ng_cisco.c#2 integrate .. //depot/projects/netperf/sys/netgraph/ng_socket.c#3 integrate .. //depot/projects/netperf/sys/netinet/tcp_input.c#18 integrate .. //depot/projects/netperf/sys/netinet/tcp_output.c#10 integrate .. //depot/projects/netperf/sys/netinet/tcp_syncache.c#14 integrate .. //depot/projects/netperf/sys/netipsec/ipsec.h#8 integrate .. //depot/projects/netperf/sys/netipsec/ipsec_output.c#8 integrate .. //depot/projects/netperf/sys/netipsec/xform_ipip.c#4 integrate .. //depot/projects/netperf/sys/pc98/conf/NOTES#12 integrate .. //depot/projects/netperf/sys/pc98/pc98/sio.c#8 integrate .. //depot/projects/netperf/sys/pci/if_rl.c#18 integrate .. //depot/projects/netperf/sys/pci/if_sk.c#12 integrate .. //depot/projects/netperf/sys/powerpc/conf/GENERIC#2 integrate .. //depot/projects/netperf/sys/powerpc/include/float.h#2 integrate .. //depot/projects/netperf/sys/powerpc/include/sc_machdep.h#1 branch .. //depot/projects/netperf/sys/powerpc/ofw/ofw_syscons.c#1 branch .. //depot/projects/netperf/sys/powerpc/ofw/ofw_syscons.h#1 branch .. //depot/projects/netperf/sys/powerpc/powerpc/clock.c#3 integrate .. //depot/projects/netperf/sys/powerpc/powerpc/machdep.c#7 integrate .. //depot/projects/netperf/sys/powerpc/powerpc/sc_machdep.c#1 branch .. //depot/projects/netperf/sys/powerpc/powerpc/trap_subr.S#2 integrate .. //depot/projects/netperf/sys/security/mac_portacl/mac_portacl.c#2 integrate .. //depot/projects/netperf/sys/sys/_task.h#1 branch .. //depot/projects/netperf/sys/sys/jail.h#2 integrate .. //depot/projects/netperf/sys/sys/proc.h#17 integrate .. //depot/projects/netperf/sys/sys/systm.h#6 integrate .. //depot/projects/netperf/sys/sys/taskqueue.h#5 integrate .. //depot/projects/netperf/sys/sys/user.h#2 integrate .. //depot/projects/netperf/sys/ufs/ffs/ffs_vnops.c#5 integrate Differences ... ==== //depot/projects/netperf+sockets/sys/dev/ath/if_ath.c#17 (text+ko) ==== @@ -338,7 +338,9 @@ | IEEE80211_C_HOSTAP /* hostap mode */ | IEEE80211_C_MONITOR /* monitor mode */ | IEEE80211_C_SHPREAMBLE /* short preamble supported */ - | IEEE80211_C_RCVMGT; /* recv management frames */ + | IEEE80211_C_RCVMGT /* recv management frames */ + ; + ic->ic_flags |= IEEE80211_F_DATAPAD; /* get mac address from hardware */ ath_hal_getmac(ah, ic->ic_myaddr); @@ -389,13 +391,12 @@ ath_stop(ifp); bpfdetach(ifp); + ATH_TXBUF_LOCK_DESTROY(sc); + ATH_TXQ_LOCK_DESTROY(sc); ath_desc_free(sc); ath_hal_detach(sc->sc_ah); ieee80211_ifdetach(ifp); - ATH_TXBUF_LOCK_DESTROY(sc); - ATH_TXQ_LOCK_DESTROY(sc); - return 0; } @@ -598,8 +599,7 @@ * in the frame output path; there's nothing to do * here except setup the interrupt mask. */ - if (ic->ic_flags & IEEE80211_F_WEPON) - ath_initkeytable(sc); + ath_initkeytable(sc); if (ath_startrecv(sc) != 0) { if_printf(ifp, "unable to start recv logic\n"); goto done; @@ -1086,17 +1086,13 @@ ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; struct ath_hal *ah = sc->sc_ah; - struct ieee80211_frame *wh; + struct ath_node *an = ATH_NODE(ni); struct ath_buf *bf; struct ath_desc *ds; struct mbuf *m; - int error, pktlen; - u_int8_t *frm, rate; - u_int16_t capinfo; - struct ieee80211_rateset *rs; - const HAL_RATE_TABLE *rt; + int error; + u_int8_t rate; bf = sc->sc_bcbuf; if (bf->bf_m != NULL) { @@ -1110,88 +1106,13 @@ * we assume the mbuf routines will return us something * with this alignment (perhaps should assert). */ - rs = &ni->ni_rates; - pktlen = sizeof (struct ieee80211_frame) - + 8 + 2 + 2 + 2+ni->ni_esslen + 2+rs->rs_nrates + 3 + 6; - if (rs->rs_nrates > IEEE80211_RATE_SIZE) - pktlen += 2; - if (pktlen <= MHLEN) - MGETHDR(m, M_DONTWAIT, MT_DATA); - else - m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + m = ieee80211_beacon_alloc(ic, ni); if (m == NULL) { - DPRINTF(ATH_DEBUG_BEACON, - ("%s: cannot get mbuf/cluster; size %u\n", - __func__, pktlen)); + DPRINTF(ATH_DEBUG_BEACON, ("%s: cannot get mbuf/cluster\n", + __func__)); sc->sc_stats.ast_be_nombuf++; return ENOMEM; } - - wh = mtod(m, struct ieee80211_frame *); - wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | - IEEE80211_FC0_SUBTYPE_BEACON; - wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; - *(u_int16_t *)wh->i_dur = 0; - memcpy(wh->i_addr1, ifp->if_broadcastaddr, IEEE80211_ADDR_LEN); - memcpy(wh->i_addr2, ic->ic_myaddr, IEEE80211_ADDR_LEN); - memcpy(wh->i_addr3, ni->ni_bssid, IEEE80211_ADDR_LEN); - *(u_int16_t *)wh->i_seq = 0; - - /* - * beacon frame format - * [8] time stamp - * [2] beacon interval - * [2] cabability information - * [tlv] ssid - * [tlv] supported rates - * [tlv] parameter set (IBSS) - * [tlv] extended supported rates - */ - frm = (u_int8_t *)&wh[1]; - memset(frm, 0, 8); /* timestamp is set by hardware */ - frm += 8; - *(u_int16_t *)frm = htole16(ni->ni_intval); - frm += 2; - if (ic->ic_opmode == IEEE80211_M_IBSS) - capinfo = IEEE80211_CAPINFO_IBSS; - else - capinfo = IEEE80211_CAPINFO_ESS; - if (ic->ic_flags & IEEE80211_F_WEPON) - capinfo |= IEEE80211_CAPINFO_PRIVACY; - if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && - IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) - capinfo |= IEEE80211_CAPINFO_SHORT_PREAMBLE; - if (ic->ic_flags & IEEE80211_F_SHSLOT) - capinfo |= IEEE80211_CAPINFO_SHORT_SLOTTIME; - *(u_int16_t *)frm = htole16(capinfo); - frm += 2; - *frm++ = IEEE80211_ELEMID_SSID; - *frm++ = ni->ni_esslen; - memcpy(frm, ni->ni_essid, ni->ni_esslen); - frm += ni->ni_esslen; - frm = ieee80211_add_rates(frm, rs); - *frm++ = IEEE80211_ELEMID_DSPARMS; - *frm++ = 1; - *frm++ = ieee80211_chan2ieee(ic, ni->ni_chan); - if (ic->ic_opmode == IEEE80211_M_IBSS) { - *frm++ = IEEE80211_ELEMID_IBSSPARMS; - *frm++ = 2; - *frm++ = 0; *frm++ = 0; /* TODO: ATIM window */ - } else { - /* TODO: TIM */ - *frm++ = IEEE80211_ELEMID_TIM; - *frm++ = 4; /* length */ - *frm++ = 0; /* DTIM count */ - *frm++ = 1; /* DTIM period */ - *frm++ = 0; /* bitmap control */ - *frm++ = 0; /* Partial Virtual Bitmap (variable length) */ - } - frm = ieee80211_add_xrates(frm, rs); - m->m_pkthdr.len = m->m_len = frm - mtod(m, u_int8_t *); - KASSERT(m->m_pkthdr.len <= pktlen, - ("beacon bigger than expected, len %u calculated %u", - m->m_pkthdr.len, pktlen)); - DPRINTF(ATH_DEBUG_BEACON, ("%s: m %p len %u\n", __func__, m, m->m_len)); error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m, ath_mbuf_load_cb, bf, @@ -1213,12 +1134,10 @@ * Calculate rate code. * XXX everything at min xmit rate */ - rt = sc->sc_currates; - KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) - rate = rt->info[0].rateCode | rt->info[0].shortPreamble; + rate = an->an_tx_mgtratesp; else - rate = rt->info[0].rateCode; + rate = an->an_tx_mgtrate; ath_hal_setuptxdesc(ah, ds , m->m_pkthdr.len + IEEE80211_CRC_LEN /* packet length */ , sizeof(struct ieee80211_frame) /* header length */ @@ -1999,9 +1918,9 @@ rix = 0; /* XXX lowest rate */ try0 = ATH_TXMAXTRY; if (shortPreamble) + txrate = an->an_tx_mgtratesp; + else txrate = an->an_tx_mgtrate; - else - txrate = an->an_tx_mgtratesp; break; case IEEE80211_FC0_TYPE_CTL: subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; @@ -2010,9 +1929,9 @@ rix = 0; /* XXX lowest rate */ try0 = ATH_TXMAXTRY; if (shortPreamble) + txrate = an->an_tx_mgtratesp; + else txrate = an->an_tx_mgtrate; - else - txrate = an->an_tx_mgtratesp; break; default: rix = an->an_tx_rix0; @@ -2025,9 +1944,9 @@ return EIO; } if (shortPreamble) + txrate = an->an_tx_rate0sp; + else txrate = an->an_tx_rate0; - else - txrate = an->an_tx_rate0sp; break; } @@ -2670,7 +2589,8 @@ } static int -ath_getchannels(struct ath_softc *sc, u_int cc, HAL_BOOL outdoor, HAL_BOOL xchans) +ath_getchannels(struct ath_softc *sc, u_int cc, + HAL_BOOL outdoor, HAL_BOOL xchanmode) { struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; @@ -2685,7 +2605,7 @@ return ENOMEM; } if (!ath_hal_init_channels(ah, chans, IEEE80211_CHAN_MAX, &nchan, - cc, HAL_MODE_ALL, outdoor, xchans)) { + cc, HAL_MODE_ALL, outdoor, xchanmode)) { if_printf(ifp, "unable to collect channel list from hal\n"); free(chans, M_TEMP); return EINVAL; @@ -2866,23 +2786,26 @@ ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni) { #define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL) - int srate; + struct ieee80211com *ic = &sc->sc_ic; - KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); - /* start with highest negotiated rate */ - srate = ni->ni_rates.rs_nrates - 1; - if (sc->sc_curmode != IEEE80211_MODE_11B) { - /* - * 11a and 11g work better if you start at 24Mb - * or 36Mb and raise the rate. Scan the negotiated - * rate set to find the closest rate. - */ - /* NB: rate set assumed sorted */ - for (; srate >= 0 && RATE(srate) > 72; srate--) - ; - KASSERT(srate >= 0, ("bogus rate set")); - } - ath_rate_update(sc, ni, srate); + if (ic->ic_fixed_rate == -1) { + KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); + /* start with highest negotiated rate */ + int srate = ni->ni_rates.rs_nrates - 1; + if (sc->sc_curmode != IEEE80211_MODE_11B) { + /* + * 11a and 11g work better if you start at 24Mb + * or 36Mb and raise the rate. Scan the negotiated + * rate set to find the closest rate. + */ + /* NB: rate set assumed sorted */ + for (; srate >= 0 && RATE(srate) > 72; srate--) + ; + KASSERT(srate >= 0, ("bogus rate set")); + } + ath_rate_update(sc, ni, srate); + } else + ath_rate_update(sc, ni, ic->ic_fixed_rate); #undef RATE } ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211.c#6 (text+ko) ==== @@ -1,6 +1,6 @@ /*- * Copyright (c) 2001 Atsushi Onoe - * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -90,9 +90,9 @@ }; void -ieee80211_ifattach(struct ifnet *ifp) +ieee80211_ifattach(struct ieee80211com *ic) { - struct ieee80211com *ic = (void *)ifp; + struct ifnet *ifp = ic->ic_ifp; struct ieee80211_channel *c; int i; @@ -101,7 +101,7 @@ bpfattach2(ifp, DLT_IEEE802_11, sizeof(struct ieee80211_frame_addr4), &ic->ic_rawbpf); #endif - ieee80211_crypto_attach(ifp); + ieee80211_crypto_attach(ic); /* * Fill in 802.11 available channel set, mark @@ -150,18 +150,18 @@ ic->ic_lintval = 100; /* default sleep */ ic->ic_bmisstimeout = 7*ic->ic_lintval; /* default 7 beacons */ - ieee80211_node_attach(ifp); - ieee80211_proto_attach(ifp); + ieee80211_node_attach(ic); + ieee80211_proto_attach(ic); } void -ieee80211_ifdetach(struct ifnet *ifp) +ieee80211_ifdetach(struct ieee80211com *ic) { - struct ieee80211com *ic = (void *)ifp; + struct ifnet *ifp = ic->ic_ifp; - ieee80211_proto_detach(ifp); - ieee80211_crypto_detach(ifp); - ieee80211_node_detach(ifp); + ieee80211_proto_detach(ic); + ieee80211_crypto_detach(ic); + ieee80211_node_detach(ic); ifmedia_removeall(&ic->ic_media); #if NBPFILTER > 0 bpfdetach(ifp); @@ -247,13 +247,13 @@ * ieee80211_attach and before most anything else. */ void -ieee80211_media_init(struct ifnet *ifp, +ieee80211_media_init(struct ieee80211com *ic, ifm_change_cb_t media_change, ifm_stat_cb_t media_stat) { #define ADD(_ic, _s, _o) \ ifmedia_add(&(_ic)->ic_media, \ IFM_MAKEWORD(IFM_IEEE80211, (_s), (_o), 0), 0, NULL) - struct ieee80211com *ic = (void *)ifp; + struct ifnet *ifp = ic->ic_ifp; struct ifmediareq imr; int i, j, mode, rate, maxrate, mword, mopt, r; struct ieee80211_rateset *rs; @@ -263,7 +263,7 @@ * Do late attach work that must wait for any subclass * (i.e. driver) work such as overriding methods. */ - ieee80211_node_lateattach(ifp); + ieee80211_node_lateattach(ic); /* * Fill in media characteristics. @@ -655,8 +655,9 @@ /* validate new mode */ if ((ic->ic_modecaps & (1<ic_modecaps)); + IEEE80211_DPRINTF(ic, NETIF_MSG_ANY, + "%s: mode %u not supported (caps 0x%x)\n", + __func__, mode, ic->ic_modecaps); return EINVAL; } @@ -664,7 +665,7 @@ * Verify at least one channel is present in the available * channel list before committing to the new mode. */ - KASSERT(mode < N(chanflags), ("Unexpected mode %u\n", mode)); + KASSERT(mode < N(chanflags), ("Unexpected mode %u", mode)); modeflags = chanflags[mode]; for (i = 0; i <= IEEE80211_CHAN_MAX; i++) { c = &ic->ic_channels[i]; @@ -678,8 +679,8 @@ } } if (i > IEEE80211_CHAN_MAX) { - IEEE80211_DPRINTF(("%s: no channels found for mode %u\n", - __func__, mode)); + IEEE80211_DPRINTF(ic, NETIF_MSG_ANY, + "%s: no channels found for mode %u\n", __func__, mode); return EINVAL; } @@ -883,34 +884,3 @@ ieeerates[IFM_SUBTYPE(mword)] : 0; #undef N } - -#ifdef __FreeBSD__ -/* - * Module glue. - * - * NB: the module name is "wlan" for compatibility with NetBSD. - */ - -static int -ieee80211_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("wlan: <802.11 Link Layer>\n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t ieee80211_mod = { - "wlan", - ieee80211_modevent, - 0 -}; -DECLARE_MODULE(wlan, ieee80211_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(wlan, 1); -MODULE_DEPEND(wlan, rc4, 1, 1, 1); -#endif /* __FreeBSD__ */ ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211.h#6 (text+ko) ==== @@ -1,7 +1,7 @@ /* $NetBSD: ieee80211.h,v 1.4 2003/10/15 11:43:51 dyoung Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe - * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,6 +69,22 @@ /* see below */ } __attribute__((__packed__)); +struct ieee80211_qosframe { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + u_int8_t i_qos[2]; + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ + /* see below */ +} __attribute__((__packed__)); + +struct ieee80211_qoscntl { + u_int8_t i_qos[2]; +}; + struct ieee80211_frame_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; @@ -79,6 +95,59 @@ u_int8_t i_addr4[IEEE80211_ADDR_LEN]; } __attribute__((__packed__)); + +struct ieee80211_qosframe_addr4 { + u_int8_t i_fc[2]; + u_int8_t i_dur[2]; + u_int8_t i_addr1[IEEE80211_ADDR_LEN]; + u_int8_t i_addr2[IEEE80211_ADDR_LEN]; + u_int8_t i_addr3[IEEE80211_ADDR_LEN]; + u_int8_t i_seq[2]; + u_int8_t i_addr4[IEEE80211_ADDR_LEN]; + u_int8_t i_qos[2]; +} __attribute__((__packed__)); + +/* + * Management Notification Frame + */ +struct ieee80211_mnf { + u_int8_t mnf_category; + u_int8_t mnf_action; + u_int8_t mnf_dialog; + u_int8_t mnf_status; +} __attribute__((__packed__)); +#define MNF_SETUP_REQ 0 +#define MNF_SETUP_RESP 1 +#define MNF_TEARDOWN 2 + +/* + * WME/802.11e Tspec Element + */ +struct ieee80211_wme_tspec { + u_int8_t ts_id; + u_int8_t ts_len; + u_int8_t ts_oui[3]; + u_int8_t ts_oui_type; + u_int8_t ts_oui_subtype; + u_int8_t ts_version; + u_int8_t ts_tsinfo[3]; + u_int8_t ts_nom_msdu[2]; + u_int8_t ts_max_msdu[2]; + u_int8_t ts_min_svc[4]; + u_int8_t ts_max_svc[4]; + u_int8_t ts_inactv_intv[4]; + u_int8_t ts_susp_intv[4]; + u_int8_t ts_start_svc[4]; + u_int8_t ts_min_rate[4]; + u_int8_t ts_mean_rate[4]; + u_int8_t ts_max_burst[4]; + u_int8_t ts_min_phy[4]; + u_int8_t ts_peak_rate[4]; + u_int8_t ts_delay[4]; + u_int8_t ts_surplus[2]; + u_int8_t ts_medium_time[2]; +} __attribute__((__packed__)); + #define IEEE80211_FC0_VERSION_MASK 0x03 #define IEEE80211_FC0_VERSION_SHIFT 0 #define IEEE80211_FC0_VERSION_0 0x00 @@ -207,7 +276,7 @@ * octet information[length] */ -typedef uint8_t *ieee80211_mgt_beacon_t; +typedef u_int8_t *ieee80211_mgt_beacon_t; #define IEEE80211_BEACON_INTERVAL(beacon) \ ((beacon)[8] | ((beacon)[9] << 8)) ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_compat.c#2 (text+ko) ==== ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_compat.h#3 (text+ko) ==== ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_crypto.c#3 (text+ko) ==== @@ -1,6 +1,6 @@ /*- * Copyright (c) 2001 Atsushi Onoe - * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -76,9 +76,8 @@ static u_int32_t ieee80211_crc_update(u_int32_t crc, u_int8_t *buf, int len); void -ieee80211_crypto_attach(struct ifnet *ifp) +ieee80211_crypto_attach(struct ieee80211com *ic) { - struct ieee80211com *ic = (void *)ifp; /* * Setup crypto support. @@ -88,9 +87,8 @@ } void -ieee80211_crypto_detach(struct ifnet *ifp) +ieee80211_crypto_detach(struct ieee80211com *ic) { - struct ieee80211com *ic = (void *)ifp; if (ic->ic_wep_ctx != NULL) { FREE(ic->ic_wep_ctx, M_DEVBUF); @@ -99,9 +97,8 @@ } struct mbuf * -ieee80211_wep_crypt(struct ifnet *ifp, struct mbuf *m0, int txflag) +ieee80211_wep_crypt(struct ieee80211com *ic, struct mbuf *m0, int txflag) { - struct ieee80211com *ic = (void *)ifp; struct mbuf *m, *n, *n0; struct ieee80211_frame *wh; int i, left, len, moff, noff, kid; @@ -265,7 +262,7 @@ if (crc != le32toh(*(u_int32_t *)crcbuf)) { #ifdef IEEE80211_DEBUG if (ieee80211_debug) { - if_printf(ifp, "decrypt CRC error\n"); + if_printf(ic->ic_ifp, "decrypt CRC error\n"); if (ieee80211_debug > 1) ieee80211_dump_pkt(n0->m_data, n0->m_len, -1, -1); ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_crypto.h#3 (text+ko) ==== @@ -1,7 +1,7 @@ /* $NetBSD: ieee80211_crypto.h,v 1.2 2003/09/14 01:14:55 dyoung Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe - * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE]; }; -extern void ieee80211_crypto_attach(struct ifnet *); -extern void ieee80211_crypto_detach(struct ifnet *); -extern struct mbuf *ieee80211_wep_crypt(struct ifnet *, struct mbuf *, int); +extern void ieee80211_crypto_attach(struct ieee80211com *); +extern void ieee80211_crypto_detach(struct ieee80211com *); +extern struct mbuf *ieee80211_wep_crypt(struct ieee80211com *, struct mbuf *, int); #endif /* _NET80211_IEEE80211_CRYPTO_H_ */ ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_input.c#5 (text+ko) ==== @@ -1,6 +1,6 @@ /*- * Copyright (c) 2001 Atsushi Onoe - * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,17 +77,17 @@ * by the 802.11 layer. */ void -ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, - int rssi, u_int32_t rstamp) +ieee80211_input(struct ieee80211com *ic, struct mbuf *m, + struct ieee80211_node *ni, int rssi, u_int32_t rstamp) { - struct ieee80211com *ic = (void *)ifp; + struct ifnet *ifp = ic->ic_ifp; struct ieee80211_frame *wh; struct ether_header *eh; struct mbuf *m1; int len; u_int8_t dir, type, subtype; u_int8_t *bssid; - u_int16_t rxseq; + u_int16_t rxseq, fragno; KASSERT(ni != NULL, ("null node")); @@ -101,17 +101,18 @@ /* * In monitor mode, send everything directly to bpf. + * Also do not process frames w/o i_addr2 any further. * XXX may want to include the CRC */ - if (ic->ic_opmode == IEEE80211_M_MONITOR) + if (ic->ic_opmode == IEEE80211_M_MONITOR || + m->m_pkthdr.len < sizeof(struct ieee80211_frame_min)) goto out; wh = mtod(m, struct ieee80211_frame *); if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) != IEEE80211_FC0_VERSION_0) { - if (ifp->if_flags & IFF_DEBUG) - if_printf(ifp, "receive packet with wrong version: %x\n", - wh->i_fc[0]); + IEEE80211_DPRINTF(ic, NETIF_MSG_ANY, + "receive packet with wrong version: %x\n", wh->i_fc[0]); ieee80211_unref_node(&ni); ic->ic_stats.is_rx_badversion++; goto err; @@ -126,7 +127,8 @@ */ if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) { /* XXX statistic */ - IEEE80211_DPRINTF2(("%s: frame too short, len %u\n", + IEEE80211_DPRINTF(ic, NETIF_MSG_ANY, + "%s: frame too short, len %u\n", __func__, m->m_pkthdr.len)); ic->ic_stats.is_rx_tooshort++; goto out; /* XXX */ @@ -134,11 +136,13 @@ if (ic->ic_state != IEEE80211_S_SCAN) { switch (ic->ic_opmode) { case IEEE80211_M_STA: - if (!IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_bssid)) { + bssid = wh->i_addr2; + if (!IEEE80211_ADDR_EQ(bssid, ni->ni_bssid)) { /* not interested in */ - IEEE80211_DPRINTF2(("%s: discard frame from " + IEEE80211_DPRINTF(ic, NETIF_MSG_INPUT, + "%s: discard frame from " "bss %s\n", __func__, - ether_sprintf(wh->i_addr2))); + ether_sprintf(wh->i_addr2)); ic->ic_stats.is_rx_wrongbss++; goto out; } @@ -151,11 +155,14 @@ else bssid = wh->i_addr1; if (!IEEE80211_ADDR_EQ(bssid, ic->ic_bss->ni_bssid) && - !IEEE80211_ADDR_EQ(bssid, ifp->if_broadcastaddr)) { + !IEEE80211_ADDR_EQ(bssid, ifp->if_broadcastaddr) && + (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == + IEEE80211_FC0_TYPE_DATA) { /* not interested in */ - IEEE80211_DPRINTF2(("%s: discard frame from " + IEEE80211_DPRINTF(ic, NETIF_MSG_ANY, + "%s: discard frame from " "bss %s\n", __func__, - ether_sprintf(bssid))); + ether_sprintf(bssid)); ic->ic_stats.is_rx_wrongbss++; goto out; } @@ -164,23 +171,58 @@ goto out; default: /* XXX catch bad values */ - break; + goto out; } ni->ni_rssi = rssi; ni->ni_rstamp = rstamp; rxseq = ni->ni_rxseq; + fragno = ni->ni_fragno; ni->ni_rxseq = le16toh(*(u_int16_t *)wh->i_seq) >> IEEE80211_SEQ_SEQ_SHIFT; - /* TODO: fragment */ + ni->ni_fragno = + le16toh(*(u_int16_t *)wh->i_seq) & IEEE80211_SEQ_FRAG_MASK; if ((wh->i_fc[1] & IEEE80211_FC1_RETRY) && - rxseq == ni->ni_rxseq) { - /* duplicate, silently discarded */ + rxseq == ni->ni_rxseq && fragno == ni->ni_fragno) { + /* duplicate, discard */ + IEEE80211_DPRINTF(ic, NETIF_MSG_INPUT, + "[%s] discard duplicate frame from %s, " + "seqno %u, fragno %u\n", + ieee80211_state_name[ic->ic_state], + ether_sprintf(bssid), rxseq, fragno); ic->ic_stats.is_rx_dup++; /* XXX per-station stat */ goto out; } ni->ni_inact = 0; } + if (ic->ic_set_tim != NULL && + (wh->i_fc[1] & IEEE80211_FC1_PWR_MGT) + && ni->ni_pwrsave == 0) { + /* turn on power save mode */ + IEEE80211_DPRINTF(ic, NETIF_MSG_POWER, + "power save mode on for %s\n", + ether_sprintf(wh->i_addr2)); + ni->ni_pwrsave = IEEE80211_PS_SLEEP; + } + if (ic->ic_set_tim != NULL && + (wh->i_fc[1] & IEEE80211_FC1_PWR_MGT) == 0 && + ni->ni_pwrsave != 0) { + /* turn off power save mode, dequeue stored packets */ + ni->ni_pwrsave = 0; + if (ic->ic_set_tim) + ic->ic_set_tim(ic, ni->ni_associd, 0); + IEEE80211_DPRINTF(ic, NETIF_MSG_POWER, + "power save mode off for %s\n", + ether_sprintf(wh->i_addr2)); + while (!_IF_QLEN(&ni->ni_savedq) != 0) { + struct mbuf *m0; + IF_DEQUEUE(&ni->ni_savedq, m0); + /* XXX need different driver interface */ + IF_ENQUEUE(&ic->ic_pwrsaveq, m); + (*ifp->if_start)(ifp); + } + } + switch (type) { case IEEE80211_FC0_TYPE_DATA: switch (ic->ic_opmode) { @@ -198,6 +240,8 @@ * It should be silently discarded for * SIMPLEX interface. */ + IEEE80211_DPRINTF(ic, NETIF_MSG_INPUT, + "%s", "discard multicast echo\n"); ic->ic_stats.is_rx_mcastecho++; goto out; } @@ -216,9 +260,10 @@ } /* check if source STA is associated */ if (ni == ic->ic_bss) { - IEEE80211_DPRINTF(("%s: data from unknown src " + IEEE80211_DPRINTF(ic, NETIF_MSG_INPUT, + "%s: data from unknown src " "%s\n", __func__, - ether_sprintf(wh->i_addr2))); + ether_sprintf(wh->i_addr2)); /* NB: caller deals with reference */ ni = ieee80211_dup_bss(ic, wh->i_addr2); if (ni != NULL) { @@ -231,9 +276,9 @@ goto err; } if (ni->ni_associd == 0) { - IEEE80211_DPRINTF(("ieee80211_input: " - "data from unassoc src %s\n", - ether_sprintf(wh->i_addr2))); + IEEE80211_DPRINTF(ic, NETIF_MSG_INPUT, + "%s: data from unassoc src %s\n", + __func__, ether_sprintf(wh->i_addr2))); IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DISASSOC, IEEE80211_REASON_NOT_ASSOCED); @@ -261,8 +306,18 @@ /* copy to listener after decrypt */ if (ic->ic_rawbpf) bpf_mtap(ic->ic_rawbpf, m); + /* XXX tap before or after defrag? */ + m = ieee80211_defrag(ic, ni, m); + if (m == NULL) { + /* XXX statistic */ + /* Fragment dropped or frame not complete yet */ + goto out; + } m = ieee80211_decap(ifp, m); if (m == NULL) { + IEEE80211_DPRINTF(ic, NETIF_MSG_INPUT, + "%s: decapsulation error for src %s\n", + __func__, ether_sprintf(wh->i_addr2)); ic->ic_stats.is_rx_decap++; goto err; } @@ -365,9 +420,21 @@ case IEEE80211_FC0_TYPE_CTL: ic->ic_stats.is_rx_ctl++; + if (ic->ic_opmode != IEEE80211_M_HOSTAP) + goto out; + subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; + if (subtype == IEEE80211_FC0_SUBTYPE_PS_POLL) { + /* XXX statistic */ + /* Dump out a single packet from the host */ + IEEE80211_DPRINTF(ic, NETIF_MSG_POWER, + "got power save probe from %s\n", + ether_sprintf(wh->i_addr2)); + ieee80211_recv_pspoll(ic, m, rssi, rstamp); + } goto out; default: - IEEE80211_DPRINTF(("%s: bad type %x\n", __func__, type)); + IEEE80211_DPRINTF(ic, NETIF_MSG_ANY, + "%s: bad type %x\n", __func__, type); /* should not come here */ break; } @@ -381,8 +448,105 @@ } } +/* + * This function reassemble fragments using the skb of the 1st fragment, + * if large enough. If not, a new skb is allocated to hold incoming + * fragments. + * + * Fragments are copied at the end of the previous fragment. A different + * strategy could have been used, where a non-linear skb is allocated and + * fragments attached to that skb. + */ +static struct mbuf * >>> TRUNCATED FOR MAIL (1000 lines) <<<