示例#1
0
static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
{
#ifdef CONFIG_P2P
	struct wpa_supplicant *wpa_s = ctx;
	const struct ieee80211_mgmt *mgmt;

	mgmt = (const struct ieee80211_mgmt *) buf;
	if (len < IEEE80211_HDRLEN + 1)
		return -1;
	wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
			   mgmt->u.action.category,
			   buf + IEEE80211_HDRLEN + 1,
			   len - IEEE80211_HDRLEN - 1, freq);
#endif /* CONFIG_P2P */
	return 0;
}
示例#2
0
文件: ap.c 项目: pocketbook/801
static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
{
#ifdef CONFIG_P2P
	struct wpa_supplicant *wpa_s = ctx;
	const struct ieee80211_mgmt *mgmt;
	size_t hdr_len;

	mgmt = (const struct ieee80211_mgmt *) buf;
	hdr_len = (const u8 *) &mgmt->u.action.u.vs_public_action.action - buf;
	if (hdr_len > len)
		return;
	wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
			   mgmt->u.action.category,
			   &mgmt->u.action.u.vs_public_action.action,
			   len - hdr_len, freq);
#endif /* CONFIG_P2P */
}
示例#3
0
static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
{
#ifdef CONFIG_P2P
	struct wpa_supplicant *wpa_s = ctx;
	const struct ieee80211_mgmt *mgmt;

	mgmt = (const struct ieee80211_mgmt *) buf;
	if (len < IEEE80211_HDRLEN + 1)
		return;
	if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
		return;
	wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
			   mgmt->u.action.category,
			   buf + IEEE80211_HDRLEN + 1,
			   len - IEEE80211_HDRLEN - 1, freq);
#endif /* CONFIG_P2P */
}
示例#4
0
void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
			  union wpa_event_data *data)
{
	struct wpa_supplicant *wpa_s = ctx;
	u16 reason_code = 0;

	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
	    event != EVENT_INTERFACE_ENABLED &&
	    event != EVENT_INTERFACE_STATUS) {
		wpa_printf(MSG_DEBUG, "Ignore event %d while interface is "
			   "disabled", event);
		return;
	}

	wpa_printf(MSG_DEBUG, "Event %d received on interface %s",
		   event, wpa_s->ifname);

	switch (event) {
	case EVENT_ASSOC:
		wpa_supplicant_event_assoc(wpa_s, data);
		break;
	case EVENT_DISASSOC:
		wpa_printf(MSG_DEBUG, "Disassociation notification");
		if (data) {
			wpa_printf(MSG_DEBUG, " * reason %u",
				   data->disassoc_info.reason_code);
			if (data->disassoc_info.addr)
				wpa_printf(MSG_DEBUG, " * address " MACSTR,
					   MAC2STR(data->disassoc_info.addr));
		}
#ifdef CONFIG_AP
		if (wpa_s->ap_iface && data && data->disassoc_info.addr) {
			hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
					       data->disassoc_info.addr);
			break;
		}
#endif /* CONFIG_AP */
		if (data) {
			reason_code = data->disassoc_info.reason_code;
			wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
				    data->disassoc_info.ie,
				    data->disassoc_info.ie_len);
#ifdef CONFIG_P2P
			wpas_p2p_disassoc_notif(
				wpa_s, data->disassoc_info.addr, reason_code,
				data->disassoc_info.ie,
				data->disassoc_info.ie_len);
