EAP peer: Add framework for external SIM/USIM processing
[mech_eap.git] / wpa_supplicant / events.c
index 69e4030..2e99af2 100644 (file)
@@ -275,7 +275,8 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
 #ifdef PCSC_FUNCS
        int aka = 0, sim = 0;
 
-       if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL)
+       if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL ||
+           wpa_s->conf->external_sim)
                return 0;
 
        if (ssid->eap.eap_methods == NULL) {
@@ -715,10 +716,13 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
        rsn_ie_len = ie ? ie[1] : 0;
 
        wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
-               "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s",
+               "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s",
                i, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len),
                wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
-               wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "");
+               wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "",
+               (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
+                wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) ?
+               " p2p" : "");
 
        e = wpa_blacklist_get(wpa_s, bss->bssid);
        if (e) {
@@ -855,6 +859,13 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                }
 
 #ifdef CONFIG_P2P
+               if (ssid->p2p_group &&
+                   !wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) &&
+                   !wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) {
+                       wpa_dbg(wpa_s, MSG_DEBUG, "   skip - no P2P IE seen");
+                       continue;
+               }
+
                /*
                 * TODO: skip the AP if its P2P IE has Group Formation
                 * bit set in the P2P Group Capability Bitmap and we
@@ -1493,6 +1504,43 @@ void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
 }
 
 
+#ifdef CONFIG_INTERWORKING
+
+static int wpas_qos_map_set(struct wpa_supplicant *wpa_s, const u8 *qos_map,
+                           size_t len)
+{
+       int res;
+
+       wpa_hexdump(MSG_DEBUG, "Interworking: QoS Map Set", qos_map, len);
+       res = wpa_drv_set_qos_map(wpa_s, qos_map, len);
+       if (res) {
+               wpa_printf(MSG_DEBUG, "Interworking: Failed to configure QoS Map Set to the driver");
+       }
+
+       return res;
+}
+
+
+static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
+                                           const u8 *ies, size_t ies_len)
+{
+       struct ieee802_11_elems elems;
+
+       if (ies == NULL)
+               return;
+
+       if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
+               return;
+
+       if (elems.qos_map_set) {
+               wpas_qos_map_set(wpa_s, elems.qos_map_set,
+                                elems.qos_map_set_len);
+       }
+}
+
+#endif /* CONFIG_INTERWORKING */
+
+
 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
                                          union wpa_event_data *data)
 {
@@ -1517,6 +1565,10 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
                wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
                                       data->assoc_info.resp_ies_len);
 #endif /* CONFIG_WNM */
+#ifdef CONFIG_INTERWORKING
+               interworking_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
+                                               data->assoc_info.resp_ies_len);
+#endif /* CONFIG_INTERWORKING */
        }
        if (data->assoc_info.beacon_ies)
                wpa_hexdump(MSG_DEBUG, "beacon_ies",
@@ -2281,8 +2333,12 @@ static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
                        wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer);
                break;
        case TDLS_REQUEST_TEARDOWN:
-               wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer,
-                                      data->tdls.reason_code);
+               if (wpa_tdls_is_external_setup(wpa_s->wpa))
+                       wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer,
+                                              data->tdls.reason_code);
+               else
+                       wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN,
+                                         data->tdls.peer);
                break;
        }
 }
@@ -2892,6 +2948,19 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                        break;
                }
 #endif /* CONFIG_TDLS */
+#ifdef CONFIG_INTERWORKING
+               if (data->rx_action.category == WLAN_ACTION_QOS &&
+                   data->rx_action.len >= 1 &&
+                   data->rx_action.data[0] == QOS_QOS_MAP_CONFIG) {
+                       wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: Received QoS Map Configure frame from "
+                               MACSTR, MAC2STR(data->rx_action.sa));
+                       if (os_memcmp(data->rx_action.sa, wpa_s->bssid, ETH_ALEN)
+                           == 0)
+                               wpas_qos_map_set(wpa_s, data->rx_action.data + 1,
+                                                data->rx_action.len - 1);
+                       break;
+               }
+#endif /* CONFIG_INTERWORKING */
 #ifdef CONFIG_P2P
                wpas_p2p_rx_action(wpa_s, data->rx_action.da,
                                   data->rx_action.sa,