[PATCH] dbus: add support to get/set the country code
Sam Leffler
sleffler
Fri Apr 1 15:55:34 PDT 2011
Add an Interface.Country property and support to get/set the value.
Change-Id: Ibe909e89f59315477c45b2b4a8a004de13d9b8c3
Signed-off-by: Sam Leffler <sleffler at chromium.org>
---
wpa_supplicant/dbus/dbus_new.c | 5 +++
wpa_supplicant/dbus/dbus_new_handlers.c | 58 +++++++++++++++++++++++++++++++
wpa_supplicant/dbus/dbus_new_handlers.h | 6 +++
3 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index d3698f8..49a0895 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1396,6 +1396,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
(WPADBusPropertyAccessor) wpas_dbus_setter_bss_expire_count,
RW
},
+ { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_country,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_country,
+ RW
+ },
{ "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
(WPADBusPropertyAccessor) wpas_dbus_getter_ifname,
NULL, R
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 0808613..e954020 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2258,6 +2258,64 @@ DBusMessage * wpas_dbus_setter_bss_expire_count(DBusMessage *message,
/**
+ * wpas_dbus_getter_country - Control country code
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: A message containong value of country variable
+ *
+ * Getter function for "Country" property.
+ */
+DBusMessage * wpas_dbus_getter_country(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ char country[3];
+ char *str = country;
+
+ country[0] = wpa_s->conf->country[0];
+ country[1] = wpa_s->conf->country[1];
+ country[2] = '\0';
+
+ return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
+ &str);
+}
+
+
+/**
+ * wpas_dbus_setter_country - Control country code
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: NULL
+ *
+ * Setter function for "Country" property.
+ */
+DBusMessage * wpas_dbus_setter_country(DBusMessage *message,
+ struct wpa_supplicant *wpa_s)
+{
+ DBusMessage *reply = NULL;
+ const char *country;
+
+ reply = wpas_dbus_simple_property_setter(message, DBUS_TYPE_STRING,
+ &country);
+ if (reply)
+ return reply;
+
+ if (!country[0] || !country[1])
+ return wpas_dbus_error_invalid_args(message,
+ "invalid country code");
+
+ if (wpa_s->drv_priv != NULL && wpa_drv_set_country(wpa_s, country)) {
+ wpa_printf(MSG_DEBUG, "Failed to set country");
+ return wpas_dbus_error_invalid_args(
+ message, "failed to set country code");
+ }
+
+ wpa_s->conf->country[0] = country[0];
+ wpa_s->conf->country[1] = country[1];
+ return NULL;
+}
+
+
+/**
* wpas_dbus_getter_ifname - Get interface name
* @message: Pointer to incoming dbus message
* @wpa_s: wpa_supplicant structure for a network interface
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index be7a9bf..742d33c 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -128,6 +128,12 @@ DBusMessage * wpas_dbus_getter_bss_expire_count(DBusMessage *message,
DBusMessage * wpas_dbus_setter_bss_expire_count(DBusMessage *message,
struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_getter_country(DBusMessage *message,
+ struct wpa_supplicant *wpa_s);
+
+DBusMessage * wpas_dbus_setter_country(DBusMessage *message,
+ struct wpa_supplicant *wpa_s);
+
DBusMessage * wpas_dbus_getter_ifname(DBusMessage *message,
struct wpa_supplicant *wpa_s);
--
1.7.3.1
More information about the Hostap
mailing list