From 82036c412c1971a65b5aea4d35557981ddc2f500 Mon Sep 17 00:00:00 2001 From: thompsa Date: Mon, 19 May 2008 17:49:57 +0000 Subject: Allow wlandebug to set the default debug level which is inherited when vaps are created. --- usr.sbin/wlandebug/wlandebug.8 | 6 +++++- usr.sbin/wlandebug/wlandebug.c | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'usr.sbin/wlandebug') diff --git a/usr.sbin/wlandebug/wlandebug.8 b/usr.sbin/wlandebug/wlandebug.8 index 2e105c3..8450bf7 100644 --- a/usr.sbin/wlandebug/wlandebug.8 +++ b/usr.sbin/wlandebug/wlandebug.8 @@ -32,7 +32,7 @@ .Nd "set/query 802.11 wireless debugging messages" .Sh SYNOPSIS .Nm -.Op Fl i Ar ifnet +.Op Fl d | Fl i Ar ifnet .Op Fl flag|+flag Ar ... .Sh DESCRIPTION The @@ -46,6 +46,10 @@ Running without any options will display the current messages enabled for the specified network interface (by default, ``ath0'). +The default debugging level for new interfaces can be set +by specifying the +.Ar -d +option. When run as the super-user .Nm can be used to enable and/or disable debugging messages. diff --git a/usr.sbin/wlandebug/wlandebug.c b/usr.sbin/wlandebug/wlandebug.c index 71f552e..a054393 100644 --- a/usr.sbin/wlandebug/wlandebug.c +++ b/usr.sbin/wlandebug/wlandebug.c @@ -149,7 +149,7 @@ usage(void) { int i; - fprintf(stderr, "usage: %s [-i device] [flags]\n", progname); + fprintf(stderr, "usage: %s [-d | -i device] [flags]\n", progname); fprintf(stderr, "where flags are:\n"); for (i = 0; i < N(flags); i++) printf("%s\n", flags[i].name); @@ -160,11 +160,18 @@ static void setoid(char oid[], size_t oidlen, const char *wlan) { #ifdef __linux__ - snprintf(oid, oidlen, "net.%s.debug", wlan); + if (wlan) + snprintf(oid, oidlen, "net.%s.debug", wlan); #elif __FreeBSD__ - snprintf(oid, oidlen, "net.wlan.%s.debug", wlan+4); + if (wlan) + snprintf(oid, oidlen, "net.wlan.%s.debug", wlan+4); + else + snprintf(oid, oidlen, "net.wlan.debug"); #elif __NetBSD__ - snprintf(oid, oidlen, "net.link.ieee80211.%s.debug", wlan+4); + if (wlan) + snprintf(oid, oidlen, "net.link.ieee80211.%s.debug", wlan+4); + else + snprintf(oid, oidlen, "net.link.ieee80211.debug"); #else #error "No support for this system" #endif @@ -183,7 +190,10 @@ main(int argc, char *argv[]) progname = argv[0]; setoid(oid, sizeof(oid), "wlan0"); if (argc > 1) { - if (strcmp(argv[1], "-i") == 0) { + if (strcmp(argv[1], "-d") == 0) { + setoid(oid, sizeof(oid), NULL); + argc -= 1, argv += 1; + } else if (strcmp(argv[1], "-i") == 0) { if (argc < 2) errx(1, "missing interface name for -i option"); if (strncmp(argv[2], "wlan", 4) != 0) -- cgit v1.1