1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include <sys/cdefs.h> 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/malloc.h> 40 #include <sys/socket.h> 41 42 #include <net/if.h> 43 #include <net/if_var.h> 44 #include <net/if_dl.h> 45 #include <net/if_media.h> 46 #include <net/if_types.h> 47 #include <net/ethernet.h> 48 #include <net/vnet.h> 49 50 #include <net80211/ieee80211_var.h> 51 #ifdef IEEE80211_SUPPORT_TDMA 52 #include <net80211/ieee80211_tdma.h> 53 #endif 54 #ifdef IEEE80211_SUPPORT_MESH 55 #include <net80211/ieee80211_mesh.h> 56 #endif 57 58 #include <ddb/ddb.h> 59 #include <ddb/db_sym.h> 60 61 #define DB_PRINTSYM(prefix, name, addr) do { \ 62 db_printf("%s%-25s : ", prefix, name); \ 63 db_printsym((db_addr_t) addr, DB_STGY_ANY); \ 64 db_printf("\n"); \ 65 } while (0) 66 67 static void _db_show_sta(const struct ieee80211_node *); 68 static void _db_show_vap(const struct ieee80211vap *, int, int); 69 static void _db_show_com(const struct ieee80211com *, 70 int showvaps, int showsta, int showmesh, int showprocs); 71 72 static void _db_show_all_vaps(void *, struct ieee80211com *); 73 74 static void _db_show_node_table(const char *tag, 75 const struct ieee80211_node_table *); 76 static void _db_show_channel(const char *tag, const struct ieee80211_channel *); 77 static void _db_show_ssid(const char *tag, int ix, int len, const uint8_t *); 78 static void _db_show_appie(const char *tag, const struct ieee80211_appie *); 79 static void _db_show_key(const char *tag, int ix, const struct ieee80211_key *); 80 static void _db_show_roamparams(const char *tag, const void *arg, 81 const struct ieee80211_roamparam *rp); 82 static void _db_show_txparams(const char *tag, const void *arg, 83 const struct ieee80211_txparam *tp); 84 static void _db_show_ageq(const char *tag, const struct ieee80211_ageq *q); 85 static void _db_show_stats(const struct ieee80211_stats *); 86 #ifdef IEEE80211_SUPPORT_MESH 87 static void _db_show_mesh(const struct ieee80211_mesh_state *); 88 #endif 89 90 DB_SHOW_COMMAND(sta, db_show_sta) 91 { 92 if (!have_addr) { 93 db_printf("usage: show sta <addr>\n"); 94 return; 95 } 96 _db_show_sta((const struct ieee80211_node *) addr); 97 } 98 99 DB_SHOW_COMMAND(statab, db_show_statab) 100 { 101 if (!have_addr) { 102 db_printf("usage: show statab <addr>\n"); 103 return; 104 } 105 _db_show_node_table("", (const struct ieee80211_node_table *) addr); 106 } 107 108 DB_SHOW_COMMAND(vap, db_show_vap) 109 { 110 int i, showmesh = 0, showprocs = 0; 111 112 if (!have_addr) { 113 db_printf("usage: show vap <addr>\n"); 114 return; 115 } 116 for (i = 0; modif[i] != '\0'; i++) 117 switch (modif[i]) { 118 case 'a': 119 showprocs = 1; 120 showmesh = 1; 121 break; 122 case 'm': 123 showmesh = 1; 124 break; 125 case 'p': 126 showprocs = 1; 127 break; 128 } 129 _db_show_vap((const struct ieee80211vap *) addr, showmesh, showprocs); 130 } 131 132 DB_SHOW_COMMAND(com, db_show_com) 133 { 134 const struct ieee80211com *ic; 135 int i, showprocs = 0, showvaps = 0, showsta = 0, showmesh = 0; 136 137 if (!have_addr) { 138 db_printf("usage: show com <addr>\n"); 139 return; 140 } 141 for (i = 0; modif[i] != '\0'; i++) 142 switch (modif[i]) { 143 case 'a': 144 showsta = showmesh = showvaps = showprocs = 1; 145 break; 146 case 's': 147 showsta = 1; 148 break; 149 case 'm': 150 showmesh = 1; 151 break; 152 case 'v': 153 showvaps = 1; 154 break; 155 case 'p': 156 showprocs = 1; 157 break; 158 } 159 160 ic = (const struct ieee80211com *) addr; 161 _db_show_com(ic, showvaps, showsta, showmesh, showprocs); 162 } 163 164 DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps) 165 { 166 int i, showall = 0; 167 168 for (i = 0; modif[i] != '\0'; i++) 169 switch (modif[i]) { 170 case 'a': 171 showall = 1; 172 break; 173 } 174 175 ieee80211_iterate_coms(_db_show_all_vaps, &showall); 176 } 177 178 #ifdef IEEE80211_SUPPORT_MESH 179 DB_SHOW_ALL_COMMAND(mesh, db_show_mesh) 180 { 181 const struct ieee80211_mesh_state *ms; 182 183 if (!have_addr) { 184 db_printf("usage: show mesh <addr>\n"); 185 return; 186 } 187 ms = (const struct ieee80211_mesh_state *) addr; 188 _db_show_mesh(ms); 189 } 190 #endif /* IEEE80211_SUPPORT_MESH */ 191 192 static void 193 _db_show_txampdu(const char *sep, int ix, const struct ieee80211_tx_ampdu *tap) 194 { 195 db_printf("%stxampdu[%d]: %p flags %b %s\n", 196 sep, ix, tap, tap->txa_flags, IEEE80211_AGGR_BITS, 197 ieee80211_wme_acnames[TID_TO_WME_AC(tap->txa_tid)]); 198 db_printf("%s token %u lastsample %d pkts %d avgpps %d qbytes %d qframes %d\n", 199 sep, tap->txa_token, tap->txa_lastsample, tap->txa_pkts, 200 tap->txa_avgpps, tap->txa_qbytes, tap->txa_qframes); 201 db_printf("%s start %u seqpending %u wnd %u attempts %d nextrequest %d\n", 202 sep, tap->txa_start, tap->txa_seqpending, tap->txa_wnd, 203 tap->txa_attempts, tap->txa_nextrequest); 204 /* XXX timer */ 205 } 206 207 static void 208 _db_show_rxampdu(const char *sep, int ix, const struct ieee80211_rx_ampdu *rap) 209 { 210 struct mbuf *m; 211 int i; 212 213 db_printf("%srxampdu[%d]: %p flags 0x%x tid %u\n", 214 sep, ix, rap, rap->rxa_flags, ix /*XXX */); 215 db_printf("%s qbytes %d qframes %d seqstart %u start %u wnd %u\n", 216 sep, rap->rxa_qbytes, rap->rxa_qframes, 217 rap->rxa_seqstart, rap->rxa_start, rap->rxa_wnd); 218 db_printf("%s age %d nframes %d\n", sep, 219 rap->rxa_age, rap->rxa_nframes); 220 for (i = 0; i < IEEE80211_AGGR_BAWMAX; i++) 221 if (mbufq_len(&rap->rxa_mq[i]) > 0) { 222 db_printf("%s m[%2u:%4u] ", sep, i, 223 IEEE80211_SEQ_ADD(rap->rxa_start, i)); 224 STAILQ_FOREACH(m, &rap->rxa_mq[i].mq_head, 225 m_stailqpkt) { 226 db_printf(" %p", m); 227 } 228 db_printf("\n"); 229 } 230 } 231 232 static void 233 _db_show_sta(const struct ieee80211_node *ni) 234 { 235 int i; 236 237 db_printf("STA: %p: mac %s refcnt %d\n", ni, 238 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni)); 239 db_printf("\tvap %p wdsvap %p ic %p table %p\n", 240 ni->ni_vap, ni->ni_wdsvap, ni->ni_ic, ni->ni_table); 241 db_printf("\tflags=%b\n", ni->ni_flags, IEEE80211_NODE_BITS); 242 db_printf("\tauthmode %u ath_flags 0x%x ath_defkeyix %u\n", 243 ni->ni_authmode, ni->ni_ath_flags, ni->ni_ath_defkeyix); 244 db_printf("\tassocid 0x%x txpower %u vlan %u\n", 245 ni->ni_associd, ni->ni_txpower, ni->ni_vlan); 246 db_printf("\tjointime %d (%lu secs) challenge %p\n", 247 ni->ni_jointime, (unsigned long)(time_uptime - ni->ni_jointime), 248 ni->ni_challenge); 249 db_printf("\ties: data %p len %d\n", ni->ni_ies.data, ni->ni_ies.len); 250 db_printf("\t[wpa_ie %p rsn_ie %p wme_ie %p ath_ie %p\n", 251 ni->ni_ies.wpa_ie, ni->ni_ies.rsn_ie, ni->ni_ies.wme_ie, 252 ni->ni_ies.ath_ie); 253 db_printf("\t htcap_ie %p htinfo_ie %p]\n", 254 ni->ni_ies.htcap_ie, ni->ni_ies.htinfo_ie); 255 db_printf("\t vhtcap_ie %p vhtopmode_ie %p vhtpwrenv_ie %p]\n", 256 ni->ni_ies.vhtcap_ie, ni->ni_ies.vhtopmode_ie, 257 ni->ni_ies.vhtpwrenv_ie); 258 if (ni->ni_flags & IEEE80211_NODE_QOS) { 259 for (i = 0; i < WME_NUM_TID; i++) { 260 if (ni->ni_txseqs[i] || ni->ni_rxseqs[i]) 261 db_printf("\t[%u] txseq %u rxseq %u fragno %u\n", 262 i, ni->ni_txseqs[i], 263 ni->ni_rxseqs[i] >> IEEE80211_SEQ_SEQ_SHIFT, 264 ni->ni_rxseqs[i] & IEEE80211_SEQ_FRAG_MASK); 265 } 266 } 267 268 db_printf("\ttxseq %u rxseq %u fragno %u rxfragstamp %u\n", 269 ni->ni_txseqs[IEEE80211_NONQOS_TID], 270 ni->ni_rxseqs[IEEE80211_NONQOS_TID] >> IEEE80211_SEQ_SEQ_SHIFT, 271 ni->ni_rxseqs[IEEE80211_NONQOS_TID] & IEEE80211_SEQ_FRAG_MASK, 272 ni->ni_rxfragstamp); 273 db_printf("\trxfrag[0] %p rxfrag[1] %p rxfrag[2] %p\n", 274 ni->ni_rxfrag[0], ni->ni_rxfrag[1], ni->ni_rxfrag[2]); 275 _db_show_key("\tucastkey", 0, &ni->ni_ucastkey); 276 db_printf("\tavgrssi 0x%x (rssi %d) noise %d\n", 277 ni->ni_avgrssi, IEEE80211_RSSI_GET(ni->ni_avgrssi), 278 ni->ni_noise); 279 db_printf("\tintval %u capinfo %b\n", 280 ni->ni_intval, ni->ni_capinfo, IEEE80211_CAPINFO_BITS); 281 db_printf("\tbssid %s", ether_sprintf(ni->ni_bssid)); 282 _db_show_ssid(" essid ", 0, ni->ni_esslen, ni->ni_essid); 283 db_printf("\n"); 284 _db_show_channel("\tchannel", ni->ni_chan); 285 db_printf("\n"); 286 db_printf("\terp %b dtim_period %u dtim_count %u\n", 287 ni->ni_erp, IEEE80211_ERP_BITS, 288 ni->ni_dtim_period, ni->ni_dtim_count); 289 290 db_printf("\thtcap %b htparam 0x%x htctlchan %u ht2ndchan %u\n", 291 ni->ni_htcap, IEEE80211_HTCAP_BITS, 292 ni->ni_htparam, ni->ni_htctlchan, ni->ni_ht2ndchan); 293 db_printf("\thtopmode 0x%x htstbc 0x%x chw %u\n", 294 ni->ni_htopmode, ni->ni_htstbc, ni->ni_chw); 295 296 /* XXX ampdu state */ 297 for (i = 0; i < WME_NUM_TID; i++) 298 if (ni->ni_tx_ampdu[i].txa_flags & IEEE80211_AGGR_SETUP) 299 _db_show_txampdu("\t", i, &ni->ni_tx_ampdu[i]); 300 for (i = 0; i < WME_NUM_TID; i++) 301 if (ni->ni_rx_ampdu[i].rxa_flags) 302 _db_show_rxampdu("\t", i, &ni->ni_rx_ampdu[i]); 303 304 db_printf("\tinact %u inact_reload %u txrate %u\n", 305 ni->ni_inact, ni->ni_inact_reload, ni->ni_txrate); 306 #ifdef IEEE80211_SUPPORT_MESH 307 _db_show_ssid("\tmeshid ", 0, ni->ni_meshidlen, ni->ni_meshid); 308 db_printf(" mlstate %b mllid 0x%x mlpid 0x%x mlrcnt %u mltval %u\n", 309 ni->ni_mlstate, IEEE80211_MESH_MLSTATE_BITS, 310 ni->ni_mllid, ni->ni_mlpid, ni->ni_mlrcnt, ni->ni_mltval); 311 #endif 312 313 /* VHT state */ 314 db_printf("\tvhtcap %b vht_basicmcs %#06x vht_pad2 %#06x\n", 315 ni->ni_vhtcap, IEEE80211_VHTCAP_BITS, 316 ni->ni_vht_basicmcs, ni->ni_vht_pad2); 317 db_printf("\tvht_mcsinfo: { rx_mcs_map %#06x rx_highest %#06x " 318 "tx_mcs_map %#06x tx_highest %#06x }\n", 319 ni->ni_vht_mcsinfo.rx_mcs_map, ni->ni_vht_mcsinfo.rx_highest, 320 ni->ni_vht_mcsinfo.tx_mcs_map, ni->ni_vht_mcsinfo.tx_highest); 321 db_printf("\tvht_chan1/chan2 %u/%u vht_chanwidth %#04x\n", 322 ni->ni_vht_chan1, ni->ni_vht_chan2, ni->ni_vht_chanwidth); 323 db_printf("\tvht_pad1 %#04x vht_spare { %#x %#x %#x %#x %#x %#x %#x %#x }\n", 324 ni->ni_vht_pad1, ni->ni_vht_spare[0], ni->ni_vht_spare[1], 325 ni->ni_vht_spare[2], ni->ni_vht_spare[3], ni->ni_vht_spare[4], 326 ni->ni_vht_spare[5], ni->ni_vht_spare[6], ni->ni_vht_spare[7]); 327 } 328 329 #ifdef IEEE80211_SUPPORT_TDMA 330 static void 331 _db_show_tdma(const char *sep, const struct ieee80211_tdma_state *ts, int showprocs) 332 { 333 db_printf("%stdma %p:\n", sep, ts); 334 db_printf("%s version %u slot %u bintval %u peer %p\n", sep, 335 ts->tdma_version, ts->tdma_slot, ts->tdma_bintval, ts->tdma_peer); 336 db_printf("%s slotlen %u slotcnt %u", sep, 337 ts->tdma_slotlen, ts->tdma_slotcnt); 338 db_printf(" inuse 0x%x active 0x%x count %d\n", 339 ts->tdma_inuse[0], ts->tdma_active[0], ts->tdma_count); 340 if (showprocs) { 341 DB_PRINTSYM(sep, " tdma_newstate", ts->tdma_newstate); 342 DB_PRINTSYM(sep, " tdma_recv_mgmt", ts->tdma_recv_mgmt); 343 DB_PRINTSYM(sep, " tdma_opdetach", ts->tdma_opdetach); 344 } 345 } 346 #endif /* IEEE80211_SUPPORT_TDMA */ 347 348 static void 349 _db_show_vap(const struct ieee80211vap *vap, int showmesh, int showprocs) 350 { 351 const struct ieee80211com *ic = vap->iv_ic; 352 int i; 353 354 db_printf("VAP %p:", vap); 355 db_printf(" bss %p", vap->iv_bss); 356 db_printf(" myaddr %s", ether_sprintf(vap->iv_myaddr)); 357 db_printf("\n"); 358 359 db_printf("\topmode %s", ieee80211_opmode_name[vap->iv_opmode]); 360 #ifdef IEEE80211_SUPPORT_MESH 361 if (vap->iv_opmode == IEEE80211_M_MBSS) 362 db_printf("(%p)", vap->iv_mesh); 363 #endif 364 db_printf(" state %s", ieee80211_state_name[vap->iv_state]); 365 db_printf(" ifp %p(%s)", vap->iv_ifp, if_name(vap->iv_ifp)); 366 db_printf("\n"); 367 368 db_printf("\tic %p", vap->iv_ic); 369 db_printf(" media %p", &vap->iv_media); 370 db_printf(" bpf_if %p", vap->iv_rawbpf); 371 db_printf(" mgtsend %p", &vap->iv_mgtsend); 372 #if 0 373 struct sysctllog *iv_sysctl; /* dynamic sysctl context */ 374 #endif 375 db_printf("\n"); 376 db_printf("\tdebug=%b\n", vap->iv_debug, IEEE80211_MSG_BITS); 377 378 db_printf("\tflags=%b\n", vap->iv_flags, IEEE80211_F_BITS); 379 db_printf("\tflags_ext=%b\n", vap->iv_flags_ext, IEEE80211_FEXT_BITS); 380 db_printf("\tflags_ht=%b\n", vap->iv_flags_ht, IEEE80211_FHT_BITS); 381 db_printf("\tflags_ven=%b\n", vap->iv_flags_ven, IEEE80211_FVEN_BITS); 382 db_printf("\tcaps=%b\n", vap->iv_caps, IEEE80211_C_BITS); 383 db_printf("\thtcaps=%b\n", vap->iv_htcaps, IEEE80211_C_HTCAP_BITS); 384 db_printf("\tvhtcaps=%b\n", vap->iv_vhtcaps, IEEE80211_VHTCAP_BITS); 385 386 _db_show_stats(&vap->iv_stats); 387 388 db_printf("\tinact_init %d", vap->iv_inact_init); 389 db_printf(" inact_auth %d", vap->iv_inact_auth); 390 db_printf(" inact_run %d", vap->iv_inact_run); 391 db_printf(" inact_probe %d", vap->iv_inact_probe); 392 db_printf("\n"); 393 394 db_printf("\tdes_nssid %d", vap->iv_des_nssid); 395 if (vap->iv_des_nssid) 396 _db_show_ssid(" des_ssid[%u] ", 0, 397 vap->iv_des_ssid[0].len, vap->iv_des_ssid[0].ssid); 398 db_printf(" des_bssid %s", ether_sprintf(vap->iv_des_bssid)); 399 db_printf("\n"); 400 db_printf("\tdes_mode %d", vap->iv_des_mode); 401 _db_show_channel(" des_chan", vap->iv_des_chan); 402 db_printf("\n"); 403 #if 0 404 int iv_nicknamelen; /* XXX junk */ 405 uint8_t iv_nickname[IEEE80211_NWID_LEN]; 406 #endif 407 db_printf("\tbgscanidle %u", vap->iv_bgscanidle); 408 db_printf(" bgscanintvl %u", vap->iv_bgscanintvl); 409 db_printf(" scanvalid %u", vap->iv_scanvalid); 410 db_printf("\n"); 411 db_printf("\tscanreq_duration %u", vap->iv_scanreq_duration); 412 db_printf(" scanreq_mindwell %u", vap->iv_scanreq_mindwell); 413 db_printf(" scanreq_maxdwell %u", vap->iv_scanreq_maxdwell); 414 db_printf("\n"); 415 db_printf("\tscanreq_flags 0x%x", vap->iv_scanreq_flags); 416 db_printf(" scanreq_nssid %d", vap->iv_scanreq_nssid); 417 for (i = 0; i < vap->iv_scanreq_nssid; i++) 418 _db_show_ssid(" scanreq_ssid[%u]", i, 419 vap->iv_scanreq_ssid[i].len, vap->iv_scanreq_ssid[i].ssid); 420 db_printf(" roaming %d", vap->iv_roaming); 421 db_printf("\n"); 422 for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++) 423 if (isset(ic->ic_modecaps, i)) { 424 _db_show_roamparams("\troamparms[%s]", 425 ieee80211_phymode_name[i], &vap->iv_roamparms[i]); 426 db_printf("\n"); 427 } 428 429 db_printf("\tbmissthreshold %u", vap->iv_bmissthreshold); 430 db_printf(" bmiss_max %u", vap->iv_bmiss_count); 431 db_printf(" bmiss_max %d", vap->iv_bmiss_max); 432 db_printf("\n"); 433 db_printf("\tswbmiss_count %u", vap->iv_swbmiss_count); 434 db_printf(" swbmiss_period %u", vap->iv_swbmiss_period); 435 db_printf(" swbmiss %p", &vap->iv_swbmiss); 436 db_printf("\n"); 437 438 db_printf("\tampdu_rxmax %d", vap->iv_ampdu_rxmax); 439 db_printf(" ampdu_density %d", vap->iv_ampdu_density); 440 db_printf(" ampdu_limit %d", vap->iv_ampdu_limit); 441 db_printf(" amsdu_limit %d", vap->iv_amsdu_limit); 442 db_printf("\n"); 443 444 db_printf("\tmax_aid %u", vap->iv_max_aid); 445 db_printf(" aid_bitmap %p", vap->iv_aid_bitmap); 446 db_printf("\n"); 447 db_printf("\tsta_assoc %u", vap->iv_sta_assoc); 448 db_printf(" ps_sta %u", vap->iv_ps_sta); 449 db_printf(" ps_pending %u", vap->iv_ps_pending); 450 db_printf(" tim_len %u", vap->iv_tim_len); 451 db_printf(" tim_bitmap %p", vap->iv_tim_bitmap); 452 db_printf("\n"); 453 db_printf("\tdtim_period %u", vap->iv_dtim_period); 454 db_printf(" dtim_count %u", vap->iv_dtim_count); 455 db_printf(" set_tim %p", vap->iv_set_tim); 456 db_printf(" csa_count %d", vap->iv_csa_count); 457 db_printf("\n"); 458 459 db_printf("\trtsthreshold %u", vap->iv_rtsthreshold); 460 db_printf(" fragthreshold %u", vap->iv_fragthreshold); 461 db_printf(" inact_timer %d", vap->iv_inact_timer); 462 db_printf("\n"); 463 for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++) 464 if (isset(ic->ic_modecaps, i)) { 465 _db_show_txparams("\ttxparms[%s]", 466 ieee80211_phymode_name[i], &vap->iv_txparms[i]); 467 db_printf("\n"); 468 } 469 470 /* application-specified IE's to attach to mgt frames */ 471 _db_show_appie("\tappie_beacon", vap->iv_appie_beacon); 472 _db_show_appie("\tappie_probereq", vap->iv_appie_probereq); 473 _db_show_appie("\tappie_proberesp", vap->iv_appie_proberesp); 474 _db_show_appie("\tappie_assocreq", vap->iv_appie_assocreq); 475 _db_show_appie("\tappie_asscoresp", vap->iv_appie_assocresp); 476 _db_show_appie("\tappie_wpa", vap->iv_appie_wpa); 477 if (vap->iv_wpa_ie != NULL || vap->iv_rsn_ie != NULL) { 478 if (vap->iv_wpa_ie != NULL) 479 db_printf("\twpa_ie %p", vap->iv_wpa_ie); 480 if (vap->iv_rsn_ie != NULL) 481 db_printf("\trsn_ie %p", vap->iv_rsn_ie); 482 db_printf("\n"); 483 } 484 db_printf("\tmax_keyix %u", vap->iv_max_keyix); 485 db_printf(" def_txkey %d", vap->iv_def_txkey); 486 db_printf("\n"); 487 for (i = 0; i < IEEE80211_WEP_NKID; i++) 488 _db_show_key("\tnw_keys[%u]", i, &vap->iv_nw_keys[i]); 489 490 db_printf("\tauth %p(%s)", vap->iv_auth, vap->iv_auth->ia_name); 491 db_printf(" ec %p", vap->iv_ec); 492 493 db_printf(" acl %p", vap->iv_acl); 494 db_printf(" as %p", vap->iv_as); 495 db_printf("\n"); 496 #ifdef IEEE80211_SUPPORT_MESH 497 if (showmesh && vap->iv_mesh != NULL) 498 _db_show_mesh(vap->iv_mesh); 499 #endif 500 #ifdef IEEE80211_SUPPORT_TDMA 501 if (vap->iv_tdma != NULL) 502 _db_show_tdma("\t", vap->iv_tdma, showprocs); 503 #endif /* IEEE80211_SUPPORT_TDMA */ 504 505 db_printf("\tsta_assoc %u", vap->iv_sta_assoc); 506 db_printf(" ht_sta_assoc %u", vap->iv_ht_sta_assoc); 507 db_printf(" ht40_sta_assoc %u", vap->iv_ht40_sta_assoc); 508 db_printf("\n"); 509 db_printf(" nonerpsta %u", vap->iv_nonerpsta); 510 db_printf(" longslotsta %u", vap->iv_longslotsta); 511 db_printf(" lastnonerp %d", vap->iv_lastnonerp); 512 db_printf(" lastnonht %d", vap->iv_lastnonht); 513 db_printf("\n"); 514 515 if (showprocs) { 516 DB_PRINTSYM("\t", "iv_key_alloc", vap->iv_key_alloc); 517 DB_PRINTSYM("\t", "iv_key_delete", vap->iv_key_delete); 518 DB_PRINTSYM("\t", "iv_key_set", vap->iv_key_set); 519 DB_PRINTSYM("\t", "iv_key_update_begin", vap->iv_key_update_begin); 520 DB_PRINTSYM("\t", "iv_key_update_end", vap->iv_key_update_end); 521 DB_PRINTSYM("\t", "iv_opdetach", vap->iv_opdetach); 522 DB_PRINTSYM("\t", "iv_input", vap->iv_input); 523 DB_PRINTSYM("\t", "iv_recv_mgmt", vap->iv_recv_mgmt); 524 DB_PRINTSYM("\t", "iv_deliver_data", vap->iv_deliver_data); 525 DB_PRINTSYM("\t", "iv_bmiss", vap->iv_bmiss); 526 DB_PRINTSYM("\t", "iv_reset", vap->iv_reset); 527 DB_PRINTSYM("\t", "iv_update_beacon", vap->iv_update_beacon); 528 DB_PRINTSYM("\t", "iv_newstate", vap->iv_newstate); 529 DB_PRINTSYM("\t", "iv_output", vap->iv_output); 530 } 531 } 532 533 static void 534 _db_show_com(const struct ieee80211com *ic, int showvaps, int showsta, 535 int showmesh, int showprocs) 536 { 537 struct ieee80211vap *vap; 538 539 db_printf("COM: %p:", ic); 540 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) 541 db_printf(" %s(%p)", if_name(vap->iv_ifp), vap); 542 db_printf("\n"); 543 db_printf("\tsoftc %p", ic->ic_softc); 544 db_printf("\tname %s", ic->ic_name); 545 db_printf(" comlock %p", &ic->ic_comlock); 546 db_printf(" txlock %p", &ic->ic_txlock); 547 db_printf(" fflock %p", &ic->ic_fflock); 548 db_printf("\n"); 549 db_printf("\theadroom %d", ic->ic_headroom); 550 db_printf(" phytype %d", ic->ic_phytype); 551 db_printf(" opmode %s", ieee80211_opmode_name[ic->ic_opmode]); 552 db_printf("\n"); 553 db_printf(" inact %p", &ic->ic_inact); 554 db_printf("\n"); 555 556 db_printf("\tflags=%b\n", ic->ic_flags, IEEE80211_F_BITS); 557 db_printf("\tflags_ext=%b\n", ic->ic_flags_ext, IEEE80211_FEXT_BITS); 558 db_printf("\tflags_ht=%b\n", ic->ic_flags_ht, IEEE80211_FHT_BITS); 559 db_printf("\tflags_ven=%b\n", ic->ic_flags_ven, IEEE80211_FVEN_BITS); 560 db_printf("\tcaps=%b\n", ic->ic_caps, IEEE80211_C_BITS); 561 db_printf("\tcryptocaps=%b\n", 562 ic->ic_cryptocaps, IEEE80211_CRYPTO_BITS); 563 db_printf("\thtcaps=%b\n", ic->ic_htcaps, IEEE80211_HTCAP_BITS); 564 db_printf("\tvhtcaps=%b\n", ic->ic_vhtcaps, IEEE80211_VHTCAP_BITS); 565 566 #if 0 567 uint8_t ic_modecaps[2]; /* set of mode capabilities */ 568 #endif 569 db_printf("\tcurmode %u", ic->ic_curmode); 570 db_printf(" promisc %u", ic->ic_promisc); 571 db_printf(" allmulti %u", ic->ic_allmulti); 572 db_printf(" nrunning %u", ic->ic_nrunning); 573 db_printf("\n"); 574 db_printf("\tbintval %u", ic->ic_bintval); 575 db_printf(" lintval %u", ic->ic_lintval); 576 db_printf(" holdover %u", ic->ic_holdover); 577 db_printf(" txpowlimit %u", ic->ic_txpowlimit); 578 db_printf("\n"); 579 #if 0 580 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; 581 #endif 582 /* 583 * Channel state: 584 * 585 * ic_channels is the set of available channels for the device; 586 * it is setup by the driver 587 * ic_nchans is the number of valid entries in ic_channels 588 * ic_chan_avail is a bit vector of these channels used to check 589 * whether a channel is available w/o searching the channel table. 590 * ic_chan_active is a (potentially) constrained subset of 591 * ic_chan_avail that reflects any mode setting or user-specified 592 * limit on the set of channels to use/scan 593 * ic_curchan is the current channel the device is set to; it may 594 * be different from ic_bsschan when we are off-channel scanning 595 * or otherwise doing background work 596 * ic_bsschan is the channel selected for operation; it may 597 * be undefined (IEEE80211_CHAN_ANYC) 598 * ic_prevchan is a cached ``previous channel'' used to optimize 599 * lookups when switching back+forth between two channels 600 * (e.g. for dynamic turbo) 601 */ 602 db_printf("\tnchans %d", ic->ic_nchans); 603 #if 0 604 struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX]; 605 uint8_t ic_chan_avail[IEEE80211_CHAN_BYTES]; 606 uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; 607 uint8_t ic_chan_scan[IEEE80211_CHAN_BYTES]; 608 #endif 609 db_printf("\n"); 610 _db_show_channel("\tcurchan", ic->ic_curchan); 611 db_printf("\n"); 612 _db_show_channel("\tbsschan", ic->ic_bsschan); 613 db_printf("\n"); 614 _db_show_channel("\tprevchan", ic->ic_prevchan); 615 db_printf("\n"); 616 db_printf("\tregdomain %p", &ic->ic_regdomain); 617 db_printf("\n"); 618 619 _db_show_channel("\tcsa_newchan", ic->ic_csa_newchan); 620 db_printf(" csa_count %d", ic->ic_csa_count); 621 db_printf( "dfs %p", &ic->ic_dfs); 622 db_printf("\n"); 623 624 db_printf("\tscan %p", ic->ic_scan); 625 db_printf(" lastdata %d", ic->ic_lastdata); 626 db_printf(" lastscan %d", ic->ic_lastscan); 627 db_printf("\n"); 628 629 db_printf("\tmax_keyix %d", ic->ic_max_keyix); 630 db_printf(" hash_key 0x%x", ic->ic_hash_key); 631 db_printf(" wme %p", &ic->ic_wme); 632 if (!showsta) 633 db_printf(" sta %p", &ic->ic_sta); 634 db_printf("\n"); 635 db_printf("\tstageq@%p:\n", &ic->ic_stageq); 636 _db_show_ageq("\t", &ic->ic_stageq); 637 if (showsta) 638 _db_show_node_table("\t", &ic->ic_sta); 639 640 db_printf("\tprotmode %d", ic->ic_protmode); 641 db_printf("\tcurhtprotmode 0x%x", ic->ic_curhtprotmode); 642 db_printf(" htprotmode %d", ic->ic_htprotmode); 643 db_printf("\n"); 644 645 db_printf("\tsuperg %p\n", ic->ic_superg); 646 647 db_printf("\tmontaps %d th %p txchan %p rh %p rxchan %p\n", 648 ic->ic_montaps, ic->ic_th, ic->ic_txchan, ic->ic_rh, ic->ic_rxchan); 649 650 if (showprocs) { 651 DB_PRINTSYM("\t", "ic_vap_create", ic->ic_vap_create); 652 DB_PRINTSYM("\t", "ic_vap_delete", ic->ic_vap_delete); 653 #if 0 654 /* operating mode attachment */ 655 ieee80211vap_attach ic_vattach[IEEE80211_OPMODE_MAX]; 656 #endif 657 DB_PRINTSYM("\t", "ic_newassoc", ic->ic_newassoc); 658 DB_PRINTSYM("\t", "ic_getradiocaps", ic->ic_getradiocaps); 659 DB_PRINTSYM("\t", "ic_setregdomain", ic->ic_setregdomain); 660 DB_PRINTSYM("\t", "ic_send_mgmt", ic->ic_send_mgmt); 661 DB_PRINTSYM("\t", "ic_raw_xmit", ic->ic_raw_xmit); 662 DB_PRINTSYM("\t", "ic_updateslot", ic->ic_updateslot); 663 DB_PRINTSYM("\t", "ic_update_mcast", ic->ic_update_mcast); 664 DB_PRINTSYM("\t", "ic_update_promisc", ic->ic_update_promisc); 665 DB_PRINTSYM("\t", "ic_node_alloc", ic->ic_node_alloc); 666 DB_PRINTSYM("\t", "ic_node_free", ic->ic_node_free); 667 DB_PRINTSYM("\t", "ic_node_cleanup", ic->ic_node_cleanup); 668 DB_PRINTSYM("\t", "ic_node_getrssi", ic->ic_node_getrssi); 669 DB_PRINTSYM("\t", "ic_node_getsignal", ic->ic_node_getsignal); 670 DB_PRINTSYM("\t", "ic_node_getmimoinfo", ic->ic_node_getmimoinfo); 671 DB_PRINTSYM("\t", "ic_scan_start", ic->ic_scan_start); 672 DB_PRINTSYM("\t", "ic_scan_end", ic->ic_scan_end); 673 DB_PRINTSYM("\t", "ic_set_channel", ic->ic_set_channel); 674 DB_PRINTSYM("\t", "ic_scan_curchan", ic->ic_scan_curchan); 675 DB_PRINTSYM("\t", "ic_scan_mindwell", ic->ic_scan_mindwell); 676 DB_PRINTSYM("\t", "ic_recv_action", ic->ic_recv_action); 677 DB_PRINTSYM("\t", "ic_send_action", ic->ic_send_action); 678 DB_PRINTSYM("\t", "ic_addba_request", ic->ic_addba_request); 679 DB_PRINTSYM("\t", "ic_addba_response", ic->ic_addba_response); 680 DB_PRINTSYM("\t", "ic_addba_stop", ic->ic_addba_stop); 681 } 682 if (showvaps && !TAILQ_EMPTY(&ic->ic_vaps)) { 683 db_printf("\n"); 684 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) 685 _db_show_vap(vap, showmesh, showprocs); 686 } 687 if (showsta && !TAILQ_EMPTY(&ic->ic_sta.nt_node)) { 688 const struct ieee80211_node_table *nt = &ic->ic_sta; 689 const struct ieee80211_node *ni; 690 691 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 692 db_printf("\n"); 693 _db_show_sta(ni); 694 } 695 } 696 } 697 698 static void 699 _db_show_all_vaps(void *arg, struct ieee80211com *ic) 700 { 701 int showall = *(int *)arg; 702 703 if (!showall) { 704 const struct ieee80211vap *vap; 705 db_printf("%s: com %p vaps:", ic->ic_name, ic); 706 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) 707 db_printf(" %s(%p)", if_name(vap->iv_ifp), vap); 708 db_printf("\n"); 709 } else 710 _db_show_com(ic, 1, 1, 1, 1); 711 } 712 713 static void 714 _db_show_node_table(const char *tag, const struct ieee80211_node_table *nt) 715 { 716 int i; 717 718 db_printf("%s%s@%p:\n", tag, nt->nt_name, nt); 719 db_printf("%s nodelock %p", tag, &nt->nt_nodelock); 720 db_printf(" inact_init %d", nt->nt_inact_init); 721 db_printf("%s keyixmax %d keyixmap %p\n", 722 tag, nt->nt_keyixmax, nt->nt_keyixmap); 723 for (i = 0; i < nt->nt_keyixmax; i++) { 724 const struct ieee80211_node *ni = nt->nt_keyixmap[i]; 725 if (ni != NULL) 726 db_printf("%s [%3u] %p %s\n", tag, i, ni, 727 ether_sprintf(ni->ni_macaddr)); 728 } 729 } 730 731 static void 732 _db_show_channel(const char *tag, const struct ieee80211_channel *c) 733 { 734 db_printf("%s ", tag); 735 if (c == NULL) 736 db_printf("<NULL>"); 737 else if (c == IEEE80211_CHAN_ANYC) 738 db_printf("<ANY>"); 739 else 740 db_printf("[%u (%u) flags=%b maxreg %d maxpow %d minpow %d state 0x%x extieee %u]", 741 c->ic_freq, c->ic_ieee, 742 c->ic_flags, IEEE80211_CHAN_BITS, 743 c->ic_maxregpower, c->ic_maxpower, c->ic_minpower, 744 c->ic_state, c->ic_extieee); 745 } 746 747 static void 748 _db_show_ssid(const char *tag, int ix, int len, const uint8_t *ssid) 749 { 750 const uint8_t *p; 751 int i; 752 753 db_printf(tag, ix); 754 755 if (len > IEEE80211_NWID_LEN) 756 len = IEEE80211_NWID_LEN; 757 /* determine printable or not */ 758 for (i = 0, p = ssid; i < len; i++, p++) { 759 if (*p < ' ' || *p > 0x7e) 760 break; 761 } 762 if (i == len) { 763 db_printf("\""); 764 for (i = 0, p = ssid; i < len; i++, p++) 765 db_printf("%c", *p); 766 db_printf("\""); 767 } else { 768 db_printf("0x"); 769 for (i = 0, p = ssid; i < len; i++, p++) 770 db_printf("%02x", *p); 771 } 772 } 773 774 static void 775 _db_show_appie(const char *tag, const struct ieee80211_appie *ie) 776 { 777 const uint8_t *p; 778 int i; 779 780 if (ie == NULL) 781 return; 782 db_printf("%s [0x", tag); 783 for (i = 0, p = ie->ie_data; i < ie->ie_len; i++, p++) 784 db_printf("%02x", *p); 785 db_printf("]\n"); 786 } 787 788 static void 789 _db_show_key(const char *tag, int ix, const struct ieee80211_key *wk) 790 { 791 static const uint8_t zerodata[IEEE80211_KEYBUF_SIZE]; 792 const struct ieee80211_cipher *cip = wk->wk_cipher; 793 int keylen = wk->wk_keylen; 794 795 db_printf(tag, ix); 796 switch (cip->ic_cipher) { 797 case IEEE80211_CIPHER_WEP: 798 /* compatibility */ 799 db_printf(" wepkey %u:%s", wk->wk_keyix, 800 keylen <= 5 ? "40-bit" : 801 keylen <= 13 ? "104-bit" : "128-bit"); 802 break; 803 case IEEE80211_CIPHER_TKIP: 804 if (keylen > 128/8) 805 keylen -= 128/8; /* ignore MIC for now */ 806 db_printf(" TKIP %u:%u-bit", wk->wk_keyix, 8*keylen); 807 break; 808 case IEEE80211_CIPHER_AES_OCB: 809 db_printf(" AES-OCB %u:%u-bit", wk->wk_keyix, 8*keylen); 810 break; 811 case IEEE80211_CIPHER_AES_CCM: 812 db_printf(" AES-CCM %u:%u-bit", wk->wk_keyix, 8*keylen); 813 break; 814 case IEEE80211_CIPHER_CKIP: 815 db_printf(" CKIP %u:%u-bit", wk->wk_keyix, 8*keylen); 816 break; 817 case IEEE80211_CIPHER_NONE: 818 db_printf(" NULL %u:%u-bit", wk->wk_keyix, 8*keylen); 819 break; 820 default: 821 db_printf(" UNKNOWN (0x%x) %u:%u-bit", 822 cip->ic_cipher, wk->wk_keyix, 8*keylen); 823 break; 824 } 825 if (wk->wk_rxkeyix != wk->wk_keyix) 826 db_printf(" rxkeyix %u", wk->wk_rxkeyix); 827 if (memcmp(wk->wk_key, zerodata, keylen) != 0) { 828 int i; 829 830 db_printf(" <"); 831 for (i = 0; i < keylen; i++) 832 db_printf("%02x", wk->wk_key[i]); 833 db_printf(">"); 834 if (cip->ic_cipher != IEEE80211_CIPHER_WEP && 835 wk->wk_keyrsc[IEEE80211_NONQOS_TID] != 0) 836 db_printf(" rsc %ju", (uintmax_t)wk->wk_keyrsc[IEEE80211_NONQOS_TID]); 837 if (cip->ic_cipher != IEEE80211_CIPHER_WEP && 838 wk->wk_keytsc != 0) 839 db_printf(" tsc %ju", (uintmax_t)wk->wk_keytsc); 840 db_printf(" flags=%b", wk->wk_flags, IEEE80211_KEY_BITS); 841 } 842 db_printf("\n"); 843 } 844 845 static void 846 printrate(const char *tag, int v) 847 { 848 if (v == IEEE80211_FIXED_RATE_NONE) 849 db_printf(" %s <none>", tag); 850 else if (v == 11) 851 db_printf(" %s 5.5", tag); 852 else if (v & IEEE80211_RATE_MCS) 853 db_printf(" %s MCS%d", tag, v &~ IEEE80211_RATE_MCS); 854 else 855 db_printf(" %s %d", tag, v/2); 856 } 857 858 static void 859 _db_show_roamparams(const char *tag, const void *arg, 860 const struct ieee80211_roamparam *rp) 861 { 862 863 db_printf(tag, arg); 864 if (rp->rssi & 1) 865 db_printf(" rssi %u.5", rp->rssi/2); 866 else 867 db_printf(" rssi %u", rp->rssi/2); 868 printrate("rate", rp->rate); 869 } 870 871 static void 872 _db_show_txparams(const char *tag, const void *arg, 873 const struct ieee80211_txparam *tp) 874 { 875 876 db_printf(tag, arg); 877 printrate("ucastrate", tp->ucastrate); 878 printrate("mcastrate", tp->mcastrate); 879 printrate("mgmtrate", tp->mgmtrate); 880 db_printf(" maxretry %d", tp->maxretry); 881 } 882 883 static void 884 _db_show_ageq(const char *tag, const struct ieee80211_ageq *q) 885 { 886 const struct mbuf *m; 887 888 db_printf("%s lock %p len %d maxlen %d drops %d head %p tail %p\n", 889 tag, &q->aq_lock, q->aq_len, q->aq_maxlen, q->aq_drops, 890 q->aq_head, q->aq_tail); 891 for (m = q->aq_head; m != NULL; m = m->m_nextpkt) 892 db_printf("%s %p (len %d, %b)\n", tag, m, m->m_len, 893 /* XXX could be either TX or RX but is mostly TX */ 894 m->m_flags, IEEE80211_MBUF_TX_FLAG_BITS); 895 } 896 897 static void 898 _db_show_stats(const struct ieee80211_stats *is) 899 { 900 } 901 902 #ifdef IEEE80211_SUPPORT_MESH 903 static void 904 _db_show_mesh(const struct ieee80211_mesh_state *ms) 905 { 906 struct ieee80211_mesh_route *rt; 907 int i; 908 909 _db_show_ssid(" meshid ", 0, ms->ms_idlen, ms->ms_id); 910 db_printf("nextseq %u ttl %u flags 0x%x\n", ms->ms_seq, 911 ms->ms_ttl, ms->ms_flags); 912 db_printf("routing table:\n"); 913 i = 0; 914 TAILQ_FOREACH(rt, &ms->ms_routes, rt_next) { 915 db_printf("entry %d:\tdest: %6D nexthop: %6D metric: %u", i, 916 rt->rt_dest, ":", rt->rt_nexthop, ":", rt->rt_metric); 917 918 db_printf("\tlifetime: %u lastseq: %u priv: %p\n", 919 ieee80211_mesh_rt_update(rt, 0), 920 rt->rt_lastmseq, rt->rt_priv); 921 i++; 922 } 923 } 924 #endif /* IEEE80211_SUPPORT_MESH */ 925 #endif /* DDB */ 926