1 /*- 2 * Copyright (c) 2007-2009 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 * 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. 24 */ 25 26 #include <sys/cdefs.h> 27 __FBSDID("$FreeBSD$"); 28 29 #include "opt_ddb.h" 30 #include "opt_wlan.h" 31 32 #ifdef DDB 33 /* 34 * IEEE 802.11 DDB support 35 */ 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/kernel.h> 39 #include <sys/socket.h> 40 #include <sys/vimage.h> 41 42 #include <net/if.h> 43 #include <net/if_dl.h> 44 #include <net/if_media.h> 45 #include <net/if_types.h> 46 #include <net/ethernet.h> 47 #include <net/vnet.h> 48 49 #include <net80211/ieee80211_var.h> 50 51 #include <ddb/ddb.h> 52 #include <ddb/db_sym.h> 53 54 #define DB_PRINTSYM(prefix, addr) \ 55 db_printf(prefix " "); \ 56 db_printsym((db_addr_t) addr, DB_STGY_ANY); \ 57 db_printf("\n"); 58 59 static void _db_show_sta(const struct ieee80211_node *); 60 static void _db_show_vap(const struct ieee80211vap *, int); 61 static void _db_show_com(const struct ieee80211com *, 62 int showvaps, int showsta, int showprocs); 63 64 static void _db_show_node_table(const char *tag, 65 const struct ieee80211_node_table *); 66 static void _db_show_channel(const char *tag, const struct ieee80211_channel *); 67 static void _db_show_ssid(const char *tag, int ix, int len, const uint8_t *); 68 static void _db_show_appie(const char *tag, const struct ieee80211_appie *); 69 static void _db_show_key(const char *tag, int ix, const struct ieee80211_key *); 70 static void _db_show_roamparams(const char *tag, const void *arg, 71 const struct ieee80211_roamparam *rp); 72 static void _db_show_txparams(const char *tag, const void *arg, 73 const struct ieee80211_txparam *tp); 74 static void _db_show_stats(const struct ieee80211_stats *); 75 76 DB_SHOW_COMMAND(sta, db_show_sta) 77 { 78 if (!have_addr) { 79 db_printf("usage: show sta <addr>\n"); 80 return; 81 } 82 _db_show_sta((const struct ieee80211_node *) addr); 83 } 84 85 DB_SHOW_COMMAND(statab, db_show_statab) 86 { 87 if (!have_addr) { 88 db_printf("usage: show statab <addr>\n"); 89 return; 90 } 91 _db_show_node_table("", (const struct ieee80211_node_table *) addr); 92 } 93 94 DB_SHOW_COMMAND(vap, db_show_vap) 95 { 96 int i, showprocs = 0; 97 98 if (!have_addr) { 99 db_printf("usage: show vap <addr>\n"); 100 return; 101 } 102 for (i = 0; modif[i] != '\0'; i++) 103 switch (modif[i]) { 104 case 'a': 105 showprocs = 1; 106 break; 107 case 'p': 108 showprocs = 1; 109 break; 110 } 111 _db_show_vap((const struct ieee80211vap *) addr, showprocs); 112 } 113 114 DB_SHOW_COMMAND(com, db_show_com) 115 { 116 const struct ieee80211com *ic; 117 int i, showprocs = 0, showvaps = 0, showsta = 0; 118 119 if (!have_addr) { 120 db_printf("usage: show com <addr>\n"); 121 return; 122 } 123 for (i = 0; modif[i] != '\0'; i++) 124 switch (modif[i]) { 125 case 'a': 126 showsta = showvaps = showprocs = 1; 127 break; 128 case 's': 129 showsta = 1; 130 break; 131 case 'v': 132 showvaps = 1; 133 break; 134 case 'p': 135 showprocs = 1; 136 break; 137 } 138 139 ic = (const struct ieee80211com *) addr; 140 _db_show_com(ic, showvaps, showsta, showprocs); 141 } 142 143 DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps) 144 { 145 VNET_ITERATOR_DECL(vnet_iter); 146 const struct ifnet *ifp; 147 int i, showall = 0; 148 149 for (i = 0; modif[i] != '\0'; i++) 150 switch (modif[i]) { 151 case 'a': 152 showall = 1; 153 break; 154 } 155 156 VNET_FOREACH(vnet_iter) { 157 INIT_VNET_NET(vnet_iter); 158 TAILQ_FOREACH(ifp, &V_ifnet, if_list) 159 if (ifp->if_type == IFT_IEEE80211) { 160 const struct ieee80211com *ic = ifp->if_l2com; 161 162 if (!showall) { 163 const struct ieee80211vap *vap; 164 db_printf("%s: com %p vaps:", 165 ifp->if_xname, ic); 166 TAILQ_FOREACH(vap, &ic->ic_vaps, 167 iv_next) 168 db_printf(" %s(%p)", 169 vap->iv_ifp->if_xname, vap); 170 db_printf("\n"); 171 } else 172 _db_show_com(ic, 1, 1, 1); 173 } 174 } 175 } 176 177 static void 178 _db_show_txampdu(const char *sep, int ix, const struct ieee80211_tx_ampdu *tap) 179 { 180 db_printf("%stxampdu[%d]: %p flags %b ac %u\n", 181 sep, ix, tap, tap->txa_flags, IEEE80211_AGGR_BITS, tap->txa_ac); 182 db_printf("%s token %u qbytes %d qframes %d start %u wnd %u\n", 183 sep, tap->txa_token, tap->txa_qbytes, tap->txa_qframes, 184 tap->txa_start, tap->txa_wnd); 185 db_printf("%s attempts %d nextrequest %d\n", 186 sep, tap->txa_attempts, tap->txa_nextrequest); 187 /* XXX packet q + timer */ 188 } 189 190 static void 191 _db_show_rxampdu(const char *sep, int ix, const struct ieee80211_rx_ampdu *rap) 192 { 193 db_printf("%srxampdu[%d]: %p flags 0x%x tid %u\n", 194 sep, ix, rap, rap->rxa_flags, ix /*XXX */); 195 db_printf("%s qbytes %d qframes %d seqstart %u start %u wnd %u\n", 196 sep, rap->rxa_qbytes, rap->rxa_qframes, 197 rap->rxa_seqstart, rap->rxa_start, rap->rxa_wnd); 198 db_printf("%s age %d nframes %d\n", 199 sep, rap->rxa_age, rap->rxa_nframes); 200 } 201 202 static void 203 _db_show_sta(const struct ieee80211_node *ni) 204 { 205 int i; 206 207 db_printf("0x%p: mac %s refcnt %d\n", ni, 208 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni)); 209 db_printf("\tvap %p wdsvap %p ic %p table %p\n", 210 ni->ni_vap, ni->ni_wdsvap, ni->ni_ic, ni->ni_table); 211 db_printf("\tflags=%b\n", ni->ni_flags, IEEE80211_NODE_BITS); 212 db_printf("\tscangen %u authmode %u ath_flags 0x%x ath_defkeyix %u\n", 213 ni->ni_scangen, ni->ni_authmode, 214 ni->ni_ath_flags, ni->ni_ath_defkeyix); 215 db_printf("\tassocid 0x%x txpower %u vlan %u\n", 216 ni->ni_associd, ni->ni_txpower, ni->ni_vlan); 217 db_printf("\tjointime %d (%lu secs) challenge %p\n", 218 ni->ni_jointime, (unsigned long)(time_uptime - ni->ni_jointime), 219 ni->ni_challenge); 220 db_printf("\ties: data %p len %d\n", ni->ni_ies.data, ni->ni_ies.len); 221 db_printf("\t[wpa_ie %p rsn_ie %p wme_ie %p ath_ie %p\n", 222 ni->ni_ies.wpa_ie, ni->ni_ies.rsn_ie, ni->ni_ies.wme_ie, 223 ni->ni_ies.ath_ie); 224 db_printf("\t htcap_ie %p htinfo_ie %p]\n", 225 ni->ni_ies.htcap_ie, ni->ni_ies.htinfo_ie); 226 db_printf("\ttxseq %u rxseq %u fragno %u rxfragstamp %u\n", 227 ni->ni_txseqs[IEEE80211_NONQOS_TID], 228 ni->ni_rxseqs[IEEE80211_NONQOS_TID] >> IEEE80211_SEQ_SEQ_SHIFT, 229 ni->ni_rxseqs[IEEE80211_NONQOS_TID] & IEEE80211_SEQ_FRAG_MASK, 230 ni->ni_rxfragstamp); 231 db_printf("\trxfrag[0] %p rxfrag[1] %p rxfrag[2] %p\n", 232 ni->ni_rxfrag[0], ni->ni_rxfrag[1], ni->ni_rxfrag[2]); 233 _db_show_key("\tucastkey", 0, &ni->ni_ucastkey); 234 db_printf("\trstamp %u avgrssi 0x%x (rssi %d) noise %d\n", 235 ni->ni_rstamp, ni->ni_avgrssi, 236 IEEE80211_RSSI_GET(ni->ni_avgrssi), ni->ni_noise); 237 db_printf("\tintval %u capinfo %b\n", 238 ni->ni_intval, ni->ni_capinfo, IEEE80211_CAPINFO_BITS); 239 db_printf("\tbssid %s", ether_sprintf(ni->ni_bssid)); 240 _db_show_ssid(" essid ", 0, ni->ni_esslen, ni->ni_essid); 241 db_printf("\n"); 242 _db_show_channel("\tchannel", ni->ni_chan); 243 db_printf("\n"); 244 db_printf("\terp %b dtim_period %u dtim_count %u\n", 245 ni->ni_erp, IEEE80211_ERP_BITS, 246 ni->ni_dtim_period, ni->ni_dtim_count); 247 248 db_printf("\thtcap %b htparam 0x%x htctlchan %u ht2ndchan %u\n", 249 ni->ni_htcap, IEEE80211_HTCAP_BITS, 250 ni->ni_htparam, ni->ni_htctlchan, ni->ni_ht2ndchan); 251 db_printf("\thtopmode 0x%x htstbc 0x%x chw %u\n", 252 ni->ni_htopmode, ni->ni_htstbc, ni->ni_chw); 253 254 /* XXX ampdu state */ 255 for (i = 0; i < WME_NUM_AC; i++) 256 if (ni->ni_tx_ampdu[i].txa_flags & IEEE80211_AGGR_SETUP) 257 _db_show_txampdu("\t", i, &ni->ni_tx_ampdu[i]); 258 for (i = 0; i < WME_NUM_TID; i++) 259 if (ni->ni_rx_ampdu[i].rxa_nframes) 260 _db_show_rxampdu("\t", i, &ni->ni_rx_ampdu[i]); 261 262 db_printf("\tinact %u inact_reload %u txrate %u\n", 263 ni->ni_inact, ni->ni_inact_reload, ni->ni_txrate); 264 /* XXX savedq */ 265 /* XXX wdsq */ 266 } 267 268 static void 269 _db_show_vap(const struct ieee80211vap *vap, int showprocs) 270 { 271 const struct ieee80211com *ic = vap->iv_ic; 272 int i; 273 274 db_printf("%p:", vap); 275 db_printf(" bss %p", vap->iv_bss); 276 db_printf(" myaddr %s", ether_sprintf(vap->iv_myaddr)); 277 db_printf("\n"); 278 279 db_printf("\topmode %s", ieee80211_opmode_name[vap->iv_opmode]); 280 db_printf(" state %s", ieee80211_state_name[vap->iv_state]); 281 db_printf(" ifp %p", vap->iv_ifp); 282 db_printf("\n"); 283 284 db_printf("\tic %p", vap->iv_ic); 285 db_printf(" media %p", &vap->iv_media); 286 db_printf(" bpf_if %p", vap->iv_rawbpf); 287 db_printf(" mgtsend %p", &vap->iv_mgtsend); 288 #if 0 289 struct sysctllog *iv_sysctl; /* dynamic sysctl context */ 290 #endif 291 db_printf("\n"); 292 db_printf("\tdebug=%b\n", vap->iv_debug, IEEE80211_MSG_BITS); 293 294 db_printf("\tflags=%b\n", vap->iv_flags, IEEE80211_F_BITS); 295 db_printf("\tflags_ext=%b\n", vap->iv_flags_ext, IEEE80211_FEXT_BITS); 296 db_printf("\tflags_ven=%b\n", vap->iv_flags_ven, IEEE80211_FVEN_BITS); 297 db_printf("\tcaps=%b\n", vap->iv_caps, IEEE80211_C_BITS); 298 db_printf("\thtcaps=%b\n", vap->iv_htcaps, IEEE80211_C_HTCAP_BITS); 299 300 _db_show_stats(&vap->iv_stats); 301 302 db_printf("\tinact_init %d", vap->iv_inact_init); 303 db_printf(" inact_auth %d", vap->iv_inact_auth); 304 db_printf(" inact_run %d", vap->iv_inact_run); 305 db_printf(" inact_probe %d", vap->iv_inact_probe); 306 db_printf("\n"); 307 308 db_printf("\tdes_nssid %d", vap->iv_des_nssid); 309 if (vap->iv_des_nssid) 310 _db_show_ssid(" des_ssid[%u] ", 0, 311 vap->iv_des_ssid[0].len, vap->iv_des_ssid[0].ssid); 312 db_printf(" des_bssid %s", ether_sprintf(vap->iv_des_bssid)); 313 db_printf("\n"); 314 db_printf("\tdes_mode %d", vap->iv_des_mode); 315 _db_show_channel(" des_chan", vap->iv_des_chan); 316 db_printf("\n"); 317 #if 0 318 int iv_nicknamelen; /* XXX junk */ 319 uint8_t iv_nickname[IEEE80211_NWID_LEN]; 320 #endif 321 db_printf("\tbgscanidle %u", vap->iv_bgscanidle); 322 db_printf(" bgscanintvl %u", vap->iv_bgscanintvl); 323 db_printf(" scanvalid %u", vap->iv_scanvalid); 324 db_printf("\n"); 325 db_printf("\tscanreq_duration %u", vap->iv_scanreq_duration); 326 db_printf(" scanreq_mindwell %u", vap->iv_scanreq_mindwell); 327 db_printf(" scanreq_maxdwell %u", vap->iv_scanreq_maxdwell); 328 db_printf("\n"); 329 db_printf(" scanreq_flags 0x%x", vap->iv_scanreq_flags); 330 db_printf("\tscanreq_nssid %d", vap->iv_scanreq_nssid); 331 for (i = 0; i < vap->iv_scanreq_nssid; i++) 332 _db_show_ssid(" scanreq_ssid[%u]", i, 333 vap->iv_scanreq_ssid[i].len, vap->iv_scanreq_ssid[i].ssid); 334 db_printf(" roaming %d", vap->iv_roaming); 335 db_printf("\n"); 336 for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++) 337 if (isset(ic->ic_modecaps, i)) { 338 _db_show_roamparams("\troamparms[%s]", 339 ieee80211_phymode_name[i], &vap->iv_roamparms[i]); 340 db_printf("\n"); 341 } 342 343 db_printf("\tbmissthreshold %u", vap->iv_bmissthreshold); 344 db_printf(" bmiss_max %u", vap->iv_bmiss_count); 345 db_printf(" bmiss_max %d", vap->iv_bmiss_max); 346 db_printf("\n"); 347 db_printf("\tswbmiss_count %u", vap->iv_swbmiss_count); 348 db_printf(" swbmiss_period %u", vap->iv_swbmiss_period); 349 db_printf(" swbmiss %p", &vap->iv_swbmiss); 350 db_printf("\n"); 351 352 db_printf("\tampdu_rxmax %d", vap->iv_ampdu_rxmax); 353 db_printf(" ampdu_density %d", vap->iv_ampdu_density); 354 db_printf(" ampdu_limit %d", vap->iv_ampdu_limit); 355 db_printf(" amsdu_limit %d", vap->iv_amsdu_limit); 356 db_printf("\n"); 357 358 db_printf("\tmax_aid %u", vap->iv_max_aid); 359 db_printf(" aid_bitmap %p", vap->iv_aid_bitmap); 360 db_printf("\n"); 361 db_printf("\tsta_assoc %u", vap->iv_sta_assoc); 362 db_printf(" ps_sta %u", vap->iv_ps_sta); 363 db_printf(" ps_pending %u", vap->iv_ps_pending); 364 db_printf(" tim_len %u", vap->iv_tim_len); 365 db_printf(" tim_bitmap %p", vap->iv_tim_bitmap); 366 db_printf("\n"); 367 db_printf("\tdtim_period %u", vap->iv_dtim_period); 368 db_printf(" dtim_count %u", vap->iv_dtim_count); 369 db_printf(" set_tim %p", vap->iv_set_tim); 370 db_printf(" csa_count %d", vap->iv_csa_count); 371 db_printf("\n"); 372 373 db_printf("\trtsthreshold %u", vap->iv_rtsthreshold); 374 db_printf(" fragthreshold %u", vap->iv_fragthreshold); 375 db_printf(" inact_timer %d", vap->iv_inact_timer); 376 db_printf("\n"); 377 for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++) 378 if (isset(ic->ic_modecaps, i)) { 379 _db_show_txparams("\ttxparms[%s]", 380 ieee80211_phymode_name[i], &vap->iv_txparms[i]); 381 db_printf("\n"); 382 } 383 384 /* application-specified IE's to attach to mgt frames */ 385 _db_show_appie("\tappie_beacon", vap->iv_appie_beacon); 386 _db_show_appie("\tappie_probereq", vap->iv_appie_probereq); 387 _db_show_appie("\tappie_proberesp", vap->iv_appie_proberesp); 388 _db_show_appie("\tappie_assocreq", vap->iv_appie_assocreq); 389 _db_show_appie("\tappie_asscoresp", vap->iv_appie_assocresp); 390 _db_show_appie("\tappie_wpa", vap->iv_appie_wpa); 391 if (vap->iv_wpa_ie != NULL || vap->iv_rsn_ie != NULL) { 392 if (vap->iv_wpa_ie != NULL) 393 db_printf("\twpa_ie %p", vap->iv_wpa_ie); 394 if (vap->iv_rsn_ie != NULL) 395 db_printf("\trsn_ie %p", vap->iv_rsn_ie); 396 db_printf("\n"); 397 } 398 db_printf("\tmax_keyix %u", vap->iv_max_keyix); 399 db_printf(" def_txkey %d", vap->iv_def_txkey); 400 db_printf("\n"); 401 for (i = 0; i < IEEE80211_WEP_NKID; i++) 402 _db_show_key("\tnw_keys[%u]", i, &vap->iv_nw_keys[i]); 403 404 db_printf("\tauth %p", vap->iv_auth); 405 db_printf(" ec %p", vap->iv_ec); 406 407 db_printf(" acl %p", vap->iv_acl); 408 db_printf(" as %p", vap->iv_as); 409 db_printf("\n"); 410 411 if (showprocs) { 412 DB_PRINTSYM("\tiv_key_alloc", vap->iv_key_alloc); 413 DB_PRINTSYM("\tiv_key_delete", vap->iv_key_delete); 414 DB_PRINTSYM("\tiv_key_set", vap->iv_key_set); 415 DB_PRINTSYM("\tiv_key_update_begin", vap->iv_key_update_begin); 416 DB_PRINTSYM("\tiv_key_update_end", vap->iv_key_update_end); 417 DB_PRINTSYM("\tiv_opdetach", vap->iv_opdetach); 418 DB_PRINTSYM("\tiv_input", vap->iv_input); 419 DB_PRINTSYM("\tiv_recv_mgmt", vap->iv_recv_mgmt); 420 DB_PRINTSYM("\tiv_deliver_data", vap->iv_deliver_data); 421 DB_PRINTSYM("\tiv_bmiss", vap->iv_bmiss); 422 DB_PRINTSYM("\tiv_reset", vap->iv_reset); 423 DB_PRINTSYM("\tiv_update_beacon", vap->iv_update_beacon); 424 DB_PRINTSYM("\tiv_newstate", vap->iv_newstate); 425 DB_PRINTSYM("\tiv_output", vap->iv_output); 426 } 427 } 428 429 static void 430 _db_show_com(const struct ieee80211com *ic, int showvaps, int showsta, int showprocs) 431 { 432 struct ieee80211vap *vap; 433 434 db_printf("%p:", ic); 435 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) 436 db_printf(" %s(%p)", vap->iv_ifp->if_xname, vap); 437 db_printf("\n"); 438 db_printf("\tifp %p", ic->ic_ifp); 439 db_printf(" comlock %p", &ic->ic_comlock); 440 db_printf("\n"); 441 db_printf("\theadroom %d", ic->ic_headroom); 442 db_printf(" phytype %d", ic->ic_phytype); 443 db_printf(" opmode %s", ieee80211_opmode_name[ic->ic_opmode]); 444 db_printf("\n"); 445 db_printf("\tmedia %p", &ic->ic_media); 446 db_printf(" myaddr %s", ether_sprintf(ic->ic_myaddr)); 447 db_printf(" inact %p", &ic->ic_inact); 448 db_printf("\n"); 449 450 db_printf("\tflags=%b\n", ic->ic_flags, IEEE80211_F_BITS); 451 db_printf("\tflags_ext=%b\n", ic->ic_flags_ext, IEEE80211_FEXT_BITS); 452 db_printf("\tflags_ven=%b\n", ic->ic_flags_ven, IEEE80211_FVEN_BITS); 453 db_printf("\tcaps=%b\n", ic->ic_caps, IEEE80211_C_BITS); 454 db_printf("\tcryptocaps=%b\n", 455 ic->ic_cryptocaps, IEEE80211_CRYPTO_BITS); 456 db_printf("\thtcaps=%b\n", ic->ic_htcaps, IEEE80211_HTCAP_BITS); 457 458 #if 0 459 uint8_t ic_modecaps[2]; /* set of mode capabilities */ 460 #endif 461 db_printf("\tcurmode %u", ic->ic_curmode); 462 db_printf(" promisc %u", ic->ic_promisc); 463 db_printf(" allmulti %u", ic->ic_allmulti); 464 db_printf(" nrunning %u", ic->ic_nrunning); 465 db_printf("\n"); 466 db_printf("\tbintval %u", ic->ic_bintval); 467 db_printf(" lintval %u", ic->ic_lintval); 468 db_printf(" holdover %u", ic->ic_holdover); 469 db_printf(" txpowlimit %u", ic->ic_txpowlimit); 470 db_printf("\n"); 471 #if 0 472 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; 473 #endif 474 /* 475 * Channel state: 476 * 477 * ic_channels is the set of available channels for the device; 478 * it is setup by the driver 479 * ic_nchans is the number of valid entries in ic_channels 480 * ic_chan_avail is a bit vector of these channels used to check 481 * whether a channel is available w/o searching the channel table. 482 * ic_chan_active is a (potentially) constrained subset of 483 * ic_chan_avail that reflects any mode setting or user-specified 484 * limit on the set of channels to use/scan 485 * ic_curchan is the current channel the device is set to; it may 486 * be different from ic_bsschan when we are off-channel scanning 487 * or otherwise doing background work 488 * ic_bsschan is the channel selected for operation; it may 489 * be undefined (IEEE80211_CHAN_ANYC) 490 * ic_prevchan is a cached ``previous channel'' used to optimize 491 * lookups when switching back+forth between two channels 492 * (e.g. for dynamic turbo) 493 */ 494 db_printf("\tnchans %d", ic->ic_nchans); 495 #if 0 496 struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX]; 497 uint8_t ic_chan_avail[IEEE80211_CHAN_BYTES]; 498 uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; 499 uint8_t ic_chan_scan[IEEE80211_CHAN_BYTES]; 500 #endif 501 db_printf("\n"); 502 _db_show_channel("\tcurchan", ic->ic_curchan); 503 db_printf("\n"); 504 _db_show_channel("\tbsschan", ic->ic_bsschan); 505 db_printf("\n"); 506 _db_show_channel("\tprevchan", ic->ic_prevchan); 507 db_printf("\n"); 508 db_printf("\tregdomain %p", &ic->ic_regdomain); 509 db_printf("\n"); 510 511 _db_show_channel("\tcsa_newchan", ic->ic_csa_newchan); 512 db_printf(" csa_count %d", ic->ic_csa_count); 513 db_printf( "dfs %p", &ic->ic_dfs); 514 db_printf("\n"); 515 516 db_printf("\tscan %p", ic->ic_scan); 517 db_printf(" lastdata %d", ic->ic_lastdata); 518 db_printf(" lastscan %d", ic->ic_lastscan); 519 db_printf("\n"); 520 521 db_printf("\tmax_keyix %d", ic->ic_max_keyix); 522 db_printf(" wme %p", &ic->ic_wme); 523 if (!showsta) 524 db_printf(" sta %p", &ic->ic_sta); 525 db_printf("\n"); 526 if (showsta) 527 _db_show_node_table("\t", &ic->ic_sta); 528 529 db_printf("\tprotmode %d", ic->ic_protmode); 530 db_printf(" nonerpsta %u", ic->ic_nonerpsta); 531 db_printf(" longslotsta %u", ic->ic_longslotsta); 532 db_printf(" lastnonerp %d", ic->ic_lastnonerp); 533 db_printf("\n"); 534 db_printf("\tsta_assoc %u", ic->ic_sta_assoc); 535 db_printf(" ht_sta_assoc %u", ic->ic_ht_sta_assoc); 536 db_printf(" ht40_sta_assoc %u", ic->ic_ht40_sta_assoc); 537 db_printf("\n"); 538 db_printf("\tcurhtprotmode 0x%x", ic->ic_curhtprotmode); 539 db_printf(" htprotmode %d", ic->ic_htprotmode); 540 db_printf(" lastnonht %d", ic->ic_lastnonht); 541 db_printf("\n"); 542 543 if (showprocs) { 544 DB_PRINTSYM("\tic_vap_create", ic->ic_vap_create); 545 DB_PRINTSYM("\tic_vap_delete", ic->ic_vap_delete); 546 #if 0 547 /* operating mode attachment */ 548 ieee80211vap_attach ic_vattach[IEEE80211_OPMODE_MAX]; 549 #endif 550 DB_PRINTSYM("\tic_newassoc", ic->ic_newassoc); 551 DB_PRINTSYM("\tic_getradiocaps", ic->ic_getradiocaps); 552 DB_PRINTSYM("\tic_setregdomain", ic->ic_setregdomain); 553 DB_PRINTSYM("\tic_send_mgmt", ic->ic_send_mgmt); 554 DB_PRINTSYM("\tic_raw_xmit", ic->ic_raw_xmit); 555 DB_PRINTSYM("\tic_updateslot", ic->ic_updateslot); 556 DB_PRINTSYM("\tic_update_mcast", ic->ic_update_mcast); 557 DB_PRINTSYM("\tic_update_promisc", ic->ic_update_promisc); 558 DB_PRINTSYM("\tic_node_alloc", ic->ic_node_alloc); 559 DB_PRINTSYM("\tic_node_free", ic->ic_node_free); 560 DB_PRINTSYM("\tic_node_cleanup", ic->ic_node_cleanup); 561 DB_PRINTSYM("\tic_node_getrssi", ic->ic_node_getrssi); 562 DB_PRINTSYM("\tic_node_getsignal", ic->ic_node_getsignal); 563 DB_PRINTSYM("\tic_node_getmimoinfo", ic->ic_node_getmimoinfo); 564 DB_PRINTSYM("\tic_scan_start", ic->ic_scan_start); 565 DB_PRINTSYM("\tic_scan_end", ic->ic_scan_end); 566 DB_PRINTSYM("\tic_set_channel", ic->ic_set_channel); 567 DB_PRINTSYM("\tic_scan_curchan", ic->ic_scan_curchan); 568 DB_PRINTSYM("\tic_scan_mindwell", ic->ic_scan_mindwell); 569 DB_PRINTSYM("\tic_recv_action", ic->ic_recv_action); 570 DB_PRINTSYM("\tic_send_action", ic->ic_send_action); 571 DB_PRINTSYM("\tic_addba_request", ic->ic_addba_request); 572 DB_PRINTSYM("\tic_addba_response", ic->ic_addba_response); 573 DB_PRINTSYM("\tic_addba_stop", ic->ic_addba_stop); 574 } 575 if (showvaps && !TAILQ_EMPTY(&ic->ic_vaps)) { 576 db_printf("\n"); 577 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) 578 _db_show_vap(vap, showprocs); 579 } 580 if (showsta && !TAILQ_EMPTY(&ic->ic_sta.nt_node)) { 581 const struct ieee80211_node_table *nt = &ic->ic_sta; 582 const struct ieee80211_node *ni; 583 584 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 585 db_printf("\n"); 586 _db_show_sta(ni); 587 } 588 } 589 } 590 591 static void 592 _db_show_node_table(const char *tag, const struct ieee80211_node_table *nt) 593 { 594 int i; 595 596 db_printf("%s%s@%p:\n", tag, nt->nt_name, nt); 597 db_printf("%s nodelock %p", tag, &nt->nt_nodelock); 598 db_printf(" inact_init %d", nt->nt_inact_init); 599 db_printf(" scanlock %p", &nt->nt_scanlock); 600 db_printf(" scangen %u\n", nt->nt_scangen); 601 db_printf("%s keyixmax %d keyixmap %p\n", 602 tag, nt->nt_keyixmax, nt->nt_keyixmap); 603 for (i = 0; i < nt->nt_keyixmax; i++) { 604 const struct ieee80211_node *ni = nt->nt_keyixmap[i]; 605 if (ni != NULL) 606 db_printf("%s [%3u] %p %s\n", tag, i, ni, 607 ether_sprintf(ni->ni_macaddr)); 608 } 609 } 610 611 static void 612 _db_show_channel(const char *tag, const struct ieee80211_channel *c) 613 { 614 db_printf("%s ", tag); 615 if (c == NULL) 616 db_printf("<NULL>"); 617 else if (c == IEEE80211_CHAN_ANYC) 618 db_printf("<ANY>"); 619 else 620 db_printf("[%u (%u) flags=%b maxreg %d maxpow %d minpow %d state 0x%x extieee %u]", 621 c->ic_freq, c->ic_ieee, 622 c->ic_flags, IEEE80211_CHAN_BITS, 623 c->ic_maxregpower, c->ic_maxpower, c->ic_minpower, 624 c->ic_state, c->ic_extieee); 625 } 626 627 static void 628 _db_show_ssid(const char *tag, int ix, int len, const uint8_t *ssid) 629 { 630 const uint8_t *p; 631 int i; 632 633 db_printf(tag, ix); 634 635 if (len > IEEE80211_NWID_LEN) 636 len = IEEE80211_NWID_LEN; 637 /* determine printable or not */ 638 for (i = 0, p = ssid; i < len; i++, p++) { 639 if (*p < ' ' || *p > 0x7e) 640 break; 641 } 642 if (i == len) { 643 db_printf("\""); 644 for (i = 0, p = ssid; i < len; i++, p++) 645 db_printf("%c", *p); 646 db_printf("\""); 647 } else { 648 db_printf("0x"); 649 for (i = 0, p = ssid; i < len; i++, p++) 650 db_printf("%02x", *p); 651 } 652 } 653 654 static void 655 _db_show_appie(const char *tag, const struct ieee80211_appie *ie) 656 { 657 const uint8_t *p; 658 int i; 659 660 if (ie == NULL) 661 return; 662 db_printf("%s [0x", tag); 663 for (i = 0, p = ie->ie_data; i < ie->ie_len; i++, p++) 664 db_printf("%02x", *p); 665 db_printf("]\n"); 666 } 667 668 static void 669 _db_show_key(const char *tag, int ix, const struct ieee80211_key *wk) 670 { 671 static const uint8_t zerodata[IEEE80211_KEYBUF_SIZE]; 672 const struct ieee80211_cipher *cip = wk->wk_cipher; 673 int keylen = wk->wk_keylen; 674 675 db_printf(tag, ix); 676 switch (cip->ic_cipher) { 677 case IEEE80211_CIPHER_WEP: 678 /* compatibility */ 679 db_printf(" wepkey %u:%s", wk->wk_keyix, 680 keylen <= 5 ? "40-bit" : 681 keylen <= 13 ? "104-bit" : "128-bit"); 682 break; 683 case IEEE80211_CIPHER_TKIP: 684 if (keylen > 128/8) 685 keylen -= 128/8; /* ignore MIC for now */ 686 db_printf(" TKIP %u:%u-bit", wk->wk_keyix, 8*keylen); 687 break; 688 case IEEE80211_CIPHER_AES_OCB: 689 db_printf(" AES-OCB %u:%u-bit", wk->wk_keyix, 8*keylen); 690 break; 691 case IEEE80211_CIPHER_AES_CCM: 692 db_printf(" AES-CCM %u:%u-bit", wk->wk_keyix, 8*keylen); 693 break; 694 case IEEE80211_CIPHER_CKIP: 695 db_printf(" CKIP %u:%u-bit", wk->wk_keyix, 8*keylen); 696 break; 697 case IEEE80211_CIPHER_NONE: 698 db_printf(" NULL %u:%u-bit", wk->wk_keyix, 8*keylen); 699 break; 700 default: 701 db_printf(" UNKNOWN (0x%x) %u:%u-bit", 702 cip->ic_cipher, wk->wk_keyix, 8*keylen); 703 break; 704 } 705 if (wk->wk_rxkeyix != wk->wk_keyix) 706 db_printf(" rxkeyix %u", wk->wk_rxkeyix); 707 if (memcmp(wk->wk_key, zerodata, keylen) != 0) { 708 int i; 709 710 db_printf(" <"); 711 for (i = 0; i < keylen; i++) 712 db_printf("%02x", wk->wk_key[i]); 713 db_printf(">"); 714 if (cip->ic_cipher != IEEE80211_CIPHER_WEP && 715 wk->wk_keyrsc[IEEE80211_NONQOS_TID] != 0) 716 db_printf(" rsc %ju", (uintmax_t)wk->wk_keyrsc[IEEE80211_NONQOS_TID]); 717 if (cip->ic_cipher != IEEE80211_CIPHER_WEP && 718 wk->wk_keytsc != 0) 719 db_printf(" tsc %ju", (uintmax_t)wk->wk_keytsc); 720 db_printf(" flags=%b", wk->wk_flags, IEEE80211_KEY_BITS); 721 } 722 db_printf("\n"); 723 } 724 725 static void 726 printrate(const char *tag, int v) 727 { 728 if (v == IEEE80211_FIXED_RATE_NONE) 729 db_printf(" %s <none>", tag); 730 else if (v == 11) 731 db_printf(" %s 5.5", tag); 732 else if (v & IEEE80211_RATE_MCS) 733 db_printf(" %s MCS%d", tag, v &~ IEEE80211_RATE_MCS); 734 else 735 db_printf(" %s %d", tag, v/2); 736 } 737 738 static void 739 _db_show_roamparams(const char *tag, const void *arg, 740 const struct ieee80211_roamparam *rp) 741 { 742 743 db_printf(tag, arg); 744 if (rp->rssi & 1) 745 db_printf(" rssi %u.5", rp->rssi/2); 746 else 747 db_printf(" rssi %u", rp->rssi/2); 748 printrate("rate", rp->rate); 749 } 750 751 static void 752 _db_show_txparams(const char *tag, const void *arg, 753 const struct ieee80211_txparam *tp) 754 { 755 756 db_printf(tag, arg); 757 printrate("ucastrate", tp->ucastrate); 758 printrate("mcastrate", tp->mcastrate); 759 printrate("mgmtrate", tp->mgmtrate); 760 db_printf(" maxretry %d", tp->maxretry); 761 } 762 763 static void 764 _db_show_stats(const struct ieee80211_stats *is) 765 { 766 } 767 #endif /* DDB */ 768