Browse Source

Add wpa_supplicant AP mode events for Public Action frames

Jouni Malinen 15 years ago
parent
commit
c706d5aa17
6 changed files with 52 additions and 4 deletions
  1. 3 4
      src/ap/hostapd.c
  2. 5 0
      src/ap/hostapd.h
  3. 8 0
      src/ap/ieee802_11.c
  4. 24 0
      wpa_supplicant/ap.c
  5. 8 0
      wpa_supplicant/mlme.c
  6. 4 0
      wpa_supplicant/wpa_supplicant_i.h

+ 3 - 4
src/ap/hostapd.c

@@ -689,7 +689,6 @@ static int setup_interface(struct hostapd_iface *iface)
 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
 {
 	struct hostapd_data *hapd = iface->bss[0];
-	int freq;
 	size_t j;
 	u8 *prev_addr;
 
@@ -701,13 +700,13 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
 
 	wpa_printf(MSG_DEBUG, "Completing interface initialization");
 	if (hapd->iconf->channel) {
-		freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
+		iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
 		wpa_printf(MSG_DEBUG, "Mode: %s  Channel: %d  "
 			   "Frequency: %d MHz",
 			   hostapd_hw_mode_txt(hapd->iconf->hw_mode),
-			   hapd->iconf->channel, freq);
+			   hapd->iconf->channel, iface->freq);
 
-		if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, freq,
+		if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
 				     hapd->iconf->channel,
 				     hapd->iconf->ieee80211n,
 				     hapd->iconf->secondary_channel)) {

+ 5 - 0
src/ap/hostapd.h

@@ -172,6 +172,10 @@ struct hostapd_data {
 	struct hostapd_probereq_cb *probereq_cb;
 	size_t num_probereq_cb;
 
+	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
+				 int freq);
+	void *public_action_cb_ctx;
+
 	void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
 				   const u8 *uuid_e);
 	void *wps_reg_success_cb_ctx;
@@ -204,6 +208,7 @@ struct hostapd_iface {
 	 * current_mode->channels */
 	int num_rates;
 	struct hostapd_rate_data *current_rates;
+	int freq;
 
 	u16 hw_flags;
 

+ 8 - 0
src/ap/ieee802_11.c

@@ -1355,6 +1355,14 @@ static void handle_action(struct hostapd_data *hapd,
 		hostapd_sa_query_action(hapd, mgmt, len);
 		return;
 #endif /* CONFIG_IEEE80211W */
+	case WLAN_ACTION_PUBLIC:
+		if (hapd->public_action_cb) {
+			hapd->public_action_cb(hapd->public_action_cb_ctx,
+					       (u8 *) mgmt, len,
+					       hapd->iface->freq);
+			return;
+		}
+		break;
 	}
 
 	hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,

+ 24 - 0
wpa_supplicant/ap.c

@@ -135,6 +135,24 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
 }
 
 
+static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
+{
+}
+
+
+static int ap_probe_req_rx(void *ctx, const u8 *addr, const u8 *ie,
+			   size_t ie_len)
+{
+	return 0;
+}
+
+
+static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
+				  const u8 *uuid_e)
+{
+}
+
+
 int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
 			     struct wpa_ssid *ssid)
 {
@@ -229,6 +247,12 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
 		}
 
 		hapd_iface->bss[i]->msg_ctx = wpa_s;
+		hapd_iface->bss[i]->public_action_cb = ap_public_action_rx;
+		hapd_iface->bss[i]->public_action_cb_ctx = wpa_s;
+		hostapd_register_probereq_cb(hapd_iface->bss[i],
+					     ap_probe_req_rx, wpa_s);
+		hapd_iface->bss[i]->wps_reg_success_cb = ap_wps_reg_success_cb;
+		hapd_iface->bss[i]->wps_reg_success_cb_ctx = wpa_s;
 	}
 
 	os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);

+ 8 - 0
wpa_supplicant/mlme.c

@@ -1976,6 +1976,14 @@ static void ieee80211_rx_mgmt_action(struct wpa_supplicant *wpa_s,
 	case WLAN_ACTION_WMM:
 		ieee80211_rx_mgmt_wmm_action(wpa_s, mgmt, len, rx_status);
 		break;
+	case WLAN_ACTION_PUBLIC:
+		if (wpa_s->mlme.public_action_cb) {
+			wpa_s->mlme.public_action_cb(
+				wpa_s->mlme.public_action_cb_ctx,
+				(u8 *) mgmt, len, rx_status->freq);
+			return;
+		}
+		break;
 	default:
 		wpa_printf(MSG_DEBUG, "MLME: unknown Action Category %d",
 			   mgmt->u.action.category);

+ 4 - 0
wpa_supplicant/wpa_supplicant_i.h

@@ -284,6 +284,10 @@ struct wpa_client_mlme {
 	size_t ft_ies_len;
 #endif /* CONFIG_IEEE80211R */
 
+	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
+				 int freq);
+	void *public_action_cb_ctx;
+
 #else /* CONFIG_CLIENT_MLME */
 	int dummy; /* to keep MSVC happy */
 #endif /* CONFIG_CLIENT_MLME */