diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index d3698f8f7..49a0895d1 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 f816bef78..68e5465db 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -2243,6 +2243,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 diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index be7a9bf6a..742d33c98 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);