modernize backfire 10.03 so it can be operational again
[openwrt-10.03/.git] / package / hostapd / patches / 900-indicate-features.patch
1 --- a/hostapd/main.c
2 +++ b/hostapd/main.c
3 @@ -19,6 +19,7 @@
4  
5  #include "utils/common.h"
6  #include "utils/eloop.h"
7 +#include "utils/build_features.h"
8  #include "crypto/random.h"
9  #include "crypto/tls.h"
10  #include "common/version.h"
11 @@ -574,7 +575,7 @@ int main(int argc, char *argv[])
12  
13         wpa_supplicant_event = hostapd_wpa_event;
14         for (;;) {
15 -               c = getopt(argc, argv, "Bde:f:hKP:tv");
16 +               c = getopt(argc, argv, "Bde:f:hKP:tv::");
17                 if (c < 0)
18                         break;
19                 switch (c) {
20 @@ -606,6 +607,8 @@ int main(int argc, char *argv[])
21                         wpa_debug_timestamp++;
22                         break;
23                 case 'v':
24 +                       if (optarg)
25 +                               exit(!has_feature(optarg));
26                         show_version();
27                         exit(1);
28                         break;
29 --- a/wpa_supplicant/main.c
30 +++ b/wpa_supplicant/main.c
31 @@ -18,6 +18,7 @@
32  #endif /* __linux__ */
33  
34  #include "common.h"
35 +#include "build_features.h"
36  #include "wpa_supplicant_i.h"
37  #include "driver_i.h"
38  
39 @@ -146,7 +147,7 @@ int main(int argc, char *argv[])
40         wpa_supplicant_fd_workaround();
41  
42         for (;;) {
43 -               c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qstuvW");
44 +               c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qstuv::W");
45                 if (c < 0)
46                         break;
47                 switch (c) {
48 @@ -233,8 +234,12 @@ int main(int argc, char *argv[])
49                         break;
50  #endif /* CONFIG_DBUS */
51                 case 'v':
52 -                       printf("%s\n", wpa_supplicant_version);
53 -                       exitcode = 0;
54 +                       if (optarg) {
55 +                               exitcode = !has_feature(optarg);
56 +                       } else {
57 +                               printf("%s\n", wpa_supplicant_version);
58 +                               exitcode = 0;
59 +                       }
60                         goto out;
61                 case 'W':
62                         params.wait_for_monitor++;
63 --- /dev/null
64 +++ b/src/utils/build_features.h
65 @@ -0,0 +1,17 @@
66 +#ifndef BUILD_FEATURES_H
67 +#define BUILD_FEATURES_H
68 +
69 +static inline int has_feature(const char *feat)
70 +{
71 +#ifdef IEEE8021X_EAPOL
72 +       if (!strcmp(feat, "eap"))
73 +               return 1;
74 +#endif
75 +#ifdef IEEE80211N
76 +       if (!strcmp(feat, "11n"))
77 +               return 1;
78 +#endif
79 +       return 0;
80 +}
81 +
82 +#endif /* BUILD_FEATURES_H */