|
Packit Service |
87a54e |
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2007 - 2008 Novell, Inc.
|
|
Packit |
5756e2 |
* Copyright (C) 2007 - 2014 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit Service |
2bceb2 |
#include "libnm/nm-default-libnm.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-device-wifi.h"
|
|
Packit |
5756e2 |
|
|
Packit Service |
d0b836 |
#include <linux/if_ether.h>
|
|
Packit Service |
d0b836 |
|
|
Packit |
5756e2 |
#include "nm-glib-aux/nm-dbus-aux.h"
|
|
Packit |
5756e2 |
#include "nm-setting-connection.h"
|
|
Packit |
5756e2 |
#include "nm-setting-wireless.h"
|
|
Packit |
5756e2 |
#include "nm-setting-wireless-security.h"
|
|
Packit |
5756e2 |
#include "nm-utils.h"
|
|
Packit |
5756e2 |
#include "nm-access-point.h"
|
|
Packit |
5756e2 |
#include "nm-object-private.h"
|
|
Packit |
5756e2 |
#include "nm-core-internal.h"
|
|
Packit |
5756e2 |
#include "nm-dbus-helpers.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PERM_HW_ADDRESS,
|
|
Packit Service |
a1bd4f |
PROP_MODE,
|
|
Packit Service |
a1bd4f |
PROP_BITRATE,
|
|
Packit Service |
a1bd4f |
PROP_ACCESS_POINTS,
|
|
Packit Service |
a1bd4f |
PROP_ACTIVE_ACCESS_POINT,
|
|
Packit Service |
a1bd4f |
PROP_WIRELESS_CAPABILITIES,
|
|
Packit Service |
a1bd4f |
PROP_LAST_SCAN, );
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
NMLDBusPropertyAO access_points;
|
|
Packit Service |
a1bd4f |
NMLDBusPropertyO active_access_point;
|
|
Packit Service |
a1bd4f |
char * perm_hw_address;
|
|
Packit Service |
a1bd4f |
gint64 last_scan;
|
|
Packit Service |
a1bd4f |
guint32 mode;
|
|
Packit Service |
a1bd4f |
guint32 bitrate;
|
|
Packit Service |
a1bd4f |
guint32 wireless_capabilities;
|
|
Packit |
5756e2 |
} NMDeviceWifiPrivate;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
enum {
|
|
Packit Service |
a1bd4f |
ACCESS_POINT_ADDED,
|
|
Packit Service |
a1bd4f |
ACCESS_POINT_REMOVED,
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
LAST_SIGNAL
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
static guint signals[LAST_SIGNAL] = {0};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMDeviceWifi {
|
|
Packit Service |
a1bd4f |
NMDevice parent;
|
|
Packit Service |
a1bd4f |
NMDeviceWifiPrivate _priv;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMDeviceWifiClass {
|
|
Packit Service |
a1bd4f |
NMDeviceClass parent;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_DEFINE_TYPE(NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE)
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define NM_DEVICE_WIFI_GET_PRIVATE(self) \
|
|
Packit Service |
a1bd4f |
_NM_GET_PRIVATE(self, NMDeviceWifi, NM_IS_DEVICE_WIFI, NMObject, NMDevice)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_hw_address: (skip)
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the actual hardware (MAC) address of the #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the actual hardware address. This is the internal string used by the
|
|
Packit |
5756e2 |
* device, and must not be modified.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.24: Use nm_device_get_hw_address() instead.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
const char *
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_hw_address(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return nm_device_get_hw_address(NM_DEVICE(device));
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_permanent_hw_address:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the permanent hardware (MAC) address of the #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the permanent hardware address. This is the internal string used by the
|
|
Packit |
5756e2 |
* device, and must not be modified.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
const char *
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_permanent_hw_address(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return _nml_coerce_property_str_not_empty(NM_DEVICE_WIFI_GET_PRIVATE(device)->perm_hw_address);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_mode:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the #NMDeviceWifi mode.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the mode
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
NM80211Mode
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_mode(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), 0);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_WIFI_GET_PRIVATE(device)->mode;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_bitrate:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the bit rate of the #NMDeviceWifi in kbit/s.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the bit rate (kbit/s)
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
guint32
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_bitrate(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceState state;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
state = nm_device_get_state(NM_DEVICE(device));
|
|
Packit Service |
a1bd4f |
switch (state) {
|
|
Packit Service |
a1bd4f |
case NM_DEVICE_STATE_IP_CONFIG:
|
|
Packit Service |
a1bd4f |
case NM_DEVICE_STATE_IP_CHECK:
|
|
Packit Service |
a1bd4f |
case NM_DEVICE_STATE_SECONDARIES:
|
|
Packit Service |
a1bd4f |
case NM_DEVICE_STATE_ACTIVATED:
|
|
Packit Service |
a1bd4f |
case NM_DEVICE_STATE_DEACTIVATING:
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
default:
|
|
Packit Service |
a1bd4f |
return 0;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_WIFI_GET_PRIVATE(device)->bitrate;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_capabilities:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the Wi-Fi capabilities of the #NMDeviceWifi.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the capabilities
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
NMDeviceWifiCapabilities
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_capabilities(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), 0);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_WIFI_GET_PRIVATE(device)->wireless_capabilities;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_active_access_point:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the active #NMAccessPoint.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: (transfer none): the access point or %NULL if none is active
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
NMAccessPoint *
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_active_access_point(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return nml_dbus_property_o_get_obj(&NM_DEVICE_WIFI_GET_PRIVATE(device)->active_access_point);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_access_points:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets all the scanned access points of the #NMDeviceWifi.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: (element-type NMAccessPoint): a #GPtrArray containing all the
|
|
Packit |
5756e2 |
* scanned #NMAccessPoints.
|
|
Packit |
5756e2 |
* The returned array is owned by the client and should not be modified.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
const GPtrArray *
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_access_points(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return nml_dbus_property_ao_get_objs_as_ptrarray(
|
|
Packit Service |
a1bd4f |
&NM_DEVICE_WIFI_GET_PRIVATE(device)->access_points);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_access_point_by_path:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
* @path: the object path of the access point
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets a #NMAccessPoint by path.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: (transfer none): the access point or %NULL if none is found.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
NMAccessPoint *
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_access_point_by_path(NMDeviceWifi *device, const char *path)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const GPtrArray *aps;
|
|
Packit Service |
a1bd4f |
int i;
|
|
Packit Service |
a1bd4f |
NMAccessPoint * ap = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), NULL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(path != NULL, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
aps = nm_device_wifi_get_access_points(device);
|
|
Packit Service |
a1bd4f |
if (!aps)
|
|
Packit Service |
a1bd4f |
return NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
for (i = 0; i < aps->len; i++) {
|
|
Packit Service |
a1bd4f |
NMAccessPoint *candidate = g_ptr_array_index(aps, i);
|
|
Packit Service |
a1bd4f |
if (!strcmp(nm_object_get_path(NM_OBJECT(candidate)), path)) {
|
|
Packit Service |
a1bd4f |
ap = candidate;
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return ap;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_get_last_scan:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns the timestamp (in CLOCK_BOOTTIME milliseconds) for the last finished
|
|
Packit |
5756e2 |
* network scan. A value of -1 means the device never scanned for access points.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Use nm_utils_get_timestamp_msec() to obtain current time value suitable for
|
|
Packit |
5756e2 |
* comparing to this value.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: the last scan time in seconds
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Since: 1.12
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gint64
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_last_scan(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), -1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_WIFI_GET_PRIVATE(device)->last_scan;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_request_scan:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Request NM to scan for access points on @device. Note that the function
|
|
Packit |
5756e2 |
* returns immediately after requesting the scan, and it may take some time
|
|
Packit |
5756e2 |
* after that for the scan to complete.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be
|
|
Packit |
5756e2 |
* set.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.22: Use nm_device_wifi_request_scan_async() or GDBusConnection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan(NMDeviceWifi *device, GCancellable *cancellable, GError **error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return nm_device_wifi_request_scan_options(device, NULL, cancellable, error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_request_scan_options:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
* @options: dictionary with options for RequestScan(), or %NULL
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Request NM to scan for access points on @device. Note that the function
|
|
Packit |
5756e2 |
* returns immediately after requesting the scan, and it may take some time
|
|
Packit |
5756e2 |
* after that for the scan to complete.
|
|
Packit |
5756e2 |
* This is the same as @nm_device_wifi_request_scan except it accepts @options
|
|
Packit |
5756e2 |
* for the scanning. The argument is the dictionary passed to RequestScan()
|
|
Packit |
5756e2 |
* D-Bus call. Valid options inside the dictionary are:
|
|
Packit |
5756e2 |
* 'ssids' => array of SSIDs (saay)
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be
|
|
Packit |
5756e2 |
* set.
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Since: 1.2
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Deprecated: 1.22: Use nm_device_wifi_request_scan_options_async() or GDBusConnection.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_options(NMDeviceWifi *device,
|
|
Packit Service |
a1bd4f |
GVariant * options,
|
|
Packit Service |
a1bd4f |
GCancellable *cancellable,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(!options || g_variant_is_of_type(options, G_VARIANT_TYPE_VARDICT), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(!error || !*error, FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!options)
|
|
Packit Service |
a1bd4f |
options = g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return _nm_client_dbus_call_sync_void(_nm_object_get_client(device),
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(device),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
|
Packit Service |
a1bd4f |
"RequestScan",
|
|
Packit Service |
a1bd4f |
g_variant_new("(@a{sv})", options),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NM_BACKPORT_SYMBOL(
|
|
Packit Service |
a1bd4f |
libnm_1_0_6,
|
|
Packit Service |
a1bd4f |
gboolean,
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_options,
|
|
Packit Service |
a1bd4f |
(NMDeviceWifi * device, GVariant *options, GCancellable *cancellable, GError **error),
|
|
Packit Service |
a1bd4f |
(device, options, cancellable, error));
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_request_scan_async:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the scan has been requested
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Request NM to scan for access points on @device. Note that @callback will be
|
|
Packit |
5756e2 |
* called immediately after requesting the scan, and it may take some time after
|
|
Packit |
5756e2 |
* that for the scan to complete.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_async(NMDeviceWifi * device,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_options_async(device, NULL, cancellable, callback, user_data);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_request_scan_options_async:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
* @options: dictionary with options for RequestScan(), or %NULL
|
|
Packit |
5756e2 |
* @cancellable: a #GCancellable, or %NULL
|
|
Packit |
5756e2 |
* @callback: callback to be called when the scan has been requested
|
|
Packit |
5756e2 |
* @user_data: caller-specific data passed to @callback
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Request NM to scan for access points on @device. Note that @callback will be
|
|
Packit |
5756e2 |
* called immediately after requesting the scan, and it may take some time after
|
|
Packit |
5756e2 |
* that for the scan to complete.
|
|
Packit |
5756e2 |
* This is the same as @nm_device_wifi_request_scan_async except it accepts @options
|
|
Packit |
5756e2 |
* for the scanning. The argument is the dictionary passed to RequestScan()
|
|
Packit |
5756e2 |
* D-Bus call. Valid options inside the dictionary are:
|
|
Packit |
5756e2 |
* 'ssids' => array of SSIDs (saay)
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* To complete the request call nm_device_wifi_request_scan_finish().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Since: 1.2
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
void
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_options_async(NMDeviceWifi * device,
|
|
Packit Service |
a1bd4f |
GVariant * options,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_if_fail(NM_IS_DEVICE_WIFI(device));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!options || g_variant_is_of_type(options, G_VARIANT_TYPE_VARDICT));
|
|
Packit Service |
a1bd4f |
g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!options)
|
|
Packit Service |
a1bd4f |
options = g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nm_client_dbus_call(_nm_object_get_client(device),
|
|
Packit Service |
a1bd4f |
device,
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_async,
|
|
Packit Service |
a1bd4f |
cancellable,
|
|
Packit Service |
a1bd4f |
callback,
|
|
Packit Service |
a1bd4f |
user_data,
|
|
Packit Service |
a1bd4f |
_nm_object_get_path(device),
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
|
Packit Service |
a1bd4f |
"RequestScan",
|
|
Packit Service |
a1bd4f |
g_variant_new("(@a{sv})", options),
|
|
Packit Service |
a1bd4f |
G_VARIANT_TYPE("()"),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit Service |
a1bd4f |
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
|
|
Packit Service |
a1bd4f |
nm_dbus_connection_call_finish_void_strip_dbus_error_cb);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NM_BACKPORT_SYMBOL(libnm_1_0_6,
|
|
Packit Service |
a1bd4f |
void,
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_options_async,
|
|
Packit Service |
a1bd4f |
(NMDeviceWifi * device,
|
|
Packit Service |
a1bd4f |
GVariant * options,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
GAsyncReadyCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer user_data),
|
|
Packit Service |
a1bd4f |
(device, options, cancellable, callback, user_data));
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* nm_device_wifi_request_scan_finish:
|
|
Packit |
5756e2 |
* @device: a #NMDeviceWifi
|
|
Packit |
5756e2 |
* @result: the result passed to the #GAsyncReadyCallback
|
|
Packit |
5756e2 |
* @error: location for a #GError, or %NULL
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Gets the result of a call to nm_device_wifi_request_scan_async() and
|
|
Packit |
5756e2 |
* nm_device_wifi_request_scan_options_async().
|
|
Packit |
5756e2 |
*
|
|
Packit |
5756e2 |
* Returns: %TRUE on success, %FALSE on error, in which case @error will be
|
|
Packit |
5756e2 |
* set.
|
|
Packit |
5756e2 |
**/
|
|
Packit |
5756e2 |
gboolean
|
|
Packit Service |
a1bd4f |
nm_device_wifi_request_scan_finish(NMDeviceWifi *device, GAsyncResult *result, GError **error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(NM_IS_DEVICE_WIFI(device), FALSE);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(nm_g_task_is_valid(result, device, nm_device_wifi_request_scan_async),
|
|
Packit Service |
a1bd4f |
FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return g_task_propagate_boolean(G_TASK(result), error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define WPA_CAPS \
|
|
Packit Service |
a1bd4f |
(NM_WIFI_DEVICE_CAP_CIPHER_TKIP | NM_WIFI_DEVICE_CAP_CIPHER_CCMP | NM_WIFI_DEVICE_CAP_WPA \
|
|
Packit Service |
a1bd4f |
| NM_WIFI_DEVICE_CAP_RSN)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#define RSN_CAPS (NM_WIFI_DEVICE_CAP_CIPHER_CCMP | NM_WIFI_DEVICE_CAP_RSN)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
has_proto(NMSettingWirelessSecurity *s_wsec, const char *proto)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
int i;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
for (i = 0; i < nm_setting_wireless_security_get_num_protos(s_wsec); i++) {
|
|
Packit Service |
a1bd4f |
if (g_strcmp0(proto, nm_setting_wireless_security_get_proto(s_wsec, i)) == 0)
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
connection_compatible(NMDevice *device, NMConnection *connection, GError **error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMSettingWireless * s_wifi;
|
|
Packit Service |
a1bd4f |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
a1bd4f |
const char * hwaddr, *setting_hwaddr;
|
|
Packit Service |
a1bd4f |
NMDeviceWifiCapabilities wifi_caps;
|
|
Packit Service |
a1bd4f |
const char * key_mgmt;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!NM_DEVICE_CLASS(nm_device_wifi_parent_class)
|
|
Packit Service |
a1bd4f |
->connection_compatible(device, connection, error))
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!nm_connection_is_type(connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
|
|
Packit Service |
a1bd4f |
g_set_error_literal(error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
|
Packit Service |
a1bd4f |
_("The connection was not a Wi-Fi connection."));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Check MAC address */
|
|
Packit Service |
a1bd4f |
hwaddr = nm_device_wifi_get_permanent_hw_address(NM_DEVICE_WIFI(device));
|
|
Packit Service |
a1bd4f |
if (hwaddr) {
|
|
Packit Service |
a1bd4f |
if (!nm_utils_hwaddr_valid(hwaddr, ETH_ALEN)) {
|
|
Packit Service |
a1bd4f |
g_set_error_literal(error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_FAILED,
|
|
Packit Service |
a1bd4f |
_("Invalid device MAC address."));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
s_wifi = nm_connection_get_setting_wireless(connection);
|
|
Packit Service |
a1bd4f |
setting_hwaddr = nm_setting_wireless_get_mac_address(s_wifi);
|
|
Packit Service |
a1bd4f |
if (setting_hwaddr && !nm_utils_hwaddr_matches(setting_hwaddr, -1, hwaddr, -1)) {
|
|
Packit Service |
a1bd4f |
g_set_error_literal(error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
|
Packit Service |
a1bd4f |
_("The MACs of the device and the connection didn't match."));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Check device capabilities; we assume all devices can do WEP at least */
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
s_wsec = nm_connection_get_setting_wireless_security(connection);
|
|
Packit Service |
a1bd4f |
if (s_wsec) {
|
|
Packit Service |
a1bd4f |
/* Connection has security, verify it against the device's capabilities */
|
|
Packit Service |
a1bd4f |
key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec);
|
|
Packit Service |
d0b836 |
if (nm_streq(key_mgmt, "wpa-psk") || nm_streq(key_mgmt, "wpa-eap")
|
|
Packit Service |
d0b836 |
|| nm_streq(key_mgmt, "wpa-eap-suite-b-192")) {
|
|
Packit Service |
a1bd4f |
wifi_caps = nm_device_wifi_get_capabilities(NM_DEVICE_WIFI(device));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Is device only WEP capable? */
|
|
Packit Service |
a1bd4f |
if (!(wifi_caps & WPA_CAPS)) {
|
|
Packit Service |
a1bd4f |
g_set_error_literal(
|
|
Packit Service |
a1bd4f |
error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
|
Packit Service |
a1bd4f |
_("The device is lacking WPA capabilities required by the connection."));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Make sure WPA2/RSN-only connections don't get chosen for WPA-only cards */
|
|
Packit Service |
a1bd4f |
if (has_proto(s_wsec, "rsn") && !has_proto(s_wsec, "wpa") && !(wifi_caps & RSN_CAPS)) {
|
|
Packit Service |
a1bd4f |
g_set_error_literal(
|
|
Packit Service |
a1bd4f |
error,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
|
Packit Service |
a1bd4f |
_("The device is lacking WPA2/RSN capabilities required by the connection."));
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static GType
|
|
Packit Service |
a1bd4f |
get_setting_type(NMDevice *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return NM_TYPE_SETTING_WIRELESS;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
_property_ao_notify_changed_access_points_cb(NMLDBusPropertyAO *pr_ao,
|
|
Packit Service |
a1bd4f |
NMClient * client,
|
|
Packit Service |
a1bd4f |
NMObject * nmobj,
|
|
Packit Service |
a1bd4f |
gboolean is_added /* or else removed */)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
_nm_client_notify_event_queue_emit_obj_signal(client,
|
|
Packit Service |
a1bd4f |
G_OBJECT(pr_ao->owner_dbobj->nmobj),
|
|
Packit Service |
a1bd4f |
nmobj,
|
|
Packit Service |
a1bd4f |
is_added,
|
|
Packit Service |
a1bd4f |
10,
|
|
Packit Service |
a1bd4f |
is_added ? signals[ACCESS_POINT_ADDED]
|
|
Packit Service |
a1bd4f |
: signals[ACCESS_POINT_REMOVED]);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_device_wifi_init(NMDeviceWifi *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(device);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
priv->last_scan = -1;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceWifi *self = NM_DEVICE_WIFI(object);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
switch (prop_id) {
|
|
Packit Service |
a1bd4f |
case PROP_PERM_HW_ADDRESS:
|
|
Packit Service |
a1bd4f |
g_value_set_string(value, nm_device_wifi_get_permanent_hw_address(self));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_MODE:
|
|
Packit Service |
a1bd4f |
g_value_set_enum(value, nm_device_wifi_get_mode(self));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_BITRATE:
|
|
Packit Service |
a1bd4f |
g_value_set_uint(value, nm_device_wifi_get_bitrate(self));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_ACTIVE_ACCESS_POINT:
|
|
Packit Service |
a1bd4f |
g_value_set_object(value, nm_device_wifi_get_active_access_point(self));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_WIRELESS_CAPABILITIES:
|
|
Packit Service |
a1bd4f |
g_value_set_flags(value, nm_device_wifi_get_capabilities(self));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_ACCESS_POINTS:
|
|
Packit Service |
a1bd4f |
g_value_take_boxed(value,
|
|
Packit Service |
a1bd4f |
_nm_utils_copy_object_array(nm_device_wifi_get_access_points(self)));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
case PROP_LAST_SCAN:
|
|
Packit Service |
a1bd4f |
g_value_set_int64(value, nm_device_wifi_get_last_scan(self));
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
default:
|
|
Packit Service |
a1bd4f |
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
Packit Service |
a1bd4f |
break;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
finalize(GObject *object)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(object);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_free(priv->perm_hw_address);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_OBJECT_CLASS(nm_device_wifi_parent_class)->finalize(object);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wireless = NML_DBUS_META_IFACE_INIT_PROP(
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
|
Packit Service |
a1bd4f |
nm_device_wifi_get_type,
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_IFACE_DBUS_PROPERTIES(
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_AO_PROP("AccessPoints",
|
|
Packit Service |
a1bd4f |
PROP_ACCESS_POINTS,
|
|
Packit Service |
a1bd4f |
NMDeviceWifi,
|
|
Packit Service |
a1bd4f |
_priv.access_points,
|
|
Packit Service |
a1bd4f |
nm_access_point_get_type,
|
|
Packit Service |
a1bd4f |
.notify_changed_ao =
|
|
Packit Service |
a1bd4f |
_property_ao_notify_changed_access_points_cb),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_O_PROP("ActiveAccessPoint",
|
|
Packit Service |
a1bd4f |
PROP_ACTIVE_ACCESS_POINT,
|
|
Packit Service |
a1bd4f |
NMDeviceWifi,
|
|
Packit Service |
a1bd4f |
_priv.active_access_point,
|
|
Packit Service |
a1bd4f |
nm_access_point_get_type),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_U("Bitrate", PROP_BITRATE, NMDeviceWifi, _priv.bitrate),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_FCN("HwAddress",
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
"s",
|
|
Packit Service |
a1bd4f |
_nm_device_notify_update_prop_hw_address),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_X("LastScan", PROP_LAST_SCAN, NMDeviceWifi, _priv.last_scan),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_U("Mode", PROP_MODE, NMDeviceWifi, _priv.mode),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_S("PermHwAddress",
|
|
Packit Service |
a1bd4f |
PROP_PERM_HW_ADDRESS,
|
|
Packit Service |
a1bd4f |
NMDeviceWifi,
|
|
Packit Service |
a1bd4f |
_priv.perm_hw_address),
|
|
Packit Service |
a1bd4f |
NML_DBUS_META_PROPERTY_INIT_U("WirelessCapabilities",
|
|
Packit Service |
a1bd4f |
PROP_WIRELESS_CAPABILITIES,
|
|
Packit Service |
a1bd4f |
NMDeviceWifi,
|
|
Packit Service |
a1bd4f |
_priv.wireless_capabilities), ), );
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_device_wifi_class_init(NMDeviceWifiClass *klass)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
GObjectClass * object_class = G_OBJECT_CLASS(klass);
|
|
Packit Service |
a1bd4f |
NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass);
|
|
Packit Service |
a1bd4f |
NMDeviceClass *device_class = NM_DEVICE_CLASS(klass);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
object_class->get_property = get_property;
|
|
Packit Service |
a1bd4f |
object_class->finalize = finalize;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceWifi);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class,
|
|
Packit Service |
a1bd4f |
NMDeviceWifiPrivate,
|
|
Packit Service |
a1bd4f |
active_access_point);
|
|
Packit Service |
a1bd4f |
_NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceWifiPrivate, access_points);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device_class->connection_compatible = connection_compatible;
|
|
Packit Service |
a1bd4f |
device_class->get_setting_type = get_setting_type;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:perm-hw-address:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The hardware (MAC) address of the device.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_PERM_HW_ADDRESS] =
|
|
Packit Service |
a1bd4f |
g_param_spec_string(NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:mode:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The mode of the device.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_MODE] = g_param_spec_enum(NM_DEVICE_WIFI_MODE,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
NM_TYPE_802_11_MODE,
|
|
Packit Service |
a1bd4f |
NM_802_11_MODE_UNKNOWN,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:bitrate:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The bit rate of the device in kbit/s.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_BITRATE] = g_param_spec_uint(NM_DEVICE_WIFI_BITRATE,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
G_MAXUINT32,
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:active-access-point:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The active #NMAccessPoint of the device.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_ACTIVE_ACCESS_POINT] =
|
|
Packit Service |
a1bd4f |
g_param_spec_object(NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
NM_TYPE_ACCESS_POINT,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:wireless-capabilities:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The wireless capabilities of the device.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_WIRELESS_CAPABILITIES] =
|
|
Packit Service |
a1bd4f |
g_param_spec_flags(NM_DEVICE_WIFI_CAPABILITIES,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
NM_TYPE_DEVICE_WIFI_CAPABILITIES,
|
|
Packit Service |
a1bd4f |
NM_WIFI_DEVICE_CAP_NONE,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:access-points: (type GPtrArray(NMAccessPoint))
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* List of all Wi-Fi access points the device can see.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_ACCESS_POINTS] =
|
|
Packit Service |
a1bd4f |
g_param_spec_boxed(NM_DEVICE_WIFI_ACCESS_POINTS,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
G_TYPE_PTR_ARRAY,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi:last-scan:
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* The timestamp (in CLOCK_BOOTTIME seconds) for the last finished
|
|
Packit Service |
a1bd4f |
* network scan. A value of -1 means the device never scanned for
|
|
Packit Service |
a1bd4f |
* access points.
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* Since: 1.12
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
obj_properties[PROP_LAST_SCAN] = g_param_spec_int64(NM_DEVICE_WIFI_LAST_SCAN,
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
"",
|
|
Packit Service |
a1bd4f |
-1,
|
|
Packit Service |
a1bd4f |
G_MAXINT64,
|
|
Packit Service |
a1bd4f |
-1,
|
|
Packit Service |
a1bd4f |
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_nml_dbus_meta_class_init_with_properties(object_class,
|
|
Packit Service |
a1bd4f |
&_nml_dbus_meta_iface_nm_device_wireless);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi::access-point-added:
|
|
Packit Service |
a1bd4f |
* @device: the Wi-Fi device that received the signal
|
|
Packit Service |
a1bd4f |
* @ap: the new access point
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* Notifies that a #NMAccessPoint is added to the Wi-Fi device.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
signals[ACCESS_POINT_ADDED] = g_signal_new("access-point-added",
|
|
Packit Service |
a1bd4f |
G_OBJECT_CLASS_TYPE(object_class),
|
|
Packit Service |
a1bd4f |
G_SIGNAL_RUN_FIRST,
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
g_cclosure_marshal_VOID__OBJECT,
|
|
Packit Service |
a1bd4f |
G_TYPE_NONE,
|
|
Packit Service |
a1bd4f |
1,
|
|
Packit Service |
a1bd4f |
G_TYPE_OBJECT);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**
|
|
Packit Service |
a1bd4f |
* NMDeviceWifi::access-point-removed:
|
|
Packit Service |
a1bd4f |
* @device: the Wi-Fi device that received the signal
|
|
Packit Service |
a1bd4f |
* @ap: the removed access point
|
|
Packit Service |
a1bd4f |
*
|
|
Packit Service |
a1bd4f |
* Notifies that a #NMAccessPoint is removed from the Wi-Fi device.
|
|
Packit Service |
a1bd4f |
**/
|
|
Packit Service |
a1bd4f |
signals[ACCESS_POINT_REMOVED] = g_signal_new("access-point-removed",
|
|
Packit Service |
a1bd4f |
G_OBJECT_CLASS_TYPE(object_class),
|
|
Packit Service |
a1bd4f |
G_SIGNAL_RUN_FIRST,
|
|
Packit Service |
a1bd4f |
0,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
g_cclosure_marshal_VOID__OBJECT,
|
|
Packit Service |
a1bd4f |
G_TYPE_NONE,
|
|
Packit Service |
a1bd4f |
1,
|
|
Packit Service |
a1bd4f |
G_TYPE_OBJECT);
|
|
Packit |
5756e2 |
}
|