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