556-wpa_supplicant-support-Multi-AP-backhaul-STA-onboard.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. From 6c4c98db9420a3321bbf091cfc254de5eba4b404 Mon Sep 17 00:00:00 2001
  2. From: Davina Lu <[email protected]>
  3. Date: Tue, 15 Jan 2019 19:17:51 +0100
  4. Subject: [PATCH] wpa_supplicant: support Multi-AP backhaul STA onboarding
  5. The Wi-Fi Alliance Multi-AP Specification v1.0 allows onboarding of a
  6. backhaul STA through WPS. To enable this, the backhaul STA needs to add
  7. a Multi-AP IE to the WFA vendor extension element in the WSC M1 message
  8. that indicates it supports the Multi-AP backhaul STA role. The registrar
  9. (if it support Multi-AP onboarding) will respond to that with a WSC M8
  10. message that also contains the Multi-AP IE, and that contains the
  11. credentials for the backhaul SSID (which may be different from the SSID
  12. on which WPS is performed).
  13. Introduce a new parameter to wpas_wps_start_pbc() and allow it to be
  14. set via control interface's new multi_ap=1 parameter of WPS_PBC call.
  15. multi_ap_backhaul_sta is set to 1 in the automatically created SSID.
  16. Thus, if the AP does not support Multi-AP, association will fail and
  17. WPS will be terminated.
  18. Only wps_pbc is supported.
  19. The multi_ap argument is only added to the socket interface, not to the
  20. dbus interface.
  21. Signed-off-by: Davina Lu <[email protected]>
  22. Signed-off-by: Igor Mitsyanko <[email protected]>
  23. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
  24. Signed-off-by: Daniel Golle <[email protected]>
  25. ---
  26. v4: use argument to wps_pbc instead of a global configuration option
  27. (requested by Jouni)
  28. ---
  29. src/eap_peer/eap_wsc.c | 3 +++
  30. src/wps/wps.h | 6 ++++++
  31. src/wps/wps_enrollee.c | 6 +++++-
  32. wpa_supplicant/ctrl_iface.c | 5 ++++-
  33. wpa_supplicant/dbus/dbus_new_handlers_wps.c | 2 +-
  34. wpa_supplicant/dbus/dbus_old_handlers_wps.c | 4 ++--
  35. wpa_supplicant/events.c | 2 +-
  36. wpa_supplicant/p2p_supplicant.c | 2 +-
  37. wpa_supplicant/wps_supplicant.c | 9 +++++++--
  38. wpa_supplicant/wps_supplicant.h | 2 +-
  39. 10 files changed, 31 insertions(+), 10 deletions(-)
  40. --- a/src/eap_peer/eap_wsc.c
  41. +++ b/src/eap_peer/eap_wsc.c
  42. @@ -274,6 +274,9 @@ static void * eap_wsc_init(struct eap_sm
  43. cfg.pin, cfg.pin_len, 0);
  44. }
  45. + if (os_strstr(phase1, "multi_ap=1"))
  46. + wps->multi_ap_backhaul_sta = 1;
  47. +
  48. /* Use reduced client timeout for WPS to avoid long wait */
  49. if (sm->ClientTimeout > 30)
  50. sm->ClientTimeout = 30;
  51. --- a/src/wps/wps.h
  52. +++ b/src/wps/wps.h
  53. @@ -613,6 +613,12 @@ struct wps_context {
  54. int ap_setup_locked;
  55. /**
  56. + * multi_ap_backhaul_sta - Whether this is a Multi-AP backhaul STA
  57. + * enrollee
  58. + */
  59. + int multi_ap_backhaul_sta;
  60. +
  61. + /**
  62. * uuid - Own UUID
  63. */
  64. u8 uuid[16];
  65. --- a/src/wps/wps_enrollee.c
  66. +++ b/src/wps/wps_enrollee.c
  67. @@ -105,6 +105,7 @@ static struct wpabuf * wps_build_m1(stru
  68. {
  69. struct wpabuf *msg;
  70. u16 config_methods;
  71. + u8 multi_ap_backhaul_sta = 0;
  72. if (random_get_bytes(wps->nonce_e, WPS_NONCE_LEN) < 0)
  73. return NULL;
  74. @@ -134,6 +135,9 @@ static struct wpabuf * wps_build_m1(stru
  75. WPS_CONFIG_PHY_PUSHBUTTON);
  76. }
  77. + if (wps->wps->multi_ap_backhaul_sta)
  78. + multi_ap_backhaul_sta = MULTI_AP_BACKHAUL_STA;
  79. +
  80. if (wps_build_version(msg) ||
  81. wps_build_msg_type(msg, WPS_M1) ||
  82. wps_build_uuid_e(msg, wps->uuid_e) ||
  83. @@ -152,7 +156,7 @@ static struct wpabuf * wps_build_m1(stru
  84. wps_build_dev_password_id(msg, wps->dev_pw_id) ||
  85. wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||
  86. wps_build_os_version(&wps->wps->dev, msg) ||
  87. - wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
  88. + wps_build_wfa_ext(msg, 0, NULL, 0, multi_ap_backhaul_sta) ||
  89. wps_build_vendor_ext_m1(&wps->wps->dev, msg)) {
  90. wpabuf_free(msg);
  91. return NULL;
  92. --- a/wpa_supplicant/ctrl_iface.c
  93. +++ b/wpa_supplicant/ctrl_iface.c
  94. @@ -1167,6 +1167,7 @@ static int wpa_supplicant_ctrl_iface_wps
  95. #ifdef CONFIG_AP
  96. u8 *_p2p_dev_addr = NULL;
  97. #endif /* CONFIG_AP */
  98. + int multi_ap = 0;
  99. if (cmd == NULL || os_strcmp(cmd, "any") == 0) {
  100. _bssid = NULL;
  101. @@ -1184,6 +1185,8 @@ static int wpa_supplicant_ctrl_iface_wps
  102. wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PBC: invalid BSSID '%s'",
  103. cmd);
  104. return -1;
  105. + } else if (os_strncmp(cmd, "multi_ap=", 9) == 0) {
  106. + multi_ap = atoi(cmd + 9);
  107. }
  108. #ifdef CONFIG_AP
  109. @@ -1191,7 +1194,7 @@ static int wpa_supplicant_ctrl_iface_wps
  110. return wpa_supplicant_ap_wps_pbc(wpa_s, _bssid, _p2p_dev_addr);
  111. #endif /* CONFIG_AP */
  112. - return wpas_wps_start_pbc(wpa_s, _bssid, 0);
  113. + return wpas_wps_start_pbc(wpa_s, _bssid, 0, multi_ap);
  114. }
  115. --- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c
  116. +++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
  117. @@ -289,7 +289,7 @@ DBusMessage * wpas_dbus_handler_wps_star
  118. if (ret > 0)
  119. os_snprintf(npin, sizeof(npin), "%08d", ret);
  120. } else {
  121. - ret = wpas_wps_start_pbc(wpa_s, params.bssid, 0);
  122. + ret = wpas_wps_start_pbc(wpa_s, params.bssid, 0, 0);
  123. }
  124. if (ret < 0) {
  125. --- a/wpa_supplicant/dbus/dbus_old_handlers_wps.c
  126. +++ b/wpa_supplicant/dbus/dbus_old_handlers_wps.c
  127. @@ -37,9 +37,9 @@ DBusMessage * wpas_dbus_iface_wps_pbc(DB
  128. return wpas_dbus_new_invalid_opts_error(message, NULL);
  129. if (os_strcmp(arg_bssid, "any") == 0)
  130. - ret = wpas_wps_start_pbc(wpa_s, NULL, 0);
  131. + ret = wpas_wps_start_pbc(wpa_s, NULL, 0, 0);
  132. else if (!hwaddr_aton(arg_bssid, bssid))
  133. - ret = wpas_wps_start_pbc(wpa_s, bssid, 0);
  134. + ret = wpas_wps_start_pbc(wpa_s, bssid, 0, 0);
  135. else {
  136. return wpas_dbus_new_invalid_opts_error(message,
  137. "Invalid BSSID");
  138. --- a/wpa_supplicant/events.c
  139. +++ b/wpa_supplicant/events.c
  140. @@ -4816,7 +4816,7 @@ void supplicant_event(void *ctx, enum wp
  141. break;
  142. case EVENT_WPS_BUTTON_PUSHED:
  143. #ifdef CONFIG_WPS
  144. - wpas_wps_start_pbc(wpa_s, NULL, 0);
  145. + wpas_wps_start_pbc(wpa_s, NULL, 0, 0);
  146. #endif /* CONFIG_WPS */
  147. break;
  148. case EVENT_AVOID_FREQUENCIES:
  149. --- a/wpa_supplicant/p2p_supplicant.c
  150. +++ b/wpa_supplicant/p2p_supplicant.c
  151. @@ -1649,7 +1649,7 @@ static void wpas_start_wps_enrollee(stru
  152. wpa_supplicant_ap_deinit(wpa_s);
  153. wpas_copy_go_neg_results(wpa_s, res);
  154. if (res->wps_method == WPS_PBC) {
  155. - wpas_wps_start_pbc(wpa_s, res->peer_interface_addr, 1);
  156. + wpas_wps_start_pbc(wpa_s, res->peer_interface_addr, 1, 0);
  157. #ifdef CONFIG_WPS_NFC
  158. } else if (res->wps_method == WPS_NFC) {
  159. wpas_wps_start_nfc(wpa_s, res->peer_device_addr,
  160. --- a/wpa_supplicant/wps_supplicant.c
  161. +++ b/wpa_supplicant/wps_supplicant.c
  162. @@ -1137,9 +1137,10 @@ static void wpas_wps_reassoc(struct wpa_
  163. int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
  164. - int p2p_group)
  165. + int p2p_group, int multi_ap_backhaul_sta)
  166. {
  167. struct wpa_ssid *ssid;
  168. + char phase1[32];
  169. #ifdef CONFIG_AP
  170. if (wpa_s->ap_iface) {
  171. @@ -1177,10 +1178,14 @@ int wpas_wps_start_pbc(struct wpa_suppli
  172. }
  173. }
  174. #endif /* CONFIG_P2P */
  175. - if (wpa_config_set(ssid, "phase1", "\"pbc=1\"", 0) < 0)
  176. + if (os_snprintf(phase1, sizeof(phase1), "pbc=1%s",
  177. + multi_ap_backhaul_sta ? " multi_ap=1" : "") ||
  178. + wpa_config_set_quoted(ssid, "phase1", phase1) < 0)
  179. return -1;
  180. if (wpa_s->wps_fragment_size)
  181. ssid->eap.fragment_size = wpa_s->wps_fragment_size;
  182. + if (multi_ap_backhaul_sta)
  183. + ssid->multi_ap_backhaul_sta = 1;
  184. wpa_supplicant_wps_event(wpa_s, WPS_EV_PBC_ACTIVE, NULL);
  185. eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
  186. wpa_s, NULL);
  187. --- a/wpa_supplicant/wps_supplicant.h
  188. +++ b/wpa_supplicant/wps_supplicant.h
  189. @@ -30,7 +30,7 @@ void wpas_wps_deinit(struct wpa_supplica
  190. int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s);
  191. enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid);
  192. int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
  193. - int p2p_group);
  194. + int p2p_group, int multi_ap_backhaul_sta);
  195. int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
  196. const char *pin, int p2p_group, u16 dev_pw_id);
  197. void wpas_wps_pbc_overlap(struct wpa_supplicant *wpa_s);