Date: Tue, 19 Feb 2008 16:47:35 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 135727 for review Message-ID: <200802191647.m1JGlZsL076113@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=135727 Change 135727 by sam@sam_ebb on 2008/02/19 16:47:17 switch over to vap setup Affected files ... .. //depot/projects/vap/usr.sbin/wlandebug/wlandebug.c#4 edit Differences ... ==== //depot/projects/vap/usr.sbin/wlandebug/wlandebug.c#4 (text+ko) ==== @@ -156,47 +156,44 @@ exit(-1); } +static void +setoid(char oid[], size_t oidlen, const char *wlan) +{ +#ifdef __linux__ + snprintf(oid, oidlen, "net.%s.debug", wlan); +#elif __FreeBSD__ + snprintf(oid, oidlen, "net.wlan.%s.debug", wlan+4); +#elif __NetBSD__ + snprintf(oid, oidlen, "net.link.ieee80211.%s.debug", wlan+4); +#else +#error "No support for this system" +#endif +} + int main(int argc, char *argv[]) { - const char *ifname = "ath0"; const char *cp, *tp; const char *sep; int op, i, unit; u_int32_t debug, ndebug; size_t debuglen, parentlen; - char oid[256], parent[256]; + char oid[256]; progname = argv[0]; + setoid(oid, sizeof(oid), "wlan0"); if (argc > 1) { if (strcmp(argv[1], "-i") == 0) { if (argc < 2) errx(1, "missing interface name for -i option"); - ifname = argv[2]; + if (strncmp(argv[2], "wlan", 4) != 0) + errx(1, "expecting a wlan interface name"); + setoid(oid, sizeof(oid), argv[2]); 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%d.%%parent", unit); -#else - snprintf(oid, sizeof(oid), "net.wlan.%d.%%parent", unit); -#endif - parentlen = sizeof(parent); - if (sysctlbyname(oid, parent, &parentlen, NULL, 0) < 0) - continue; - if (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) err(1, "sysctl-get(%s)", oid);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802191647.m1JGlZsL076113>