freebsd-nq/sys/net80211/ieee80211_ddb.c
Marko Zec 8b615593fc Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit

Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.

Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().

Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).

All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).

(*) netipsec/keysock.c did not validate depending on compile time options.

Implemented by:	julian, bz, brooks, zec
Reviewed by:	julian, bz, brooks, kris, rwatson, ...
Approved by:	julian (mentor)
Obtained from:	//depot/projects/vimage-commit2/...
X-MFC after:	never
Sponsored by:	NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00

805 lines
26 KiB
C

/*-
* Copyright (c) 2007-2008 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
* documentation and/or other materials provided with the distribution.
*
* 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_ddb.h"
#include "opt_wlan.h"
#ifdef DDB
/*
* IEEE 802.11 DDB support
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/ethernet.h>
#include <net80211/ieee80211_var.h>
#include <ddb/ddb.h>
#include <ddb/db_sym.h>
#define IEEE80211_MSG_BITS \
"\20\3IOCTL\4WDS\5ACTION\6RATECTL\7ROAM\10INACT\11DOTH\12SUPERG" \
"\13WME\14ACL\15WPA\16RADKEYS\17RADDUMP\20RADIUS\21DOT1X\22POWER" \
"\23STATE\24OUTPUT\25SCAN\26AUTH\27ASSOC\30NODE\31ELEMID\32XRATE" \
"\33INPUT\34CRYPTO\35DUPMPKTS\36DEBUG\3711N"
#define IEEE80211_F_BITS \
"\20\1TURBOP\2COMP\3FF\4BURST\5PRIVACY\6PUREG\10SCAN\11ASCAN\12SIBSS" \
"\13SHSLOT\14PMGTON\15DESBSSID\16WME\17BGSCAN\20SWRETRY\21TXPOW_FIXED" \
"\22IBSSON\23SHPREAMBLE\24DATAPAD\25USEPROT\26USERBARKER\27CSAPENDING" \
"\30WPA1\31WPA2\32DROPUNENC\33COUNTERM\34HIDESSID\35NOBRIDG\36PCF" \
"\37DOTH\40DWDS"
#define IEEE80211_FEXT_BITS \
"\20\1NONHT_PR\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \
"\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\22WDSLEGACY\23PROBECHAN\24HT" \
"\25AMDPU_TX\26AMPDU_TX\27AMSDU_TX\30AMSDU_RX\31USEHT40\32PUREN" \
"\33SHORTGI20\34SHORTGI40\35HTCOMPAT\36RIFS"
#define IEEE80211_FVEN_BITS "\20"
#define IEEE80211_C_BITS \
"\20\1STA\7FF\10TURBOP\11IBSS\12PMGT" \
"\13HOSTAP\14AHDEMO\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE" \
"\21MONITOR\22DFS\30WPA1\31WPA2\32BURST\33WME\34WDS\36BGSCAN" \
"\37TXFRAG"
#define IEEE80211_C_CRYPTO_BITS \
"\20\1WEP\2TKIP\3AES\4AES_CCM\5TKIPMIC\6CKIP\12PMGT"
#define IEEE80211_C_HTCAP_BITS \
"\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
"\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS"
/* NB: policy bits not included */
#define IEEE80211_CHAN_BITS \
"\20\5TURBO\6CCK\7OFDM\0102GHZ\0115GHZ\12PASSIVE\13DYN\14GFSK" \
"\15STURBO\16HALF\17QUARTER\20HT20\21HT40U\22HT40D\23DFS"
#define IEEE80211_NODE_BITS \
"\20\1AUTH\2QOS\3ERP\5PWR_MGT\6AREF\7HT\10HTCOMPAT\11WPS\12TSN" \
"\13AMPDU_RX\14AMPDU_TX\15MIMO_PS\16MIMO_RTS\17RIFS\20SGI20\21SGI40"
#define IEEE80211_ERP_BITS \
"\20\1NON_ERP_PRESENT\2USE_PROTECTION\3LONG_PREAMBLE"
#define IEEE80211_CAPINFO_BITS \
"\20\1ESS\2IBSS\3CF_POLLABLE\4CF_POLLREQ\5PRIVACY\6SHORT_PREAMBLE" \
"\7PBCC\10CHNL_AGILITY\11SPECTRUM_MGMT\13SHORT_SLOTTIME\14RSN" \
"\16DSSOFDM"
#define IEEE80211_HTCAP_BITS \
"\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
"\13DELBA\14AMSDU(7935)\15DSSSCCK40\16PSMP\1740INTOLERANT" \
"\20LSIGTXOPPROT"
#define IEEE80211_AGGR_BITS \
"\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK"
#define DB_PRINTSYM(prefix, addr) \
db_printf(prefix " "); \
db_printsym((db_addr_t) addr, DB_STGY_ANY); \
db_printf("\n");
static void _db_show_sta(const struct ieee80211_node *);
static void _db_show_vap(const struct ieee80211vap *, int);
static void _db_show_com(const struct ieee80211com *,
int showvaps, int showsta, int showprocs);
static void _db_show_channel(const char *tag, const struct ieee80211_channel *);
static void _db_show_ssid(const char *tag, int ix, int len, const uint8_t *);
static void _db_show_appie(const char *tag, const struct ieee80211_appie *);
static void _db_show_key(const char *tag, int ix, const struct ieee80211_key *);
static void _db_show_roamparams(const char *tag, const void *arg,
const struct ieee80211_roamparam *rp);
static void _db_show_txparams(const char *tag, const void *arg,
const struct ieee80211_txparam *tp);
static void _db_show_stats(const struct ieee80211_stats *);
DB_SHOW_COMMAND(sta, db_show_sta)
{
if (!have_addr) {
db_printf("usage: show sta <addr>\n");
return;
}
_db_show_sta((const struct ieee80211_node *) addr);
}
DB_SHOW_COMMAND(vap, db_show_vap)
{
int i, showprocs = 0;
if (!have_addr) {
db_printf("usage: show vap <addr>\n");
return;
}
for (i = 0; modif[i] != '\0'; i++)
switch (modif[i]) {
case 'a':
showprocs = 1;
break;
case 'p':
showprocs = 1;
break;
}
_db_show_vap((const struct ieee80211vap *) addr, showprocs);
}
DB_SHOW_COMMAND(com, db_show_com)
{
const struct ieee80211com *ic;
int i, showprocs = 0, showvaps = 0, showsta = 0;
if (!have_addr) {
db_printf("usage: show com <addr>\n");
return;
}
for (i = 0; modif[i] != '\0'; i++)
switch (modif[i]) {
case 'a':
showsta = showvaps = showprocs = 1;
break;
case 's':
showsta = 1;
break;
case 'v':
showvaps = 1;
break;
case 'p':
showprocs = 1;
break;
}
ic = (const struct ieee80211com *) addr;
_db_show_com(ic, showvaps, showsta, showprocs);
}
DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps)
{
VNET_ITERATOR_DECL(vnet_iter);
const struct ifnet *ifp;
int i, showall = 0;
for (i = 0; modif[i] != '\0'; i++)
switch (modif[i]) {
case 'a':
showall = 1;
break;
}
VNET_FOREACH(vnet_iter) {
INIT_VNET_NET(vnet_iter);
TAILQ_FOREACH(ifp, &V_ifnet, if_list)
if (ifp->if_type == IFT_IEEE80211) {
const struct ieee80211com *ic = ifp->if_l2com;
if (!showall) {
const struct ieee80211vap *vap;
db_printf("%s: com %p vaps:",
ifp->if_xname, ic);
TAILQ_FOREACH(vap, &ic->ic_vaps,
iv_next)
db_printf(" %s(%p)",
vap->iv_ifp->if_xname, vap);
db_printf("\n");
} else
_db_show_com(ic, 1, 1, 1);
}
}
}
static void
_db_show_txampdu(const char *sep, int ix, const struct ieee80211_tx_ampdu *tap)
{
db_printf("%stxampdu[%d]: %p flags %b ac %u\n",
sep, ix, tap, tap->txa_flags, IEEE80211_AGGR_BITS, tap->txa_ac);
db_printf("%s token %u qbytes %d qframes %d start %u wnd %u\n",
sep, tap->txa_token, tap->txa_qbytes, tap->txa_qframes,
tap->txa_start, tap->txa_wnd);
db_printf("%s attempts %d nextrequest %d\n",
sep, tap->txa_attempts, tap->txa_nextrequest);
/* XXX packet q + timer */
}
static void
_db_show_rxampdu(const char *sep, int ix, const struct ieee80211_rx_ampdu *rap)
{
db_printf("%srxampdu[%d]: %p flags 0x%x tid %u\n",
sep, ix, rap, rap->rxa_flags, ix /*XXX */);
db_printf("%s qbytes %d qframes %d seqstart %u start %u wnd %u\n",
sep, rap->rxa_qbytes, rap->rxa_qframes,
rap->rxa_seqstart, rap->rxa_start, rap->rxa_wnd);
db_printf("%s age %d nframes %d\n",
sep, rap->rxa_age, rap->rxa_nframes);
}
static void
_db_show_sta(const struct ieee80211_node *ni)
{
int i;
db_printf("0x%p: mac %s refcnt %d\n", ni,
ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni));
db_printf("\tvap %p wdsvap %p ic %p table %p\n",
ni->ni_vap, ni->ni_wdsvap, ni->ni_ic, ni->ni_table);
db_printf("\tflags=%b\n", ni->ni_flags, IEEE80211_NODE_BITS);
db_printf("\tscangen %u authmode %u ath_flags 0x%x ath_defkeyix %u\n",
ni->ni_scangen, ni->ni_authmode,
ni->ni_ath_flags, ni->ni_ath_defkeyix);
db_printf("\tassocid 0x%x txpower %u vlan %u\n",
ni->ni_associd, ni->ni_txpower, ni->ni_vlan);
db_printf("\tjointime %d (%lu secs) challenge %p\n",
ni->ni_jointime, (unsigned long)(time_uptime - ni->ni_jointime),
ni->ni_challenge);
db_printf("\ties: data %p len %d\n", ni->ni_ies.data, ni->ni_ies.len);
db_printf("\t[wpa_ie %p rsn_ie %p wme_ie %p ath_ie %p\n",
ni->ni_ies.wpa_ie, ni->ni_ies.rsn_ie, ni->ni_ies.wme_ie,
ni->ni_ies.ath_ie);
db_printf("\t htcap_ie %p htinfo_ie %p]\n",
ni->ni_ies.htcap_ie, ni->ni_ies.htinfo_ie);
db_printf("\ttxseq %u rxseq %u fragno %u rxfragstamp %u\n",
ni->ni_txseqs[IEEE80211_NONQOS_TID],
ni->ni_rxseqs[IEEE80211_NONQOS_TID] >> IEEE80211_SEQ_SEQ_SHIFT,
ni->ni_rxseqs[IEEE80211_NONQOS_TID] & IEEE80211_SEQ_FRAG_MASK,
ni->ni_rxfragstamp);
db_printf("\trxfrag[0] %p rxfrag[1] %p rxfrag[2] %p\n",
ni->ni_rxfrag[0], ni->ni_rxfrag[1], ni->ni_rxfrag[2]);
db_printf("\trstamp %u avgrssi 0x%x (rssi %d) noise %d\n",
ni->ni_rstamp, ni->ni_avgrssi,
IEEE80211_RSSI_GET(ni->ni_avgrssi), ni->ni_noise);
db_printf("\tintval %u capinfo %b\n",
ni->ni_intval, ni->ni_capinfo, IEEE80211_CAPINFO_BITS);
db_printf("\tbssid %s", ether_sprintf(ni->ni_bssid));
_db_show_ssid(" essid ", 0, ni->ni_esslen, ni->ni_essid);
db_printf("\n");
_db_show_channel("\tchannel", ni->ni_chan);
db_printf("\n");
db_printf("\terp %b dtim_period %u dtim_count %u\n",
ni->ni_erp, IEEE80211_ERP_BITS,
ni->ni_dtim_period, ni->ni_dtim_count);
db_printf("\thtcap %b htparam 0x%x htctlchan %u ht2ndchan %u\n",
ni->ni_htcap, IEEE80211_HTCAP_BITS,
ni->ni_htparam, ni->ni_htctlchan, ni->ni_ht2ndchan);
db_printf("\thtopmode 0x%x htstbc 0x%x chw %u\n",
ni->ni_htopmode, ni->ni_htstbc, ni->ni_chw);
/* XXX ampdu state */
for (i = 0; i < WME_NUM_AC; i++)
if (ni->ni_tx_ampdu[i].txa_flags & IEEE80211_AGGR_SETUP)
_db_show_txampdu("\t", i, &ni->ni_tx_ampdu[i]);
for (i = 0; i < WME_NUM_TID; i++)
if (ni->ni_rx_ampdu[i].rxa_nframes)
_db_show_rxampdu("\t", i, &ni->ni_rx_ampdu[i]);
db_printf("\tinact %u inact_reload %u txrate %u\n",
ni->ni_inact, ni->ni_inact_reload, ni->ni_txrate);
/* XXX savedq */
/* XXX wdsq */
}
static void
_db_show_vap(const struct ieee80211vap *vap, int showprocs)
{
const struct ieee80211com *ic = vap->iv_ic;
int i;
db_printf("%p:", vap);
db_printf(" bss %p", vap->iv_bss);
db_printf(" myaddr %s", ether_sprintf(vap->iv_myaddr));
db_printf("\n");
db_printf("\topmode %s", ieee80211_opmode_name[vap->iv_opmode]);
db_printf(" state %s", ieee80211_state_name[vap->iv_state]);
db_printf(" ifp %p", vap->iv_ifp);
db_printf("\n");
db_printf("\tic %p", vap->iv_ic);
db_printf(" media %p", &vap->iv_media);
db_printf(" bpf_if %p", vap->iv_rawbpf);
db_printf(" mgtsend %p", &vap->iv_mgtsend);
#if 0
struct sysctllog *iv_sysctl; /* dynamic sysctl context */
#endif
db_printf("\n");
db_printf("\tdebug=%b\n", vap->iv_debug, IEEE80211_MSG_BITS);
db_printf("\tflags=%b\n", vap->iv_flags, IEEE80211_F_BITS);
db_printf("\tflags_ext=%b\n", vap->iv_flags_ext, IEEE80211_FEXT_BITS);
db_printf("\tflags_ven=%b\n", vap->iv_flags_ven, IEEE80211_FVEN_BITS);
db_printf("\tcaps=%b\n", vap->iv_caps, IEEE80211_C_BITS);
db_printf("\thtcaps=%b\n", vap->iv_htcaps, IEEE80211_C_HTCAP_BITS);
_db_show_stats(&vap->iv_stats);
db_printf("\tinact_init %d", vap->iv_inact_init);
db_printf(" inact_auth %d", vap->iv_inact_auth);
db_printf(" inact_run %d", vap->iv_inact_run);
db_printf(" inact_probe %d", vap->iv_inact_probe);
db_printf("\n");
db_printf("\tdes_nssid %d", vap->iv_des_nssid);
if (vap->iv_des_nssid)
_db_show_ssid(" des_ssid[%u] ", 0,
vap->iv_des_ssid[0].len, vap->iv_des_ssid[0].ssid);
db_printf(" des_bssid %s", ether_sprintf(vap->iv_des_bssid));
db_printf("\n");
db_printf("\tdes_mode %d", vap->iv_des_mode);
_db_show_channel(" des_chan", vap->iv_des_chan);
db_printf("\n");
#if 0
int iv_nicknamelen; /* XXX junk */
uint8_t iv_nickname[IEEE80211_NWID_LEN];
#endif
db_printf("\tbgscanidle %u", vap->iv_bgscanidle);
db_printf(" bgscanintvl %u", vap->iv_bgscanintvl);
db_printf(" scanvalid %u", vap->iv_scanvalid);
db_printf("\n");
db_printf("\tscanreq_duration %u", vap->iv_scanreq_duration);
db_printf(" scanreq_mindwell %u", vap->iv_scanreq_mindwell);
db_printf(" scanreq_maxdwell %u", vap->iv_scanreq_maxdwell);
db_printf("\n");
db_printf(" scanreq_flags 0x%x", vap->iv_scanreq_flags);
db_printf("\tscanreq_nssid %d", vap->iv_scanreq_nssid);
for (i = 0; i < vap->iv_scanreq_nssid; i++)
_db_show_ssid(" scanreq_ssid[%u]", i,
vap->iv_scanreq_ssid[i].len, vap->iv_scanreq_ssid[i].ssid);
db_printf(" roaming %d", vap->iv_roaming);
db_printf("\n");
for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++)
if (isset(ic->ic_modecaps, i)) {
_db_show_roamparams("\troamparms[%s]",
ieee80211_phymode_name[i], &vap->iv_roamparms[i]);
db_printf("\n");
}
db_printf("\tbmissthreshold %u", vap->iv_bmissthreshold);
db_printf(" bmiss_max %u", vap->iv_bmiss_count);
db_printf(" bmiss_max %d", vap->iv_bmiss_max);
db_printf("\n");
db_printf("\tswbmiss_count %u", vap->iv_swbmiss_count);
db_printf(" swbmiss_period %u", vap->iv_swbmiss_period);
db_printf(" swbmiss %p", &vap->iv_swbmiss);
db_printf("\n");
db_printf("\tampdu_rxmax %d", vap->iv_ampdu_rxmax);
db_printf(" ampdu_density %d", vap->iv_ampdu_density);
db_printf(" ampdu_limit %d", vap->iv_ampdu_limit);
db_printf(" amsdu_limit %d", vap->iv_amsdu_limit);
db_printf("\n");
db_printf("\tmax_aid %u", vap->iv_max_aid);
db_printf(" aid_bitmap %p", vap->iv_aid_bitmap);
db_printf("\n");
db_printf("\tsta_assoc %u", vap->iv_sta_assoc);
db_printf(" ps_sta %u", vap->iv_ps_sta);
db_printf(" ps_pending %u", vap->iv_ps_pending);
db_printf(" tim_len %u", vap->iv_tim_len);
db_printf(" tim_bitmap %p", vap->iv_tim_bitmap);
db_printf("\n");
db_printf("\tdtim_period %u", vap->iv_dtim_period);
db_printf(" dtim_count %u", vap->iv_dtim_count);
db_printf(" set_tim %p", vap->iv_set_tim);
db_printf(" csa_count %d", vap->iv_csa_count);
db_printf("\n");
db_printf("\trtsthreshold %u", vap->iv_rtsthreshold);
db_printf(" fragthreshold %u", vap->iv_fragthreshold);
db_printf(" inact_timer %d", vap->iv_inact_timer);
db_printf("\n");
for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++)
if (isset(ic->ic_modecaps, i)) {
_db_show_txparams("\ttxparms[%s]",
ieee80211_phymode_name[i], &vap->iv_txparms[i]);
db_printf("\n");
}
/* application-specified IE's to attach to mgt frames */
_db_show_appie("\tappie_beacon", vap->iv_appie_beacon);
_db_show_appie("\tappie_probereq", vap->iv_appie_probereq);
_db_show_appie("\tappie_proberesp", vap->iv_appie_proberesp);
_db_show_appie("\tappie_assocreq", vap->iv_appie_assocreq);
_db_show_appie("\tappie_asscoresp", vap->iv_appie_assocresp);
_db_show_appie("\tappie_wpa", vap->iv_appie_wpa);
if (vap->iv_wpa_ie != NULL || vap->iv_rsn_ie != NULL) {
if (vap->iv_wpa_ie != NULL)
db_printf("\twpa_ie %p", vap->iv_wpa_ie);
if (vap->iv_rsn_ie != NULL)
db_printf("\trsn_ie %p", vap->iv_rsn_ie);
db_printf("\n");
}
db_printf("\tmax_keyix %u", vap->iv_max_keyix);
db_printf(" def_txkey %d", vap->iv_def_txkey);
db_printf("\n");
for (i = 0; i < IEEE80211_WEP_NKID; i++)
_db_show_key("\tnw_keys[%u]", i, &vap->iv_nw_keys[i]);
db_printf("\tauth %p", vap->iv_auth);
db_printf(" ec %p", vap->iv_ec);
db_printf(" acl %p", vap->iv_acl);
db_printf(" as %p", vap->iv_as);
db_printf("\n");
if (showprocs) {
DB_PRINTSYM("\tiv_key_alloc", vap->iv_key_alloc);
DB_PRINTSYM("\tiv_key_delete", vap->iv_key_delete);
DB_PRINTSYM("\tiv_key_set", vap->iv_key_set);
DB_PRINTSYM("\tiv_key_update_begin", vap->iv_key_update_begin);
DB_PRINTSYM("\tiv_key_update_end", vap->iv_key_update_end);
DB_PRINTSYM("\tiv_opdetach", vap->iv_opdetach);
DB_PRINTSYM("\tiv_input", vap->iv_input);
DB_PRINTSYM("\tiv_recv_mgmt", vap->iv_recv_mgmt);
DB_PRINTSYM("\tiv_deliver_data", vap->iv_deliver_data);
DB_PRINTSYM("\tiv_bmiss", vap->iv_bmiss);
DB_PRINTSYM("\tiv_reset", vap->iv_reset);
DB_PRINTSYM("\tiv_update_beacon", vap->iv_update_beacon);
DB_PRINTSYM("\tiv_newstate", vap->iv_newstate);
DB_PRINTSYM("\tiv_output", vap->iv_output);
}
}
static void
_db_show_com(const struct ieee80211com *ic, int showvaps, int showsta, int showprocs)
{
struct ieee80211vap *vap;
db_printf("%p:", ic);
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
db_printf(" %s(%p)", vap->iv_ifp->if_xname, vap);
db_printf("\n");
db_printf("\tifp %p", ic->ic_ifp);
db_printf(" comlock %p", &ic->ic_comlock);
db_printf("\n");
_db_show_stats(&ic->ic_stats);
db_printf("\theadroom %d", ic->ic_headroom);
db_printf(" phytype %d", ic->ic_phytype);
db_printf(" opmode %s", ieee80211_opmode_name[ic->ic_opmode]);
db_printf("\n");
db_printf("\tmedia %p", &ic->ic_media);
db_printf(" myaddr %s", ether_sprintf(ic->ic_myaddr));
db_printf(" inact %p", &ic->ic_inact);
db_printf("\n");
db_printf("\tflags=%b\n", ic->ic_flags, IEEE80211_F_BITS);
db_printf("\tflags_ext=%b\n", ic->ic_flags_ext, IEEE80211_FEXT_BITS);
db_printf("\tflags_ven=%b\n", ic->ic_flags_ven, IEEE80211_FVEN_BITS);
db_printf("\tcaps=%b\n", ic->ic_caps, IEEE80211_C_BITS);
db_printf("\tcryptocaps=%b\n",
ic->ic_cryptocaps, IEEE80211_C_CRYPTO_BITS);
db_printf("\thtcaps=%b\n", ic->ic_htcaps, IEEE80211_HTCAP_BITS);
#if 0
uint8_t ic_modecaps[2]; /* set of mode capabilities */
#endif
db_printf("\tcurmode %u", ic->ic_curmode);
db_printf(" promisc %u", ic->ic_promisc);
db_printf(" allmulti %u", ic->ic_allmulti);
db_printf(" nrunning %u", ic->ic_nrunning);
db_printf("\n");
db_printf("\tbintval %u", ic->ic_bintval);
db_printf(" lintval %u", ic->ic_lintval);
db_printf(" holdover %u", ic->ic_holdover);
db_printf(" txpowlimit %u", ic->ic_txpowlimit);
db_printf("\n");
#if 0
struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
#endif
/*
* Channel state:
*
* ic_channels is the set of available channels for the device;
* it is setup by the driver
* ic_nchans is the number of valid entries in ic_channels
* ic_chan_avail is a bit vector of these channels used to check
* whether a channel is available w/o searching the channel table.
* ic_chan_active is a (potentially) constrained subset of
* ic_chan_avail that reflects any mode setting or user-specified
* limit on the set of channels to use/scan
* ic_curchan is the current channel the device is set to; it may
* be different from ic_bsschan when we are off-channel scanning
* or otherwise doing background work
* ic_bsschan is the channel selected for operation; it may
* be undefined (IEEE80211_CHAN_ANYC)
* ic_prevchan is a cached ``previous channel'' used to optimize
* lookups when switching back+forth between two channels
* (e.g. for dynamic turbo)
*/
db_printf("\tnchans %d", ic->ic_nchans);
#if 0
struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1];
uint8_t ic_chan_avail[IEEE80211_CHAN_BYTES];
uint8_t ic_chan_active[IEEE80211_CHAN_BYTES];
uint8_t ic_chan_scan[IEEE80211_CHAN_BYTES];
#endif
db_printf("\n");
_db_show_channel("\tcurchan", ic->ic_curchan);
db_printf("\n");
_db_show_channel("\tbsschan", ic->ic_bsschan);
db_printf("\n");
_db_show_channel("\tprevchan", ic->ic_prevchan);
db_printf("\n");
db_printf("\tregdomain %p", &ic->ic_regdomain);
db_printf("\n");
_db_show_channel("\tcsa_newchan", ic->ic_csa_newchan);
db_printf(" csa_count %d", ic->ic_csa_count);
db_printf( "dfs %p", &ic->ic_dfs);
db_printf("\n");
db_printf("\tscan %p", ic->ic_scan);
db_printf(" lastdata %d", ic->ic_lastdata);
db_printf(" lastscan %d", ic->ic_lastscan);
db_printf("\n");
db_printf("\tmax_keyix %d", ic->ic_max_keyix);
db_printf(" sta %p", &ic->ic_sta);
db_printf(" wme %p", &ic->ic_wme);
db_printf("\n");
db_printf("\tprotmode %d", ic->ic_protmode);
db_printf(" nonerpsta %u", ic->ic_nonerpsta);
db_printf(" longslotsta %u", ic->ic_longslotsta);
db_printf(" lastnonerp %d", ic->ic_lastnonerp);
db_printf("\n");
db_printf("\tsta_assoc %u", ic->ic_sta_assoc);
db_printf(" ht_sta_assoc %u", ic->ic_ht_sta_assoc);
db_printf(" ht40_sta_assoc %u", ic->ic_ht40_sta_assoc);
db_printf("\n");
db_printf("\tcurhtprotmode 0x%x", ic->ic_curhtprotmode);
db_printf(" htprotmode %d", ic->ic_htprotmode);
db_printf(" lastnonht %d", ic->ic_lastnonht);
db_printf("\n");
if (showprocs) {
DB_PRINTSYM("\tic_vap_create", ic->ic_vap_create);
DB_PRINTSYM("\tic_vap_delete", ic->ic_vap_delete);
#if 0
/* operating mode attachment */
ieee80211vap_attach ic_vattach[IEEE80211_OPMODE_MAX];
#endif
DB_PRINTSYM("\tic_newassoc", ic->ic_newassoc);
DB_PRINTSYM("\tic_getradiocaps", ic->ic_getradiocaps);
DB_PRINTSYM("\tic_setregdomain", ic->ic_setregdomain);
DB_PRINTSYM("\tic_send_mgmt", ic->ic_send_mgmt);
DB_PRINTSYM("\tic_raw_xmit", ic->ic_raw_xmit);
DB_PRINTSYM("\tic_updateslot", ic->ic_updateslot);
DB_PRINTSYM("\tic_update_mcast", ic->ic_update_mcast);
DB_PRINTSYM("\tic_update_promisc", ic->ic_update_promisc);
DB_PRINTSYM("\tic_node_alloc", ic->ic_node_alloc);
DB_PRINTSYM("\tic_node_free", ic->ic_node_free);
DB_PRINTSYM("\tic_node_cleanup", ic->ic_node_cleanup);
DB_PRINTSYM("\tic_node_getrssi", ic->ic_node_getrssi);
DB_PRINTSYM("\tic_node_getsignal", ic->ic_node_getsignal);
DB_PRINTSYM("\tic_node_getmimoinfo", ic->ic_node_getmimoinfo);
DB_PRINTSYM("\tic_scan_start", ic->ic_scan_start);
DB_PRINTSYM("\tic_scan_end", ic->ic_scan_end);
DB_PRINTSYM("\tic_set_channel", ic->ic_set_channel);
DB_PRINTSYM("\tic_scan_curchan", ic->ic_scan_curchan);
DB_PRINTSYM("\tic_scan_mindwell", ic->ic_scan_mindwell);
DB_PRINTSYM("\tic_recv_action", ic->ic_recv_action);
DB_PRINTSYM("\tic_send_action", ic->ic_send_action);
DB_PRINTSYM("\tic_addba_request", ic->ic_addba_request);
DB_PRINTSYM("\tic_addba_response", ic->ic_addba_response);
DB_PRINTSYM("\tic_addba_stop", ic->ic_addba_stop);
}
if (showvaps && !TAILQ_EMPTY(&ic->ic_vaps)) {
db_printf("\n");
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
_db_show_vap(vap, showprocs);
}
if (showsta && !TAILQ_EMPTY(&ic->ic_sta.nt_node)) {
const struct ieee80211_node_table *nt = &ic->ic_sta;
const struct ieee80211_node *ni;
TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
db_printf("\n");
_db_show_sta(ni);
}
}
}
static void
_db_show_channel(const char *tag, const struct ieee80211_channel *c)
{
db_printf("%s ", tag);
if (c == NULL)
db_printf("<NULL>");
else if (c == IEEE80211_CHAN_ANYC)
db_printf("<ANY>");
else
db_printf("[%u (%u) flags=%b maxreg %u maxpow %u minpow %u state 0x%x extieee %u]",
c->ic_freq, c->ic_ieee,
c->ic_flags, IEEE80211_CHAN_BITS,
c->ic_maxregpower, c->ic_maxpower, c->ic_minpower,
c->ic_state, c->ic_extieee);
}
static void
_db_show_ssid(const char *tag, int ix, int len, const uint8_t *ssid)
{
const uint8_t *p;
int i;
db_printf(tag, ix);
if (len > IEEE80211_NWID_LEN)
len = IEEE80211_NWID_LEN;
/* determine printable or not */
for (i = 0, p = ssid; i < len; i++, p++) {
if (*p < ' ' || *p > 0x7e)
break;
}
if (i == len) {
db_printf("\"");
for (i = 0, p = ssid; i < len; i++, p++)
db_printf("%c", *p);
db_printf("\"");
} else {
db_printf("0x");
for (i = 0, p = ssid; i < len; i++, p++)
db_printf("%02x", *p);
}
}
static void
_db_show_appie(const char *tag, const struct ieee80211_appie *ie)
{
const uint8_t *p;
int i;
if (ie == NULL)
return;
db_printf("%s [0x", tag);
for (i = 0, p = ie->ie_data; i < ie->ie_len; i++, p++)
db_printf("%02x", *p);
db_printf("]\n");
}
static void
_db_show_key(const char *tag, int ix, const struct ieee80211_key *wk)
{
static const uint8_t zerodata[IEEE80211_KEYBUF_SIZE];
const struct ieee80211_cipher *cip = wk->wk_cipher;
int keylen = wk->wk_keylen;
if ((wk->wk_flags & IEEE80211_KEY_DEVKEY) == 0)
return;
db_printf(tag, ix);
switch (cip->ic_cipher) {
case IEEE80211_CIPHER_WEP:
/* compatibility */
db_printf(" wepkey %u:%s", wk->wk_keyix,
keylen <= 5 ? "40-bit" :
keylen <= 13 ? "104-bit" : "128-bit");
break;
case IEEE80211_CIPHER_TKIP:
if (keylen > 128/8)
keylen -= 128/8; /* ignore MIC for now */
db_printf(" TKIP %u:%u-bit", wk->wk_keyix, 8*keylen);
break;
case IEEE80211_CIPHER_AES_OCB:
db_printf(" AES-OCB %u:%u-bit", wk->wk_keyix, 8*keylen);
break;
case IEEE80211_CIPHER_AES_CCM:
db_printf(" AES-CCM %u:%u-bit", wk->wk_keyix, 8*keylen);
break;
case IEEE80211_CIPHER_CKIP:
db_printf(" CKIP %u:%u-bit", wk->wk_keyix, 8*keylen);
break;
case IEEE80211_CIPHER_NONE:
db_printf(" NULL %u:%u-bit", wk->wk_keyix, 8*keylen);
break;
default:
db_printf(" UNKNOWN (0x%x) %u:%u-bit",
cip->ic_cipher, wk->wk_keyix, 8*keylen);
break;
}
if (memcmp(wk->wk_key, zerodata, keylen) != 0) {
int i;
db_printf(" <");
for (i = 0; i < keylen; i++)
db_printf("%02x", wk->wk_key[i]);
db_printf(">");
if (cip->ic_cipher != IEEE80211_CIPHER_WEP &&
wk->wk_keyrsc[IEEE80211_NONQOS_TID] != 0)
db_printf(" rsc %ju", (uintmax_t)wk->wk_keyrsc[IEEE80211_NONQOS_TID]);
if (cip->ic_cipher != IEEE80211_CIPHER_WEP &&
wk->wk_keytsc != 0)
db_printf(" tsc %ju", (uintmax_t)wk->wk_keytsc);
if (wk->wk_flags != 0) {
const char *sep = " ";
if (wk->wk_flags & IEEE80211_KEY_XMIT)
db_printf("%stx", sep), sep = "+";
if (wk->wk_flags & IEEE80211_KEY_RECV)
db_printf("%srx", sep), sep = "+";
if (wk->wk_flags & IEEE80211_KEY_DEFAULT)
db_printf("%sdef", sep), sep = "+";
if (wk->wk_flags & IEEE80211_KEY_SWCRYPT)
db_printf("%sswcrypt", sep), sep = "+";
if (wk->wk_flags & IEEE80211_KEY_SWMIC)
db_printf("%sswmic", sep), sep = "+";
}
db_printf("\n");
}
}
static void
printrate(const char *tag, int v)
{
if (v == IEEE80211_FIXED_RATE_NONE)
db_printf(" %s <none>", tag);
else if (v == 11)
db_printf(" %s 5.5", tag);
else if (v & IEEE80211_RATE_MCS)
db_printf(" %s MCS%d", tag, v &~ IEEE80211_RATE_MCS);
else
db_printf(" %s %d", tag, v/2);
}
static void
_db_show_roamparams(const char *tag, const void *arg,
const struct ieee80211_roamparam *rp)
{
db_printf(tag, arg);
if (rp->rssi & 1)
db_printf(" rssi %u.5", rp->rssi/2);
else
db_printf(" rssi %u", rp->rssi/2);
printrate("rate", rp->rate);
}
static void
_db_show_txparams(const char *tag, const void *arg,
const struct ieee80211_txparam *tp)
{
db_printf(tag, arg);
printrate("ucastrate", tp->ucastrate);
printrate("mcastrate", tp->mcastrate);
printrate("mgmtrate", tp->mgmtrate);
db_printf(" maxretry %d", tp->maxretry);
}
static void
_db_show_stats(const struct ieee80211_stats *is)
{
}
#endif /* DDB */