diff options
author | Sam Leffler <sam@FreeBSD.org> | 2005-08-03 04:25:04 +0000 |
---|---|---|
committer | Sam Leffler <sam@FreeBSD.org> | 2005-08-03 04:25:04 +0000 |
commit | f0abdaaa6410898e40d9ce4b833a88e4ab90b105 (patch) | |
tree | 0d0825c7865f0f2a2d3b6bf02454f6690b7a118b /tools | |
parent | bb2fd058ceec89ea67ceafb0dcf43a6ff0a3fbab (diff) | |
download | src-f0abdaaa6410898e40d9ce4b833a88e4ab90b105.tar.gz src-f0abdaaa6410898e40d9ce4b833a88e4ab90b105.zip |
simplify use with non-ath devices; search the wlan sysctl nodes to
locate the right one for the specified interface
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=148665
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 79feabfafcbf..0750e676b26d 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) |