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