1 /* 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * Alternatively, this software may be distributed under the terms of the 18 * GNU General Public License ("GPL") version 2 as published by the Free 19 * Software Foundation. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * $FreeBSD: src/sys/net80211/ieee80211_node.h,v 1.10 2004/04/05 22:10:26 sam Exp $ 33 * $DragonFly: src/sys/netproto/802_11/ieee80211_node.h,v 1.1 2004/07/26 16:30:17 joerg Exp $ 34 */ 35 36 #ifndef _NETPROTO_802_11_IEEE80211_NODE_H_ 37 #define _NETPROTO_802_11_IEEE80211_NODE_H_ 38 39 #define IEEE80211_PSCAN_WAIT 5 /* passive scan wait */ 40 #define IEEE80211_TRANS_WAIT 5 /* transition wait */ 41 #define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */ 42 #define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT) 43 44 #define IEEE80211_NODE_HASHSIZE 32 45 /* simple hash is enough for variation of macaddr */ 46 #define IEEE80211_NODE_HASH(addr) \ 47 (((uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % IEEE80211_NODE_HASHSIZE) 48 49 #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ 50 #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ 51 52 struct ieee80211_rateset { 53 uint8_t rs_nrates; 54 uint8_t rs_rates[IEEE80211_RATE_MAXSIZE]; 55 }; 56 57 /* 58 * Node specific information. Note that drivers are expected 59 * to derive from this structure to add device-specific per-node 60 * state. This is done by overriding the ic_node_* methods in 61 * the ieee80211com structure. 62 */ 63 struct ieee80211_node { 64 TAILQ_ENTRY(ieee80211_node) ni_list; 65 LIST_ENTRY(ieee80211_node) ni_hash; 66 u_int ni_refcnt; 67 u_int ni_scangen; /* gen# for timeout scan */ 68 69 /* hardware */ 70 uint32_t ni_rstamp; /* recv timestamp */ 71 uint8_t ni_rssi; /* recv ssi */ 72 73 /* header */ 74 uint8_t ni_macaddr[IEEE80211_ADDR_LEN]; 75 uint8_t ni_bssid[IEEE80211_ADDR_LEN]; 76 77 /* beacon, probe response */ 78 uint8_t ni_tstamp[8]; /* from last rcv'd beacon */ 79 uint16_t ni_intval; /* beacon interval */ 80 uint16_t ni_capinfo; /* capabilities */ 81 uint8_t ni_esslen; 82 uint8_t ni_essid[IEEE80211_NWID_LEN]; 83 struct ieee80211_rateset ni_rates; /* negotiated rate set */ 84 uint8_t *ni_country; /* country information XXX */ 85 struct ieee80211_channel *ni_chan; 86 uint16_t ni_fhdwell; /* FH only */ 87 uint8_t ni_fhindex; /* FH only */ 88 uint8_t ni_erp; /* 11g only */ 89 90 #ifdef notyet 91 /* DTIM and contention free period (CFP) */ 92 uint8_t ni_dtimperiod; 93 uint8_t ni_cfpperiod; /* # of DTIMs between CFPs */ 94 uint16_t ni_cfpduremain; /* remaining cfp duration */ 95 uint16_t ni_cfpmaxduration;/* max CFP duration in TU */ 96 uint16_t ni_nextdtim; /* time to next DTIM */ 97 uint16_t ni_timoffset; 98 #endif 99 100 /* others */ 101 uint16_t ni_associd; /* assoc response */ 102 uint16_t ni_txseq; /* seq to be transmitted */ 103 uint16_t ni_rxseq; /* seq previous received */ 104 int ni_fails; /* failure count to associate */ 105 int ni_inact; /* inactivity mark count */ 106 int ni_txrate; /* index to ni_rates[] */ 107 }; 108 109 static __inline struct ieee80211_node * 110 ieee80211_ref_node(struct ieee80211_node *ni) 111 { 112 atomic_add_int(&ni->ni_refcnt, 1); 113 return ni; 114 } 115 116 static __inline void 117 ieee80211_unref_node(struct ieee80211_node **ni) 118 { 119 atomic_subtract_int(&(*ni)->ni_refcnt, 1); 120 *ni = NULL; /* guard against use */ 121 } 122 123 struct ieee80211com; 124 125 #ifdef MALLOC_DECLARE 126 MALLOC_DECLARE(M_80211_NODE); 127 #endif 128 129 extern void ieee80211_node_attach(struct ifnet *); 130 extern void ieee80211_node_lateattach(struct ifnet *); 131 extern void ieee80211_node_detach(struct ifnet *); 132 133 extern void ieee80211_begin_scan(struct ifnet *); 134 extern void ieee80211_next_scan(struct ifnet *); 135 extern void ieee80211_end_scan(struct ifnet *); 136 extern struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *, 137 uint8_t *); 138 extern struct ieee80211_node *ieee80211_dup_bss(struct ieee80211com *, 139 uint8_t *); 140 extern struct ieee80211_node *ieee80211_find_node(struct ieee80211com *, 141 uint8_t *); 142 extern struct ieee80211_node *ieee80211_find_txnode(struct ieee80211com *, 143 uint8_t *); 144 extern struct ieee80211_node * ieee80211_lookup_node(struct ieee80211com *, 145 uint8_t *macaddr, struct ieee80211_channel *); 146 extern void ieee80211_free_node(struct ieee80211com *, 147 struct ieee80211_node *); 148 extern void ieee80211_free_allnodes(struct ieee80211com *); 149 typedef void ieee80211_iter_func(void *, struct ieee80211_node *); 150 extern void ieee80211_iterate_nodes(struct ieee80211com *ic, 151 ieee80211_iter_func *, void *); 152 extern void ieee80211_timeout_nodes(struct ieee80211com *); 153 154 extern void ieee80211_create_ibss(struct ieee80211com* , 155 struct ieee80211_channel *); 156 #endif /* _NETPROTO_802_11_IEEE80211_NODE_H_ */ 157