3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

ap: add PairwiseCiphers/GroupCipher to dbus interface

Expose these values on the DBus interface so clients can view them.
This commit is contained in:
James Prestwood 2022-11-02 15:51:11 -07:00 committed by Denis Kenzior
parent 2b64b493d0
commit 0363d51c5c

View File

@ -3154,6 +3154,25 @@ static enum ie_rsn_cipher_suite ap_string_to_cipher(const char *str)
return 0; return 0;
} }
static char *ap_ciphers_to_string(uint16_t ciphers)
{
uint16_t i;
char **list = l_strv_new();
char *ret;
for (i = 0; i < 16; i++) {
if (!(ciphers & (1 << i)))
continue;
list = l_strv_append(list,
ie_rsn_cipher_suite_to_string(1 << i));
}
ret = l_strjoinv(list, ',');
l_strv_free(list);
return ret;
}
static int ap_load_config(struct ap_state *ap, const struct l_settings *config, static int ap_load_config(struct ap_state *ap, const struct l_settings *config,
bool *out_cck_rates) bool *out_cck_rates)
{ {
@ -3690,6 +3709,12 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
l_dbus_property_changed(dbus_get_bus(), l_dbus_property_changed(dbus_get_bus(),
netdev_get_path(ap_if->netdev), netdev_get_path(ap_if->netdev),
IWD_AP_INTERFACE, "Name"); IWD_AP_INTERFACE, "Name");
l_dbus_property_changed(dbus_get_bus(),
netdev_get_path(ap_if->netdev),
IWD_AP_INTERFACE, "PairwiseCiphers");
l_dbus_property_changed(dbus_get_bus(),
netdev_get_path(ap_if->netdev),
IWD_AP_INTERFACE, "GroupCipher");
l_rtnl_set_linkmode_and_operstate(rtnl, l_rtnl_set_linkmode_and_operstate(rtnl,
netdev_get_ifindex(ap_if->netdev), netdev_get_ifindex(ap_if->netdev),
@ -3711,6 +3736,12 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,
l_dbus_property_changed(dbus_get_bus(), l_dbus_property_changed(dbus_get_bus(),
netdev_get_path(ap_if->netdev), netdev_get_path(ap_if->netdev),
IWD_AP_INTERFACE, "Frequency"); IWD_AP_INTERFACE, "Frequency");
l_dbus_property_changed(dbus_get_bus(),
netdev_get_path(ap_if->netdev),
IWD_AP_INTERFACE, "PairwiseCiphers");
l_dbus_property_changed(dbus_get_bus(),
netdev_get_path(ap_if->netdev),
IWD_AP_INTERFACE, "GroupCipher");
l_rtnl_set_linkmode_and_operstate(rtnl, l_rtnl_set_linkmode_and_operstate(rtnl,
netdev_get_ifindex(ap_if->netdev), netdev_get_ifindex(ap_if->netdev),
@ -4061,6 +4092,44 @@ static bool ap_dbus_property_get_freq(struct l_dbus *dbus,
return true; return true;
} }
static bool ap_dbus_property_get_pairwise(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message_builder *builder,
void *user_data)
{
struct ap_if_data *ap_if = user_data;
char *list;
if (!ap_if->ap || !ap_if->ap->started)
return false;
list = ap_ciphers_to_string(ap_if->ap->ciphers);
l_dbus_message_builder_append_basic(builder, 's', list);
l_free(list);
return true;
}
static bool ap_dbus_property_get_group(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message_builder *builder,
void *user_data)
{
struct ap_if_data *ap_if = user_data;
char *cipher;
if (!ap_if->ap || !ap_if->ap->started)
return false;
cipher = ap_ciphers_to_string(ap_if->ap->group_cipher);
l_dbus_message_builder_append_basic(builder, 's', cipher);
l_free(cipher);
return true;
}
static void ap_setup_interface(struct l_dbus_interface *interface) static void ap_setup_interface(struct l_dbus_interface *interface)
{ {
l_dbus_interface_method(interface, "Start", 0, ap_dbus_start, "", l_dbus_interface_method(interface, "Start", 0, ap_dbus_start, "",
@ -4082,6 +4151,10 @@ static void ap_setup_interface(struct l_dbus_interface *interface)
ap_dbus_property_get_scanning, NULL); ap_dbus_property_get_scanning, NULL);
l_dbus_interface_property(interface, "Frequency", 0, "u", l_dbus_interface_property(interface, "Frequency", 0, "u",
ap_dbus_property_get_freq, NULL); ap_dbus_property_get_freq, NULL);
l_dbus_interface_property(interface, "PairwiseCiphers", 0, "s",
ap_dbus_property_get_pairwise, NULL);
l_dbus_interface_property(interface, "GroupCipher", 0, "s",
ap_dbus_property_get_group, NULL);
} }
static void ap_destroy_interface(void *user_data) static void ap_destroy_interface(void *user_data)