net80211_impl.h revision bcb5c89da22515e2ccf139578bad3caebcd716ad
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SYS_NET80211_IMPL_H
#define _SYS_NET80211_IMPL_H
#include <sys/sysmacros.h>
#include <sys/net80211_proto.h>
#include <sys/net80211.h>
#include <sys/mac_wifi.h>
/*
* IEEE802.11 kernel support module
*/
#ifdef __cplusplus
extern "C" {
#endif
#define IEEE80211_TXPOWER_MIN 0 /* kill radio */
/* NB: min+max come from WiFi requirements */
/*
* The RSSI values of two node are taken as almost the same when
* the difference between these two node's RSSI values is within
* IEEE80211_RSSI_CMP_THRESHOLD
*/
#define IEEE80211_RSSI_CMP_THRESHOLD 5
/*
* Each ieee80211com instance has a single timer that fires once a
* second. This is used to initiate various work depending on the
* state of the instance: scanning (passive or active), ``transition''
* (waiting for a response to a management frame when operating
* as a station), and node inactivity processing (when operating
* as an AP). For inactivity processing each node has a timeout
* set in it's in_inact field that is decremented on each timeout
* and the node is reclaimed when the counter goes to zero. We
* use different inactivity timeout values depending on whether
* the node is associated and authorized (either by 802.1x or
* authorized. The latter timeout is shorter to more aggressively
* reclaim nodes that leave part way through the 802.1x exchange.
*
* IEEE80211_INACT_WAIT defines node table's inactivity interval in
* seconds. On timeout, node table's registered nt_timeout callback
* function is executed. Each node in the node table has a timeout
* set in its in_inact field with IEEE80211_INACT_<state>. In
* nt_timeout function, node table is iterated and each node's
* in_inact is decremented. So IEEE80211_INACT_<state> is defined in
* the form [inact_sec]/IEEE80211_INACT_WAIT.
*
*/
/* associated but not authorized */
/*
* Useful combinations of channel characteristics.
*/
#define IEEE80211_CHAN_FHSS \
#define IEEE80211_CHAN_A \
#define IEEE80211_CHAN_B \
#define IEEE80211_CHAN_PUREG \
#define IEEE80211_CHAN_G \
#define IEEE80211_CHAN_T \
#define IEEE80211_CHAN_108G \
#define IEEE80211_CHAN_ALL \
#define IEEE80211_CHAN_ALLTURBO \
#define IEEE80211_IS_CHAN_FHSS(_c) \
#define IEEE80211_IS_CHAN_A(_c) \
#define IEEE80211_IS_CHAN_B(_c) \
#define IEEE80211_IS_CHAN_PUREG(_c) \
#define IEEE80211_IS_CHAN_G(_c) \
#define IEEE80211_IS_CHAN_ANYG(_c) \
#define IEEE80211_IS_CHAN_T(_c) \
#define IEEE80211_IS_CHAN_108G(_c) \
#define IEEE80211_IS_CHAN_OFDM(_c) \
#define IEEE80211_IS_CHAN_CCK(_c) \
#define IEEE80211_IS_CHAN_GFSK(_c) \
#define IEEE80211_IS_CHAN_PASSIVE(_c) \
/* ni_chan encoding for FH phy */
#define IEEE80211_FH_CHANMOD 80
#define IEEE80211_FH_CHANSET(chan) \
#define IEEE80211_FH_CHANPAT(chan) \
((chan) % IEEE80211_FH_CHANMOD)
#define IEEE80211_MAXRSSI 127
/* Debug Flags */
/* Error flags returned by ieee80211_match_bss */
#define IEEE80211_BADCHAN 0x01
#define IEEE80211_BADOPMODE 0x02
#define IEEE80211_BADPRIVACY 0x04
#define IEEE80211_BADRATE 0x08
#define IEEE80211_BADESSID 0x10
#define IEEE80211_BADBSSID 0x20
#define IEEE80211_NODEFAIL 0x40
typedef struct ieee80211_impl {
struct ieee80211com *ic;
/*
* scan cache. Pointer variables should be set to NULL
* if no data is available. Pointer references can be to
* local data; any information that is saved will be copied.
* All multi-byte values must be in host byte order.
*/
struct ieee80211_scanparams {
enum ieee80211_phytype phytype;
};
/* Verify the existence and length of __elem or get out. */
ieee80211_err("ieee80211: no #__elem \n"); \
__func; \
} \
(__elem)[1]); \
__func; \
} \
} while (0)
"ie of type %s too short", \
_func; \
} \
} while (0)
if ((_ssid)[1] != 0 && \
_func; \
} \
} while (0)
#define IEEE80211_N(a) (sizeof (a) / sizeof (a[0]))
#define IEEE80211_LOCK(_ic) \
#define IEEE80211_UNLOCK(_ic) \
#define IEEE80211_IS_LOCKED(_ic) \
#define IEEE80211_LOCK_ASSERT(_ic) \
#define IEEE80211_NODE_LOCK(_nt) \
#define IEEE80211_NODE_UNLOCK(_nt) \
#define IEEE80211_NODE_IS_LOCKED(_nt) \
#define IEEE80211_NODE_LOCK_ASSERT(_nt) \
#define ieee80211_node_hash(addr) \
#define IEEE80211_RV(v) ((v) & IEEE80211_RATE_VAL)
#define IEEE80211_SUBTYPE_NAME(subtype) \
extern const char *ieee80211_mgt_subtype_name[];
extern const char *ieee80211_phymode_name[];
void ieee80211_err(const int8_t *, ...);
int ieee80211_hdrspace(const void *);
void ieee80211_mac_update(ieee80211com_t *);
/* node */
void ieee80211_node_attach(ieee80211com_t *);
void ieee80211_node_lateattach(ieee80211com_t *);
void ieee80211_node_detach(ieee80211com_t *);
void ieee80211_reset_bss(ieee80211com_t *);
void ieee80211_cancel_scan(ieee80211com_t *);
const struct ieee80211_frame *, int, int, int);
const struct ieee80211_scanparams *);
const struct ieee80211_frame *, const struct ieee80211_scanparams *);
const uint8_t *);
/* proto */
void ieee80211_proto_attach(ieee80211com_t *);
int ieee80211_fix_rate(ieee80211_node_t *, int);
void ieee80211_setbasicrates(struct ieee80211_rateset *,
enum ieee80211_phymode);
void ieee80211_reset_erp(ieee80211com_t *);
/* input */
const uint8_t *, int);
int, int, uint32_t);
/* output */
size_t);
/* crypto */
/* generic */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_NET80211_IMPL_H */