hostapd: support optional argument for the -v switch of hostapd and wpa_supplicant to query build features, e.g. hostapd -veap to test whether 802.11i support is compiled in

SVN-Revision: 29507
owl
Jo-Philipp Wich 2011-12-12 17:26:13 +00:00
parent d886c0aaed
commit 059d4bad00
2 changed files with 83 additions and 1 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd PKG_NAME:=hostapd
PKG_VERSION:=20111103 PKG_VERSION:=20111103
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_REV:=6caaae1e48da247b21b54ea6001646597e35d9b1 PKG_REV:=6caaae1e48da247b21b54ea6001646597e35d9b1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2

View File

@ -0,0 +1,82 @@
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -19,6 +19,7 @@
#include "utils/common.h"
#include "utils/eloop.h"
+#include "utils/build_features.h"
#include "crypto/random.h"
#include "crypto/tls.h"
#include "common/version.h"
@@ -574,7 +575,7 @@ int main(int argc, char *argv[])
wpa_supplicant_event = hostapd_wpa_event;
for (;;) {
- c = getopt(argc, argv, "Bde:f:hKP:tv");
+ c = getopt(argc, argv, "Bde:f:hKP:tv::");
if (c < 0)
break;
switch (c) {
@@ -606,6 +607,8 @@ int main(int argc, char *argv[])
wpa_debug_timestamp++;
break;
case 'v':
+ if (optarg)
+ exit(!has_feature(optarg));
show_version();
exit(1);
break;
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -18,6 +18,7 @@
#endif /* __linux__ */
#include "common.h"
+#include "build_features.h"
#include "wpa_supplicant_i.h"
#include "driver_i.h"
@@ -146,7 +147,7 @@ int main(int argc, char *argv[])
wpa_supplicant_fd_workaround();
for (;;) {
- c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qstuvW");
+ c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qstuv::W");
if (c < 0)
break;
switch (c) {
@@ -233,8 +234,12 @@ int main(int argc, char *argv[])
break;
#endif /* CONFIG_DBUS */
case 'v':
- printf("%s\n", wpa_supplicant_version);
- exitcode = 0;
+ if (optarg) {
+ exitcode = !has_feature(optarg);
+ } else {
+ printf("%s\n", wpa_supplicant_version);
+ exitcode = 0;
+ }
goto out;
case 'W':
params.wait_for_monitor++;
--- /dev/null
+++ b/src/utils/build_features.h
@@ -0,0 +1,17 @@
+#ifndef BUILD_FEATURES_H
+#define BUILD_FEATURES_H
+
+static inline int has_feature(const char *feat)
+{
+#ifdef IEEE8021X_EAPOL
+ if (!strcmp(feat, "eap"))
+ return 1;
+#endif
+#ifdef IEEE80211N
+ if (!strcmp(feat, "11n"))
+ return 1;
+#endif
+ return 0;
+}
+
+#endif /* BUILD_FEATURES_H */