root / lab4 / .minix-src / include / net80211 / ieee80211_netbsd.h @ 14
History | View | Annotate | Download (9.21 KB)
1 | 13 | up20180614 | /* $NetBSD: ieee80211_netbsd.h,v 1.19 2014/04/07 00:07:40 pooka Exp $ */
|
---|---|---|---|
2 | /*-
|
||
3 | * Copyright (c) 2003-2005 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 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
27 | *
|
||
28 | * $FreeBSD: src/sys/net80211/ieee80211_freebsd.h,v 1.6 2005/08/08 18:46:36 sam Exp $
|
||
29 | */
|
||
30 | #ifndef _NET80211_IEEE80211_NETBSD_H_
|
||
31 | #define _NET80211_IEEE80211_NETBSD_H_
|
||
32 | |||
33 | #ifdef _KERNEL
|
||
34 | #define IASSERT(__cond, __complaint) \
|
||
35 | do { \
|
||
36 | if (!(__cond)) \
|
||
37 | panic __complaint ; \ |
||
38 | } while (/*CONSTCOND*/0) |
||
39 | |||
40 | void if_printf(struct ifnet *, const char *, ...) |
||
41 | __attribute__((__format__(__printf__,2,3))); |
||
42 | |||
43 | #define IEEE80211_LOCK_INIT_IMPL(_ic, _name, _member) \
|
||
44 | mutex_init(&(_ic)->_member, MUTEX_DEFAULT, IPL_NET) |
||
45 | #define IEEE80211_LOCK_IMPL(_ic, _member) \
|
||
46 | mutex_enter(&(_ic)->_member) |
||
47 | #define IEEE80211_IS_LOCKED_IMPL(_ic, _member) \
|
||
48 | mutex_owned(&(_ic)->_member) |
||
49 | #define IEEE80211_UNLOCK_IMPL(_ic, _member) \
|
||
50 | mutex_exit(&(_ic)->_member) |
||
51 | #define IEEE80211_LOCK_ASSERT_IMPL(_ic, _member) \
|
||
52 | IASSERT(mutex_owned(&(_ic)->_member), \ |
||
53 | ("%s: IEEE80211_LOCK not held", __func__))
|
||
54 | #define IEEE80211_LOCK_DESTROY_IMPL(_ic, _member) \
|
||
55 | mutex_destroy(&(_ic)->_member) |
||
56 | |||
57 | /*
|
||
58 | * Beacon locking definitions.
|
||
59 | */
|
||
60 | typedef kmutex_t ieee80211_beacon_lock_t;
|
||
61 | #define IEEE80211_BEACON_LOCK_INIT(_ic, _name) \
|
||
62 | IEEE80211_LOCK_INIT_IMPL(_ic, _name, ic_beaconlock) |
||
63 | #define IEEE80211_BEACON_LOCK_DESTROY(_ic) \
|
||
64 | IEEE80211_LOCK_DESTROY_IMPL(_ic, ic_beaconlock) |
||
65 | #define IEEE80211_BEACON_LOCK(_ic) \
|
||
66 | IEEE80211_LOCK_IMPL(_ic, ic_beaconlock) |
||
67 | #define IEEE80211_BEACON_UNLOCK(_ic) \
|
||
68 | IEEE80211_UNLOCK_IMPL(_ic, ic_beaconlock) |
||
69 | #define IEEE80211_BEACON_LOCK_ASSERT(_ic) \
|
||
70 | IEEE80211_LOCK_ASSERT_IMPL(_ic, ic_beaconlock) |
||
71 | |||
72 | /*
|
||
73 | * Node locking definitions.
|
||
74 | * NB: MTX_DUPOK is because we don't generate per-interface strings.
|
||
75 | */
|
||
76 | typedef kmutex_t ieee80211_node_lock_t;
|
||
77 | #define IEEE80211_NODE_LOCK_INIT(_nt, _name) \
|
||
78 | IEEE80211_LOCK_INIT_IMPL(_nt, _name, nt_nodelock) |
||
79 | #define IEEE80211_NODE_LOCK_DESTROY(_nt) \
|
||
80 | IEEE80211_LOCK_DESTROY_IMPL(_nt, nt_nodelock) |
||
81 | #define IEEE80211_NODE_LOCK(_nt) \
|
||
82 | IEEE80211_LOCK_IMPL(_nt, nt_nodelock) |
||
83 | #define IEEE80211_NODE_IS_LOCKED(_nt) \
|
||
84 | IEEE80211_IS_LOCKED_IMPL(_nt, nt_nodelock) |
||
85 | #define IEEE80211_NODE_UNLOCK(_nt) \
|
||
86 | IEEE80211_UNLOCK_IMPL(_nt, nt_nodelock) |
||
87 | #define IEEE80211_NODE_LOCK_ASSERT(_nt) \
|
||
88 | IEEE80211_LOCK_ASSERT_IMPL(_nt, nt_nodelock) |
||
89 | |||
90 | /*
|
||
91 | * Node table scangen locking definitions.
|
||
92 | */
|
||
93 | typedef kmutex_t ieee80211_scan_lock_t;
|
||
94 | #define IEEE80211_SCAN_LOCK_INIT(_nt, _name) \
|
||
95 | IEEE80211_LOCK_INIT_IMPL(_nt, _name, nt_scanlock) |
||
96 | #define IEEE80211_SCAN_LOCK_DESTROY(_nt) \
|
||
97 | IEEE80211_LOCK_DESTROY_IMPL(_nt, nt_scanlock) |
||
98 | #define IEEE80211_SCAN_LOCK(_nt) \
|
||
99 | IEEE80211_LOCK_IMPL(_nt, nt_scanlock) |
||
100 | #define IEEE80211_SCAN_UNLOCK(_nt) \
|
||
101 | IEEE80211_UNLOCK_IMPL(_nt, nt_scanlock) |
||
102 | #define IEEE80211_SCAN_LOCK_ASSERT(_nt) \
|
||
103 | IEEE80211_LOCK_ASSERT_IMPL(_nt, nt_scanlock) |
||
104 | |||
105 | /*
|
||
106 | * Per-node power-save queue definitions.
|
||
107 | */
|
||
108 | #define IEEE80211_NODE_SAVEQ_INIT(_ni, _name) do { \ |
||
109 | (_ni)->ni_savedq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE; \ |
||
110 | } while (0) |
||
111 | #define IEEE80211_NODE_SAVEQ_DESTROY(_ni)
|
||
112 | #define IEEE80211_NODE_SAVEQ_QLEN(_ni) ((_ni)->ni_savedq.ifq_len)
|
||
113 | #define IEEE80211_NODE_SAVEQ_LOCK(_ni)
|
||
114 | #define IEEE80211_NODE_SAVEQ_UNLOCK(_ni)
|
||
115 | #define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _m, _qlen) do { \ |
||
116 | IEEE80211_NODE_SAVEQ_LOCK(_ni); \ |
||
117 | IF_DEQUEUE(&(_ni)->ni_savedq, _m); \ |
||
118 | (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ |
||
119 | IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \ |
||
120 | } while (0) |
||
121 | #define IEEE80211_NODE_SAVEQ_DRAIN(_ni, _qlen) do { \ |
||
122 | IEEE80211_NODE_SAVEQ_LOCK(_ni); \ |
||
123 | (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ |
||
124 | IF_PURGE(&(_ni)->ni_savedq); \ |
||
125 | IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \ |
||
126 | } while (0) |
||
127 | /* XXX could be optimized */
|
||
128 | #define _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(_ni, _m) do { \ |
||
129 | IF_DEQUEUE(&(_ni)->ni_savedq, m); \ |
||
130 | } while (0) |
||
131 | #define _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _m, _qlen, _age) do {\ |
||
132 | (_m)->m_nextpkt = NULL; \
|
||
133 | if ((_ni)->ni_savedq.ifq_tail != NULL) { \ |
||
134 | _age -= M_AGE_GET((_ni)->ni_savedq.ifq_tail); \ |
||
135 | (_ni)->ni_savedq.ifq_tail->m_nextpkt = (_m); \ |
||
136 | } else { \
|
||
137 | (_ni)->ni_savedq.ifq_head = (_m); \ |
||
138 | } \ |
||
139 | M_AGE_SET(_m, _age); \ |
||
140 | (_ni)->ni_savedq.ifq_tail = (_m); \ |
||
141 | (_qlen) = ++(_ni)->ni_savedq.ifq_len; \ |
||
142 | } while (0) |
||
143 | |||
144 | /*
|
||
145 | * 802.1x MAC ACL database locking definitions.
|
||
146 | */
|
||
147 | typedef kmutex_t acl_lock_t;
|
||
148 | #define ACL_LOCK_INIT(_as, _name) \
|
||
149 | IEEE80211_LOCK_INIT_IMPL(_as, _name, as_lock) |
||
150 | #define ACL_LOCK_DESTROY(_as) \
|
||
151 | IEEE80211_LOCK_DESTROY_IMPL(_as, as_lock) |
||
152 | #define ACL_LOCK(_as) IEEE80211_LOCK_IMPL(_as, as_lock)
|
||
153 | #define ACL_UNLOCK(_as) IEEE80211_UNLOCK_IMPL(_as, as_lock)
|
||
154 | #define ACL_LOCK_ASSERT(_as) IEEE80211_LOCK_ASSERT_IMPL(_as, as_lock)
|
||
155 | |||
156 | struct ifqueue;
|
||
157 | void ieee80211_drain_ifq(struct ifqueue *); |
||
158 | |||
159 | struct mbuf *ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen);
|
||
160 | #define M_PWR_SAV M_PROTO1 /* bypass PS handling */ |
||
161 | #define M_MORE_DATA M_LINK3 /* more data frames to follow */ |
||
162 | #define M_FRAG M_LINK4 /* 802.11 fragment */ |
||
163 | #define M_FIRSTFRAG M_LINK5 /* first 802.11 fragment */ |
||
164 | #define M_FF M_LINK6 /* "fast frames" */ |
||
165 | /*
|
||
166 | * Encode WME access control bits in the PROTO flags.
|
||
167 | * This is safe since it's passed directly in to the
|
||
168 | * driver and there's no chance someone else will clobber
|
||
169 | * them on us.
|
||
170 | */
|
||
171 | #define M_WME_AC_MASK (M_LINK1|M_LINK2)
|
||
172 | /* XXX 5 is wrong if M_LINK* are redefined */
|
||
173 | #define M_WME_AC_SHIFT 13 |
||
174 | |||
175 | #define M_WME_SETAC(m, ac) \
|
||
176 | ((m)->m_flags = ((m)->m_flags &~ M_WME_AC_MASK) | \ |
||
177 | ((ac) << M_WME_AC_SHIFT)) |
||
178 | #define M_WME_GETAC(m) (((m)->m_flags >> M_WME_AC_SHIFT) & 0x3) |
||
179 | |||
180 | /*
|
||
181 | * Mbufs on the power save queue are tagged with an age and
|
||
182 | * timed out. We reuse the hardware checksum field in the
|
||
183 | * mbuf packet header to store this data.
|
||
184 | */
|
||
185 | #define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v)
|
||
186 | #define M_AGE_GET(m) (m->m_pkthdr.csum_data)
|
||
187 | #define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)
|
||
188 | |||
189 | struct ieee80211com;
|
||
190 | #endif /* _KERNEL */ |
||
191 | |||
192 | /* XXX this stuff belongs elsewhere */
|
||
193 | /*
|
||
194 | * Message formats for messages from the net80211 layer to user
|
||
195 | * applications via the routing socket. These messages are appended
|
||
196 | * to an if_announcemsghdr structure.
|
||
197 | */
|
||
198 | struct ieee80211_join_event {
|
||
199 | uint8_t iev_addr[6];
|
||
200 | }; |
||
201 | |||
202 | struct ieee80211_leave_event {
|
||
203 | uint8_t iev_addr[6];
|
||
204 | }; |
||
205 | |||
206 | struct ieee80211_replay_event {
|
||
207 | uint8_t iev_src[6]; /* src MAC */ |
||
208 | uint8_t iev_dst[6]; /* dst MAC */ |
||
209 | uint8_t iev_cipher; /* cipher type */
|
||
210 | uint8_t iev_keyix; /* key id/index */
|
||
211 | uint64_t iev_keyrsc; /* RSC from key */
|
||
212 | uint64_t iev_rsc; /* RSC from frame */
|
||
213 | }; |
||
214 | |||
215 | struct ieee80211_michael_event {
|
||
216 | uint8_t iev_src[6]; /* src MAC */ |
||
217 | uint8_t iev_dst[6]; /* dst MAC */ |
||
218 | uint8_t iev_cipher; /* cipher type */
|
||
219 | uint8_t iev_keyix; /* key id/index */
|
||
220 | }; |
||
221 | |||
222 | #define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */ |
||
223 | #define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */ |
||
224 | #define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */ |
||
225 | #define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */ |
||
226 | #define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */ |
||
227 | #define RTM_IEEE80211_SCAN 105 /* scan complete, results available */ |
||
228 | #define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */ |
||
229 | #define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */ |
||
230 | #define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */ |
||
231 | |||
232 | #ifdef _KERNEL
|
||
233 | #define ticks hardclock_ticks
|
||
234 | #define ovbcopy(__src, __dst, __n) ((void)memmove(__dst, __src, __n)) |
||
235 | |||
236 | void if_printf(struct ifnet *, const char *, ...); |
||
237 | void get_random_bytes(void *, size_t); |
||
238 | |||
239 | void ieee80211_sysctl_attach(struct ieee80211com *); |
||
240 | void ieee80211_sysctl_detach(struct ieee80211com *); |
||
241 | void ieee80211_load_module(const char *); |
||
242 | |||
243 | void ieee80211_rssadapt_sysctl_setup(struct sysctllog **); |
||
244 | |||
245 | void ieee80211_init(void); |
||
246 | #define IEEE80211_CRYPTO_SETUP(name) \
|
||
247 | static void name(void); \ |
||
248 | __link_set_add_text(ieee80211_funcs, name); \ |
||
249 | static void name(void) |
||
250 | #endif
|
||
251 | |||
252 | #endif /* !_NET80211_IEEE80211_NETBSD_H_ */ |