Lines Matching refs:wpa_s
55 static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s);
59 wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
61 static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s);
63 static int wpas_p2p_join(struct wpa_supplicant *wpa_s, const u8 *iface_addr,
67 static int wpas_p2p_create_iface(struct wpa_supplicant *wpa_s);
68 static void wpas_p2p_cross_connect_setup(struct wpa_supplicant *wpa_s);
70 static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s);
73 static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s)
77 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
89 static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
94 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
102 if (p2p_scan_res_handler(wpa_s->global->p2p, bss->bssid,
109 p2p_scan_res_handled(wpa_s->global->p2p);
117 struct wpa_supplicant *wpa_s = ctx;
125 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
135 wpa_s->wps->dev.p2p = 1;
136 wps_ie = wps_build_probe_req_ie(0, &wpa_s->wps->dev, wpa_s->wps->uuid,
142 ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p);
151 p2p_scan_ie(wpa_s->global->p2p, ies, dev_id);
174 was_in_p2p_scan = wpa_s->scan_res_handler == wpas_p2p_scan_res_handler;
175 wpa_s->scan_res_handler = wpas_p2p_scan_res_handler;
176 ret = wpa_drv_scan(wpa_s, ¶ms);
181 wpa_s->scan_res_handler = NULL;
183 if (wpa_s->scanning || was_in_p2p_scan || wpas_global_scan_in_progress(wpa_s)) {
185 if (wpa_s->scanning || was_in_p2p_scan) {
187 wpa_s->p2p_cb_on_scan_complete = 1;
211 static struct wpa_supplicant * wpas_get_p2p_group(struct wpa_supplicant *wpa_s,
217 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
218 for (s = wpa_s->conf->ssid; s; s = s->next) {
224 s != wpa_s->current_ssid)
228 return wpa_s;
236 static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s)
242 eloop_cancel_timeout(wpas_p2p_group_idle_timeout, wpa_s, NULL);
244 ssid = wpa_s->current_ssid;
250 ssid = wpa_s->conf->ssid;
259 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO)
261 else if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT ||
263 wpa_s->reassociate = 0;
264 wpa_s->disconnected = 1;
265 wpa_supplicant_deauthenticate(wpa_s,
270 if (wpa_s->cross_connect_in_use) {
271 wpa_s->cross_connect_in_use = 0;
272 wpa_msg(wpa_s->parent, MSG_INFO,
274 wpa_s->ifname, wpa_s->cross_connect_uplink);
276 switch (wpa_s->removal_reason) {
295 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_REMOVED "%s %s%s",
296 wpa_s->ifname, gtype, reason);
299 wpas_notify_p2p_group_removed(wpa_s, ssid, gtype);
301 if (wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE) {
306 wpa_s->ifname);
307 global = wpa_s->global;
308 ifname = os_strdup(wpa_s->ifname);
309 type = wpas_p2p_if_type(wpa_s->p2p_group_interface);
310 wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0);
311 wpa_s = global->ifaces;
312 if (wpa_s && ifname)
313 wpa_drv_if_remove(wpa_s, type, ifname);
323 if (ssid == wpa_s->current_ssid) {
324 wpa_sm_set_config(wpa_s->wpa, NULL);
325 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
326 wpa_s->current_ssid = NULL;
337 wpa_config_remove_network(wpa_s->conf, id);
338 wpa_supplicant_clear_status(wpa_s);
339 wpa_supplicant_cancel_sched_scan(wpa_s);
344 wpa_supplicant_ap_deinit(wpa_s);
348 static int wpas_p2p_persistent_group(struct wpa_supplicant *wpa_s,
358 if (wpa_s->go_params)
359 bssid = wpa_s->go_params->peer_interface_addr;
361 bssid = wpa_s->bssid;
363 bss = wpa_bss_get(wpa_s, bssid, ssid, ssid_len);
366 if (p2p_get_interface_addr(wpa_s->global->p2p, bssid,
368 bss = wpa_bss_get(wpa_s, iface_addr, ssid, ssid_len);
410 static int wpas_p2p_store_persistent_group(struct wpa_supplicant *wpa_s,
419 for (s = wpa_s->conf->ssid; s; s = s->next) {
439 s = wpa_config_add_network(wpa_s->conf);
451 wpas_notify_persistent_group_added(wpa_s, s);
486 if (changed && wpa_s->conf->update_config &&
487 wpa_config_write(wpa_s->confname, wpa_s->conf)) {
496 static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
503 ssid = wpa_s->current_ssid;
508 for (s = wpa_s->parent->conf->ssid; s; s = s->next) {
535 if (wpa_s->parent->conf->update_config &&
536 wpa_config_write(wpa_s->parent->confname, wpa_s->parent->conf))
542 static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
553 * This callback is likely called for the main interface. Update wpa_s
557 if (wpa_s->global->p2p_group_formation)
558 wpa_s = wpa_s->global->p2p_group_formation;
559 wpa_s->global->p2p_group_formation = NULL;
560 wpa_s->p2p_in_provisioning = 0;
563 wpa_msg(wpa_s->parent, MSG_INFO,
565 wpas_p2p_group_delete(wpa_s);
569 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_FORMATION_SUCCESS);
571 ssid = wpa_s->current_ssid;
574 p2p_group_notif_formation_done(wpa_s->p2p_group);
575 wpa_supplicant_ap_mac_addr_filter(wpa_s, NULL);
584 os_memcpy(go_dev_addr, wpa_s->global->p2p_dev_addr,
587 persistent = wpas_p2p_persistent_group(wpa_s,
593 client = wpa_s->p2p_group_interface ==
598 wpa_s->show_group_started = 0;
605 wpa_s
609 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_STARTED
612 wpa_s->ifname, ssid_txt, ssid->frequency, psk,
615 wpas_p2p_cross_connect_setup(wpa_s);
616 wpas_p2p_set_group_idle_timeout(wpa_s);
618 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_STARTED
621 wpa_s->ifname, ssid_txt, ssid ? ssid->frequency : 0,
625 wpas_p2p_cross_connect_setup(wpa_s);
626 wpas_p2p_set_group_idle_timeout(wpa_s);
630 network_id = wpas_p2p_store_persistent_group(wpa_s->parent,
635 wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 0);
639 static void wpas_p2p_send_action_tx_status(struct wpa_supplicant *wpa_s,
649 if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled)
651 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
666 p2p_send_action_cb(wpa_s->global->p2p, freq, dst, src, bssid, res);
669 wpa_s->pending_pd_before_join &&
670 (os_memcmp(dst, wpa_s->pending_join_dev_addr, ETH_ALEN) == 0 ||
671 os_memcmp(dst, wpa_s->pending_join_iface_addr, ETH_ALEN) == 0)) {
672 wpa_s->pending_pd_before_join = 0;
676 wpas_p2p_join_start(wpa_s);
685 struct wpa_supplicant *wpa_s = ctx;
686 return offchannel_send_action(wpa_s, freq, dst, src, bssid, buf, len,
694 struct wpa_supplicant *wpa_s = ctx;
695 offchannel_send_action_done(wpa_s);
699 static int wpas_copy_go_neg_results(struct wpa_supplicant *wpa_s,
702 if (wpa_s->go_params == NULL) {
703 wpa_s->go_params = os_malloc(sizeof(*params));
704 if (wpa_s->go_params == NULL)
707 os_memcpy(wpa_s->go_params, params, sizeof(*params));
712 static void wpas_start_wps_enrollee(struct wpa_supplicant *wpa_s,
719 wpa_supplicant_ap_deinit(wpa_s);
720 wpas_copy_go_neg_results(wpa_s, res);
722 wpas_wps_start_pbc(wpa_s, res->peer_interface_addr, 1);
725 if (wpa_s->p2p_wps_method == WPS_PIN_KEYPAD)
727 wpas_wps_start_pin(wpa_s, res->peer_interface_addr,
728 wpa_s->p2p_pin, 1, dev_pw_id);
735 struct wpa_supplicant *wpa_s = ctx;
740 ssid = wpa_s->current_ssid;
743 if (wpa_s->global->p2p_group_formation == wpa_s)
744 wpa_s->global->p2p_group_formation = NULL;
745 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_STARTED
748 wpa_s->ifname,
752 MAC2STR(wpa_s->global->p2p_dev_addr),
757 wpa_s->parent, ssid,
758 wpa_s->global->p2p_dev_addr);
761 wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 0);
762 wpas_p2p_cross_connect_setup(wpa_s);
763 wpas_p2p_set_group_idle_timeout(wpa_s);
768 if (wpa_supplicant_ap_mac_addr_filter(wpa_s,
775 wpa_supplicant_ap_wps_pbc(wpa_s, params->peer_interface_addr,
777 else if (wpa_s->p2p_pin[0])
778 wpa_supplicant_ap_wps_pin(wpa_s, params->peer_interface_addr,
779 wpa_s->p2p_pin, NULL, 0);
780 os_free(wpa_s->go_params);
781 wpa_s->go_params = NULL;
785 static void wpas_start_wps_go(struct wpa_supplicant *wpa_s,
791 if (wpas_copy_go_neg_results(wpa_s, params) < 0)
794 ssid = wpa_config_add_network(wpa_s->conf);
798 wpa_s->show_group_started = 0;
818 wpa_s->ap_configured_cb = p2p_go_configured;
819 wpa_s->ap_configured_cb_ctx = wpa_s;
820 wpa_s->ap_configured_cb_data = wpa_s->go_params;
821 wpa_s->connect_without_scan = ssid;
822 wpa_s->reassociate = 1;
823 wpa_s->disconnected = 0;
824 wpa_supplicant_req_scan(wpa_s, 0, 0);
857 static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
862 if (wpa_s->pending_interface_name[0]) {
865 if (is_zero_ether_addr(wpa_s->pending_interface_addr)) {
868 wpa_s->pending_interface_name);
874 os_snprintf(ifname, sizeof(ifname), "p2p-%s-%d", wpa_s->ifname,
875 wpa_s->p2p_group_idx);
877 os_strlen(wpa_s->ifname) < IFNAMSIZ) {
880 wpa_s->p2p_group_idx);
886 wpa_s->p2p_group_idx++;
888 wpa_s->pending_interface_type = type;
889 if (wpa_drv_if_add(wpa_s, type, ifname, NULL, NULL, force_ifname,
890 wpa_s->pending_interface_addr, NULL) < 0) {
899 os_strlcpy(wpa_s->pending_interface_name, force_ifname,
900 sizeof(wpa_s->pending_interface_name));
902 os_strlcpy(wpa_s->pending_interface_name, ifname,
903 sizeof(wpa_s->pending_interface_name));
905 MACSTR, wpa_s->pending_interface_name,
906 MAC2STR(wpa_s->pending_interface_addr));
913 struct wpa_supplicant *wpa_s)
915 if (!wpa_s->pending_interface_name[0] ||
916 is_zero_ether_addr(wpa_s->pending_interface_addr))
920 wpa_s->pending_interface_name);
921 wpa_drv_if_remove(wpa_s, wpa_s->pending_interface_type,
922 wpa_s->pending_interface_name);
923 os_memset(wpa_s->pending_interface_addr, 0, ETH_ALEN);
924 wpa_s->pending_interface_name[0] = '\0';
929 wpas_p2p_init_group_interface(struct wpa_supplicant *wpa_s, int go)
934 if (!wpa_s->pending_interface_name[0]) {
936 if (!wpas_p2p_create_iface(wpa_s))
943 if (wpas_p2p_add_group_interface(wpa_s, go ? WPA_IF_P2P_GO :
949 iface.ifname = wpa_s->pending_interface_name;
950 iface.driver = wpa_s->driver->name;
951 iface.ctrl_interface = wpa_s->conf->ctrl_interface;
952 iface.driver_param = wpa_s->conf->driver_param;
953 group_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface);
959 wpa_s->pending_interface_name[0] = '\0';
960 group_wpa_s->parent = wpa_s;
963 wpa_s->global->p2p_group_formation = group_wpa_s;
965 wpas_p2p_clone_config(group_wpa_s, wpa_s);
974 struct wpa_supplicant *wpa_s = eloop_ctx;
976 if (wpa_s->global->p2p)
977 p2p_group_formation_failed(wpa_s->global->p2p);
978 else if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
979 wpa_drv_p2p_group_formation_failed(wpa_s);
980 wpas_group_formation_completed(wpa_s, 0);
986 struct wpa_supplicant *wpa_s = ctx;
988 if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) {
989 wpa_drv_cancel_remain_on_channel(wpa_s);
990 wpa_s->off_channel_freq = 0;
991 wpa_s->roc_waiting_drv_freq = 0;
995 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_GO_NEG_FAILURE "status=%d",
997 wpas_notify_p2p_go_neg_completed(wpa_s, res);
998 wpas_p2p_remove_pending_group_interface(wpa_s);
1002 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_GO_NEG_SUCCESS);
1003 wpas_notify_p2p_go_neg_completed(wpa_s, res);
1005 if (wpa_s->create_p2p_iface) {
1007 wpas_p2p_init_group_interface(wpa_s, res->role_go);
1009 wpas_p2p_remove_pending_group_interface(wpa_s);
1012 if (group_wpa_s != wpa_s) {
1013 os_memcpy(group_wpa_s->p2p_pin, wpa_s->p2p_pin,
1015 group_wpa_s->p2p_wps_method = wpa_s->p2p_wps_method;
1017 os_memset(wpa_s->pending_interface_addr, 0, ETH_ALEN);
1018 wpa_s->pending_interface_name[0] = '\0';
1026 wpa_s->p2p_in_provisioning = 1;
1027 wpa_s->global->p2p_group_formation = wpa_s;
1030 wpas_start_wps_go(wpa_s, res, 1);
1035 wpa_s->p2p_long_listen = 0;
1036 eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
1038 eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s, NULL);
1041 wpas_p2p_group_formation_timeout, wpa_s, NULL);
1047 struct wpa_supplicant *wpa_s = ctx;
1048 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_GO_NEG_REQUEST MACSTR
1051 wpas_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
1060 struct wpa_supplicant *wpa_s = ctx;
1063 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_FOUND MACSTR
1080 struct wpa_supplicant *wpa_s = ctx;
1082 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_LOST
1085 wpas_notify_p2p_device_lost(wpa_s, dev_addr);
1093 struct wpa_supplicant *wpa_s = ctx;
1095 wpa_drv_set_ap_wps_ie(wpa_s, NULL, probe_resp_ie, NULL);
1097 if (wpa_drv_probe_req_report(wpa_s, 1) < 0) {
1103 wpa_s->pending_listen_freq = freq;
1104 wpa_s->pending_listen_duration = duration;
1106 if (wpa_drv_remain_on_channel(wpa_s, freq, duration) < 0) {
1110 wpa_s->pending_listen_freq = 0;
1113 wpa_s->off_channel_freq = 0;
1114 wpa_s->roc_waiting_drv_freq = freq;
1122 struct wpa_supplicant *wpa_s = ctx;
1123 if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) {
1124 wpa_drv_cancel_remain_on_channel(wpa_s);
1125 wpa_s->off_channel_freq = 0;
1126 wpa_s->roc_waiting_drv_freq = 0;
1128 wpa_drv_set_ap_wps_ie(wpa_s, NULL, NULL, NULL);
1129 wpa_drv_probe_req_report(wpa_s, 0);
1135 struct wpa_supplicant *wpa_s = ctx;
1136 return wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1);
1141 wpas_p2p_service_get_bonjour(struct wpa_supplicant *wpa_s,
1148 dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
1160 wpas_p2p_service_get_upnp(struct wpa_supplicant *wpa_s, u8 version,
1165 dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
1194 static void wpas_sd_all_bonjour(struct wpa_supplicant *wpa_s,
1202 if (dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
1207 dl_list_for_each(bsrv, &wpa_s->global->p2p_srv_bonjour,
1230 static void wpas_sd_req_bonjour(struct wpa_supplicant *wpa_s,
1240 if (dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
1248 wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
1260 bsrv = wpas_p2p_service_get_bonjour(wpa_s, &buf);
1288 static void wpas_sd_all_upnp(struct wpa_supplicant *wpa_s,
1296 if (dl_list_empty(&wpa_s->global->p2p_srv_upnp)) {
1301 dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
1324 static void wpas_sd_req_upnp(struct wpa_supplicant *wpa_s,
1337 if (dl_list_empty(&wpa_s->global->p2p_srv_upnp)) {
1345 wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
1364 dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
1408 struct wpa_supplicant *wpa_s = ctx;
1424 wpa_msg_ctrl(wpa_s, MSG_INFO, P2P_EVENT_SERV_DISC_REQ "%d "
1431 if (wpa_s->p2p_sd_over_ctrl_iface) {
1432 wpas_notify_p2p_sd_request(wpa_s, freq, sa, dialog_token,
1464 if (wpa_s->force_long_sd) {
1467 wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
1468 wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
1476 if (dl_list_empty(&wpa_s->global->p2p_srv_upnp) &&
1477 dl_list_empty(&wpa_s->global->p2p_srv_bonjour)) {
1485 wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
1486 wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
1489 wpas_sd_req_bonjour(wpa_s, resp, srv_trans_id,
1493 wpas_sd_req_upnp(wpa_s, resp, srv_trans_id,
1508 wpas_notify_p2p_sd_request(wpa_s, freq, sa, dialog_token,
1511 wpas_p2p_sd_response(wpa_s, freq, sa, dialog_token, resp);
1520 struct wpa_supplicant *wpa_s = ctx;
1532 wpa_msg_ctrl(wpa_s, MSG_INFO,
1542 wpa_msg_ctrl(wpa_s, MSG_INFO,
1578 wpas_notify_p2p_sd_response(wpa_s, sa, update_indic, tlvs, tlvs_len);
1582 u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
1585 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
1586 return wpa_drv_p2p_sd_request(wpa_s, dst, tlvs);
1587 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
1589 return (uintptr_t) p2p_sd_request(wpa_s->global->p2p, dst, tlvs);
1593 u64 wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
1607 ret = wpas_p2p_sd_request(wpa_s, dst, tlvs);
1613 int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, u64 req)
1615 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
1616 return wpa_drv_p2p_sd_cancel_request(wpa_s, req);
1617 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
1619 return p2p_sd_cancel_request(wpa_s->global->p2p,
1624 void wpas_p2p_sd_response(struct wpa_supplicant *wpa_s, int freq,
1628 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
1629 wpa_drv_p2p_sd_response(wpa_s, freq, dst, dialog_token,
1633 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
1635 p2p_sd_response(wpa_s->global->p2p, freq, dst, dialog_token,
1640 void wpas_p2p_sd_service_update(struct wpa_supplicant *wpa_s)
1642 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
1643 wpa_drv_p2p_service_update(wpa_s);
1646 if (wpa_s->global->p2p)
1647 p2p_sd_service_update(wpa_s->global->p2p);
1668 void wpas_p2p_service_flush(struct wpa_supplicant *wpa_s)
1673 dl_list_for_each_safe(bsrv, bn, &wpa_s->global->p2p_srv_bonjour,
1677 dl_list_for_each_safe(usrv, un, &wpa_s->global->p2p_srv_upnp,
1681 wpas_p2p_sd_service_update(wpa_s);
1685 int wpas_p2p_service_add_bonjour(struct wpa_supplicant *wpa_s,
1690 bsrv = wpas_p2p_service_get_bonjour(wpa_s, query);
1703 dl_list_add(&wpa_s->global->p2p_srv_bonjour, &bsrv->list);
1705 wpas_p2p_sd_service_update(wpa_s);
1710 int wpas_p2p_service_del_bonjour(struct wpa_supplicant *wpa_s,
1715 bsrv = wpas_p2p_service_get_bonjour(wpa_s, query);
1719 wpas_p2p_sd_service_update(wpa_s);
1724 int wpas_p2p_service_add_upnp(struct wpa_supplicant *wpa_s, u8 version,
1729 if (wpas_p2p_service_get_upnp(wpa_s, version, service))
1740 dl_list_add(&wpa_s->global->p2p_srv_upnp, &usrv->list);
1742 wpas_p2p_sd_service_update(wpa_s);
1747 int wpas_p2p_service_del_upnp(struct wpa_supplicant *wpa_s, u8 version,
1752 usrv = wpas_p2p_service_get_upnp(wpa_s, version, service);
1756 wpas_p2p_sd_service_update(wpa_s);
1761 static void wpas_prov_disc_local_display(struct wpa_supplicant *wpa_s,
1765 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_SHOW_PIN MACSTR " %08d%s",
1770 static void wpas_prov_disc_local_keypad(struct wpa_supplicant *wpa_s,
1773 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_ENTER_PIN MACSTR "%s",
1784 struct wpa_supplicant *wpa_s = ctx;
1792 for (group = wpa_s->global->ifaces; group; group = group->next)
1821 wpas_prov_disc_local_display(wpa_s, peer, params,
1824 wpas_prov_disc_local_keypad(wpa_s, peer, params);
1826 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_PBC_REQ MACSTR
1829 wpas_notify_p2p_provision_discovery(wpa_s, peer, 1 /* request */,
1837 struct wpa_supplicant *wpa_s = ctx;
1840 if (wpa_s->pending_pd_before_join &&
1841 (os_memcmp(peer, wpa_s->pending_join_dev_addr, ETH_ALEN) == 0 ||
1842 os_memcmp(peer, wpa_s->pending_join_iface_addr, ETH_ALEN) == 0)) {
1843 wpa_s->pending_pd_before_join = 0;
1846 wpas_p2p_join_start(wpa_s);
1851 wpas_prov_disc_local_keypad(wpa_s, peer, "");
1854 wpas_prov_disc_local_display(wpa_s, peer, "", generated_pin);
1856 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_PBC_RESP MACSTR,
1859 wpas_notify_p2p_provision_discovery(wpa_s, peer, 0 /* response */,
1868 struct wpa_supplicant *wpa_s = ctx;
1870 wpas_notify_p2p_provision_discovery(wpa_s, peer, 0 /* response */,
1880 struct wpa_supplicant *wpa_s = ctx;
1889 if (!is_zero_ether_addr(wpa_s->p2p_auth_invite) &&
1890 (os_memcmp(go_dev_addr, wpa_s->p2p_auth_invite, ETH_ALEN)
1892 os_memcmp(sa, wpa_s->p2p_auth_invite, ETH_ALEN) == 0)) {
1904 grp = wpas_get_p2p_group(wpa_s, ssid, ssid_len, go);
1913 if (!wpa_s->conf->persistent_reconnect)
1916 for (s = wpa_s->conf->ssid; s; s = s->next) {
1931 if (s->mode == WPAS_MODE_P2P_GO && !wpas_p2p_create_iface(wpa_s)) {
1933 if (wpa_s->wpa_state >= WPA_AUTHENTICATING) {
1939 os_memcpy(group_bssid, wpa_s->own_addr, ETH_ALEN);
1942 if (wpas_p2p_add_group_interface(wpa_s, WPA_IF_P2P_GO) < 0)
1948 os_memcpy(group_bssid, wpa_s->pending_interface_addr,
1953 if (wpa_s->current_ssid && wpa_drv_get_bssid(wpa_s, cur_bssid) == 0 &&
1954 wpa_s->assoc_freq) {
1957 *force_freq = wpa_s->assoc_freq;
1960 res = wpa_drv_shared_freq(wpa_s);
1977 struct wpa_supplicant *wpa_s = ctx;
1980 for (s = wpa_s->conf->ssid; s; s = s->next) {
1993 wpa_s, s, s->mode == WPAS_MODE_P2P_GO, 0);
1995 wpas_p2p_join(wpa_s, bssid, go_dev_addr,
1996 wpa_s->p2p_wps_method);
2009 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_INVITATION_RECEIVED
2015 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_INVITATION_RECEIVED
2023 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_INVITATION_RECEIVED "sa=" MACSTR
2030 struct wpa_supplicant *wpa_s = ctx;
2034 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_INVITATION_RESULT
2038 wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_INVITATION_RESULT
2041 wpas_notify_p2p_invitation_result(wpa_s, status, bssid);
2043 if (wpa_s->pending_invite_ssid_id == -1)
2047 wpas_p2p_remove_pending_group_interface(wpa_s);
2051 ssid = wpa_config_get_network(wpa_s->conf,
2052 wpa_s->pending_invite_ssid_id);
2059 wpas_p2p_group_add_persistent(wpa_s, ssid,
2064 static int wpas_p2p_default_channels(struct wpa_supplicant *wpa_s,
2152 static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
2173 if (wpa_s->hw.modes == NULL) {
2177 return wpas_p2p_default_channels(wpa_s, chan);
2187 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, o->mode);
2227 struct wpa_supplicant *wpa_s = ctx;
2229 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
2230 if (os_memcmp(wpa_s->own_addr, interface_addr, ETH_ALEN) == 0)
2233 if (wpa_s == NULL)
2236 return wpa_drv_get_noa(wpa_s, buf, buf_len);
2242 struct wpa_supplicant *wpa_s = ctx;
2244 for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
2245 struct wpa_ssid *ssid = wpa_s->current_ssid;
2250 if (wpa_s->wpa_state != WPA_COMPLETED &&
2251 wpa_s->wpa_state != WPA_GROUP_HANDSHAKE)
2253 if (os_memcmp(wpa_s->go_dev_addr, dev_addr, ETH_ALEN) == 0)
2264 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
2267 int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
2273 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE))
2279 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
2284 params.dev_name = wpa_s->conf->device_name;
2285 os_memcpy(params.pri_dev_type, wpa_s->conf->device_type,
2287 params.num_sec_dev_types = wpa_s->conf->num_sec_device_types;
2289 wpa_s->conf->sec_device_type,
2292 if (wpa_drv_p2p_set_params(wpa_s, ¶ms) < 0)
2299 p2p.msg_ctx = wpa_s;
2300 p2p.cb_ctx = wpa_s;
2322 os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN);
2323 os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN);
2324 p2p.dev_name = wpa_s->conf->device_name;
2325 p2p.manufacturer = wpa_s->conf->manufacturer;
2326 p2p.model_name = wpa_s->conf->model_name;
2327 p2p.model_number = wpa_s->conf->model_number;
2328 p2p.serial_number = wpa_s->conf->serial_number;
2329 if (wpa_s->wps) {
2330 os_memcpy(p2p.uuid, wpa_s->wps->uuid, 16);
2331 p2p.config_methods = wpa_s->wps->config_methods;
2334 if (wpa_s->conf->p2p_listen_reg_class &&
2335 wpa_s->conf->p2p_listen_channel) {
2336 p2p.reg_class = wpa_s->conf->p2p_listen_reg_class;
2337 p2p.channel = wpa_s->conf->p2p_listen_channel;
2349 if (wpa_s->conf->p2p_oper_reg_class &&
2350 wpa_s->conf->p2p_oper_channel) {
2351 p2p.op_reg_class = wpa_s->conf->p2p_oper_reg_class;
2352 p2p.op_channel = wpa_s->conf->p2p_oper_channel;
2369 if (wpa_s->conf->country[0] && wpa_s->conf->country[1]) {
2370 os_memcpy(p2p.country, wpa_s->conf->country, 2);
2375 if (wpas_p2p_setup_channels(wpa_s, &p2p.channels)) {
2381 os_memcpy(p2p.pri_dev_type, wpa_s->conf->device_type,
2384 p2p.num_sec_dev_types = wpa_s->conf->num_sec_device_types;
2385 os_memcpy(p2p.sec_dev_type, wpa_s->conf->sec_device_type,
2388 p2p.concurrent_operations = !!(wpa_s->drv_flags &
2393 if (wpa_s->conf->p2p_ssid_postfix) {
2395 os_strlen(wpa_s->conf->p2p_ssid_postfix);
2398 os_memcpy(p2p.ssid_postfix, wpa_s->conf->p2p_ssid_postfix,
2402 p2p.p2p_intra_bss = wpa_s->conf->p2p_intra_bss;
2409 if (wpa_s->conf->wps_vendor_ext[i] == NULL)
2412 global->p2p, wpa_s->conf->wps_vendor_ext[i]);
2421 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
2425 void wpas_p2p_deinit(struct wpa_supplicant *wpa_s)
2427 if (wpa_s->driver && wpa_s->drv_priv)
2428 wpa_drv_probe_req_report(wpa_s, 0);
2430 if (wpa_s->go_params) {
2433 wpa_s->global->p2p,
2434 wpa_s->go_params->peer_interface_addr);
2437 os_free(wpa_s->go_params);
2438 wpa_s->go_params = NULL;
2439 eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s, NULL);
2440 eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
2441 eloop_cancel_timeout(wpas_p2p_pd_before_join_timeout, wpa_s, NULL);
2442 wpa_s->p2p_long_listen = 0;
2443 eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
2444 eloop_cancel_timeout(wpas_p2p_group_idle_timeout, wpa_s, NULL);
2445 wpas_p2p_remove_pending_group_interface(wpa_s);
2447 /* TODO: remove group interface from the driver if this wpa_s instance
2460 struct wpa_supplicant *wpa_s, *tmp;
2467 wpa_s = global->ifaces;
2468 if (wpa_s)
2469 wpas_p2p_service_flush(wpa_s);
2470 while (wpa_s && wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE)
2471 wpa_s = wpa_s->next;
2472 while (wpa_s) {
2476 (tmp == wpa_s ||
2486 wpa_drv_if_remove(wpa_s, type, ifname);
2494 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
2495 if (wpa_s->ap_iface)
2496 wpas_p2p_group_deinit(wpa_s);
2504 static int wpas_p2p_create_iface(struct wpa_supplicant *wpa_s)
2506 if (wpa_s->drv_flags &
2511 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CONCURRENT))
2513 if (wpa_s->global->ifaces->next)
2515 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
2521 static int wpas_p2p_start_go_neg(struct wpa_supplicant *wpa_s,
2527 if (persistent_group && wpa_s->conf->persistent_reconnect)
2530 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
2531 return wpa_drv_p2p_connect(wpa_s, peer_addr, wps_method,
2536 return p2p_connect(wpa_s->global->p2p, peer_addr, wps_method,
2542 static int wpas_p2p_auth_go_neg(struct wpa_supplicant *wpa_s,
2548 if (persistent_group && wpa_s->conf->persistent_reconnect)
2551 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
2554 return p2p_authorize(wpa_s->global->p2p, peer_addr, wps_method,
2560 static void wpas_p2p_check_join_scan_limit(struct wpa_supplicant *wpa_s)
2562 wpa_s->p2p_join_scan_count++;
2564 wpa_s->p2p_join_scan_count);
2565 if (wpa_s->p2p_join_scan_count > P2P_MAX_JOIN_SCAN_ATTEMPTS) {
2568 MAC2STR(wpa_s->pending_join_iface_addr));
2569 eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
2570 wpa_msg(wpa_s->parent, MSG_INFO,
2578 struct wpa_supplicant *wpa_s = eloop_ctx;
2579 if (!wpa_s->pending_pd_before_join)
2587 wpas_p2p_join_start(wpa_s);
2591 static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
2600 eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
2602 if (wpa_s->global->p2p_disabled)
2609 wpas_p2p_scan_res_handler(wpa_s, scan_res);
2611 freq = p2p_get_oper_freq(wpa_s->global->p2p,
2612 wpa_s->pending_join_iface_addr);
2614 p2p_get_interface_addr(wpa_s->global->p2p,
2615 wpa_s->pending_join_dev_addr,
2617 os_memcmp(iface_addr, wpa_s->pending_join_dev_addr, ETH_ALEN) != 0)
2622 MAC2STR(wpa_s->pending_join_iface_addr),
2624 os_memcpy(wpa_s->pending_join_iface_addr, iface_addr,
2627 freq = p2p_get_oper_freq(wpa_s->global->p2p,
2628 wpa_s->pending_join_iface_addr);
2636 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_MULTI_CHANNEL_CONCURRENT) &&
2637 ((shared_freq = wpa_drv_shared_freq(wpa_s)) > 0) && (shared_freq != freq)) {
2638 wpa_msg(wpa_s->parent, MSG_INFO,
2644 bss = wpa_bss_get_bssid(wpa_s, wpa_s->pending_join_iface_addr);
2656 MAC2STR(wpa_s->pending_join_dev_addr), freq);
2657 wpa_s->pending_pd_before_join = 1;
2659 switch (wpa_s->pending_join_wps_method) {
2674 if ((p2p_get_provisioning_info(wpa_s->global->p2p,
2675 wpa_s->pending_join_dev_addr) ==
2684 MAC2STR(wpa_s->pending_join_dev_addr));
2685 wpa_s->pending_pd_before_join = 0;
2689 if (p2p_prov_disc_req(wpa_s->global->p2p,
2690 wpa_s->pending_join_dev_addr, method, 1,
2695 wpa_s->pending_pd_before_join = 0;
2706 eloop_cancel_timeout(wpas_p2p_pd_before_join_timeout, wpa_s,
2709 wpa_s, NULL);
2714 eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
2715 eloop_register_timeout(1, 0, wpas_p2p_join_scan, wpa_s, NULL);
2716 wpas_p2p_check_join_scan_limit(wpa_s);
2721 wpas_p2p_join_start(wpa_s);
2727 struct wpa_supplicant *wpa_s = eloop_ctx;
2740 wpa_s->wps->dev.p2p = 1;
2741 wps_ie = wps_build_probe_req_ie(0, &wpa_s->wps->dev, wpa_s->wps->uuid,
2744 wpas_p2p_scan_res_join(wpa_s, NULL);
2748 ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p);
2752 wpas_p2p_scan_res_join(wpa_s, NULL);
2758 p2p_scan_ie(wpa_s->global->p2p, ies, NULL);
2768 wpa_s->scan_res_handler = wpas_p2p_scan_res_join;
2769 ret = wpa_drv_scan(wpa_s, ¶ms);
2776 eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
2777 eloop_register_timeout(1, 0, wpas_p2p_join_scan, wpa_s, NULL);
2778 wpas_p2p_check_join_scan_limit(wpa_s);
2783 static int wpas_p2p_join(struct wpa_supplicant *wpa_s, const u8 *iface_addr,
2790 os_memcpy(wpa_s->pending_join_iface_addr, iface_addr, ETH_ALEN);
2791 os_memcpy(wpa_s->pending_join_dev_addr, dev_addr, ETH_ALEN);
2792 wpa_s->pending_join_wps_method = wps_method;
2795 wpas_p2p_stop_find(wpa_s);
2797 wpa_s->p2p_join_scan_count = 0;
2798 wpas_p2p_join_scan(wpa_s, NULL);
2803 static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s)
2808 eloop_cancel_timeout(wpas_p2p_pd_before_join_timeout, wpa_s, NULL);
2809 group = wpas_p2p_get_group_iface(wpa_s, 0, 0);
2812 if (group != wpa_s) {
2813 os_memcpy(group->p2p_pin, wpa_s->p2p_pin,
2815 group->p2p_wps_method = wpa_s->p2p_wps_method;
2821 os_memcpy(res.peer_interface_addr, wpa_s->pending_join_iface_addr,
2823 res.wps_method = wpa_s->pending_join_wps_method;
2824 if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) {
2827 wpa_drv_cancel_remain_on_channel(wpa_s);
2828 wpa_s->off_channel_freq = 0;
2829 wpa_s->roc_waiting_drv_freq = 0;
2838 eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s, NULL);
2840 wpa_s, NULL);
2848 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
2862 int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
2873 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
2877 go_intent = wpa_s->conf->p2p_go_intent;
2880 wpa_s->p2p_long_listen = 0;
2882 wpa_s->p2p_wps_method = wps_method;
2885 os_strlcpy(wpa_s->p2p_pin, pin, sizeof(wpa_s->p2p_pin));
2888 os_snprintf(wpa_s->p2p_pin, sizeof(wpa_s->p2p_pin), "%08d",
2891 wpa_s->p2p_pin);
2893 wpa_s->p2p_pin[0] = '\0';
2901 os_memcpy(wpa_s->p2p_auth_invite, peer_addr, ETH_ALEN);
2905 if (p2p_get_interface_addr(wpa_s->global->p2p, peer_addr,
2908 p2p_get_dev_addr(wpa_s->global->p2p, peer_addr,
2911 if (wpas_p2p_join(wpa_s, iface_addr, dev_addr, wps_method) <
2917 if (wpa_s->current_ssid && wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
2918 wpa_s->assoc_freq)
2919 oper_freq = wpa_s->assoc_freq;
2921 oper_freq = wpa_drv_shared_freq(wpa_s);
2927 if (!p2p_supported_freq(wpa_s->global->p2p, freq)) {
2935 !(wpa_s->drv_flags &
2946 !p2p_supported_freq(wpa_s->global->p2p, oper_freq)) {
2947 if (!(wpa_s->drv_flags &
2965 wpa_s->create_p2p_iface = wpas_p2p_create_iface(wpa_s);
2967 if (wpa_s->create_p2p_iface) {
2972 if (wpas_p2p_add_group_interface(wpa_s, iftype) < 0) {
2978 if_addr = wpa_s->pending_interface_addr;
2980 if_addr = wpa_s->own_addr;
2983 if (wpas_p2p_auth_go_neg(wpa_s, peer_addr, wps_method,
2990 if (wpas_p2p_start_go_neg(wpa_s, peer_addr, wps_method,
2993 if (wpa_s->create_p2p_iface)
2994 wpas_p2p_remove_pending_group_interface(wpa_s);
3003 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
3010 void wpas_p2p_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
3013 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3015 if (wpa_s->off_channel_freq == wpa_s->pending_listen_freq) {
3016 p2p_listen_cb(wpa_s->global->p2p, wpa_s->pending_listen_freq,
3017 wpa_s->pending_listen_duration);
3018 wpa_s->pending_listen_freq = 0;
3023 static int wpas_p2p_listen_start(struct wpa_supplicant *wpa_s,
3027 if (timeout > wpa_s->max_remain_on_chan)
3028 timeout = wpa_s->max_remain_on_chan;
3030 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3031 return wpa_drv_p2p_listen(wpa_s, timeout);
3033 return p2p_listen(wpa_s->global->p2p, timeout);
3039 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
3046 void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
3051 wpa_s->p2p_long_listen, wpa_s->pending_action_tx);
3052 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3054 if (p2p_listen_end(wpa_s->global->p2p, freq) > 0)
3056 if (wpa_s->pending_action_tx)
3058 if (wpa_s->p2p_long_listen > 0)
3059 wpa_s->p2p_long_listen -= wpa_s->max_remain_on_chan;
3060 if (wpa_s->p2p_long_listen > 0) {
3062 wpas_p2p_listen_start(wpa_s, wpa_s->p2p_long_listen);
3069 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
3080 int wpas_p2p_group_remove(struct wpa_supplicant *wpa_s, const char *ifname)
3082 struct wpa_global *global = wpa_s->global;
3086 wpa_s = global->ifaces;
3087 while (wpa_s) {
3088 prev = wpa_s;
3089 wpa_s = wpa_s->next;
3095 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
3096 if (os_strcmp(wpa_s->ifname, ifname) == 0)
3100 return wpas_p2p_disconnect(wpa_s);
3104 static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
3117 } else if (wpa_s->conf->p2p_oper_reg_class == 81 &&
3118 wpa_s->conf->p2p_oper_channel >= 1 &&
3119 wpa_s->conf->p2p_oper_channel <= 11) {
3120 params->freq = 2407 + 5 * wpa_s->conf->p2p_oper_channel;
3123 } else if (wpa_s->conf->p2p_oper_reg_class == 115 ||
3124 wpa_s->conf->p2p_oper_reg_class == 124) {
3125 params->freq = 5000 + 5 * wpa_s->conf->p2p_oper_channel;
3128 } else if (wpa_s->conf->p2p_oper_channel == 0 &&
3129 wpa_s->best_overall_freq > 0 &&
3130 p2p_supported_freq(wpa_s->global->p2p,
3131 wpa_s->best_overall_freq)) {
3132 params->freq = wpa_s->best_overall_freq;
3135 } else if (wpa_s->conf->p2p_oper_channel == 0 &&
3136 wpa_s->best_24_freq > 0 &&
3137 p2p_supported_freq(wpa_s->global->p2p,
3138 wpa_s->best_24_freq)) {
3139 params->freq = wpa_s->best_24_freq;
3142 } else if (wpa_s->conf->p2p_oper_channel == 0 &&
3143 wpa_s->best_5_freq > 0 &&
3144 p2p_supported_freq(wpa_s->global->p2p,
3145 wpa_s->best_5_freq)) {
3146 params->freq = wpa_s->best_5_freq;
3155 if (wpa_s->current_ssid && wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
3156 wpa_s->assoc_freq && !freq) {
3159 params->freq = wpa_s->assoc_freq;
3162 res = wpa_drv_shared_freq(wpa_s);
3168 !(wpa_s->drv_flags &
3181 wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
3186 if (!wpas_p2p_create_iface(wpa_s))
3187 return wpa_s;
3189 if (wpas_p2p_add_group_interface(wpa_s, go ? WPA_IF_P2P_GO :
3192 group_wpa_s = wpas_p2p_init_group_interface(wpa_s, go);
3194 wpas_p2p_remove_pending_group_interface(wpa_s);
3204 * @wpa_s: Pointer to wpa_supplicant data from wpa_supplicant_add_iface()
3212 int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group,
3218 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3223 wpas_p2p_stop_find(wpa_s);
3228 if (wpa_s->best_24_freq > 0 &&
3229 p2p_supported_freq(wpa_s->global->p2p,
3230 wpa_s->best_24_freq)) {
3231 freq = wpa_s->best_24_freq;
3245 if (wpa_s->best_5_freq > 0 &&
3246 p2p_supported_freq(wpa_s->global->p2p,
3247 wpa_s->best_5_freq)) {
3248 freq = wpa_s->best_5_freq;
3254 if (!p2p_supported_freq(wpa_s->global->p2p, freq)) {
3264 if (freq > 0 && !p2p_supported_freq(wpa_s->global->p2p, freq)) {
3271 if (wpas_p2p_init_go_params(wpa_s, ¶ms, freq))
3273 p2p_go_params(wpa_s->global->p2p, ¶ms);
3276 wpa_s = wpas_p2p_get_group_iface(wpa_s, 0, 1);
3277 if (wpa_s == NULL)
3279 wpas_start_wps_go(wpa_s, ¶ms, 0);
3285 static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
3290 wpa_s = wpas_p2p_get_group_iface(wpa_s, addr_allocated, 0);
3291 if (wpa_s == NULL)
3294 wpa_supplicant_ap_deinit(wpa_s);
3296 ssid = wpa_config_add_network(wpa_s->conf);
3307 wpa_config_remove_network(wpa_s->conf, ssid->id);
3321 wpa_supplicant_select_network(wpa_s, ssid);
3323 wpa_s->show_group_started = 1;
3329 int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
3339 if (wpas_get_p2p_group(wpa_s, ssid->ssid, ssid->ssid_len, &go) &&
3347 wpas_p2p_stop_find(wpa_s);
3350 return wpas_start_p2p_client(wpa_s, ssid, addr_allocated);
3355 if (wpas_p2p_init_go_params(wpa_s, ¶ms, freq))
3371 wpa_s = wpas_p2p_get_group_iface(wpa_s, addr_allocated, 1);
3372 if (wpa_s == NULL)
3375 wpas_start_wps_go(wpa_s, ¶ms, 0);
3384 struct wpa_supplicant *wpa_s = ctx;
3385 if (wpa_s->ap_iface) {
3386 struct hostapd_data *hapd = wpa_s->ap_iface->bss[0];
3402 wpa_supplicant_ap_update_beacon(wpa_s);
3408 struct wpa_supplicant *wpa_s = ctx;
3409 if (!wpa_s->ap_iface)
3414 wpas_p2p_set_group_idle_timeout(wpa_s);
3417 eloop_cancel_timeout(wpas_p2p_group_idle_timeout, wpa_s, NULL);
3421 struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
3428 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3430 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3437 if (persistent_group && wpa_s->conf->persistent_reconnect)
3441 os_memcpy(cfg->interface_addr, wpa_s->own_addr, ETH_ALEN);
3442 if (wpa_s->max_stations &&
3443 wpa_s->max_stations < wpa_s->conf->max_num_sta)
3444 cfg->max_clients = wpa_s->max_stations;
3446 cfg->max_clients = wpa_s->conf->max_num_sta;
3447 cfg->cb_ctx = wpa_s;
3451 group = p2p_group_init(wpa_s->global->p2p, cfg);
3456 wpa_s->p2p_group = group;
3461 void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
3464 if (!wpa_s->p2p_in_provisioning) {
3471 p2p_clear_provisioning_info(wpa_s->global->p2p, peer_addr);
3473 eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->parent,
3475 if (wpa_s->global->p2p)
3476 p2p_wps_success_cb(wpa_s->global->p2p, peer_addr);
3477 else if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3478 wpa_drv_wps_success_cb(wpa_s, peer_addr);
3479 wpas_group_formation_completed(wpa_s, 1);
3483 void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
3486 if (!wpa_s->p2p_in_provisioning) {
3492 if (wpa_s->go_params) {
3494 wpa_s->global->p2p,
3495 wpa_s->go_params->peer_interface_addr);
3498 wpas_notify_p2p_wps_failed(wpa_s, fail);
3502 int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
3519 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
3520 return wpa_drv_p2p_prov_disc_req(wpa_s, peer_addr,
3524 if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled)
3527 return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
3539 static void wpas_p2p_clear_pending_action_tx(struct wpa_supplicant *wpa_s)
3541 if (!wpa_s->pending_action_tx)
3546 wpabuf_free(wpa_s->pending_action_tx);
3547 wpa_s->pending_action_tx = NULL;
3551 int wpas_p2p_find(struct wpa_supplicant *wpa_s, unsigned int timeout,
3556 wpas_p2p_clear_pending_action_tx(wpa_s);
3557 wpa_s->p2p_long_listen = 0;
3559 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3560 return wpa_drv_p2p_find(wpa_s, timeout, type);
3562 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3565 wpa_supplicant_cancel_sched_scan(wpa_s);
3567 return p2p_find(wpa_s->global->p2p, timeout, type,
3572 void wpas_p2p_stop_find(struct wpa_supplicant *wpa_s)
3574 wpas_p2p_clear_pending_action_tx(wpa_s);
3575 wpa_s->p2p_long_listen = 0;
3576 eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
3577 eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
3578 wpa_s->p2p_cb_on_scan_complete = 0;
3580 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
3581 wpa_drv_p2p_stop_find(wpa_s);
3585 if (wpa_s->global->p2p)
3586 p2p_stop_find(wpa_s->global->p2p);
3588 wpas_p2p_remove_pending_group_interface(wpa_s);
3594 struct wpa_supplicant *wpa_s = eloop_ctx;
3595 wpa_s->p2p_long_listen = 0;
3599 int wpas_p2p_listen(struct wpa_supplicant *wpa_s, unsigned int timeout)
3603 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3606 wpa_supplicant_cancel_sched_scan(wpa_s);
3607 wpas_p2p_clear_pending_action_tx(wpa_s);
3617 eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
3618 wpa_s->p2p_long_listen = 0;
3625 if (wpa_s->global->p2p)
3626 p2p_stop_find(wpa_s->global->p2p);
3628 res = wpas_p2p_listen_start(wpa_s, timeout * 1000);
3629 if (res == 0 && timeout * 1000 > wpa_s->max_remain_on_chan) {
3630 wpa_s->p2p_long_listen = timeout * 1000;
3633 wpa_s, NULL);
3640 int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
3646 if (wpa_s->global->p2p_disabled)
3648 if (wpa_s->global->p2p == NULL)
3654 ret = p2p_assoc_req_ie(wpa_s->global->p2p, bss->bssid, buf, len,
3662 int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
3666 if (wpa_s->global->p2p_disabled)
3668 if (wpa_s->global->p2p == NULL)
3671 return p2p_probe_req_rx(wpa_s->global->p2p, addr, dst, bssid,
3676 void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
3680 if (wpa_s->global->p2p_disabled)
3682 if (wpa_s->global->p2p == NULL)
3685 p2p_rx_action(wpa_s->global->p2p, da, sa, bssid, category, data, len,
3690 void wpas_p2p_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ies)
3692 if (wpa_s->global->p2p_disabled)
3694 if (wpa_s->global->p2p == NULL)
3697 p2p_scan_ie(wpa_s->global->p2p, ies, NULL);
3701 void wpas_p2p_group_deinit(struct wpa_supplicant *wpa_s)
3703 p2p_group_deinit(wpa_s->p2p_group);
3704 wpa_s->p2p_group = NULL;
3706 wpa_s->ap_configured_cb = NULL;
3707 wpa_s->ap_configured_cb_ctx = NULL;
3708 wpa_s->ap_configured_cb_data = NULL;
3709 wpa_s->connect_without_scan = NULL;
3713 int wpas_p2p_reject(struct wpa_supplicant *wpa_s, const u8 *addr)
3715 wpa_s->p2p_long_listen = 0;
3717 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3718 return wpa_drv_p2p_reject(wpa_s, addr);
3720 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3723 return p2p_reject(wpa_s->global->p2p, addr);
3728 int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
3741 if (wpas_p2p_create_iface(wpa_s)) {
3742 if (wpas_p2p_add_group_interface(wpa_s,
3749 bssid = wpa_s->pending_interface_addr;
3751 bssid = wpa_s->own_addr;
3756 wpa_s->pending_invite_ssid_id = ssid->id;
3758 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3759 return wpa_drv_p2p_invite(wpa_s, peer_addr, role, bssid,
3763 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3766 return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid,
3772 int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
3775 struct wpa_global *global = wpa_s->global;
3781 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
3782 if (os_strcmp(wpa_s->ifname, ifname) == 0)
3785 if (wpa_s == NULL) {
3790 ssid = wpa_s->current_ssid;
3798 wpas_p2p_get_persistent(wpa_s->parent, peer_addr,
3803 bssid = wpa_s->own_addr;
3805 go_dev_addr = wpa_s->global->p2p_dev_addr;
3808 if (wpa_s->wpa_state < WPA_ASSOCIATED) {
3813 bssid = wpa_s->bssid;
3815 !is_zero_ether_addr(wpa_s->go_dev_addr))
3816 go_dev_addr = wpa_s->go_dev_addr;
3818 wpa_s->parent->pending_invite_ssid_id = -1;
3820 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3821 return wpa_drv_p2p_invite(wpa_s, peer_addr, role, bssid,
3825 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3828 return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid,
3829 ssid->ssid, ssid->ssid_len, wpa_s->assoc_freq,
3834 void wpas_p2p_completed(struct wpa_supplicant *wpa_s)
3836 struct wpa_ssid *ssid = wpa_s->current_ssid;
3843 if (!wpa_s->show_group_started || !ssid)
3846 wpa_s->show_group_started = 0;
3852 persistent = wpas_p2p_persistent_group(wpa_s, go_dev_addr, ssid->ssid,
3854 os_memcpy(wpa_s->go_dev_addr, go_dev_addr, ETH_ALEN);
3856 if (wpa_s->global->p2p_group_formation == wpa_s)
3857 wpa_s->global->p2p_group_formation = NULL;
3859 freq = wpa_s->current_bss ? wpa_s->current_bss->freq :
3860 (int) wpa_s->assoc_freq;
3864 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_STARTED
3867 wpa_s->ifname, ssid_txt, freq, psk,
3871 wpa_msg(wpa_s->parent, MSG_INFO, P2P_EVENT_GROUP_STARTED
3874 wpa_s->ifname, ssid_txt, freq,
3881 network_id = wpas_p2p_store_persistent_group(wpa_s->parent,
3885 wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 1);
3889 int wpas_p2p_presence_req(struct wpa_supplicant *wpa_s, u32 duration1,
3892 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3894 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3897 if (wpa_s->wpa_state < WPA_ASSOCIATED ||
3898 wpa_s->current_ssid == NULL ||
3899 wpa_s->current_ssid->mode != WPAS_MODE_INFRA)
3902 return p2p_presence_req(wpa_s->global->p2p, wpa_s->bssid,
3903 wpa_s->own_addr, wpa_s->assoc_freq,
3908 int wpas_p2p_ext_listen(struct wpa_supplicant *wpa_s, unsigned int period,
3911 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3914 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3917 return p2p_ext_listen(wpa_s->global->p2p, period, interval);
3921 static int wpas_p2p_is_client(struct wpa_supplicant *wpa_s)
3923 return wpa_s->current_ssid != NULL &&
3924 wpa_s->current_ssid->p2p_group &&
3925 wpa_s->current_ssid->mode == WPAS_MODE_INFRA;
3931 struct wpa_supplicant *wpa_s = eloop_ctx;
3933 if (wpa_s->conf->p2p_group_idle == 0 && !wpas_p2p_is_client(wpa_s)) {
3940 "group",wpa_s->conf->p2p_group_idle);
3941 wpa_s->removal_reason = P2P_GROUP_REMOVAL_IDLE_TIMEOUT;
3942 wpas_p2p_group_delete(wpa_s);
3946 static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s)
3950 eloop_cancel_timeout(wpas_p2p_group_idle_timeout, wpa_s, NULL);
3951 if (wpa_s->current_ssid == NULL || !wpa_s->current_ssid->p2p_group)
3954 timeout = wpa_s->conf->p2p_group_idle;
3955 if (wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
3965 wpa_s, NULL);
3969 void wpas_p2p_deauth_notif(struct wpa_supplicant *wpa_s, const u8 *bssid,
3972 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3974 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3977 p2p_deauth_notif(wpa_s->global->p2p, bssid, reason_code, ie, ie_len);
3981 void wpas_p2p_disassoc_notif(struct wpa_supplicant *wpa_s, const u8 *bssid,
3984 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
3986 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
3989 p2p_disassoc_notif(wpa_s->global->p2p, bssid, reason_code, ie, ie_len);
3993 void wpas_p2p_update_config(struct wpa_supplicant *wpa_s)
3995 struct p2p_data *p2p = wpa_s->global->p2p;
4000 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE))
4003 if (wpa_s->conf->changed_parameters & CFG_CHANGED_DEVICE_NAME)
4004 p2p_set_dev_name(p2p, wpa_s->conf->device_name);
4006 if (wpa_s->conf->changed_parameters & CFG_CHANGED_DEVICE_TYPE)
4007 p2p_set_pri_dev_type(p2p, wpa_s->conf->device_type);
4009 if (wpa_s->wps &&
4010 (wpa_s->conf->changed_parameters & CFG_CHANGED_CONFIG_METHODS))
4011 p2p_set_config_methods(p2p, wpa_s->wps->config_methods);
4013 if (wpa_s->wps && (wpa_s->conf->changed_parameters & CFG_CHANGED_UUID))
4014 p2p_set_uuid(p2p, wpa_s->wps->uuid);
4016 if (wpa_s->conf->changed_parameters & CFG_CHANGED_WPS_STRING) {
4017 p2p_set_manufacturer(p2p, wpa_s->conf->manufacturer);
4018 p2p_set_model_name(p2p, wpa_s->conf->model_name);
4019 p2p_set_model_number(p2p, wpa_s->conf->model_number);
4020 p2p_set_serial_number(p2p, wpa_s->conf->serial_number);
4023 if (wpa_s->conf->changed_parameters & CFG_CHANGED_SEC_DEVICE_TYPE)
4025 (void *) wpa_s->conf->sec_device_type,
4026 wpa_s->conf->num_sec_device_types);
4028 if (wpa_s->conf->changed_parameters & CFG_CHANGED_VENDOR_EXTENSION) {
4032 if (wpa_s->conf->wps_vendor_ext[i] == NULL)
4035 p2p, wpa_s->conf->wps_vendor_ext[i]);
4039 if ((wpa_s->conf->changed_parameters & CFG_CHANGED_COUNTRY) &&
4040 wpa_s->conf->country[0] && wpa_s->conf->country[1]) {
4042 country[0] = wpa_s->conf->country[0];
4043 country[1] = wpa_s->conf->country[1];
4048 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_SSID_POSTFIX) {
4049 p2p_set_ssid_postfix(p2p, (u8 *) wpa_s->conf->p2p_ssid_postfix,
4050 wpa_s->conf->p2p_ssid_postfix ?
4051 os_strlen(wpa_s->conf->p2p_ssid_postfix) :
4055 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_INTRA_BSS)
4056 p2p_set_intra_bss_dist(p2p, wpa_s->conf->p2p_intra_bss);
4058 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_LISTEN_CHANNEL) {
4062 if (wpa_s->conf->p2p_listen_reg_class &&
4063 wpa_s->conf->p2p_listen_channel) {
4064 reg_class = wpa_s->conf->p2p_listen_reg_class;
4065 channel = wpa_s->conf->p2p_listen_channel;
4080 if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_OPER_CHANNEL) {
4084 if (wpa_s
4085 wpa_s->conf->p2p_oper_channel) {
4086 op_reg_class = wpa_s->conf->p2p_oper_reg_class;
4087 op_channel = wpa_s->conf->p2p_oper_channel;
4108 int wpas_p2p_set_noa(struct wpa_supplicant *wpa_s, u8 count, int start,
4111 if (!wpa_s->ap_iface)
4113 return hostapd_p2p_set_noa(wpa_s->ap_iface->bss[0], count, start,
4118 int wpas_p2p_set_cross_connect(struct wpa_supplicant *wpa_s, int enabled)
4120 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
4122 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
4125 wpa_s->global->cross_connection = enabled;
4126 p2p_set_cross_connect(wpa_s->global->p2p, enabled);
4131 for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
4195 void wpas_p2p_notif_connected(struct wpa_supplicant *wpa_s)
4197 if (wpa_s->ap_iface || wpa_s->current_ssid == NULL ||
4198 wpa_s->current_ssid->mode != WPAS_MODE_INFRA ||
4199 wpa_s->cross_connect_disallowed)
4200 wpas_p2p_disable_cross_connect(wpa_s);
4202 wpas_p2p_enable_cross_connect(wpa_s);
4203 if (!wpa_s->ap_iface)
4204 eloop_cancel_timeout(wpas_p2p_group_idle_timeout, wpa_s, NULL);
4208 void wpas_p2p_notif_disconnected(struct wpa_supplicant *wpa_s)
4210 wpas_p2p_disable_cross_connect(wpa_s);
4211 if (!wpa_s->ap_iface &&
4213 wpa_s, NULL))
4216 wpas_p2p_set_group_idle_timeout(wpa_s);
4221 static void wpas_p2p_cross_connect_setup(struct wpa_supplicant *wpa_s)
4225 if (!wpa_s->global->cross_connection)
4228 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
4229 if (iface == wpa_s)
4237 wpa_s->cross_connect_enabled = 1;
4238 os_strlcpy(wpa_s->cross_connect_uplink, iface->ifname,
4239 sizeof(wpa_s->cross_connect_uplink));
4242 wpa_s->ifname, wpa_s->cross_connect_uplink);
4250 wpa_s->cross_connect_in_use = 1;
4251 wpa_msg(wpa_s->parent, MSG_INFO,
4253 wpa_s->ifname, wpa_s->cross_connect_uplink);
4259 int wpas_p2p_notif_pbc_overlap(struct wpa_supplicant *wpa_s)
4261 if (wpa_s->p2p_group_interface != P2P_GROUP_INTERFACE_CLIENT &&
4262 !wpa_s->p2p_in_provisioning)
4267 if (wpa_s != wpa_s->parent)
4268 wpa_msg_ctrl(wpa_s->parent, MSG_INFO, WPS_EVENT_OVERLAP);
4270 if (wpa_s->global->p2p)
4271 p2p_group_formation_failed(wpa_s->global->p2p);
4274 wpa_s->parent, NULL);
4276 wpas_group_formation_completed(wpa_s, 0);
4281 void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s)
4285 if (wpa_s->global == NULL || wpa_s->global->p2p == NULL)
4289 if (wpas_p2p_setup_channels(wpa_s, &chan)) {
4295 p2p_update_channel_list(wpa_s->global->p2p, &chan);
4299 int wpas_p2p_cancel(struct wpa_supplicant *wpa_s)
4301 struct wpa_global *global = wpa_s->global;
4310 if (wpa_s->pending_interface_name[0] &&
4311 !is_zero_ether_addr(wpa_s->pending_interface_addr))
4321 wpas_p2p_stop_find(wpa_s);
4323 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
4324 if (wpa_s == global->p2p_group_formation &&
4325 (wpa_s->p2p_in_provisioning ||
4326 wpa_s->parent->pending_interface_type ==
4330 wpa_s->ifname);
4333 wpa_s->parent, NULL);
4334 wpas_p2p_group_delete(wpa_s);
4348 void wpas_p2p_interface_unavailable(struct wpa_supplicant *wpa_s)
4350 if (wpa_s->current_ssid == NULL || !wpa_s->current_ssid->p2p_group)
4355 wpa_s->removal_reason = P2P_GROUP_REMOVAL_UNAVAILABLE;
4356 wpas_p2p_group_delete(wpa_s);
4360 void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
4363 struct p2p_data *p2p = wpa_s->global->p2p;
4364 if (p2p == NULL || (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT))
4370 int wpas_p2p_unauthorize(struct wpa_supplicant *wpa_s, const char *addr)
4373 struct p2p_data *p2p = wpa_s->global->p2p;
4375 if (p2p == NULL || (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT))
4387 * @wpa_s: Pointer to wpa_supplicant data
4396 int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s)
4399 if (wpa_s == NULL)
4402 wpa_s->removal_reason = P2P_GROUP_REMOVAL_REQUESTED;
4403 wpas_p2p_group_delete(wpa_s);
4409 int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
4411 if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
4414 return p2p_in_progress(wpa_s->global->p2p);
4418 void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
4422 if (wpa_s->p2p_in_provisioning && ssid->p2p_group &&
4424 wpa_s->parent, NULL) > 0) {
4430 wpa_s->parent, NULL);
4432 wpas_p2p_group_formation_timeout(wpa_s->parent, NULL);
4438 struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
4445 for (s = wpa_s->conf->ssid; s; s = s->next) {
4468 void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
4473 wpas_p2p_add_persistent_group_client(wpa_s, addr);
4477 int wpas_p2p_handle_frequency_conflicts(struct wpa_supplicant *wpa_s, int freq)
4480 struct p2p_data *p2p = wpa_s->global->p2p;
4482 for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
4500 if(!wpas_is_p2p_prioritized(wpa_s)) {