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