1 /* 2 * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * $FreeBSD: src/sys/net80211/ieee80211_freebsd.h,v 1.5.2.1 2005/09/03 22:40:02 sam Exp $ 28 * $DragonFly: src/sys/netproto/802_11/ieee80211_dragonfly.h,v 1.1 2006/05/18 13:51:46 sephe Exp $ 29 */ 30 #ifndef _NET80211_IEEE80211_DRAGONFLY_H_ 31 #define _NET80211_IEEE80211_DRAGONFLY_H_ 32 33 /* 34 * Per-node power-save queue definitions. 35 */ 36 #define IEEE80211_NODE_SAVEQ_INIT(_ni, _name) do { \ 37 (_ni)->ni_savedq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE; \ 38 } while (0) 39 #define IEEE80211_NODE_SAVEQ_DESTROY(_ni) ((void)0) 40 #define IEEE80211_NODE_SAVEQ_QLEN(_ni) IF_QLEN(&(_ni)->ni_savedq) 41 #define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _m, _qlen) do { \ 42 IF_DEQUEUE(&(_ni)->ni_savedq, _m); \ 43 (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ 44 } while (0) 45 #define IEEE80211_NODE_SAVEQ_DRAIN(_ni, _qlen) do { \ 46 (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ 47 IF_DRAIN(&(_ni)->ni_savedq); \ 48 } while (0) 49 /* XXX could be optimized */ 50 #define _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(_ni, _m) do { \ 51 IF_DEQUEUE(&(_ni)->ni_savedq, m); \ 52 } while (0) 53 #define _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _m, _qlen, _age) do {\ 54 (_m)->m_nextpkt = NULL; \ 55 if ((_ni)->ni_savedq.ifq_tail != NULL) { \ 56 _age -= M_AGE_GET((_ni)->ni_savedq.ifq_tail); \ 57 (_ni)->ni_savedq.ifq_tail->m_nextpkt = (_m); \ 58 } else { \ 59 (_ni)->ni_savedq.ifq_head = (_m); \ 60 } \ 61 M_AGE_SET(_m, _age); \ 62 (_ni)->ni_savedq.ifq_tail = (_m); \ 63 (_qlen) = ++(_ni)->ni_savedq.ifq_len; \ 64 } while (0) 65 66 /* 67 * Node reference counting definitions. 68 * 69 * ieee80211_node_initref initialize the reference count to 1 70 * ieee80211_node_incref add a reference 71 * ieee80211_node_decref remove a reference 72 * ieee80211_node_dectestref remove a reference and return 1 if this 73 * is the last reference, otherwise 0 74 * ieee80211_node_refcnt reference count for printing (only) 75 */ 76 #include <machine/atomic.h> 77 78 #define ieee80211_node_initref(_ni) \ 79 do { ((_ni)->ni_refcnt = 1); } while (0) 80 #define ieee80211_node_incref(_ni) \ 81 atomic_add_int(&(_ni)->ni_refcnt, 1) 82 #define ieee80211_node_decref(_ni) \ 83 atomic_subtract_int(&(_ni)->ni_refcnt, 1) 84 struct ieee80211_node; 85 int ieee80211_node_dectestref(struct ieee80211_node *ni); 86 #define ieee80211_node_refcnt(_ni) (_ni)->ni_refcnt 87 88 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, u_int pktlen); 89 #define M_LINK0 M_PROTO1 /* WEP requested */ 90 #define M_PWR_SAV M_PROTO4 /* bypass PS handling */ 91 #define M_MORE_DATA M_PROTO5 /* more data frames to follow */ 92 /* 93 * Encode WME access control bits in the PROTO flags. 94 * This is safe since it's passed directly in to the 95 * driver and there's no chance someone else will clobber 96 * them on us. 97 */ 98 #define M_WME_AC_MASK (M_PROTO2|M_PROTO3) 99 /* XXX 5 is wrong if M_PROTO* are redefined */ 100 #define M_WME_AC_SHIFT 5 101 102 #define M_WME_SETAC(m, ac) \ 103 ((m)->m_flags = ((m)->m_flags &~ M_WME_AC_MASK) | \ 104 ((ac) << M_WME_AC_SHIFT)) 105 #define M_WME_GETAC(m) (((m)->m_flags >> M_WME_AC_SHIFT) & 0x3) 106 107 /* 108 * Mbufs on the power save queue are tagged with an age and 109 * timed out. We reuse the hardware checksum field in the 110 * mbuf packet header to store this data. 111 */ 112 #define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v) 113 #define M_AGE_GET(m) (m->m_pkthdr.csum_data) 114 #define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj) 115 116 void get_random_bytes(void *, size_t); 117 118 struct ieee80211com; 119 120 void ieee80211_sysctl_attach(struct ieee80211com *); 121 void ieee80211_sysctl_detach(struct ieee80211com *); 122 123 void ieee80211_load_module(const char *); 124 int ieee80211_mbuf_append(struct mbuf *, int, const uint8_t *); 125 struct mbuf *ieee80211_mbuf_clone(struct mbuf *, int); 126 127 /* XXX this stuff belongs elsewhere */ 128 /* 129 * Message formats for messages from the net80211 layer to user 130 * applications via the routing socket. These messages are appended 131 * to an if_announcemsghdr structure. 132 */ 133 struct ieee80211_join_event { 134 uint8_t iev_addr[6]; 135 }; 136 137 struct ieee80211_leave_event { 138 uint8_t iev_addr[6]; 139 }; 140 141 struct ieee80211_replay_event { 142 uint8_t iev_src[6]; /* src MAC */ 143 uint8_t iev_dst[6]; /* dst MAC */ 144 uint8_t iev_cipher; /* cipher type */ 145 uint8_t iev_keyix; /* key id/index */ 146 uint64_t iev_keyrsc; /* RSC from key */ 147 uint64_t iev_rsc; /* RSC from frame */ 148 }; 149 150 struct ieee80211_michael_event { 151 uint8_t iev_src[6]; /* src MAC */ 152 uint8_t iev_dst[6]; /* dst MAC */ 153 uint8_t iev_cipher; /* cipher type */ 154 uint8_t iev_keyix; /* key id/index */ 155 }; 156 157 #define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */ 158 #define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */ 159 #define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */ 160 #define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */ 161 #define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */ 162 #define RTM_IEEE80211_SCAN 105 /* scan complete, results available */ 163 #define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */ 164 #define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */ 165 #define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */ 166 167 #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */ 168