dbus: Add support to get/set the country code
Add an Interface.Country property and support to get/set the value. Signed-off-by: Sam Leffler <sleffler@chromium.org>
This commit is contained in:
parent
d9040cdb10
commit
9768da202b
3 changed files with 69 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue