wifi: rename NMAccessPoint to NMWifiAP
NMAccessPoint was in file "nm-wifi-ap.h" with method nm_ap_*(). Make the naming consistent. Also rename "nm-wifi-ap-utils.*" as it contains general purpose wifi utilities. No need to have special "ap" utilities. Same for "test-wifi-ap-utils.c". It just contains general wifi tests.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -240,7 +240,7 @@ test-*.trs
|
|||||||
/src/NetworkManager
|
/src/NetworkManager
|
||||||
/src/devices/tests/test-arping
|
/src/devices/tests/test-arping
|
||||||
/src/devices/tests/test-lldp
|
/src/devices/tests/test-lldp
|
||||||
/src/devices/wifi/tests/test-wifi-ap-utils
|
/src/devices/wifi/tests/test-general
|
||||||
/src/dhcp-manager/nm-dhcp-helper
|
/src/dhcp-manager/nm-dhcp-helper
|
||||||
/src/dhcp-manager/tests/test-dhcp-dhclient
|
/src/dhcp-manager/tests/test-dhcp-dhclient
|
||||||
/src/dhcp-manager/tests/test-dhcp-options
|
/src/dhcp-manager/tests/test-dhcp-options
|
||||||
|
@@ -30,8 +30,8 @@ libnm_device_plugin_wifi_la_SOURCES = \
|
|||||||
nm-device-wifi.h \
|
nm-device-wifi.h \
|
||||||
nm-wifi-ap.c \
|
nm-wifi-ap.c \
|
||||||
nm-wifi-ap.h \
|
nm-wifi-ap.h \
|
||||||
nm-wifi-ap-utils.c \
|
nm-wifi-utils.c \
|
||||||
nm-wifi-ap-utils.h \
|
nm-wifi-utils.h \
|
||||||
nm-device-olpc-mesh.c \
|
nm-device-olpc-mesh.c \
|
||||||
nm-device-olpc-mesh.h
|
nm-device-olpc-mesh.h
|
||||||
|
|
||||||
|
@@ -91,7 +91,7 @@ typedef struct {
|
|||||||
gint8 invalid_strength_counter;
|
gint8 invalid_strength_counter;
|
||||||
|
|
||||||
GHashTable * aps;
|
GHashTable * aps;
|
||||||
NMAccessPoint * current_ap;
|
NMWifiAP * current_ap;
|
||||||
guint32 rate;
|
guint32 rate;
|
||||||
bool enabled:1; /* rfkilled or not */
|
bool enabled:1; /* rfkilled or not */
|
||||||
bool requested_scan:1;
|
bool requested_scan:1;
|
||||||
@@ -185,7 +185,7 @@ static void request_wireless_scan (NMDeviceWifi *self, GVariant *scan_options);
|
|||||||
|
|
||||||
static void ap_add_remove (NMDeviceWifi *self,
|
static void ap_add_remove (NMDeviceWifi *self,
|
||||||
guint signum,
|
guint signum,
|
||||||
NMAccessPoint *ap,
|
NMWifiAP *ap,
|
||||||
gboolean recheck_available_connections);
|
gboolean recheck_available_connections);
|
||||||
|
|
||||||
static void remove_supplicant_interface_error_handler (NMDeviceWifi *self);
|
static void remove_supplicant_interface_error_handler (NMDeviceWifi *self);
|
||||||
@@ -321,7 +321,7 @@ supplicant_interface_release (NMDeviceWifi *self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMAccessPoint *
|
static NMWifiAP *
|
||||||
get_ap_by_path (NMDeviceWifi *self, const char *path)
|
get_ap_by_path (NMDeviceWifi *self, const char *path)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (path != NULL, NULL);
|
g_return_val_if_fail (path != NULL, NULL);
|
||||||
@@ -329,24 +329,24 @@ get_ap_by_path (NMDeviceWifi *self, const char *path)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMAccessPoint *
|
static NMWifiAP *
|
||||||
get_ap_by_supplicant_path (NMDeviceWifi *self, const char *path)
|
get_ap_by_supplicant_path (NMDeviceWifi *self, const char *path)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
|
|
||||||
g_return_val_if_fail (path != NULL, NULL);
|
g_return_val_if_fail (path != NULL, NULL);
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
|
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
|
||||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
|
||||||
if (g_strcmp0 (path, nm_ap_get_supplicant_path (ap)) == 0)
|
if (g_strcmp0 (path, nm_wifi_ap_get_supplicant_path (ap)) == 0)
|
||||||
return ap;
|
return ap;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_seen_bssids_cache (NMDeviceWifi *self, NMAccessPoint *ap)
|
update_seen_bssids_cache (NMDeviceWifi *self, NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_if_fail (NM_IS_DEVICE_WIFI (self));
|
g_return_if_fail (NM_IS_DEVICE_WIFI (self));
|
||||||
|
|
||||||
@@ -354,21 +354,21 @@ update_seen_bssids_cache (NMDeviceWifi *self, NMAccessPoint *ap)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Don't cache the BSSID for Ad-Hoc APs */
|
/* Don't cache the BSSID for Ad-Hoc APs */
|
||||||
if (nm_ap_get_mode (ap) != NM_802_11_MODE_INFRA)
|
if (nm_wifi_ap_get_mode (ap) != NM_802_11_MODE_INFRA)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED
|
if ( nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED
|
||||||
&& nm_device_has_unmodified_applied_connection (NM_DEVICE (self), NM_SETTING_COMPARE_FLAG_NONE)) {
|
&& nm_device_has_unmodified_applied_connection (NM_DEVICE (self), NM_SETTING_COMPARE_FLAG_NONE)) {
|
||||||
nm_settings_connection_add_seen_bssid (nm_device_get_settings_connection (NM_DEVICE (self)),
|
nm_settings_connection_add_seen_bssid (nm_device_get_settings_connection (NM_DEVICE (self)),
|
||||||
nm_ap_get_address (ap));
|
nm_wifi_ap_get_address (ap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_current_ap (NMDeviceWifi *self, NMAccessPoint *new_ap, gboolean recheck_available_connections)
|
set_current_ap (NMDeviceWifi *self, NMWifiAP *new_ap, gboolean recheck_available_connections)
|
||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv;
|
NMDeviceWifiPrivate *priv;
|
||||||
NMAccessPoint *old_ap;
|
NMWifiAP *old_ap;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_DEVICE_WIFI (self));
|
g_return_if_fail (NM_IS_DEVICE_WIFI (self));
|
||||||
|
|
||||||
@@ -387,10 +387,10 @@ set_current_ap (NMDeviceWifi *self, NMAccessPoint *new_ap, gboolean recheck_avai
|
|||||||
priv->current_ap = NULL;
|
priv->current_ap = NULL;
|
||||||
|
|
||||||
if (old_ap) {
|
if (old_ap) {
|
||||||
NM80211Mode mode = nm_ap_get_mode (old_ap);
|
NM80211Mode mode = nm_wifi_ap_get_mode (old_ap);
|
||||||
|
|
||||||
/* Remove any AP from the internal list if it was created by NM or isn't known to the supplicant */
|
/* Remove any AP from the internal list if it was created by NM or isn't known to the supplicant */
|
||||||
if (mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_ap_get_fake (old_ap))
|
if (mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_wifi_ap_get_fake (old_ap))
|
||||||
ap_add_remove (self, ACCESS_POINT_REMOVED, old_ap, recheck_available_connections);
|
ap_add_remove (self, ACCESS_POINT_REMOVED, old_ap, recheck_available_connections);
|
||||||
g_object_unref (old_ap);
|
g_object_unref (old_ap);
|
||||||
}
|
}
|
||||||
@@ -433,7 +433,7 @@ periodic_update (NMDeviceWifi *self)
|
|||||||
/* Smooth out the strength to work around crappy drivers */
|
/* Smooth out the strength to work around crappy drivers */
|
||||||
percent = nm_platform_wifi_get_quality (NM_PLATFORM_GET, ifindex);
|
percent = nm_platform_wifi_get_quality (NM_PLATFORM_GET, ifindex);
|
||||||
if (percent >= 0 || ++priv->invalid_strength_counter > 3) {
|
if (percent >= 0 || ++priv->invalid_strength_counter > 3) {
|
||||||
nm_ap_set_strength (priv->current_ap, (gint8) percent);
|
nm_wifi_ap_set_strength (priv->current_ap, (gint8) percent);
|
||||||
priv->invalid_strength_counter = 0;
|
priv->invalid_strength_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,7 +455,7 @@ periodic_update_cb (gpointer user_data)
|
|||||||
static void
|
static void
|
||||||
ap_add_remove (NMDeviceWifi *self,
|
ap_add_remove (NMDeviceWifi *self,
|
||||||
guint signum,
|
guint signum,
|
||||||
NMAccessPoint *ap,
|
NMWifiAP *ap,
|
||||||
gboolean recheck_available_connections)
|
gboolean recheck_available_connections)
|
||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
@@ -487,7 +487,7 @@ remove_all_aps (NMDeviceWifi *self)
|
|||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
|
|
||||||
if (!g_hash_table_size (priv->aps))
|
if (!g_hash_table_size (priv->aps))
|
||||||
return;
|
return;
|
||||||
@@ -651,24 +651,24 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMAccessPoint *
|
static NMWifiAP *
|
||||||
find_first_compatible_ap (NMDeviceWifi *self,
|
find_first_compatible_ap (NMDeviceWifi *self,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean allow_unstable_order)
|
gboolean allow_unstable_order)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
NMAccessPoint *cand_ap = NULL;
|
NMWifiAP *cand_ap = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
|
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
|
||||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) {
|
||||||
if (!nm_ap_check_compatible (ap, connection))
|
if (!nm_wifi_ap_check_compatible (ap, connection))
|
||||||
continue;
|
continue;
|
||||||
if (allow_unstable_order)
|
if (allow_unstable_order)
|
||||||
return ap;
|
return ap;
|
||||||
if (!cand_ap || (nm_ap_get_id (cand_ap) < nm_ap_get_id (ap)))
|
if (!cand_ap || (nm_wifi_ap_get_id (cand_ap) < nm_wifi_ap_get_id (ap)))
|
||||||
cand_ap = ap;
|
cand_ap = ap;
|
||||||
}
|
}
|
||||||
return cand_ap;
|
return cand_ap;
|
||||||
@@ -690,10 +690,10 @@ check_connection_available (NMDevice *device,
|
|||||||
* also be available in general (without @specific_object). */
|
* also be available in general (without @specific_object). */
|
||||||
|
|
||||||
if (specific_object) {
|
if (specific_object) {
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
|
|
||||||
ap = get_ap_by_path (NM_DEVICE_WIFI (device), specific_object);
|
ap = get_ap_by_path (NM_DEVICE_WIFI (device), specific_object);
|
||||||
return ap ? nm_ap_check_compatible (ap, connection) : FALSE;
|
return ap ? nm_wifi_ap_check_compatible (ap, connection) : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ad-Hoc and AP connections are always available because they may be
|
/* Ad-Hoc and AP connections are always available because they may be
|
||||||
@@ -763,7 +763,7 @@ complete_connection (NMDevice *device,
|
|||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
const char *setting_mac;
|
const char *setting_mac;
|
||||||
char *str_ssid = NULL;
|
char *str_ssid = NULL;
|
||||||
NMAccessPoint *ap = NULL;
|
NMWifiAP *ap = NULL;
|
||||||
const GByteArray *ssid = NULL;
|
const GByteArray *ssid = NULL;
|
||||||
GByteArray *tmp_ssid = NULL;
|
GByteArray *tmp_ssid = NULL;
|
||||||
GBytes *setting_ssid = NULL;
|
GBytes *setting_ssid = NULL;
|
||||||
@@ -823,7 +823,7 @@ complete_connection (NMDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ap)
|
if (ap)
|
||||||
ssid = nm_ap_get_ssid (ap);
|
ssid = nm_wifi_ap_get_ssid (ap);
|
||||||
if (ssid == NULL) {
|
if (ssid == NULL) {
|
||||||
/* The AP must be hidden. Connecting to a WiFi AP requires the SSID
|
/* The AP must be hidden. Connecting to a WiFi AP requires the SSID
|
||||||
* as part of the initial handshake, so check the connection details
|
* as part of the initial handshake, so check the connection details
|
||||||
@@ -856,10 +856,10 @@ complete_connection (NMDevice *device,
|
|||||||
/* If the SSID is a well-known SSID, lock the connection to the AP's
|
/* If the SSID is a well-known SSID, lock the connection to the AP's
|
||||||
* specific BSSID so NM doesn't autoconnect to some random wifi net.
|
* specific BSSID so NM doesn't autoconnect to some random wifi net.
|
||||||
*/
|
*/
|
||||||
if (!nm_ap_complete_connection (ap,
|
if (!nm_wifi_ap_complete_connection (ap,
|
||||||
connection,
|
connection,
|
||||||
is_manf_default_ssid (ssid),
|
is_manf_default_ssid (ssid),
|
||||||
error)) {
|
error)) {
|
||||||
if (tmp_ssid)
|
if (tmp_ssid)
|
||||||
g_byte_array_unref (tmp_ssid);
|
g_byte_array_unref (tmp_ssid);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -957,7 +957,7 @@ can_auto_connect (NMDevice *device,
|
|||||||
{
|
{
|
||||||
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
|
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
const char *method, *mode;
|
const char *method, *mode;
|
||||||
guint64 timestamp = 0;
|
guint64 timestamp = 0;
|
||||||
|
|
||||||
@@ -998,10 +998,10 @@ can_auto_connect (NMDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
ap_id_compare (NMAccessPoint *a, NMAccessPoint *b)
|
ap_id_compare (NMWifiAP *a, NMWifiAP *b)
|
||||||
{
|
{
|
||||||
guint32 a_id = nm_ap_get_id (a);
|
guint32 a_id = nm_wifi_ap_get_id (a);
|
||||||
guint32 b_id = nm_ap_get_id (b);
|
guint32 b_id = nm_wifi_ap_get_id (b);
|
||||||
|
|
||||||
return a_id < b_id ? -1 : (a_id == b_id ? 0 : 1);
|
return a_id < b_id ? -1 : (a_id == b_id ? 0 : 1);
|
||||||
}
|
}
|
||||||
@@ -1011,7 +1011,7 @@ get_sorted_ap_list (NMDeviceWifi *self)
|
|||||||
{
|
{
|
||||||
GSList *sorted = NULL;
|
GSList *sorted = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
|
g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps);
|
||||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap))
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap))
|
||||||
@@ -1029,9 +1029,9 @@ impl_device_wifi_get_access_points (NMDeviceWifi *self,
|
|||||||
paths = g_ptr_array_new ();
|
paths = g_ptr_array_new ();
|
||||||
sorted = get_sorted_ap_list (self);
|
sorted = get_sorted_ap_list (self);
|
||||||
for (iter = sorted; iter; iter = iter->next) {
|
for (iter = sorted; iter; iter = iter->next) {
|
||||||
NMAccessPoint *ap = NM_AP (iter->data);
|
NMWifiAP *ap = NM_WIFI_AP (iter->data);
|
||||||
|
|
||||||
if (nm_ap_get_ssid (ap))
|
if (nm_wifi_ap_get_ssid (ap))
|
||||||
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
|
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
|
||||||
}
|
}
|
||||||
g_ptr_array_add (paths, NULL);
|
g_ptr_array_add (paths, NULL);
|
||||||
@@ -1532,7 +1532,7 @@ ap_list_dump (gpointer user_data)
|
|||||||
priv->scheduled_scan_time);
|
priv->scheduled_scan_time);
|
||||||
sorted = get_sorted_ap_list (self);
|
sorted = get_sorted_ap_list (self);
|
||||||
for (iter = sorted; iter; iter = iter->next)
|
for (iter = sorted; iter; iter = iter->next)
|
||||||
nm_ap_dump (NM_AP (iter->data), "dump ", nm_device_get_iface (NM_DEVICE (self)));
|
nm_wifi_ap_dump (NM_WIFI_AP (iter->data), "dump ", nm_device_get_iface (NM_DEVICE (self)));
|
||||||
g_slist_free (sorted);
|
g_slist_free (sorted);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
@@ -1550,15 +1550,15 @@ schedule_ap_list_dump (NMDeviceWifi *self)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
try_fill_ssid_for_hidden_ap (NMDeviceWifi *self,
|
try_fill_ssid_for_hidden_ap (NMDeviceWifi *self,
|
||||||
NMAccessPoint *ap)
|
NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
const char *bssid;
|
const char *bssid;
|
||||||
NMSettingsConnection *const*connections;
|
NMSettingsConnection *const*connections;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_return_if_fail (nm_ap_get_ssid (ap) == NULL);
|
g_return_if_fail (nm_wifi_ap_get_ssid (ap) == NULL);
|
||||||
|
|
||||||
bssid = nm_ap_get_address (ap);
|
bssid = nm_wifi_ap_get_address (ap);
|
||||||
g_return_if_fail (bssid);
|
g_return_if_fail (bssid);
|
||||||
|
|
||||||
/* Look for this AP's BSSID in the seen-bssids list of a connection,
|
/* Look for this AP's BSSID in the seen-bssids list of a connection,
|
||||||
@@ -1573,9 +1573,9 @@ try_fill_ssid_for_hidden_ap (NMDeviceWifi *self,
|
|||||||
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
|
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
|
||||||
GBytes *ssid = nm_setting_wireless_get_ssid (s_wifi);
|
GBytes *ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||||
|
|
||||||
nm_ap_set_ssid (ap,
|
nm_wifi_ap_set_ssid (ap,
|
||||||
g_bytes_get_data (ssid, NULL),
|
g_bytes_get_data (ssid, NULL),
|
||||||
g_bytes_get_size (ssid));
|
g_bytes_get_size (ssid));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1590,8 +1590,8 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
|||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
NMDeviceState state;
|
NMDeviceState state;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
NMAccessPoint *found_ap = NULL;
|
NMWifiAP *found_ap = NULL;
|
||||||
const GByteArray *ssid;
|
const GByteArray *ssid;
|
||||||
|
|
||||||
g_return_if_fail (self != NULL);
|
g_return_if_fail (self != NULL);
|
||||||
@@ -1605,36 +1605,36 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
|||||||
if (NM_DEVICE_WIFI_GET_PRIVATE (self)->mode == NM_802_11_MODE_AP)
|
if (NM_DEVICE_WIFI_GET_PRIVATE (self)->mode == NM_802_11_MODE_AP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ap = nm_ap_new_from_properties (object_path, properties);
|
ap = nm_wifi_ap_new_from_properties (object_path, properties);
|
||||||
if (!ap) {
|
if (!ap) {
|
||||||
_LOGD (LOGD_WIFI_SCAN, "invalid AP properties received for %s", object_path);
|
_LOGD (LOGD_WIFI_SCAN, "invalid AP properties received for %s", object_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the manager try to fill in the SSID from seen-bssids lists */
|
/* Let the manager try to fill in the SSID from seen-bssids lists */
|
||||||
ssid = nm_ap_get_ssid (ap);
|
ssid = nm_wifi_ap_get_ssid (ap);
|
||||||
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
|
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
|
||||||
/* Try to fill the SSID from the AP database */
|
/* Try to fill the SSID from the AP database */
|
||||||
try_fill_ssid_for_hidden_ap (self, ap);
|
try_fill_ssid_for_hidden_ap (self, ap);
|
||||||
|
|
||||||
ssid = nm_ap_get_ssid (ap);
|
ssid = nm_wifi_ap_get_ssid (ap);
|
||||||
if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
|
if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
|
||||||
/* Yay, matched it, no longer treat as hidden */
|
/* Yay, matched it, no longer treat as hidden */
|
||||||
_LOGD (LOGD_WIFI_SCAN, "matched hidden AP %s => '%s'",
|
_LOGD (LOGD_WIFI_SCAN, "matched hidden AP %s => '%s'",
|
||||||
nm_ap_get_address (ap), nm_utils_escape_ssid (ssid->data, ssid->len));
|
nm_wifi_ap_get_address (ap), nm_utils_escape_ssid (ssid->data, ssid->len));
|
||||||
} else {
|
} else {
|
||||||
/* Didn't have an entry for this AP in the database */
|
/* Didn't have an entry for this AP in the database */
|
||||||
_LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP %s",
|
_LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP %s",
|
||||||
nm_ap_get_address (ap));
|
nm_wifi_ap_get_address (ap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
found_ap = get_ap_by_supplicant_path (self, object_path);
|
found_ap = get_ap_by_supplicant_path (self, object_path);
|
||||||
if (found_ap) {
|
if (found_ap) {
|
||||||
nm_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self)));
|
nm_wifi_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self)));
|
||||||
nm_ap_update_from_properties (found_ap, object_path, properties);
|
nm_wifi_ap_update_from_properties (found_ap, object_path, properties);
|
||||||
} else {
|
} else {
|
||||||
nm_ap_dump (ap, "added ", nm_device_get_iface (NM_DEVICE (self)));
|
nm_wifi_ap_dump (ap, "added ", nm_device_get_iface (NM_DEVICE (self)));
|
||||||
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
|
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1656,7 +1656,7 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
|
|||||||
NMDeviceWifi *self)
|
NMDeviceWifi *self)
|
||||||
{
|
{
|
||||||
NMDeviceState state;
|
NMDeviceState state;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
|
|
||||||
g_return_if_fail (self != NULL);
|
g_return_if_fail (self != NULL);
|
||||||
g_return_if_fail (object_path != NULL);
|
g_return_if_fail (object_path != NULL);
|
||||||
@@ -1669,8 +1669,8 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
|
|||||||
|
|
||||||
ap = get_ap_by_supplicant_path (self, object_path);
|
ap = get_ap_by_supplicant_path (self, object_path);
|
||||||
if (ap) {
|
if (ap) {
|
||||||
nm_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self)));
|
nm_wifi_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self)));
|
||||||
nm_ap_update_from_properties (ap, object_path, properties);
|
nm_wifi_ap_update_from_properties (ap, object_path, properties);
|
||||||
schedule_ap_list_dump (self);
|
schedule_ap_list_dump (self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1681,7 +1681,7 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
|
|||||||
NMDeviceWifi *self)
|
NMDeviceWifi *self)
|
||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv;
|
NMDeviceWifiPrivate *priv;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
|
|
||||||
g_return_if_fail (self != NULL);
|
g_return_if_fail (self != NULL);
|
||||||
g_return_if_fail (object_path != NULL);
|
g_return_if_fail (object_path != NULL);
|
||||||
@@ -1695,9 +1695,9 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
|
|||||||
* when the current AP is changed or cleared. Set 'fake' to
|
* when the current AP is changed or cleared. Set 'fake' to
|
||||||
* indicate that this AP is now unknown to the supplicant.
|
* indicate that this AP is now unknown to the supplicant.
|
||||||
*/
|
*/
|
||||||
nm_ap_set_fake (ap, TRUE);
|
nm_wifi_ap_set_fake (ap, TRUE);
|
||||||
} else {
|
} else {
|
||||||
nm_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self)));
|
nm_wifi_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self)));
|
||||||
ap_add_remove (self, ACCESS_POINT_REMOVED, ap, TRUE);
|
ap_add_remove (self, ACCESS_POINT_REMOVED, ap, TRUE);
|
||||||
schedule_ap_list_dump (self);
|
schedule_ap_list_dump (self);
|
||||||
}
|
}
|
||||||
@@ -2121,7 +2121,7 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface,
|
|||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
const char *current_bss;
|
const char *current_bss;
|
||||||
NMAccessPoint *new_ap = NULL;
|
NMWifiAP *new_ap = NULL;
|
||||||
|
|
||||||
current_bss = nm_supplicant_interface_get_current_bss (iface);
|
current_bss = nm_supplicant_interface_get_current_bss (iface);
|
||||||
if (current_bss)
|
if (current_bss)
|
||||||
@@ -2137,17 +2137,17 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface,
|
|||||||
* supplicant's current BSS yet. It'll get replaced when we receive
|
* supplicant's current BSS yet. It'll get replaced when we receive
|
||||||
* the current BSS's scan result.
|
* the current BSS's scan result.
|
||||||
*/
|
*/
|
||||||
if (new_ap == NULL && nm_ap_get_fake (priv->current_ap))
|
if (new_ap == NULL && nm_wifi_ap_get_fake (priv->current_ap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (new_ap) {
|
if (new_ap) {
|
||||||
new_bssid = nm_ap_get_address (new_ap);
|
new_bssid = nm_wifi_ap_get_address (new_ap);
|
||||||
new_ssid = nm_ap_get_ssid (new_ap);
|
new_ssid = nm_wifi_ap_get_ssid (new_ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->current_ap) {
|
if (priv->current_ap) {
|
||||||
old_bssid = nm_ap_get_address (priv->current_ap);
|
old_bssid = nm_wifi_ap_get_address (priv->current_ap);
|
||||||
old_ssid = nm_ap_get_ssid (priv->current_ap);
|
old_ssid = nm_wifi_ap_get_ssid (priv->current_ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
_LOGD (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)",
|
_LOGD (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)",
|
||||||
@@ -2357,7 +2357,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
|||||||
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
|
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
NMActStageReturn ret;
|
NMActStageReturn ret;
|
||||||
NMAccessPoint *ap = NULL;
|
NMWifiAP *ap = NULL;
|
||||||
NMActRequest *req;
|
NMActRequest *req;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
@@ -2429,11 +2429,11 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
|||||||
* until the real one is found in the scan list (Ad-Hoc or Hidden), or until
|
* until the real one is found in the scan list (Ad-Hoc or Hidden), or until
|
||||||
* the device is deactivated (Hotspot).
|
* the device is deactivated (Hotspot).
|
||||||
*/
|
*/
|
||||||
ap = nm_ap_new_fake_from_connection (connection);
|
ap = nm_wifi_ap_new_fake_from_connection (connection);
|
||||||
g_return_val_if_fail (ap != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
g_return_val_if_fail (ap != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||||
|
|
||||||
if (nm_ap_is_hotspot (ap))
|
if (nm_wifi_ap_is_hotspot (ap))
|
||||||
nm_ap_set_address (ap, nm_device_get_hw_address (device));
|
nm_wifi_ap_set_address (ap, nm_device_get_hw_address (device));
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (self));
|
g_object_freeze_notify (G_OBJECT (self));
|
||||||
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
|
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
|
||||||
@@ -2451,7 +2451,7 @@ done:
|
|||||||
static void
|
static void
|
||||||
ensure_hotspot_frequency (NMDeviceWifi *self,
|
ensure_hotspot_frequency (NMDeviceWifi *self,
|
||||||
NMSettingWireless *s_wifi,
|
NMSettingWireless *s_wifi,
|
||||||
NMAccessPoint *ap)
|
NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
const char *band = nm_setting_wireless_get_band (s_wifi);
|
const char *band = nm_setting_wireless_get_band (s_wifi);
|
||||||
const guint32 a_freqs[] = { 5180, 5200, 5220, 5745, 5765, 5785, 5805, 0 };
|
const guint32 a_freqs[] = { 5180, 5200, 5220, 5745, 5765, 5785, 5805, 0 };
|
||||||
@@ -2460,7 +2460,7 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
|
|||||||
|
|
||||||
g_assert (ap);
|
g_assert (ap);
|
||||||
|
|
||||||
if (nm_ap_get_freq (ap))
|
if (nm_wifi_ap_get_freq (ap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_strcmp0 (band, "a") == 0)
|
if (g_strcmp0 (band, "a") == 0)
|
||||||
@@ -2471,7 +2471,7 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
|
|||||||
if (!freq)
|
if (!freq)
|
||||||
freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462;
|
freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462;
|
||||||
|
|
||||||
nm_ap_set_freq (ap, freq);
|
nm_wifi_ap_set_freq (ap, freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2514,7 +2514,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
NMSupplicantConfig *config = NULL;
|
NMSupplicantConfig *config = NULL;
|
||||||
NMActRequest *req;
|
NMActRequest *req;
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
const char *setting_name;
|
const char *setting_name;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
@@ -2569,14 +2569,14 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||||||
* didn't specify one and we didn't find an AP that matched the connection,
|
* didn't specify one and we didn't find an AP that matched the connection,
|
||||||
* just pick a frequency the device supports.
|
* just pick a frequency the device supports.
|
||||||
*/
|
*/
|
||||||
if ((nm_ap_get_mode (ap) == NM_802_11_MODE_ADHOC) || nm_ap_is_hotspot (ap))
|
if ((nm_wifi_ap_get_mode (ap) == NM_802_11_MODE_ADHOC) || nm_wifi_ap_is_hotspot (ap))
|
||||||
ensure_hotspot_frequency (self, s_wireless, ap);
|
ensure_hotspot_frequency (self, s_wireless, ap);
|
||||||
|
|
||||||
if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA)
|
if (nm_wifi_ap_get_mode (ap) == NM_802_11_MODE_INFRA)
|
||||||
set_powersave (device);
|
set_powersave (device);
|
||||||
|
|
||||||
/* Build up the supplicant configuration */
|
/* Build up the supplicant configuration */
|
||||||
config = build_supplicant_config (self, connection, nm_ap_get_freq (ap), &error);
|
config = build_supplicant_config (self, connection, nm_wifi_ap_get_freq (ap), &error);
|
||||||
if (config == NULL) {
|
if (config == NULL) {
|
||||||
_LOGE (LOGD_DEVICE | LOGD_WIFI,
|
_LOGE (LOGD_DEVICE | LOGD_WIFI,
|
||||||
"Activation: (wifi) couldn't build wireless configuration: %s",
|
"Activation: (wifi) couldn't build wireless configuration: %s",
|
||||||
@@ -2822,26 +2822,26 @@ activation_success_handler (NMDevice *device)
|
|||||||
*/
|
*/
|
||||||
g_warn_if_fail (priv->current_ap);
|
g_warn_if_fail (priv->current_ap);
|
||||||
if (priv->current_ap) {
|
if (priv->current_ap) {
|
||||||
if (nm_ap_get_fake (priv->current_ap)) {
|
if (nm_wifi_ap_get_fake (priv->current_ap)) {
|
||||||
/* If the activation AP hasn't been seen by the supplicant in a scan
|
/* If the activation AP hasn't been seen by the supplicant in a scan
|
||||||
* yet, it will be "fake". This usually happens for Ad-Hoc and
|
* yet, it will be "fake". This usually happens for Ad-Hoc and
|
||||||
* AP-mode connections. Fill in the details from the device itself
|
* AP-mode connections. Fill in the details from the device itself
|
||||||
* until the supplicant sends the scan result.
|
* until the supplicant sends the scan result.
|
||||||
*/
|
*/
|
||||||
if (!nm_ap_get_address (priv->current_ap)) {
|
if (!nm_wifi_ap_get_address (priv->current_ap)) {
|
||||||
guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
|
guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
|
||||||
gs_free char *bssid_str = NULL;
|
gs_free char *bssid_str = NULL;
|
||||||
|
|
||||||
if ( nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid)
|
if ( nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid)
|
||||||
&& nm_ethernet_address_is_valid (bssid, ETH_ALEN)) {
|
&& nm_ethernet_address_is_valid (bssid, ETH_ALEN)) {
|
||||||
bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
|
bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
|
||||||
nm_ap_set_address (priv->current_ap, bssid_str);
|
nm_wifi_ap_set_address (priv->current_ap, bssid_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!nm_ap_get_freq (priv->current_ap))
|
if (!nm_wifi_ap_get_freq (priv->current_ap))
|
||||||
nm_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex));
|
nm_wifi_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex));
|
||||||
if (!nm_ap_get_max_bitrate (priv->current_ap))
|
if (!nm_wifi_ap_get_max_bitrate (priv->current_ap))
|
||||||
nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex));
|
nm_wifi_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
|
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
|
||||||
@@ -3204,7 +3204,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||||||
0,
|
0,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
NM_TYPE_AP);
|
NM_TYPE_WIFI_AP);
|
||||||
|
|
||||||
signals[ACCESS_POINT_REMOVED] =
|
signals[ACCESS_POINT_REMOVED] =
|
||||||
g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_REMOVED,
|
g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_REMOVED,
|
||||||
@@ -3213,7 +3213,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||||||
0,
|
0,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
NM_TYPE_AP);
|
NM_TYPE_WIFI_AP);
|
||||||
|
|
||||||
signals[SCANNING_ALLOWED] =
|
signals[SCANNING_ALLOWED] =
|
||||||
g_signal_new (NM_DEVICE_WIFI_SCANNING_ALLOWED,
|
g_signal_new (NM_DEVICE_WIFI_SCANNING_ALLOWED,
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "nm-wifi-ap.h"
|
#include "nm-wifi-ap.h"
|
||||||
#include "nm-wifi-ap-utils.h"
|
#include "nm-wifi-utils.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
@@ -57,22 +57,22 @@ typedef struct
|
|||||||
bool fake; /* Whether or not the AP is from a scan */
|
bool fake; /* Whether or not the AP is from a scan */
|
||||||
bool hotspot; /* Whether the AP is a local device's hotspot network */
|
bool hotspot; /* Whether the AP is a local device's hotspot network */
|
||||||
gint32 last_seen; /* Timestamp when the AP was seen lastly (obtained via nm_utils_get_monotonic_timestamp_s()) */
|
gint32 last_seen; /* Timestamp when the AP was seen lastly (obtained via nm_utils_get_monotonic_timestamp_s()) */
|
||||||
} NMAccessPointPrivate;
|
} NMWifiAPPrivate;
|
||||||
|
|
||||||
struct _NMAccessPoint {
|
struct _NMWifiAP {
|
||||||
NMExportedObject parent;
|
NMExportedObject parent;
|
||||||
NMAccessPointPrivate _priv;
|
NMWifiAPPrivate _priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _NMAccessPointClass{
|
struct _NMWifiAPClass{
|
||||||
NMExportedObjectClass parent;
|
NMExportedObjectClass parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NM_AP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMAccessPoint, NM_IS_AP)
|
#define NM_WIFI_AP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMWifiAP, NM_IS_WIFI_AP)
|
||||||
|
|
||||||
G_DEFINE_TYPE (NMAccessPoint, nm_ap, NM_TYPE_EXPORTED_OBJECT)
|
G_DEFINE_TYPE (NMWifiAP, nm_wifi_ap, NM_TYPE_EXPORTED_OBJECT)
|
||||||
|
|
||||||
NM_GOBJECT_PROPERTIES_DEFINE (NMAccessPoint,
|
NM_GOBJECT_PROPERTIES_DEFINE (NMWifiAP,
|
||||||
PROP_FLAGS,
|
PROP_FLAGS,
|
||||||
PROP_WPA_FLAGS,
|
PROP_WPA_FLAGS,
|
||||||
PROP_RSN_FLAGS,
|
PROP_RSN_FLAGS,
|
||||||
@@ -88,38 +88,38 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMAccessPoint,
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
nm_ap_get_supplicant_path (NMAccessPoint *ap)
|
nm_wifi_ap_get_supplicant_path (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->supplicant_path;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->supplicant_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_ap_get_id (NMAccessPoint *ap)
|
nm_wifi_ap_get_id (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
|
||||||
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0);
|
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0);
|
||||||
|
|
||||||
return atoi (strrchr (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)), '/') + 1);
|
return atoi (strrchr (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)), '/') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GByteArray * nm_ap_get_ssid (const NMAccessPoint *ap)
|
const GByteArray * nm_wifi_ap_get_ssid (const NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->ssid;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->ssid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len)
|
nm_wifi_ap_set_ssid (NMWifiAP *ap, const guint8 *ssid, gsize len)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
g_return_if_fail (ssid == NULL || len > 0);
|
g_return_if_fail (ssid == NULL || len > 0);
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
/* same SSID */
|
/* same SSID */
|
||||||
if ((ssid && priv->ssid) && (len == priv->ssid->len)) {
|
if ((ssid && priv->ssid) && (len == priv->ssid->len)) {
|
||||||
@@ -141,13 +141,13 @@ nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags)
|
nm_wifi_ap_set_flags (NMWifiAP *ap, NM80211ApFlags flags)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (priv->flags != flags) {
|
if (priv->flags != flags) {
|
||||||
priv->flags = flags;
|
priv->flags = flags;
|
||||||
@@ -156,13 +156,13 @@ nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_set_wpa_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags)
|
nm_wifi_ap_set_wpa_flags (NMWifiAP *ap, NM80211ApSecurityFlags flags)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
if (priv->wpa_flags != flags) {
|
if (priv->wpa_flags != flags) {
|
||||||
priv->wpa_flags = flags;
|
priv->wpa_flags = flags;
|
||||||
_notify (ap, PROP_WPA_FLAGS);
|
_notify (ap, PROP_WPA_FLAGS);
|
||||||
@@ -170,13 +170,13 @@ nm_ap_set_wpa_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags)
|
nm_wifi_ap_set_rsn_flags (NMWifiAP *ap, NM80211ApSecurityFlags flags)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
if (priv->rsn_flags != flags) {
|
if (priv->rsn_flags != flags) {
|
||||||
priv->rsn_flags = flags;
|
priv->rsn_flags = flags;
|
||||||
_notify (ap, PROP_RSN_FLAGS);
|
_notify (ap, PROP_RSN_FLAGS);
|
||||||
@@ -184,23 +184,23 @@ nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
nm_ap_get_address (const NMAccessPoint *ap)
|
nm_wifi_ap_get_address (const NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->address;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->address;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_address (NMAccessPoint *ap, const char *addr)
|
nm_wifi_ap_set_address (NMWifiAP *ap, const char *addr)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
g_return_if_fail (addr != NULL);
|
g_return_if_fail (addr != NULL);
|
||||||
g_return_if_fail (nm_utils_hwaddr_valid (addr, ETH_ALEN));
|
g_return_if_fail (nm_utils_hwaddr_valid (addr, ETH_ALEN));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (!priv->address || !nm_utils_hwaddr_matches (addr, -1, priv->address, -1)) {
|
if (!priv->address || !nm_utils_hwaddr_matches (addr, -1, priv->address, -1)) {
|
||||||
g_free (priv->address);
|
g_free (priv->address);
|
||||||
@@ -210,23 +210,23 @@ nm_ap_set_address (NMAccessPoint *ap, const char *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NM80211Mode
|
NM80211Mode
|
||||||
nm_ap_get_mode (NMAccessPoint *ap)
|
nm_wifi_ap_get_mode (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), NM_802_11_MODE_UNKNOWN);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), NM_802_11_MODE_UNKNOWN);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->mode;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode)
|
nm_wifi_ap_set_mode (NMWifiAP *ap, const NM80211Mode mode)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
g_return_if_fail ( mode == NM_802_11_MODE_ADHOC
|
g_return_if_fail ( mode == NM_802_11_MODE_ADHOC
|
||||||
|| mode == NM_802_11_MODE_INFRA);
|
|| mode == NM_802_11_MODE_INFRA);
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (priv->mode != mode) {
|
if (priv->mode != mode) {
|
||||||
priv->mode = mode;
|
priv->mode = mode;
|
||||||
@@ -235,29 +235,29 @@ nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_ap_is_hotspot (NMAccessPoint *ap)
|
nm_wifi_ap_is_hotspot (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), FALSE);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->hotspot;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->hotspot;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint8
|
gint8
|
||||||
nm_ap_get_strength (NMAccessPoint *ap)
|
nm_wifi_ap_get_strength (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->strength;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength)
|
nm_wifi_ap_set_strength (NMWifiAP *ap, const gint8 strength)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (priv->strength != strength) {
|
if (priv->strength != strength) {
|
||||||
priv->strength = strength;
|
priv->strength = strength;
|
||||||
@@ -266,22 +266,22 @@ nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength)
|
|||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_ap_get_freq (NMAccessPoint *ap)
|
nm_wifi_ap_get_freq (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->freq;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_freq (NMAccessPoint *ap,
|
nm_wifi_ap_set_freq (NMWifiAP *ap,
|
||||||
const guint32 freq)
|
const guint32 freq)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (priv->freq != freq) {
|
if (priv->freq != freq) {
|
||||||
priv->freq = freq;
|
priv->freq = freq;
|
||||||
@@ -290,22 +290,22 @@ nm_ap_set_freq (NMAccessPoint *ap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_ap_get_max_bitrate (NMAccessPoint *ap)
|
nm_wifi_ap_get_max_bitrate (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0);
|
||||||
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0);
|
g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->max_bitrate;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->max_bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate)
|
nm_wifi_ap_set_max_bitrate (NMWifiAP *ap, guint32 bitrate)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (priv->max_bitrate != bitrate) {
|
if (priv->max_bitrate != bitrate) {
|
||||||
priv->max_bitrate = bitrate;
|
priv->max_bitrate = bitrate;
|
||||||
@@ -314,29 +314,29 @@ nm_ap_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_ap_get_fake (const NMAccessPoint *ap)
|
nm_wifi_ap_get_fake (const NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
g_return_val_if_fail (NM_IS_WIFI_AP (ap), FALSE);
|
||||||
|
|
||||||
return NM_AP_GET_PRIVATE (ap)->fake;
|
return NM_WIFI_AP_GET_PRIVATE (ap)->fake;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_set_fake (NMAccessPoint *ap, gboolean fake)
|
nm_wifi_ap_set_fake (NMWifiAP *ap, gboolean fake)
|
||||||
{
|
{
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
NM_AP_GET_PRIVATE (ap)->fake = fake;
|
NM_WIFI_AP_GET_PRIVATE (ap)->fake = fake;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen)
|
nm_wifi_ap_set_last_seen (NMWifiAP *ap, gint32 last_seen)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (ap));
|
g_return_if_fail (NM_IS_WIFI_AP (ap));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
if (priv->last_seen != last_seen) {
|
if (priv->last_seen != last_seen) {
|
||||||
priv->last_seen = last_seen;
|
priv->last_seen = last_seen;
|
||||||
@@ -387,11 +387,11 @@ security_from_vardict (GVariant *security)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_update_from_properties (NMAccessPoint *ap,
|
nm_wifi_ap_update_from_properties (NMWifiAP *ap,
|
||||||
const char *supplicant_path,
|
const char *supplicant_path,
|
||||||
GVariant *properties)
|
GVariant *properties)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
char *addr;
|
char *addr;
|
||||||
const guint8 *bytes;
|
const guint8 *bytes;
|
||||||
GVariant *v;
|
GVariant *v;
|
||||||
@@ -403,25 +403,25 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
|
|||||||
|
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
g_return_if_fail (properties != NULL);
|
g_return_if_fail (properties != NULL);
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (ap));
|
g_object_freeze_notify (G_OBJECT (ap));
|
||||||
|
|
||||||
if (g_variant_lookup (properties, "Privacy", "b", &b) && b)
|
if (g_variant_lookup (properties, "Privacy", "b", &b) && b)
|
||||||
nm_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY);
|
nm_wifi_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY);
|
||||||
|
|
||||||
if (g_variant_lookup (properties, "Mode", "&s", &s)) {
|
if (g_variant_lookup (properties, "Mode", "&s", &s)) {
|
||||||
if (!g_strcmp0 (s, "infrastructure"))
|
if (!g_strcmp0 (s, "infrastructure"))
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||||
else if (!g_strcmp0 (s, "ad-hoc"))
|
else if (!g_strcmp0 (s, "ad-hoc"))
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_variant_lookup (properties, "Signal", "n", &i16))
|
if (g_variant_lookup (properties, "Signal", "n", &i16))
|
||||||
nm_ap_set_strength (ap, nm_ap_utils_level_to_quality (i16));
|
nm_wifi_ap_set_strength (ap, nm_wifi_utils_level_to_quality (i16));
|
||||||
|
|
||||||
if (g_variant_lookup (properties, "Frequency", "q", &u16))
|
if (g_variant_lookup (properties, "Frequency", "q", &u16))
|
||||||
nm_ap_set_freq (ap, u16);
|
nm_wifi_ap_set_freq (ap, u16);
|
||||||
|
|
||||||
v = g_variant_lookup_value (properties, "SSID", G_VARIANT_TYPE_BYTESTRING);
|
v = g_variant_lookup_value (properties, "SSID", G_VARIANT_TYPE_BYTESTRING);
|
||||||
if (v) {
|
if (v) {
|
||||||
@@ -432,7 +432,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
|
|||||||
if ( bytes && len
|
if ( bytes && len
|
||||||
&& !(((len == 8) || (len == 9)) && !memcmp (bytes, "<hidden>", 8))
|
&& !(((len == 8) || (len == 9)) && !memcmp (bytes, "<hidden>", 8))
|
||||||
&& !nm_utils_is_empty_ssid (bytes, len))
|
&& !nm_utils_is_empty_ssid (bytes, len))
|
||||||
nm_ap_set_ssid (ap, bytes, len);
|
nm_wifi_ap_set_ssid (ap, bytes, len);
|
||||||
|
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
|
|||||||
bytes = g_variant_get_fixed_array (v, &len, 1);
|
bytes = g_variant_get_fixed_array (v, &len, 1);
|
||||||
if (len == ETH_ALEN) {
|
if (len == ETH_ALEN) {
|
||||||
addr = nm_utils_hwaddr_ntoa (bytes, len);
|
addr = nm_utils_hwaddr_ntoa (bytes, len);
|
||||||
nm_ap_set_address (ap, addr);
|
nm_wifi_ap_set_address (ap, addr);
|
||||||
g_free (addr);
|
g_free (addr);
|
||||||
}
|
}
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
@@ -458,7 +458,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
|
|||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (rates[i] > maxrate) {
|
if (rates[i] > maxrate) {
|
||||||
maxrate = rates[i];
|
maxrate = rates[i];
|
||||||
nm_ap_set_max_bitrate (ap, rates[i] / 1000);
|
nm_wifi_ap_set_max_bitrate (ap, rates[i] / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
@@ -466,41 +466,41 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
|
|||||||
|
|
||||||
v = g_variant_lookup_value (properties, "WPA", G_VARIANT_TYPE_VARDICT);
|
v = g_variant_lookup_value (properties, "WPA", G_VARIANT_TYPE_VARDICT);
|
||||||
if (v) {
|
if (v) {
|
||||||
nm_ap_set_wpa_flags (ap, priv->wpa_flags | security_from_vardict (v));
|
nm_wifi_ap_set_wpa_flags (ap, priv->wpa_flags | security_from_vardict (v));
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
v = g_variant_lookup_value (properties, "RSN", G_VARIANT_TYPE_VARDICT);
|
v = g_variant_lookup_value (properties, "RSN", G_VARIANT_TYPE_VARDICT);
|
||||||
if (v) {
|
if (v) {
|
||||||
nm_ap_set_rsn_flags (ap, priv->rsn_flags | security_from_vardict (v));
|
nm_wifi_ap_set_rsn_flags (ap, priv->rsn_flags | security_from_vardict (v));
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->supplicant_path)
|
if (!priv->supplicant_path)
|
||||||
priv->supplicant_path = g_strdup (supplicant_path);
|
priv->supplicant_path = g_strdup (supplicant_path);
|
||||||
|
|
||||||
nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ());
|
nm_wifi_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ());
|
||||||
priv->fake = FALSE;
|
priv->fake = FALSE;
|
||||||
|
|
||||||
g_object_thaw_notify (G_OBJECT (ap));
|
g_object_thaw_notify (G_OBJECT (ap));
|
||||||
}
|
}
|
||||||
|
|
||||||
NMAccessPoint *
|
NMWifiAP *
|
||||||
nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties)
|
nm_wifi_ap_new_from_properties (const char *supplicant_path, GVariant *properties)
|
||||||
{
|
{
|
||||||
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 };
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
const char *addr;
|
const char *addr;
|
||||||
|
|
||||||
g_return_val_if_fail (supplicant_path != NULL, NULL);
|
g_return_val_if_fail (supplicant_path != NULL, NULL);
|
||||||
g_return_val_if_fail (properties != NULL, NULL);
|
g_return_val_if_fail (properties != NULL, NULL);
|
||||||
|
|
||||||
ap = (NMAccessPoint *) g_object_new (NM_TYPE_AP, NULL);
|
ap = (NMWifiAP *) g_object_new (NM_TYPE_WIFI_AP, NULL);
|
||||||
nm_ap_update_from_properties (ap, supplicant_path, properties);
|
nm_wifi_ap_update_from_properties (ap, supplicant_path, properties);
|
||||||
|
|
||||||
/* ignore APs with invalid or missing BSSIDs */
|
/* ignore APs with invalid or missing BSSIDs */
|
||||||
addr = nm_ap_get_address (ap);
|
addr = nm_wifi_ap_get_address (ap);
|
||||||
if ( !addr
|
if ( !addr
|
||||||
|| nm_utils_hwaddr_matches (addr, -1, bad_bssid1, ETH_ALEN)
|
|| nm_utils_hwaddr_matches (addr, -1, bad_bssid1, ETH_ALEN)
|
||||||
|| nm_utils_hwaddr_matches (addr, -1, bad_bssid2, ETH_ALEN)) {
|
|| nm_utils_hwaddr_matches (addr, -1, bad_bssid2, ETH_ALEN)) {
|
||||||
@@ -531,9 +531,9 @@ has_proto (NMSettingWirelessSecurity *sec, const char *proto)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_pair_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec)
|
add_pair_ciphers (NMWifiAP *ap, NMSettingWirelessSecurity *sec)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
guint32 num = nm_setting_wireless_security_get_num_pairwise (sec);
|
guint32 num = nm_setting_wireless_security_get_num_pairwise (sec);
|
||||||
NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE;
|
NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE;
|
||||||
guint32 i;
|
guint32 i;
|
||||||
@@ -553,15 +553,15 @@ add_pair_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (has_proto (sec, PROTO_WPA))
|
if (has_proto (sec, PROTO_WPA))
|
||||||
nm_ap_set_wpa_flags (ap, priv->wpa_flags | flags);
|
nm_wifi_ap_set_wpa_flags (ap, priv->wpa_flags | flags);
|
||||||
if (has_proto (sec, PROTO_RSN))
|
if (has_proto (sec, PROTO_RSN))
|
||||||
nm_ap_set_rsn_flags (ap, priv->rsn_flags | flags);
|
nm_wifi_ap_set_rsn_flags (ap, priv->rsn_flags | flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_group_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec)
|
add_group_ciphers (NMWifiAP *ap, NMSettingWirelessSecurity *sec)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
guint32 num = nm_setting_wireless_security_get_num_groups (sec);
|
guint32 num = nm_setting_wireless_security_get_num_groups (sec);
|
||||||
NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE;
|
NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE;
|
||||||
guint32 i;
|
guint32 i;
|
||||||
@@ -585,16 +585,16 @@ add_group_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (has_proto (sec, PROTO_WPA))
|
if (has_proto (sec, PROTO_WPA))
|
||||||
nm_ap_set_wpa_flags (ap, priv->wpa_flags | flags);
|
nm_wifi_ap_set_wpa_flags (ap, priv->wpa_flags | flags);
|
||||||
if (has_proto (sec, PROTO_RSN))
|
if (has_proto (sec, PROTO_RSN))
|
||||||
nm_ap_set_rsn_flags (ap, priv->rsn_flags | flags);
|
nm_wifi_ap_set_rsn_flags (ap, priv->rsn_flags | flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
NMAccessPoint *
|
NMWifiAP *
|
||||||
nm_ap_new_fake_from_connection (NMConnection *connection)
|
nm_wifi_ap_new_fake_from_connection (NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap;
|
NMWifiAP *ap;
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
NMSettingWirelessSecurity *s_wireless_sec;
|
NMSettingWirelessSecurity *s_wireless_sec;
|
||||||
GBytes *ssid;
|
GBytes *ssid;
|
||||||
@@ -612,26 +612,26 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
g_return_val_if_fail (ssid != NULL, NULL);
|
g_return_val_if_fail (ssid != NULL, NULL);
|
||||||
g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL);
|
g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL);
|
||||||
|
|
||||||
ap = (NMAccessPoint *) g_object_new (NM_TYPE_AP, NULL);
|
ap = (NMWifiAP *) g_object_new (NM_TYPE_WIFI_AP, NULL);
|
||||||
priv = NM_AP_GET_PRIVATE (ap);
|
priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
priv->fake = TRUE;
|
priv->fake = TRUE;
|
||||||
nm_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
|
nm_wifi_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
|
||||||
|
|
||||||
// FIXME: bssid too?
|
// FIXME: bssid too?
|
||||||
|
|
||||||
mode = nm_setting_wireless_get_mode (s_wireless);
|
mode = nm_setting_wireless_get_mode (s_wireless);
|
||||||
if (mode) {
|
if (mode) {
|
||||||
if (!strcmp (mode, "infrastructure"))
|
if (!strcmp (mode, "infrastructure"))
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||||
else if (!strcmp (mode, "adhoc"))
|
else if (!strcmp (mode, "adhoc"))
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
||||||
else if (!strcmp (mode, "ap")) {
|
else if (!strcmp (mode, "ap")) {
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||||
NM_AP_GET_PRIVATE (ap)->hotspot = TRUE;
|
NM_WIFI_AP_GET_PRIVATE (ap)->hotspot = TRUE;
|
||||||
} else
|
} else
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
band = nm_setting_wireless_get_band (s_wireless);
|
band = nm_setting_wireless_get_band (s_wireless);
|
||||||
@@ -643,7 +643,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
if (freq == 0)
|
if (freq == 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
nm_ap_set_freq (ap, freq);
|
nm_wifi_ap_set_freq (ap, freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
|
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
|
||||||
@@ -654,7 +654,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
|
key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
|
||||||
|
|
||||||
/* Everything below here uses encryption */
|
/* Everything below here uses encryption */
|
||||||
nm_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY);
|
nm_wifi_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY);
|
||||||
|
|
||||||
/* Static & Dynamic WEP */
|
/* Static & Dynamic WEP */
|
||||||
if (!strcmp (key_mgmt, "none") || !strcmp (key_mgmt, "ieee8021x"))
|
if (!strcmp (key_mgmt, "none") || !strcmp (key_mgmt, "ieee8021x"))
|
||||||
@@ -665,11 +665,11 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
if (psk || eap) {
|
if (psk || eap) {
|
||||||
if (has_proto (s_wireless_sec, PROTO_WPA)) {
|
if (has_proto (s_wireless_sec, PROTO_WPA)) {
|
||||||
flags = priv->wpa_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK);
|
flags = priv->wpa_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK);
|
||||||
nm_ap_set_wpa_flags (ap, flags);
|
nm_wifi_ap_set_wpa_flags (ap, flags);
|
||||||
}
|
}
|
||||||
if (has_proto (s_wireless_sec, PROTO_RSN)) {
|
if (has_proto (s_wireless_sec, PROTO_RSN)) {
|
||||||
flags = priv->rsn_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK);
|
flags = priv->rsn_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK);
|
||||||
nm_ap_set_rsn_flags (ap, flags);
|
nm_wifi_ap_set_rsn_flags (ap, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_pair_ciphers (ap, s_wireless_sec);
|
add_pair_ciphers (ap, s_wireless_sec);
|
||||||
@@ -704,10 +704,10 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||||||
if (!(flags & NM_802_11_AP_SEC_GROUP_CCMP))
|
if (!(flags & NM_802_11_AP_SEC_GROUP_CCMP))
|
||||||
flags |= NM_802_11_AP_SEC_GROUP_TKIP;
|
flags |= NM_802_11_AP_SEC_GROUP_TKIP;
|
||||||
|
|
||||||
nm_ap_set_wpa_flags (ap, flags);
|
nm_wifi_ap_set_wpa_flags (ap, flags);
|
||||||
|
|
||||||
/* Don't use Ad-Hoc RSN yet */
|
/* Don't use Ad-Hoc RSN yet */
|
||||||
nm_ap_set_rsn_flags (ap, NM_802_11_AP_SEC_NONE);
|
nm_wifi_ap_set_rsn_flags (ap, NM_802_11_AP_SEC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@@ -719,9 +719,9 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char
|
static char
|
||||||
mode_to_char (NMAccessPoint *self)
|
mode_to_char (NMWifiAP *self)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (self);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (self);
|
||||||
|
|
||||||
if (priv->mode == NM_802_11_MODE_ADHOC)
|
if (priv->mode == NM_802_11_MODE_ADHOC)
|
||||||
return '*';
|
return '*';
|
||||||
@@ -733,17 +733,17 @@ mode_to_char (NMAccessPoint *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ap_dump (NMAccessPoint *self,
|
nm_wifi_ap_dump (NMWifiAP *self,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *ifname)
|
const char *ifname)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
const char *supplicant_id = "-";
|
const char *supplicant_id = "-";
|
||||||
guint32 chan;
|
guint32 chan;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_AP (self));
|
g_return_if_fail (NM_IS_WIFI_AP (self));
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (self);
|
priv = NM_WIFI_AP_GET_PRIVATE (self);
|
||||||
chan = nm_utils_wifi_freq_to_channel (priv->freq);
|
chan = nm_utils_wifi_freq_to_channel (priv->freq);
|
||||||
if (priv->supplicant_path)
|
if (priv->supplicant_path)
|
||||||
supplicant_id = strrchr (priv->supplicant_path, '/');
|
supplicant_id = strrchr (priv->supplicant_path, '/');
|
||||||
@@ -775,10 +775,10 @@ freq_to_band (guint32 freq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_ap_check_compatible (NMAccessPoint *self,
|
nm_wifi_ap_check_compatible (NMWifiAP *self,
|
||||||
NMConnection *connection)
|
NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv;
|
NMWifiAPPrivate *priv;
|
||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
NMSettingWirelessSecurity *s_wireless_sec;
|
NMSettingWirelessSecurity *s_wireless_sec;
|
||||||
GBytes *ssid;
|
GBytes *ssid;
|
||||||
@@ -787,10 +787,10 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||||||
const char *bssid;
|
const char *bssid;
|
||||||
guint32 channel;
|
guint32 channel;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_AP (self), FALSE);
|
g_return_val_if_fail (NM_IS_WIFI_AP (self), FALSE);
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||||
|
|
||||||
priv = NM_AP_GET_PRIVATE (self);
|
priv = NM_WIFI_AP_GET_PRIVATE (self);
|
||||||
|
|
||||||
s_wireless = nm_connection_get_setting_wireless (connection);
|
s_wireless = nm_connection_get_setting_wireless (connection);
|
||||||
if (s_wireless == NULL)
|
if (s_wireless == NULL)
|
||||||
@@ -851,32 +851,32 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_ap_complete_connection (NMAccessPoint *self,
|
nm_wifi_ap_complete_connection (NMWifiAP *self,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean lock_bssid,
|
gboolean lock_bssid,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (self);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (self);
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, FALSE);
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
|
||||||
return nm_ap_utils_complete_connection (priv->ssid,
|
return nm_wifi_utils_complete_connection (priv->ssid,
|
||||||
priv->address,
|
priv->address,
|
||||||
priv->mode,
|
priv->mode,
|
||||||
priv->flags,
|
priv->flags,
|
||||||
priv->wpa_flags,
|
priv->wpa_flags,
|
||||||
priv->rsn_flags,
|
priv->rsn_flags,
|
||||||
connection,
|
connection,
|
||||||
lock_bssid,
|
lock_bssid,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_init (NMAccessPoint *ap)
|
nm_wifi_ap_init (NMWifiAP *ap)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
priv->mode = NM_802_11_MODE_INFRA;
|
priv->mode = NM_802_11_MODE_INFRA;
|
||||||
priv->flags = NM_802_11_AP_FLAGS_NONE;
|
priv->flags = NM_802_11_AP_FLAGS_NONE;
|
||||||
@@ -888,14 +888,14 @@ nm_ap_init (NMAccessPoint *ap)
|
|||||||
static void
|
static void
|
||||||
finalize (GObject *object)
|
finalize (GObject *object)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE ((NMAccessPoint *) object);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE ((NMWifiAP *) object);
|
||||||
|
|
||||||
g_free (priv->supplicant_path);
|
g_free (priv->supplicant_path);
|
||||||
if (priv->ssid)
|
if (priv->ssid)
|
||||||
g_byte_array_free (priv->ssid, TRUE);
|
g_byte_array_free (priv->ssid, TRUE);
|
||||||
g_free (priv->address);
|
g_free (priv->address);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_ap_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_wifi_ap_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -909,7 +909,7 @@ static void
|
|||||||
get_property (GObject *object, guint prop_id,
|
get_property (GObject *object, guint prop_id,
|
||||||
GValue *value, GParamSpec *pspec)
|
GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE ((NMAccessPoint *) object);
|
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE ((NMWifiAP *) object);
|
||||||
GVariant *ssid;
|
GVariant *ssid;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
@@ -958,7 +958,7 @@ get_property (GObject *object, guint prop_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_ap_class_init (NMAccessPointClass *ap_class)
|
nm_wifi_ap_class_init (NMWifiAPClass *ap_class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
|
||||||
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ap_class);
|
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ap_class);
|
||||||
@@ -983,59 +983,59 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
|
|||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
obj_properties[PROP_FLAGS] =
|
obj_properties[PROP_FLAGS] =
|
||||||
g_param_spec_uint (NM_AP_FLAGS, "", "",
|
g_param_spec_uint (NM_WIFI_AP_FLAGS, "", "",
|
||||||
NM_802_11_AP_FLAGS_NONE,
|
NM_802_11_AP_FLAGS_NONE,
|
||||||
NM_802_11_AP_FLAGS_PRIVACY,
|
NM_802_11_AP_FLAGS_PRIVACY,
|
||||||
NM_802_11_AP_FLAGS_NONE,
|
NM_802_11_AP_FLAGS_NONE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_WPA_FLAGS] =
|
obj_properties[PROP_WPA_FLAGS] =
|
||||||
g_param_spec_uint (NM_AP_WPA_FLAGS, "", "",
|
g_param_spec_uint (NM_WIFI_AP_WPA_FLAGS, "", "",
|
||||||
NM_802_11_AP_SEC_NONE,
|
NM_802_11_AP_SEC_NONE,
|
||||||
all_sec_flags,
|
all_sec_flags,
|
||||||
NM_802_11_AP_SEC_NONE,
|
NM_802_11_AP_SEC_NONE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_RSN_FLAGS] =
|
obj_properties[PROP_RSN_FLAGS] =
|
||||||
g_param_spec_uint (NM_AP_RSN_FLAGS, "", "",
|
g_param_spec_uint (NM_WIFI_AP_RSN_FLAGS, "", "",
|
||||||
NM_802_11_AP_SEC_NONE,
|
NM_802_11_AP_SEC_NONE,
|
||||||
all_sec_flags,
|
all_sec_flags,
|
||||||
NM_802_11_AP_SEC_NONE,
|
NM_802_11_AP_SEC_NONE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_SSID] =
|
obj_properties[PROP_SSID] =
|
||||||
g_param_spec_variant (NM_AP_SSID, "", "",
|
g_param_spec_variant (NM_WIFI_AP_SSID, "", "",
|
||||||
G_VARIANT_TYPE ("ay"),
|
G_VARIANT_TYPE ("ay"),
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_FREQUENCY] =
|
obj_properties[PROP_FREQUENCY] =
|
||||||
g_param_spec_uint (NM_AP_FREQUENCY, "", "",
|
g_param_spec_uint (NM_WIFI_AP_FREQUENCY, "", "",
|
||||||
0, 10000, 0,
|
0, 10000, 0,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_HW_ADDRESS] =
|
obj_properties[PROP_HW_ADDRESS] =
|
||||||
g_param_spec_string (NM_AP_HW_ADDRESS, "", "",
|
g_param_spec_string (NM_WIFI_AP_HW_ADDRESS, "", "",
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_MODE] =
|
obj_properties[PROP_MODE] =
|
||||||
g_param_spec_uint (NM_AP_MODE, "", "",
|
g_param_spec_uint (NM_WIFI_AP_MODE, "", "",
|
||||||
NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA,
|
NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_MAX_BITRATE] =
|
obj_properties[PROP_MAX_BITRATE] =
|
||||||
g_param_spec_uint (NM_AP_MAX_BITRATE, "", "",
|
g_param_spec_uint (NM_WIFI_AP_MAX_BITRATE, "", "",
|
||||||
0, G_MAXUINT16, 0,
|
0, G_MAXUINT16, 0,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_STRENGTH] =
|
obj_properties[PROP_STRENGTH] =
|
||||||
g_param_spec_uchar (NM_AP_STRENGTH, "", "",
|
g_param_spec_uchar (NM_WIFI_AP_STRENGTH, "", "",
|
||||||
0, G_MAXINT8, 0,
|
0, G_MAXINT8, 0,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_LAST_SEEN] =
|
obj_properties[PROP_LAST_SEEN] =
|
||||||
g_param_spec_int (NM_AP_LAST_SEEN, "", "",
|
g_param_spec_int (NM_WIFI_AP_LAST_SEEN, "", "",
|
||||||
-1, G_MAXINT, -1,
|
-1, G_MAXINT, -1,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
@@ -19,78 +19,78 @@
|
|||||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NETWORKMANAGER_ACCESS_POINT_H__
|
#ifndef __NM_WIFI_AP_H__
|
||||||
#define __NETWORKMANAGER_ACCESS_POINT_H__
|
#define __NM_WIFI_AP_H__
|
||||||
|
|
||||||
#include "nm-exported-object.h"
|
#include "nm-exported-object.h"
|
||||||
#include "nm-dbus-interface.h"
|
#include "nm-dbus-interface.h"
|
||||||
#include "nm-connection.h"
|
#include "nm-connection.h"
|
||||||
|
|
||||||
#define NM_TYPE_AP (nm_ap_get_type ())
|
#define NM_TYPE_WIFI_AP (nm_wifi_ap_get_type ())
|
||||||
#define NM_AP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AP, NMAccessPoint))
|
#define NM_WIFI_AP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_AP, NMWifiAP))
|
||||||
#define NM_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_AP, NMAccessPointClass))
|
#define NM_WIFI_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_AP, NMWifiAPClass))
|
||||||
#define NM_IS_AP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_AP))
|
#define NM_IS_WIFI_AP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_AP))
|
||||||
#define NM_IS_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AP))
|
#define NM_IS_WIFI_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_AP))
|
||||||
#define NM_AP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AP, NMAccessPointClass))
|
#define NM_WIFI_AP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_AP, NMWifiAPClass))
|
||||||
|
|
||||||
#define NM_AP_FLAGS "flags"
|
#define NM_WIFI_AP_FLAGS "flags"
|
||||||
#define NM_AP_WPA_FLAGS "wpa-flags"
|
#define NM_WIFI_AP_WPA_FLAGS "wpa-flags"
|
||||||
#define NM_AP_RSN_FLAGS "rsn-flags"
|
#define NM_WIFI_AP_RSN_FLAGS "rsn-flags"
|
||||||
#define NM_AP_SSID "ssid"
|
#define NM_WIFI_AP_SSID "ssid"
|
||||||
#define NM_AP_FREQUENCY "frequency"
|
#define NM_WIFI_AP_FREQUENCY "frequency"
|
||||||
#define NM_AP_HW_ADDRESS "hw-address"
|
#define NM_WIFI_AP_HW_ADDRESS "hw-address"
|
||||||
#define NM_AP_MODE "mode"
|
#define NM_WIFI_AP_MODE "mode"
|
||||||
#define NM_AP_MAX_BITRATE "max-bitrate"
|
#define NM_WIFI_AP_MAX_BITRATE "max-bitrate"
|
||||||
#define NM_AP_STRENGTH "strength"
|
#define NM_WIFI_AP_STRENGTH "strength"
|
||||||
#define NM_AP_LAST_SEEN "last-seen"
|
#define NM_WIFI_AP_LAST_SEEN "last-seen"
|
||||||
|
|
||||||
typedef struct _NMAccessPoint NMAccessPoint;
|
typedef struct _NMWifiAP NMWifiAP;
|
||||||
typedef struct _NMAccessPointClass NMAccessPointClass;
|
typedef struct _NMWifiAPClass NMWifiAPClass;
|
||||||
|
|
||||||
GType nm_ap_get_type (void);
|
GType nm_wifi_ap_get_type (void);
|
||||||
|
|
||||||
NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path,
|
NMWifiAP * nm_wifi_ap_new_from_properties (const char *supplicant_path,
|
||||||
GVariant *properties);
|
GVariant *properties);
|
||||||
NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection);
|
NMWifiAP * nm_wifi_ap_new_fake_from_connection (NMConnection *connection);
|
||||||
|
|
||||||
void nm_ap_update_from_properties (NMAccessPoint *ap,
|
void nm_wifi_ap_update_from_properties (NMWifiAP *ap,
|
||||||
const char *supplicant_path,
|
const char *supplicant_path,
|
||||||
GVariant *properties);
|
GVariant *properties);
|
||||||
|
|
||||||
gboolean nm_ap_check_compatible (NMAccessPoint *self,
|
gboolean nm_wifi_ap_check_compatible (NMWifiAP *self,
|
||||||
NMConnection *connection);
|
NMConnection *connection);
|
||||||
|
|
||||||
gboolean nm_ap_complete_connection (NMAccessPoint *self,
|
gboolean nm_wifi_ap_complete_connection (NMWifiAP *self,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean lock_bssid,
|
gboolean lock_bssid,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
const char * nm_ap_get_supplicant_path (NMAccessPoint *ap);
|
const char * nm_wifi_ap_get_supplicant_path (NMWifiAP *ap);
|
||||||
guint32 nm_ap_get_id (NMAccessPoint *ap);
|
guint32 nm_wifi_ap_get_id (NMWifiAP *ap);
|
||||||
const GByteArray *nm_ap_get_ssid (const NMAccessPoint *ap);
|
const GByteArray *nm_wifi_ap_get_ssid (const NMWifiAP *ap);
|
||||||
void nm_ap_set_ssid (NMAccessPoint *ap,
|
void nm_wifi_ap_set_ssid (NMWifiAP *ap,
|
||||||
const guint8 *ssid,
|
const guint8 *ssid,
|
||||||
gsize len);
|
gsize len);
|
||||||
const char * nm_ap_get_address (const NMAccessPoint *ap);
|
const char * nm_wifi_ap_get_address (const NMWifiAP *ap);
|
||||||
void nm_ap_set_address (NMAccessPoint *ap,
|
void nm_wifi_ap_set_address (NMWifiAP *ap,
|
||||||
const char *addr);
|
const char *addr);
|
||||||
NM80211Mode nm_ap_get_mode (NMAccessPoint *ap);
|
NM80211Mode nm_wifi_ap_get_mode (NMWifiAP *ap);
|
||||||
gboolean nm_ap_is_hotspot (NMAccessPoint *ap);
|
gboolean nm_wifi_ap_is_hotspot (NMWifiAP *ap);
|
||||||
gint8 nm_ap_get_strength (NMAccessPoint *ap);
|
gint8 nm_wifi_ap_get_strength (NMWifiAP *ap);
|
||||||
void nm_ap_set_strength (NMAccessPoint *ap,
|
void nm_wifi_ap_set_strength (NMWifiAP *ap,
|
||||||
gint8 strength);
|
gint8 strength);
|
||||||
guint32 nm_ap_get_freq (NMAccessPoint *ap);
|
guint32 nm_wifi_ap_get_freq (NMWifiAP *ap);
|
||||||
void nm_ap_set_freq (NMAccessPoint *ap,
|
void nm_wifi_ap_set_freq (NMWifiAP *ap,
|
||||||
guint32 freq);
|
guint32 freq);
|
||||||
guint32 nm_ap_get_max_bitrate (NMAccessPoint *ap);
|
guint32 nm_wifi_ap_get_max_bitrate (NMWifiAP *ap);
|
||||||
void nm_ap_set_max_bitrate (NMAccessPoint *ap,
|
void nm_wifi_ap_set_max_bitrate (NMWifiAP *ap,
|
||||||
guint32 bitrate);
|
guint32 bitrate);
|
||||||
gboolean nm_ap_get_fake (const NMAccessPoint *ap);
|
gboolean nm_wifi_ap_get_fake (const NMWifiAP *ap);
|
||||||
void nm_ap_set_fake (NMAccessPoint *ap,
|
void nm_wifi_ap_set_fake (NMWifiAP *ap,
|
||||||
gboolean fake);
|
gboolean fake);
|
||||||
|
|
||||||
void nm_ap_dump (NMAccessPoint *self,
|
void nm_wifi_ap_dump (NMWifiAP *self,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *ifname);
|
const char *ifname);
|
||||||
|
|
||||||
#endif /* __NETWORKMANAGER_ACCESS_POINT_H__ */
|
#endif /* __NM_WIFI_AP_H__ */
|
||||||
|
@@ -20,10 +20,11 @@
|
|||||||
|
|
||||||
#include "nm-default.h"
|
#include "nm-default.h"
|
||||||
|
|
||||||
|
#include "nm-wifi-utils.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "nm-wifi-ap-utils.h"
|
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -524,15 +525,15 @@ verify_adhoc (NMSettingWirelessSecurity *s_wsec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
nm_wifi_utils_complete_connection (const GByteArray *ap_ssid,
|
||||||
const char *bssid,
|
const char *bssid,
|
||||||
NM80211Mode ap_mode,
|
NM80211Mode ap_mode,
|
||||||
guint32 ap_flags,
|
guint32 ap_flags,
|
||||||
guint32 ap_wpa_flags,
|
guint32 ap_wpa_flags,
|
||||||
guint32 ap_rsn_flags,
|
guint32 ap_rsn_flags,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean lock_bssid,
|
gboolean lock_bssid,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
@@ -763,7 +764,7 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_ap_utils_level_to_quality (gint val)
|
nm_wifi_utils_level_to_quality (gint val)
|
||||||
{
|
{
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
/* Assume dBm already; rough conversion: best = -40, worst = -100 */
|
/* Assume dBm already; rough conversion: best = -40, worst = -100 */
|
@@ -18,9 +18,8 @@
|
|||||||
* (C) Copyright 2011 Red Hat, Inc.
|
* (C) Copyright 2011 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NETWORKMANAGER_WIFI_AP_UTILS_H__
|
#ifndef __NM_WIFI_UTILS_H__
|
||||||
#define __NETWORKMANAGER_WIFI_AP_UTILS_H__
|
#define __NM_WIFI_UTILS_H__
|
||||||
|
|
||||||
|
|
||||||
#include <nm-dbus-interface.h>
|
#include <nm-dbus-interface.h>
|
||||||
#include <nm-connection.h>
|
#include <nm-connection.h>
|
||||||
@@ -28,17 +27,16 @@
|
|||||||
#include <nm-setting-wireless-security.h>
|
#include <nm-setting-wireless-security.h>
|
||||||
#include <nm-setting-8021x.h>
|
#include <nm-setting-8021x.h>
|
||||||
|
|
||||||
gboolean nm_ap_utils_complete_connection (const GByteArray *ssid,
|
gboolean nm_wifi_utils_complete_connection (const GByteArray *ssid,
|
||||||
const char *bssid,
|
const char *bssid,
|
||||||
NM80211Mode mode,
|
NM80211Mode mode,
|
||||||
guint32 flags,
|
guint32 flags,
|
||||||
guint32 wpa_flags,
|
guint32 wpa_flags,
|
||||||
guint32 rsn_flags,
|
guint32 rsn_flags,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean lock_bssid,
|
gboolean lock_bssid,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
guint32 nm_ap_utils_level_to_quality (gint val);
|
guint32 nm_wifi_utils_level_to_quality (gint val);
|
||||||
|
|
||||||
#endif /* NM_WIFI_AP_UTILS_H */
|
|
||||||
|
|
||||||
|
#endif /* __NM_WIFI_UTILS_H__ */
|
@@ -12,17 +12,17 @@ AM_CPPFLAGS = \
|
|||||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||||
$(GLIB_CFLAGS)
|
$(GLIB_CFLAGS)
|
||||||
|
|
||||||
noinst_PROGRAMS = test-wifi-ap-utils
|
noinst_PROGRAMS = test-general
|
||||||
|
|
||||||
test_wifi_ap_utils_SOURCES = \
|
test_general_SOURCES = \
|
||||||
test-wifi-ap-utils.c \
|
test-general.c \
|
||||||
$(srcdir)/../nm-wifi-ap.c \
|
$(srcdir)/../nm-wifi-ap.c \
|
||||||
$(srcdir)/../nm-wifi-ap.h \
|
$(srcdir)/../nm-wifi-ap.h \
|
||||||
$(srcdir)/../nm-wifi-ap-utils.c \
|
$(srcdir)/../nm-wifi-utils.c \
|
||||||
$(srcdir)/../nm-wifi-ap-utils.h
|
$(srcdir)/../nm-wifi-utils.h
|
||||||
|
|
||||||
test_wifi_ap_utils_LDADD = $(top_builddir)/src/libNetworkManager.la
|
test_general_LDADD = $(top_builddir)/src/libNetworkManager.la
|
||||||
|
|
||||||
@VALGRIND_RULES@
|
@VALGRIND_RULES@
|
||||||
TESTS = test-wifi-ap-utils
|
TESTS = test-general
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "nm-wifi-ap-utils.h"
|
#include "nm-wifi-utils.h"
|
||||||
|
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
@@ -88,15 +88,15 @@ complete_connection (const char *ssid,
|
|||||||
tmp = g_byte_array_sized_new (strlen (ssid));
|
tmp = g_byte_array_sized_new (strlen (ssid));
|
||||||
g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid));
|
g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid));
|
||||||
|
|
||||||
success = nm_ap_utils_complete_connection (tmp,
|
success = nm_wifi_utils_complete_connection (tmp,
|
||||||
bssid,
|
bssid,
|
||||||
mode,
|
mode,
|
||||||
flags,
|
flags,
|
||||||
wpa_flags,
|
wpa_flags,
|
||||||
rsn_flags,
|
rsn_flags,
|
||||||
src,
|
src,
|
||||||
lock_bssid,
|
lock_bssid,
|
||||||
error);
|
error);
|
||||||
g_byte_array_free (tmp, TRUE);
|
g_byte_array_free (tmp, TRUE);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -1289,17 +1289,17 @@ static void
|
|||||||
test_strength_dbm (void)
|
test_strength_dbm (void)
|
||||||
{
|
{
|
||||||
/* boundary conditions first */
|
/* boundary conditions first */
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-1), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-1), ==, 100);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-40), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-40), ==, 100);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-30), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-30), ==, 100);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-100), ==, 0);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-100), ==, 0);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-200), ==, 0);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-200), ==, 0);
|
||||||
|
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-81), ==, 32);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-81), ==, 32);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-92), ==, 14);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-92), ==, 14);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-74), ==, 44);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-74), ==, 44);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-81), ==, 32);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-81), ==, 32);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (-66), ==, 57);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (-66), ==, 57);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1308,30 +1308,30 @@ test_strength_percent (void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* boundary conditions first */
|
/* boundary conditions first */
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (0), ==, 0);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (0), ==, 0);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (100), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (100), ==, 100);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (110), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (110), ==, 100);
|
||||||
|
|
||||||
for (i = 0; i <= 100; i++)
|
for (i = 0; i <= 100; i++)
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (i), ==, i);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (i), ==, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_strength_wext (void)
|
test_strength_wext (void)
|
||||||
{
|
{
|
||||||
/* boundary conditions that we assume aren't WEXT first */
|
/* boundary conditions that we assume aren't WEXT first */
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (256), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (256), ==, 100);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (110), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (110), ==, 100);
|
||||||
|
|
||||||
/* boundary conditions that we assume are WEXT */
|
/* boundary conditions that we assume are WEXT */
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (111), ==, 0);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (111), ==, 0);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (150), ==, 0);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (150), ==, 0);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (225), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (225), ==, 100);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (255), ==, 100);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (255), ==, 100);
|
||||||
|
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (157), ==, 2);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (157), ==, 2);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (200), ==, 74);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (200), ==, 74);
|
||||||
g_assert_cmpint (nm_ap_utils_level_to_quality (215), ==, 99);
|
g_assert_cmpint (nm_wifi_utils_level_to_quality (215), ==, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
Reference in New Issue
Block a user