ieee80211_node.h revision 116742
1116742Ssam/*- 2116742Ssam * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 3116742Ssam * All rights reserved. 4116742Ssam * 5116742Ssam * Redistribution and use in source and binary forms, with or without 6116742Ssam * modification, are permitted provided that the following conditions 7116742Ssam * are met: 8116742Ssam * 1. Redistributions of source code must retain the above copyright 9116742Ssam * notice, this list of conditions and the following disclaimer. 10116742Ssam * 2. Redistributions in binary form must reproduce the above copyright 11116742Ssam * notice, this list of conditions and the following disclaimer in the 12116742Ssam * documentation and/or other materials provided with the distribution. 13116742Ssam * 14116742Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15116742Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16116742Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17116742Ssam * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18116742Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19116742Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20116742Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21116742Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22116742Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23116742Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24116742Ssam * SUCH DAMAGE. 25116742Ssam * 26116742Ssam * $FreeBSD: head/sys/net80211/ieee80211_node.h 116742 2003-06-23 16:55:01Z sam $ 27116742Ssam */ 28116742Ssam#ifndef _NET80211_IEEE80211_NODE_H_ 29116742Ssam#define _NET80211_IEEE80211_NODE_H_ 30116742Ssam 31116742Ssam#define IEEE80211_PSCAN_WAIT 5 /* passive scan wait */ 32116742Ssam#define IEEE80211_TRANS_WAIT 5 /* transition wait */ 33116742Ssam#define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */ 34116742Ssam#define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT) 35116742Ssam 36116742Ssam#define IEEE80211_NODE_HASHSIZE 32 37116742Ssam/* simple hash is enough for variation of macaddr */ 38116742Ssam#define IEEE80211_NODE_HASH(addr) \ 39116742Ssam (((u_int8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % IEEE80211_NODE_HASHSIZE) 40116742Ssam 41116742Ssam#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ 42116742Ssam#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ 43116742Ssam 44116742Ssamstruct ieee80211_rateset { 45116742Ssam u_int8_t rs_nrates; 46116742Ssam u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE]; 47116742Ssam}; 48116742Ssam 49116742Ssam/* 50116742Ssam * Node specific information. Note that drivers are expected 51116742Ssam * to derive from this structure to add device-specific per-node 52116742Ssam * state. This is done by overriding the ic_node_* methods in 53116742Ssam * the ieee80211com structure. 54116742Ssam */ 55116742Ssamstruct ieee80211_node { 56116742Ssam TAILQ_ENTRY(ieee80211_node) ni_list; 57116742Ssam LIST_ENTRY(ieee80211_node) ni_hash; 58116742Ssam u_int ni_refcnt; 59116742Ssam 60116742Ssam /* hardware */ 61116742Ssam u_int8_t ni_rssi; /* recv ssi */ 62116742Ssam u_int32_t ni_rstamp; /* recv timestamp */ 63116742Ssam u_int8_t ni_rantenna; /* recv antenna */ 64116742Ssam 65116742Ssam /* header */ 66116742Ssam u_int8_t ni_macaddr[IEEE80211_ADDR_LEN]; 67116742Ssam u_int8_t ni_bssid[IEEE80211_ADDR_LEN]; 68116742Ssam 69116742Ssam /* beacon, probe response */ 70116742Ssam u_int8_t ni_tstamp[8]; /* from last rcv'd beacon */ 71116742Ssam u_int16_t ni_intval; /* beacon interval */ 72116742Ssam u_int16_t ni_capinfo; /* capabilities */ 73116742Ssam u_int8_t ni_esslen; 74116742Ssam u_int8_t ni_essid[IEEE80211_NWID_LEN]; 75116742Ssam struct ieee80211_rateset ni_rates; /* negotiated rate set */ 76116742Ssam u_int8_t *ni_country; /* country information XXX */ 77116742Ssam struct ieee80211_channel *ni_chan; 78116742Ssam u_int16_t ni_fhdwell; /* FH only */ 79116742Ssam u_int8_t ni_fhindex; /* FH only */ 80116742Ssam u_int8_t ni_erp; /* 11g only */ 81116742Ssam 82116742Ssam#ifdef notyet 83116742Ssam /* DTIM and contention free period (CFP) */ 84116742Ssam u_int8_t ni_dtimperiod; 85116742Ssam u_int8_t ni_cfpperiod; /* # of DTIMs between CFPs */ 86116742Ssam u_int16_t ni_cfpduremain; /* remaining cfp duration */ 87116742Ssam u_int16_t ni_cfpmaxduration;/* max CFP duration in TU */ 88116742Ssam u_int16_t ni_nextdtim; /* time to next DTIM */ 89116742Ssam u_int16_t ni_timoffset; 90116742Ssam#endif 91116742Ssam 92116742Ssam /* others */ 93116742Ssam u_int16_t ni_associd; /* assoc response */ 94116742Ssam u_int16_t ni_txseq; /* seq to be transmitted */ 95116742Ssam u_int16_t ni_rxseq; /* seq previous received */ 96116742Ssam int ni_fails; /* failure count to associate */ 97116742Ssam int ni_inact; /* inactivity mark count */ 98116742Ssam int ni_txrate; /* index to ni_rates[] */ 99116742Ssam}; 100116742Ssam 101116742Ssamstatic __inline struct ieee80211_node * 102116742Ssamieee80211_ref_node(struct ieee80211_node *ni) 103116742Ssam{ 104116742Ssam atomic_add_int(&ni->ni_refcnt, 1); 105116742Ssam return ni; 106116742Ssam} 107116742Ssam 108116742Ssamstatic __inline void 109116742Ssamieee80211_unref_node(struct ieee80211_node **ni) 110116742Ssam{ 111116742Ssam atomic_subtract_int(&(*ni)->ni_refcnt, 1); 112116742Ssam *ni = NULL; /* guard against use */ 113116742Ssam} 114116742Ssam 115116742Ssamstruct ieee80211com; 116116742Ssam 117116742Ssamextern void ieee80211_node_attach(struct ifnet *); 118116742Ssamextern void ieee80211_node_detach(struct ifnet *); 119116742Ssam 120116742Ssamextern void ieee80211_reset_scan(struct ifnet *); 121116742Ssamextern void ieee80211_begin_scan(struct ifnet *, struct ieee80211_node *); 122116742Ssamextern void ieee80211_next_scan(struct ifnet *); 123116742Ssamextern void ieee80211_end_scan(struct ifnet *); 124116742Ssamextern struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *, 125116742Ssam u_int8_t *); 126116742Ssamextern struct ieee80211_node *ieee80211_dup_bss(struct ieee80211com *, 127116742Ssam u_int8_t *); 128116742Ssamextern struct ieee80211_node *ieee80211_find_node(struct ieee80211com *, 129116742Ssam u_int8_t *); 130116742Ssamextern struct ieee80211_node * ieee80211_lookup_node(struct ieee80211com *, 131116742Ssam u_int8_t *macaddr, struct ieee80211_channel *); 132116742Ssamextern void ieee80211_free_node(struct ieee80211com *, 133116742Ssam struct ieee80211_node *); 134116742Ssamextern void ieee80211_free_allnodes(struct ieee80211com *); 135116742Ssamtypedef void ieee80211_iter_func(void *, struct ieee80211_node *); 136116742Ssamextern void ieee80211_iterate_nodes(struct ieee80211com *ic, 137116742Ssam ieee80211_iter_func *, void *); 138116742Ssamextern void ieee80211_timeout_nodes(struct ieee80211com *); 139116742Ssam 140116742Ssamextern void ieee80211_create_ibss(struct ieee80211com* , 141116742Ssam struct ieee80211_channel *); 142116742Ssam#endif /* _NET80211_IEEE80211_NODE_H_ */ 143