Home | History | Annotate | only in /src/sys/net80211
History log of /src/sys/net80211
RevisionDateAuthorComments
 1.3 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.2 23-Nov-2005  skrll branches: 1.2.18; 1.2.166;
Update for recent changes and after tweaking the command to generate
this:

- use UTC
- only list the changes to HEAD.
 1.1 04-Sep-2005  dyoung branches: 1.1.6; 1.1.8;
Add a CHANGES file with a summary of source changes between FreeBSD
imports on 2005-05-18 and on 2005-07-11.
 1.1.8.1 29-Nov-2005  yamt sync with head.
 1.1.6.3 11-Dec-2005  christos Sync with head.
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 04-Sep-2005  skrll file CHANGES was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.2.166.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 23-Nov-2005  yamt file CHANGES was added on branch yamt-lazymbuf on 2006-06-21 15:10:45 +0000
 1.5 11-Dec-2005  christos branches: 1.5.68;
merge ktrace-lwp.
 1.4 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.3 16-Jul-2004  dyoung branches: 1.3.2;
Add sysctl access to 802.11 node tables, step #2.
 1.2 16-Jul-2004  dyoung Move ieee80211_channel definition and channel flags into
ieee80211_channel.h, step #2.
 1.1 13-Oct-2003  dyoung Install header files for the new 802.11 layer.
 1.3.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Aug-2004  skrll Sync with HEAD
 1.3.2.1 16-Jul-2004  skrll file Makefile was added on branch ktrace-lwp on 2004-08-03 10:54:20 +0000
 1.5.68.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.11 14-Mar-2022  mlelstv Additional channel flags.
 1.10 21-Mar-2013  christos branches: 1.10.38;
Instead of always checking for ANYC, make it a valid channel
 1.9 21-Mar-2013  christos Don't attempt to dereference ANYC (since it is a pointer to 0x1).
Fixes random crashes in hostap mode (race conditions in the interrupt handler
while the interface comes up or down).
 1.8 10-Jan-2009  cegger branches: 1.8.14; 1.8.24;
Introduce ieee80211_setbasicrates().
Use it to set speed in ieee80211_ifattach().
Export new ieee80211_std_rateset_11{a,b,g}.

From OpenBSD.
 1.7 28-Jul-2008  christos branches: 1.7.2;
- trailing commas in enums
- arithmetic on enums needs cast
from Anon Ymous
 1.6 16-Dec-2007  degroote branches: 1.6.4; 1.6.6; 1.6.10; 1.6.12; 1.6.14; 1.6.16;
Add support for the command list scan in ifconfig (this command permits to scan
access point in the neighbourhood).

Complete list of channel attributes and list of management information element
payload.

While here, use estrlcpy instead of strncpy.

From FreeBSD ifconfig and net80211
 1.5 08-Mar-2006  lukem branches: 1.5.36; 1.5.46; 1.5.50;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.4 02-Mar-2006  dyoung branches: 1.4.2; 1.4.4;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.3 10-Dec-2005  elad branches: 1.3.4; 1.3.6;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.2 20-Nov-2005  dyoung Set the "special" struct ieee80211_channel pointer, IEEE80211_CHAN_ANYC,
to 0x1 instead of 0xffff, so the kernel will trap accidental
dereferences. I don't set IEEE80211_CHAN_ANYC to NULL because it
may have a distinct meaning in net80211. Thanks to Steve Woodford
for pointing out that 0xffff may be a valid kernel memory address
on x86.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.1 21-Jun-2005  dyoung branches: 1.1.1.1.2; 1.1.1.1.8; 1.1.1.1.10;
Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.1.10.1 22-Nov-2005  yamt sync with head.
 1.1.1.1.8.3 11-Dec-2005  christos Sync with head.
 1.1.1.1.8.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.1.1.8.1 21-Jun-2005  skrll file _ieee80211.h was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.1.1.1.2.2 21-Jan-2008  yamt sync with head
 1.1.1.1.2.1 21-Jun-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.4.1 19-Apr-2006  elad sync with head.
 1.4.2.1 13-Mar-2006  yamt sync with head.
 1.5.50.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.46.1 26-Dec-2007  ad Sync with head.
 1.5.36.1 09-Jan-2008  matt sync with HEAD
 1.6.16.1 19-Oct-2008  haad Sync with HEAD.
 1.6.14.1 31-Jul-2008  simonb Sync with head.
 1.6.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.10.1 04-May-2009  yamt sync with head.
 1.6.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.6.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.7.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.24.1 23-Jun-2013  tls resync from head
 1.8.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.38.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.10.38.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.3 13-Sep-2013  joerg branches: 1.3.30;
GC unused functions. Don't bother building ieee80211_acl.c, nothing in
it is non-static.
 1.2 31-Oct-2006  joerg branches: 1.2.46; 1.2.88; 1.2.98; 1.2.104;
Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.
 1.1 27-Nov-2005  thorpej branches: 1.1.2; 1.1.4; 1.1.22; 1.1.26; 1.1.28;
Move 802.11-specific files to files.net80211
 1.1.28.1 10-Dec-2006  yamt sync with head.
 1.1.26.1 18-Nov-2006  ad Sync with head.
 1.1.22.3 30-Dec-2006  yamt sync with head.
 1.1.22.2 21-Jun-2006  yamt sync with head.
 1.1.22.1 27-Nov-2005  yamt file files.net80211 was added on branch yamt-lazymbuf on 2006-06-21 15:10:45 +0000
 1.1.4.2 11-Dec-2005  christos Sync with head.
 1.1.4.1 27-Nov-2005  christos file files.net80211 was added on branch ktrace-lwp on 2005-12-11 10:29:22 +0000
 1.1.2.2 29-Nov-2005  yamt sync with head.
 1.1.2.1 27-Nov-2005  yamt file files.net80211 was added on branch yamt-readahead on 2005-11-29 21:23:29 +0000
 1.2.104.1 18-May-2014  rmind sync with head
 1.2.98.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.88.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.3.30.1 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.61 21-Aug-2021  andvar fix some more typos in comments/log messages, improve wording as well.
 1.60 06-Oct-2020  roy net80211: Initialise the interface with a decent link state.

Link state transitions to UP when a node is joined and DOWN when left.
This means that with the interface UP, the link state could be UNKNOWN
for a while, implying it can be used in BSS mode.
Which is of course false.

Add a function to set an initial link state based on the operating mode.
Also call this when the operating mode changes.

Basically in BSS and MONITOR it starts off down.
BSS will transition UP and DOWN as before, MONITOR will stay down.
IBSS, AHDEMO and HOSTAP will remain as link unknown because the state is
..... unknown.
 1.59 15-Mar-2020  thorpej Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.58 04-Feb-2020  thorpej Use ifmedia_fini().
 1.57 03-Oct-2019  jmcneill branches: 1.57.2;
ieee80211_announce: Print supported rates with aprint_debug
 1.56 24-Aug-2015  pooka branches: 1.56.18;
sprinkle _KERNEL_OPT
 1.55 18-Oct-2014  snj branches: 1.55.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.54 21-Mar-2013  christos Instead of always checking for ANYC, make it a valid channel
 1.53 05-Apr-2010  joerg branches: 1.53.8; 1.53.18;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.52 02-Apr-2010  dyoung Delete ieee80211_setbasicrates(). It's buggy, and we drivers can get
along fine without it.
 1.51 26-Mar-2010  dyoung In ieee80211_media_init(), change a pointer that we never write
through to a pointer to const.
 1.50 19-Jan-2010  pooka branches: 1.50.2; 1.50.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.49 10-Jan-2009  cegger Introduce ieee80211_setbasicrates().
Use it to set speed in ieee80211_ifattach().
Export new ieee80211_std_rateset_11{a,b,g}.

From OpenBSD.
 1.48 01-Dec-2007  jmcneill branches: 1.48.12; 1.48.14; 1.48.18; 1.48.26;
aprintify
 1.47 16-Nov-2006  christos branches: 1.47.22; 1.47.24; 1.47.30;
__unused removal on arguments; approved by core.
 1.46 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.45 08-Mar-2006  lukem branches: 1.45.10; 1.45.12;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.44 02-Mar-2006  dyoung branches: 1.44.2; 1.44.4;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.43 13-Dec-2005  dyoung branches: 1.43.4; 1.43.6;
Fix ieee80211_media2rate to suit the funny order of NetBSD's DSSS
media flags: DS2, DS5, DS11, DS1.
 1.42 25-Nov-2005  thorpej Use a once control to call initialize the 802.11 layer when
ieee80211_ifattach() is called. "wlan" no longer needs-flag,
and remove the ieee80211_init() call from main().
 1.41 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.40 26-Jul-2005  dyoung branches: 1.40.6;
Resolve conflicts.
 1.39 11-Jul-2005  dyoung Synchronize ieee80211_find_vap, ieee80211_find_instance.
 1.38 26-Jun-2005  dyoung branches: 1.38.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP'. I will
use this in the INSTALL kernel to save some space.
 1.37 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.36 20-Jun-2005  atatat Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.35 09-Jun-2005  atatat Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.
 1.34 30-May-2005  christos Unconst sysctl_query... hi atatat
 1.33 26-Feb-2005  perry nuke trailing whitespace
 1.32 10-Aug-2004  dyoung branches: 1.32.4; 1.32.6;
Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.31 30-Jul-2004  mycroft branches: 1.31.2;
Change the basic rate list for 11g to contain just the 11b modes, mimicking the
behavior of other systems.
 1.30 30-Jul-2004  dyoung For interoperability with legacy equipment, do not enable short
preamble by default.
 1.29 30-Jul-2004  dyoung Change sysctl range-checking: net.link.ieee80211.debug values are
now 0x0 -> 0xffffffff, not 0 -> 2.
 1.28 23-Jul-2004  mycroft Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
 1.27 23-Jul-2004  mycroft Changes from madwifi:
Abstract some of the node management code into separate functions, and use them
throughout, plugging memory leaks.
Allocate the AID allocation map dynamically.
 1.26 23-Jul-2004  mycroft More diff reduction; mainly IEEE80211_DPRINTF() stuff.
 1.25 23-Jul-2004  mycroft Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.24 23-Jul-2004  mycroft IEEE80211_MAX_AID has been renamed to IEEE80211_AID_MAX.
 1.23 22-Jul-2004  mycroft The low-level drivers are not setting the "basic rate" bit in the rateset.
Instead, change *_set11gbasicrate() to *_setbasicrates(), have it operate on
all modes, and call it from *_ifattach(). Also, fix obvious bugs in it (it
had an off-by-one error, at least).
 1.22 16-Jul-2004  dyoung Add sysctl access to 802.11 node tables, step #2.
 1.21 16-Jul-2004  dyoung Straggler: *really* chain the ieee80211coms.
 1.20 16-Jul-2004  dyoung Chain ieee80211coms together so that the 802.11 sysctls can walk
them all to retrieve their node tables.
 1.19 06-Jun-2004  dyoung Add sysctl(9) descriptions for net.link and net.link.ieee80211.
 1.18 06-Jun-2004  dyoung Fix a typo in some #ifdef notdef code.
 1.17 06-Jun-2004  dyoung Improve argument checking. Convert from seconds to some number of
inactivity countdown intervals (currently these are 5 seconds).
 1.16 06-Jun-2004  dyoung Fix for kern/25604: ifconfig wi0 media DS11 panics system.

In ieee80211_chan2mode, do not dereference the marker for "any
channel," IEEE80211_CHAN_ANYC.
 1.15 25-May-2004  atatat Sysctl descriptions under net subtree (net.key not done)
 1.14 09-May-2004  dyoung Undo last: I committed the wrong file.
 1.13 09-May-2004  dyoung In ieee80211_find_rxnode, when we "fake up" a node for an ad hoc
peer, we have to copy the "master" rate table to the faked-up node's
rate table, or else ath0 will complain, "ath0: bogus xmit rate
0x0". Thank you Konstantin KABASSANOV for reporting this problem.
 1.12 06-May-2004  dyoung Following Andrew Brown's suggestion, move net.ieee80211 to
net.link.ieee80211. The convention is that nodes directly under
net are protocol families (PF_*).

Also, simplify the sysctl setup for net80211 and rssadapt, following
another suggestion by Andrew.
 1.11 06-May-2004  dyoung Add a sysctl, net.ieee80211.debug, for turning debug messages on
and off.

Add a sysctl, net.ieee80211.maxinact, for adjusting the node time-out
interval. After net.ieee80211.maxinact seconds of inactivity, an
AP will purge a peer/client-record. Now the client has to reassociate.
 1.10 30-Apr-2004  dyoung From FreeBSD. Change ieee80211_phymode_name from
a subroutine back to an array. Rearrange ieee80211_setmode.
Miscellaneous small changes to make our code and FreeBSD's agree.
 1.9 13-Jan-2004  dyoung branches: 1.9.2;
NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.
 1.8 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.7 16-Oct-2003  matt bpfattach/bpfdetach need to be protected with NBPFILTER > 0
 1.6 14-Oct-2003  dyoung Do not index arrays using enum constants, since enums can be
re-ordered and extended. Instead, use a switch-statement or a
key->value table with appropriate bounds-checking.
 1.5 13-Oct-2003  dyoung More changes to the new 802.11 layer:

* Add Kevin Lahey's power-saving support from the old 802.11 layer

* Support for frequency-hopping PHYs

* Add support frequency-hopping PHY mode, IFM_IEEE80211_FH
* Add channel flags for frequency-hopping
* Add mode<->media mappings in for FH PHY in ieee80211_media2rate
and ieee80211_rate2media

* Stop using IFM_MAKEMODE macro since the mode constants
(e.g., IFM_IEEE80211_11A) are pre-shifted in sys/net/if_media.h

* Add some PLCP constants.
 1.4 23-Sep-2003  dyoung Put FreeBSDisms in #ifdef __FreeBSD__, and add the equivalent
