42#include <sys/malloc.h>
43#include <sys/kernel.h>
45#include <sys/socket.h>
46#include <sys/sockio.h>
47#include <sys/endian.h>
50#include <sys/sysctl.h>
53#include <net/if_var.h>
54#include <net/if_media.h>
55#include <net/if_llc.h>
56#include <net/ethernet.h>
63#ifdef IEEE80211_SUPPORT_SUPERG
66#ifdef IEEE80211_SUPPORT_TDMA
71#define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2)
111#ifdef IEEE80211_SUPPORT_TDMA
235#ifdef IEEE80211_DEBUG
236 if (ieee80211_msg_debug(vap)) {
238 "synchronized with %s ssid ",
243 printf(
" channel %d start %uMb\n",
273 "%s: unexpected state transition %s -> %s\n", __func__,
314 struct ifnet *ifp = vap->
iv_ifp;
317 struct ether_header *eh;
318 int hdrspace, need_tap = 1;
319 uint8_t dir, type, subtype, qos;
321 int is_hw_decrypted = 0;
322 int has_decrypted = 0;
349 KASSERT(ni != NULL, (
"null node"));
357 "too short (1): len %u", m->m_pkthdr.len);
372 ni->
ni_macaddr, NULL,
"wrong version, fc %02x:%02x",
390 NULL,
"too short (2): len %u",
407 bssid, NULL,
"%s",
"not to bss");
426 wh,
"data",
"not in RUN state (%s)",
461 if (m->m_len < hdrspace &&
462 (m = m_pullup(m, hdrspace)) == NULL) {
465 "data too short: expecting %u", hdrspace);
471 wh,
"data",
"incorrect dir 0x%x", dir);
504 wh,
"WEP",
"%s",
"PRIVACY off");
515 wh->
i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
575 eh = mtod(m,
struct ether_header *);
588 eh->ether_type != htons(ETHERTYPE_PAE)) {
591 "unknown port: ether type 0x%x len %u",
592 eh == NULL ? -1 : eh->ether_type,
604 ((has_decrypted == 0) && (m->m_flags &
M_WEP) == 0) &&
605 (is_hw_decrypted == 0) &&
607 eh->ether_type != htons(ETHERTYPE_PAE))) {
622#ifdef IEEE80211_SUPPORT_SUPERG
639 wh,
"data",
"incorrect dir 0x%x", dir);
650#ifdef IEEE80211_DEBUG
651 if ((ieee80211_msg_debug(vap) &&
doprint(vap, subtype)) ||
653 if_printf(ifp,
"received %s from %s rssi %d\n",
655 ether_sprintf(wh->
i_addr2), rssi);
660 wh, NULL,
"%s",
"WEP set but not permitted");
675 wh,
"bad",
"frame type 0x%x", type);
680 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
693 static const uint32_t brates = (1<<2*1)|(1<<2*2)|(1<<11)|(1<<2*11);
697 if (xrates != NULL || rates == NULL)
699 for (i = 0; i < rates[1]; i++) {
701 if (r > 2*11 || ((1<<r) & brates) == 0)
716 uint8_t *ssid, *rates, *xrates;
718 int ht_state_change = 0;
722 frm = (uint8_t *)&wh[1];
723 efrm = mtod(m0, uint8_t *) + m0->m_len;
726 "%s: recv mgmt frame, addr2=%6D, ni=%p (%6D) fc=%.02x %.02x\n",
891 wh, NULL,
"wrong state %s",
899 wh, NULL,
"%s",
"not unicast");
910 ssid = rates = xrates = NULL;
911 while (efrm - frm > 1) {
935 "%s",
"no ssid with ssid suppression enabled");
942 "%s",
"recv probe req");
961 if ((ni == vap->
iv_bss) &&
964 wh, NULL,
"%s",
"unknown node");
969 wh, NULL,
"%s",
"not for us");
973 wh, NULL,
"wrong state %s",
992 wh, NULL,
"%s",
"not handled");
998 wh,
"mgt",
"subtype 0x%x not handled", subtype);
1003#undef IEEE80211_VERIFY_LENGTH
1004#undef IEEE80211_VERIFY_ELEMENT
1020#ifdef IEEE80211_DEBUG
1041 wh, NULL,
"%s",
"not handled");
1046 wh,
"mgt",
"subtype 0x%x not handled", subtype);
#define IEEE80211_RX_F_DECRYPTED
#define IEEE80211_RATE_MAXSIZE
#define IEEE80211_IS_CHAN_RADAR(_c)
#define IEEE80211_CHAN_ANYC
int ieee80211_chan2ieee(struct ieee80211com *ic, const struct ieee80211_channel *c)
struct ieee80211_channel * ieee80211_lookup_channel_rxstatus(struct ieee80211vap *vap, const struct ieee80211_rx_stats *rxs)
#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ
#define IEEE80211_FC0_SUBTYPE_ACTION
#define IEEE80211_FC0_TYPE_CTL
#define IEEE80211_FC0_TYPE_MASK
#define IEEE80211_FC0_SUBTYPE_ATIM
#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ
#define IEEE80211_FC0_SUBTYPE_PROBE_REQ
#define IEEE80211_FC1_PROTECTED
#define IEEE80211_HAS_SEQ(type, subtype)
#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP
#define IEEE80211_FC0_VERSION_MASK
#define IEEE80211_FC0_SUBTYPE_DEAUTH
#define IEEE80211_FC1_DIR_DSTODS
#define IEEE80211_RATE_VAL
#define IEEE80211_FC0_SUBTYPE_BAR
#define IEEE80211_FC0_TYPE_MGT
#define IEEE80211_FC0_SUBTYPE_PROBE_RESP
#define IEEE80211_FC0_TYPE_DATA
#define IEEE80211_IS_MULTICAST(_a)
#define IEEE80211_QOS_HAS_SEQ(wh)
#define IEEE80211_FC0_SUBTYPE_TIMING_ADV
#define IEEE80211_FC0_SUBTYPE_DISASSOC
#define TID_TO_WME_AC(_tid)
#define IEEE80211_FC1_DIR_NODS
#define IEEE80211_FC1_DIR_MASK
#define IEEE80211_FC0_VERSION_0
#define IEEE80211_FC0_SUBTYPE_NODATA
#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP
#define IEEE80211_FC0_SUBTYPE_QOS
#define IEEE80211_FC0_SUBTYPE_ACTION_NOACK
#define IEEE80211_FC0_SUBTYPE_QOS_NULL
#define IEEE80211_NWID_LEN
#define IEEE80211_QOS_AMSDU
@ IEEE80211_ELEMID_XRATES
#define IEEE80211_FC0_SUBTYPE_MASK
#define IEEE80211_CAPINFO_IBSS
#define IEEE80211_FC0_SUBTYPE_BEACON
#define IEEE80211_FC0_SUBTYPE_AUTH
static void sta_leave(void *arg, struct ieee80211_node *ni)
void ieee80211_adhoc_attach(struct ieee80211com *ic)
static int is11bclient(const uint8_t *rates, const uint8_t *xrates)
static int adhoc_input(struct ieee80211_node *, struct mbuf *, const struct ieee80211_rx_stats *, int, int)
void ieee80211_adhoc_detach(struct ieee80211com *ic)
static void adhoc_recv_mgmt(struct ieee80211_node *, struct mbuf *, int subtype, const struct ieee80211_rx_stats *, int, int)
static void adhoc_vattach(struct ieee80211vap *)
static __inline int doprint(struct ieee80211vap *vap, int subtype)
#define IEEE80211_RATE2MBS(r)
static void ahdemo_recv_mgmt(struct ieee80211_node *, struct mbuf *, int subtype, const struct ieee80211_rx_stats *rxs, int, int)
static void adhoc_vdetach(struct ieee80211vap *vap)
static int adhoc_newstate(struct ieee80211vap *, enum ieee80211_state, int)
static void adhoc_recv_ctl(struct ieee80211_node *, struct mbuf *, int subtype)
int ieee80211_crypto_decap(struct ieee80211_node *ni, struct mbuf *m, int hdrlen, struct ieee80211_key **key)
int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, struct mbuf *m, int force)
#define IEEE80211_LOCK_ASSERT(_ic)
struct ieee80211_channel * ieee80211_ht_adjust_channel(struct ieee80211com *ic, struct ieee80211_channel *chan, int flags)
void ieee80211_recv_bar(struct ieee80211_node *ni, struct mbuf *m0)
int ieee80211_ht_updateparams_final(struct ieee80211_node *ni, const uint8_t *htcapie, const uint8_t *htinfoie)
int ieee80211_ampdu_reorder(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_rx_stats *rxs)
struct mbuf * ieee80211_decap_amsdu(struct ieee80211_node *ni, struct mbuf *m)
void ieee80211_ht_updateparams(struct ieee80211_node *ni, const uint8_t *htcapie, const uint8_t *htinfoie)
struct ieee80211_node * ieee80211_fakeup_adhoc_node(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
void ieee80211_reset_bss(struct ieee80211vap *vap)
void ieee80211_node_authorize(struct ieee80211_node *ni)
void ieee80211_init_neighbor(struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_scanparams *sp)
void ieee80211_update_chw(struct ieee80211com *ic)
void ieee80211_node_leave(struct ieee80211_node *ni)
struct ieee80211_node * ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *wh, const struct ieee80211_scanparams *sp)
int ieee80211_ibss_node_check_new(struct ieee80211_node *ni, const struct ieee80211_scanparams *scan)
int ieee80211_iterate_nodes_vap(struct ieee80211_node_table *nt, struct ieee80211vap *vap, ieee80211_iter_func *f, void *arg)
void ieee80211_create_ibss(struct ieee80211vap *vap, struct ieee80211_channel *chan)
#define IEEE80211_RSSI_LPF(x, y)
static __inline int ieee80211_node_is_authorized(const struct ieee80211_node *ni)
#define IEEE80211_NODE_STAT(ni, stat)
int ieee80211_send_proberesp(struct ieee80211vap *vap, const uint8_t da[IEEE80211_ADDR_LEN], int legacy)
int ieee80211_send_probereq(struct ieee80211_node *ni, const uint8_t sa[IEEE80211_ADDR_LEN], const uint8_t da[IEEE80211_ADDR_LEN], const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t *ssid, size_t ssidlen)
void ieee80211_print_essid(const uint8_t *essid, int len)
const char * ieee80211_state_name[IEEE80211_S_MAX]
#define IEEE80211_SEND_LEGACY_11B
static __inline uint8_t ieee80211_gettid(const struct ieee80211_frame *wh)
static __inline uint8_t * ieee80211_getqos(void *data)
static __inline const char * ieee80211_mgt_subtype_name(uint8_t subtype)
void ieee80211_radiotap_rx(struct ieee80211vap *vap0, struct mbuf *m)
void ieee80211_add_scan(struct ieee80211vap *vap, struct ieee80211_channel *curchan, const struct ieee80211_scanparams *sp, const struct ieee80211_frame *wh, int subtype, int rssi, int noise)
void ieee80211_cancel_scan(struct ieee80211vap *vap)
int ieee80211_check_scan(struct ieee80211vap *vap, int flags, u_int duration, u_int mindwell, u_int maxdwell, u_int nssid, const struct ieee80211_scan_ssid ssids[])
int ieee80211_check_scan_current(struct ieee80211vap *vap)
void ieee80211_probe_curchan(struct ieee80211vap *vap, int force)
static __inline struct mbuf * ieee80211_decap_fastframe(struct ieee80211vap *vap, struct ieee80211_node *ni, struct mbuf *m)
void ieee80211_tdma_vattach(struct ieee80211vap *)
static __inline int ieee80211_radiotap_active_vap(const struct ieee80211vap *vap)
#define IEEE80211_MSG_STATE
#define IEEE80211_FEXT_PROBECHAN
static __inline int ieee80211_hdrspace(struct ieee80211com *ic, const void *data)
#define IEEE80211_MSG_ANY
#define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt,...)
#define IEEE80211_ADDR_EQ(a1, a2)
#define IEEE80211_F_PRIVACY
#define IEEE80211_F_HIDESSID
#define IEEE80211_MSG_DEBUG
#define IEEE80211_DISCARD_MAC(_vap, _m, _mac, _type, _fmt,...)
#define IEEE80211_DPRINTF(_vap, _m, _fmt,...)
#define IEEE80211_MSG_INPUT
#define IEEE80211_DISCARD(_vap, _m, _wh, _type, _fmt,...)
#define ieee80211_msg_dumppkts(_vap)
#define IEEE80211_FEXT_SCANREQ
#define IEEE80211_F_DROPUNENC
uint8_t i_addr1[IEEE80211_ADDR_LEN]
uint8_t i_addr2[IEEE80211_ADDR_LEN]
uint8_t i_addr3[IEEE80211_ADDR_LEN]
struct ieee80211com * ni_ic
uint8_t ni_macaddr[IEEE80211_ADDR_LEN]
uint8_t ni_bssid[IEEE80211_ADDR_LEN]
struct ieee80211vap * ni_vap
struct ieee80211vap * ni_wdsvap
union ieee80211_node::@24 ni_tstamp
uint8_t ni_essid[IEEE80211_NWID_LEN]
uint32_t is_rx_badversion
uint32_t is_rx_badsubtype
uint32_t is_rx_ssidmismatch
uint32_t is_rx_mgtdiscard
uint32_t is_rx_unencrypted
ieee80211vap_attach ic_vattach[IEEE80211_OPMODE_MAX]
struct ieee80211_node_table ic_sta
struct ieee80211_wme_state ic_wme
int(* ic_recv_action)(struct ieee80211_node *, const struct ieee80211_frame *, const uint8_t *frm, const uint8_t *efrm)
struct ieee80211_channel * ic_curchan
void(* ic_newassoc)(struct ieee80211_node *, int)
struct ieee80211com * iv_ic
struct ieee80211_node * iv_bss
enum ieee80211_roamingmode iv_roaming
enum ieee80211_opmode iv_opmode
struct ieee80211_channel * iv_des_chan
uint8_t iv_myaddr[IEEE80211_ADDR_LEN]
struct ieee80211_stats iv_stats
void(* iv_recv_mgmt)(struct ieee80211_node *, struct mbuf *, int, const struct ieee80211_rx_stats *, int, int)
u_int iv_scanreq_mindwell
enum ieee80211_state iv_state
u_int iv_scanreq_maxdwell
void(* iv_opdetach)(struct ieee80211vap *)
uint16_t iv_scanreq_flags
void(* iv_recv_ctl)(struct ieee80211_node *, struct mbuf *, int)
int(* iv_input)(struct ieee80211_node *, struct mbuf *, const struct ieee80211_rx_stats *, int, int)
struct ieee80211_scan_ssid iv_scanreq_ssid[IEEE80211_SCAN_MAX_SSID]
void(* iv_sta_ps)(struct ieee80211vap *, int)
u_int iv_scanreq_duration
int(* iv_newstate)(struct ieee80211vap *, enum ieee80211_state, int)