diff options
author | sam <sam@FreeBSD.org> | 2005-08-03 04:25:04 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2005-08-03 04:25:04 +0000 |
commit | 24f85b0b69c29af04dc033d110270b9a40a1bcaa (patch) | |
tree | 0d0825c7865f0f2a2d3b6bf02454f6690b7a118b /tools | |
parent | bbf3c9f8158f29ed24b1133b7804395a64a09c68 (diff) | |
download | FreeBSD-src-24f85b0b69c29af04dc033d110270b9a40a1bcaa.zip FreeBSD-src-24f85b0b69c29af04dc033d110270b9a40a1bcaa.tar.gz |
simplify use with non-ath devices; search the wlan sysctl nodes to
locate the right one for the specified interface
MFC after: 3 days
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/ath/80211debug.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/tools/ath/80211debug.c b/tools/tools/ath/80211debug.c index 79feabf..0750e67 100644 --- a/tools/tools/ath/80211debug.c +++ b/tools/tools/ath/80211debug.c @@ -148,10 +148,10 @@ main(int argc, char *argv[]) const char *ifname = "ath0"; const char *cp, *tp; const char *sep; - int c, op, i; + int c, op, i, unit; u_int32_t debug, ndebug; - size_t debuglen; - char oid[256]; + size_t debuglen, parentlen; + char oid[256], parent[256]; progname = argv[0]; if (argc > 1) { @@ -159,17 +159,28 @@ main(int argc, char *argv[]) if (argc < 2) errx(1, "missing interface name for -i option"); ifname = argv[2]; - if (strncmp(ifname, "ath", 3) != 0) - errx(2, "huh, this is for ath devices?"); argc -= 2, argv += 2; } else if (strcmp(argv[1], "-?") == 0) usage(); } + for (unit = 0; unit < 10; unit++) { #ifdef __linux__ - snprintf(oid, sizeof(oid), "net.wlan%s.debug", ifname+3); + snprintf(oid, sizeof(oid), "net.wlan%d.%%parent", unit); #else - snprintf(oid, sizeof(oid), "net.wlan.%s.debug", ifname+3); + snprintf(oid, sizeof(oid), "net.wlan.%d.%%parent", unit); +#endif + parentlen = sizeof(parentlen); + if (sysctlbyname(oid, parent, &parentlen, NULL, 0) >= 0 && + strncmp(parent, ifname, parentlen) == 0) + break; + } + if (unit == 10) + errx(1, "%s: cannot locate wlan sysctl node.", ifname); +#ifdef __linux__ + snprintf(oid, sizeof(oid), "net.wlan%d.debug", unit); +#else + snprintf(oid, sizeof(oid), "net.wlan.%d.debug", unit); #endif debuglen = sizeof(debug); if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) |