Deleted Added
full compact
wlandebug.c (165963) wlandebug.c (170534)
1/*-
2 * Copyright (c) 2002-2004 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

--- 19 unchanged lines hidden (view full) ---

28 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
29 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGES.
35 *
1/*-
2 * Copyright (c) 2002-2004 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

--- 19 unchanged lines hidden (view full) ---

28 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
29 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGES.
35 *
36 * $FreeBSD: head/usr.sbin/wlandebug/wlandebug.c 165963 2007-01-12 05:36:17Z sam $
36 * $FreeBSD: head/usr.sbin/wlandebug/wlandebug.c 170534 2007-06-11 04:05:15Z sam $
37 */
38
39/*
40 * wlandebug [-i interface] flags
41 * (default interface is wlan.0).
42 */
43#include <sys/types.h>
44
45#include <stdio.h>
37 */
38
39/*
40 * wlandebug [-i interface] flags
41 * (default interface is wlan.0).
42 */
43#include <sys/types.h>
44
45#include <stdio.h>
46#include <stdlib.h>
46#include <ctype.h>
47#include <getopt.h>
48#include <string.h>
47#include <ctype.h>
48#include <getopt.h>
49#include <string.h>
50#include <err.h>
49
50#define N(a) (sizeof(a)/sizeof(a[0]))
51
52const char *progname;
53
51
52#define N(a) (sizeof(a)/sizeof(a[0]))
53
54const char *progname;
55
56#define IEEE80211_MSG_11N 0x80000000 /* 11n mode debug */
54#define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */
55#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */
56#define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */
57#define IEEE80211_MSG_INPUT 0x08000000 /* input handling */
58#define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */
59#define IEEE80211_MSG_ELEMID 0x02000000 /* element id parsing */
60#define IEEE80211_MSG_NODE 0x01000000 /* node handling */
61#define IEEE80211_MSG_ASSOC 0x00800000 /* association handling */

--- 15 unchanged lines hidden (view full) ---

