2
0

453-ap_sta_support.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. --- a/wpa_supplicant/wpa_supplicant_i.h
  2. +++ b/wpa_supplicant/wpa_supplicant_i.h
  3. @@ -95,6 +95,8 @@ struct wpa_interface {
  4. * receiving of EAPOL frames from an additional interface.
  5. */
  6. const char *bridge_ifname;
  7. +
  8. + const char *hostapd_ctrl;
  9. };
  10. /**
  11. @@ -271,6 +273,8 @@ struct wpa_supplicant {
  12. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  13. char bridge_ifname[16];
  14. + struct wpa_ctrl *hostapd;
  15. +
  16. char *confname;
  17. struct wpa_config *conf;
  18. int countermeasures;
  19. --- a/wpa_supplicant/Makefile
  20. +++ b/wpa_supplicant/Makefile
  21. @@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
  22. CFLAGS += -I../src
  23. CFLAGS += -I../src/utils
  24. +ifdef MULTICALL
  25. +CFLAGS += -DMULTICALL
  26. +endif
  27. +
  28. -include .config
  29. -include $(if $(MULTICALL),../hostapd/.config)
  30. @@ -71,6 +75,10 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
  31. OBJS_c += ../src/utils/wpa_debug.o
  32. OBJS_c += ../src/utils/common.o
  33. +ifdef MULTICALL
  34. +OBJS += ../src/common/wpa_ctrl.o
  35. +endif
  36. +
  37. ifndef CONFIG_OS
  38. ifdef CONFIG_NATIVE_WINDOWS
  39. CONFIG_OS=win32
  40. --- a/wpa_supplicant/wpa_supplicant.c
  41. +++ b/wpa_supplicant/wpa_supplicant.c
  42. @@ -103,6 +103,55 @@ extern int wpa_debug_show_keys;
  43. extern int wpa_debug_timestamp;
  44. extern struct wpa_driver_ops *wpa_drivers[];
  45. +#ifdef MULTICALL
  46. +static int hostapd_stop(struct wpa_supplicant *wpa_s)
  47. +{
  48. + const char *cmd = "DOWN";
  49. + char buf[256];
  50. + int len = sizeof(buf);
  51. +
  52. + if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
  53. + wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
  54. + return -1;
  55. + }
  56. + return 0;
  57. +}
  58. +
  59. +static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
  60. +{
  61. + char *cmd = NULL;
  62. + char buf[256];
  63. + int len = sizeof(buf);
  64. + int channel, hw_mode;
  65. + int ret;
  66. +
  67. + if (!bss)
  68. + return;
  69. +
  70. + if (bss->freq < 4000) {
  71. + hw_mode = HOSTAPD_MODE_IEEE80211G;
  72. + channel = (bss->freq - 2407) / 5;
  73. + } else {
  74. + hw_mode = HOSTAPD_MODE_IEEE80211A;
  75. + channel = (bss->freq - 5000) / 5;
  76. + }
  77. +
  78. + if (asprintf(&cmd, "RELOAD channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
  79. + channel, hw_mode, !!bss->ht_capab) < 0) {
  80. + return -1;
  81. + }
  82. +
  83. + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
  84. + free(cmd);
  85. +
  86. + if (ret < 0) {
  87. + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
  88. + return -1;
  89. + }
  90. + return 0;
  91. +}
  92. +#endif
  93. +
  94. /* Configure default/group WEP keys for static WEP */
  95. int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
  96. {
  97. @@ -607,8 +656,16 @@ void wpa_supplicant_set_state(struct wpa
  98. #ifdef CONFIG_P2P
  99. wpas_p2p_completed(wpa_s);
  100. #endif /* CONFIG_P2P */
  101. +#ifdef MULTICALL
  102. + if (wpa_s->hostapd)
  103. + hostapd_reload(wpa_s, wpa_s->current_bss);
  104. +#endif
  105. } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
  106. state == WPA_ASSOCIATED) {
  107. +#ifdef MULTICALL
  108. + if (wpa_s->hostapd)
  109. + hostapd_stop(wpa_s);
  110. +#endif
  111. wpa_s->new_connection = 1;
  112. wpa_drv_set_operstate(wpa_s, 0);
  113. #ifndef IEEE8021X_EAPOL
  114. @@ -2522,6 +2579,21 @@ static int wpa_supplicant_init_iface(str
  115. os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
  116. sizeof(wpa_s->bridge_ifname));
  117. }
  118. +#ifdef MULTICALL
  119. + if (iface->hostapd_ctrl) {
  120. + char *cmd = "DOWN";
  121. + char buf[256];
  122. + int len = sizeof(buf);
  123. +
  124. + wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
  125. + if (!wpa_s->hostapd) {
  126. + wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
  127. + return -1;
  128. + }
  129. + if (hostapd_stop(wpa_s) < 0)
  130. + return -1;
  131. + }
  132. +#endif
  133. /* RSNA Supplicant Key Management - INITIALIZE */
  134. eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
  135. --- a/wpa_supplicant/bss.c
  136. +++ b/wpa_supplicant/bss.c
  137. @@ -11,6 +11,7 @@
  138. #include "utils/common.h"
  139. #include "utils/eloop.h"
  140. #include "common/ieee802_11_defs.h"
  141. +#include "common/ieee802_11_common.h"
  142. #include "drivers/driver.h"
  143. #include "wpa_supplicant_i.h"
  144. #include "config.h"
  145. @@ -75,6 +76,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
  146. static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
  147. {
  148. + struct ieee80211_ht_capabilities *capab;
  149. + struct ieee802_11_elems elems;
  150. os_time_t usec;
  151. dst->flags = src->flags;
  152. @@ -87,6 +90,12 @@ static void wpa_bss_copy_res(struct wpa_
  153. dst->level = src->level;
  154. dst->tsf = src->tsf;
  155. + memset(&elems, 0, sizeof(elems));
  156. + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
  157. + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
  158. + if (capab)
  159. + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
  160. +
  161. os_get_time(&dst->last_update);
  162. dst->last_update.sec -= src->age / 1000;
  163. usec = (src->age % 1000) * 1000;
  164. --- a/wpa_supplicant/bss.h
  165. +++ b/wpa_supplicant/bss.h
  166. @@ -51,6 +51,7 @@ struct wpa_bss {
  167. unsigned int flags;
  168. u8 bssid[ETH_ALEN];
  169. u8 ssid[32];
  170. + u16 ht_capab;
  171. size_t ssid_len;
  172. int freq;
  173. u16 beacon_int;
  174. --- a/wpa_supplicant/main.c
  175. +++ b/wpa_supplicant/main.c
  176. @@ -25,7 +25,7 @@ static void usage(void)
  177. "usage:\n"
  178. " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
  179. "[-g<global ctrl>] \\\n"
  180. - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
  181. + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
  182. "[-p<driver_param>] \\\n"
  183. " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
  184. "\\\n"
  185. @@ -67,6 +67,7 @@ static void usage(void)
  186. #endif /* CONFIG_DEBUG_LINUX_TRACING */
  187. printf(" -t = include timestamp in debug messages\n"
  188. " -h = show this help text\n"
  189. + " -H = connect to a hostapd instance to manage state changes\n"
  190. " -L = show license (BSD)\n"
  191. " -o = override driver parameter for new interfaces\n"
  192. " -O = override ctrl_interface parameter for new interfaces\n"
  193. @@ -144,7 +145,7 @@ int main(int argc, char *argv[])
  194. for (;;) {
  195. c = getopt(argc, argv,
  196. - "b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qsTtuvW");
  197. + "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuvW");
  198. if (c < 0)
  199. break;
  200. switch (c) {
  201. @@ -188,6 +189,9 @@ int main(int argc, char *argv[])
  202. usage();
  203. exitcode = 0;
  204. goto out;
  205. + case 'H':
  206. + iface->hostapd_ctrl = optarg;
  207. + break;
  208. case 'i':
  209. iface->ifname = optarg;
  210. break;