NetBSDisms.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.5 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.9.2.2 23-Jul-2004  he Pull up revision 1.23 (via patch, requested by mycroft in ticket #700):
Many bug fixes and performance fixes for the wi(4) driver,
as well as changes paving the way for further performance
improvements.
 1.9.2.1 07-Jun-2004  jdc Pull up revision 1.16 (requested by dyoung in ticket #449).

Fix for kern/25604: ifconfig wi0 media DS11 panics system.

In ieee80211_chan2mode, do not dereference the marker for "any
channel," IEEE80211_CHAN_ANYC.
 1.31.2.8 11-Dec-2005  christos Sync with head.
 1.31.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.31.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.31.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.31.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.31.2.2 03-Aug-2004  skrll Sync with HEAD
 1.31.2.1 30-Jul-2004  skrll file ieee80211.c was added on branch ktrace-lwp on 2004-08-03 10:54:20 +0000
 1.32.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.4.1 29-Apr-2005  kent sync with -current
 1.38.2.2 07-Dec-2007  yamt sync with head
 1.38.2.1 21-Jun-2006  yamt sync with head.
 1.40.6.2 29-Nov-2005  yamt sync with head.
 1.40.6.1 22-Nov-2005  yamt sync with head.
 1.43.6.1 22-Apr-2006  simonb Sync with head.
 1.43.4.1 09-Sep-2006  rpaulo sync with head
 1.44.4.1 19-Apr-2006  elad sync with head.
 1.44.2.1 13-Mar-2006  yamt sync with head.
 1.45.12.2 10-Dec-2006  yamt sync with head.
 1.45.12.1 22-Oct-2006  yamt sync with head
 1.45.10.1 18-Nov-2006  ad Sync with head.
 1.47.30.1 08-Dec-2007  mjf Sync with HEAD.
 1.47.24.1 09-Jan-2008  matt sync with HEAD
 1.47.22.1 01-Dec-2007  jmcneill Sync with HEAD.
 1.48.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.48.18.3 11-Aug-2010  yamt sync with head.
 1.48.18.2 11-Mar-2010  yamt sync with head
 1.48.18.1 04-May-2009  yamt sync with head.
 1.48.14.1 17-Jan-2009  mjf Sync with HEAD.
 1.48.12.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.50.4.1 30-May-2010  rmind sync with head
 1.50.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.53.18.2 03-Dec-2017  jdolecek update from HEAD
 1.53.18.1 23-Jun-2013  tls resync from head
 1.53.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.55.2.1 22-Sep-2015  skrll Sync with HEAD
 1.56.18.9 16-Apr-2020  nat Use if_stat functions.
 1.56.18.8 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.56.18.7 10-Jun-2019  christos Sync with HEAD
 1.56.18.6 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.56.18.5 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.56.18.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.56.18.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.56.18.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.56.18.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.57.2.1 29-Feb-2020  ad Sync with head.
 1.28 16-Sep-2016  mlelstv branches: 1.28.16;
Merge enough FreeBSD code to make RT5592 work.
 1.27 27-Apr-2016  christos branches: 1.27.2;
Add 80211n ht frame.
 1.26 30-Mar-2013  christos branches: 1.26.12;
Use only one set of EDCA variables
 1.25 30-Mar-2013  christos remove obsolete macro
 1.24 30-Mar-2013  christos remove trailing whitespace.
 1.23 30-Mar-2013  christos EDCA and QOS additions from OpenBSD
 1.22 20-Aug-2012  christos branches: 1.22.2;
add more QoS bits
 1.21 03-Nov-2010  christos branches: 1.21.8;
From: Anon Ymous
add a few constants so that if_otus.c compiles.
 1.20 06-Nov-2008  dyoung branches: 1.20.6; 1.20.8;
Fix typo: IEEE80211_DUR_DIFS -> IEEE80211_DUR_DS_DIFS.
 1.19 28-Jul-2008  christos branches: 1.19.2;
- trailing commas in enums
- arithmetic on enums needs cast
from Anon Ymous
 1.18 16-Dec-2007  degroote branches: 1.18.4; 1.18.6; 1.18.10; 1.18.12; 1.18.14; 1.18.16;
Add support for the command list scan in ifconfig (this command permits to scan
access point in the neighbourhood).

Complete list of channel attributes and list of management information element
payload.

While here, use estrlcpy instead of strncpy.

From FreeBSD ifconfig and net80211
 1.17 28-Mar-2006  dyoung branches: 1.17.34; 1.17.44; 1.17.48;
For eventual re-use, extract the sub-band struct from struct
ieee80211_country_ie and call it ieee80211_band.
 1.16 10-Dec-2005  elad branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.15 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.14 26-Jul-2005  dyoung branches: 1.14.6;
Resolve conflicts.
 1.13 22-Jun-2005  dyoung branches: 1.13.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.12 26-Feb-2005  perry nuke trailing whitespace
 1.11 27-Dec-2004  mycroft branches: 1.11.2; 1.11.4;
GC unused stuff.
 1.10 27-Dec-2004  mycroft Replace d_plcp_svc with d_residue. The latter is the number of whole
empty/unused octets to fill out the data time slot. The value is constrained
by math to 0 for <= 5.5Mb, 0-1 for 11Mb, and 0-2 for 22Mb. It is used to
signal to the MAC that there is residue.
 1.9 23-Dec-2004  dyoung #define the difference in microseconds between a fast and a slow
preamble and PLCP header.
 1.8 19-Dec-2004  dyoung Define for more bits in the Service field of the 802.11 PLCP Header.

For use by the subroutine ieee80211_compute_duration, add struct
ieee80211_duration, and #define a number of microsecond constants
used for the transmit timing of 802.11 packets.

Add the subroutine ieee80211_compute_duration, which computes for
any packet the appropriate 802.11 Duration field, the PLCP Length
field, as well as the Duration and Length fields for an RTS frame.

atw(4), rtw(4), future drivers, and possibly ath(4) will share
ieee80211_compute_duration.
 1.7 23-Jul-2004  mycroft branches: 1.7.2;
Sync with madwifi.
 1.6 30-Apr-2004  dyoung From FreeBSD. Definite structures and constants for
QoS/WME/802.11e, for WPA, and for 802.11 MTU.
 1.5 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.4 15-Oct-2003  dyoung Add WEP shared-key authentication.
 1.3 13-Oct-2003  dyoung More changes to the new 802.11 layer:

* Add Kevin Lahey's power-saving support from the old 802.11 layer

* Support for frequency-hopping PHYs

* Add support frequency-hopping PHY mode, IFM_IEEE80211_FH
* Add channel flags for frequency-hopping
* Add mode<->media mappings in for FH PHY in ieee80211_media2rate
and ieee80211_rate2media

* Stop using IFM_MAKEMODE macro since the mode constants
(e.g., IFM_IEEE80211_11A) are pre-shifted in sys/net/if_media.h

* Add some PLCP constants.
 1.2 14-Sep-2003  dyoung Insert RCSIDs.
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.7.2.8 11-Dec-2005  christos Sync with head.
 1.7.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.7.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 23-Jul-2004  skrll file ieee80211.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.11.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.2.1 29-Apr-2005  kent sync with -current
 1.13.2.2 21-Jan-2008  yamt sync with head
 1.13.2.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Nov-2005  yamt sync with head.
 1.16.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.16.10.1 19-Apr-2006  elad sync with head.
 1.16.8.1 01-Apr-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.17.48.1 02-Jan-2008  bouyer Sync with HEAD
 1.17.44.1 26-Dec-2007  ad Sync with head.
 1.17.34.1 09-Jan-2008  matt sync with HEAD
 1.18.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.18.16.1 19-Oct-2008  haad Sync with HEAD.
 1.18.14.1 31-Jul-2008  simonb Sync with head.
 1.18.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.18.10.1 04-May-2009  yamt sync with head.
 1.18.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.18.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.18.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.19.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.8.1 05-Mar-2011  rmind sync with head
 1.20.6.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.21.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.21.8.1 30-Oct-2012  yamt sync with head
 1.22.2.2 03-Dec-2017  jdolecek update from HEAD
 1.22.2.1 23-Jun-2013  tls resync from head
 1.26.12.2 05-Oct-2016  skrll Sync with HEAD
 1.26.12.1 29-May-2016  skrll Sync with HEAD
 1.27.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.28.16.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.28.16.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.10 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.9 12-Jun-2011  christos branches: 1.9.54;
Change i_len in ieee80211req to be unsigned and fix other signed/unsigned
issues. From Dan Rosenberg (drosenberg at vsecurity dot com).
 1.8 17-Dec-2008  cegger branches: 1.8.12;
kill MALLOC and FREE macros.
 1.7 16-Nov-2006  christos branches: 1.7.46; 1.7.48; 1.7.52; 1.7.62;
__unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 17-Mar-2006  christos branches: 1.5.8; 1.5.10;
don't use MALLOC with a non-constant size; use malloc instead.
 1.4 18-Nov-2005  skrll branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12;
Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.3 26-Jul-2005  dyoung branches: 1.3.6; 1.3.8;
Resolve conflicts.
 1.2 22-Jun-2005  dyoung branches: 1.2.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.2.2.2 30-Dec-2006  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.8.1 22-Nov-2005  yamt sync with head.
 1.3.6.3 11-Dec-2005  christos Sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 26-Jul-2005  skrll file ieee80211_acl.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.4.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.4.10.1 19-Apr-2006  elad sync with head.
 1.4.8.1 01-Apr-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.10.2 10-Dec-2006  yamt sync with head.
 1.5.10.1 22-Oct-2006  yamt sync with head
 1.5.8.1 18-Nov-2006  ad Sync with head.
 1.7.62.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.52.1 04-May-2009  yamt sync with head.
 1.7.48.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.8.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.54.5 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.54.4 10-Jun-2019  christos Sync with HEAD
 1.9.54.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.9.54.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.9.54.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_action.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_action.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_adhoc.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_adhoc.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_ageq.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_ageq.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_alq.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_alq.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.3 24-Aug-2015  pooka branches: 1.3.18;
+ include opt_inet.h for INET (or lack thereof)
+ include net/in_ether.h, not netinet/in_ether.h
(did not cause a meltdown only because opt_inet.h was missing)
 1.2 11-Dec-2007  lukem branches: 1.2.6; 1.2.56; 1.2.76;
use __KERNEL_RCSID()
 1.1 31-Oct-2006  joerg branches: 1.1.2; 1.1.6; 1.1.8; 1.1.30; 1.1.40; 1.1.42; 1.1.44;
Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.
 1.1.44.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.42.1 11-Dec-2007  yamt sync with head.
 1.1.40.1 26-Dec-2007  ad Sync with head.
 1.1.30.1 09-Jan-2008  matt sync with HEAD
 1.1.8.3 21-Jan-2008  yamt sync with head
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 31-Oct-2006  yamt file ieee80211_amrr.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:28 +0000
 1.1.6.2 10-Dec-2006  yamt sync with head.
 1.1.6.1 31-Oct-2006  yamt file ieee80211_amrr.c was added on branch yamt-splraiseipl on 2006-12-10 07:19:06 +0000
 1.1.2.2 18-Nov-2006  ad Sync with head.
 1.1.2.1 31-Oct-2006  ad file ieee80211_amrr.c was added on branch newlock2 on 2006-11-18 21:39:32 +0000
 1.2.76.1 22-Sep-2015  skrll Sync with HEAD
 1.2.56.1 03-Dec-2017  jdolecek update from HEAD
 1.2.6.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.3.18.5 10-Jun-2019  christos Sync with HEAD
 1.3.18.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.3.18.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.3.18.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.3.18.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 31-Oct-2006  joerg branches: 1.1.2; 1.1.6; 1.1.8; 1.1.52; 1.1.148;
Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.
 1.1.148.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.148.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.52.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 31-Oct-2006  yamt file ieee80211_amrr.h was added on branch yamt-lazymbuf on 2006-12-30 20:50:28 +0000
 1.1.6.2 10-Dec-2006  yamt sync with head.
 1.1.6.1 31-Oct-2006  yamt file ieee80211_amrr.h was added on branch yamt-splraiseipl on 2006-12-10 07:19:06 +0000
 1.1.2.2 18-Nov-2006  ad Sync with head.
 1.1.2.1 31-Oct-2006  ad file ieee80211_amrr.h was added on branch newlock2 on 2006-11-18 21:39:32 +0000
 1.2 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 16-Jul-2004  dyoung branches: 1.1.2;
Move ieee80211_channel definition and channel flags into
ieee80211_channel.h, step #1.
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 16-Jul-2004  skrll file ieee80211_channel.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.4 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.3 23-Sep-2003  dyoung branches: 1.3.4;
Make if_printf more nearly match FreeBSD's, and make it compile.
Remove ieee80211_node_{dec,inc}ref (they go to ieee80211_node.h).
 1.2 14-Sep-2003  dyoung Insert RCSIDs.
 1.1 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.3.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 23-Sep-2003  skrll file ieee80211_compat.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.6 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.5 13-Jan-2004  dyoung branches: 1.5.4;
NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.
 1.4 15-Oct-2003  itojun add __attribute__((__format__)) to if_printf
 1.3 23-Sep-2003  dyoung Make if_printf more nearly match FreeBSD's, and make it compile.
Remove ieee80211_node_{dec,inc}ref (they go to ieee80211_node.h).
 1.2 14-Sep-2003  dyoung Insert RCSIDs.
 1.1 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.5.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.4.2 03-Aug-2004  skrll Sync with HEAD
 1.5.4.1 13-Jan-2004  skrll file ieee80211_compat.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.23 08-May-2018  maxv branches: 1.23.2;
Remove three useless debug messages, remove meaningless XXXs, and remove
ieee80211_note_frame (unused).
 1.22 10-Apr-2018  maxv Improve an XXX of mine, and fix one stat.
 1.21 19-Jan-2018  maxv branches: 1.21.2;
Style, and make sure that there is a header+trailer included in the
packet. The crypto functions can touch the trailer, but they don't check
whether it's there in the first place.
 1.20 17-Jan-2018  maxv Style, and fix two pretty bad mistakes in the crypto functions:

* They call M_PREPEND, but don't pass the updated pointer back to the
caller.

* They use memmove on the mbuf data, but they don't ensure that the
area they touch is contiguous.

This fix is not complete, ieee80211_crypto_encap too needs to pass back
the updated pointer. This will be done in another commit.
 1.19 16-Jan-2018  maxv Update the mbuf pointer when m_pullup succeeds, I forgot this in my last
revision (I only fixed the UAF in one branch). Meanwhile, style.
 1.18 10-Dec-2017  maxv Fix use-after-free: ieee80211_crypto_decap does a pullup on the mbuf but
the updated pointer is not passed back. Looks like it is triggerable
remotely.
 1.17 24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.16 13-Sep-2013  joerg branches: 1.16.6;
GC unused functions. Don't bother building ieee80211_acl.c, nothing in
it is non-static.
 1.15 23-May-2011  drochner branches: 1.15.4; 1.15.14; 1.15.18;
-remove references to crypto/arc4/arc4.* -- the code isn't used
anywhere afaics
(The confusion comes probably from use of arc4random() at various places,
but this lives in libkern and doesn't share code with the former.)
-g/c non-implementation of arc4 encryption in swcrypto(4)
-remove special casing of ARC4 in crypto(4) -- the point is that it
doesn't use an IV, and this fact is made explicit by the new "ivsize"
property of xforms
 1.14 16-Nov-2006  christos branches: 1.14.46; 1.14.76; 1.14.82;
__unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 27-Feb-2006  dyoung branches: 1.12.14; 1.12.16;
KNF: return NULL for a pointer, instead of 0.
 1.11 19-Feb-2006  dyoung Use a safe idiom to extract the keyid from the WEP header, instead
of assuming that the bytes of the 802.11 header and WEP header are
contiguous in the mbuf chain.
 1.10 18-Nov-2005  skrll branches: 1.10.2; 1.10.4; 1.10.6;
Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.9 26-Jul-2005  dyoung branches: 1.9.6;
Resolve conflicts.
 1.8 06-Jul-2005  dyoung Avoid an unnecessary API difference between NetBSD and FreeBSD:
back out my change to ieee80211_crypto_encap that made it free its
mbuf argument on error. I had thought it was a bug. It was not.
It's the drivers that are broken. Make an(4), atw(4), ipw(4),
iwi(4), ral(4), rtw(4), ural(4), and wi(4) free the mbuf when
ieee80211_crypto_encap returns NULL. Also, return ath(4) to the
way it was---i.e., free the mbuf.

Thanks to Sam Leffler to pointing out my mistake.
 1.7 22-Jun-2005  dyoung branches: 1.7.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.6 26-Feb-2005  perry nuke trailing whitespace
 1.5 14-Dec-2003  dyoung branches: 1.5.4; 1.5.10; 1.5.12;
Synchronize with FreeBSD sources from 12 Dec 2003.
 1.4 23-Sep-2003  dyoung More changes following this pattern:

#ifdef __FreeBSD__
/* FreeBSD-ism */
#else
/* NetBSD-ism */
#endif
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.5 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.4 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.3 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.5.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.4.7 11-Dec-2005  christos Sync with head.
 1.5.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.4.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.4.2 03-Aug-2004  skrll Sync with HEAD
 1.5.4.1 14-Dec-2003  skrll file ieee80211_crypto.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.7.2.2 30-Dec-2006  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.9.6.1 22-Nov-2005  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.1 01-Mar-2006  yamt sync with head.
 1.12.16.2 10-Dec-2006  yamt sync with head.
 1.12.16.1 22-Oct-2006  yamt sync with head
 1.12.14.1 18-Nov-2006  ad Sync with head.
 1.14.82.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.76.1 31-May-2011  rmind sync with head
 1.14.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.15.18.1 18-May-2014  rmind sync with head
 1.15.14.2 03-Dec-2017  jdolecek update from HEAD
 1.15.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.6.1 22-Sep-2015  skrll Sync with HEAD
 1.21.2.2 21-May-2018  pgoyette Sync with HEAD
 1.21.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.23.2.4 10-Jun-2019  christos Sync with HEAD
 1.23.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.23.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.23.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.12 10-Dec-2017  maxv branches: 1.12.4;
Fix use-after-free: ieee80211_crypto_decap does a pullup on the mbuf but
the updated pointer is not passed back. Looks like it is triggerable
remotely.
 1.11 03-Jan-2009  yamt remove extra semicolons.
 1.10 16-Nov-2006  christos branches: 1.10.46; 1.10.48; 1.10.52; 1.10.62;
__unused removal on arguments; approved by core.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 10-Dec-2005  elad branches: 1.8.20; 1.8.22;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.7 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.6 26-Jul-2005  dyoung branches: 1.6.6;
Remove duplicate FreeBSD RCS ID.
 1.5 26-Jul-2005  dyoung Resolve conflicts.
 1.4 26-Jun-2005  erh branches: 1.4.2;
Make sure there is a valid transmit key, before trying to use information
about it. Fixes a crash when configuring wi0.
 1.3 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.2 14-Sep-2003  dyoung branches: 1.2.4;
Insert RCSIDs.
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.4 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.3 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.2 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.2.4.6 11-Dec-2005  christos Sync with head.
 1.2.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 14-Sep-2003  skrll file ieee80211_crypto.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.4.2.2 30-Dec-2006  yamt sync with head.
 1.4.2.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Nov-2005  yamt sync with head.
 1.8.22.2 10-Dec-2006  yamt sync with head.
 1.8.22.1 22-Oct-2006  yamt sync with head
 1.8.20.1 18-Nov-2006  ad Sync with head.
 1.10.62.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.52.1 04-May-2009  yamt sync with head.
 1.10.48.1 17-Jan-2009  mjf Sync with HEAD.
 1.10.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.12.4.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.12.4.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.20 24-Jun-2023  msaitoh Fix typo in comment.
 1.19 03-Nov-2020  mlelstv Use kmem_* instead of malloc/free and use interrupt versions as the
code can be called from interrupt.
 1.18 28-Jul-2020  riastradh branches: 1.18.2;
Omit now-unused function.

Ceased to be needed with the AES CCM changes.

For some reason gcc didn't complain about this, but clang did.
 1.17 25-Jul-2020  riastradh Convert malloc -> kmem.

Switch order of members for better alignment. Sort includes.
 1.16 25-Jul-2020  riastradh Convert ieee80211_crypto_ccmp.c to new aes_ccm API.

This will make it easier to provide better hardware acceleration
without fpu enabling/disabling overhead for each block of data.
 1.15 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.14 03-May-2018  maxv branches: 1.14.2;
Remove ovbcopy from net80211.
 1.13 19-Jan-2018  maxv branches: 1.13.2;
Style, no functional change.
 1.12 17-Jan-2018  maxv Style, and fix two pretty bad mistakes in the crypto functions:

* They call M_PREPEND, but don't pass the updated pointer back to the
caller.

* They use memmove on the mbuf data, but they don't ensure that the
area they touch is contiguous.

This fix is not complete, ieee80211_crypto_encap too needs to pass back
the updated pointer. This will be done in another commit.
 1.11 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.10 30-Mar-2013  christos remove trailing whitespace
 1.9 30-Mar-2013  christos remove trailing space
 1.8 17-Dec-2008  cegger branches: 1.8.14; 1.8.24;
kill MALLOC and FREE macros.
 1.7 16-Nov-2006  christos branches: 1.7.46; 1.7.48; 1.7.52; 1.7.62;
__unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 16-Mar-2006  christos branches: 1.5.10; 1.5.12;
include if_ether.h if you want to use ether_sprintf()
 1.4 18-Nov-2005  skrll branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
Register these crypto modules.
 1.3 26-Jul-2005  dyoung branches: 1.3.6; 1.3.8;
Resolve conflicts.
 1.2 22-Jun-2005  dyoung branches: 1.2.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.2 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.2.2.2 30-Dec-2006  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.8.1 22-Nov-2005  yamt sync with head.
 1.3.6.3 11-Dec-2005  christos Sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 26-Jul-2005  skrll file ieee80211_crypto_ccmp.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.4.10.1 19-Apr-2006  elad sync with head.
 1.4.8.1 01-Apr-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.12.2 10-Dec-2006  yamt sync with head.
 1.5.12.1 22-Oct-2006  yamt sync with head
 1.5.10.1 18-Nov-2006  ad Sync with head.
 1.7.62.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.52.1 04-May-2009  yamt sync with head.
 1.7.48.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.8.24.2 03-Dec-2017  jdolecek update from HEAD
 1.8.24.1 23-Jun-2013  tls resync from head
 1.8.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.13.2.1 21-May-2018  pgoyette Sync with HEAD
 1.14.2.3 10-Jun-2019  christos Sync with HEAD
 1.14.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.14.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.18.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.8 19-Jan-2018  maxv branches: 1.8.4;
Style, no functional change.
 1.7 16-Nov-2006  christos branches: 1.7.46;
__unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 16-Mar-2006  christos branches: 1.5.10; 1.5.12;
include if_ether.h if you want to use ether_sprintf()
 1.4 11-Dec-2005  christos branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
merge ktrace-lwp.
 1.3 26-Jul-2005  dyoung branches: 1.3.6;
Resolve conflicts.
 1.2 22-Jun-2005  dyoung branches: 1.2.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.2 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 26-Jul-2005  skrll file ieee80211_crypto_none.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.4.10.1 19-Apr-2006  elad sync with head.
 1.4.8.1 01-Apr-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.12.2 10-Dec-2006  yamt sync with head.
 1.5.12.1 22-Oct-2006  yamt sync with head
 1.5.10.1 18-Nov-2006  ad Sync with head.
 1.7.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.8.4.3 10-Jun-2019  christos Sync with HEAD
 1.8.4.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.8.4.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.18 24-Jun-2023  msaitoh Fix typo in comment.
 1.17 03-Nov-2020  mlelstv Use kmem_* instead of malloc/free and use interrupt versions as the
code can be called from interrupt.
 1.16 19-Dec-2019  kamil branches: 1.16.8;
Avoid changing signedness bit with << 24 in ieee80211_crypto_tkip.c

Reported by <prlw1>
 1.15 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.14 19-Jan-2018  maxv branches: 1.14.2; 1.14.4;
Style, and check the return value of m_append.
 1.13 17-Jan-2018  maxv Style, and fix two pretty bad mistakes in the crypto functions:

* They call M_PREPEND, but don't pass the updated pointer back to the
caller.

* They use memmove on the mbuf data, but they don't ensure that the
area they touch is contiguous.

This fix is not complete, ieee80211_crypto_encap too needs to pass back
the updated pointer. This will be done in another commit.
 1.12 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.11 03-Apr-2011  drochner branches: 1.11.14;
make michael_mic() robust against degenerate mbuf layouts like
odd sizes in the middle of a chain
 1.10 17-Dec-2008  cegger branches: 1.10.6; 1.10.8;
kill MALLOC and FREE macros.
 1.9 26-Aug-2008  drochner branches: 1.9.2;
replace ths previous fix with a simpler one by Sam Leffler - it doesn't
deal with odd lengths in the mbuf before the last one, but it is assumed
that these don't occur in practice
 1.8 19-Aug-2008  drochner in michael_mic, handle the case where the last 4 bytes cross a mbuf
boundary, fixes connection drops with WPA aka TKIP on dumb
wireless adapters (tested with wpi)
 1.7 16-Nov-2006  christos branches: 1.7.46; 1.7.48; 1.7.52; 1.7.54; 1.7.58;
__unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 16-Mar-2006  christos branches: 1.5.10; 1.5.12;
include if_ether.h if you want to use ether_sprintf()
 1.4 18-Nov-2005  skrll branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.3 26-Jul-2005  dyoung branches: 1.3.6; 1.3.8;
Resolve conflicts.
 1.2 22-Jun-2005  dyoung branches: 1.2.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.3 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.2 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.8.1 22-Nov-2005  yamt sync with head.
 1.3.6.3 11-Dec-2005  christos Sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 26-Jul-2005  skrll file ieee80211_crypto_tkip.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.4.10.1 19-Apr-2006  elad sync with head.
 1.4.8.1 01-Apr-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.12.2 10-Dec-2006  yamt sync with head.
 1.5.12.1 22-Oct-2006  yamt sync with head
 1.5.10.1 18-Nov-2006  ad Sync with head.
 1.7.58.1 19-Oct-2008  haad Sync with HEAD.
 1.7.54.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.52.1 04-May-2009  yamt sync with head.
 1.7.48.2 17-Jan-2009  mjf Sync with HEAD.
 1.7.48.1 28-Sep-2008  mjf Sync with HEAD.
 1.7.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.9.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.6.1 21-Apr-2011  rmind sync with head
 1.11.14.1 03-Dec-2017  jdolecek update from HEAD
 1.14.4.5 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14.4.4 10-Jun-2019  christos Sync with HEAD
 1.14.4.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.14.4.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.14.4.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.14.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.16.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.14 24-Jun-2023  msaitoh Fix typo in comment.
 1.13 03-Nov-2020  mlelstv Use kmem_* instead of malloc/free and use interrupt versions as the
code can be called from interrupt.
 1.12 03-May-2018  maxv branches: 1.12.2; 1.12.14;
Remove ovbcopy from net80211.
 1.11 19-Jan-2018  maxv branches: 1.11.2;
Style, no functional change.
 1.10 17-Jan-2018  maxv Style, and fix two pretty bad mistakes in the crypto functions:

* They call M_PREPEND, but don't pass the updated pointer back to the
caller.

* They use memmove on the mbuf data, but they don't ensure that the
area they touch is contiguous.

This fix is not complete, ieee80211_crypto_encap too needs to pass back
the updated pointer. This will be done in another commit.
 1.9 09-Oct-2016  christos PR/51540: Henning Petersen: replace , with ;
 1.8 17-Dec-2008  cegger branches: 1.8.24; 1.8.42; 1.8.46;
kill MALLOC and FREE macros.
 1.7 16-Nov-2006  christos branches: 1.7.46; 1.7.48; 1.7.52; 1.7.62;
__unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 16-Mar-2006  christos branches: 1.5.10; 1.5.12;
include if_ether.h if you want to use ether_sprintf()
 1.4 18-Nov-2005  skrll branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
Register these crypto modules.
 1.3 26-Jul-2005  dyoung branches: 1.3.6; 1.3.8;
Resolve conflicts.
 1.2 22-Jun-2005  dyoung branches: 1.2.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.2 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.2.2.2 30-Dec-2006  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.8.1 22-Nov-2005  yamt sync with head.
 1.3.6.3 11-Dec-2005  christos Sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 26-Jul-2005  skrll file ieee80211_crypto_wep.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.4.10.1 19-Apr-2006  elad sync with head.
 1.4.8.1 01-Apr-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.12.2 10-Dec-2006  yamt sync with head.
 1.5.12.1 22-Oct-2006  yamt sync with head
 1.5.10.1 18-Nov-2006  ad Sync with head.
 1.7.62.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.52.1 04-May-2009  yamt sync with head.
 1.7.48.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.46.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.8.46.1 04-Nov-2016  pgoyette Sync with HEAD
 1.8.42.1 05-Dec-2016  skrll Sync with HEAD
 1.8.24.1 03-Dec-2017  jdolecek update from HEAD
 1.11.2.1 21-May-2018  pgoyette Sync with HEAD
 1.12.14.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.12.2.4 10-Jun-2019  christos Sync with HEAD
 1.12.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.12.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.12.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_ddb.c was initially added on branch phil-wifi.
 1.1.2.4 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_dfs.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_dfs.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_hostap.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_hostap.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_ht.c was initially added on branch nick-net80211-sync.
 1.1.56.5 10-Jun-2019  christos Sync with HEAD
 1.1.56.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.56.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_ht.c was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_ht.h was initially added on branch nick-net80211-sync.
 1.1.56.3 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_ht.h was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_hwmp.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.118 18-Oct-2025  mlelstv When defragmenting, check that both fragments are plaintext or
that both are encrypted.

From FreeBSD.
 1.117 19-Nov-2022  yamt branches: 1.117.4;
ieee80211_input.c: Fix a few debug messages
 1.116 29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.115 22-Dec-2018  maxv branches: 1.115.6;
Replace: M_MOVE_PKTHDR -> m_move_pkthdr. No functional change, since the
former is a macro to the latter.
 1.114 26-Jun-2018  msaitoh branches: 1.114.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.113 21-Jun-2018  maxv remove unused arguments
 1.112 21-Jun-2018  maxv Fix use-after-free, m_cat can free m.
 1.111 08-May-2018  maxv Remove three useless debug messages, remove meaningless XXXs, and remove
ieee80211_note_frame (unused).
 1.110 21-Jan-2018  maxv branches: 1.110.2;
Appease the overflow check, 4 is enough.
 1.109 17-Jan-2018  maxv Several changes:

* Style in several places, to make the code more readable or easier to
understand.

* Instead of checking m->m_pkthdr.len, check m->m_len. m_pkthdr.len is
the total size of the packet, not the size of the current mbuf (which
may be smaller).

* Add a missing length check when handling QoS frames.

* Cast the lengths passed in IEEE80211_VERIFY_LENGTH to size_t.

* Remove the length check on scan.sp_xrates, that I added yesterday.
xrates gets silently truncated in ieee80211_setup_rates().

* Fix several buffer overflows in the parsers of the MANAGEMENT frames.
 1.108 16-Jan-2018  maxv Various fixes: style, remove tiring XXXs, and prevent integer overflow in
ieee80211_setup_rates (normally it already can't happen, because I added a
length check on xrates in ieee80211_recv_mgmt_beacon).
 1.107 16-Jan-2018  maxv Prepend 'sp_' to the name of the fields, so that they can easily be found
via NXR or grep.
 1.106 16-Jan-2018  maxv Add comments about the length checks, and check xrates.
 1.105 16-Jan-2018  maxv Gather related code.
 1.104 16-Jan-2018  maxv Style on the new functions.
 1.103 16-Jan-2018  maxv Introduce ieee80211_recv_mgmt_disassoc.
 1.102 16-Jan-2018  maxv Introduce ieee80211_recv_mgmt_deauth.
 1.101 16-Jan-2018  maxv Introduce ieee80211_recv_mgmt_assoc_resp.
 1.100 16-Jan-2018  maxv Introduce ieee80211_recv_mgmt_assoc_req.
 1.99 16-Jan-2018  maxv Introduce ieee80211_recv_mgmt_auth.
 1.98 16-Jan-2018  maxv Start splitting ieee80211_recv_mgmt.
 1.97 16-Jan-2018  maxv More overflows...
 1.96 16-Jan-2018  maxv Fix overflow.
 1.95 16-Jan-2018  maxv Fix memory leak. If m1 == m, m = NULL, so it's safe to just call m_freem.
 1.94 16-Jan-2018  maxv Style, remove pointless XXXs, and add a comment about LLC.
 1.93 16-Jan-2018  maxv Split ieee80211_input into three sub-functions, that parse received
packets depending on their type:

DATA -> ieee80211_input_data
MANAGEMENT -> ieee80211_input_management
CONTROL -> ieee80211_input_control

No real functional change, but makes the code much clearer.
 1.92 16-Jan-2018  maxv Start cleaning up this mess.
 1.91 10-Dec-2017  maxv Fix use-after-free: ieee80211_crypto_decap does a pullup on the mbuf but
the updated pointer is not passed back. Looks like it is triggerable
remotely.
 1.90 10-Dec-2017  maxv Update the pointer after m_pullup, otherwise possible use-after-free.
 1.89 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.88 06-Mar-2017  ozaki-r branches: 1.88.6;
Fix incrementing wrong counter
 1.87 02-Feb-2017  nonaka wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.86 15-Dec-2016  ozaki-r branches: 1.86.2;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.85 27-Sep-2016  christos - use ether_snprintf() so that we don't overwrite our buffer for printing
ethernet-like addresses
- make this compile againw without IEEE80211_DEBUG.
 1.84 14-May-2016  mlelstv branches: 1.84.2;
In station mode filter packets that or not for us in case the
interface is in promiscous mode or doesn't filter packets itself.
 1.83 07-May-2016  mlelstv Don't check sequence number on multicast packets in station mode.
Handle overflow of 12bit sequence number.
 1.82 20-Apr-2016  knakahara IFQ_ENQUEUE refactor (3/3) : eliminate pktattr argument from IFQ_ENQUEUE caller
 1.81 20-Apr-2016  knakahara IFQ_ENQUEUE refactor (2/3) : eliminate pktattr argument from altq implemantation
 1.80 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.79 24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.78 18-Oct-2014  snj branches: 1.78.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.77 13-Sep-2013  joerg branches: 1.77.4;
GC unused functions. Don't bother building ieee80211_acl.c, nothing in
it is non-static.
 1.76 30-Mar-2013  christos branches: 1.76.4;
Putting extra l's in align does not make it more so.
 1.75 30-Mar-2013  christos remove trailing whitespace
 1.74 30-Mar-2013  christos remove trailing space
 1.73 10-Jan-2013  christos The IEEE80211_F_ flag prefix was used for both the flags in ieee80211_var.h
and for the rates in ieee80211_proto.h; rename the rate bits as _R_ to avoid
confusion.
 1.72 31-Dec-2011  christos branches: 1.72.2; 1.72.6;
- fix offsetof usage, and redundant defines
- kill pointer casts to 0
 1.71 17-Jul-2011  joerg branches: 1.71.2; 1.71.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.70 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.69 19-Jan-2010  pooka branches: 1.69.2; 1.69.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.68 02-Sep-2009  joerg Fix ALTQ for bridge mode. Based on FreeBSD's revision 1.115.
Tested by roy@.
 1.67 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.66 04-Mar-2007  christos branches: 1.66.34; 1.66.36; 1.66.40; 1.66.50;
fix fallout from caddr_t changes.
 1.65 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.64 16-Nov-2006  christos branches: 1.64.4;
__unused removal on arguments; approved by core.
 1.63 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.62 30-Aug-2006  christos branches: 1.62.2; 1.62.4;
wrong place for __inline
 1.61 25-Aug-2006  dyoung In promiscuous mode, some WNICs stop filtering management frames
whose destination does not match our MAC address. Filter those
frames in ieee80211_recv_mgmt, to prevent spurious
deauthentication/disassociation.
 1.60 30-Jun-2006  tacha Make 802.11 devices to work with stealth AP even when scanning
channels marked passive.

From FreeBSD.
 1.59 14-May-2006  elad branches: 1.59.4;
integrate kauth.
 1.58 17-Mar-2006  christos don't use MALLOC with a non-constant size; use malloc instead.
 1.57 02-Mar-2006  dyoung branches: 1.57.2; 1.57.4; 1.57.6;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.56 29-Dec-2005  dyoung branches: 1.56.4; 1.56.6;
Cosmetic: extract a subroutine ieee80211_update_adhoc_node() from
ieee80211_recv_mgmt(). ieee80211_update_adhoc_node() updates IBSS
nodes based on received beacons and probe responses. I extract a
subroutine to maintain a tolerable indentation level.
 1.55 16-Dec-2005  dyoung In IBSS mode, track all nodes' change of BSSID, not only the BSS
node's change. Thanks to Konstantin Kabassanov for pointing out
the problem.
 1.54 16-Dec-2005  dyoung Cosmetic: normalize whitespace.
 1.53 08-Dec-2005  dyoung Cosmetic: remove unnecessary stairstep.
 1.52 08-Dec-2005  dyoung Always record a change of the BSS node's BSSID, even if a desired
BSSID is set.

In IBSS mode, if the BSS node's BSSID changes, and a desired BSSID
is *not* set, make a RUN->RUN transition to give the driver an
opportunity to reprogram its BSSID filter. This fixes a bug where
both wlanctl(8) and ifconfig(8) indicated that an interface had
joined a new BSS, but no packets would get through, except in
promiscuous mode, because the hardware still filtered packets based
on the old BSSID.
 1.51 23-Nov-2005  dyoung In adhoc mode, mark the "BSS" node's (ic->ic_bss) change of BSSID.

If the operator did not configure a "desired BSSID," then we simply
adopt the BSS node's new BSSID. If the operator configured a
"desired BSSID," the new BSSID is (probably) not the desired one,
so start scanning for it.

Note that a change of BSSID will occur as two ad hoc networks merge.
 1.50 20-Nov-2005  dyoung Repair adhoc mode.

1 Complete initialization of "faked up" ieee80211_nodes,
whose capabilities and other fields are wrong, when we
first receive a beacon or probe response from the
corresponding neighbor. This entails factoring
ieee80211_init_neighbor out of ieee80211_add_neighbor.

2 In adhoc mode, ic->ic_bss is present in the neighbors
table, ic->ic_sta, and it is not necessarily the wrong
node on which to mark statistics for a rx'd packet. Do
not reject ic->ic_bss and fake-up a new node without
comparing its MAC address with the address of the sender
in the rx'd packet. This fixes a memory leak.
 1.49 19-Nov-2005  he Add an overlooked #if NBPFILTER > 0 / #endif.
 1.48 19-Nov-2005  riz Move the (ALTQ-conditional) declaration of struct altq_pktattr pktattr
into ieee80211_deliver_data(), since the code which uses it has been
moved there. Fixes build with options ALTQ.

reviewed by christos@
 1.47 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.46 24-Sep-2005  dyoung branches: 1.46.6;
Reduce diffs against FreeBSD by removing some redundant checks on
the BSSID and destination address.
 1.45 18-Aug-2005  yamt - introduce M_MOVE_PKTHDR and use it where appropriate.
intended to be mostly API compatible with openbsd/freebsd.
- remove a glue #define in netipsec/ipsec_osdep.h.
 1.44 26-Jul-2005  dyoung Import changes in FreeBSD's net80211 between 2005-05-18 and 2005-07-11.

A summary of changes is forthcoming.
 1.43 03-Jul-2005  dyoung branches: 1.43.2;
Restore ALTQ-classification to the AP-bridge, as pointed out by
Bernd Ernesti.
 1.42 03-Jul-2005  dyoung Refine an ieee80211_node-match using the SSID and the channel before
increasing the _node's beacon/probe count.
 1.41 26-Jun-2005  dyoung Do not build AP support if 'options IEEE80211_NO_HOSTAP'. I will
use this in the INSTALL kernel to save some space.
 1.40 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.39 30-May-2005  christos avoid shadowing of m1
 1.38 26-Feb-2005  perry nuke trailing whitespace
 1.37 16-Jan-2005  dyoung branches: 1.37.2; 1.37.4;
Fix a misuse of ether_sprintf so that IBSS merges are printed
xx:xx:xx:xx:xx:xx -> yy:yy:yy:yy:yy:yy instead of
xx:xx:xx:xx:xx:xx -> xx:xx:xx:xx:xx:xx.
 1.36 04-Jan-2005  dyoung IBSS-merge clean-up, inspired by some Linux patches from Jon Anderson
(mail@janderson.ca): remove ieee80211_ibss_merge's TSFT argument.
Do the TSFT comparison in the drivers (ath, atw). Remove a lot of
extraneous debug statements from ieee80211_ibss_merge.

Set the ieee80211_node's state to IEEE80211_STA_BSS after it's been
copied to the ic_bss, not before.

In struct ieee80211_node, make the ni_tstamp field a union of a
uint64_t and the 8 TSF octets so that it's easier to compare a
neighbor's TSF with the local TSF.

Log IBSS merges (Greg Troxel's suggestion). Also log IBSS creation.
These are rare and important events that deserve to be logged.
 1.35 10-Aug-2004  dyoung Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.34 30-Jul-2004  mycroft branches: 1.34.2;
Put a check for an impossible case inside '#ifdef DIAGNOSTIC'.
 1.33 29-Jul-2004  mycroft Implement passive scanning for APs in station and host-AP mode:
ieee80211_input():
* Do not discard management frames in station mode just because they have
the wrong BSSID.
* Do not discard beacons in station and host-AP mode when not scanning.
* Some minor rearrangement. Update node statistics even if the packet is
rejected.
ieee80211_recv_mgmt():
* Accept probe responses and beacons in station and host-AP even when not
scanning.
* Do not immediately free the node created by a beacon or probe response.
XXX Should I check BSSIDs more carefully in ieee80211_recv_mgmt() --
specifically for ASSOC_RESP, REASSOC_RESP, AUTH, DEAUTH and DISASSOC?

Fix a problem with APs that advertise multiple SSIDs:
Change the footprint of ieee80211_find_node_with_channel() to take a SSID as
well, and, if not empty, compared it with the existing nodes. This causes
us to allocate multiple nodes for the same AP. Without this we were only
leaving one SSID in the node table, which might not be the desired one, and
so the interface would fail to fully initialize. (Reported by he@ with a
Cisco 350 AP.)
 1.32 28-Jul-2004  dyoung Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.
 1.31 24-Jul-2004  dyoung Pull the IBSS merge logic out of atw and into net80211, since ath
will eventually share it.

In the IBSS merge logic, check conditions in a different order so
that they run faster in the common case---no merge. Fix the
rate-limiting on the debug outputs (enabled by IFF_LINK0).
 1.30 23-Jul-2004  mycroft Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
 1.29 23-Jul-2004  mycroft Changes from madwifi:
Abstract some of the node management code into separate functions, and use them
throughout, plugging memory leaks.
Allocate the AID allocation map dynamically.
 1.28 23-Jul-2004  mycroft IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY
 1.27 23-Jul-2004  mycroft Yet more DPRINTF() cleanup.
 1.26 23-Jul-2004  mycroft More diff reduction; mainly IEEE80211_DPRINTF() stuff.
 1.25 23-Jul-2004  mycroft Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.24 31-May-2004  dyoung Prevent ad hoc lossage: copy the SSID from a beacon into the
beacon-sender's ieee80211_node, if ni->ni_esslen == 0. This fixes
WEP for Matthew. I think that it also will save us from IBSS
splits.

Thanks again, Matthew Gream.
 1.23 06-May-2004  dyoung Incorporate new authentication debug statements from FreeBSD.

Fix authentication where I had botched it with the FreeBSD import.
(In FreeBSD, net80211 is strangely subroutine-averse, so where we
have ieee80211_auth_open and ieee80211_auth_shared, they incorporate
all of ieee80211_auth_open into ieee80211_recv_mgmt. I had not
realized that was why the 20 lines of new code.)
 1.22 30-Apr-2004  dyoung From FreeBSD. Be more consistent with ieee80211_node
reference counts, and treat ad hoc nodes properly. More complete
authentication support.
 1.21 11-Feb-2004  mrg branches: 1.21.2;
fix int/size_t issues in debug code.
 1.20 01-Feb-2004  dyoung This patch from Sam Leffler fixes bugs in the client-side of
shared-key authentication. This should help with your Apple products.
Any bugs, new or old, are mine.
 1.19 15-Jan-2004  onoe For FH phy, accept beacons whose hop pattern in FH params is different
from current setting, because the rssi value would be correct once the
datagram is received regardless the hopping pattern.
 1.18 14-Jan-2004  dyoung Don't panic on frames without a second address field. Tap them for
BPF, instead.
 1.17 13-Jan-2004  dyoung NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.
 1.16 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.15 07-Dec-2003  dyoung Diagnostics: complain if packet decapsulation fails.
 1.14 27-Oct-2003  mycroft Eliminate bogus initializer.
 1.13 25-Oct-2003  christos Fix uninitialized variable warning
 1.12 25-Oct-2003  mycroft Do that replacement in one more place.
 1.11 25-Oct-2003  mycroft Replace a constant with a symbol.
 1.10 23-Oct-2003  dyoung In the input path, do not discard management frames belonging to
a different BSS, because that keeps drivers like atw from detecting
ad hoc beacons with the same SSID but different BSSID for the
purpose of IBSS merges.

This should be revisited: maybe drivers should check for beacons
before handing packets up with ieee80211_input(). However, this
restores the atw(4) to working like it did with the old 802.11
layer, and it *is* nice to re-use the 802.11 layer's packet-decode
& -dispatch code (i.e., the ic_recv_mgmt callback).
 1.9 18-Oct-2003  itojun print "association failed" message only if IFF_DEBUG
 1.8 18-Oct-2003  onoe Do not update SSID by beacon, because hidden SSID implementation is vary.
ex. 0-length, single space, 0x00 with correct length.
So, we don't update SSID in node table by beacon, but always update by
Probe Response.
 1.7 15-Oct-2003  dyoung Add WEP shared-key authentication.
 1.6 14-Oct-2003  dyoung Add missing pktattr declaration. Should compile w/ ALTQ, now.
 1.5 13-Oct-2003  dyoung Add Kevin Lahey's power-saving support from the old 802.11 layer

Spelling fix: s/unmatch/mismatch/g
 1.4 28-Sep-2003  dyoung More NetBSD-FreeBSD compatibility changes in the pattern

#ifdef __FreeBSD__
/* FreeBSDism */
#else
/* NetBSDism */
#endif

An important and non-obvious change is in ieee80211_mgmt_output,

#ifdef __FreeBSD__
KASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
#endif

Because NetBSD mbufs are not bzero'd like FreeBSD's, we cannot
count on rcvif == NULL.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.21.2.1 03-Aug-2004  jmc Pullup patch (requested by he in ticket #729)

Fix a problem with APs advertising multiple SSIDs by
allocating multiple nodes for the same AP when the announced
SSID differs. Fixes PR#26377.
 1.34.2.9 11-Dec-2005  christos Sync with head.
 1.34.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.34.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.34.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.34.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.34.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.34.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.34.2.2 03-Aug-2004  skrll Sync with HEAD
 1.34.2.1 30-Jul-2004  skrll file ieee80211_input.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.37.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.37.2.2 29-Apr-2005  kent sync with -current
 1.37.2.1 16-Jan-2005  kent file ieee80211_input.c was added on branch kent-audio2 on 2005-04-29 11:29:32 +0000
 1.43.2.3 03-Sep-2007  yamt sync with head.
 1.43.2.2 30-Dec-2006  yamt sync with head.
 1.43.2.1 21-Jun-2006  yamt sync with head.
 1.46.6.2 29-Nov-2005  yamt sync with head.
 1.46.6.1 22-Nov-2005  yamt sync with head.
 1.56.6.1 22-Apr-2006  simonb Sync with head.
 1.56.4.1 09-Sep-2006  rpaulo sync with head
 1.57.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.57.4.1 19-Apr-2006  elad sync with head.
 1.57.2.3 03-Sep-2006  yamt sync with head.
 1.57.2.2 11-Aug-2006  yamt sync with head
 1.57.2.1 01-Apr-2006  yamt sync with head.
 1.59.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.62.4.2 10-Dec-2006  yamt sync with head.
 1.62.4.1 22-Oct-2006  yamt sync with head
 1.62.2.1 18-Nov-2006  ad Sync with head.
 1.64.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.66.50.1 19-Jan-2009  skrll Sync with HEAD.
 1.66.40.4 11-Aug-2010  yamt sync with head.
 1.66.40.3 11-Mar-2010  yamt sync with head
 1.66.40.2 16-Sep-2009  yamt sync with head
 1.66.40.1 04-May-2009  yamt sync with head.
 1.66.36.1 17-Jan-2009  mjf Sync with HEAD.
 1.66.34.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.69.4.1 30-May-2010  rmind sync with head
 1.69.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.71.6.1 18-Feb-2012  mrg merge to -current.
 1.71.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.71.2.2 23-Jan-2013  yamt sync with head
 1.71.2.1 17-Apr-2012  yamt sync with head
 1.72.6.4 03-Dec-2017  jdolecek update from HEAD
 1.72.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.72.6.2 23-Jun-2013  tls resync from head
 1.72.6.1 25-Feb-2013  tls resync with head
 1.72.2.1 31-Aug-2016  bouyer Pull up following revision(s) (requested by mlelstv in ticket #1382):
sys/net80211/ieee80211_input.c: revision 1.83
sys/net80211/ieee80211_input.c: revision 1.84
Don't check sequence number on multicast packets in station mode.
Handle overflow of 12bit sequence number.
In station mode filter packets that or not for us in case the
interface is in promiscous mode or doesn't filter packets itself.
 1.76.4.1 18-May-2014  rmind sync with head
 1.77.4.1 15-May-2016  martin Pull up following revision(s) (requested by mlelstv in ticket #1167):
sys/net80211/ieee80211_input.c: revision 1.83-1.84
Don't check sequence number on multicast packets in station mode.
Handle overflow of 12bit sequence number.
In station mode filter packets that or not for us in case the
interface is in promiscous mode or doesn't filter packets itself.
 1.78.2.7 28-Aug-2017  skrll Sync with HEAD
 1.78.2.6 05-Feb-2017  skrll Sync with HEAD
 1.78.2.5 05-Oct-2016  skrll Sync with HEAD
 1.78.2.4 29-May-2016  skrll Sync with HEAD
 1.78.2.3 22-Apr-2016  skrll Sync with HEAD
 1.78.2.2 19-Mar-2016  skrll Sync with HEAD
 1.78.2.1 22-Sep-2015  skrll Sync with HEAD
 1.84.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.84.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.84.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.86.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.88.6.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.110.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.110.2.3 28-Jul-2018  pgoyette Sync with HEAD
 1.110.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.110.2.1 21-May-2018  pgoyette Sync with HEAD
 1.114.2.6 10-Jun-2019  christos Sync with HEAD
 1.114.2.5 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.114.2.4 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.114.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.114.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.114.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.115.6.1 29-Feb-2020  ad Sync with head.
 1.117.4.1 11-Nov-2023  thorpej branches: 1.117.4.1.2;
Mostly de-tangle ifnet::if_snd from ifaltq, in a way that's minimally-
invasive to the ALTQ code itself.

The point of this is to lay the groundwork for future changes to ifqueue,
which among other benefits, will also hide the ALTQ ABI from drivers.
 1.117.4.1.2.1 16-Nov-2023  thorpej Clean up the locking protocol around altq_etherclassify(). It's no longer
required to acquire KERNEL_LOCK *just* because ALTQ is compiled into the
kernel; you only have to acquire it if ALTQ is enabled on the interface
in question.
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_input.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.69 21-Sep-2021  christos don't opencode kauth_cred_get()
 1.68 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.67 10-Nov-2019  chs branches: 1.67.12;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.66 17-May-2019  msaitoh Remove extra OSIOCSIFMEDIA. This old ioctl is converted to new one in
doifioctl().
 1.65 11-Apr-2019  kamil Fix CVS Id

NFCI
 1.64 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.63 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.62 28-Jan-2019  christos - Don't expose random data conversion functions, but expose the high level
entry point (such as ioctl) instead.
- Attempt to autoload the module before using it.

Naming: Should the names of the hooks be:
<category>_<version>_<function>_hook_t
or:
<category>_<function>_<version>_hook_t

We should make those consistent.
 1.61 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.60 24-Aug-2015  pooka branches: 1.60.16; 1.60.18;
sprinkle _KERNEL_OPT
 1.59 25-Jan-2014  christos branches: 1.59.6;
fix monitor mode channel.
 1.58 12-Sep-2013  martin Fix return value of ieee80211_ioctl_setoptie
 1.57 31-Dec-2011  christos branches: 1.57.6; 1.57.10;
- fix offsetof usage, and redundant defines
- kill pointer casts to 0
 1.56 12-Jun-2011  christos branches: 1.56.2; 1.56.6;
Change i_len in ieee80211req to be unsigned and fix other signed/unsigned
issues. From Dan Rosenberg (drosenberg at vsecurity dot com).
 1.55 02-Apr-2011  mbalmer branches: 1.55.2;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.
 1.54 18-Apr-2009  tsutsui branches: 1.54.4; 1.54.6;
Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.53 18-Mar-2009  cegger bcopy -> memcpy
 1.52 18-Mar-2009  cegger bzero -> memset
 1.51 17-Dec-2008  cegger branches: 1.51.2;
kill MALLOC and FREE macros.
 1.50 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.49 05-Apr-2008  mlelstv branches: 1.49.4; 1.49.10; 1.49.12;
revert the broken DeMorgan-ification
 1.48 07-Feb-2008  dyoung branches: 1.48.4; 1.48.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.47 28-Nov-2007  degroote Fix compilation in case of COMPAT_FREEBSD_NET80211.

Any reason that we use by default the old api ioctl instead of the 'new' api ioctl ?
(Time is a good reason :)).
 1.46 29-May-2007  christos branches: 1.46.6; 1.46.8; 1.46.14;
Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.45 04-Mar-2007  christos branches: 1.45.2; 1.45.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.44 06-Jan-2007  dyoung branches: 1.44.2;
Extract all of the FreeBSD compatibility ioctls into a subroutine,
ieee80211_ioctl_get80211_fbsd(), eliminating a bunch of #ifdef/#endif
clutter.
 1.43 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.42 27-Oct-2006  elad oops - passing wrong integer.
 1.41 25-Oct-2006  elad Kill some KAUTH_GENERIC_ISSUSER.
 1.40 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.39 09-Aug-2006  christos branches: 1.39.2; 1.39.4;
Use curchan in monitor mode. From Dheeraj S. FreeBSD always uses curchan,
and maybe we should too.
 1.38 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.37 27-Jun-2006  drochner fix some pointer botches which made wiconfig panic my machine
 1.36 22-Jun-2006  christos PR/33794: Arnaud Degroote: Wiconfig is broken in current. I broke it with
the previous set of stack changes.
 1.35 12-Jun-2006  christos branches: 1.35.2;
don't allocate chans on the stack.
 1.34 12-Jun-2006  christos Don't allocate wi_req on the stack.
 1.33 12-Jun-2006  christos Don't use roundup(IEEE80211_CHAN_MAX, NBBY) which is wrong anyway
[correct would have been howmany(...), use IEEE80211_CHAN_BYTES,
which is used in the other ioctl method. While here s/u_char/u_int8_t/
for chanlist to match the rest of the uses.
 1.32 14-May-2006  elad branches: 1.32.2;
integrate kauth.
 1.31 17-Mar-2006  christos don't use MALLOC with a non-constant size; use malloc instead.
 1.30 02-Mar-2006  dyoung branches: 1.30.2; 1.30.4; 1.30.6;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.29 27-Feb-2006  dyoung Simplify SIOCS80211BSSID, making it work just like IEEE80211_IOC_BSSID.
The upshot is that the interface is *always* reset when a BSSID is
configured. While I am here, rename unwieldy empty_macaddr variable
to zerobssid.
 1.28 18-Jan-2006  christos branches: 1.28.2; 1.28.4;
Apply patch from FreeBSD-SA-06:05. This avoids the overflow during the
lenght calculation phase instead of just growing the buffer like the older
patch did. I am leaving the bigger buffer too for now since it does not hurt.
 1.27 13-Jan-2006  christos Avoid buffer overflow in ioctl (from Karl Janmar)
 1.26 18-Nov-2005  skrll branches: 1.26.2;
Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.25 27-Jul-2005  dyoung branches: 1.25.6;
We don't really have FreeBSD 802.11 compatibility, and it will take
more work to get it right, so change the misleading COMPAT_FREEBSD
#ifdefs to #ifdef __FreeBSD__.
 1.24 27-Jul-2005  dyoung IEEE80211_IOC_BEACON_INTERVAL is not duplicated by SIOC[SG]80211POWER,
as I thought. The latter actually sets the station listen interval.

We cannot get/set "drop-unencrypted" and "privacy" properties
independently with SIOCS80211NWKEY, so put back IEEE80211_IOC_PRIVACY
and IEEE80211_IOC_DROPUNENCRYPTED.

Thanks Sam Leffler for pointing out my mistakes.
 1.23 27-Jul-2005  dyoung NetBSD already has ioctls that get/set these parameters. Only
compile support for the duplicate ioctls from FreeBSD if it is a
COMPAT_FREEBSD kernel:

IEEE80211_IOC_SSID
IEEE80211_IOC_WEPTXKEY
IEEE80211_IOC_CHANNEL
IEEE80211_IOC_PRIVACY
IEEE80211_IOC_DROPUNENCRYPTED
IEEE80211_IOC_BSSID
IEEE80211_IOC_BEACON_INTERVAL
IEEE80211_IOC_WEPKEY
 1.22 27-Jul-2005  dyoung Restore ABI compatibility with SIOCG80211STATS, SIOCG80211ZSTATS
in NetBSD 2.0:

* If 2.x compatibility is enabled (#ifdef COMPAT_20),
compile support for OSIOCG80211STATS and OSIOCG80211ZSTATS,
with the same ioctl numbers as SIOCG80211STATS and
SIOCG80211ZSTATS in 2.x. OSIOCG80211STATS and
OSIOCG80211ZSTATS return an ieee80211_ostats struct,
which has the same layout as ieee80211_stats in 2.x.

* Add new ioctl numbers for SIOCG80211STATS and SIOCG80211ZSTATS.
Both these ioctls will copy at most ifr_buflen bytes of
the new ieee80211_stats to ifr_buf.
 1.21 26-Jul-2005  dyoung Resolve conflicts.
 1.20 26-Jun-2005  dyoung branches: 1.20.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP'. I will
use this in the INSTALL kernel to save some space.
 1.19 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.18 26-Feb-2005  perry nuke trailing whitespace
 1.17 20-Dec-2004  dyoung branches: 1.17.2; 1.17.4;
Add SIOCG80211ZSTATS to atomically get/clear 802.11 statistics.

Protect SIOCG80211STATS with splnet()/splx() so that it takes a
"snapshot" of the 802.11 statistics, which is superfluous if
ieee80211_ioctl is always called at splnet()....
 1.16 23-Jul-2004  mycroft branches: 1.16.2;
IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY
 1.15 06-May-2004  dyoung No need to suppress if_init calls, ether_ioctl already does it.
Also, ether_ioctl handles more address families than ieee80211_ioctl
was.
 1.14 06-May-2004  dyoung NetBSD does not contain IPX support.
 1.13 06-May-2004  dyoung Fix spelling: supress -> suppress.
 1.12 06-May-2004  dyoung Check if_init error.
 1.11 05-May-2004  cube In NetBSD, if_init() expects a struct ifnet, not the softc.
 1.10 30-Apr-2004  dyoung From FreeBSD. Handle 802.11g protection mode and
Tx power control ioctls.
 1.9 21-Apr-2004  itojun kill some strcpy
 1.8 16-Jan-2004  onoe Ignore WI_RID_STA_IDENTITY and WI_RID_DBM_ADJUST instead of EINVAL
to allow wiconfig to report other informations.
 1.7 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.6 07-Dec-2003  dyoung Get/set fragmentation threshold. DTRT when the RTS threshold is
set.
 1.5 13-Oct-2003  dyoung Fix PR 23146 (sys/net80211/ intergration break WEP/power management
function) from FUKAUMI Naoki.
 1.4 28-Sep-2003  dyoung Adapt ieee80211_ioctl.[ch] to suit NetBSD. NetBSD and FreeBSD have
the least in common here, so I have not concerned myself with
compatibility.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.16.2.8 11-Dec-2005  christos Sync with head.
 1.16.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.16.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.16.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.2 03-Aug-2004  skrll Sync with HEAD
 1.16.2.1 23-Jul-2004  skrll file ieee80211_ioctl.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.17.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.2.1 29-Apr-2005  kent sync with -current
 1.20.2.6 11-Feb-2008  yamt sync with head.
 1.20.2.5 07-Dec-2007  yamt sync with head
 1.20.2.4 03-Sep-2007  yamt sync with head.
 1.20.2.3 26-Feb-2007  yamt sync with head.
 1.20.2.2 30-Dec-2006  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.25.6.1 22-Nov-2005  yamt sync with head.
 1.26.2.3 01-Mar-2006  yamt sync with head.
 1.26.2.2 01-Feb-2006  yamt sync with head.
 1.26.2.1 15-Jan-2006  yamt sync with head.
 1.28.4.2 01-Jun-2006  kardel Sync with head.
 1.28.4.1 22-Apr-2006  simonb Sync with head.
 1.28.2.1 09-Sep-2006  rpaulo sync with head
 1.30.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.30.4.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.30.4.3 19-Apr-2006  elad sync with head.
 1.30.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.30.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.30.2.4 11-Aug-2006  yamt sync with head
 1.30.2.3 26-Jun-2006  yamt sync with head.
 1.30.2.2 24-May-2006  yamt sync with head.
 1.30.2.1 01-Apr-2006  yamt sync with head.
 1.32.2.1 19-Jun-2006  chap Sync with head.
 1.35.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.39.4.2 10-Dec-2006  yamt sync with head.
 1.39.4.1 22-Oct-2006  yamt sync with head
 1.39.2.2 12-Jan-2007  ad Sync with head.
 1.39.2.1 18-Nov-2006  ad Sync with head.
 1.44.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.45.4.1 11-Jul-2007  mjf Sync with head.
 1.45.2.1 09-Jun-2007  ad Sync with head.
 1.46.14.2 18-Feb-2008  mjf Sync with HEAD.
 1.46.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.46.8.2 23-Mar-2008  matt sync with HEAD
 1.46.8.1 09-Jan-2008  matt sync with HEAD
 1.46.6.1 03-Dec-2007  joerg Sync with HEAD.
 1.48.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.48.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.48.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.49.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.49.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.49.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.49.4.1 04-May-2009  yamt sync with head.
 1.51.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.54.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.54.4.1 21-Apr-2011  rmind sync with head
 1.55.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.56.6.1 18-Feb-2012  mrg merge to -current.
 1.56.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.56.2.1 17-Apr-2012  yamt sync with head
 1.57.10.1 18-May-2014  rmind sync with head
 1.57.6.2 03-Dec-2017  jdolecek update from HEAD
 1.57.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.59.6.1 22-Sep-2015  skrll Sync with HEAD
 1.60.18.10 27-Apr-2020  nat Pass the error through to the hardware to initialize.
 1.60.18.9 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.60.18.8 10-Jun-2019  christos Sync with HEAD
 1.60.18.7 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.60.18.6 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.60.18.5 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.60.18.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.60.18.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.60.18.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.60.18.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.60.16.8 22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.60.16.7 18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.60.16.6 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.60.16.5 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.60.16.4 29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.60.16.3 21-Sep-2018  pgoyette Adapt the ieee80211_20 code to the new MP-safe mechanism
 1.60.16.2 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.60.16.1 28-Mar-2018  pgoyette No need to make the #include conditional; the included file contains
all required conditions.
 1.67.12.1 01-Aug-2021  thorpej Sync with HEAD.
 1.26 20-Aug-2019  christos Include <net/if.h> for IFNAMSIZ
 1.25 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.24 04-May-2018  maxv branches: 1.24.2;
Remove duplicate macros. Reported in PR/29786.
 1.23 08-Apr-2016  roy branches: 1.23.16;
Revert prior.
 1.22 06-Apr-2016  roy ieee80211 users in Other OS export rssi and noise as int8_t.
We should not be the odd one out for no good reason and the majority
of the ieee80211 drivers treat rssi as int8_t.
 1.21 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.20 12-Jun-2011  christos branches: 1.20.12; 1.20.30;
Change i_len in ieee80211req to be unsigned and fix other signed/unsigned
issues. From Dan Rosenberg (drosenberg at vsecurity dot com).
 1.19 28-Jul-2008  christos branches: 1.19.26;
- trailing commas in enums
- arithmetic on enums needs cast
from Anon Ymous
 1.18 02-Mar-2006  dyoung branches: 1.18.62; 1.18.64; 1.18.68; 1.18.70; 1.18.72; 1.18.74;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.17 27-Feb-2006  dyoung Move the SIOCS80211, SIOCG80211STATS, SIOCG80211ZSTATS definitions
nearer the top of ieee80211_ioctl.h for easy comparison with their
FreeBSD counterparts (which should just go away).
 1.16 10-Dec-2005  elad branches: 1.16.2; 1.16.4; 1.16.6;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.15 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.14 27-Jul-2005  dyoung branches: 1.14.6;
We don't really have FreeBSD 802.11 compatibility, and it will take
more work to get it right, so change the misleading COMPAT_FREEBSD
#ifdefs to #ifdef __FreeBSD__.
 1.13 27-Jul-2005  dyoung IEEE80211_IOC_BEACON_INTERVAL is not duplicated by SIOC[SG]80211POWER,
as I thought. The latter actually sets the station listen interval.

We cannot get/set "drop-unencrypted" and "privacy" properties
independently with SIOCS80211NWKEY, so put back IEEE80211_IOC_PRIVACY
and IEEE80211_IOC_DROPUNENCRYPTED.

Thanks Sam Leffler for pointing out my mistakes.
 1.12 27-Jul-2005  dyoung NetBSD already has ioctls that get/set these parameters. Only
compile support for the duplicate ioctls from FreeBSD if it is a
COMPAT_FREEBSD kernel:

IEEE80211_IOC_SSID
IEEE80211_IOC_WEPTXKEY
IEEE80211_IOC_CHANNEL
IEEE80211_IOC_PRIVACY
IEEE80211_IOC_DROPUNENCRYPTED
IEEE80211_IOC_BSSID
IEEE80211_IOC_BEACON_INTERVAL
IEEE80211_IOC_WEPKEY
 1.11 27-Jul-2005  dyoung Restore ABI compatibility with SIOCG80211STATS, SIOCG80211ZSTATS
in NetBSD 2.0:

* If 2.x compatibility is enabled (#ifdef COMPAT_20),
compile support for OSIOCG80211STATS and OSIOCG80211ZSTATS,
with the same ioctl numbers as SIOCG80211STATS and
SIOCG80211ZSTATS in 2.x. OSIOCG80211STATS and
OSIOCG80211ZSTATS return an ieee80211_ostats struct,
which has the same layout as ieee80211_stats in 2.x.

* Add new ioctl numbers for SIOCG80211STATS and SIOCG80211ZSTATS.
Both these ioctls will copy at most ifr_buflen bytes of
the new ieee80211_stats to ifr_buf.
 1.10 26-Jul-2005  dyoung Resolve conflicts.
 1.9 22-Jun-2005  dyoung branches: 1.9.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.8 20-Dec-2004  dyoung Add SIOCG80211ZSTATS to atomically get/clear 802.11 statistics.

Protect SIOCG80211STATS with splnet()/splx() so that it takes a
"snapshot" of the 802.11 statistics, which is superfluous if
ieee80211_ioctl is always called at splnet()....
 1.7 30-Apr-2004  dyoung branches: 1.7.2;
Add ioctl constants for both the 802.11g protection mode and for
Tx power control.
 1.6 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.5 13-Oct-2003  dyoung Revive constant IEEE80211_CHAN_ANY for ioctls.
 1.4 28-Sep-2003  dyoung Adapt ieee80211_ioctl.[ch] to suit NetBSD. NetBSD and FreeBSD have
the least in common here, so I have not concerned myself with
compatibility.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.7.2.7 11-Dec-2005  christos Sync with head.
 1.7.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.7.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 30-Apr-2004  skrll file ieee80211_ioctl.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Nov-2005  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.16.2.1 01-Mar-2006  yamt sync with head.
 1.18.74.1 19-Oct-2008  haad Sync with HEAD.
 1.18.72.1 31-Jul-2008  simonb Sync with head.
 1.18.70.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.18.68.1 04-May-2009  yamt sync with head.
 1.18.64.1 28-Sep-2008  mjf Sync with HEAD.
 1.18.62.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.19.26.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.20.30.1 22-Sep-2015  skrll Sync with HEAD
 1.20.12.1 03-Dec-2017  jdolecek update from HEAD
 1.23.16.2 21-May-2018  pgoyette Sync with HEAD
 1.23.16.1 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.24.2.7 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.24.2.6 10-Jun-2019  christos Sync with HEAD
 1.24.2.5 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.24.2.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.24.2.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.24.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.24.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_mesh.c was initially added on branch phil-wifi.
 1.1.2.5 10-Jun-2019  christos Sync with HEAD
 1.1.2.4 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_mesh.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_monitor.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_monitor.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.34 22-Dec-2018  maxv Replace M_ALIGN and MH_ALIGN by m_align.
 1.33 22-Dec-2018  maxv Move m_align() back into the kernel, and switch M_ALIGN and MH_ALIGN to it.
Forcing a distinction between M_ALIGN and MH_ALIGN is too bug-friendly and
serves no particular purpose.
 1.32 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.31 27-Apr-2018  maxv branches: 1.31.2;
Move m_align and m_append into iee80211_netbsd.c. They are part of
net80211, and shouldn't be used outside.
 1.30 18-Jan-2018  maxv branches: 1.30.2;
Style, and zero out 'ns' entirely, otherwise some bytes get leaked to
userland (eg ns_rsvd0).
 1.29 14-Jan-2017  maya appease coverity by using strlcpy instead of strncpy

ok riastradh
 1.28 27-Sep-2016  christos - use ether_snprintf() so that we don't overwrite our buffer for printing
ethernet-like addresses
- make this compile againw without IEEE80211_DEBUG.
 1.27 16-May-2016  ozaki-r branches: 1.27.2;
Use M_GETCTX and M_SETCTX instead of open-coding rcvif

No functional change.
 1.26 07-Apr-2014  pooka branches: 1.26.4;
Use module-compatible sysctl init instead of link sets.
 1.25 25-Feb-2014  pooka branches: 1.25.2;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.24 27-Jun-2013  christos branches: 1.24.2;
- add m_add() that puts an mbuf to end of a chain
- m_append() and m_align() with their family
- remove parameters from prototypes
 1.23 04-Feb-2013  christos don't print the interface name 2ice.
 1.22 14-Nov-2012  matt Set max_linkhdr when attaching so when bridging/forwarding ethernet drivers
have a chance to reserve enough space to insert a max-sized 802.11 header.
 1.21 02-Jun-2012  dsl branches: 1.21.2;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.20 19-Nov-2011  tls First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.19 07-Oct-2011  dyoung branches: 1.19.2;
Use atomic_ops(3) to increase/decrease node reference counts, just
like the upstream code did, because the current reference counting is
potentially racy. This works fine in light testing.
 1.18 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.17 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.16 31-Jan-2008  christos branches: 1.16.4; 1.16.6; 1.16.10; 1.16.16; 1.16.18;
fix 0 bssid problem on rejoin. From FreeBSD.
 1.15 13-Jan-2008  degroote Fix ieee80211_node leak

We can't use IF_PURGE here because m_pkthdr.rcvif have here a special meaning :
it holds ieee80211_node to which the management frame should be sent and the
node has its reference count bumped.

Introduce ieee80211_drain_ifq which release the node before freeing the mbuf.
Use it instead of IF_PURGE.

From DragonflyBSD
 1.14 04-Mar-2007  christos branches: 1.14.16; 1.14.22; 1.14.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 02-Mar-2006  dyoung branches: 1.13.20;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.12 16-Jan-2006  yamt branches: 1.12.2; 1.12.4;
- tweak RUN_ONCE api to allow init_func returns an error.
- physio: handle failure of workqueue_create.
 1.11 04-Dec-2005  christos branches: 1.11.2;
Merge the 3 copies of m_getcl() so that fast ipsec compiles again together
with net80211. XXX: We don't really have an m_getcl(), we just emulate it.
 1.10 25-Nov-2005  thorpej Use a once control to call initialize the 802.11 layer when
ieee80211_ifattach() is called. "wlan" no longer needs-flag,
and remove the ieee80211_init() call from main().
 1.9 20-Nov-2005  dyoung Mark ieee80211_nodes with their node-table membership: scan table
or client/neighbor table.

While I'm here, assert that ieee80211_getmgtframe returns a frame
that starts on a 32-bit boundary.
 1.8 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.7 24-Sep-2005  dyoung branches: 1.7.6; 1.7.8;
Reduce gratuitous differences from FreeBSD.
 1.6 26-Jul-2005  dyoung Resolve conflicts.
 1.5 10-Jul-2005  dyoung Bug fix: reset saw_bss when we start iterating over a new interface's
nodes, so that we list every interface's ic_bss node, instead of
listing only the first interface's.
 1.4 03-Jul-2005  dyoung branches: 1.4.2;
Don't load the ic_bss node into the sysctl result twice, as we
would do in IBSS mode if the ic_bss had not expired from the
scan/neighbor node-table.
 1.3 26-Jun-2005  dyoung Add some debug messages to ieee80211_notify_node_{join,leave}.

Change the way we walk 802.11 peers/clients: for each eligible
interface, walk the ic_sta (peers/clients) table, first; walk the
ic_scan (scan results) table, second; then visit the ic_bss (node
for the network joined/created by the interface).
 1.2 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.4.2.4 04-Feb-2008  yamt sync with head.
 1.4.2.3 21-Jan-2008  yamt sync with head
 1.4.2.2 03-Sep-2007  yamt sync with head.
 1.4.2.1 21-Jun-2006  yamt sync with head.
 1.7.8.2 29-Nov-2005  yamt sync with head.
 1.7.8.1 22-Nov-2005  yamt sync with head.
 1.7.6.3 11-Dec-2005  christos Sync with head.
 1.7.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.6.1 24-Sep-2005  skrll file ieee80211_netbsd.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.11.2.1 01-Feb-2006  yamt sync with head.
 1.12.4.1 22-Apr-2006  simonb Sync with head.
 1.12.2.1 09-Sep-2006  rpaulo sync with head
 1.13.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.28.1 19-Jan-2008  bouyer Sync with HEAD
 1.14.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.16.1 23-Mar-2008  matt sync with HEAD
 1.16.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.16.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.10.1 04-May-2009  yamt sync with head.
 1.16.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.16.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.19.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.19.2.2 30-Oct-2012  yamt sync with head
 1.19.2.1 17-Apr-2012  yamt sync with head
 1.21.2.4 03-Dec-2017  jdolecek update from HEAD
 1.21.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.2 25-Feb-2013  tls resync with head
 1.21.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.24.2.1 18-May-2014  rmind sync with head
 1.25.2.1 10-Aug-2014  tls Rebase.
 1.26.4.3 05-Feb-2017  skrll Sync with HEAD
 1.26.4.2 05-Oct-2016  skrll Sync with HEAD
 1.26.4.1 29-May-2016  skrll Sync with HEAD
 1.27.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.27.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.30.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.30.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.30.2.1 02-May-2018  pgoyette Synch with HEAD
 1.31.2.10 16-Apr-2020  nat Use if_stat functions.
 1.31.2.9 19-Nov-2019  phil Fix an ifdef
 1.31.2.8 10-Jun-2019  christos Sync with HEAD
 1.31.2.7 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.31.2.6 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.31.2.5 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.31.2.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.31.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.31.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.31.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.24 18-Mar-2022  riastradh net80211: Use getticks(), not hardclock_ticks.

Less extern in .c this way too.
 1.23 15-Mar-2020  thorpej Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.22 22-Dec-2018  maxv Move m_align() back into the kernel, and switch M_ALIGN and MH_ALIGN to it.
Forcing a distinction between M_ALIGN and MH_ALIGN is too bug-friendly and
serves no particular purpose.
 1.21 03-May-2018  maxv branches: 1.21.2;
Remove ovbcopy from net80211.
 1.20 27-Apr-2018  maxv Move m_align and m_append into iee80211_netbsd.c. They are part of
net80211, and shouldn't be used outside.
 1.19 07-Apr-2014  pooka branches: 1.19.26;
Use module-compatible sysctl init instead of link sets.
 1.18 27-Jun-2013  christos branches: 1.18.2; 1.18.6;
- add m_add() that puts an mbuf to end of a chain
- m_append() and m_align() with their family
- remove parameters from prototypes
 1.17 31-Dec-2011  christos branches: 1.17.6;
- fix offsetof usage, and redundant defines
- kill pointer casts to 0
 1.16 07-Oct-2011  dyoung branches: 1.16.2; 1.16.6;
Use atomic_ops(3) to increase/decrease node reference counts, just
like the upstream code did, because the current reference counting is
potentially racy. This works fine in light testing.
 1.15 15-Jun-2008  christos move TAILQ_FOREACH_SAFE -> sys/queue.h
 1.14 13-Feb-2008  skrll branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12; 1.14.14;
s/MUTEX_DRIVER/MUTEX_DEFAULT/

The only true NetBSD mutex type.
 1.13 11-Feb-2008  dyoung Re-implement the net80211 locks using mutex(9) instead of splnet(9)
shenanigans. This matches the FreeBSD implementation much more
closely, but performance may suffer.
 1.12 13-Jan-2008  degroote Fix ieee80211_node leak

We can't use IF_PURGE here because m_pkthdr.rcvif have here a special meaning :
it holds ieee80211_node to which the management frame should be sent and the
node has its reference count bumped.

Introduce ieee80211_drain_ifq which release the node before freeing the mbuf.
Use it instead of IF_PURGE.

From DragonflyBSD
 1.11 04-Mar-2007  christos branches: 1.11.16; 1.11.22; 1.11.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.10 02-Mar-2006  dyoung branches: 1.10.18; 1.10.20; 1.10.28;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.9 10-Dec-2005  elad branches: 1.9.4; 1.9.6;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.8 04-Dec-2005  christos Merge the 3 copies of m_getcl() so that fast ipsec compiles again together
with net80211. XXX: We don't really have an m_getcl(), we just emulate it.
 1.7 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.6 18-Aug-2005  skrll branches: 1.6.6;
Don't need to declare m_append twice.
 1.5 26-Jul-2005  dyoung Resolve conflicts.
 1.4 10-Jul-2005  dyoung Cosmetic: reunite a comment with the code it describes.
 1.3 22-Jun-2005  martin branches: 1.3.2;
Remove unused <atomic.h> include; add <sys/device.h> includes where
needed.
 1.2 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 23-Jul-2004  mycroft branches: 1.1.1; 1.1.2;
First part of this file -- ieee80211_node locking macros.
 1.1.2.4 11-Dec-2005  christos Sync with head.
 1.1.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 23-Jul-2004  skrll file ieee80211_netbsd.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.1.1.3 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.2 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.3.2.4 27-Feb-2008  yamt sync with head.
 1.3.2.3 21-Jan-2008  yamt sync with head
 1.3.2.2 03-Sep-2007  yamt sync with head.
 1.3.2.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Nov-2005  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.28.1 05-Jun-2009  snj Pull up following revision(s) (requested by joerg in ticket #1321):
sys/net80211/ieee80211_netbsd.h: revision 1.15
sys/sys/queue.h: revision 1.49
move TAILQ_FOREACH_SAFE -> sys/queue.h
 1.10.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.18.1 05-Jun-2009  snj Pull up following revision(s) (requested by joerg in ticket #1321):
sys/net80211/ieee80211_netbsd.h: revision 1.15
sys/sys/queue.h: revision 1.49
move TAILQ_FOREACH_SAFE -> sys/queue.h
 1.11.28.1 19-Jan-2008  bouyer Sync with HEAD
 1.11.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.11.16.1 23-Mar-2008  matt sync with HEAD
 1.14.14.1 18-Jun-2008  simonb Sync with head.
 1.14.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.10.1 04-May-2009  yamt sync with head.
 1.14.8.1 17-Jun-2008  yamt sync with head.
 1.14.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.14.4.3 23-Feb-2008  skrll Another merge botch.
 1.14.4.2 23-Feb-2008  skrll Fix merge botch so that we use new world locking.
 1.14.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.16.6.1 18-Feb-2012  mrg merge to -current.
 1.16.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.2.1 17-Apr-2012  yamt sync with head
 1.17.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.6.1 10-Aug-2014  tls Rebase.
 1.18.2.1 18-May-2014  rmind sync with head
 1.19.26.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.19.26.2 21-May-2018  pgoyette Sync with HEAD
 1.19.26.1 02-May-2018  pgoyette Synch with HEAD
 1.21.2.12 16-Apr-2020  nat Use if_stat functions.
 1.21.2.11 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.21.2.10 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.2.9 10-Jun-2019  christos Sync with HEAD
 1.21.2.8 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.21.2.7 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.21.2.6 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.21.2.5 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.21.2.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.21.2.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.21.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.21.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.85 18-Oct-2025  mlelstv Avoid recursive calls into ieee80211_next_scan. Depending on number of
scanned channels, this can overflow the kernel stack.
 1.84 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.83 24-Jun-2023  msaitoh branches: 1.83.6;
Fix typo in comment.
 1.82 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.81 30-Nov-2020  msaitoh s/ we we / we /
 1.80 24-Feb-2020  rin branches: 1.80.6;
0x%p --> %p for non-external codes.
 1.79 27-Dec-2019  msaitoh branches: 1.79.2;
s/inital/initial/
 1.78 19-Dec-2019  jakllsch Add comment for previous.
 1.77 19-Dec-2019  jakllsch Do not associate with with any access point if no SSID has been configured.
 1.76 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.75 18-Jan-2018  maxv branches: 1.75.4;
Style, no functional change.
 1.74 16-Jan-2018  maxv Various fixes: style, remove tiring XXXs, and prevent integer overflow in
ieee80211_setup_rates (normally it already can't happen, because I added a
length check on xrates in ieee80211_recv_mgmt_beacon).
 1.73 16-Jan-2018  maxv Prepend 'sp_' to the name of the fields, so that they can easily be found
via NXR or grep.
 1.72 27-Sep-2016  christos - use ether_snprintf() so that we don't overwrite our buffer for printing
ethernet-like addresses
- make this compile againw without IEEE80211_DEBUG.
 1.71 08-Apr-2016  roy branches: 1.71.2;
Revert prior.
 1.70 06-Apr-2016  roy ieee80211 users in Other OS export rssi and noise as int8_t.
We should not be the odd one out for no good reason and the majority
of the ieee80211 drivers treat rssi as int8_t.
 1.69 24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.68 18-Oct-2014  snj branches: 1.68.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.67 29-Mar-2013  christos one we is enough.
 1.66 29-Mar-2013  christos Don't hold 2 locks at the same time, causes lockdebug panic. Triggered by
running usb wifi interfaces as access points. What we do instead is check
the generation number upon restart, and if it changed we give up.
 1.65 29-Mar-2013  christos trailing blanks police.
 1.64 10-Jan-2013  christos The IEEE80211_F_ flag prefix was used for both the flags in ieee80211_var.h
and for the rates in ieee80211_proto.h; rename the rate bits as _R_ to avoid
confusion.
 1.63 03-Jan-2009  yamt branches: 1.63.14; 1.63.24;
remove extra semicolons.
 1.62 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.61 24-Jun-2008  gmcgarry branches: 1.61.4;
Fix uses of #ifdef/#endif inside macro expansions.
 1.60 20-Dec-2007  dyoung branches: 1.60.4; 1.60.6; 1.60.10; 1.60.12; 1.60.14;
Add IEEE80211_NODE_UNLOCK() to match the IEEE80211_NODE_LOCK() .
 1.59 16-Nov-2006  christos branches: 1.59.24; 1.59.34; 1.59.38;
__unused removal on arguments; approved by core.
 1.58 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.57 30-Jun-2006  tacha branches: 1.57.4; 1.57.6;
Make 802.11 devices to work with stealth AP even when scanning
channels marked passive.

From FreeBSD.
 1.56 03-May-2006  seanb branches: 1.56.4;
- Make sure scangen sequence number is unique
per iteration.
- From FreeBSD.
- CI: sam
 1.55 28-Mar-2006  dyoung Revamp ieee80211_get_rate. Now it does not use the rateset in the
ic->ic_bss, but it uses the rateset in its new ieee80211_node
argument, instead. If the rate is fixed by ic->ic_fixed_rate, but
the fixed rate is not in the node's rateset, choose a reasonable
default: prefer the lowest basic rate or, if there is no basic
rate, prefer the lowest rate, period.

Change a printf complaint to a debug message.

Adapt drivers to suit new ieee80211_get_rate calling convention.

XXX I really need to replace ieee80211_get_rate with a bitrate
XXX adaptation algorithm. Soon, soon....
 1.54 17-Mar-2006  christos don't use MALLOC with a non-constant size; use malloc instead.
 1.53 08-Mar-2006  lukem branches: 1.53.2;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.52 02-Mar-2006  dyoung branches: 1.52.2; 1.52.4;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.51 25-Feb-2006  wiz Fix some typos.
 1.50 13-Jan-2006  skrll branches: 1.50.2; 1.50.4;
KNF a comment.
 1.49 29-Dec-2005  dyoung branches: 1.49.2;
Rewrite ieee80211_get_rate using clue from sys/dev/ic/athrate-sample.c:
Change -1 to named constant IEEE80211_FIXED_RATE_NONE. ic_fixed_rate
is an index into the ic_sup_rates table, so lookup a fixed rate
there and search the ni->ni_rates table for it.
 1.48 29-Dec-2005  dyoung IBSS merge nit: clear IEEE80211_F_SIBSS (STATUS: start IBSS) when
we merge with another IBSS.
 1.47 23-Nov-2005  dyoung In ieee80211_init_neighbor, delete unsupported rates from an adhoc
node. It's the right thing to do, but it is of pressing importance
because SampleRate's ath_rate_ctl_reset() will convert an unsupported
rate to an invalid rate-index of 0xff, and pass the index to
ath_hal_computetxtime(). ath_hal_computetxtime() does not tolerate
an invalid index; the CPU traps a divide-by-zero fault in
ath_hal_computetxtime().
 1.46 20-Nov-2005  dyoung Repair adhoc mode.

1 Complete initialization of "faked up" ieee80211_nodes,
whose capabilities and other fields are wrong, when we
first receive a beacon or probe response from the
corresponding neighbor. This entails factoring
ieee80211_init_neighbor out of ieee80211_add_neighbor.

2 In adhoc mode, ic->ic_bss is present in the neighbors
table, ic->ic_sta, and it is not necessarily the wrong
node on which to mark statistics for a rx'd packet. Do
not reject ic->ic_bss and fake-up a new node without
comparing its MAC address with the address of the sender
in the rx'd packet. This fixes a memory leak.
 1.45 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.44 25-Sep-2005  dyoung branches: 1.44.6;
Reduce diffs from FreeBSD: remove a gratuitous temporary variable.
Also, remove redundant code that honors the "desired BSSID"
(ic_des_bssid), since FreeBSD already does that.
 1.43 26-Jul-2005  dyoung In ieee80211_refine_node_for_beacon, deal gracefully with a node
that belongs to no table: don't dereference the null ni_table
pointer and panic.
 1.42 26-Jul-2005  dyoung Resolve conflicts.
 1.41 05-Jul-2005  dyoung branches: 1.41.2;
In ieee80211_refine_node_for_beacon, do not decrease the reference
count on the node that is passed in, because it belongs to the
driver. Also, do not increase the reference count on the refined
node, because ieee80211_refine_node_for_beacon's caller (ieee80211_input)
will never decrease the reference count.

As a general rule, reference counts are used for driver code to
assert ownership of ieee80211_nodes that are shared by the driver
and net80211 layer.
 1.40 26-Jun-2005  dyoung Do not build AP support if 'options IEEE80211_NO_HOSTAP'. I will
use this in the INSTALL kernel to save some space.
 1.39 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.38 26-Feb-2005  perry nuke trailing whitespace
 1.37 04-Jan-2005  dyoung branches: 1.37.2; 1.37.4;
IBSS-merge clean-up, inspired by some Linux patches from Jon Anderson
(mail@janderson.ca): remove ieee80211_ibss_merge's TSFT argument.
Do the TSFT comparison in the drivers (ath, atw). Remove a lot of
extraneous debug statements from ieee80211_ibss_merge.

Set the ieee80211_node's state to IEEE80211_STA_BSS after it's been
copied to the ic_bss, not before.

In struct ieee80211_node, make the ni_tstamp field a union of a
uint64_t and the 8 TSF octets so that it's easier to compare a
neighbor's TSF with the local TSF.

Log IBSS merges (Greg Troxel's suggestion). Also log IBSS creation.
These are rare and important events that deserve to be logged.
 1.36 04-Oct-2004  dyoung Drivers are not expected to call ieee80211_find_node_for_beacon,
so don't increase the reference count on a node before returning
it.
 1.35 04-Oct-2004  dyoung Bug fix: in ieee80211_find_txnode, we used to call ieee80211_ref_node(ni)
if ni == NULL and the operating mode was not "ad hoc" or "ad hoc
demo." That crashed the kernel. Now, if the operating mode is
not "ad hoc (demo)," and ni == NULL, return NULL right away.

Also, if ieee80211_dup_bss returns NULL, return NULL right away.
This doesn't fix a bug, but it makes clear how this works.
 1.34 10-Aug-2004  dyoung Cosmetic: remove extraneous blank line.
 1.33 10-Aug-2004  dyoung Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.32 29-Jul-2004  mycroft branches: 1.32.2;
Whoops, rearrange the function so the TAILQ_EMPTY() DTRT.
 1.31 29-Jul-2004  mycroft Don't reset the inactivity timer every time we create a node -- this could
cause us to stall and never time out anything.
 1.30 29-Jul-2004  mycroft Implement passive scanning for APs in station and host-AP mode:
ieee80211_input():
* Do not discard management frames in station mode just because they have
the wrong BSSID.
* Do not discard beacons in station and host-AP mode when not scanning.
* Some minor rearrangement. Update node statistics even if the packet is
rejected.
ieee80211_recv_mgmt():
* Accept probe responses and beacons in station and host-AP even when not
scanning.
* Do not immediately free the node created by a beacon or probe response.
XXX Should I check BSSIDs more carefully in ieee80211_recv_mgmt() --
specifically for ASSOC_RESP, REASSOC_RESP, AUTH, DEAUTH and DISASSOC?

Fix a problem with APs that advertise multiple SSIDs:
Change the footprint of ieee80211_find_node_with_channel() to take a SSID as
well, and, if not empty, compared it with the existing nodes. This causes
us to allocate multiple nodes for the same AP. Without this we were only
leaving one SSID in the node table, which might not be the desired one, and
so the interface would fail to fully initialize. (Reported by he@ with a
Cisco 350 AP.)
 1.29 28-Jul-2004  dyoung Always lookup/create a node table entry for Beacons and Probe
Responses. Ad hoc mode uses these entries to track network peers.
This provides passive-scan information for the current channel in
infrastructure mode (XXX really should keep it in a different
table). Host APs will someday use these entries to track APs in
the same ESS for AP-to-AP bridging.
 1.28 26-Jul-2004  mycroft The adhoc mode changes are seriously broken. In host-AP mode, at least, we
must use a full node for received management frames, or we are unable to
complete association and talk to the client. I could add an
"if mode == HOSTAP" to fix this, but instead I am reverting the change and
remanding it to the person who broke it.
 1.27 25-Jul-2004  dyoung Call ieee80211_free_node, not ieee80211_node_leave, on timed-out
IBSS nodes. Do not send an EXPIRE-type DEAUTH message when IBSS
nodes time-out. This ends the panic that rev 1.25 fixed, but
without a dual-use ieee80211_node_leave.
 1.26 25-Jul-2004  dyoung Undo last: Sam Leffler has shown me a better way to avoid ad hoc
lossage.
 1.25 24-Jul-2004  dyoung ieee80211_node_leave runs in all modes, not just hostap mode, so
it must not IASSERT that it is in hostap mode.
 1.24 24-Jul-2004  dyoung NetBSD does not define ieee80211_node_refcnt(). Use ni->ni_refcnt,
instead.
 1.23 23-Jul-2004  mycroft Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
 1.22 23-Jul-2004  mycroft Changes from madwifi:
Abstract some of the node management code into separate functions, and use them
throughout, plugging memory leaks.
Allocate the AID allocation map dynamically.
 1.21 23-Jul-2004  mycroft IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY
 1.20 23-Jul-2004  mycroft Yet more DPRINTF() cleanup.
 1.19 23-Jul-2004  dyoung Fix ieee80211_needs_rxnode so that net80211 does something akin to
a passive scan for APs and IBSSs, always, but without visiting new
channels.
 1.18 23-Jul-2004  mycroft Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.17 23-Jul-2004  dyoung Don't be so repetitive repetitive in the ieee80211_needs_rxnode
synopsis.
 1.16 23-Jul-2004  dyoung Bug fix: in ad hoc mode, the principle of least surprise demands
that we create the network with the BSSID preferred by the operator.

[Say the operator set the desired BSSID with 'ifconfig atw0 bssid
02:25:25:75:75:75'. If no such network is found during scanning,
then create the network with that BSSID.]
 1.15 02-Jul-2004  dyoung Remove a few levels of indentation in ieee80211_find_rxnode by
return'ing early.
 1.14 09-May-2004  dyoung In ieee80211_find_rxnode, when we "fake up" a node for an ad hoc
peer, we have to copy the "master" rate table to the faked-up node's
rate table, or else ath0 will complain, "ath0: bogus xmit rate
0x0". Thank you Konstantin KABASSANOV for reporting this problem.
 1.13 06-May-2004  dyoung Add a sysctl, net.ieee80211.debug, for turning debug messages on
and off.

Add a sysctl, net.ieee80211.maxinact, for adjusting the node time-out
interval. After net.ieee80211.maxinact seconds of inactivity, an
AP will purge a peer/client-record. Now the client has to reassociate.
 1.12 01-May-2004  dyoung Doh. Make it compile w/o IEEE80211_DEBUG.
 1.11 30-Apr-2004  dyoung From FreeBSD. Handle ad hoc-mode nodes better.
Use FREE/MALLOC instead of free/malloc. Add back _ieee80211_find_node,
the helper for ieee80211_find_node.
 1.10 13-Jan-2004  dyoung branches: 1.10.2;
NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.
 1.9 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.8 02-Nov-2003  dyoung Cosmetic: get rid of an indent level in ieee80211_find_txnode by
changing an if () ... else to an if () return.
 1.7 29-Oct-2003  dyoung Add ieee80211_find_rxnode and its helper ieee80211_needs_rxnode.
802.11 drivers will use ieee80211_find_rxnode to match each received
packet with the ieee80211_node belonging to the sender. The driver
will use the ieee80211_node to track the sender's RSSI and other
statistics for, e.g., rate adaptation.

ieee80211_find_rxnode "fakes-up" missing ieee80211_nodes in IBSS
mode and in ad-hoc demo mode when it is appropriate. See the comments
in the source.

Also add ieee80211_find_txnode, which looks up the ieee80211_node
belonging to a MAC destination. ieee80211_find_txnode will also
fake-up missing nodes in IBSS/ad-hoc demo mode.

In ieee80211_encap, use ieee80211_find_txnode. This fixes the bug
in ad hoc packet-transmission reported by Greg Troxel, Urban Boquist,
and Kurt Schreiner.
 1.6 15-Oct-2003  dyoung Add WEP shared-key authentication.
 1.5 13-Oct-2003  dyoung More changes to the new 802.11 layer:

* Add Kevin Lahey's power-saving support from the old 802.11 layer

* Add my stop-gap rate-selection routine, ieee80211_get_rate,
from the old 802.11 layer

* Also from the old 802.11 layer: factor ieee80211_match_bss out
of ieee80211_end_scan, since atw(4) uses it for IBSS merges.
 1.4 23-Sep-2003  dyoung Make ieee80211_unref_node compile.

#ifdef __FreeBSD__ a lot of lines, and put the NetBSDisms into the #else
half.

Add ieee80211_node_{dec,inc}ref to ieee80211_node.h.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.10.2.1 03-Aug-2004  jmc Pullup patch (requested by he in ticket #729)

Fix a problem with APs advertising multiple SSIDs by
allocating multiple nodes for the same AP when the announced
SSID differs. Fixes PR#26377.
 1.32.2.10 11-Dec-2005  christos Sync with head.
 1.32.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.32.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.32.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.32.2.6 19-Oct-2004  skrll Sync with HEAD
 1.32.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.32.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.32.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.32.2.2 03-Aug-2004  skrll Sync with HEAD
 1.32.2.1 29-Jul-2004  skrll file ieee80211_node.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.37.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.37.2.1 29-Apr-2005  kent sync with -current
 1.41.2.3 21-Jan-2008  yamt sync with head
 1.41.2.2 30-Dec-2006  yamt sync with head.
 1.41.2.1 21-Jun-2006  yamt sync with head.
 1.44.6.2 29-Nov-2005  yamt sync with head.
 1.44.6.1 22-Nov-2005  yamt sync with head.
 1.49.2.2 01-Mar-2006  yamt sync with head.
 1.49.2.1 15-Jan-2006  yamt sync with head.
 1.50.4.2 01-Jun-2006  kardel Sync with head.
 1.50.4.1 22-Apr-2006  simonb Sync with head.
 1.50.2.1 09-Sep-2006  rpaulo sync with head
 1.52.4.2 11-May-2006  elad sync with head
 1.52.4.1 19-Apr-2006  elad sync with head.
 1.52.2.4 11-Aug-2006  yamt sync with head
 1.52.2.3 24-May-2006  yamt sync with head.
 1.52.2.2 01-Apr-2006  yamt sync with head.
 1.52.2.1 13-Mar-2006  yamt sync with head.
 1.53.2.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.53.2.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.56.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.57.6.2 10-Dec-2006  yamt sync with head.
 1.57.6.1 22-Oct-2006  yamt sync with head
 1.57.4.1 18-Nov-2006  ad Sync with head.
 1.59.38.1 02-Jan-2008  bouyer Sync with HEAD
 1.59.34.1 26-Dec-2007  ad Sync with head.
 1.59.24.1 09-Jan-2008  matt sync with HEAD
 1.60.14.1 27-Jun-2008  simonb Sync with head.
 1.60.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.60.10.1 04-May-2009  yamt sync with head.
 1.60.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.60.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.60.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.61.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.63.24.3 03-Dec-2017  jdolecek update from HEAD
 1.63.24.2 23-Jun-2013  tls resync from head
 1.63.24.1 25-Feb-2013  tls resync with head
 1.63.14.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.63.14.1 23-Jan-2013  yamt sync with head
 1.68.2.2 05-Oct-2016  skrll Sync with HEAD
 1.68.2.1 22-Sep-2015  skrll Sync with HEAD
 1.71.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.75.4.7 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.75.4.6 10-Jun-2019  christos Sync with HEAD
 1.75.4.5 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.75.4.4 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.75.4.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.75.4.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.75.4.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.79.2.1 29-Feb-2020  ad Sync with head.
 1.80.6.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.83.6.1 02-Aug-2025  perseant Sync with HEAD
 1.32 01-Aug-2023  mrg fix simple mis-matched function prototype and definitions.

most of these are like, eg

void foo(int[2]);

with either of these

void foo(int*) { ... }
void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
 1.31 16-Feb-2022  andvar fix various typos, mainly in comments.
 1.30 19-Apr-2018  christos branches: 1.30.2;
s/static inline/static __inline/g for consistency.
 1.29 21-Jan-2018  maxv branches: 1.29.2;
Switch sp_timoff to u_int16_t, to prevent possible overflow in
ieee80211_recv_mgmt_beacon(). Actually this field is unused.
 1.28 16-Jan-2018  maxv Prepend 'sp_' to the name of the fields, so that they can easily be found
via NXR or grep.
 1.27 08-Apr-2016  roy Revert prior.
 1.26 06-Apr-2016  roy ieee80211 users in Other OS export rssi and noise as int8_t.
We should not be the odd one out for no good reason and the majority
of the ieee80211 drivers treat rssi as int8_t.
 1.25 18-Oct-2014  snj branches: 1.25.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.24 07-Oct-2011  dyoung branches: 1.24.12;
Use atomic_ops(3) to increase/decrease node reference counts, just
like the upstream code did, because the current reference counting is
potentially racy. This works fine in light testing.
 1.23 22-Dec-2007  dyoung branches: 1.23.4;
Use #ifdef _KERNEL to keep kernel-only definitions out of userland.
 1.22 30-Jun-2006  tacha branches: 1.22.30; 1.22.40; 1.22.44;
Make 802.11 devices to work with stealth AP even when scanning
channels marked passive.

From FreeBSD.
 1.21 10-Dec-2005  elad branches: 1.21.4; 1.21.8; 1.21.16;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.20 20-Nov-2005  dyoung Repair adhoc mode.

1 Complete initialization of "faked up" ieee80211_nodes,
whose capabilities and other fields are wrong, when we
first receive a beacon or probe response from the
corresponding neighbor. This entails factoring
ieee80211_init_neighbor out of ieee80211_add_neighbor.

2 In adhoc mode, ic->ic_bss is present in the neighbors
table, ic->ic_sta, and it is not necessarily the wrong
node on which to mark statistics for a rx'd packet. Do
not reject ic->ic_bss and fake-up a new node without
comparing its MAC address with the address of the sender
in the rx'd packet. This fixes a memory leak.
 1.19 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.18 26-Jul-2005  dyoung branches: 1.18.6;
Resolve conflicts.
 1.17 05-Jul-2005  he branches: 1.17.2;
Wrap use of MALLOC_DECLARE() within an #ifdef _KERNEL, it's declaration
in sys/mallocvar.h is within a similar conditional.
Fixes build problem for vax.
 1.16 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.15 04-Jan-2005  dyoung IBSS-merge clean-up, inspired by some Linux patches from Jon Anderson
(mail@janderson.ca): remove ieee80211_ibss_merge's TSFT argument.
Do the TSFT comparison in the drivers (ath, atw). Remove a lot of
extraneous debug statements from ieee80211_ibss_merge.

Set the ieee80211_node's state to IEEE80211_STA_BSS after it's been
copied to the ic_bss, not before.

In struct ieee80211_node, make the ni_tstamp field a union of a
uint64_t and the 8 TSF octets so that it's easier to compare a
neighbor's TSF with the local TSF.

Log IBSS merges (Greg Troxel's suggestion). Also log IBSS creation.
These are rare and important events that deserve to be logged.
 1.14 10-Aug-2004  dyoung Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.13 29-Jul-2004  mycroft branches: 1.13.2;
Implement passive scanning for APs in station and host-AP mode:
ieee80211_input():
* Do not discard management frames in station mode just because they have
the wrong BSSID.
* Do not discard beacons in station and host-AP mode when not scanning.
* Some minor rearrangement. Update node statistics even if the packet is
rejected.
ieee80211_recv_mgmt():
* Accept probe responses and beacons in station and host-AP even when not
scanning.
* Do not immediately free the node created by a beacon or probe response.
XXX Should I check BSSIDs more carefully in ieee80211_recv_mgmt() --
specifically for ASSOC_RESP, REASSOC_RESP, AUTH, DEAUTH and DISASSOC?

Fix a problem with APs that advertise multiple SSIDs:
Change the footprint of ieee80211_find_node_with_channel() to take a SSID as
well, and, if not empty, compared it with the existing nodes. This causes
us to allocate multiple nodes for the same AP. Without this we were only
leaving one SSID in the node table, which might not be the desired one, and
so the interface would fail to fully initialize. (Reported by he@ with a
Cisco 350 AP.)
 1.12 23-Jul-2004  mycroft Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
 1.11 23-Jul-2004  mycroft Changes from madwifi:
Abstract some of the node management code into separate functions, and use them
throughout, plugging memory leaks.
Allocate the AID allocation map dynamically.
 1.10 22-Jul-2004  dyoung Protect userland from some of the definitions with #ifdef _KERNEL.
Thank you, Havard Eidnes, for the pointing out my oversight.
 1.9 30-Apr-2004  dyoung Add a malloc(9) type for 802.11 nodes.
 1.8 14-Dec-2003  dyoung branches: 1.8.2;
Synchronize with FreeBSD sources from 12 Dec 2003.
 1.7 29-Oct-2003  dyoung Add ieee80211_find_rxnode and its helper ieee80211_needs_rxnode.
802.11 drivers will use ieee80211_find_rxnode to match each received
packet with the ieee80211_node belonging to the sender. The driver
will use the ieee80211_node to track the sender's RSSI and other
statistics for, e.g., rate adaptation.

ieee80211_find_rxnode "fakes-up" missing ieee80211_nodes in IBSS
mode and in ad-hoc demo mode when it is appropriate. See the comments
in the source.

Also add ieee80211_find_txnode, which looks up the ieee80211_node
belonging to a MAC destination. ieee80211_find_txnode will also
fake-up missing nodes in IBSS/ad-hoc demo mode.

In ieee80211_encap, use ieee80211_find_txnode. This fixes the bug
in ad hoc packet-transmission reported by Greg Troxel, Urban Boquist,
and Kurt Schreiner.
 1.6 15-Oct-2003  dyoung Add WEP shared-key authentication.
 1.5 13-Oct-2003  dyoung More changes to the new 802.11 layer:

* Add Kevin Lahey's power-saving support from the old 802.11 layer

* Add my stop-gap rate-selection routine, ieee80211_get_rate,
from the old 802.11 layer

* Also from the old 802.11 layer: factor ieee80211_match_bss out
of ieee80211_end_scan, since atw(4) uses it for IBSS merges.
 1.4 23-Sep-2003  dyoung Make ieee80211_unref_node compile.

#ifdef __FreeBSD__ a lot of lines, and put the NetBSDisms into the #else
half.

Add ieee80211_node_{dec,inc}ref to ieee80211_node.h.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.8.2.1 03-Aug-2004  jmc Pullup patch (requested by he in ticket #729)

Fix a problem with APs advertising multiple SSIDs by
allocating multiple nodes for the same AP when the announced
SSID differs. Fixes PR#26377.
 1.13.2.8 11-Dec-2005  christos Sync with head.
 1.13.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.13.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.13.2.2 03-Aug-2004  skrll Sync with HEAD
 1.13.2.1 29-Jul-2004  skrll file ieee80211_node.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.17.2.3 21-Jan-2008  yamt sync with head
 1.17.2.2 30-Dec-2006  yamt sync with head.
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.18.6.1 22-Nov-2005  yamt sync with head.
 1.21.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.21.8.1 11-Aug-2006  yamt sync with head
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.22.44.1 02-Jan-2008  bouyer Sync with HEAD
 1.22.40.1 26-Dec-2007  ad Sync with head.
 1.22.30.1 09-Jan-2008  matt sync with HEAD
 1.23.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.24.12.1 03-Dec-2017  jdolecek update from HEAD
 1.25.2.1 22-Apr-2016  skrll Sync with HEAD
 1.29.2.1 22-Apr-2018  pgoyette Sync with HEAD
 1.30.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.30.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.68 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.67 24-Oct-2022  msaitoh branches: 1.67.8;
Make ifq_drops in struct ifqueue and struct ifaltq 64 bit.
 1.66 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.65 29-Feb-2020  mlelstv branches: 1.65.10;
Fix printf to handle various datatypes for MHLEN.
 1.64 22-Dec-2018  maxv branches: 1.64.6;
Replace: M_MOVE_PKTHDR -> m_move_pkthdr. No functional change, since the
former is a macro to the latter.
 1.63 08-May-2018  maxv branches: 1.63.2;
Remove three useless debug messages, remove meaningless XXXs, and remove
ieee80211_note_frame (unused).
 1.62 03-May-2018  maxv Remove ovbcopy from net80211.
 1.61 18-Jan-2018  maxv branches: 1.61.2;
Several changes:

* Make the code more readable.

* Add a panic in ieee80211_compute_duration(). I'm not sure there's
a bug here - I don't have the hardware -, but looking at the code, it
may be possible for 'paylen' to go negative. Obviously that's not the
correct way to fix it, but at least we'll see if it happens.
 1.60 18-Jan-2018  maxv Several changes:

* Make the code more readable. In particular, declare variables as const
along the way.

* Explain what we're doing in ieee80211_send_mgmt(). The
IEEE80211_FC0_SUBTYPE_PROBE_RESP case has some inconsistencies, but
they are not inherently wrong so I'm not changing that.

* When sending IEEE80211_FC0_SUBTYPE_REASSOC_RESP frames, make sure to
zero out the 'association ID', otherwise two bytes are leaked.

* Fix a possible memory leak in ieee80211_send_probereq().
 1.59 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.58 04-Jan-2017  nonaka branches: 1.58.8;
Export some 802.11 IE manipulate functions.
 1.57 07-Jul-2016  msaitoh branches: 1.57.2;
KNF. Remove extra spaces. No functional change.
 1.56 20-Jun-2016  ozaki-r Get rid of invalid KASSERT

The mbuf being checked is allocated in ieee80211_getmgtframe just above,
so checking NULL of its CTX is meaningless.

Pointed out by mlelstv@
 1.55 20-Jun-2016  knakahara apply if_start_lock() to L2 callers which call ifp->if_start() of device derivers
 1.54 16-May-2016  ozaki-r Use M_GETCTX and M_SETCTX instead of open-coding rcvif

No functional change.
 1.53 24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.52 18-Oct-2014  snj branches: 1.52.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.51 31-Dec-2011  christos branches: 1.51.6;
- fix offsetof usage, and redundant defines
- kill pointer casts to 0
 1.50 21-Feb-2011  jmcneill branches: 1.50.4; 1.50.8;
add ieee80211_get_rts and ieee80211_get_cts_to_self from openbsd, ok dyoung@
 1.49 19-Jan-2010  pooka branches: 1.49.4; 1.49.6; 1.49.8;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.48 19-Jun-2008  dyoung Note a defect in 802.11 Duration field calculations.
 1.47 04-Mar-2007  christos branches: 1.47.34; 1.47.36; 1.47.40; 1.47.42; 1.47.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.46 06-Jan-2007  dyoung branches: 1.46.2;
Add software fragmentation of 802.11 packets to net80211. Some
wireless NICs need the host's help to fragment packets before the
NIC transmits them. From Sam Leffler.

Screen-scraped by me from the WWW source browser at perforce.freebsd.org.
 1.45 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 19-Feb-2006  dyoung branches: 1.43.14; 1.43.16;
From sam@FreeBSD.org:

set the mgt frame tx timer before dispatching the frame to the
driver; this closes a race where a response could be processed
before the timer was started and cause a RUN->SCAN state change
when operating in station mode
 1.42 19-Feb-2006  dyoung In 802.11 Duration and PLCP Length calculation, account for privacy
overhead in both the header and the *trailer*.
 1.41 29-Dec-2005  dyoung branches: 1.41.2; 1.41.4; 1.41.6;
In atw(4), use ieee80211_compute_duration() to compute IEEE 802.11
Duration and PLCP Length fields, and delete the abominable
atw_frame_setdurs() subroutine.

Make rtw(4) use the new ieee80211_compute_duration() calling
convention.

Add an ieee80211_key argument to ieee80211_compute_duration() and
lightly constify arguments. Get the crypto header length from the
key argument instead of blithely assuming a WEP header. Add some
inline documentation. Account for data padding (IEEE80211_F_DATAPAD).
 1.40 11-Dec-2005  dyoung Correct comment on ieee80211_compute_duration().
 1.39 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.38 25-Sep-2005  dyoung branches: 1.38.6;
Cosmetic: fix indentation.
 1.37 21-Aug-2005  dyoung In ieee80211_mbuf_adjust, cope with read-only mbufs: make the
802.11 header + opt(crypto header) + LLC writable, regardless of
crypto state. If s/w crypto is enabled, still make the entire
chain writable, as before.

Reviewed by: Nick Hudson
 1.36 18-Aug-2005  yamt - introduce M_MOVE_PKTHDR and use it where appropriate.
intended to be mostly API compatible with openbsd/freebsd.
- remove a glue #define in netipsec/ipsec_osdep.h.
 1.35 16-Aug-2005  dyoung Fix previous patch for non-crypto operation: test for a NULL key
before testing the key flags.

XXX Problems remain. Nick Hudson points out my questionable
XXX M_COPY_PKTHDR usage. Also, it seems to me that we may not be
XXX protected against writing a read-only mbuf during the crypto
XXX encapsulation stage, even if hardware does the actual crypto.
 1.34 15-Aug-2005  skrll If we're going to s/w encrypt the mbuf chain make sure it is writable.

Fixes wep on iwi(4).
 1.33 26-Jul-2005  dyoung Resolve conflicts.
 1.32 27-Jun-2005  dyoung branches: 1.32.2;
rtw: Try to get hardware WEP to work. It seems to work in
the RX direction, but not in the TX direction. The
net80211 crypto framework doesn't seem to cope very well
with the assymetry (I'm probably missing something), so
I will use software WEP for now.

net80211: In ieee80211_compute_duration, figure out whether to add
the WEP header to the packet overhead by checking the
WEP bit in the Frame Control field of the 802.11 header,
instead of checking the IEEE80211_F_PRIVACY flag.

Also, if the WEP bit is present, assume that the frame
described by (wh, len) has already already been WEP
encapsulated, and adjust the payload length accordingly.
XXX that's a grotty hack that I will have to revisit,
later.
 1.31 26-Jun-2005  erh Make sure there is a valid transmit key, before trying to use information
about it. Fixes a crash when configuring wi0.
 1.30 26-Jun-2005  dyoung Do not build AP support if 'options IEEE80211_NO_HOSTAP'. I will
use this in the INSTALL kernel to save some space.
 1.29 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.28 26-Feb-2005  perry nuke trailing whitespace
 1.27 21-Jan-2005  dyoung branches: 1.27.2;
Bug fix: when encapsulating 802.11 data packets, always copy the
BSS node's BSSID into the frame header. It is incorrect to copy
in the neighbor's BSSID because it may be out of date following an
IBSS merge.
 1.26 16-Jan-2005  dyoung branches: 1.26.2;
Cosmetic: shorten a staircase.
 1.25 04-Jan-2005  dyoung In ieee80211_getmbuf, remove the #ifdef __FreeBSD__ code. Check
for MCLGET success using the (m->m_flags & M_EXT) idiom.
 1.24 27-Dec-2004  dyoung Cosmetic: remove some dead code. Join some lines.
 1.23 27-Dec-2004  dyoung 802.11 Control/multicast/broadcast packets are not acknowledged.
Set a shorter 802.11 Duration field, accordingly.

XXX We expect CTS/ACK at 1 Mb/s for 1 & 2 Mb/s stations; and CTS/ACK
at 2 Mb/s for 5.5 & 11 Mb/s stations. We need to check with the
802.11 standard. Rate negotiation may need to be overhauld for
standards compliance, too.
 1.22 27-Dec-2004  mycroft Simplify the duration calculations somewhat.
* Add an intermediate variable, ctsrate, which is currently derived directly
from rate, but may be handled differently later (especially for 11g).
* Assume ACKs are sent at the same rate as the original data packet, as ath
does, shortening the ACK reservation time substantially.
* Add a note that we need to deal with not adding the ACK time for some
packets, though this is not implemented yet.

Questions:
* How do we affect the control rate used to send RTS/CTS packets?
* Is the PLCP header length actually controlled by the preamble length
selection, or should this be based on the transmit rate?

Of course short preamble is not actually implemented/working yet.
 1.21 27-Dec-2004  mycroft Update a comment.
 1.20 27-Dec-2004  mycroft Replace d_plcp_svc with d_residue. The latter is the number of whole
empty/unused octets to fill out the data time slot. The value is constrained
by math to 0 for <= 5.5Mb, 0-1 for 11Mb, and 0-2 for 22Mb. It is used to
signal to the MAC that there is residue.
 1.19 23-Dec-2004  dyoung Fix a bug in ieee80211_compute_duration: the 802.11 Duration field
in an 802.11 unicast data packet is equal to the duration of the
SIFS and Acknowledgement. That is, the amount of time reserved
*after* the packet has finished transmitting.

Change the arguments to ieee80211_compute_duration: pass the entire
packet length, not just the payload length. Add a 'debug' argument
to ieee80211_compute_duration and its helper subroutine,
ieee80211_compute_duration1.

If debug != 0, ieee80211_compute_duration printfs its arguments
and several local variables.

In rtw(4), load the 802.11 Duration field with the result from
ieee80211_compute_duration.
 1.18 19-Dec-2004  dyoung Define for more bits in the Service field of the 802.11 PLCP Header.

For use by the subroutine ieee80211_compute_duration, add struct
ieee80211_duration, and #define a number of microsecond constants
used for the transmit timing of 802.11 packets.

Add the subroutine ieee80211_compute_duration, which computes for
any packet the appropriate 802.11 Duration field, the PLCP Length
field, as well as the Duration and Length fields for an RTS frame.

atw(4), rtw(4), future drivers, and possibly ath(4) will share
ieee80211_compute_duration.
 1.17 10-Aug-2004  dyoung Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.16 23-Jul-2004  mycroft branches: 1.16.2;
IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY
 1.15 23-Jul-2004  mycroft Yet more DPRINTF() cleanup.
 1.14 23-Jul-2004  mycroft Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.13 31-May-2004  dyoung If WEP is on, set a data packet's WEP flag when we 802.11-encapsulate
it. Credit: Matthew Gream.
 1.12 30-Apr-2004  dyoung From FreeBSD. Increase a stats counter when
ieee80211_find_txnode fails.
 1.11 13-Jan-2004  dyoung NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.
 1.10 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.9 02-Nov-2003  dyoung On the output path, save a power-saving station's ieee80211_node
in the mbuf's rcvif field so that the driver can get at it.
 1.8 29-Oct-2003  dyoung Add ieee80211_find_rxnode and its helper ieee80211_needs_rxnode.
802.11 drivers will use ieee80211_find_rxnode to match each received
packet with the ieee80211_node belonging to the sender. The driver
will use the ieee80211_node to track the sender's RSSI and other
statistics for, e.g., rate adaptation.

ieee80211_find_rxnode "fakes-up" missing ieee80211_nodes in IBSS
mode and in ad-hoc demo mode when it is appropriate. See the comments
in the source.

Also add ieee80211_find_txnode, which looks up the ieee80211_node
belonging to a MAC destination. ieee80211_find_txnode will also
fake-up missing nodes in IBSS/ad-hoc demo mode.

In ieee80211_encap, use ieee80211_find_txnode. This fixes the bug
in ad hoc packet-transmission reported by Greg Troxel, Urban Boquist,
and Kurt Schreiner.
 1.7 15-Oct-2003  dyoung Add WEP shared-key authentication.
 1.6 13-Oct-2003  dyoung Even more changes to the new 802.11 layer:

* Add Kevin Lahey's power-saving support from the old 802.11 layer
* Add a FHPARMS or DSPARMS info element to probe responses and beacons
as appropriate.
 1.5 28-Sep-2003  dyoung More NetBSD-FreeBSD compatibility changes in the pattern

#ifdef __FreeBSD__
/* FreeBSDism */
#else
/* NetBSDism */
#endif

An important and non-obvious change is in ieee80211_mgmt_output,

#ifdef __FreeBSD__
KASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
#endif

Because NetBSD mbufs are not bzero'd like FreeBSD's, we cannot
count on rcvif == NULL.
 1.4 14-Sep-2003  dyoung Insert RCSIDs.
 1.3 07-Sep-2003  dyoung Complete merge.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.7 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.6 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.5 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.4 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.3 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.2 07-Sep-2003  dyoung Bring net80211/ sources up-to-date with FreeBSD.

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.16.2.10 11-Dec-2005  christos Sync with head.
 1.16.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.16.2.7 24-Jan-2005  skrll Sync with HEAD.
 1.16.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.16.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.16.2.2 03-Aug-2004  skrll Sync with HEAD
 1.16.2.1 23-Jul-2004  skrll file ieee80211_output.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.26.2.2 29-Apr-2005  kent sync with -current
 1.26.2.1 16-Jan-2005  kent file ieee80211_output.c was added on branch kent-audio2 on 2005-04-29 11:29:32 +0000
 1.27.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.2.4 03-Sep-2007  yamt sync with head.
 1.32.2.3 26-Feb-2007  yamt sync with head.
 1.32.2.2 30-Dec-2006  yamt sync with head.
 1.32.2.1 21-Jun-2006  yamt sync with head.
 1.38.6.1 22-Nov-2005  yamt sync with head.
 1.41.6.1 22-Apr-2006  simonb Sync with head.
 1.41.4.1 09-Sep-2006  rpaulo sync with head
 1.41.2.1 01-Mar-2006  yamt sync with head.
 1.43.16.2 10-Dec-2006  yamt sync with head.
 1.43.16.1 22-Oct-2006  yamt sync with head
 1.43.14.2 12-Jan-2007  ad Sync with head.
 1.43.14.1 18-Nov-2006  ad Sync with head.
 1.46.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.47.44.1 27-Jun-2008  simonb Sync with head.
 1.47.42.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.47.40.2 11-Mar-2010  yamt sync with head
 1.47.40.1 04-May-2009  yamt sync with head.
 1.47.36.1 29-Jun-2008  mjf Sync with HEAD.
 1.47.34.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.49.8.1 05-Mar-2011  bouyer Sync with HEAD
 1.49.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.49.4.1 05-Mar-2011  rmind sync with head
 1.50.8.1 18-Feb-2012  mrg merge to -current.
 1.50.4.1 17-Apr-2012  yamt sync with head
 1.51.6.1 03-Dec-2017  jdolecek update from HEAD
 1.52.2.4 05-Feb-2017  skrll Sync with HEAD
 1.52.2.3 09-Jul-2016  skrll Sync with HEAD
 1.52.2.2 29-May-2016  skrll Sync with HEAD
 1.52.2.1 22-Sep-2015  skrll Sync with HEAD
 1.57.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.58.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.61.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.61.2.1 21-May-2018  pgoyette Sync with HEAD
 1.63.2.6 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.63.2.5 10-Jun-2019  christos Sync with HEAD
 1.63.2.4 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.63.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.63.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.63.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.64.6.1 29-Feb-2020  ad Sync with head.
 1.65.10.1 01-Aug-2021  thorpej Sync with HEAD.
 1.67.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_phy.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_phy.h was initially added on branch phil-wifi.
 1.1.2.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_power.c was initially added on branch nick-net80211-sync.
 1.1.56.4 10-Jun-2019  christos Sync with HEAD
 1.1.56.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_power.c was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_power.h was initially added on branch nick-net80211-sync.
 1.1.56.3 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_power.h was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.37 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.36 22-Jul-2020  msaitoh branches: 1.36.6;
s/reseting/resetting/
 1.35 13-Jul-2020  mrg i hit an assert in this code but we weren't sure why.

for now, add the ostate and nstate values for further diagnosis
to the assert message.
 1.34 02-Feb-2017  nonaka branches: 1.34.14;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.33 07-Jul-2016  msaitoh branches: 1.33.2; 1.33.4;
KNF. Remove extra spaces. No functional change.
 1.32 20-Jun-2016  knakahara apply if_start_lock() to L2 callers which call ifp->if_start() of device derivers
 1.31 24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.30 10-Jan-2013  christos branches: 1.30.14;
The IEEE80211_F_ flag prefix was used for both the flags in ieee80211_var.h
and for the rates in ieee80211_proto.h; rename the rate bits as _R_ to avoid
confusion.
 1.29 13-Jan-2008  degroote branches: 1.29.4; 1.29.44; 1.29.54;
Fix ieee80211_node leak

We can't use IF_PURGE here because m_pkthdr.rcvif have here a special meaning :
it holds ieee80211_node to which the management frame should be sent and the
node has its reference count bumped.

Introduce ieee80211_drain_ifq which release the node before freeing the mbuf.
Use it instead of IF_PURGE.

From DragonflyBSD
 1.28 16-Nov-2006  christos branches: 1.28.24; 1.28.30; 1.28.38;
__unused removal on arguments; approved by core.
 1.27 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.26 30-Aug-2006  christos branches: 1.26.2; 1.26.4;
fix initializers
 1.25 30-Jun-2006  tacha Make 802.11 devices to work with stealth AP even when scanning
channels marked passive.

From FreeBSD.
 1.24 02-Mar-2006  dyoung branches: 1.24.2; 1.24.10;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.23 18-Nov-2005  skrll branches: 1.23.4; 1.23.6;
Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.22 15-Aug-2005  dyoung branches: 1.22.6;
Don't build sta_disassoc or sta_deauth if IEEE80211_NO_HOSTAP is
defined. Avoids "declared static but not used" warnings.
 1.21 26-Jul-2005  dyoung Resolve conflicts.
 1.20 26-Jun-2005  dyoung branches: 1.20.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP'. I will
use this in the INSTALL kernel to save some space.
 1.19 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.18 26-Feb-2005  perry nuke trailing whitespace
 1.17 07-Sep-2004  enami branches: 1.17.4; 1.17.6;
Adjust caller for net/if_ieee80211subr.c rev 1.11 change; the argument
`reassoc' is replaced with testing if the type is ..._REASSOC_REQ.
 1.16 10-Aug-2004  dyoung Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.15 23-Jul-2004  mycroft branches: 1.15.2;
Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
 1.14 23-Jul-2004  mycroft Hide some code behind an #ifdef IEEE80211_DEBUG.
 1.13 23-Jul-2004  mycroft Yet more DPRINTF() cleanup.
 1.12 23-Jul-2004  mycroft More diff reduction; mainly IEEE80211_DPRINTF() stuff.
 1.11 23-Jul-2004  mycroft Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.10 22-Jul-2004  mycroft In *_fix_rate(), set ni_txrate to the highest common speed so that probe
and authentication responses are sent with a sensible speed. XXX
 1.9 16-Jul-2004  dyoung Send "no carrier"/"active" indications on the routing socket when
(most) 802.11 interfaces change state.
 1.8 30-Apr-2004  dyoung From FreeBSD. Copy the "basic rate" bit from the
ieee80211com to the node's rate set during rate negotiation. Set
a default .11g protection mode.
 1.7 13-Jan-2004  dyoung NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.
 1.6 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.5 13-Oct-2003  dyoung Add Kevin Lahey's power-saving support from the old 802.11 layer
 1.4 28-Sep-2003  dyoung More NetBSD-FreeBSD compatibility changes in the pattern

#ifdef __FreeBSD__
/* FreeBSDism */
#else
/* NetBSDism */
#endif

An important and non-obvious change is in ieee80211_mgmt_output,

#ifdef __FreeBSD__
KASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
#endif

Because NetBSD mbufs are not bzero'd like FreeBSD's, we cannot
count on rcvif == NULL.
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.15.2.8 11-Dec-2005  christos Sync with head.
 1.15.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.15.2.2 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 23-Jul-2004  skrll file ieee80211_proto.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.17.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.4.1 29-Apr-2005  kent sync with -current
 1.20.2.3 21-Jan-2008  yamt sync with head
 1.20.2.2 30-Dec-2006  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.22.6.1 22-Nov-2005  yamt sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.24.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.24.2.2 03-Sep-2006  yamt sync with head.
 1.24.2.1 11-Aug-2006  yamt sync with head
 1.26.4.2 10-Dec-2006  yamt sync with head.
 1.26.4.1 22-Oct-2006  yamt sync with head
 1.26.2.1 18-Nov-2006  ad Sync with head.
 1.28.38.1 19-Jan-2008  bouyer Sync with HEAD
 1.28.30.1 18-Feb-2008  mjf Sync with HEAD.
 1.28.24.1 23-Mar-2008  matt sync with HEAD
 1.29.54.2 03-Dec-2017  jdolecek update from HEAD
 1.29.54.1 25-Feb-2013  tls resync with head
 1.29.44.1 23-Jan-2013  yamt sync with head
 1.29.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.30.14.3 05-Feb-2017  skrll Sync with HEAD
 1.30.14.2 09-Jul-2016  skrll Sync with HEAD
 1.30.14.1 22-Sep-2015  skrll Sync with HEAD
 1.33.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.34.14.8 10-Jun-2019  christos Sync with HEAD
 1.34.14.7 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.34.14.6 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.34.14.5 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.34.14.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.34.14.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.34.14.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.34.14.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.36.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.24 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.23 04-Jan-2017  nonaka branches: 1.23.16; 1.23.32;
Export some 802.11 IE manipulate functions.
 1.22 30-Mar-2013  christos branches: 1.22.12; 1.22.16;
remove trailing whitespace
 1.21 30-Mar-2013  christos remove trailing whitespace.
 1.20 30-Mar-2013  christos EDCA and QOS additions from OpenBSD
 1.19 10-Jan-2013  christos The IEEE80211_F_ flag prefix was used for both the flags in ieee80211_var.h
and for the rates in ieee80211_proto.h; rename the rate bits as _R_ to avoid
confusion.
 1.18 21-Feb-2011  jmcneill branches: 1.18.4; 1.18.14;
add ieee80211_get_rts and ieee80211_get_cts_to_self from openbsd, ok dyoung@
 1.17 28-Jul-2008  christos branches: 1.17.16; 1.17.22; 1.17.24;
- trailing commas in enums
- arithmetic on enums needs cast
from Anon Ymous
 1.16 02-Mar-2006  dyoung branches: 1.16.62; 1.16.64; 1.16.68; 1.16.70; 1.16.72; 1.16.74;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.15 29-Dec-2005  dyoung branches: 1.15.4; 1.15.6;
In atw(4), use ieee80211_compute_duration() to compute IEEE 802.11
Duration and PLCP Length fields, and delete the abominable
atw_frame_setdurs() subroutine.

Make rtw(4) use the new ieee80211_compute_duration() calling
convention.

Add an ieee80211_key argument to ieee80211_compute_duration() and
lightly constify arguments. Get the crypto header length from the
key argument instead of blithely assuming a WEP header. Add some
inline documentation. Account for data padding (IEEE80211_F_DATAPAD).
 1.14 10-Dec-2005  elad Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.13 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.12 26-Jul-2005  dyoung branches: 1.12.6;
Resolve conflicts.
 1.11 27-Jun-2005  dyoung branches: 1.11.2;
rtw: Try to get hardware WEP to work. It seems to work in
the RX direction, but not in the TX direction. The
net80211 crypto framework doesn't seem to cope very well
with the assymetry (I'm probably missing something), so
I will use software WEP for now.

net80211: In ieee80211_compute_duration, figure out whether to add
the WEP header to the packet overhead by checking the
WEP bit in the Frame Control field of the 802.11 header,
instead of checking the IEEE80211_F_PRIVACY flag.

Also, if the WEP bit is present, assume that the frame
described by (wh, len) has already already been WEP
encapsulated, and adjust the payload length accordingly.
XXX that's a grotty hack that I will have to revisit,
later.
 1.10 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.9 26-Feb-2005  perry nuke trailing whitespace
 1.8 04-Jan-2005  dyoung branches: 1.8.2; 1.8.4;
IBSS-merge clean-up, inspired by some Linux patches from Jon Anderson
(mail@janderson.ca): remove ieee80211_ibss_merge's TSFT argument.
Do the TSFT comparison in the drivers (ath, atw). Remove a lot of
extraneous debug statements from ieee80211_ibss_merge.

Set the ieee80211_node's state to IEEE80211_STA_BSS after it's been
copied to the ic_bss, not before.

In struct ieee80211_node, make the ni_tstamp field a union of a
uint64_t and the 8 TSF octets so that it's easier to compare a
neighbor's TSF with the local TSF.

Log IBSS merges (Greg Troxel's suggestion). Also log IBSS creation.
These are rare and important events that deserve to be logged.
 1.7 23-Dec-2004  dyoung Fix a bug in ieee80211_compute_duration: the 802.11 Duration field
in an 802.11 unicast data packet is equal to the duration of the
SIFS and Acknowledgement. That is, the amount of time reserved
*after* the packet has finished transmitting.

Change the arguments to ieee80211_compute_duration: pass the entire
packet length, not just the payload length. Add a 'debug' argument
to ieee80211_compute_duration and its helper subroutine,
ieee80211_compute_duration1.

If debug != 0, ieee80211_compute_duration printfs its arguments
and several local variables.

In rtw(4), load the 802.11 Duration field with the result from
ieee80211_compute_duration.
 1.6 19-Dec-2004  dyoung Define for more bits in the Service field of the 802.11 PLCP Header.

For use by the subroutine ieee80211_compute_duration, add struct
ieee80211_duration, and #define a number of microsecond constants
used for the transmit timing of 802.11 packets.

Add the subroutine ieee80211_compute_duration, which computes for
any packet the appropriate 802.11 Duration field, the PLCP Length
field, as well as the Duration and Length fields for an RTS frame.

atw(4), rtw(4), future drivers, and possibly ath(4) will share
ieee80211_compute_duration.
 1.5 28-Jul-2004  dyoung branches: 1.5.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.
 1.4 24-Jul-2004  dyoung Pull the IBSS merge logic out of atw and into net80211, since ath
will eventually share it.

In the IBSS merge logic, check conditions in a different order so
that they run faster in the common case---no merge. Fix the
rate-limiting on the debug outputs (enabled by IFF_LINK0).
 1.3 13-Oct-2003  dyoung Add Kevin Lahey's power-saving support from the old 802.11 layer
 1.2 14-Sep-2003  dyoung Insert RCSIDs.
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.3 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.2 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.5.2.8 11-Dec-2005  christos Sync with head.
 1.5.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 28-Jul-2004  skrll file ieee80211_proto.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.8.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.2.1 29-Apr-2005  kent sync with -current
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.12.6.1 22-Nov-2005  yamt sync with head.
 1.15.6.1 22-Apr-2006  simonb Sync with head.
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.16.74.1 19-Oct-2008  haad Sync with HEAD.
 1.16.72.1 31-Jul-2008  simonb Sync with head.
 1.16.70.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.16.68.1 04-May-2009  yamt sync with head.
 1.16.64.1 28-Sep-2008  mjf Sync with HEAD.
 1.16.62.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.17.24.1 05-Mar-2011  bouyer Sync with HEAD
 1.17.22.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.16.1 05-Mar-2011  rmind sync with head
 1.18.14.3 03-Dec-2017  jdolecek update from HEAD
 1.18.14.2 23-Jun-2013  tls resync from head
 1.18.14.1 25-Feb-2013  tls resync with head
 1.18.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.4.1 23-Jan-2013  yamt sync with head
 1.22.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.12.1 05-Feb-2017  skrll Sync with HEAD
 1.23.32.1 01-Aug-2021  thorpej Sync with HEAD.
 1.23.16.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.23.16.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.23.16.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.23.16.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_radiotap.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.25 05-Oct-2019  mrg remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned. codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
 1.24 25-Feb-2011  tron branches: 1.24.56;
Remove duplicate definitions which break the build.
 1.23 25-Feb-2011  cegger fix botched line break. How did this even compile for me?
 1.22 25-Feb-2011  cegger sync with FreeBSD rev 1.11. No binary changes.
 1.21 19-Oct-2009  rmind branches: 1.21.4; 1.21.6; 1.21.8;
Drop 3rd and 4th clauses from David Young's license.
Reviewed and approved by dyoung@ (copyright holder).
 1.20 08-Sep-2008  gmcgarry Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.19 28-Jul-2008  christos - trailing commas in enums
- arithmetic on enums needs cast
from Anon Ymous
 1.18 26-Mar-2007  dyoung branches: 1.18.28; 1.18.30; 1.18.34; 1.18.36; 1.18.38; 1.18.40;
Reference the right flag,
s/IEEE80211_RADIOTAP_F_FCS/IEEE80211_RADIOTAP_F_BADFCS/.
 1.17 26-Mar-2007  dyoung Define four new radiotap fields per discussions with John Bicket, Sam
Leffler, and others:

IEEE80211_RADIOTAP_RX_FLAGS = 14,
IEEE80211_RADIOTAP_TX_FLAGS = 15,
IEEE80211_RADIOTAP_RTS_RETRIES = 16,
IEEE80211_RADIOTAP_DATA_RETRIES = 17,

I describe the fields in the manual page and in comments in the
header file (cross-referenced by the manual page).
 1.16 06-Jan-2007  dyoung branches: 1.16.2; 1.16.6; 1.16.8; 1.16.10;
Add a hint to the compiler that the radiotap header requires 8-byte
alignment. This

1 helps GCC make better code for architectures such as ARM
where it would otherwise do a lot of byte-loads and shifts
to load a multi-byte word, and

2 ensures that the compiler will add no padding between a
radiotap header and a 64-bit or narrower field that
follows it.
 1.15 12-Mar-2006  dyoung branches: 1.15.10;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.
 1.14 10-Dec-2005  elad branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.13 08-Dec-2005  dyoung Add flag IEEE80211_RADIOTAP_F_BADFCS for packets whose checksum
doesn't match their contents. While I'm here, remove the mention
of field IEEE80211_RADIOTAP_FCS, which wasn't adopted.
 1.12 26-Jul-2005  dyoung Resolve conflicts.
 1.11 22-Jun-2005  dyoung branches: 1.11.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.10 04-Jan-2005  dyoung Fix a typo.
 1.9 06-Jun-2004  dyoung branches: 1.9.2;
Define IEEE80211_RADIOTAP_HDRLEN, the length of a radiotap header.
 1.8 30-Apr-2004  dyoung Sync with FreeBSD. Some apps get confused when the FCS comes at
the end of the tapped frame, so stick it into the radiotap header.
 1.7 29-Mar-2004  dyoung Add missing flags IEEE80211_CHAN_DYN and IEEE80211_CHAN_GFSK, needed
by userland programs to interpret radiotap channel indications.
 1.6 29-Mar-2004  dyoung Whitespace nits, esp. change #define<SPACE> to #define<TAB>.
 1.5 08-Dec-2003  dyoung Forget the tcpdump $Header$.
 1.4 07-Dec-2003  dyoung Updates to 802.11 radiotap. The _DB_ flags were used everywhere to
denote a signed dBm Rx power, so rename them to _DBM_ and change
the signedness. Add new _DB_ flags for unsigned Rx power measured
from an arbitrary reference.

Try to synchronize net80211/ieee80211_radiotap.h with my tcpdump
sources (which public tcpdump has not seen, yet) and with FreeBSD.
 1.3 16-Nov-2003  dyoung Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
 1.2 14-Sep-2003  dyoung Insert RCSIDs.
 1.1 07-Sep-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.3 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.2 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.1 07-Sep-2003  dyoung Bring net80211/ sources up-to-date with FreeBSD.

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
 1.9.2.7 11-Dec-2005  christos Sync with head.
 1.9.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.9.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.2 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 06-Jun-2004  skrll file ieee80211_radiotap.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.11.2.3 03-Sep-2007  yamt sync with head.
 1.11.2.2 26-Feb-2007  yamt sync with head.
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.14.10.1 19-Apr-2006  elad sync with head.
 1.14.8.1 13-Mar-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.10.1 12-Jan-2007  ad Sync with head.
 1.16.10.1 29-Mar-2007  reinoud Pullup to -current
 1.16.8.1 11-Jul-2007  mjf Sync with head.
 1.16.6.1 10-Apr-2007  ad Sync with head.
 1.16.2.1 15-Apr-2007  yamt sync with head.
 1.18.40.1 19-Oct-2008  haad Sync with HEAD.
 1.18.38.1 31-Jul-2008  simonb Sync with head.
 1.18.36.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.18.36.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.18.34.2 11-Mar-2010  yamt sync with head
 1.18.34.1 04-May-2009  yamt sync with head.
 1.18.30.1 28-Sep-2008  mjf Sync with HEAD.
 1.18.28.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.21.8.1 05-Mar-2011  bouyer Sync with HEAD
 1.21.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.1 05-Mar-2011  rmind sync with head
 1.24.56.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.24.56.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.24.56.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_ratectl.c was initially added on branch phil-wifi.
 1.1.2.5 19-Nov-2019  phil Add a FreeBSD ifdef
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_ratectl.h was initially added on branch phil-wifi.
 1.1.2.5 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.1.2.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.2.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_ratectl_none.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_regdomain.c was initially added on branch nick-net80211-sync.
 1.1.56.4 10-Jun-2019  christos Sync with HEAD
 1.1.56.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_regdomain.c was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_regdomain.h was initially added on branch nick-net80211-sync.
 1.1.56.3 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_regdomain.h was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.21 27-Sep-2016  christos branches: 1.21.16;
- use ether_snprintf() so that we don't overwrite our buffer for printing
ethernet-like addresses
- make this compile againw without IEEE80211_DEBUG.
 1.20 07-Jul-2016  msaitoh branches: 1.20.2;
KNF. Remove extra spaces. No functional change.
 1.19 07-Apr-2014  pooka branches: 1.19.4;
Use module-compatible sysctl init instead of link sets.
 1.18 25-Feb-2014  pooka branches: 1.18.2;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.17 19-Oct-2009  rmind branches: 1.17.12; 1.17.22; 1.17.26;
Drop 3rd and 4th clauses from David Young's license.
Reviewed and approved by dyoung@ (copyright holder).
 1.16 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.15 24-Jun-2008  gmcgarry branches: 1.15.2; 1.15.4;
Replace gcc-style designated initialisers with c99-style.
 1.14 30-Aug-2006  christos branches: 1.14.50; 1.14.52; 1.14.56; 1.14.58; 1.14.60;
comment out impossible comparisons.
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.8;
merge ktrace-lwp.
 1.12 26-Jul-2005  dyoung Resolve conflicts.
 1.11 22-Jun-2005  dyoung branches: 1.11.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.10 20-Jun-2005  atatat Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.9 26-Feb-2005  perry nuke trailing whitespace
 1.8 23-Jul-2004  mycroft branches: 1.8.2; 1.8.6; 1.8.8;
Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.7 25-May-2004  atatat Sysctl descriptions under net subtree (net.key not done)
 1.6 06-May-2004  dyoung Following Andrew Brown's suggestion, move net.ieee80211 to
net.link.ieee80211. The convention is that nodes directly under
net are protocol families (PF_*).

Also, simplify the sysctl setup for net80211 and rssadapt, following
another suggestion by Andrew.
 1.5 06-May-2004  dyoung Create ieee80211_rssadapt_debug to control rssadapt(9) debug messages
independently from net80211 debug messages. Create a new sysctl,
net.ieee80211.rssadapt.debug, for turning the debug messages on
and off.

Create a new sysctl, net.ieee80211.rssadapt.expavgctl, to control
the rate of decay for the exponential averages used by rssadapt(9).
 1.4 29-Mar-2004  dyoung Get the sense of ra->ra_nok and ra->ra_nfail right. They indicate
successes and failures, respectively, not the other way around.
 1.3 17-Mar-2004  dyoung In wi(4), wi_choose_rate used to contain device-independent code.
I have pulled that code into the function ieee80211_rssadapt_choose
so that I can re-use it in ath(4), atw(4), and in other drivers.

In rssadapt(9), I have also created a struct ieee80211_rssadapt_expavgctl
that contains parameters for rate adaptation. When IEEE80211_RSSADAPT_DEBUG
is enabled, I will using sysctl to expose an ieee80211_rssadapt_expavgctl
for each wireless device.

Also in rssadapt(9), I have introduced an interpolate() macro which
makes the exponential-averaging code more compact.
 1.2 07-Dec-2003  dyoung Oops. Make it compile with 'options IEEE80211_DEBUG'.
 1.1 26-Oct-2003  dyoung Support data-rate adaptation loosely based on the paper "Link
Adaptation Strategy for IEEE 802.11 WLAN via Received Signal Strength
Measurement" by Javier del Prado Pavon and Sunghyun Choi. This
module should provide faster adaptation and higher throughput than
Lucent's rate-adaptation scheme.

Individual drivers need to be modified to use this module. Patches
for wi(4) are forthcoming.
 1.8.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.6.1 29-Apr-2005  kent sync with -current
 1.8.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.2 03-Aug-2004  skrll Sync with HEAD
 1.8.2.1 23-Jul-2004  skrll file ieee80211_rssadapt.c was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.11.2.1 30-Dec-2006  yamt sync with head.
 1.13.8.1 03-Sep-2006  yamt sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.60.1 27-Jun-2008  simonb Sync with head.
 1.14.58.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.14.56.2 11-Mar-2010  yamt sync with head
 1.14.56.1 04-May-2009  yamt sync with head.
 1.14.52.2 17-Jan-2009  mjf Sync with HEAD.
 1.14.52.1 29-Jun-2008  mjf Sync with HEAD.
 1.14.50.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.15.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.17.26.1 18-May-2014  rmind sync with head
 1.17.22.2 03-Dec-2017  jdolecek update from HEAD
 1.17.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.2.1 10-Aug-2014  tls Rebase.
 1.19.4.2 05-Oct-2016  skrll Sync with HEAD
 1.19.4.1 09-Jul-2016  skrll Sync with HEAD
 1.20.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.21.16.5 10-Jun-2019  christos Sync with HEAD
 1.21.16.4 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.21.16.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.21.16.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.21.16.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.9 08-Apr-2016  roy branches: 1.9.18;
Revert prior.
 1.8 06-Apr-2016  roy ieee80211 users in Other OS export rssi and noise as int8_t.
We should not be the odd one out for no good reason and the majority
of the ieee80211 drivers treat rssi as int8_t.
 1.7 19-Oct-2009  rmind branches: 1.7.40;
Drop 3rd and 4th clauses from David Young's license.
Reviewed and approved by dyoung@ (copyright holder).
 1.6 10-Dec-2005  elad branches: 1.6.68; 1.6.74;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.5 26-Jul-2005  dyoung Resolve conflicts.
 1.4 26-Feb-2005  perry branches: 1.4.4;
nuke trailing whitespace
 1.3 06-May-2004  dyoung branches: 1.3.2; 1.3.6; 1.3.8;
Create ieee80211_rssadapt_debug to control rssadapt(9) debug messages
independently from net80211 debug messages. Create a new sysctl,
net.ieee80211.rssadapt.debug, for turning the debug messages on
and off.

Create a new sysctl, net.ieee80211.rssadapt.expavgctl, to control
the rate of decay for the exponential averages used by rssadapt(9).
 1.2 17-Mar-2004  dyoung In wi(4), wi_choose_rate used to contain device-independent code.
I have pulled that code into the function ieee80211_rssadapt_choose
so that I can re-use it in ath(4), atw(4), and in other drivers.

In rssadapt(9), I have also created a struct ieee80211_rssadapt_expavgctl
that contains parameters for rate adaptation. When IEEE80211_RSSADAPT_DEBUG
is enabled, I will using sysctl to expose an ieee80211_rssadapt_expavgctl
for each wireless device.

Also in rssadapt(9), I have introduced an interpolate() macro which
makes the exponential-averaging code more compact.
 1.1 26-Oct-2003  dyoung Support data-rate adaptation loosely based on the paper "Link
Adaptation Strategy for IEEE 802.11 WLAN via Received Signal Strength
Measurement" by Javier del Prado Pavon and Sunghyun Choi. This
module should provide faster adaptation and higher throughput than
Lucent's rate-adaptation scheme.

Individual drivers need to be modified to use this module. Patches
for wi(4) are forthcoming.
 1.3.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.6.1 29-Apr-2005  kent sync with -current
 1.3.2.6 11-Dec-2005  christos Sync with head.
 1.3.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Aug-2004  skrll Sync with HEAD
 1.3.2.1 06-May-2004  skrll file ieee80211_rssadapt.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.4.4.1 21-Jun-2006  yamt sync with head.
 1.6.74.1 11-Mar-2010  yamt sync with head
 1.6.68.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.7.40.1 22-Apr-2016  skrll Sync with HEAD
 1.9.18.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.9.18.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_scan.c was initially added on branch nick-net80211-sync.
 1.1.56.6 10-Jun-2019  christos Sync with HEAD
 1.1.56.5 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.56.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.56.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_scan.c was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_scan.h was initially added on branch nick-net80211-sync.
 1.1.56.3 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_scan.h was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 22-Feb-2008  skrll branches: 1.1.2;
file ieee80211_scan_ap.c was initially added on branch nick-net80211-sync.
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 22-Feb-2008  skrll branches: 1.1.2; 1.1.56;
file ieee80211_scan_sta.c was initially added on branch nick-net80211-sync.
 1.1.56.8 10-Jun-2019  christos Sync with HEAD
 1.1.56.7 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.1.56.6 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.1.56.5 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.56.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.1.56.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.56.2 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1.56.1 22-Feb-2008  phil file ieee80211_scan_sta.c was added on branch phil-wifi on 2018-06-28 21:03:07 +0000
 1.1.2.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_scan_sw.c was initially added on branch phil-wifi.
 1.1.2.5 10-Jun-2019  christos Sync with HEAD
 1.1.2.4 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.1.2.3 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_scan_sw.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_sta.c was initially added on branch phil-wifi.
 1.1.2.7 27-Apr-2020  nat Make ostate reflect the updated state.
 1.1.2.6 10-Jun-2019  christos Sync with HEAD
 1.1.2.5 15-Aug-2018  phil Final changes for 200 hour contract. Still a lot of work to do.
With these changes, Station mode works with an open AP.
 1.1.2.4 03-Aug-2018  phil State Save:
Scanning works, can see the broadcasts and stations.
Association appears to work. (open networks only, no encryption yet.)
IP traffic doesn't flow yet, not sure where the error is.
Added back more NetBSD ioctls not in the FreeBSD code. Still have
more to go.
Updated my TESTWIFI kernel config.
 1.1.2.3 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_sta.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_superg.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_superg.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.9 19-Oct-2009  rmind branches: 1.9.64;
Drop 3rd and 4th clauses from David Young's license.
Reviewed and approved by dyoung@ (copyright holder).
 1.8 25-Dec-2007  perry branches: 1.8.4; 1.8.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.7 10-Dec-2005  elad branches: 1.7.46; 1.7.52; 1.7.56; 1.7.60;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.6 20-Nov-2005  dyoung Mark ieee80211_nodes with their node-table membership: scan table
or client/neighbor table.

While I'm here, assert that ieee80211_getmgtframe returns a frame
that starts on a 32-bit boundary.
 1.5 26-Jul-2005  dyoung branches: 1.5.6;
Resolve conflicts.
 1.4 26-Jun-2005  dyoung branches: 1.4.2;
Add some debug messages to ieee80211_notify_node_{join,leave}.

Change the way we walk 802.11 peers/clients: for each eligible
interface, walk the ic_sta (peers/clients) table, first; walk the
ic_scan (scan results) table, second; then visit the ic_bss (node
for the network joined/created by the interface).
 1.3 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.2 26-Feb-2005  perry nuke trailing whitespace
 1.1 16-Jul-2004  dyoung branches: 1.1.2; 1.1.6; 1.1.8;
Add sysctl access to 802.11 node tables, step #1.
 1.1.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 29-Apr-2005  kent sync with -current
 1.1.2.7 11-Dec-2005  christos Sync with head.
 1.1.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 16-Jul-2004  skrll file ieee80211_sysctl.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.4.2.2 21-Jan-2008  yamt sync with head
 1.4.2.1 21-Jun-2006  yamt sync with head.
 1.5.6.1 22-Nov-2005  yamt sync with head.
 1.7.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.7.56.1 26-Dec-2007  ad Sync with head.
 1.7.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.46.1 09-Jan-2008  matt sync with HEAD
 1.8.10.1 11-Mar-2010  yamt sync with head
 1.8.4.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.9.64.1 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_tdma.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_tdma.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.35 24-Jun-2023  msaitoh Fix typo in comment.
 1.34 15-Mar-2020  thorpej Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.33 08-May-2018  maxv branches: 1.33.2;
Remove three useless debug messages, remove meaningless XXXs, and remove
ieee80211_note_frame (unused).
 1.32 16-Jan-2018  maxv branches: 1.32.2;
Start cleaning up this mess.
 1.31 27-Sep-2016  christos - use ether_snprintf() so that we don't overwrite our buffer for printing
ethernet-like addresses
- make this compile againw without IEEE80211_DEBUG.
 1.30 08-Apr-2016  roy branches: 1.30.2;
Revert prior.
 1.29 06-Apr-2016  roy ieee80211 users in Other OS export rssi and noise as int8_t.
We should not be the odd one out for no good reason and the majority
of the ieee80211 drivers treat rssi as int8_t.
 1.28 17-Jan-2010  pooka branches: 1.28.22; 1.28.40;
Forward declare struct bpf_if and use that as the type for bpf_if
instead of "void *". Buys us oo times the type-safety for 0 times
the price.
(no functional change)
 1.27 11-Dec-2008  alc Doh! What should have happened happens ...

Restore the check to see if the chip does MIC correctly when
WME is turned on. Btw, define IEEE80211_C_WME_TKIPMIC and fix build :/
 1.26 04-Mar-2007  christos branches: 1.26.34; 1.26.36; 1.26.40; 1.26.46; 1.26.50; 1.26.52; 1.26.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 30-Jun-2006  tacha branches: 1.25.10;
Make 802.11 devices to work with stealth AP even when scanning
channels marked passive.

From FreeBSD.
 1.24 28-Mar-2006  dyoung branches: 1.24.4;
Revamp ieee80211_get_rate. Now it does not use the rateset in the
ic->ic_bss, but it uses the rateset in its new ieee80211_node
argument, instead. If the rate is fixed by ic->ic_fixed_rate, but
the fixed rate is not in the node's rateset, choose a reasonable
default: prefer the lowest basic rate or, if there is no basic
rate, prefer the lowest rate, period.

Change a printf complaint to a debug message.

Adapt drivers to suit new ieee80211_get_rate calling convention.

XXX I really need to replace ieee80211_get_rate with a bitrate
XXX adaptation algorithm. Soon, soon....
 1.23 02-Mar-2006  dyoung branches: 1.23.2; 1.23.4; 1.23.6;
Miscellaneous ath(4) and net80211 updates and bug-fixes coming from
sam@ and various open source repositories:

ath(4):

Ignore "phantom" beacon misses: should stabilize connections
to access points (no more ceaseless link-UP/DOWN indications).
Also, re-synchronize beacon timer using the TSF in the
first beacon received after joining a BSS---this should
also help suppress spurious beacon misses. I am hopeful
that this will help ath(4) lossage reported by perry@ and
smb@.

Add new configuration through sysctl.

Use a shorter calibration interval until IQ calibration
finishes.

Report antenna noise through radiotap.

Rudiments of Radar Detection / Dynamic Frequency Selection.

Update to HAL version 0.9.16.13.

Update open sources for changes to the HAL API.

Add HALs for additional architectures: add big-endian ELF
HALs for sparc64 and for PowerPC. Also add a Alpha HAL.
These new HALs are untested under NetBSD.

ath(4) + net80211:

Make the multicast transmit rate configurable by ioctl.

Miscellaneous bug fixes.
 1.22 10-Dec-2005  elad branches: 1.22.4; 1.22.6;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.21 18-Nov-2005  skrll Resolve conflicts and adapt to NetBSD.

Thanks to dyoung@, scw@, and perry@ for help testing.

2005-08-30 15:27 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes

2005-08-13 18:50 sam

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl

2005-08-13 18:31 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks

2005-08-10 18:42 sam

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks

2005-08-10 17:22 sam

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks

2005-08-09 11:19 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days

2005-08-08 19:46 sam

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks

2005-08-08 06:49 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week

2005-08-08 04:30 sam

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week

2005-08-06 05:57 sam

fix debug msg typo

MFC after: 3 days

2005-08-06 05:56 sam

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days

2005-07-31 07:12 sam

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days

2005-07-27 05:41 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days

2005-07-27 03:53 sam

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days

2005-07-23 01:16 sam

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table

2005-07-23 00:25 sam

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days

2005-07-22 22:11 sam

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days

2005-07-22 21:48 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days

2005-07-22 18:57 sam

simplify ic_newassoc callback

MFC after: 3 days

2005-07-22 18:54 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days

2005-07-22 18:50 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days

2005-07-22 18:45 sam

simplify tim callback api

MFC after: 3 days

2005-07-22 18:42 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:36 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days

2005-07-22 18:31 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days

2005-07-22 18:29 sam

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days

2005-07-22 18:21 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days

2005-07-22 18:16 sam

missed one in last commit; add device name to discard msgs

2005-07-22 18:13 sam

include device name in discard msgs

2005-07-22 18:12 sam

add diag msgs for frames discarded because the direction field is wrong

2005-07-22 18:08 sam

split data frame delivery out to a new function ieee80211_deliver_data

2005-07-22 18:00 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days

2005-07-22 17:55 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h

2005-07-22 17:50 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1

2005-07-22 17:37 sam

add flags missed in last merge

2005-07-22 17:36 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days

2005-07-22 06:17 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong

2005-07-22 06:15 sam

remove excess whitespace

2005-07-22 05:55 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days

2005-07-11 04:06 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)

2005-07-11 04:00 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)
 1.20 26-Jul-2005  dyoung branches: 1.20.6;
Resolve conflicts.
 1.19 22-Jun-2005  dyoung branches: 1.19.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.18 10-Aug-2004  dyoung Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue. Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver. Every node in the table with ni_refcnt=0
is eligible to be garbage-collected. The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now. A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.17 28-Jul-2004  dyoung branches: 1.17.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.
 1.16 24-Jul-2004  dyoung Pull the IBSS merge logic out of atw and into net80211, since ath
will eventually share it.

In the IBSS merge logic, check conditions in a different order so
that they run faster in the common case---no merge. Fix the
rate-limiting on the debug outputs (enabled by IFF_LINK0).
 1.15 23-Jul-2004  mycroft Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
 1.14 23-Jul-2004  mycroft Changes from madwifi:
Abstract some of the node management code into separate functions, and use them
throughout, plugging memory leaks.
Allocate the AID allocation map dynamically.
 1.13 23-Jul-2004  mycroft IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY
 1.12 23-Jul-2004  dyoung Don't #define IEEE80211_DEBUG here.
 1.11 23-Jul-2004  mycroft Diff reduction vs. madwifi.
Change the signature of IEEE80211_DPRINTF() so that it uses a bitmask, and
convert some of the if_printf()s to IEEE80211_DPRINTF()s. XXX I'm using a
global variable at the moment rather than per-interface.
 1.10 23-Jul-2004  mycroft IEEE80211_MAX_AID has been renamed to IEEE80211_AID_MAX.
 1.9 16-Jul-2004  dyoung Move ieee80211_channel definition and channel flags into
ieee80211_channel.h, step #2.
 1.8 16-Jul-2004  dyoung Chain ieee80211coms together so that the 802.11 sysctls can walk
them all to retrieve their node tables.
 1.7 06-May-2004  dyoung Add a sysctl, net.ieee80211.debug, for turning debug messages on
and off.

Add a sysctl, net.ieee80211.maxinact, for adjusting the node time-out
interval. After net.ieee80211.maxinact seconds of inactivity, an
AP will purge a peer/client-record. Now the client has to reassociate.
 1.6 30-Apr-2004  dyoung From FreeBSD. Add protection mode bits. Get rid of
the RCVMGT capability.
 1.5 14-Dec-2003  dyoung Synchronize with FreeBSD sources from 12 Dec 2003.
 1.4 13-Oct-2003  dyoung * Add support for frequency-hopping PHY mode.

* Do not enable debugging by default w/ IEEE80211_DEBUG.

* Add Kevin Lahey's power-saving support from the old 802.11 layer
 1.3 14-Sep-2003  dyoung Insert RCSIDs.
 1.2 07-Sep-2003  dyoung First stab at producing a unified NetBSD/FreeBSD 802.11 layer,
striving to keep the diffs short and simple.

* Replace FreeBSDisms (e.g. struct arpcom) with conditionally-compiled
NetBSDism (struct ethercom).

* Add compatibility shims in ieee80211_compat.*: provide NetBSD with
if_printf, for example.

* Convert FreeBSD node mutex uses to generic node critical-section
protection (ieee80211_node_critsect_begin, _end), replace
FreeBSD atomic arithmetic with generic alternative, and implement
generics in NetBSD

* Provide NetBSD-style 802.11 ioctls

* Style nits
 1.1 30-Aug-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.6 18-Nov-2005  skrll Import FreeBSD's net80211(9) of 1-nov-2005
 1.1.1.5 26-Jul-2005  dyoung Import FreeBSD's net80211(9) of 2005-07-11
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's net80211 of 28-apr-2004
 1.1.1.2 13-Dec-2003  dyoung Import FreeBSD's net80211 of 12 Dec 2003
 1.1.1.1 30-Aug-2003  dyoung Pull in net80211/ from FreeBSD. This contains Sam Leffler's
enhancements to the 802.11 layer, which are necessary for ath(4),
the Atheros-chipset driver.
 1.17.2.7 11-Dec-2005  christos Sync with head.
 1.17.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.17.2.2 03-Aug-2004  skrll Sync with HEAD
 1.17.2.1 28-Jul-2004  skrll file ieee80211_var.h was added on branch ktrace-lwp on 2004-08-03 10:54:21 +0000
 1.19.2.3 03-Sep-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.20.6.1 22-Nov-2005  yamt sync with head.
 1.22.6.1 22-Apr-2006  simonb Sync with head.
 1.22.4.1 09-Sep-2006  rpaulo sync with head
 1.23.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.23.4.1 19-Apr-2006  elad sync with head.
 1.23.2.2 11-Aug-2006  yamt sync with head
 1.23.2.1 01-Apr-2006  yamt sync with head.
 1.24.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.25.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.58.1 21-Apr-2010  matt sync to netbsd-5
 1.26.52.1 07-Aug-2009  snj Apply patch (requested by jmcneill in ticket 775):
Update to the open source atheros HAL.
 1.26.50.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.46.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.26.40.2 11-Mar-2010  yamt sync with head
 1.26.40.1 04-May-2009  yamt sync with head.
 1.26.36.1 17-Jan-2009  mjf Sync with HEAD.
 1.26.34.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.
 1.28.40.2 05-Oct-2016  skrll Sync with HEAD
 1.28.40.1 22-Apr-2016  skrll Sync with HEAD
 1.28.22.1 03-Dec-2017  jdolecek update from HEAD
 1.30.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.32.2.1 21-May-2018  pgoyette Sync with HEAD
 1.33.2.6 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.33.2.5 20-Jul-2018  phil State save:
urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
add missing routines, need to get them filled out correctly.
80211: Add back some NetBSD ioctls, start working on the sysctl tree.
 1.33.2.4 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.33.2.3 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.33.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.33.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_vht.c was initially added on branch phil-wifi.
 1.1.2.3 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_vht.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_wds.c was initially added on branch phil-wifi.
 1.1.2.4 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 28-Jul-2018  phil End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
 1.1.2.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.1 28-Jun-2018  phil branches: 1.1.2;
file ieee80211_wds.h was initially added on branch phil-wifi.
 1.1.2.2 28-Jun-2018  phil Add RCS ID at the top of all the files.
 1.1.2.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.5 27-Feb-2006  dyoung branches: 1.5.62; 1.5.158;
Register authenticators for 802.1x, WPA.
 1.4 11-Dec-2005  christos branches: 1.4.2; 1.4.4; 1.4.6;
merge ktrace-lwp.
 1.3 26-Jul-2005  dyoung branches: 1.3.6;
Resolve conflicts.
 1.2 22-Jun-2005  dyoung branches: 1.2.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 21-Jun-2005  dyoung branches: 1.1.1;
Initial revision
 1.1.1.1 21-Jun-2005  dyoung Import FreeBSD's net80211(9) of 2005-05-18
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 26-Jul-2005  skrll file ieee80211_xauth.c was added on branch ktrace-lwp on 2005-11-10 14:10:51 +0000
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.4.2.1 01-Mar-2006  yamt sync with head.
 1.5.158.4 10-Jun-2019  christos Sync with HEAD
 1.5.158.3 16-Jul-2018  phil State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
 1.5.158.2 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.5.158.1 28-Jun-2018  phil Start of WiFi refresh. Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet. ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].
 1.5.62.1 22-Feb-2008  skrll Beginning of a sync with net80211 from FreeBSD. Lots to do.

Sources taken from 2008-02-22.

RSS XML Feed