77#define IEEE80211_MSG_INACT 0x00000080 /* inactivity handling */
78#define IEEE80211_MSG_ROAM 0x00000040 /* sta-mode roaming */
79#define IEEE80211_MSG_RATECTL 0x00000020 /* tx rate control */
80
81static struct {
82 const char *name;
83 u_int bit;
84} flags[] = {
57#define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */
58#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */
59#define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */
60#define IEEE80211_MSG_INPUT 0x08000000 /* input handling */
61#define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */
62#define IEEE80211_MSG_ELEMID 0x02000000 /* element id parsing */
63#define IEEE80211_MSG_NODE 0x01000000 /* node handling */
64#define IEEE80211_MSG_ASSOC 0x00800000 /* association handling */

--- 15 unchanged lines hidden (view full) ---

80#define IEEE80211_MSG_INACT 0x00000080 /* inactivity handling */
81#define IEEE80211_MSG_ROAM 0x00000040 /* sta-mode roaming */
82#define IEEE80211_MSG_RATECTL 0x00000020 /* tx rate control */
83
84static struct {
85 const char *name;
86 u_int bit;
87} flags[] = {
88 { "11n", IEEE80211_MSG_11N },
85 { "debug", IEEE80211_MSG_DEBUG },
86 { "dumppkts", IEEE80211_MSG_DUMPPKTS },
87 { "crypto", IEEE80211_MSG_CRYPTO },
88 { "input", IEEE80211_MSG_INPUT },
89 { "xrate", IEEE80211_MSG_XRATE },
90 { "elemid", IEEE80211_MSG_ELEMID },
91 { "node", IEEE80211_MSG_NODE },
92 { "assoc", IEEE80211_MSG_ASSOC },

--- 52 unchanged lines hidden (view full) ---

145}
146
147int
148main(int argc, char *argv[])
149{
150 const char *ifname = "ath0";
151 const char *cp, *tp;
152 const char *sep;
89 { "debug", IEEE80211_MSG_DEBUG },
90 { "dumppkts", IEEE80211_MSG_DUMPPKTS },
91 { "crypto", IEEE80211_MSG_CRYPTO },
92 { "input", IEEE80211_MSG_INPUT },
93 { "xrate", IEEE80211_MSG_XRATE },
94 { "elemid", IEEE80211_MSG_ELEMID },
95 { "node", IEEE80211_MSG_NODE },
96 { "assoc", IEEE80211_MSG_ASSOC },

--- 52 unchanged lines hidden (view full) ---

149}
150
151int
152main(int argc, char *argv[])
153{
154 const char *ifname = "ath0";
155 const char *cp, *tp;
156 const char *sep;
153 int c, op, i, unit;
157 int op, i, unit;
154 u_int32_t debug, ndebug;
155 size_t debuglen, parentlen;
156 char oid[256], parent[256];
157
158 progname = argv[0];
159 if (argc > 1) {
160 if (strcmp(argv[1], "-i") == 0) {
161 if (argc < 2)

--- 6 unchanged lines hidden (view full) ---

168
169 for (unit = 0; unit < 10; unit++) {
170#ifdef __linux__
171 snprintf(oid, sizeof(oid), "net.wlan%d.%%parent", unit);
172#else
173 snprintf(oid, sizeof(oid), "net.wlan.%d.%%parent", unit);
174#endif
175 parentlen = sizeof(parent);
158 u_int32_t debug, ndebug;
159 size_t debuglen, parentlen;
160 char oid[256], parent[256];
161
162 progname = argv[0];
163 if (argc > 1) {
164 if (strcmp(argv[1], "-i") == 0) {
165 if (argc < 2)

--- 6 unchanged lines hidden (view full) ---

172
173 for (unit = 0; unit < 10; unit++) {
174#ifdef __linux__
175 snprintf(oid, sizeof(oid), "net.wlan%d.%%parent", unit);
176#else
177 snprintf(oid, sizeof(oid), "net.wlan.%d.%%parent", unit);
178#endif
179 parentlen = sizeof(parent);
176 if (sysctlbyname(oid, parent, &parentlen, NULL, 0) >= 0 &&
177 strncmp(parent, ifname, parentlen) == 0)
180 if (sysctlbyname(oid, parent, &parentlen, NULL, 0) < 0)
181 continue;
182 if (strncmp(parent, ifname, parentlen) == 0)
178 break;
179 }
180 if (unit == 10)
181 errx(1, "%s: cannot locate wlan sysctl node.", ifname);
182#ifdef __linux__
183 snprintf(oid, sizeof(oid), "net.wlan%d.debug", unit);
184#else
185 snprintf(oid, sizeof(oid), "net.wlan.%d.debug", unit);

--- 19 unchanged lines hidden (view full) ---

205 tp++;
206 bit = getflag(cp, tp-cp);
207 if (op < 0)
208 ndebug &= ~bit;
209 else if (op > 0)
210 ndebug |= bit;
211 else {
212 if (bit == 0) {
183 break;
184 }
185 if (unit == 10)
186 errx(1, "%s: cannot locate wlan sysctl node.", ifname);
187#ifdef __linux__
188 snprintf(oid, sizeof(oid), "net.wlan%d.debug", unit);
189#else
190 snprintf(oid, sizeof(oid), "net.wlan.%d.debug", unit);

--- 19 unchanged lines hidden (view full) ---

210 tp++;
211 bit = getflag(cp, tp-cp);
212 if (op < 0)
213 ndebug &= ~bit;
214 else if (op > 0)
215 ndebug |= bit;
216 else {
217 if (bit == 0) {
213 if (isdigit(*cp))
218 int c = *cp;
219 if (isdigit(c))
214 bit = strtoul(cp, NULL, 0);
215 else
216 errx(1, "unknown flag %.*s",
220 bit = strtoul(cp, NULL, 0);
221 else
222 errx(1, "unknown flag %.*s",
217 tp-cp, cp);
223 (int)(tp-cp), cp);
218 }
219 ndebug = bit;
220 }
221 } while (*(cp = tp) != '\0');
222 }
223 if (debug != ndebug) {
224 printf("%s: 0x%x => ", oid, debug);
225 if (sysctlbyname(oid, NULL, NULL, &ndebug, sizeof(ndebug)) < 0)

--- 14 unchanged lines hidden ---
224 }
225 ndebug = bit;
226 }
227 } while (*(cp = tp) != '\0');
228 }
229 if (debug != ndebug) {
230 printf("%s: 0x%x => ", oid, debug);
231 if (sysctlbyname(oid, NULL, NULL, &ndebug, sizeof(ndebug)) < 0)

--- 14 unchanged lines hidden ---