[v2,2/2] dbus: Add FILS capability

Message ID 1517709037-5015-2-git-send-email-masashi.honma@gmail.com
State Accepted
Headers show
Series
  • [v2,1/2] wpa_cli: Fix duplicate const warning
Related show

Commit Message

Masashi Honma Feb. 4, 2018, 1:50 a.m.
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 wpa_supplicant/ctrl_iface.c             | 40 +++++----------------------------
 wpa_supplicant/dbus/dbus_new_handlers.c | 17 +++++++++++++-
 wpa_supplicant/wpa_supplicant.c         | 29 ++++++++++++++++++++++++
 wpa_supplicant/wpa_supplicant_i.h       |  3 +++
 4 files changed, 53 insertions(+), 36 deletions(-)

Comments

Jouni Malinen April 2, 2018, 10:30 a.m. | #1
Thanks, applied.

Patch

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9ad39b8..b6755bc 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -64,28 +64,6 @@  static int * freq_range_to_channel_list(struct wpa_supplicant *wpa_s,
 					char *val);
 
 
-#ifdef CONFIG_FILS
-
-static int wpa_is_fils_supported(struct wpa_supplicant *wpa_s)
-{
-	return (((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
-		 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_FILS)) ||
-		(!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
-		 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_FILS_SK_OFFLOAD)));
-}
-
-
-#ifdef CONFIG_FILS_SK_PFS
-static int wpa_is_fils_sk_pfs_supported(struct wpa_supplicant *wpa_s)
-{
-	return (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
-		(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_FILS);
-}
-#endif /* CONFIG_FILS_SK_PFS */
-
-#endif /* CONFIG_FILS */
-
-
 static int set_bssid_filter(struct wpa_supplicant *wpa_s, char *val)
 {
 	char *pos;
@@ -4093,8 +4071,7 @@  static int ctrl_iface_get_capability_auth_alg(struct wpa_supplicant *wpa_s,
 	}
 #endif /* CONFIG_SAE */
 
-#ifdef CONFIG_FILS
-	if (wpa_is_fils_supported(wpa_s)) {
+	if (wpas_is_fils_supported(wpa_s)) {
 		ret = os_snprintf(pos, end - pos, "%sFILS_SK_WITHOUT_PFS",
 				  pos == buf ? "" : " ");
 		if (os_snprintf_error(end - pos, ret))
@@ -4102,16 +4079,13 @@  static int ctrl_iface_get_capability_auth_alg(struct wpa_supplicant *wpa_s,
 		pos += ret;
 	}
 
-#ifdef CONFIG_FILS_SK_PFS
-	if (wpa_is_fils_sk_pfs_supported(wpa_s)) {
+	if (wpas_is_fils_sk_pfs_supported(wpa_s)) {
 		ret = os_snprintf(pos, end - pos, "%sFILS_SK_WITH_PFS",
 				  pos == buf ? "" : " ");
 		if (os_snprintf_error(end - pos, ret))
 			return pos - buf;
 		pos += ret;
 	}
-#endif /* CONFIG_FILS_SK_PFS */
-#endif /* CONFIG_FILS */
 
 	return pos - buf;
 }
@@ -4370,26 +4344,22 @@  static int wpa_supplicant_ctrl_iface_get_capability(
 	}
 #endif /* CONFIG_ACS */
 
-#ifdef CONFIG_FILS
 	if (os_strcmp(field, "fils") == 0) {
-#ifdef CONFIG_FILS_SK_PFS
-		if (wpa_is_fils_supported(wpa_s) &&
-		    wpa_is_fils_sk_pfs_supported(wpa_s)) {
+		if (wpas_is_fils_supported(wpa_s) &&
+		    wpas_is_fils_sk_pfs_supported(wpa_s)) {
 			res = os_snprintf(buf, buflen, "FILS FILS-SK-PFS");
 			if (os_snprintf_error(buflen, res))
 				return -1;
 			return res;
 		}
-#endif /* CONFIG_FILS_SK_PFS */
 
-		if (wpa_is_fils_supported(wpa_s)) {
+		if (wpas_is_fils_supported(wpa_s)) {
 			res = os_snprintf(buf, buflen, "FILS");
 			if (os_snprintf_error(buflen, res))
 				return -1;
 			return res;
 		}
 	}
-#endif /* CONFIG_FILS */
 
 	wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown GET_CAPABILITY field '%s'",
 		   field);
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index e31b733..90bf0d9 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -980,9 +980,20 @@  dbus_bool_t wpas_dbus_getter_global_capabilities(
 	const struct wpa_dbus_property_desc *property_desc,
 	DBusMessageIter *iter, DBusError *error, void *user_data)
 {
-	const char *capabilities[5] = { NULL, NULL, NULL, NULL, NULL };
+	struct wpa_global *global = user_data;
+	struct wpa_supplicant *wpa_s;
+	int fils_supported = 0, fils_sk_pfs_supported = 0;
+	const char *capabilities[7] = { NULL, NULL, NULL, NULL, NULL, NULL,
+					NULL };
 	size_t num_items = 0;
 
+	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+		if (wpas_is_fils_supported(wpa_s))
+			fils_supported = 1;
+		if (wpas_is_fils_sk_pfs_supported(wpa_s))
+			fils_sk_pfs_supported = 1;
+	}
+
 #ifdef CONFIG_AP
 	capabilities[num_items++] = "ap";
 #endif /* CONFIG_AP */
@@ -998,6 +1009,10 @@  dbus_bool_t wpas_dbus_getter_global_capabilities(
 #ifdef CONFIG_IEEE80211W
 	capabilities[num_items++] = "pmf";
 #endif /* CONFIG_IEEE80211W */
+	if (fils_supported)
+		capabilities[num_items++] = "fils";
+	if (fils_sk_pfs_supported)
+		capabilities[num_items++] = "fils_sk_pfs";
 
 	return wpas_dbus_simple_array_property_getter(iter,
 						      DBUS_TYPE_STRING,
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 4209c41..dc5ce73 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2337,6 +2337,35 @@  static size_t wpas_add_fils_hlp_req(struct wpa_supplicant *wpa_s, u8 *ie_buf,
 
 	return ie_len;
 }
+
+
+int wpas_is_fils_supported(struct wpa_supplicant *wpa_s)
+{
+	return (((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
+		 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_FILS)) ||
+		(!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
+		 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_FILS_SK_OFFLOAD)));
+}
+
+
+int wpas_is_fils_sk_pfs_supported(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_FILS_SK_PFS
+	return (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
+		(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_FILS);
+#else /* CONFIG_FILS_SK_PFS */
+	return 0;
+#endif /* CONFIG_FILS_SK_PFS */
+}
+#else /* CONFIG_FILS */
+int wpas_is_fils_supported(struct wpa_supplicant *wpa_s)
+{
+	return 0;
+}
+int wpas_is_fils_sk_pfs_supported(struct wpa_supplicant *wpa_s)
+{
+	return 0;
+}
 #endif /* CONFIG_FILS */
 
 
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index b154d3e..4a735ae 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1474,4 +1474,7 @@  int wpas_ctrl_iface_get_pref_freq_list_override(struct wpa_supplicant *wpa_s,
 						unsigned int *num,
 						unsigned int *freq_list);
 
+int wpas_is_fils_supported(struct wpa_supplicant *wpa_s);
+int wpas_is_fils_sk_pfs_supported(struct wpa_supplicant *wpa_s);
+
 #endif /* WPA_SUPPLICANT_I_H */