#endif /* CONFIG_P2P */
		}
		/* fall through */
	case EVENT_DEAUTH:
		if (event == EVENT_DEAUTH) {
			wpa_printf(MSG_DEBUG, "Deauthentication notification");
			if (data) {
				reason_code = data->deauth_info.reason_code;
				wpa_printf(MSG_DEBUG, " * reason %u",
					   data->deauth_info.reason_code);
				if (data->deauth_info.addr) {
					wpa_printf(MSG_DEBUG, " * address "
						   MACSTR,
						   MAC2STR(data->deauth_info.
							   addr));
				}
				wpa_hexdump(MSG_DEBUG,
					    "Deauthentication frame IE(s)",
					    data->deauth_info.ie,
					    data->deauth_info.ie_len);
#ifdef CONFIG_P2P
				wpas_p2p_deauth_notif(
					wpa_s, data->deauth_info.addr,
					reason_code,
					data->deauth_info.ie,
					data->deauth_info.ie_len);
#endif /* CONFIG_P2P */
			}
		}
#ifdef CONFIG_AP
		if (wpa_s->ap_iface && data && data->deauth_info.addr) {
			hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
					       data->deauth_info.addr);
			break;
		}
#endif /* CONFIG_AP */
		wpa_supplicant_event_disassoc(wpa_s, reason_code);
		break;
	case EVENT_MICHAEL_MIC_FAILURE:
		wpa_supplicant_event_michael_mic_failure(wpa_s, data);
		break;
#ifndef CONFIG_NO_SCAN_PROCESSING
	case EVENT_SCAN_RESULTS:
		wpa_supplicant_event_scan_results(wpa_s, data);
		break;
#endif /* CONFIG_NO_SCAN_PROCESSING */
	case EVENT_ASSOCINFO:
		wpa_supplicant_event_associnfo(wpa_s, data);
		break;
	case EVENT_INTERFACE_STATUS:
		wpa_supplicant_event_interface_status(wpa_s, data);
		break;
	case EVENT_PMKID_CANDIDATE:
		wpa_supplicant_event_pmkid_candidate(wpa_s, data);
		break;
#ifdef CONFIG_PEERKEY
	case EVENT_STKSTART:
		wpa_supplicant_event_stkstart(wpa_s, data);
		break;
#endif /* CONFIG_PEERKEY */
#ifdef CONFIG_IEEE80211R
	case EVENT_FT_RESPONSE:
		wpa_supplicant_event_ft_response(wpa_s, data);
		break;
#endif /* CONFIG_IEEE80211R */
#ifdef CONFIG_IBSS_RSN
	case EVENT_IBSS_RSN_START:
		wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
		break;
#endif /* CONFIG_IBSS_RSN */
#ifdef CONFIG_AP
	case EVENT_TX_STATUS:
		wpa_printf(MSG_DEBUG, "EVENT_TX_STATUS on %s dst=" MACSTR
			   " type=%d stype=%d pending_dst=" MACSTR,
			   wpa_s->ifname, MAC2STR(data->tx_status.dst),
			   data->tx_status.type, data->tx_status.stype,
			   MAC2STR(wpa_s->parent->pending_action_dst));
		if (wpa_s->ap_iface == NULL) {
#ifdef CONFIG_P2P
			if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
			    data->tx_status.stype == WLAN_FC_STYPE_ACTION)
				wpas_send_action_tx_status(
					wpa_s, data->tx_status.dst,
					data->tx_status.data,
					data->tx_status.data_len,
					data->tx_status.ack);
#endif /* CONFIG_P2P */
			break;
		}
#ifdef CONFIG_P2P
		/*
		 * Catch TX status events for Action frames we sent via group
		 * interface in GO mode.
		 */
		if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
		    data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
		    os_memcmp(wpa_s->parent->pending_action_dst,
			      data->tx_status.dst, ETH_ALEN) == 0) {
			wpas_send_action_tx_status(
				wpa_s->parent, data->tx_status.dst,
				data->tx_status.data,
				data->tx_status.data_len,
				data->tx_status.ack);
			break;
		}
