Deleted Added
full compact
wlandebug.c (171634) wlandebug.c (178359)
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 170534 2007-06-11 04:05:15Z sam $
36 * $FreeBSD: head/usr.sbin/wlandebug/wlandebug.c 178359 2008-04-20 20:41:47Z sam $
37 */
38
39/*
40 * wlandebug [-i interface] flags
41 * (default interface is wlan.0).
42 */
43#include <sys/types.h>
44

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

75#define IEEE80211_MSG_WPA 0x00001000 /* WPA/RSN protocol */
76#define IEEE80211_MSG_ACL 0x00000800 /* ACL handling */
77#define IEEE80211_MSG_WME 0x00000400 /* WME protocol */
78#define IEEE80211_MSG_SUPERG 0x00000200 /* Atheros SuperG protocol */
79#define IEEE80211_MSG_DOTH 0x00000100 /* 802.11h support */
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 */
37 */
38
39/*
40 * wlandebug [-i interface] flags
41 * (default interface is wlan.0).
42 */
43#include <sys/types.h>
44

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

75#define IEEE80211_MSG_WPA 0x00001000 /* WPA/RSN protocol */
76#define IEEE80211_MSG_ACL 0x00000800 /* ACL handling */
77#define IEEE80211_MSG_WME 0x00000400 /* WME protocol */
78#define IEEE80211_MSG_SUPERG 0x00000200 /* Atheros SuperG protocol */
79#define IEEE80211_MSG_DOTH 0x00000100 /* 802.11h support */
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#define IEEE80211_MSG_ACTION 0x00000010 /* action frame handling */
84#define IEEE80211_MSG_WDS 0x00000008 /* WDS handling */
85#define IEEE80211_MSG_IOCTL 0x00000004 /* ioctl handling */
86#define IEEE80211_MSG_ADDBA 0x00000002 /* ADDBA handling */
83
84static struct {
85 const char *name;
86 u_int bit;
87} flags[] = {
88 { "11n", IEEE80211_MSG_11N },
89 { "debug", IEEE80211_MSG_DEBUG },
90 { "dumppkts", IEEE80211_MSG_DUMPPKTS },

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

107 { "wpa", IEEE80211_MSG_WPA },
108 { "acl", IEEE80211_MSG_ACL },
109 { "wme", IEEE80211_MSG_WME },
110 { "superg", IEEE80211_MSG_SUPERG },
111 { "doth", IEEE80211_MSG_DOTH },
112 { "inact", IEEE80211_MSG_INACT },
113 { "roam", IEEE80211_MSG_ROAM },
114 { "rate", IEEE80211_MSG_RATECTL },
87
88static struct {
89 const char *name;
90 u_int bit;
91} flags[] = {
92 { "11n", IEEE80211_MSG_11N },
93 { "debug", IEEE80211_MSG_DEBUG },
94 { "dumppkts", IEEE80211_MSG_DUMPPKTS },

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

111 { "wpa", IEEE80211_MSG_WPA },
112 { "acl", IEEE80211_MSG_ACL },
113 { "wme", IEEE80211_MSG_WME },
114 { "superg", IEEE80211_MSG_SUPERG },
115 { "doth", IEEE80211_MSG_DOTH },
116 { "inact", IEEE80211_MSG_INACT },
117 { "roam", IEEE80211_MSG_ROAM },
118 { "rate", IEEE80211_MSG_RATECTL },
119 { "action", IEEE80211_MSG_ACTION },
120 { "wds", IEEE80211_MSG_WDS },
121 { "ioctl", IEEE80211_MSG_IOCTL },
122 { "addba", IEEE80211_MSG_ADDBA },
115};
116
117static u_int
118getflag(const char *name, int len)
119{
120 int i;
121
122 for (i = 0; i < N(flags); i++)

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

143
144 fprintf(stderr, "usage: %s [-i device] [flags]\n", progname);
145 fprintf(stderr, "where flags are:\n");
146 for (i = 0; i < N(flags); i++)
147 printf("%s\n", flags[i].name);
148 exit(-1);
149}
150
123};
124
125static u_int
126getflag(const char *name, int len)
127{
128 int i;
129
130 for (i = 0; i < N(flags); i++)

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

151
152 fprintf(stderr, "usage: %s [-i device] [flags]\n", progname);
153 fprintf(stderr, "where flags are:\n");
154 for (i = 0; i < N(flags); i++)
155 printf("%s\n", flags[i].name);
156 exit(-1);
157}
158
159static void
160setoid(char oid[], size_t oidlen, const char *wlan)
161{
162#ifdef __linux__
163 snprintf(oid, oidlen, "net.%s.debug", wlan);
164#elif __FreeBSD__
165 snprintf(oid, oidlen, "net.wlan.%s.debug", wlan+4);
166#elif __NetBSD__
167 snprintf(oid, oidlen, "net.link.ieee80211.%s.debug", wlan+4);
168#else
169#error "No support for this system"
170#endif
171}
172
151int
152main(int argc, char *argv[])
153{
173int
174main(int argc, char *argv[])
175{
154 const char *ifname = "ath0";
155 const char *cp, *tp;
156 const char *sep;
157 int op, i, unit;
158 u_int32_t debug, ndebug;
159 size_t debuglen, parentlen;
176 const char *cp, *tp;
177 const char *sep;
178 int op, i, unit;
179 u_int32_t debug, ndebug;
180 size_t debuglen, parentlen;
160 char oid[256], parent[256];
181 char oid[256];
161
162 progname = argv[0];
182
183 progname = argv[0];
184 setoid(oid, sizeof(oid), "wlan0");
163 if (argc > 1) {
164 if (strcmp(argv[1], "-i") == 0) {
165 if (argc < 2)
166 errx(1, "missing interface name for -i option");
185 if (argc > 1) {
186 if (strcmp(argv[1], "-i") == 0) {
187 if (argc < 2)
188 errx(1, "missing interface name for -i option");
167 ifname = argv[2];
189 if (strncmp(argv[2], "wlan", 4) != 0)
190 errx(1, "expecting a wlan interface name");
191 setoid(oid, sizeof(oid), argv[2]);
168 argc -= 2, argv += 2;
169 } else if (strcmp(argv[1], "-?") == 0)
170 usage();
171 }
172
192 argc -= 2, argv += 2;
193 } else if (strcmp(argv[1], "-?") == 0)
194 usage();
195 }
196
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);
180 if (sysctlbyname(oid, parent, &parentlen, NULL, 0) < 0)
181 continue;
182 if (strncmp(parent, ifname, parentlen) == 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);
191#endif
192 debuglen = sizeof(debug);
193 if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0)
194 err(1, "sysctl-get(%s)", oid);
195 ndebug = debug;
196 for (; argc > 1; argc--, argv++) {
197 cp = argv[1];
198 do {
199 u_int bit;

--- 46 unchanged lines hidden ---
197 debuglen = sizeof(debug);
198 if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0)
199 err(1, "sysctl-get(%s)", oid);
200 ndebug = debug;
201 for (; argc > 1; argc--, argv++) {
202 cp = argv[1];
203 do {
204 u_int bit;

--- 46 unchanged lines hidden ---