mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 08:18:03 +02:00
supplicant: convert interface/config to GDBus
(cherry picked from commit 59c8192b22)
This commit is contained in:
parent
7ea33e5c92
commit
0de28bd08b
8 changed files with 912 additions and 1120 deletions
|
|
@ -156,7 +156,7 @@ static void supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
||||||
|
|
||||||
static void supplicant_iface_new_bss_cb (NMSupplicantInterface * iface,
|
static void supplicant_iface_new_bss_cb (NMSupplicantInterface * iface,
|
||||||
const char *object_path,
|
const char *object_path,
|
||||||
GHashTable *properties,
|
GVariant *properties,
|
||||||
NMDeviceWifi * self);
|
NMDeviceWifi * self);
|
||||||
|
|
||||||
static void supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
|
static void supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
|
||||||
|
|
@ -1832,7 +1832,7 @@ schedule_scanlist_cull (NMDeviceWifi *self)
|
||||||
static void
|
static void
|
||||||
supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
||||||
const char *object_path,
|
const char *object_path,
|
||||||
GHashTable *properties,
|
GVariant *properties,
|
||||||
NMDeviceWifi *self)
|
NMDeviceWifi *self)
|
||||||
{
|
{
|
||||||
NMDeviceState state;
|
NMDeviceState state;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
#include "nm-dbus-manager.h"
|
#include "nm-dbus-manager.h"
|
||||||
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
#include "nm-setting-wireless.h"
|
#include "nm-setting-wireless.h"
|
||||||
#include "nm-glib-compat.h"
|
#include "nm-glib-compat.h"
|
||||||
|
|
@ -330,163 +331,131 @@ nm_ap_new (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static NM80211ApSecurityFlags
|
static NM80211ApSecurityFlags
|
||||||
pair_to_flags (const char *str)
|
security_from_vardict (GVariant *security)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (str != NULL, NM_802_11_AP_SEC_NONE);
|
|
||||||
|
|
||||||
if (strcmp (str, "tkip") == 0)
|
|
||||||
return NM_802_11_AP_SEC_PAIR_TKIP;
|
|
||||||
if (strcmp (str, "ccmp") == 0)
|
|
||||||
return NM_802_11_AP_SEC_PAIR_CCMP;
|
|
||||||
return NM_802_11_AP_SEC_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NM80211ApSecurityFlags
|
|
||||||
group_to_flags (const char *str)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (str != NULL, NM_802_11_AP_SEC_NONE);
|
|
||||||
|
|
||||||
if (strcmp (str, "wep40") == 0)
|
|
||||||
return NM_802_11_AP_SEC_GROUP_WEP40;
|
|
||||||
if (strcmp (str, "wep104") == 0)
|
|
||||||
return NM_802_11_AP_SEC_GROUP_WEP104;
|
|
||||||
if (strcmp (str, "tkip") == 0)
|
|
||||||
return NM_802_11_AP_SEC_GROUP_TKIP;
|
|
||||||
if (strcmp (str, "ccmp") == 0)
|
|
||||||
return NM_802_11_AP_SEC_GROUP_CCMP;
|
|
||||||
return NM_802_11_AP_SEC_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NM80211ApSecurityFlags
|
|
||||||
security_from_dict (GHashTable *security)
|
|
||||||
{
|
|
||||||
GValue *value;
|
|
||||||
NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE;
|
NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE;
|
||||||
const char **items, **iter;
|
const char **array, *tmp;
|
||||||
|
|
||||||
value = g_hash_table_lookup (security, "KeyMgmt");
|
g_return_val_if_fail (g_variant_is_of_type (security, G_VARIANT_TYPE_VARDICT), NM_802_11_AP_SEC_NONE);
|
||||||
if (value) {
|
|
||||||
items = g_value_get_boxed (value);
|
if (g_variant_lookup (security, "KeyMgmt", "^a&s", &array)) {
|
||||||
for (iter = items; iter && *iter; iter++) {
|
if (_nm_utils_string_in_list ("wpa-psk", array))
|
||||||
if (strcmp (*iter, "wpa-psk") == 0)
|
flags |= NM_802_11_AP_SEC_KEY_MGMT_PSK;
|
||||||
flags |= NM_802_11_AP_SEC_KEY_MGMT_PSK;
|
if (_nm_utils_string_in_list ("wpa-eap", array))
|
||||||
else if (strcmp (*iter, "wpa-eap") == 0)
|
flags |= NM_802_11_AP_SEC_KEY_MGMT_802_1X;
|
||||||
flags |= NM_802_11_AP_SEC_KEY_MGMT_802_1X;
|
g_free (array);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value = g_hash_table_lookup (security, "Pairwise");
|
if (g_variant_lookup (security, "Pairwise", "^a&s", &array)) {
|
||||||
if (value) {
|
if (_nm_utils_string_in_list ("tkip", array))
|
||||||
items = g_value_get_boxed (value);
|
flags |= NM_802_11_AP_SEC_PAIR_TKIP;
|
||||||
for (iter = items; iter && *iter; iter++)
|
if (_nm_utils_string_in_list ("ccmp", array))
|
||||||
flags |= pair_to_flags (*iter);
|
flags |= NM_802_11_AP_SEC_PAIR_CCMP;
|
||||||
|
g_free (array);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = g_hash_table_lookup (security, "Group");
|
if (g_variant_lookup (security, "Group", "&s", &tmp)) {
|
||||||
if (value)
|
if (strcmp (tmp, "wep40") == 0)
|
||||||
flags |= group_to_flags (g_value_get_string (value));
|
flags |= NM_802_11_AP_SEC_GROUP_WEP40;
|
||||||
|
if (strcmp (tmp, "wep104") == 0)
|
||||||
|
flags |= NM_802_11_AP_SEC_GROUP_WEP104;
|
||||||
|
if (strcmp (tmp, "tkip") == 0)
|
||||||
|
flags |= NM_802_11_AP_SEC_GROUP_TKIP;
|
||||||
|
if (strcmp (tmp, "ccmp") == 0)
|
||||||
|
flags |= NM_802_11_AP_SEC_GROUP_CCMP;
|
||||||
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
|
||||||
{
|
|
||||||
GValue *variant = (GValue *) value;
|
|
||||||
NMAccessPoint *ap = (NMAccessPoint *) user_data;
|
|
||||||
|
|
||||||
if (G_VALUE_HOLDS_BOXED (variant)) {
|
|
||||||
GArray *array = g_value_get_boxed (variant);
|
|
||||||
|
|
||||||
if (!strcmp (key, "SSID")) {
|
|
||||||
guint32 len = MIN (32, array->len);
|
|
||||||
|
|
||||||
/* Stupid ieee80211 layer uses <hidden> */
|
|
||||||
if (((len == 8) || (len == 9))
|
|
||||||
&& (memcmp (array->data, "<hidden>", 8) == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (nm_utils_is_empty_ssid ((const guint8 *) array->data, len))
|
|
||||||
return;
|
|
||||||
|
|
||||||
nm_ap_set_ssid (ap, (const guint8 *) array->data, len);
|
|
||||||
} else if (!strcmp (key, "BSSID")) {
|
|
||||||
char *addr;
|
|
||||||
|
|
||||||
if (array->len != ETH_ALEN)
|
|
||||||
return;
|
|
||||||
addr = nm_utils_hwaddr_ntoa (array->data, array->len);
|
|
||||||
nm_ap_set_address (ap, addr);
|
|
||||||
g_free (addr);
|
|
||||||
} else if (!strcmp (key, "Rates")) {
|
|
||||||
guint32 maxrate = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Find the max AP rate */
|
|
||||||
for (i = 0; i < array->len; i++) {
|
|
||||||
guint32 r = g_array_index (array, guint32, i);
|
|
||||||
|
|
||||||
if (r > maxrate) {
|
|
||||||
maxrate = r;
|
|
||||||
nm_ap_set_max_bitrate (ap, r / 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!strcmp (key, "WPA")) {
|
|
||||||
NM80211ApSecurityFlags flags = nm_ap_get_wpa_flags (ap);
|
|
||||||
|
|
||||||
flags |= security_from_dict (g_value_get_boxed (variant));
|
|
||||||
nm_ap_set_wpa_flags (ap, flags);
|
|
||||||
} else if (!strcmp (key, "RSN")) {
|
|
||||||
NM80211ApSecurityFlags flags = nm_ap_get_rsn_flags (ap);
|
|
||||||
|
|
||||||
flags |= security_from_dict (g_value_get_boxed (variant));
|
|
||||||
nm_ap_set_rsn_flags (ap, flags);
|
|
||||||
}
|
|
||||||
} else if (G_VALUE_HOLDS_UINT (variant)) {
|
|
||||||
guint32 val = g_value_get_uint (variant);
|
|
||||||
|
|
||||||
if (!strcmp (key, "Frequency"))
|
|
||||||
nm_ap_set_freq (ap, val);
|
|
||||||
} else if (G_VALUE_HOLDS_INT (variant)) {
|
|
||||||
gint val = g_value_get_int (variant);
|
|
||||||
|
|
||||||
if (!strcmp (key, "Signal"))
|
|
||||||
nm_ap_set_strength (ap, nm_ap_utils_level_to_quality (val));
|
|
||||||
} else if (G_VALUE_HOLDS_STRING (variant)) {
|
|
||||||
const char *val = g_value_get_string (variant);
|
|
||||||
|
|
||||||
if (val && !strcmp (key, "Mode")) {
|
|
||||||
if (strcmp (val, "infrastructure") == 0)
|
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
|
||||||
else if (strcmp (val, "ad-hoc") == 0)
|
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
|
||||||
}
|
|
||||||
} else if (G_VALUE_HOLDS_BOOLEAN (variant)) {
|
|
||||||
gboolean val = g_value_get_boolean (variant);
|
|
||||||
|
|
||||||
if (strcmp (key, "Privacy") == 0) {
|
|
||||||
if (val) {
|
|
||||||
NM80211ApFlags flags = nm_ap_get_flags (ap);
|
|
||||||
nm_ap_set_flags (ap, flags | NM_802_11_AP_FLAGS_PRIVACY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NMAccessPoint *
|
NMAccessPoint *
|
||||||
nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
|
nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties)
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap;
|
|
||||||
const char *addr;
|
|
||||||
const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
const char *addr;
|
||||||
|
const guint8 *bytes;
|
||||||
|
NMAccessPoint *ap;
|
||||||
|
GVariant *v;
|
||||||
|
gsize len;
|
||||||
|
gboolean b = FALSE;
|
||||||
|
const char *s;
|
||||||
|
gint16 i16;
|
||||||
|
guint16 u16;
|
||||||
|
|
||||||
g_return_val_if_fail (properties != NULL, NULL);
|
g_return_val_if_fail (properties != NULL, NULL);
|
||||||
|
|
||||||
ap = nm_ap_new ();
|
ap = nm_ap_new ();
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (ap));
|
g_object_freeze_notify (G_OBJECT (ap));
|
||||||
g_hash_table_foreach (properties, foreach_property_cb, ap);
|
|
||||||
|
if (g_variant_lookup (properties, "Privacy", "b", &b) && b)
|
||||||
|
nm_ap_set_flags (ap, nm_ap_get_flags (ap) | NM_802_11_AP_FLAGS_PRIVACY);
|
||||||
|
|
||||||
|
if (g_variant_lookup (properties, "Mode", "&s", &s)) {
|
||||||
|
if (!g_strcmp0 (s, "infrastructure"))
|
||||||
|
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||||
|
else if (!g_strcmp0 (s, "ad-hoc"))
|
||||||
|
nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_variant_lookup (properties, "Signal", "n", &i16))
|
||||||
|
nm_ap_set_strength (ap, nm_ap_utils_level_to_quality (i16));
|
||||||
|
|
||||||
|
if (g_variant_lookup (properties, "Frequency", "q", &u16))
|
||||||
|
nm_ap_set_freq (ap, u16);
|
||||||
|
|
||||||
|
v = g_variant_lookup_value (properties, "SSID", G_VARIANT_TYPE_BYTESTRING);
|
||||||
|
if (v) {
|
||||||
|
bytes = g_variant_get_fixed_array (v, &len, 1);
|
||||||
|
len = MIN (32, len);
|
||||||
|
|
||||||
|
/* Stupid ieee80211 layer uses <hidden> */
|
||||||
|
if ( bytes && len
|
||||||
|
&& !(((len == 8) || (len == 9)) && !memcmp (bytes, "<hidden>", 8))
|
||||||
|
&& !nm_utils_is_empty_ssid (bytes, len))
|
||||||
|
nm_ap_set_ssid (ap, bytes, len);
|
||||||
|
|
||||||
|
g_variant_unref (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
v = g_variant_lookup_value (properties, "BSSID", G_VARIANT_TYPE_BYTESTRING);
|
||||||
|
if (v) {
|
||||||
|
bytes = g_variant_get_fixed_array (v, &len, 1);
|
||||||
|
if (len == ETH_ALEN) {
|
||||||
|
addr = nm_utils_hwaddr_ntoa (bytes, len);
|
||||||
|
nm_ap_set_address (ap, addr);
|
||||||
|
}
|
||||||
|
g_variant_unref (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
v = g_variant_lookup_value (properties, "Rates", G_VARIANT_TYPE ("au"));
|
||||||
|
if (v) {
|
||||||
|
const guint32 *rates = g_variant_get_fixed_array (v, &len, sizeof (guint32));
|
||||||
|
guint32 maxrate = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Find the max AP rate */
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (rates[i] > maxrate) {
|
||||||
|
maxrate = rates[i];
|
||||||
|
nm_ap_set_max_bitrate (ap, rates[i] / 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_variant_unref (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
v = g_variant_lookup_value (properties, "WPA", G_VARIANT_TYPE_VARDICT);
|
||||||
|
if (v) {
|
||||||
|
nm_ap_set_wpa_flags (ap, nm_ap_get_wpa_flags (ap) | security_from_vardict (v));
|
||||||
|
g_variant_unref (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
v = g_variant_lookup_value (properties, "RSN", G_VARIANT_TYPE_VARDICT);
|
||||||
|
if (v) {
|
||||||
|
nm_ap_set_wpa_flags (ap, nm_ap_get_rsn_flags (ap) | security_from_vardict (v));
|
||||||
|
g_variant_unref (v);
|
||||||
|
}
|
||||||
|
|
||||||
nm_ap_set_supplicant_path (ap, supplicant_path);
|
nm_ap_set_supplicant_path (ap, supplicant_path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ typedef struct {
|
||||||
GType nm_ap_get_type (void);
|
GType nm_ap_get_type (void);
|
||||||
|
|
||||||
NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path,
|
NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path,
|
||||||
GHashTable *properties);
|
GVariant *properties);
|
||||||
NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection);
|
NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection);
|
||||||
void nm_ap_export_to_dbus (NMAccessPoint *ap);
|
void nm_ap_export_to_dbus (NMAccessPoint *ap);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,65 +260,44 @@ nm_supplicant_config_fast_required (NMSupplicantConfig *self)
|
||||||
return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->fast_required;
|
return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->fast_required;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
GVariant *
|
||||||
get_hash_cb (gpointer key, gpointer value, gpointer user_data)
|
nm_supplicant_config_to_variant (NMSupplicantConfig *self)
|
||||||
{
|
|
||||||
ConfigOption *opt = (ConfigOption *) value;
|
|
||||||
GValue *variant;
|
|
||||||
GByteArray *array;
|
|
||||||
|
|
||||||
variant = g_slice_new0 (GValue);
|
|
||||||
|
|
||||||
switch (opt->type) {
|
|
||||||
case TYPE_INT:
|
|
||||||
g_value_init (variant, G_TYPE_INT);
|
|
||||||
g_value_set_int (variant, atoi (opt->value));
|
|
||||||
break;
|
|
||||||
case TYPE_BYTES:
|
|
||||||
case TYPE_UTF8:
|
|
||||||
array = g_byte_array_sized_new (opt->len);
|
|
||||||
g_byte_array_append (array, (const guint8 *) opt->value, opt->len);
|
|
||||||
g_value_init (variant, DBUS_TYPE_G_UCHAR_ARRAY);
|
|
||||||
g_value_set_boxed (variant, array);
|
|
||||||
g_byte_array_free (array, TRUE);
|
|
||||||
break;
|
|
||||||
case TYPE_KEYWORD:
|
|
||||||
case TYPE_STRING:
|
|
||||||
g_value_init (variant, G_TYPE_STRING);
|
|
||||||
g_value_set_string (variant, opt->value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_slice_free (GValue, variant);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), variant);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
destroy_hash_value (gpointer data)
|
|
||||||
{
|
|
||||||
GValue *value = (GValue *) data;
|
|
||||||
|
|
||||||
g_value_unset (value);
|
|
||||||
g_slice_free (GValue, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
GHashTable *
|
|
||||||
nm_supplicant_config_get_hash (NMSupplicantConfig * self)
|
|
||||||
{
|
{
|
||||||
NMSupplicantConfigPrivate *priv;
|
NMSupplicantConfigPrivate *priv;
|
||||||
GHashTable *hash;
|
GVariantBuilder builder;
|
||||||
|
GHashTableIter iter;
|
||||||
|
ConfigOption *option;
|
||||||
|
const char *key;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), NULL);
|
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), NULL);
|
||||||
|
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
||||||
(GDestroyNotify) g_free,
|
|
||||||
destroy_hash_value);
|
|
||||||
|
|
||||||
priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
|
priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
|
||||||
g_hash_table_foreach (priv->config, get_hash_cb, hash);
|
|
||||||
return hash;
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
|
||||||
|
|
||||||
|
g_hash_table_iter_init (&iter, priv->config);
|
||||||
|
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &option)) {
|
||||||
|
switch (option->type) {
|
||||||
|
case TYPE_INT:
|
||||||
|
g_variant_builder_add (&builder, "{sv}", key, g_variant_new_int32 (atoi (option->value)));
|
||||||
|
break;
|
||||||
|
case TYPE_BYTES:
|
||||||
|
case TYPE_UTF8:
|
||||||
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
|
key,
|
||||||
|
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||||
|
option->value, option->len, 1));
|
||||||
|
break;
|
||||||
|
case TYPE_KEYWORD:
|
||||||
|
case TYPE_STRING:
|
||||||
|
g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (option->value));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_variant_builder_end (&builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
GHashTable *
|
GHashTable *
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ void nm_supplicant_config_set_ap_scan (NMSupplicantConfig *self,
|
||||||
|
|
||||||
gboolean nm_supplicant_config_fast_required (NMSupplicantConfig *self);
|
gboolean nm_supplicant_config_fast_required (NMSupplicantConfig *self);
|
||||||
|
|
||||||
GHashTable *nm_supplicant_config_get_hash (NMSupplicantConfig *self);
|
GVariant *nm_supplicant_config_to_variant (NMSupplicantConfig *self);
|
||||||
|
|
||||||
GHashTable *nm_supplicant_config_get_blobs (NMSupplicantConfig *self);
|
GHashTable *nm_supplicant_config_get_blobs (NMSupplicantConfig *self);
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -87,8 +87,11 @@ nm_supplicant_manager_iface_get (NMSupplicantManager * self,
|
||||||
priv->fast_supported,
|
priv->fast_supported,
|
||||||
priv->ap_support,
|
priv->ap_support,
|
||||||
start_now);
|
start_now);
|
||||||
if (iface)
|
if (iface) {
|
||||||
g_hash_table_insert (priv->ifaces, g_strdup (ifname), iface);
|
g_hash_table_insert (priv->ifaces,
|
||||||
|
(char *) nm_supplicant_interface_get_ifname (iface),
|
||||||
|
iface);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname);
|
nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname);
|
||||||
}
|
}
|
||||||
|
|
@ -190,12 +193,13 @@ static void
|
||||||
availability_changed (NMSupplicantManager *self, gboolean available)
|
availability_changed (NMSupplicantManager *self, gboolean available)
|
||||||
{
|
{
|
||||||
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
|
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
|
||||||
NMSupplicantInterface *iface;
|
GList *ifaces, *iter;
|
||||||
GHashTableIter iter;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, priv->ifaces);
|
/* priv->ifaces may be modified if availability changes; can't use GHashTableIter */
|
||||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &iface))
|
ifaces = g_hash_table_get_values (priv->ifaces);
|
||||||
nm_supplicant_interface_set_supplicant_available (iface, available);
|
for (iter = ifaces; iter; iter = iter->next)
|
||||||
|
nm_supplicant_interface_set_supplicant_available (NM_SUPPLICANT_INTERFACE (iter->data), available);
|
||||||
|
g_list_free (ifaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -333,7 +337,7 @@ nm_supplicant_manager_init (NMSupplicantManager *self)
|
||||||
{
|
{
|
||||||
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
|
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
priv->ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
||||||
|
|
||||||
priv->cancellable = g_cancellable_new ();
|
priv->cancellable = g_cancellable_new ();
|
||||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
||||||
|
|
|
||||||
|
|
@ -41,78 +41,67 @@
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
validate_opt (const char *detail,
|
validate_opt (const char *detail,
|
||||||
GHashTable *hash,
|
GVariant *config,
|
||||||
const char *key,
|
const char *key,
|
||||||
OptType val_type,
|
OptType val_type,
|
||||||
gconstpointer expected,
|
gconstpointer expected,
|
||||||
size_t expected_len)
|
size_t expected_len)
|
||||||
{
|
{
|
||||||
GValue *value;
|
char *config_key;
|
||||||
gint int_val;
|
GVariant *config_value;
|
||||||
GByteArray *array;
|
gboolean found = FALSE;
|
||||||
|
const guint8 *bytes;
|
||||||
|
gsize len;
|
||||||
const char *s;
|
const char *s;
|
||||||
const unsigned char *expected_array = expected;
|
const unsigned char *expected_array = expected;
|
||||||
int result;
|
GVariantIter iter;
|
||||||
|
|
||||||
ASSERT (hash != NULL, detail, "hash was NULL");
|
g_assert (g_variant_is_of_type (config, G_VARIANT_TYPE_VARDICT));
|
||||||
|
|
||||||
value = g_hash_table_lookup (hash, key);
|
g_variant_iter_init (&iter, config);
|
||||||
ASSERT (value != NULL,
|
while (g_variant_iter_next (&iter, "{&sv}", (gpointer) &config_key, (gpointer) &config_value)) {
|
||||||
detail, "option '%s' expected but not found in config hash.");
|
if (!strcmp (key, config_key)) {
|
||||||
|
found = TRUE;
|
||||||
switch (val_type) {
|
switch (val_type) {
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
ASSERT (G_VALUE_HOLDS_INT (value),
|
g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_INT32));
|
||||||
detail, "config hash item '%s' was not TYPE_INT.", key);
|
g_assert_cmpint (g_variant_get_int32 (config_value), ==, GPOINTER_TO_INT (expected));
|
||||||
int_val = g_value_get_int (value);
|
break;
|
||||||
ASSERT (int_val == GPOINTER_TO_INT (expected),
|
case TYPE_BYTES:
|
||||||
detail, "unexpected config hash item '%s' value %d (expected %d)",
|
g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_BYTESTRING));
|
||||||
key, int_val, GPOINTER_TO_INT (expected));
|
bytes = g_variant_get_fixed_array (config_value, &len, 1);
|
||||||
break;
|
g_assert_cmpint (len, ==, expected_len);
|
||||||
case TYPE_BYTES:
|
g_assert (memcmp (bytes, expected_array, expected_len) == 0);
|
||||||
ASSERT (G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY),
|
break;
|
||||||
detail, "config hash item '%s' was not TYPE_BYTES.", key);
|
case TYPE_KEYWORD:
|
||||||
array = g_value_get_boxed (value);
|
case TYPE_STRING:
|
||||||
ASSERT (array->len == expected_len,
|
g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_STRING));
|
||||||
detail, "unexpected config hash item '%s' length %d (expected %d)",
|
if (expected_len == -1)
|
||||||
key, array->len, expected_len);
|
expected_len = strlen ((const char *) expected);
|
||||||
result = memcmp (array->data, expected_array, expected_len);
|
s = g_variant_get_string (config_value, NULL);
|
||||||
ASSERT (result == 0, detail, "unexpected config hash item '%s' value", key);
|
g_assert_cmpint (strlen (s), ==, expected_len);
|
||||||
break;
|
g_assert_cmpstr (s, ==, expected);
|
||||||
case TYPE_KEYWORD:
|
break;
|
||||||
case TYPE_STRING:
|
default:
|
||||||
ASSERT (G_VALUE_HOLDS_STRING (value),
|
g_assert_not_reached ();
|
||||||
detail, "config hash item '%s' was not TYPE_STRING or TYPE_KEYWORD.", key);
|
break;
|
||||||
if (expected_len == -1)
|
}
|
||||||
expected_len = strlen ((const char *) expected);
|
}
|
||||||
s = g_value_get_string (value);
|
g_variant_unref (config_value);
|
||||||
ASSERT (s != NULL, detail, "unexpected NULL config hash string item '%s'.", key);
|
|
||||||
ASSERT (strlen (s) == expected_len,
|
|
||||||
detail, "unexpected config hash string item '%s' length %d (expected %d)",
|
|
||||||
key, strlen (s), expected_len);
|
|
||||||
result = strcmp (s, (const char *) expected);
|
|
||||||
ASSERT (result == 0,
|
|
||||||
detail, "unexpected config hash string item '%s' value '%s' (expected '%s')",
|
|
||||||
key, s, (const char *) expected);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_warning ("unknown supplicant config hash item '%s' option type %d",
|
|
||||||
key, val_type);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_wifi_open (void)
|
test_wifi_open (void)
|
||||||
{
|
{
|
||||||
NMConnection *connection;
|
gs_unref_object NMConnection *connection = NULL;
|
||||||
|
gs_unref_object NMSupplicantConfig *config = NULL;
|
||||||
|
gs_unref_variant GVariant *config_dict = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
gs_unref_object NMSupplicantConfig *config = NULL;
|
|
||||||
GHashTable *hash;
|
|
||||||
char *uuid;
|
char *uuid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
@ -156,9 +145,9 @@ test_wifi_open (void)
|
||||||
|
|
||||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||||
|
|
||||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
success = nm_connection_verify (connection, &error);
|
||||||
"wifi-open", "failed to verify connection: %s",
|
g_assert_no_error (error);
|
||||||
(error && error->message) ? error->message : "(unknown)");
|
g_assert (success);
|
||||||
|
|
||||||
config = nm_supplicant_config_new ();
|
config = nm_supplicant_config_new ();
|
||||||
|
|
||||||
|
|
@ -170,29 +159,21 @@ test_wifi_open (void)
|
||||||
"*added 'bssid' value '11:22:33:44:55:66'*");
|
"*added 'bssid' value '11:22:33:44:55:66'*");
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
"*added 'freq_list' value *");
|
"*added 'freq_list' value *");
|
||||||
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, 0);
|
g_assert (nm_supplicant_config_add_setting_wireless (config, s_wifi, 0));
|
||||||
ASSERT (success == TRUE,
|
|
||||||
"wifi-open", "failed to add wireless setting to supplicant config.");
|
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
"*added 'key_mgmt' value 'NONE'");
|
"*added 'key_mgmt' value 'NONE'");
|
||||||
success = nm_supplicant_config_add_no_security (config);
|
g_assert (nm_supplicant_config_add_no_security (config));
|
||||||
ASSERT (success == TRUE,
|
|
||||||
"wifi-open", "failed to add wireless security to supplicant config.");
|
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
hash = nm_supplicant_config_get_hash (config);
|
config_dict = nm_supplicant_config_to_variant (config);
|
||||||
ASSERT (hash != NULL,
|
g_assert (config_dict);
|
||||||
"wifi-open", "failed to hash supplicant config options.");
|
|
||||||
|
|
||||||
validate_opt ("wifi-open", hash, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1);
|
validate_opt ("wifi-open", config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1);
|
||||||
validate_opt ("wifi-open", hash, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data));
|
validate_opt ("wifi-open", config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data));
|
||||||
validate_opt ("wifi-open", hash, "bssid", TYPE_KEYWORD, bssid_str, -1);
|
validate_opt ("wifi-open", config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1);
|
||||||
validate_opt ("wifi-open", hash, "key_mgmt", TYPE_KEYWORD, "NONE", -1);
|
validate_opt ("wifi-open", config_dict, "key_mgmt", TYPE_KEYWORD, "NONE", -1);
|
||||||
|
|
||||||
g_hash_table_unref (hash);
|
|
||||||
g_object_unref (connection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -202,13 +183,13 @@ test_wifi_wep_key (const char *detail,
|
||||||
const unsigned char *expected,
|
const unsigned char *expected,
|
||||||
size_t expected_size)
|
size_t expected_size)
|
||||||
{
|
{
|
||||||
NMConnection *connection;
|
gs_unref_object NMConnection *connection = NULL;
|
||||||
|
gs_unref_object NMSupplicantConfig *config = NULL;
|
||||||
|
gs_unref_variant GVariant *config_dict = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
gs_unref_object NMSupplicantConfig *config = NULL;
|
|
||||||
GHashTable *hash;
|
|
||||||
char *uuid;
|
char *uuid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
@ -262,9 +243,9 @@ test_wifi_wep_key (const char *detail,
|
||||||
|
|
||||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||||
|
|
||||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
success = nm_connection_verify (connection, &error);
|
||||||
detail, "failed to verify connection: %s",
|
g_assert_no_error (error);
|
||||||
(error && error->message) ? error->message : "(unknown)");
|
g_assert (success);
|
||||||
|
|
||||||
config = nm_supplicant_config_new ();
|
config = nm_supplicant_config_new ();
|
||||||
|
|
||||||
|
|
@ -276,9 +257,7 @@ test_wifi_wep_key (const char *detail,
|
||||||
"*added 'bssid' value '11:22:33:44:55:66'*");
|
"*added 'bssid' value '11:22:33:44:55:66'*");
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
"*added 'freq_list' value *");
|
"*added 'freq_list' value *");
|
||||||
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, 0);
|
g_assert (nm_supplicant_config_add_setting_wireless (config, s_wifi, 0));
|
||||||
ASSERT (success == TRUE,
|
|
||||||
detail, "failed to add wireless setting to supplicant config.");
|
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
|
|
@ -287,27 +266,21 @@ test_wifi_wep_key (const char *detail,
|
||||||
"*added 'wep_key0' value *");
|
"*added 'wep_key0' value *");
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
"*added 'wep_tx_keyidx' value '0'");
|
"*added 'wep_tx_keyidx' value '0'");
|
||||||
success = nm_supplicant_config_add_setting_wireless_security (config,
|
g_assert (nm_supplicant_config_add_setting_wireless_security (config,
|
||||||
s_wsec,
|
s_wsec,
|
||||||
NULL,
|
NULL,
|
||||||
"376aced7-b28c-46be-9a62-fcdf072571da");
|
"376aced7-b28c-46be-9a62-fcdf072571da"));
|
||||||
ASSERT (success == TRUE,
|
|
||||||
detail, "failed to add wireless security to supplicant config.");
|
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
hash = nm_supplicant_config_get_hash (config);
|
config_dict = nm_supplicant_config_to_variant (config);
|
||||||
ASSERT (hash != NULL,
|
g_assert (config_dict);
|
||||||
detail, "failed to hash supplicant config options.");
|
|
||||||
|
|
||||||
validate_opt (detail, hash, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1);
|
validate_opt (detail, config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1);
|
||||||
validate_opt (detail, hash, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data));
|
validate_opt (detail, config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data));
|
||||||
validate_opt (detail, hash, "bssid", TYPE_KEYWORD, bssid_str, -1);
|
validate_opt (detail, config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1);
|
||||||
validate_opt (detail, hash, "key_mgmt", TYPE_KEYWORD, "NONE", -1);
|
validate_opt (detail, config_dict, "key_mgmt", TYPE_KEYWORD, "NONE", -1);
|
||||||
validate_opt (detail, hash, "wep_tx_keyidx", TYPE_INT, GINT_TO_POINTER (0), -1);
|
validate_opt (detail, config_dict, "wep_tx_keyidx", TYPE_INT, GINT_TO_POINTER (0), -1);
|
||||||
validate_opt (detail, hash, "wep_key0", TYPE_BYTES, expected, expected_size);
|
validate_opt (detail, config_dict, "wep_key0", TYPE_BYTES, expected, expected_size);
|
||||||
|
|
||||||
g_hash_table_unref (hash);
|
|
||||||
g_object_unref (connection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -340,13 +313,13 @@ test_wifi_wpa_psk (const char *detail,
|
||||||
const unsigned char *expected,
|
const unsigned char *expected,
|
||||||
size_t expected_size)
|
size_t expected_size)
|
||||||
{
|
{
|
||||||
NMConnection *connection;
|
gs_unref_object NMConnection *connection = NULL;
|
||||||
|
gs_unref_object NMSupplicantConfig *config = NULL;
|
||||||
|
gs_unref_variant GVariant *config_dict = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
gs_unref_object NMSupplicantConfig *config = NULL;
|
|
||||||
GHashTable *hash;
|
|
||||||
char *uuid;
|
char *uuid;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
@ -406,9 +379,9 @@ test_wifi_wpa_psk (const char *detail,
|
||||||
|
|
||||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||||
|
|
||||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
success = nm_connection_verify (connection, &error);
|
||||||
detail, "failed to verify connection: %s",
|
g_assert_no_error (error);
|
||||||
(error && error->message) ? error->message : "(unknown)");
|
g_assert (success);
|
||||||
|
|
||||||
config = nm_supplicant_config_new ();
|
config = nm_supplicant_config_new ();
|
||||||
|
|
||||||
|
|
@ -420,9 +393,7 @@ test_wifi_wpa_psk (const char *detail,
|
||||||
"*added 'bssid' value '11:22:33:44:55:66'*");
|
"*added 'bssid' value '11:22:33:44:55:66'*");
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
"*added 'freq_list' value *");
|
"*added 'freq_list' value *");
|
||||||
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, 0);
|
g_assert (nm_supplicant_config_add_setting_wireless (config, s_wifi, 0));
|
||||||
ASSERT (success == TRUE,
|
|
||||||
detail, "failed to add wireless setting to supplicant config.");
|
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
|
|
@ -435,29 +406,23 @@ test_wifi_wpa_psk (const char *detail,
|
||||||
"*added 'pairwise' value 'TKIP CCMP'");
|
"*added 'pairwise' value 'TKIP CCMP'");
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||||
"*added 'group' value 'TKIP CCMP'");
|
"*added 'group' value 'TKIP CCMP'");
|
||||||
success = nm_supplicant_config_add_setting_wireless_security (config,
|
g_assert (nm_supplicant_config_add_setting_wireless_security (config,
|
||||||
s_wsec,
|
s_wsec,
|
||||||
NULL,
|
NULL,
|
||||||
"376aced7-b28c-46be-9a62-fcdf072571da");
|
"376aced7-b28c-46be-9a62-fcdf072571da"));
|
||||||
ASSERT (success == TRUE,
|
|
||||||
detail, "failed to add wireless security to supplicant config.");
|
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
hash = nm_supplicant_config_get_hash (config);
|
config_dict = nm_supplicant_config_to_variant (config);
|
||||||
ASSERT (hash != NULL,
|
g_assert (config_dict);
|
||||||
detail, "failed to hash supplicant config options.");
|
|
||||||
|
|
||||||
validate_opt (detail, hash, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1);
|
validate_opt (detail, config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1);
|
||||||
validate_opt (detail, hash, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data));
|
validate_opt (detail, config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data));
|
||||||
validate_opt (detail, hash, "bssid", TYPE_KEYWORD, bssid_str, -1);
|
validate_opt (detail, config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1);
|
||||||
validate_opt (detail, hash, "key_mgmt", TYPE_KEYWORD, "WPA-PSK", -1);
|
validate_opt (detail, config_dict, "key_mgmt", TYPE_KEYWORD, "WPA-PSK", -1);
|
||||||
validate_opt (detail, hash, "proto", TYPE_KEYWORD, "WPA RSN", -1);
|
validate_opt (detail, config_dict, "proto", TYPE_KEYWORD, "WPA RSN", -1);
|
||||||
validate_opt (detail, hash, "pairwise", TYPE_KEYWORD, "TKIP CCMP", -1);
|
validate_opt (detail, config_dict, "pairwise", TYPE_KEYWORD, "TKIP CCMP", -1);
|
||||||
validate_opt (detail, hash, "group", TYPE_KEYWORD, "TKIP CCMP", -1);
|
validate_opt (detail, config_dict, "group", TYPE_KEYWORD, "TKIP CCMP", -1);
|
||||||
validate_opt (detail, hash, "psk", key_type, expected, expected_size);
|
validate_opt (detail, config_dict, "psk", key_type, expected, expected_size);
|
||||||
|
|
||||||
g_hash_table_unref (hash);
|
|
||||||
g_object_unref (connection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -478,18 +443,12 @@ NMTST_DEFINE ();
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *base;
|
|
||||||
|
|
||||||
nmtst_init (&argc, &argv, TRUE);
|
nmtst_init (&argc, &argv, TRUE);
|
||||||
|
|
||||||
/* The tests */
|
g_test_add_func ("/supplicant-config/wifi-open", test_wifi_open);
|
||||||
test_wifi_open ();
|
g_test_add_func ("/supplicant-config/wifi-wep", test_wifi_wep);
|
||||||
test_wifi_wep ();
|
g_test_add_func ("/supplicant-config/wifi-wpa-psk-types", test_wifi_wpa_psk_types);
|
||||||
test_wifi_wpa_psk_types ();
|
|
||||||
|
|
||||||
base = g_path_get_basename (argv[0]);
|
return g_test_run ();
|
||||||
fprintf (stdout, "%s: SUCCESS\n", base);
|
|
||||||
g_free (base);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue