ieee80211_node.h revision 116904
11590Srgrimes/*- 21590Srgrimes * Copyright (c) 2001 Atsushi Onoe 31590Srgrimes * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 41590Srgrimes * All rights reserved. 51590Srgrimes * 61590Srgrimes * Redistribution and use in source and binary forms, with or without 71590Srgrimes * modification, are permitted provided that the following conditions 81590Srgrimes * are met: 91590Srgrimes * 1. Redistributions of source code must retain the above copyright 101590Srgrimes * notice, this list of conditions and the following disclaimer. 111590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 121590Srgrimes * notice, this list of conditions and the following disclaimer in the 131590Srgrimes * documentation and/or other materials provided with the distribution. 141590Srgrimes * 3. The name of the author may not be used to endorse or promote products 151590Srgrimes * derived from this software without specific prior written permission. 161590Srgrimes * 171590Srgrimes * Alternatively, this software may be distributed under the terms of the 181590Srgrimes * GNU General Public License ("GPL") version 2 as published by the Free 191590Srgrimes * Software Foundation. 201590Srgrimes * 211590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221590Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231590Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241590Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251590Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261590Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271590Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281590Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291590Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301590Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311590Srgrimes * 321590Srgrimes * $FreeBSD: head/sys/net80211/ieee80211_node.h 116904 2003-06-27 05:13:52Z sam $ 331590Srgrimes */ 341590Srgrimes#ifndef _NET80211_IEEE80211_NODE_H_ 351590Srgrimes#define _NET80211_IEEE80211_NODE_H_ 361590Srgrimes 3774769Smikeh#define IEEE80211_PSCAN_WAIT 5 /* passive scan wait */ 3888150Smikeh#define IEEE80211_TRANS_WAIT 5 /* transition wait */ 3974769Smikeh#define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */ 401590Srgrimes#define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT) 4199112Sobrien 4299112Sobrien#define IEEE80211_NODE_HASHSIZE 32 431590Srgrimes/* simple hash is enough for variation of macaddr */ 441590Srgrimes#define IEEE80211_NODE_HASH(addr) \ 451590Srgrimes (((u_int8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % IEEE80211_NODE_HASHSIZE) 461590Srgrimes 471590Srgrimes#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ 481590Srgrimes#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ 491590Srgrimes 501590Srgrimesstruct ieee80211_rateset { 511590Srgrimes u_int8_t rs_nrates; 521590Srgrimes u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE]; 531590Srgrimes}; 54173439Sdds 551590Srgrimes/* 5677274Smikeh * Node specific information. Note that drivers are expected 5777274Smikeh * to derive from this structure to add device-specific per-node 581590Srgrimes * state. This is done by overriding the ic_node_* methods in 59216564Scharnier * the ieee80211com structure. 601590Srgrimes */ 6177274Smikehstruct ieee80211_node { 621590Srgrimes TAILQ_ENTRY(ieee80211_node) ni_list; 6332189Sjoerg LIST_ENTRY(ieee80211_node) ni_hash; 6488150Smikeh u_int ni_refcnt; 651590Srgrimes 661590Srgrimes /* hardware */ 671590Srgrimes u_int8_t ni_rssi; /* recv ssi */ 681590Srgrimes u_int32_t ni_rstamp; /* recv timestamp */ 691590Srgrimes u_int8_t ni_rantenna; /* recv antenna */ 701590Srgrimes 711590Srgrimes /* header */ 721590Srgrimes u_int8_t ni_macaddr[IEEE80211_ADDR_LEN]; 7377274Smikeh u_int8_t ni_bssid[IEEE80211_ADDR_LEN]; 741590Srgrimes 751590Srgrimes /* beacon, probe response */ 761590Srgrimes u_int8_t ni_tstamp[8]; /* from last rcv'd beacon */ 771590Srgrimes u_int16_t ni_intval; /* beacon interval */ 781590Srgrimes u_int16_t ni_capinfo; /* capabilities */ 791590Srgrimes u_int8_t ni_esslen; 801590Srgrimes u_int8_t ni_essid[IEEE80211_NWID_LEN]; 811590Srgrimes struct ieee80211_rateset ni_rates; /* negotiated rate set */ 821590Srgrimes u_int8_t *ni_country; /* country information XXX */ 831590Srgrimes struct ieee80211_channel *ni_chan; 8477274Smikeh u_int16_t ni_fhdwell; /* FH only */ 8577274Smikeh u_int8_t ni_fhindex; /* FH only */ 8677274Smikeh u_int8_t ni_erp; /* 11g only */ 8777274Smikeh 8877274Smikeh#ifdef notyet 8977274Smikeh /* DTIM and contention free period (CFP) */ 90126415Smikeh u_int8_t ni_dtimperiod; 911590Srgrimes u_int8_t ni_cfpperiod; /* # of DTIMs between CFPs */ 921590Srgrimes u_int16_t ni_cfpduremain; /* remaining cfp duration */ 931590Srgrimes u_int16_t ni_cfpmaxduration;/* max CFP duration in TU */ 941590Srgrimes u_int16_t ni_nextdtim; /* time to next DTIM */ 951590Srgrimes u_int16_t ni_timoffset; 961590Srgrimes#endif 971590Srgrimes 9874769Smikeh /* others */ 9977274Smikeh u_int16_t ni_associd; /* assoc response */ 10074769Smikeh u_int16_t ni_txseq; /* seq to be transmitted */ 10177274Smikeh u_int16_t ni_rxseq; /* seq previous received */ 1021590Srgrimes int ni_fails; /* failure count to associate */ 1031590Srgrimes int ni_inact; /* inactivity mark count */ 1041590Srgrimes int ni_txrate; /* index to ni_rates[] */ 1051590Srgrimes}; 1061590Srgrimes 1071590Srgrimesstatic __inline struct ieee80211_node * 10877274Smikehieee80211_ref_node(struct ieee80211_node *ni) 1091590Srgrimes{ 1101590Srgrimes atomic_add_int(&ni->ni_refcnt, 1); 1111590Srgrimes return ni; 1121590Srgrimes} 1131590Srgrimes 1141590Srgrimesstatic __inline void 1151590Srgrimesieee80211_unref_node(struct ieee80211_node **ni) 1161590Srgrimes{ 1171590Srgrimes atomic_subtract_int(&(*ni)->ni_refcnt, 1); 1181590Srgrimes *ni = NULL; /* guard against use */ 1191590Srgrimes} 120126415Smikeh 121126415Smikehstruct ieee80211com; 122126415Smikeh 123126415Smikehextern void ieee80211_node_attach(struct ifnet *); 124126415Smikehextern void ieee80211_node_detach(struct ifnet *); 125126415Smikeh 126126415Smikehextern void ieee80211_reset_scan(struct ifnet *); 127126415Smikehextern void ieee80211_begin_scan(struct ifnet *, struct ieee80211_node *); 128126415Smikehextern void ieee80211_next_scan(struct ifnet *); 129126415Smikehextern void ieee80211_end_scan(struct ifnet *); 130126415Smikehextern struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *, 131126415Smikeh u_int8_t *); 132126415Smikehextern struct ieee80211_node *ieee80211_dup_bss(struct ieee80211com *, 133126415Smikeh u_int8_t *); 134126415Smikehextern struct ieee80211_node *ieee80211_find_node(struct ieee80211com *, 135126415Smikeh u_int8_t *); 136126415Smikehextern struct ieee80211_node * ieee80211_lookup_node(struct ieee80211com *, 137126415Smikeh u_int8_t *macaddr, struct ieee80211_channel *); 138126415Smikehextern void ieee80211_free_node(struct ieee80211com *, 1391590Srgrimes struct ieee80211_node *); 1401590Srgrimesextern void ieee80211_free_allnodes(struct ieee80211com *); 1411590Srgrimestypedef void ieee80211_iter_func(void *, struct ieee80211_node *); 1421590Srgrimesextern void ieee80211_iterate_nodes(struct ieee80211com *ic, 1431590Srgrimes ieee80211_iter_func *, void *); 1441590Srgrimesextern void ieee80211_timeout_nodes(struct ieee80211com *); 1451590Srgrimes 1461590Srgrimesextern void ieee80211_create_ibss(struct ieee80211com* , 1471590Srgrimes struct ieee80211_channel *); 1481590Srgrimes#endif /* _NET80211_IEEE80211_NODE_H_ */ 1491590Srgrimes