diff mbox series

[03/25] Make channel_info and get_sta available to authenticator

Message ID 20180806194643.1328-4-Mathy.Vanhoef@cs.kuleuven.be
State Accepted
Headers show
Series Add support for Operating Channel Validation (OCV) | expand

Commit Message

Mathy Vanhoef Aug. 6, 2018, 7:46 p.m. UTC
This adds the necessary functions and callbacks to make the channel_info
driver API available to the authenticator state machine that implements
the 4-way and group key handshake. It also makes the get_sta function
available.

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
---
 src/ap/ap_drv_ops.h    |  8 ++++++++
 src/ap/wpa_auth.c      | 19 +++++++++++++++++++
 src/ap/wpa_auth.h      |  3 +++
 src/ap/wpa_auth_glue.c | 17 +++++++++++++++++
 4 files changed, 47 insertions(+)
diff mbox series

Patch

diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h
index db93fde7d..c01d44200 100644
--- a/src/ap/ap_drv_ops.h
+++ b/src/ap/ap_drv_ops.h
@@ -356,4 +356,12 @@  static inline int hostapd_drv_stop_ap(struct hostapd_data *hapd)
 	return hapd->driver->stop_ap(hapd->drv_priv);
 }
 
+static inline int hostapd_drv_channel_info(struct hostapd_data *hapd,
+					   struct wpa_channel_info *ci)
+{
+	if (hapd->driver == NULL || hapd->driver->channel_info == NULL)
+		return 0;
+	return hapd->driver->channel_info(hapd->drv_priv, ci);
+}
+
 #endif /* AP_DRV_OPS */
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index 126d98c9f..f20dd806a 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -22,12 +22,14 @@ 
 #include "crypto/sha384.h"
 #include "crypto/random.h"
 #include "eapol_auth/eapol_auth_sm.h"
+#include "drivers/driver.h"
 #include "ap_config.h"
 #include "ieee802_11.h"
 #include "wpa_auth.h"
 #include "pmksa_cache_auth.h"
 #include "wpa_auth_i.h"
 #include "wpa_auth_ie.h"
+#include "sta_info.h"
 
 #define STATE_MACHINE_DATA struct wpa_state_machine
 #define STATE_MACHINE_DEBUG_PREFIX "WPA"
@@ -238,6 +240,23 @@  static void wpa_sta_disconnect(struct wpa_authenticator *wpa_auth,
 }
 
 
+static int wpa_channel_info(struct wpa_authenticator *wpa_auth,
+			    struct wpa_channel_info *ci)
+{
+	if (wpa_auth->cb->channel_info == NULL)
+		return -1;
+	return wpa_auth->cb->channel_info(wpa_auth->cb_ctx, ci);
+}
+
+
+static struct sta_info * wpa_get_sta(struct wpa_authenticator *wpa_auth,
+				     const u8 *addr)
+{
+	if (wpa_auth->cb->get_sta == NULL)
+		return NULL;
+	return wpa_auth->cb->get_sta(wpa_auth->cb_ctx, addr);
+}
+
 static void wpa_rekey_gmk(void *eloop_ctx, void *timeout_ctx)
 {
 	struct wpa_authenticator *wpa_auth = eloop_ctx;
diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
index fad5536f7..5837c3e9f 100644
--- a/src/ap/wpa_auth.h
+++ b/src/ap/wpa_auth.h
@@ -145,6 +145,7 @@  struct wpa_state_machine;
 struct rsn_pmksa_cache_entry;
 struct eapol_state_machine;
 struct ft_remote_seq;
+struct wpa_channel_info;
 
 
 struct ft_remote_r0kh {
@@ -265,6 +266,8 @@  struct wpa_auth_callbacks {
 			  size_t data_len);
 	int (*send_oui)(void *ctx, const u8 *dst, u8 oui_suffix, const u8 *data,
 			size_t data_len);
+	int (*channel_info)(void *ctx, struct wpa_channel_info *ci);
+	struct sta_info * (*get_sta)(void *ctx, const u8 *addr);
 #ifdef CONFIG_IEEE80211R_AP
 	struct wpa_state_machine * (*add_sta)(void *ctx, const u8 *sta_addr);
 	int (*set_vlan)(void *ctx, const u8 *sta_addr,
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index 812740301..754b04462 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -775,6 +775,21 @@  static int hostapd_wpa_auth_send_oui(void *ctx, const u8 *dst, u8 oui_suffix,
 #endif /* CONFIG_ETH_P_OUI */
 }
 
+int hostapd_channel_info(void *ctx, struct wpa_channel_info *ci)
+{
+	struct hostapd_data *hapd = ctx;
+
+	if (hostapd_drv_channel_info(hapd, ci) != 0)
+		return -1;
+
+	return 0;
+}
+
+struct sta_info * hostapd_get_sta(void *ctx, const u8 *addr)
+{
+	struct hostapd_data *hapd = ctx;
+	return ap_get_sta(hapd, addr);
+}
 
 #ifdef CONFIG_IEEE80211R_AP
 
@@ -1202,6 +1217,8 @@  int hostapd_setup_wpa(struct hostapd_data *hapd)
 		.set_session_timeout = hostapd_wpa_auth_set_session_timeout,
 		.get_session_timeout = hostapd_wpa_auth_get_session_timeout,
 #endif /* CONFIG_IEEE80211R_AP */
+		.channel_info = hostapd_channel_info,
+		.get_sta = hostapd_get_sta
 	};
 	const u8 *wpa_ie;
 	size_t wpa_ie_len;