Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/wlandebug/wlandebug.c
Show All 37 Lines | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <getopt.h> | #include <getopt.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <libifconfig.h> | |||||
#define N(a) (sizeof(a)/sizeof(a[0])) | #define N(a) (sizeof(a)/sizeof(a[0])) | ||||
const char *progname; | const char *progname; | ||||
#define IEEE80211_MSG_11N 0x80000000 /* 11n mode debug */ | #define IEEE80211_MSG_11N 0x80000000 /* 11n mode debug */ | ||||
#define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */ | #define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */ | ||||
#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */ | #define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */ | ||||
#define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */ | #define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */ | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if (wlan) | ||||
snprintf(oid, oidlen, "net.link.ieee80211.%s.debug", wlan); | snprintf(oid, oidlen, "net.link.ieee80211.%s.debug", wlan); | ||||
else | else | ||||
snprintf(oid, oidlen, "net.link.ieee80211.debug"); | snprintf(oid, oidlen, "net.link.ieee80211.debug"); | ||||
#else | #else | ||||
#error "No support for this system" | #error "No support for this system" | ||||
#endif | #endif | ||||
} | } | ||||
static void | |||||
change_iface_unit(char *oid, size_t oid_size, char *name) | |||||
{ | |||||
struct ifconfig_handle *h; | |||||
char *orig_name; | |||||
h = ifconfig_open(); | |||||
if (ifconfig_get_orig_name(h, name, &orig_name) < 0) | |||||
errc(1, ifconfig_err_errno(h), "cannot get interface number"); | |||||
ifconfig_close(h); | |||||
setoid(oid, oid_size, orig_name); | |||||
free(orig_name); | |||||
} | |||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
const char *cp, *tp; | const char *cp, *tp; | ||||
const char *sep; | const char *sep; | ||||
int op, i; | int op, i; | ||||
u_int32_t debug, ndebug; | u_int32_t debug, ndebug; | ||||
size_t debuglen; | size_t debuglen; | ||||
char oid[256]; | char oid[256]; | ||||
progname = argv[0]; | progname = argv[0]; | ||||
setoid(oid, sizeof(oid), "wlan0"); | setoid(oid, sizeof(oid), "wlan0"); | ||||
if (argc > 1) { | if (argc > 1) { | ||||
if (strcmp(argv[1], "-d") == 0) { | if (strcmp(argv[1], "-d") == 0) { | ||||
setoid(oid, sizeof(oid), NULL); | setoid(oid, sizeof(oid), NULL); | ||||
argc -= 1, argv += 1; | argc -= 1, argv += 1; | ||||
} else if (strcmp(argv[1], "-i") == 0) { | } else if (strcmp(argv[1], "-i") == 0) { | ||||
if (argc <= 2) | if (argc <= 2) | ||||
errx(1, "missing interface name for -i option"); | errx(1, "missing interface name for -i option"); | ||||
if (strncmp(argv[2], "wlan", 4) != 0) | change_iface_unit(oid, sizeof(oid), argv[2]); | ||||
errx(1, "expecting a wlan interface name"); | |||||
setoid(oid, sizeof(oid), argv[2]); | |||||
argc -= 2, argv += 2; | argc -= 2, argv += 2; | ||||
} else if (strcmp(argv[1], "-?") == 0) | } else if (strcmp(argv[1], "-?") == 0) | ||||
usage(); | usage(); | ||||
} | } | ||||
debuglen = sizeof(debug); | debuglen = sizeof(debug); | ||||
if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) | if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) | ||||
err(1, "sysctl-get(%s)", oid); | err(1, "sysctl-get(%s)", oid); | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |