core: remove unused 'error' argument to check_connection_compatible()

Nothing uses the error, so simplify some code and save 5K (0.45%) in
binary size.
This commit is contained in:
Dan Williams 2014-05-30 13:44:53 -05:00
parent 253bfa5c47
commit c4dd68bce9
22 changed files with 106 additions and 393 deletions

View file

@ -51,17 +51,6 @@ G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE)
#define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate))
#define NM_ADSL_ERROR (nm_adsl_error_quark ())
static GQuark
nm_adsl_error_quark (void)
{
static GQuark quark = 0;
if (!quark)
quark = g_quark_from_static_string ("nm-adsl-error");
return quark;
}
/**********************************************/
typedef struct {
@ -87,39 +76,25 @@ get_generic_capabilities (NMDevice *dev)
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMSettingAdsl *s_adsl;
const char *protocol;
if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->check_connection_compatible (device, connection))
return FALSE;
if (!nm_connection_is_type (connection, NM_SETTING_ADSL_SETTING_NAME)) {
g_set_error (error,
NM_ADSL_ERROR, NM_ADSL_ERROR_CONNECTION_NOT_ADSL,
"The connection was not an ADSL connection.");
if (!nm_connection_is_type (connection, NM_SETTING_ADSL_SETTING_NAME))
return FALSE;
}
s_adsl = nm_connection_get_setting_adsl (connection);
if (!s_adsl) {
g_set_error (error,
NM_ADSL_ERROR, NM_ADSL_ERROR_CONNECTION_INVALID,
"The connection was not a valid ADSL connection.");
if (!s_adsl)
return FALSE;
}
/* FIXME: we don't yet support IPoATM */
protocol = nm_setting_adsl_get_protocol (s_adsl);
if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM) == 0) {
g_set_error (error,
NM_ADSL_ERROR, NM_ADSL_ERROR_CONNECTION_INVALID,
"IPoATM connections are not yet supported.");
if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM) == 0)
return FALSE;
}
return TRUE;
}

View file

@ -36,12 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ADSL))
#define NM_DEVICE_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass))
typedef enum {
NM_ADSL_ERROR_CONNECTION_NOT_ADSL = 0, /*< nick=ConnectionNotAdsl >*/
NM_ADSL_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/
NM_ADSL_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/
} NMAdslError;
typedef struct {
NMDevice parent;
} NMDeviceAdsl;

View file

@ -162,9 +162,7 @@ can_auto_connect (NMDevice *device,
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
NMSettingConnection *s_con;
@ -172,49 +170,29 @@ check_connection_compatible (NMDevice *device,
const GByteArray *array;
guint32 bt_type;
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_BLUETOOTH_SETTING_NAME)) {
g_set_error (error,
NM_BT_ERROR, NM_BT_ERROR_CONNECTION_NOT_BT,
"The connection was not a Bluetooth connection.");
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_BLUETOOTH_SETTING_NAME))
return FALSE;
}
s_bt = nm_connection_get_setting_bluetooth (connection);
if (!s_bt) {
g_set_error (error,
NM_BT_ERROR, NM_BT_ERROR_CONNECTION_INVALID,
"The connection was not a valid Bluetooth connection.");
if (!s_bt)
return FALSE;
}
bt_type = get_connection_bt_type (connection);
if (!(bt_type & priv->capabilities)) {
g_set_error (error,
NM_BT_ERROR, NM_BT_ERROR_CONNECTION_INCOMPATIBLE,
"The connection was not compatible with the device's capabilities.");
if (!(bt_type & priv->capabilities))
return FALSE;
}
array = nm_setting_bluetooth_get_bdaddr (s_bt);
if (!array || (array->len != ETH_ALEN)) {
g_set_error (error,
NM_BT_ERROR, NM_BT_ERROR_CONNECTION_INVALID,
"The connection did not contain a valid Bluetooth address.");
if (!array || (array->len != ETH_ALEN))
return FALSE;
}
if (memcmp (priv->bdaddr, array->data, ETH_ALEN) != 0) {
g_set_error (error,
NM_BT_ERROR, NM_BT_ERROR_CONNECTION_INCOMPATIBLE,
"The connection did not match the device's Bluetooth address.");
if (memcmp (priv->bdaddr, array->data, ETH_ALEN) != 0)
return FALSE;
}
return TRUE;
}

View file

@ -97,30 +97,22 @@ check_connection_available (NMDevice *device,
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
const char *iface;
NMSettingBond *s_bond;
if (!NM_DEVICE_CLASS (nm_device_bond_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_bond_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_bond = nm_connection_get_setting_bond (connection);
if (!s_bond || !nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
g_set_error (error, NM_BOND_ERROR, NM_BOND_ERROR_CONNECTION_NOT_BOND,
"The connection was not a bond connection.");
if (!s_bond || !nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME))
return FALSE;
}
/* Bond connections must specify the virtual interface name */
iface = nm_connection_get_virtual_iface_name (connection);
if (!iface || strcmp (nm_device_get_iface (device), iface)) {
g_set_error (error, NM_BOND_ERROR, NM_BOND_ERROR_CONNECTION_NOT_BOND,
"The bond connection virtual interface name did not match.");
if (!iface || strcmp (nm_device_get_iface (device), iface))
return FALSE;
}
/* FIXME: match bond properties like mode, etc? */

View file

@ -96,31 +96,23 @@ check_connection_available (NMDevice *device,
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
const char *iface;
NMSettingBridge *s_bridge;
const GByteArray *mac_address;
if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_bridge = nm_connection_get_setting_bridge (connection);
if (!s_bridge || !nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
g_set_error (error, NM_BRIDGE_ERROR, NM_BRIDGE_ERROR_CONNECTION_NOT_BRIDGE,
"The connection was not a bridge connection.");
if (!s_bridge || !nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME))
return FALSE;
}
/* Bridge connections must specify the virtual interface name */
iface = nm_connection_get_virtual_iface_name (connection);
if (!iface || strcmp (nm_device_get_iface (device), iface)) {
g_set_error (error, NM_BRIDGE_ERROR, NM_BRIDGE_ERROR_CONNECTION_INVALID,
"The bridge connection virtual interface name did not match.");
if (!iface || strcmp (nm_device_get_iface (device), iface))
return FALSE;
}
mac_address = nm_setting_bridge_get_mac_address (s_bridge);
if (mac_address) {
@ -130,11 +122,8 @@ check_connection_compatible (NMDevice *device,
hw_addr = nm_device_get_hw_address (device, &hw_len);
if ( !hw_addr
|| hw_len != mac_address->len
|| memcmp (mac_address->data, hw_addr, hw_len) != 0) {
g_set_error (error, NM_BRIDGE_ERROR, NM_BRIDGE_ERROR_CONNECTION_INVALID,
"The bridge mac-address does not match the address of the device.");
|| memcmp (mac_address->data, hw_addr, hw_len) != 0)
return FALSE;
}
}
return TRUE;

View file

@ -456,15 +456,13 @@ match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_m
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMSettingWired *s_wired;
if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_wired = nm_connection_get_setting_wired (connection);
@ -472,38 +470,22 @@ check_connection_compatible (NMDevice *device,
if (nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) {
/* NOP */
} else if (nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)) {
if (!s_wired) {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_INVALID,
"The connection was not a valid wired connection.");
if (!s_wired)
return FALSE;
}
} else {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_NOT_WIRED,
"The connection was not a wired, bond, or PPPoE connection.");
} else
return FALSE;
}
if (s_wired) {
const GByteArray *mac;
gboolean try_mac = TRUE;
const GSList *mac_blacklist, *mac_blacklist_iter;
if (!match_subchans (self, s_wired, &try_mac)) {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's s390 subchannels did not match this device.");
if (!match_subchans (self, s_wired, &try_mac))
return FALSE;
}
mac = nm_setting_wired_get_mac_address (s_wired);
if (try_mac && mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN)) {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address did not match this device.");
if (try_mac && mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN))
return FALSE;
}
/* Check for MAC address blacklist */
mac_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired);
@ -515,13 +497,9 @@ check_connection_compatible (NMDevice *device,
g_warn_if_reached ();
return FALSE;
}
if (memcmp (&addr, &priv->perm_hw_addr, ETH_ALEN) == 0) {
g_set_error (error,
NM_ETHERNET_ERROR, NM_ETHERNET_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address (%s) is blacklisted in %s.",
(char *) mac_blacklist_iter->data, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
if (memcmp (&addr, &priv->perm_hw_addr, ETH_ALEN) == 0)
return FALSE;
}
}
}

View file

@ -68,29 +68,19 @@ get_generic_capabilities (NMDevice *dev)
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMSettingConnection *s_con;
if (!NM_DEVICE_CLASS (nm_device_generic_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_generic_parent_class)->check_connection_compatible (device, connection))
return FALSE;
if (!nm_connection_is_type (connection, NM_SETTING_GENERIC_SETTING_NAME)) {
g_set_error (error,
NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_CONNECTION_NOT_GENERIC,
"The connection was not a generic connection.");
if (!nm_connection_is_type (connection, NM_SETTING_GENERIC_SETTING_NAME))
return FALSE;
}
s_con = nm_connection_get_setting_connection (connection);
if (!nm_setting_connection_get_interface_name (s_con)) {
g_set_error (error,
NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_CONNECTION_INVALID,
"The connection did not specify an interface name.");
if (!nm_setting_connection_get_interface_name (s_con))
return FALSE;
}
return TRUE;
}

View file

@ -211,44 +211,28 @@ ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMSettingInfiniband *s_infiniband;
const GByteArray *mac;
if (!NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->check_connection_compatible (device, connection))
return FALSE;
if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) {
g_set_error (error,
NM_INFINIBAND_ERROR,
NM_INFINIBAND_ERROR_CONNECTION_NOT_INFINIBAND,
"The connection was not an InfiniBand connection.");
if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME))
return FALSE;
}
s_infiniband = nm_connection_get_setting_infiniband (connection);
if (!s_infiniband) {
g_set_error (error,
NM_INFINIBAND_ERROR, NM_INFINIBAND_ERROR_CONNECTION_INVALID,
"The connection was not a valid infiniband connection.");
if (!s_infiniband)
return FALSE;
}
if (s_infiniband) {
mac = nm_setting_infiniband_get_mac_address (s_infiniband);
/* We only compare the last 8 bytes */
if (mac && memcmp (mac->data + INFINIBAND_ALEN - 8,
nm_device_get_hw_address (device, NULL) + INFINIBAND_ALEN - 8,
8)) {
g_set_error (error,
NM_INFINIBAND_ERROR,
NM_INFINIBAND_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address did not match this device.");
8))
return FALSE;
}
}
return TRUE;

View file

@ -109,30 +109,22 @@ check_connection_available (NMDevice *device,
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
const char *iface;
NMSettingTeam *s_team;
if (!NM_DEVICE_CLASS (nm_device_team_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_team_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_team = nm_connection_get_setting_team (connection);
if (!s_team || !nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME)) {
g_set_error (error, NM_TEAM_ERROR, NM_TEAM_ERROR_CONNECTION_NOT_TEAM,
"The connection was not a team connection.");
if (!s_team || !nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME))
return FALSE;
}
/* Team connections must specify the virtual interface name */
iface = nm_connection_get_virtual_iface_name (connection);
if (!iface || strcmp (nm_device_get_iface (device), iface)) {
g_set_error (error, NM_TEAM_ERROR, NM_TEAM_ERROR_CONNECTION_NOT_TEAM,
"The team connection virtual interface name did not match.");
if (!iface || strcmp (nm_device_get_iface (device), iface))
return FALSE;
}
/* FIXME: match team properties like mode, etc? */

View file

@ -119,7 +119,7 @@ bring_up (NMDevice *dev, gboolean *no_firmware)
/******************************************************************/
static gboolean
match_parent (NMDeviceVlan *self, const char *parent, GError **error)
match_parent (NMDeviceVlan *self, const char *parent)
{
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
@ -134,30 +134,19 @@ match_parent (NMDeviceVlan *self, const char *parent, GError **error)
*/
parent_req = nm_device_get_act_request (priv->parent);
if (!parent_req) {
g_set_error_literal (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"Parent interface not active; could not match UUID");
if (!parent_req)
return FALSE;
}
parent_connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (parent_req));
if (!parent_connection) {
g_set_error_literal (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"Parent interface had no connection; could not match UUID");
if (!parent_connection)
return FALSE;
}
if (g_strcmp0 (parent, nm_connection_get_uuid (parent_connection)) != 0) {
g_set_error_literal (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"Parent interface UUID did not match connection UUID");
if (g_strcmp0 (parent, nm_connection_get_uuid (parent_connection)) != 0)
return FALSE;
}
} else {
/* interface name */
if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0) {
g_set_error_literal (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"Parent interface name did not match connection");
if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0)
return FALSE;
}
}
return TRUE;
@ -186,42 +175,31 @@ match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hw
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
NMSettingVlan *s_vlan;
const char *parent, *iface = NULL;
if (!NM_DEVICE_CLASS (nm_device_vlan_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_vlan_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_vlan = nm_connection_get_setting_vlan (connection);
if (!s_vlan) {
g_set_error (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"The connection was not a VLAN connection.");
if (!s_vlan)
return FALSE;
}
if (nm_setting_vlan_get_id (s_vlan) != priv->vlan_id) {
g_set_error (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"The connection's VLAN ID did not match the device's VLAN ID.");
if (nm_setting_vlan_get_id (s_vlan) != priv->vlan_id)
return FALSE;
}
/* Check parent interface; could be an interface name or a UUID */
parent = nm_setting_vlan_get_parent (s_vlan);
if (parent) {
if (!match_parent (NM_DEVICE_VLAN (device), parent, error))
if (!match_parent (NM_DEVICE_VLAN (device), parent))
return FALSE;
} else {
/* Parent could be a MAC address in an NMSettingWired */
if (!match_hwaddr (device, connection, TRUE)) {
g_set_error (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"Failed to match the VLAN parent interface via hardware address.");
if (!match_hwaddr (device, connection, TRUE))
return FALSE;
}
}
/* Ensure the interface name matches. If not specified we assume a match
@ -230,11 +208,8 @@ check_connection_compatible (NMDevice *device,
*/
iface = nm_connection_get_virtual_iface_name (connection);
if (iface) {
if (g_strcmp0 (nm_device_get_ip_iface (device), iface) != 0) {
g_set_error (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
"The VLAN connection virtual interface name did not match.");
if (g_strcmp0 (nm_device_get_ip_iface (device), iface) != 0)
return FALSE;
}
}
return TRUE;
@ -345,7 +320,7 @@ update_connection (NMDevice *device, NMConnection *connection)
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = nm_connection_provider_get_connection_by_uuid (nm_connection_provider_get (), setting_parent);
if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection, NULL))
if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection))
new_parent = NULL;
}
if (new_parent)

View file

@ -1950,9 +1950,7 @@ nm_device_complete_connection (NMDevice *self,
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMSettingConnection *s_con;
const char *config_iface, *device_iface;
@ -1962,12 +1960,8 @@ check_connection_compatible (NMDevice *device,
config_iface = nm_setting_connection_get_interface_name (s_con);
device_iface = nm_device_get_iface (device);
if (config_iface && strcmp (config_iface, device_iface) != 0) {
g_set_error (error,
NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_INVALID,
"The connection is not valid for this interface.");
if (config_iface && strcmp (config_iface, device_iface) != 0)
return FALSE;
}
return TRUE;
}
@ -1976,7 +1970,6 @@ check_connection_compatible (NMDevice *device,
* nm_device_check_connection_compatible:
* @device: an #NMDevice
* @connection: an #NMConnection
* @error: return location for an error, or %NULL
*
* Checks if @connection could potentially be activated on @device.
* This means only that @device has the proper capabilities, and that
@ -1989,14 +1982,12 @@ check_connection_compatible (NMDevice *device,
* @device.
*/
gboolean
nm_device_check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
nm_device_check_connection_compatible (NMDevice *device, NMConnection *connection)
{
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
return NM_DEVICE_GET_CLASS (device)->check_connection_compatible (device, connection, error);
return NM_DEVICE_GET_CLASS (device)->check_connection_compatible (device, connection);
}
/**
@ -7037,7 +7028,7 @@ capture_lease_config (NMDevice *device,
NMConnection *candidate = citer->data;
const char *method;
if (!nm_device_check_connection_compatible (device, candidate, NULL))
if (!nm_device_check_connection_compatible (device, candidate))
continue;
/* IPv4 leases */
@ -7397,7 +7388,7 @@ nm_device_connection_is_available (NMDevice *device,
/* default-unmanaged devices in UNMANAGED state have no available connections
* so we must manually check whether the connection is available here.
*/
if ( nm_device_check_connection_compatible (device, connection, NULL)
if ( nm_device_check_connection_compatible (device, connection)
&& NM_DEVICE_GET_CLASS (device)->check_connection_available (device, connection, NULL))
return TRUE;
}
@ -7409,7 +7400,7 @@ nm_device_connection_is_available (NMDevice *device,
* activating but the network isn't available let the device recheck
* availability.
*/
if ( nm_device_check_connection_compatible (device, connection, NULL)
if ( nm_device_check_connection_compatible (device, connection)
&& NM_DEVICE_GET_CLASS (device)->check_connection_available_wifi_hidden)
available = NM_DEVICE_GET_CLASS (device)->check_connection_available_wifi_hidden (device, connection);
}
@ -7437,7 +7428,7 @@ _try_add_available_connection (NMDevice *self, NMConnection *connection)
if (nm_device_get_state (self) < NM_DEVICE_STATE_DISCONNECTED)
return FALSE;
if (nm_device_check_connection_compatible (self, connection, NULL)) {
if (nm_device_check_connection_compatible (self, connection)) {
if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) {
g_hash_table_insert (NM_DEVICE_GET_PRIVATE (self)->available_connections,
g_object_ref (connection),

View file

@ -140,9 +140,7 @@ typedef struct {
* only the devices type and characteristics. Does not use any live
* network information like WiFi/WiMAX scan lists etc.
*/
gboolean (* check_connection_compatible) (NMDevice *self,
NMConnection *connection,
GError **error);
gboolean (* check_connection_compatible) (NMDevice *self, NMConnection *connection);
/* Checks whether the connection is likely available to be activated,
* including any live network information like scan lists. The connection
@ -273,9 +271,7 @@ gboolean nm_device_complete_connection (NMDevice *device,
const GSList *existing_connection,
GError **error);
gboolean nm_device_check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error);
gboolean nm_device_check_connection_compatible (NMDevice *device, NMConnection *connection);
gboolean nm_device_can_assume_connections (NMDevice *device);

View file

@ -94,33 +94,23 @@ nm_olpc_mesh_error_quark (void)
/*******************************************************************/
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMSettingConnection *s_con;
NMSettingOlpcMesh *s_mesh;
if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_OLPC_MESH_SETTING_NAME)) {
g_set_error (error,
NM_OLPC_MESH_ERROR, NM_OLPC_MESH_ERROR_CONNECTION_NOT_MESH,
"The connection was not a Mesh connection.");
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_OLPC_MESH_SETTING_NAME))
return FALSE;
}
s_mesh = nm_connection_get_setting_olpc_mesh (connection);
if (!s_mesh) {
g_set_error (error,
NM_OLPC_MESH_ERROR, NM_OLPC_MESH_ERROR_CONNECTION_INVALID,
"The connection was not a valid Mesh connection.");
if (!s_mesh)
return FALSE;
}
return TRUE;
}

View file

@ -822,9 +822,7 @@ is_adhoc_wpa (NMConnection *connection)
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
@ -834,35 +832,22 @@ check_connection_compatible (NMDevice *device,
const GSList *mac_blacklist, *mac_blacklist_iter;
const char *mode;
if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME)) {
g_set_error (error,
NM_WIFI_ERROR, NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS,
"The connection was not a WiFi connection.");
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME))
return FALSE;
}
s_wireless = nm_connection_get_setting_wireless (connection);
if (!s_wireless) {
g_set_error (error,
NM_WIFI_ERROR, NM_WIFI_ERROR_CONNECTION_INVALID,
"The connection was not a valid WiFi connection.");
if (!s_wireless)
return FALSE;
}
mac = nm_setting_wireless_get_mac_address (s_wireless);
if (mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN)) {
g_set_error (error,
NM_WIFI_ERROR, NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address did not match this device.");
if (mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN))
return FALSE;
}
/* Check for MAC address blacklist */
mac_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless);
@ -874,55 +859,26 @@ check_connection_compatible (NMDevice *device,
g_warn_if_reached ();
continue;
}
if (memcmp (&addr, &priv->perm_hw_addr, ETH_ALEN) == 0) {
g_set_error (error,
NM_WIFI_ERROR, NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address (%s) is blacklisted in %s.",
(char *) mac_blacklist_iter->data, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST);
if (memcmp (&addr, &priv->perm_hw_addr, ETH_ALEN) == 0)
return FALSE;
}
}
if (is_adhoc_wpa (connection)) {
g_set_error_literal (error,
NM_WIFI_ERROR,
NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,
"WPA Ad-Hoc disabled due to kernel bugs");
if (is_adhoc_wpa (connection))
return FALSE;
}
/* Early exit if supplicant or device doesn't support requested mode */
mode = nm_setting_wireless_get_mode (s_wireless);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) {
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_ADHOC)) {
g_set_error_literal (error,
NM_WIFI_ERROR,
NM_WIFI_ERROR_ADHOC_MODE_UNSUPPORTED,
"Ad-Hoc mode is not supported by this device.");
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_ADHOC))
return FALSE;
}
} else if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0) {
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_AP)) {
g_set_error_literal (error,
NM_WIFI_ERROR,
NM_WIFI_ERROR_AP_MODE_UNSUPPORTED,
"Access Point (AP) mode is not supported by this device.");
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_AP))
return FALSE;
}
if (priv->sup_iface) {
switch (nm_supplicant_interface_get_ap_support (priv->sup_iface)) {
case AP_SUPPORT_NO:
g_set_error_literal (error,
NM_WIFI_ERROR,
NM_WIFI_ERROR_AP_MODE_UNSUPPORTED,
"Access Point (AP) mode is not supported by the supplicant.");
if (nm_supplicant_interface_get_ap_support (priv->sup_iface) == AP_SUPPORT_NO)
return FALSE;
case AP_SUPPORT_YES:
case AP_SUPPORT_UNKNOWN:
default:
break;
}
}
}

View file

@ -311,44 +311,30 @@ set_enabled (NMDevice *device, gboolean enabled)
/* NMDevice methods */
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMSettingConnection *s_con;
NMSettingWimax *s_wimax;
const char *connection_type;
const GByteArray *mac;
if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->check_connection_compatible (device, connection))
return FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
connection_type = nm_setting_connection_get_connection_type (s_con);
if (strcmp (connection_type, NM_SETTING_WIMAX_SETTING_NAME)) {
g_set_error (error,
NM_WIMAX_ERROR, NM_WIMAX_ERROR_CONNECTION_NOT_WIMAX,
"The connection was not a WiMAX connection.");
if (strcmp (connection_type, NM_SETTING_WIMAX_SETTING_NAME))
return FALSE;
}
s_wimax = nm_connection_get_setting_wimax (connection);
if (!s_wimax) {
g_set_error (error,
NM_WIMAX_ERROR, NM_WIMAX_ERROR_CONNECTION_INVALID,
"The connection was not a valid WiMAX connection.");
if (!s_wimax)
return FALSE;
}
mac = nm_setting_wimax_get_mac_address (s_wimax);
if (mac && memcmp (mac->data, nm_device_get_hw_address (device, NULL), ETH_ALEN)) {
g_set_error (error,
NM_WIMAX_ERROR, NM_WIMAX_ERROR_CONNECTION_INCOMPATIBLE,
"The connection's MAC address did not match this device.");
if (mac && memcmp (mac->data, nm_device_get_hw_address (device, NULL), ETH_ALEN))
return FALSE;
}
return TRUE;
}

View file

@ -301,16 +301,12 @@ get_hw_address_length (NMDevice *device, gboolean *out_permanent)
}
static gboolean
check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error)
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device);
if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection, error))
if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection))
return FALSE;
return nm_modem_check_connection_compatible (priv->modem, connection, error);
return nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, connection);
}
static gboolean

View file

@ -349,9 +349,7 @@ act_stage1_prepare (NMModem *_self,
/*****************************************************************************/
static gboolean
check_connection_compatible (NMModem *_self,
NMConnection *connection,
GError **error)
check_connection_compatible (NMModem *_self, NMConnection *connection)
{
NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
MMModemCapability modem_caps;
@ -365,22 +363,12 @@ check_connection_compatible (NMModem *_self,
NMSettingGsm *s_gsm;
if (!g_str_equal (nm_setting_connection_get_connection_type (s_con),
NM_SETTING_GSM_SETTING_NAME)) {
g_set_error (error,
NM_MODEM_ERROR,
NM_MODEM_ERROR_CONNECTION_NOT_GSM,
"The connection was not a 3GPP connection.");
NM_SETTING_GSM_SETTING_NAME))
return FALSE;
}
s_gsm = nm_connection_get_setting_gsm (connection);
if (!s_gsm) {
g_set_error (error,
NM_MODEM_ERROR,
NM_MODEM_ERROR_CONNECTION_INVALID,
"The connection was not a valid 3GPP connection.");
if (!s_gsm)
return FALSE;
}
return TRUE;
}
@ -389,30 +377,16 @@ check_connection_compatible (NMModem *_self,
NMSettingCdma *s_cdma;
if (!g_str_equal (nm_setting_connection_get_connection_type (s_con),
NM_SETTING_CDMA_SETTING_NAME)) {
g_set_error (error,
NM_MODEM_ERROR,
NM_MODEM_ERROR_CONNECTION_NOT_CDMA,
"The connection was not a 3GPP2 connection.");
NM_SETTING_CDMA_SETTING_NAME))
return FALSE;
}
s_cdma = nm_connection_get_setting_cdma (connection);
if (!s_cdma) {
g_set_error (error,
NM_MODEM_ERROR,
NM_MODEM_ERROR_CONNECTION_INVALID,
"The connection was not a valid 3GPP2 connection.");
if (!s_cdma)
return FALSE;
}
return TRUE;
}
g_set_error (error,
NM_MODEM_ERROR,
NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE,
"Device is not a mobile broadband modem");
return FALSE;
}

View file

@ -733,9 +733,7 @@ modem_properties_changed (DBusGProxy *proxy,
/*****************************************************************************/
static gboolean
check_connection_compatible (NMModem *modem,
NMConnection *connection,
GError **error)
check_connection_compatible (NMModem *modem, NMConnection *connection)
{
NMModemOldPrivate *priv = NM_MODEM_OLD_GET_PRIVATE (modem);
NMSettingConnection *s_con;
@ -760,26 +758,14 @@ check_connection_compatible (NMModem *modem,
return TRUE;
/* If the modem is only CDMA and the connection is not CDMA, error */
if ((priv->caps ^ NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) == 0) {
g_set_error (error, NM_MODEM_ERROR, NM_MODEM_ERROR_CONNECTION_NOT_CDMA,
"The connection was not a CDMA connection.");
if ((priv->caps ^ NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) == 0)
return FALSE;
}
}
/* Validate 3GPP */
if (priv->caps & CAPS_3GPP) {
if (valid_gsm)
return TRUE;
if (priv->caps & CAPS_3GPP)
return valid_gsm;
g_set_error (error, NM_MODEM_ERROR, NM_MODEM_ERROR_CONNECTION_NOT_GSM,
"The connection was not a GSM/UMTS/LTE connection.");
return FALSE;
}
g_set_error (error, NM_MODEM_ERROR, NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE,
"The connection was not not compatible with this modem (caps 0x%X)",
priv->caps);
return FALSE;
}

View file

@ -585,12 +585,10 @@ nm_modem_act_stage2_config (NMModem *self,
/*****************************************************************************/
gboolean
nm_modem_check_connection_compatible (NMModem *self,
NMConnection *connection,
GError **error)
nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection)
{
if (NM_MODEM_GET_CLASS (self)->check_connection_compatible)
return NM_MODEM_GET_CLASS (self)->check_connection_compatible (self, connection, error);
return NM_MODEM_GET_CLASS (self)->check_connection_compatible (self, connection);
return FALSE;
}

View file

@ -107,8 +107,7 @@ typedef struct {
const char **pass);
gboolean (*check_connection_compatible) (NMModem *modem,
NMConnection *connection,
GError **error);
NMConnection *connection);
gboolean (*complete_connection) (NMModem *modem,
NMConnection *connection,
@ -162,9 +161,7 @@ void nm_modem_get_capabilities (NMModem *self,
NMDeviceModemCapabilities *modem_caps,
NMDeviceModemCapabilities *current_caps);
gboolean nm_modem_check_connection_compatible (NMModem *self,
NMConnection *connection,
GError **error);
gboolean nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection);
gboolean nm_modem_complete_connection (NMModem *self,
NMConnection *connection,

View file

@ -1062,14 +1062,10 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
/* Make sure we didn't create a device for this connection already */
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
NMDevice *candidate = iter->data;
GError *error = NULL;
if ( g_strcmp0 (nm_device_get_iface (candidate), iface) == 0
|| nm_device_check_connection_compatible (candidate, connection, &error)) {
g_clear_error (&error);
|| nm_device_check_connection_compatible (candidate, connection))
goto out;
}
g_clear_error (&error);
}
/* Block notification of link added since we're creating the device
@ -1516,7 +1512,7 @@ local_slist_free (void *loc)
static gboolean
match_connection_filter (NMConnection *connection, gpointer user_data)
{
return nm_device_check_connection_compatible (NM_DEVICE (user_data), connection, NULL);
return nm_device_check_connection_compatible (NM_DEVICE (user_data), connection);
}
/**

View file

@ -1131,7 +1131,7 @@ reset_autoconnect_all (NMPolicy *policy, NMDevice *device)
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = g_slist_next (iter)) {
if (!device || nm_device_check_connection_compatible (device, iter->data, NULL)) {
if (!device || nm_device_check_connection_compatible (device, iter->data)) {
nm_settings_connection_reset_autoconnect_retries (iter->data);
nm_settings_connection_set_autoconnect_blocked_reason (iter->data, NM_DEVICE_STATE_REASON_NONE);
}
@ -1177,7 +1177,7 @@ block_autoconnect_for_device (NMPolicy *policy, NMDevice *device)
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = g_slist_next (iter)) {
if (nm_device_check_connection_compatible (device, iter->data, NULL)) {
if (nm_device_check_connection_compatible (device, iter->data)) {
nm_settings_connection_set_autoconnect_blocked_reason (NM_SETTINGS_CONNECTION (iter->data),
NM_DEVICE_STATE_REASON_USER_REQUESTED);
}