553-ap_sta_support.patch 5.9 KB

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