diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2013-04-15 15:00:16 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2013-04-15 15:00:16 +0000 |
commit | e8b3e8e7f2fccbbb089e9ff56ffc8443f79e4c00 (patch) | |
tree | 1e61d63dd3273d9937fbcffa0d501fbfeb84f5da /package | |
parent | c916e833c023030bd21dbee8ae934742e8408f9f (diff) | |
download | upstream-e8b3e8e7f2fccbbb089e9ff56ffc8443f79e4c00.tar.gz upstream-e8b3e8e7f2fccbbb089e9ff56ffc8443f79e4c00.tar.bz2 upstream-e8b3e8e7f2fccbbb089e9ff56ffc8443f79e4c00.zip |
iwinfo: print info of all existing wireless ifaces when cli is called without arguments
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36339 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r-- | package/network/utils/iwinfo/Makefile | 2 | ||||
-rw-r--r-- | package/network/utils/iwinfo/src/iwinfo_cli.c | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/package/network/utils/iwinfo/Makefile b/package/network/utils/iwinfo/Makefile index 23f3f38cb4..8b103ebb57 100644 --- a/package/network/utils/iwinfo/Makefile +++ b/package/network/utils/iwinfo/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libiwinfo -PKG_RELEASE:=40 +PKG_RELEASE:=41 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_CONFIG_DEPENDS := \ diff --git a/package/network/utils/iwinfo/src/iwinfo_cli.c b/package/network/utils/iwinfo/src/iwinfo_cli.c index 7ec5aef95c..8da216a6ef 100644 --- a/package/network/utils/iwinfo/src/iwinfo_cli.c +++ b/package/network/utils/iwinfo/src/iwinfo_cli.c @@ -17,6 +17,7 @@ */ #include <stdio.h> +#include <glob.h> #include "iwinfo.h" @@ -735,9 +736,11 @@ static void print_countrylist(const struct iwinfo_ops *iw, const char *ifname) int main(int argc, char **argv) { int i; + char *p; const struct iwinfo_ops *iw; + glob_t globbuf; - if (argc < 3) + if (argc > 1 && argc < 3) { fprintf(stderr, "Usage:\n" @@ -752,6 +755,30 @@ int main(int argc, char **argv) return 1; } + if (argc == 1) + { + glob("/sys/class/net/*", 0, NULL, &globbuf); + + for (i = 0; i < globbuf.gl_pathc; i++) + { + p = strrchr(globbuf.gl_pathv[i], '/'); + + if (!p) + continue; + + iw = iwinfo_backend(++p); + + if (!iw) + continue; + + print_info(iw, p); + printf("\n"); + } + + globfree(&globbuf); + return 0; + } + iw = iwinfo_backend(argv[1]); if (!iw) |