Commit Graph

202 Commits

Author SHA1 Message Date
atatat df13e3579e 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.
2005-06-20 02:49:18 +00:00
atatat 420d91208b 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.
2005-06-09 02:19:59 +00:00
christos b71716c913 Unconst sysctl_query... hi atatat 2005-05-30 04:16:56 +00:00
christos a1f8461e23 avoid shadowing of m1 2005-05-30 04:16:10 +00:00
perry f07677dd81 nuke trailing whitespace 2005-02-26 22:45:09 +00:00
dyoung 89e3661699 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.
2005-01-21 22:57:30 +00:00
dyoung 07a485e480 Cosmetic: shorten a staircase. 2005-01-16 11:37:58 +00:00
dyoung a4bb6a73ed 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.
2005-01-16 11:36:54 +00:00
dyoung 5dc6377838 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.
2005-01-04 00:56:51 +00:00
dyoung 4c03aed52f In ieee80211_getmbuf, remove the #ifdef __FreeBSD__ code. Check
for MCLGET success using the (m->m_flags & M_EXT) idiom.
2005-01-04 00:36:18 +00:00
dyoung eeb33155cd Fix a typo. 2005-01-04 00:34:58 +00:00
dyoung 45d5300ab2 Cosmetic: remove some dead code. Join some lines. 2004-12-27 10:47:57 +00:00
dyoung 07e67ea7d6 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.
2004-12-27 09:25:05 +00:00
mycroft 1989546a4c GC unused stuff. 2004-12-27 05:36:08 +00:00
mycroft e3c9106a08 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.
2004-12-27 05:35:33 +00:00
mycroft 9fc969bfcb Update a comment. 2004-12-27 01:57:58 +00:00
mycroft 06e4fe7f62 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.
2004-12-27 01:51:49 +00:00
dyoung 24ba04b962 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.
2004-12-23 06:08:52 +00:00
dyoung 8828aae46c #define the difference in microseconds between a fast and a slow
preamble and PLCP header.
2004-12-23 05:25:41 +00:00
dyoung 8fff1555a5 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()....
2004-12-20 23:03:39 +00:00
dyoung 81eefc6f1a 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.
2004-12-19 08:08:06 +00:00
dyoung 49cfbd0442 Drivers are not expected to call ieee80211_find_node_for_beacon,
so don't increase the reference count on a node before returning
it.
2004-10-04 07:35:48 +00:00
dyoung b01c9a3223 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.
2004-10-04 07:17:41 +00:00
enami a4ee532ba4 Adjust caller for net/if_ieee80211subr.c rev 1.11 change; the argument
`reassoc' is replaced with testing if the type is ..._REASSOC_REQ.
2004-09-07 01:07:40 +00:00
dyoung 90691ca787 Cosmetic: remove extraneous blank line. 2004-08-10 21:58:31 +00:00
dyoung 8abb07d1ac 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.
2004-08-10 00:57:20 +00:00
mycroft 8e9a02ab5e Put a check for an impossible case inside '#ifdef DIAGNOSTIC'. 2004-07-30 17:45:21 +00:00
mycroft 2a134a8f3c Change the basic rate list for 11g to contain just the 11b modes, mimicking the
behavior of other systems.
2004-07-30 17:05:18 +00:00
dyoung 59380646e3 For interoperability with legacy equipment, do not enable short
preamble by default.
2004-07-30 04:32:10 +00:00
dyoung 8205ae2288 Change sysctl range-checking: net.link.ieee80211.debug values are
now 0x0 -> 0xffffffff, not 0 -> 2.
2004-07-30 04:29:52 +00:00
mycroft 198c3a9495 Whoops, rearrange the function so the TAILQ_EMPTY() DTRT. 2004-07-29 23:17:29 +00:00
mycroft 3fbc463c40 Don't reset the inactivity timer every time we create a node -- this could
cause us to stall and never time out anything.
2004-07-29 22:59:19 +00:00
mycroft 88a8480ea3 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.)
2004-07-29 22:28:05 +00:00
dyoung 6f9ff5e059 Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks.  Change the reference IBSS-merge implementation in atw
to match.
2004-07-28 08:12:49 +00:00
dyoung 1d27a29121 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.
2004-07-28 08:11:03 +00:00
mycroft feabadd671 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.
2004-07-26 16:31:47 +00:00
dyoung f704e633b9 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.
2004-07-25 05:21:36 +00:00
dyoung 4388de1ef5 Undo last: Sam Leffler has shown me a better way to avoid ad hoc
lossage.
2004-07-25 05:08:33 +00:00
dyoung ce488d2bf7 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).
2004-07-24 23:53:49 +00:00
dyoung bd6e05d5bd ieee80211_node_leave runs in all modes, not just hostap mode, so
it must not IASSERT that it is in hostap mode.
2004-07-24 04:44:51 +00:00
dyoung 3fcb69ddbf NetBSD does not define ieee80211_node_refcnt(). Use ni->ni_refcnt,
instead.
2004-07-24 04:07:01 +00:00
mycroft daed6ac762 First part of this file -- ieee80211_node locking macros. 2004-07-23 10:16:00 +00:00
mycroft f526e7326b Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.
2004-07-23 10:15:13 +00:00
mycroft 3551583171 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.
2004-07-23 09:22:15 +00:00
mycroft e47eed0be7 Hide some code behind an #ifdef IEEE80211_DEBUG. 2004-07-23 08:38:08 +00:00
mycroft 50d44f4f07 IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY 2004-07-23 08:31:39 +00:00
mycroft 75f8366d87 Yet more DPRINTF() cleanup. 2004-07-23 08:25:25 +00:00
mycroft a02b46e848 More diff reduction; mainly IEEE80211_DPRINTF() stuff. 2004-07-23 08:05:00 +00:00
dyoung a70c2acfb1 Don't #define IEEE80211_DEBUG here. 2004-07-23 07:24:21 +00:00
dyoung e135a8a4a9 Fix ieee80211_needs_rxnode so that net80211 does something akin to
a passive scan for APs and IBSSs, always, but without visiting new
channels.
2004-07-23 06:57:33 +00:00
mycroft f0546001c6 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.
2004-07-23 06:44:55 +00:00
dyoung 5b42102f70 Don't be so repetitive repetitive in the ieee80211_needs_rxnode
synopsis.
2004-07-23 05:54:02 +00:00
mycroft c3138ef3da IEEE80211_MAX_AID has been renamed to IEEE80211_AID_MAX. 2004-07-23 05:33:41 +00:00
mycroft de64f03a72 Sync with madwifi. 2004-07-23 05:33:23 +00:00
dyoung 754d58a536 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.]
2004-07-23 05:19:41 +00:00
dyoung 218f34f115 Protect userland from some of the definitions with #ifdef _KERNEL.
Thank you, Havard Eidnes, for the pointing out my oversight.
2004-07-22 17:04:38 +00:00
mycroft eec7430f97 In *_fix_rate(), set ni_txrate to the highest common speed so that probe
and authentication responses are sent with a sensible speed.  XXX
2004-07-22 14:52:07 +00:00
mycroft 427f7b9264 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).
2004-07-22 14:44:17 +00:00
dyoung 9946103dce Add sysctl access to 802.11 node tables, step #2. 2004-07-16 03:02:41 +00:00
dyoung cb049b8c75 Add sysctl access to 802.11 node tables, step #1. 2004-07-16 03:01:09 +00:00
dyoung 22b2f98500 Move ieee80211_channel definition and channel flags into
ieee80211_channel.h, step #2.
2004-07-16 02:57:32 +00:00
dyoung d5a069fe39 Move ieee80211_channel definition and channel flags into
ieee80211_channel.h, step #1.
2004-07-16 02:56:50 +00:00
dyoung 74d2bb365f Straggler: *really* chain the ieee80211coms. 2004-07-16 02:54:05 +00:00
dyoung e5c3be4f90 Send "no carrier"/"active" indications on the routing socket when
(most) 802.11 interfaces change state.
2004-07-16 02:38:34 +00:00
dyoung d18cdaab4e Chain ieee80211coms together so that the 802.11 sysctls can walk
them all to retrieve their node tables.
2004-07-16 02:36:58 +00:00
dyoung 4021fab89e Remove a few levels of indentation in ieee80211_find_rxnode by
return'ing early.
2004-07-02 23:54:08 +00:00
dyoung b0ce431f32 Add sysctl(9) descriptions for net.link and net.link.ieee80211. 2004-06-06 05:45:29 +00:00
dyoung 390d3859bf Fix a typo in some #ifdef notdef code. 2004-06-06 05:44:25 +00:00
dyoung 7b92b29893 Improve argument checking. Convert from seconds to some number of
inactivity countdown intervals (currently these are 5 seconds).
2004-06-06 05:43:17 +00:00
dyoung e071e08cc6 Fix for kern/25604: ifconfig wi0 media DS11 panics system.
In ieee80211_chan2mode, do not dereference the marker for "any
channel," IEEE80211_CHAN_ANYC.
2004-06-06 05:28:58 +00:00
dyoung 50c193fc53 Define IEEE80211_RADIOTAP_HDRLEN, the length of a radiotap header. 2004-06-06 04:13:28 +00:00
dyoung c9f71eaeb7 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.
2004-05-31 11:12:24 +00:00
dyoung a49a69d67a If WEP is on, set a data packet's WEP flag when we 802.11-encapsulate
it.  Credit: Matthew Gream.
2004-05-31 11:02:55 +00:00
atatat 4de3747b89 Sysctl descriptions under net subtree (net.key not done) 2004-05-25 04:33:59 +00:00
dyoung 7412e6e599 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.
2004-05-09 09:18:47 +00:00
dyoung 6263dee43f Undo last: I committed the wrong file. 2004-05-09 09:00:05 +00:00
dyoung dd998d980d 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.
2004-05-09 08:19:21 +00:00
dyoung 998a558a7f 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.
2004-05-06 07:11:40 +00:00
dyoung fcd7df4334 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.
2004-05-06 03:07:10 +00:00
dyoung 7c84c56e55 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).
2004-05-06 03:03:20 +00:00
dyoung 27d8afead9 No need to suppress if_init calls, ether_ioctl already does it.
Also, ether_ioctl handles more address families than ieee80211_ioctl
was.
2004-05-06 02:58:16 +00:00
dyoung 1ff6496e8c 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.)
2004-05-06 02:56:48 +00:00
dyoung 9e76c33909 NetBSD does not contain IPX support. 2004-05-06 02:16:59 +00:00
dyoung 752f5ad0b1 Fix spelling: supress -> suppress. 2004-05-06 02:14:03 +00:00
dyoung 3d73dc9e3e Check if_init error. 2004-05-06 01:56:08 +00:00
cube 57d44e1cee In NetBSD, if_init() expects a struct ifnet, not the softc. 2004-05-05 16:10:29 +00:00
dyoung 6da519f16e Doh. Make it compile w/o IEEE80211_DEBUG. 2004-05-01 01:49:03 +00:00
dyoung 8d4772498f 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.
2004-04-30 23:58:20 +00:00
dyoung 974bfde812 From FreeBSD. Increase a stats counter when
ieee80211_find_txnode fails.
2004-04-30 23:58:17 +00:00
dyoung bd8379210b 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.
2004-04-30 23:58:14 +00:00
dyoung 26f67ccc94 From FreeBSD. Handle 802.11g protection mode and
Tx power control ioctls.
2004-04-30 23:58:11 +00:00
dyoung 1d6dd12bbb From FreeBSD. Be more consistent with ieee80211_node
reference counts, and treat ad hoc nodes properly.  More complete
authentication support.
2004-04-30 23:58:08 +00:00
dyoung fd6869101d 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.
2004-04-30 23:58:05 +00:00
dyoung bf30017770 From FreeBSD. Definite structures and constants for
QoS/WME/802.11e, for WPA, and for 802.11 MTU.
2004-04-30 23:51:53 +00:00
dyoung ae5c86c258 From FreeBSD. Add protection mode bits. Get rid of
the RCVMGT capability.
2004-04-30 23:51:50 +00:00
dyoung 255f57a8b6 Add a malloc(9) type for 802.11 nodes. 2004-04-30 22:57:32 +00:00
dyoung 40e9f581a4 Add ioctl constants for both the 802.11g protection mode and for
Tx power control.
2004-04-30 22:51:04 +00:00
dyoung 5c35c045ac 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.
2004-04-30 22:22:53 +00:00
itojun e133d13e80 kill some strcpy 2004-04-21 18:16:14 +00:00
dyoung 811d8c496e Get the sense of ra->ra_nok and ra->ra_nfail right. They indicate
successes and failures, respectively, not the other way around.
2004-03-29 04:09:45 +00:00