build - Fixup world/kernel build
[dragonfly.git] / sys / netproto / 802_11 / ieee80211_input.h
blob8f99734f1ae18273e864033e824f4f7cfc55fb2e
1 /*-
2 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
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.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * $FreeBSD: head/sys/net80211/ieee80211_input.h 195757 2009-07-18 20:19:53Z sam $
26 * $DragonFly$
28 #ifndef _NET80211_IEEE80211_INPUT_H_
29 #define _NET80211_IEEE80211_INPUT_H_
31 /* Verify the existence and length of __elem or get out. */
32 #define IEEE80211_VERIFY_ELEMENT(__elem, __maxlen, _action) do { \
33 if ((__elem) == NULL) { \
34 IEEE80211_DISCARD(vap, IEEE80211_MSG_ELEMID, \
35 wh, NULL, "%s", "no " #__elem ); \
36 vap->iv_stats.is_rx_elem_missing++; \
37 _action; \
38 } else if ((__elem)[1] > (__maxlen)) { \
39 IEEE80211_DISCARD(vap, IEEE80211_MSG_ELEMID, \
40 wh, NULL, "bad " #__elem " len %d", (__elem)[1]); \
41 vap->iv_stats.is_rx_elem_toobig++; \
42 _action; \
43 } \
44 } while (0)
46 #define IEEE80211_VERIFY_LENGTH(_len, _minlen, _action) do { \
47 if ((_len) < (_minlen)) { \
48 IEEE80211_DISCARD(vap, IEEE80211_MSG_ELEMID, \
49 wh, NULL, "ie too short, got %d, expected %d", \
50 (_len), (_minlen)); \
51 vap->iv_stats.is_rx_elem_toosmall++; \
52 _action; \
53 } \
54 } while (0)
56 void ieee80211_ssid_mismatch(struct ieee80211vap *, const char *tag,
57 uint8_t mac[IEEE80211_ADDR_LEN], uint8_t *ssid);
59 #ifdef IEEE80211_DEBUG
61 #define IEEE80211_VERIFY_SSID(_ni, _ssid, _action) do { \
62 if ((_ssid)[1] != 0 && \
63 ((_ssid)[1] != (_ni)->ni_esslen || \
64 memcmp((_ssid) + 2, (_ni)->ni_essid, (_ssid)[1]) != 0)) { \
65 if (ieee80211_msg_input(vap)) \
66 ieee80211_ssid_mismatch(vap, \
67 ieee80211_mgt_subtype_name[subtype >> \
68 IEEE80211_FC0_SUBTYPE_SHIFT], \
69 wh->i_addr2, _ssid); \
70 vap->iv_stats.is_rx_ssidmismatch++; \
71 _action; \
72 } \
73 } while (0)
74 #else /* !IEEE80211_DEBUG */
75 #define IEEE80211_VERIFY_SSID(_ni, _ssid, _action) do { \
76 if ((_ssid)[1] != 0 && \
77 ((_ssid)[1] != (_ni)->ni_esslen || \
78 memcmp((_ssid) + 2, (_ni)->ni_essid, (_ssid)[1]) != 0)) { \
79 vap->iv_stats.is_rx_ssidmismatch++; \
80 _action; \
81 } \
82 } while (0)
83 #endif /* !IEEE80211_DEBUG */
85 /* unalligned little endian access */
86 #define LE_READ_2(p) \
87 ((uint16_t) \
88 ((((const uint8_t *)(p))[0] ) | \
89 (((const uint8_t *)(p))[1] << 8)))
90 #define LE_READ_4(p) \
91 ((uint32_t) \
92 ((((const uint8_t *)(p))[0] ) | \
93 (((const uint8_t *)(p))[1] << 8) | \
94 (((const uint8_t *)(p))[2] << 16) | \
95 (((const uint8_t *)(p))[3] << 24)))
97 static __inline int
98 iswpaoui(const uint8_t *frm)
100 return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI);
103 static __inline int
104 iswmeoui(const uint8_t *frm)
106 return frm[1] > 3 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI);
109 static __inline int
110 iswmeparam(const uint8_t *frm)
112 return frm[1] > 5 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) &&
113 frm[6] == WME_PARAM_OUI_SUBTYPE;
116 static __inline int
117 iswmeinfo(const uint8_t *frm)
119 return frm[1] > 5 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) &&
120 frm[6] == WME_INFO_OUI_SUBTYPE;
123 static __inline int
124 isatherosoui(const uint8_t *frm)
126 return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI);
129 static __inline int
130 istdmaoui(const uint8_t *frm)
132 return frm[1] > 3 && LE_READ_4(frm+2) == ((TDMA_OUI_TYPE<<24)|TDMA_OUI);
135 static __inline int
136 ishtcapoui(const uint8_t *frm)
138 return frm[1] > 3 && LE_READ_4(frm+2) == ((BCM_OUI_HTCAP<<24)|BCM_OUI);
141 static __inline int
142 ishtinfooui(const uint8_t *frm)
144 return frm[1] > 3 && LE_READ_4(frm+2) == ((BCM_OUI_HTINFO<<24)|BCM_OUI);
147 void ieee80211_deliver_data(struct ieee80211vap *,
148 struct ieee80211_node *, struct mbuf *);
149 struct mbuf *ieee80211_defrag(struct ieee80211_node *,
150 struct mbuf *, int);
151 struct mbuf *ieee80211_realign(struct ieee80211vap *, struct mbuf *, size_t);
152 struct mbuf *ieee80211_decap(struct ieee80211vap *, struct mbuf *, int);
153 struct mbuf *ieee80211_decap1(struct mbuf *, int *);
154 int ieee80211_setup_rates(struct ieee80211_node *ni,
155 const uint8_t *rates, const uint8_t *xrates, int flags);
156 void ieee80211_send_error(struct ieee80211_node *,
157 const uint8_t mac[IEEE80211_ADDR_LEN], int subtype, int arg);
158 int ieee80211_alloc_challenge(struct ieee80211_node *);
159 int ieee80211_parse_beacon(struct ieee80211_node *, struct mbuf *,
160 struct ieee80211_scanparams *);
161 int ieee80211_parse_action(struct ieee80211_node *, struct mbuf *);
162 #endif /* _NET80211_IEEE80211_INPUT_H_ */