summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-12-09 01:33:40 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2010-12-15 20:43:49 +0100
commitaae3b737cd558459673f3d3896188d169e7bd50f (patch)
treefee8d4a4374990f25e7f98a43220daa3324e2320 /gsupplicant
parent3a468316c62172f89e3b4d2a9750c46466c7f477 (diff)
downloadconnman-aae3b737cd558459673f3d3896188d169e7bd50f.tar.gz
connman-aae3b737cd558459673f3d3896188d169e7bd50f.tar.bz2
connman-aae3b737cd558459673f3d3896188d169e7bd50f.zip
gsupplicant: Country setting implementation
This implements the Country wpa_supplicant global property setting, in order to be able to set a regulatory domain.
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/gsupplicant.h7
-rw-r--r--gsupplicant/supplicant.c68
2 files changed, 75 insertions, 0 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index c6ecf788..1da96614 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -114,6 +114,13 @@ struct _GSupplicantSSID {
typedef struct _GSupplicantSSID GSupplicantSSID;
+/* global API */
+typedef void (*GSupplicantCountryCallback) (void *user_data);
+
+int g_supplicant_set_country(const char *alpha2,
+ GSupplicantCountryCallback callback,
+ const void *user_data);
+
/* Interface API */
struct _GSupplicantInterface;
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 0e4f932b..934ad1c2 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -1455,6 +1455,11 @@ static void service_property(const char *key, DBusMessageIter *iter,
} else if (g_strcmp0(key, "EapMethods") == 0) {
supplicant_dbus_array_foreach(iter, eap_method, NULL);
debug_strvalmap("EAP method", eap_method_map, eap_methods);
+ } else if (g_strcmp0(key, "Country") == 0) {
+ const char *country = NULL;
+
+ dbus_message_iter_get_basic(iter, &country);
+ SUPPLICANT_DBG("Country %s", country);
} else
SUPPLICANT_DBG("key %s type %c",
key, dbus_message_iter_get_arg_type(iter));
@@ -1699,6 +1704,69 @@ static DBusHandlerResult g_supplicant_filter(DBusConnection *conn,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+struct supplicant_regdom {
+ GSupplicantCountryCallback callback;
+ const void *user_data;
+};
+
+static void country_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct supplicant_regdom *regdom = user_data;
+ char *alpha2;
+
+ SUPPLICANT_DBG("Country setting result");
+
+ if (user_data == NULL)
+ return;
+
+ if (error == NULL) {
+ alpha2 = (char *)regdom->user_data;
+ } else {
+ SUPPLICANT_DBG("Country setting failure %s", error);
+ alpha2 = NULL;
+ }
+
+ if (regdom->callback)
+ regdom->callback(alpha2);
+
+ g_free(regdom);
+}
+
+static void country_params(DBusMessageIter *iter, void *user_data)
+{
+ struct supplicant_regdom *regdom = user_data;
+ const char *country;
+
+ country = regdom->user_data;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &country);
+}
+
+int g_supplicant_set_country(const char *alpha2,
+ GSupplicantCountryCallback callback,
+ const void *user_data)
+{
+ struct supplicant_regdom *regdom;
+
+ SUPPLICANT_DBG("Country setting %s", alpha2);
+
+ if (system_available == FALSE)
+ return -EFAULT;
+
+ regdom = dbus_malloc0(sizeof(*regdom));
+ if (regdom == NULL)
+ return -ENOMEM;
+
+ regdom->callback = callback;
+ regdom->user_data = user_data;
+
+ return supplicant_dbus_property_set(SUPPLICANT_PATH, SUPPLICANT_INTERFACE,
+ "Country", DBUS_TYPE_STRING_AS_STRING,
+ country_params, country_result,
+ regdom);
+}
+
struct interface_data {
GSupplicantInterface *interface;
GSupplicantInterfaceCallback callback;