3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 02:19:26 +01:00

ap: change PairwiseCiphers to string array

A comma separated list as a string was ok for pure display purposes
but if any processing needed to be done on these values by external
consumers it really makes more sense to use a DBus array.
This commit is contained in:
James Prestwood 2022-11-04 09:37:58 -07:00 committed by Denis Kenzior
parent 809067c924
commit 55924fbb56

View File

@ -3154,11 +3154,10 @@ 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) static char **ap_ciphers_to_strv(uint16_t ciphers)
{ {
uint16_t i; uint16_t i;
char **list = l_strv_new(); char **list = l_strv_new();
char *ret;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (!(ciphers & (1 << i))) if (!(ciphers & (1 << i)))
@ -3168,9 +3167,7 @@ static char *ap_ciphers_to_string(uint16_t ciphers)
ie_rsn_cipher_suite_to_string(1 << i)); ie_rsn_cipher_suite_to_string(1 << i));
} }
ret = l_strjoinv(list, ','); return 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,
@ -4096,15 +4093,22 @@ static bool ap_dbus_property_get_pairwise(struct l_dbus *dbus,
void *user_data) void *user_data)
{ {
struct ap_if_data *ap_if = user_data; struct ap_if_data *ap_if = user_data;
char *list; char **ciphers;
size_t i;
if (!ap_if->ap || !ap_if->ap->started) if (!ap_if->ap || !ap_if->ap->started)
return false; return false;
list = ap_ciphers_to_string(ap_if->ap->ciphers); ciphers = ap_ciphers_to_strv(ap_if->ap->ciphers);
l_dbus_message_builder_append_basic(builder, 's', list); l_dbus_message_builder_enter_array(builder, "s");
l_free(list);
for (i = 0; ciphers[i]; i++)
l_dbus_message_builder_append_basic(builder, 's', ciphers[i]);
l_dbus_message_builder_leave_array(builder);
l_strv_free(ciphers);
return true; return true;
} }
@ -4115,15 +4119,16 @@ static bool ap_dbus_property_get_group(struct l_dbus *dbus,
void *user_data) void *user_data)
{ {
struct ap_if_data *ap_if = user_data; struct ap_if_data *ap_if = user_data;
char *cipher; char **cipher;
if (!ap_if->ap || !ap_if->ap->started) if (!ap_if->ap || !ap_if->ap->started)
return false; return false;
cipher = ap_ciphers_to_string(ap_if->ap->group_cipher); cipher = ap_ciphers_to_strv(ap_if->ap->group_cipher);
l_dbus_message_builder_append_basic(builder, 's', cipher); /* Group cipher will only ever be a single value */
l_free(cipher); l_dbus_message_builder_append_basic(builder, 's', cipher[0]);
l_strv_free(cipher);
return true; return true;
} }
@ -4149,7 +4154,7 @@ 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", l_dbus_interface_property(interface, "PairwiseCiphers", 0, "as",
ap_dbus_property_get_pairwise, NULL); ap_dbus_property_get_pairwise, NULL);
l_dbus_interface_property(interface, "GroupCipher", 0, "s", l_dbus_interface_property(interface, "GroupCipher", 0, "s",
ap_dbus_property_get_group, NULL); ap_dbus_property_get_group, NULL);