#endif /* CONFIG_P2P */
		switch (data->tx_status.type) {
		case WLAN_FC_TYPE_MGMT:
			ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
				      data->tx_status.data_len,
				      data->tx_status.stype,
				      data->tx_status.ack);
			break;
		case WLAN_FC_TYPE_DATA:
			ap_tx_status(wpa_s, data->tx_status.dst,
				     data->tx_status.data,
				     data->tx_status.data_len,
				     data->tx_status.ack);
			break;
		}
		break;
	case EVENT_RX_FROM_UNKNOWN:
		if (wpa_s->ap_iface == NULL)
			break;
		ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.frame,
				       data->rx_from_unknown.len);
		break;
	case EVENT_RX_MGMT:
		if (wpa_s->ap_iface == NULL) {
#ifdef CONFIG_P2P
			u16 fc, stype;
			const struct ieee80211_mgmt *mgmt;
			mgmt = (const struct ieee80211_mgmt *)
				data->rx_mgmt.frame;
			fc = le_to_host16(mgmt->frame_control);
			stype = WLAN_FC_GET_STYPE(fc);
			if (stype == WLAN_FC_STYPE_PROBE_REQ &&
			    data->rx_mgmt.frame_len > 24) {
				const u8 *src = mgmt->sa;
				const u8 *ie = mgmt->u.probe_req.variable;
				size_t ie_len = data->rx_mgmt.frame_len -
					(mgmt->u.probe_req.variable -
					 data->rx_mgmt.frame);
				wpas_p2p_probe_req_rx(wpa_s, src, ie, ie_len);
				break;
			}
#endif /* CONFIG_P2P */
			wpa_printf(MSG_DEBUG, "AP: ignore received management "
				   "frame in non-AP mode");
			break;
		}
		ap_mgmt_rx(wpa_s, &data->rx_mgmt);
		break;
#endif /* CONFIG_AP */
	case EVENT_RX_ACTION:
		wpa_printf(MSG_DEBUG, "Received Action frame: SA=" MACSTR
			   " Category=%u DataLen=%d freq=%d MHz",
			   MAC2STR(data->rx_action.sa),
			   data->rx_action.category, (int) data->rx_action.len,
			   data->rx_action.freq);
#ifdef CONFIG_IEEE80211R
		if (data->rx_action.category == WLAN_ACTION_FT) {
			ft_rx_action(wpa_s, data->rx_action.data,
				     data->rx_action.len);
			break;
		}
#endif /* CONFIG_IEEE80211R */
#ifdef CONFIG_P2P
		wpas_p2p_rx_action(wpa_s, data->rx_action.da,
				   data->rx_action.sa,
				   data->rx_action.bssid,
				   data->rx_action.category,
				   data->rx_action.data,
				   data->rx_action.len, data->rx_action.freq);
#endif /* CONFIG_P2P */
		break;
#ifdef CONFIG_P2P
	case EVENT_REMAIN_ON_CHANNEL:
		wpas_p2p_remain_on_channel_cb(
			wpa_s, data->remain_on_channel.freq,
			data->remain_on_channel.duration);
		break;
	case EVENT_CANCEL_REMAIN_ON_CHANNEL:
		wpas_p2p_cancel_remain_on_channel_cb(
			wpa_s, data->remain_on_channel.freq);
		break;
	case EVENT_RX_PROBE_REQ:
		wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
				      data->rx_probe_req.ie,
				      data->rx_probe_req.ie_len);
		break;
#endif /* CONFIG_P2P */
	case EVENT_EAPOL_RX:
		wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
					data->eapol_rx.data,
					data->eapol_rx.data_len);
		break;
	case EVENT_INTERFACE_ENABLED:
		wpa_printf(MSG_DEBUG, "Interface was enabled");
		if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
			wpa_supplicant_set_state(wpa_s,
						 WPA_DISCONNECTED);
			wpa_supplicant_req_scan(wpa_s, 0, 0);
		}
		break;
	case EVENT_INTERFACE_DISABLED:
		wpa_printf(MSG_DEBUG, "Interface was disabled");
		wpa_supplicant_mark_disassoc(wpa_s);
		wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
		break;
	default:
		wpa_printf(MSG_INFO, "Unknown event %d", event);
		break;
	}
}