libnm: merge device-type-specific errors into NMDeviceError

As with the settings, each device type was defining its own error
type, containing either redundant or non-useful error codes. Drop all
of the subtype-specific errors, and reduce things to just
NM_DEVICE_ERROR_FAILED, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, and
NM_DEVICE_ERROR_INVALID_CONNECTION.

The device-type-specific errors were only returned from their
nm_device_connection_compatible() implementations, so this is also a
good opportunity to simplify those, by moving duplicated functionality
into the base NMDevice implementation, and then allowing the
subclasses to assume that the connection has already been validated in
their own code. Most of the implementations now just check that the
connection has the correct type for the device (which can't be done at
the NMDevice level since some device types (eg, Ethernet) support
multiple connection types.)

Also, make sure that all of the error messages are localized.
This commit is contained in:
Dan Winship 2014-10-11 14:44:10 -04:00
parent 5632ac6730
commit 69099f3e80
30 changed files with 165 additions and 763 deletions

View file

@ -151,24 +151,16 @@ global:
nm_connectivity_state_get_type;
nm_crypto_error_get_type;
nm_crypto_error_quark;
nm_device_adsl_error_get_type;
nm_device_adsl_error_quark;
nm_device_adsl_get_carrier;
nm_device_adsl_get_type;
nm_device_bond_error_get_type;
nm_device_bond_error_quark;
nm_device_bond_get_carrier;
nm_device_bond_get_hw_address;
nm_device_bond_get_slaves;
nm_device_bond_get_type;
nm_device_bridge_error_get_type;
nm_device_bridge_error_quark;
nm_device_bridge_get_carrier;
nm_device_bridge_get_hw_address;
nm_device_bridge_get_slaves;
nm_device_bridge_get_type;
nm_device_bt_error_get_type;
nm_device_bt_error_quark;
nm_device_bt_get_capabilities;
nm_device_bt_get_hw_address;
nm_device_bt_get_name;
@ -185,16 +177,12 @@ global:
nm_device_disconnect_finish;
nm_device_error_get_type;
nm_device_error_quark;
nm_device_ethernet_error_get_type;
nm_device_ethernet_error_quark;
nm_device_ethernet_get_carrier;
nm_device_ethernet_get_hw_address;
nm_device_ethernet_get_permanent_hw_address;
nm_device_ethernet_get_speed;
nm_device_ethernet_get_type;
nm_device_filter_connections;
nm_device_generic_error_get_type;
nm_device_generic_error_quark;
nm_device_generic_get_hw_address;
nm_device_generic_get_type;
nm_device_get_active_connection;
@ -225,20 +213,14 @@ global:
nm_device_get_type_description;
nm_device_get_udi;
nm_device_get_vendor;
nm_device_infiniband_error_get_type;
nm_device_infiniband_error_quark;
nm_device_infiniband_get_carrier;
nm_device_infiniband_get_hw_address;
nm_device_infiniband_get_type;
nm_device_is_software;
nm_device_modem_capabilities_get_type;
nm_device_modem_error_get_type;
nm_device_modem_error_quark;
nm_device_modem_get_current_capabilities;
nm_device_modem_get_modem_capabilities;
nm_device_modem_get_type;
nm_device_olpc_mesh_error_get_type;
nm_device_olpc_mesh_error_quark;
nm_device_olpc_mesh_get_active_channel;
nm_device_olpc_mesh_get_companion;
nm_device_olpc_mesh_get_hw_address;
@ -246,22 +228,16 @@ global:
nm_device_set_autoconnect;
nm_device_state_get_type;
nm_device_state_reason_get_type;
nm_device_team_error_get_type;
nm_device_team_error_quark;
nm_device_team_get_carrier;
nm_device_team_get_hw_address;
nm_device_team_get_slaves;
nm_device_team_get_type;
nm_device_type_get_type;
nm_device_vlan_error_get_type;
nm_device_vlan_error_quark;
nm_device_vlan_get_carrier;
nm_device_vlan_get_hw_address;
nm_device_vlan_get_type;
nm_device_vlan_get_vlan_id;
nm_device_wifi_capabilities_get_type;
nm_device_wifi_error_get_type;
nm_device_wifi_error_quark;
nm_device_wifi_get_access_point_by_path;
nm_device_wifi_get_access_points;
nm_device_wifi_get_active_access_point;
@ -274,8 +250,6 @@ global:
nm_device_wifi_request_scan;
nm_device_wifi_request_scan_async;
nm_device_wifi_request_scan_finish;
nm_device_wimax_error_get_type;
nm_device_wimax_error_quark;
nm_device_wimax_get_active_nsp;
nm_device_wimax_get_bsid;
nm_device_wimax_get_center_frequency;

View file

@ -26,6 +26,7 @@
#include "nm-setting-adsl.h"
#include <string.h>
#include <glib/gi18n.h>
G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE)
@ -42,23 +43,6 @@ enum {
LAST_PROP
};
/**
* nm_device_adsl_error_quark:
*
* Registers an error quark for #NMDeviceAdsl if necessary.
*
* Returns: the error quark used for #NMDeviceAdsl errors.
**/
GQuark
nm_device_adsl_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-adsl-error-quark");
return quark;
}
/**
* nm_device_adsl_get_carrier:
* @device: a #NMDeviceAdsl
@ -78,28 +62,16 @@ nm_device_adsl_get_carrier (NMDeviceAdsl *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingAdsl *s_adsl;
const char *ctype;
if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error))
return FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_ADSL_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION,
"The connection was not an ADSL connection.");
if (!nm_connection_is_type (connection, NM_SETTING_ADSL_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not an ADSL connection."));
return FALSE;
}
s_adsl = nm_connection_get_setting_adsl (connection);
if (!s_adsl) {
g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION,
"The connection was not a valid ADSL connection.");
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,21 +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))
/**
* NMDeviceAdslError:
* @NM_DEVICE_ADSL_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION: the connection was not of ADSL type
* @NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION: the ADSL connection was invalid
*/
typedef enum {
NM_DEVICE_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION, /*< nick=NotAdslConnection >*/
NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION, /*< nick=InvalidAdslConnection >*/
} NMDeviceAdslError;
#define NM_DEVICE_ADSL_ERROR nm_device_adsl_error_quark ()
GQuark nm_device_adsl_error_quark (void);
#define NM_DEVICE_ADSL_CARRIER "carrier"
struct _NMDeviceAdsl {

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -51,23 +52,6 @@ enum {
LAST_PROP
};
/**
* nm_device_bond_error_quark:
*
* Registers an error quark for #NMDeviceBond if necessary.
*
* Returns: the error quark used for #NMDeviceBond errors.
**/
GQuark
nm_device_bond_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-bond-error-quark");
return quark;
}
/**
* nm_device_bond_get_hw_address:
* @device: a #NMDeviceBond
@ -122,38 +106,18 @@ nm_device_bond_get_slaves (NMDeviceBond *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingBond *s_bond;
const char *ctype, *dev_iface_name, *bond_iface_name;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_BOND_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION,
"The connection was not a bond connection.");
if (!NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_bond = nm_connection_get_setting_bond (connection);
if (!s_bond) {
g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION,
"The connection was not a valid bond connection.");
return FALSE;
}
dev_iface_name = nm_device_get_iface (device);
bond_iface_name = nm_setting_connection_get_interface_name (s_con);
if (g_strcmp0 (dev_iface_name, bond_iface_name) != 0) {
g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
if (!nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a bond connection."));
return FALSE;
}
/* FIXME: check slaves? */
return NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,23 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BOND))
#define NM_DEVICE_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BOND, NMDeviceBondClass))
/**
* NMDeviceBondError:
* @NM_DEVICE_BOND_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION: the connection was not of bond type
* @NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION: the bond connection was invalid
* @NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_BOND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION, /*< nick=NotBondConnection >*/
NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION, /*< nick=InvalidBondConnection >*/
NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
} NMDeviceBondError;
#define NM_DEVICE_BOND_ERROR nm_device_bond_error_quark ()
GQuark nm_device_bond_error_quark (void);
#define NM_DEVICE_BOND_HW_ADDRESS "hw-address"
#define NM_DEVICE_BOND_CARRIER "carrier"
#define NM_DEVICE_BOND_SLAVES "slaves"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -51,23 +52,6 @@ enum {
LAST_PROP
};
/**
* nm_device_bridge_error_quark:
*
* Registers an error quark for #NMDeviceBridge if necessary.
*
* Returns: the error quark used for #NMDeviceBridge errors.
**/
GQuark
nm_device_bridge_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-bridge-error-quark");
return quark;
}
/**
* nm_device_bridge_get_hw_address:
* @device: a #NMDeviceBridge
@ -122,38 +106,18 @@ nm_device_bridge_get_slaves (NMDeviceBridge *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingBridge *s_bridge;
const char *ctype, *dev_iface_name, *bridge_iface_name;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_BRIDGE_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION,
"The connection was not a bridge connection.");
if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_bridge = nm_connection_get_setting_bridge (connection);
if (!s_bridge) {
g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION,
"The connection was not a valid bridge connection.");
return FALSE;
}
dev_iface_name = nm_device_get_iface (device);
bridge_iface_name = nm_setting_connection_get_interface_name (s_con);
if (g_strcmp0 (dev_iface_name, bridge_iface_name) != 0) {
g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
if (!nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a bridge connection."));
return FALSE;
}
/* FIXME: check ports? */
return NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,23 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BRIDGE))
#define NM_DEVICE_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgeClass))
/**
* NMDeviceBridgeError:
* @NM_DEVICE_BRIDGE_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION: the connection was not of bridge type
* @NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION: the bridge connection was invalid
* @NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_BRIDGE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION, /*< nick=NotBridgeConnection >*/
NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION, /*< nick=InvalidBridgeConnection >*/
NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
} NMDeviceBridgeError;
#define NM_DEVICE_BRIDGE_ERROR nm_device_bridge_error_quark ()
GQuark nm_device_bridge_error_quark (void);
#define NM_DEVICE_BRIDGE_HW_ADDRESS "hw-address"
#define NM_DEVICE_BRIDGE_CARRIER "carrier"
#define NM_DEVICE_BRIDGE_SLAVES "slaves"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -52,23 +53,6 @@ enum {
LAST_PROP
};
/**
* nm_device_bt_error_quark:
*
* Registers an error quark for #NMDeviceBt if necessary.
*
* Returns: the error quark used for #NMDeviceBt errors.
**/
GQuark
nm_device_bt_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-bt-error-quark");
return quark;
}
/**
* nm_device_bt_get_hw_address:
* @device: a #NMDeviceBt
@ -142,27 +126,17 @@ get_connection_bt_type (NMConnection *connection)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingBluetooth *s_bt;
const char *ctype;
const char *hw_addr, *setting_addr;
NMBluetoothCapabilities dev_caps;
NMBluetoothCapabilities bt_type;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION,
"The connection was not a Bluetooth connection.");
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_bt = nm_connection_get_setting_bluetooth (connection);
if (!s_bt) {
g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION,
"The connection was not a valid Bluetooth connection.");
if (!nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a Bluetooth connection."));
return FALSE;
}
@ -170,14 +144,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
hw_addr = nm_device_bt_get_hw_address (NM_DEVICE_BT (device));
if (hw_addr) {
if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) {
g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC,
"Invalid device MAC address.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
_("Invalid device Bluetooth address."));
return FALSE;
}
s_bt = nm_connection_get_setting_bluetooth (connection);
setting_addr = nm_setting_bluetooth_get_bdaddr (s_bt);
if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, hw_addr, -1)) {
g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MAC_MISMATCH,
"The MACs of the device and the connection didn't match.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The Bluetooth addresses of the device and the connection didn't match."));
return FALSE;
}
}
@ -185,12 +160,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
dev_caps = nm_device_bt_get_capabilities (NM_DEVICE_BT (device));
bt_type = get_connection_bt_type (connection);
if (!(bt_type & dev_caps)) {
g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS,
"The device missed BT capabilities required by the connection.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The device is lacking Bluetooth capabilities required by the connection."));
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -37,27 +37,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BT))
#define NM_DEVICE_BT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BT, NMDeviceBtClass))
/**
* NMDeviceBtError:
* @NM_DEVICE_BT_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION: the connection was not of bluetooth type
* @NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION: the bluetooth connection was invalid
* @NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
* @NM_DEVICE_BT_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
* @NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS: the device missed required capabilities
*/
typedef enum {
NM_DEVICE_BT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION, /*< nick=NotBtConnection >*/
NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION, /*< nick=InvalidBtConnection >*/
NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
NM_DEVICE_BT_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS, /*< nick=MissingDeviceCaps >*/
} NMDeviceBtError;
#define NM_DEVICE_BT_ERROR nm_device_bt_error_quark ()
GQuark nm_device_bt_error_quark (void);
#define NM_DEVICE_BT_HW_ADDRESS "hw-address"
#define NM_DEVICE_BT_NAME "name"
#define NM_DEVICE_BT_CAPABILITIES "bt-capabilities"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -54,23 +55,6 @@ enum {
LAST_PROP
};
/**
* nm_device_ethernet_error_quark:
*
* Registers an error quark for #NMDeviceEthernet if necessary.
*
* Returns: the error quark used for #NMDeviceEthernet errors.
**/
GQuark
nm_device_ethernet_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-ethernet-error-quark");
return quark;
}
/**
* nm_device_ethernet_get_hw_address:
* @device: a #NMDeviceEthernet
@ -140,31 +124,22 @@ nm_device_ethernet_get_carrier (NMDeviceEthernet *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingWired *s_wired;
const char *ctype;
gboolean is_pppoe = FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error))
return FALSE;
ctype = nm_setting_connection_get_connection_type (s_con);
if (!strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME))
if (nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME))
is_pppoe = TRUE;
else if (strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION,
"The connection was not a wired or PPPoE connection.");
else if (!nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not an Ethernet or PPPoE connection."));
return FALSE;
}
s_wired = nm_connection_get_setting_wired (connection);
/* Wired setting optional for PPPoE */
if (!is_pppoe && !s_wired) {
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION,
"The connection was not a valid Ethernet connection.");
return FALSE;
}
if (s_wired) {
const char *perm_addr, *setting_addr;
@ -174,20 +149,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
perm_addr = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device));
if (perm_addr) {
if (!nm_utils_hwaddr_valid (perm_addr, ETH_ALEN)) {
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC,
"Invalid device MAC address.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
_("Invalid device MAC address."));
return FALSE;
}
setting_addr = nm_setting_wired_get_mac_address (s_wired);
if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, perm_addr, -1)) {
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH,
"The MACs of the device and the connection didn't match.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The MACs of the device and the connection didn't match."));
return FALSE;
}
}
}
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -37,25 +37,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ETHERNET))
#define NM_DEVICE_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetClass))
/**
* NMDeviceEthernetError:
* @NM_DEVICE_ETHERNET_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION: the connection was not of Ethernet or PPPoE type
* @NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION: the Ethernet connection was invalid
* @NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
* @NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_ETHERNET_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION, /*< nick=NotEthernetConnection >*/
NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION, /*< nick=InvalidEthernetConnection >*/
NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
} NMDeviceEthernetError;
#define NM_DEVICE_ETHERNET_ERROR nm_device_ethernet_error_quark ()
GQuark nm_device_ethernet_error_quark (void);
#define NM_DEVICE_ETHERNET_HW_ADDRESS "hw-address"
#define NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS "perm-hw-address"
#define NM_DEVICE_ETHERNET_SPEED "speed"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-device-generic.h"
#include "nm-device-private.h"
@ -44,23 +45,6 @@ enum {
LAST_PROP
};
/**
* nm_device_generic_error_quark:
*
* Registers an error quark for #NMDeviceGeneric if necessary.
*
* Returns: the error quark used for #NMDeviceGeneric errors.
**/
GQuark
nm_device_generic_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-generic-error-quark");
return quark;
}
/**
* nm_device_generic_get_hw_address:
* @device: a #NMDeviceGeneric
@ -97,27 +81,25 @@ get_hw_address (NMDevice *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
const char *ctype, *iface_name;
const char *iface_name;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (!NM_DEVICE_CLASS (nm_device_generic_parent_class)->connection_compatible (device, connection, error))
return FALSE;
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_GENERIC_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION,
"The connection was not a generic connection.");
if (!nm_connection_is_type (connection, NM_SETTING_GENERIC_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a generic connection."));
return FALSE;
}
iface_name = nm_setting_connection_get_interface_name (s_con);
iface_name = nm_connection_get_interface_name (connection);
if (!iface_name) {
g_set_error (error, NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME,
"The connection did not specify an interface name.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
_("The connection did not specify an interface name."));
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_generic_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,21 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_GENERIC))
#define NM_DEVICE_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericClass))
/**
* NMDeviceGenericError:
* @NM_DEVICE_GENERIC_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION: the connection was not of generic type
* @NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME: the connection did not specify the interface name
*/
typedef enum {
NM_DEVICE_GENERIC_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION, /*< nick=NotGenericConnection >*/
NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME, /*< nick=MissingInterfaceName >*/
} NMDeviceGenericError;
#define NM_DEVICE_GENERIC_ERROR nm_device_generic_error_quark ()
GQuark nm_device_generic_error_quark (void);
#define NM_DEVICE_GENERIC_HW_ADDRESS "hw-address"
#define NM_DEVICE_GENERIC_TYPE_DESCRIPTION "type-description"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -48,23 +49,6 @@ enum {
LAST_PROP
};
/**
* nm_device_infiniband_error_quark:
*
* Registers an error quark for #NMDeviceInfiniband if necessary.
*
* Returns: the error quark used for #NMDeviceInfiniband errors.
**/
GQuark
nm_device_infiniband_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-infiniband-error-quark");
return quark;
}
/**
* nm_device_infiniband_get_hw_address:
* @device: a #NMDeviceInfiniband
@ -101,44 +85,36 @@ nm_device_infiniband_get_carrier (NMDeviceInfiniband *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingInfiniband *s_infiniband;
const char *ctype, *hwaddr, *setting_hwaddr;
const char *hwaddr, *setting_hwaddr;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_INFINIBAND_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION,
"The connection was not a InfiniBand connection.");
if (!NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_infiniband = nm_connection_get_setting_infiniband (connection);
if (!s_infiniband) {
g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION,
"The connection was not a valid InfiniBand connection.");
if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not an InfiniBand connection."));
return FALSE;
}
hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
if (hwaddr) {
if (!nm_utils_hwaddr_valid (hwaddr, INFINIBAND_ALEN)) {
g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC,
"Invalid device MAC address.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
_("Invalid device MAC address."));
return FALSE;
}
s_infiniband = nm_connection_get_setting_infiniband (connection);
setting_hwaddr = nm_setting_infiniband_get_mac_address (s_infiniband);
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH,
"The MACs of the device and the connection didn't match.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The MACs of the device and the connection didn't match."));
return FALSE;
}
}
return NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,25 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_INFINIBAND))
#define NM_DEVICE_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass))
/**
* NMDeviceInfinibandError:
* @NM_DEVICE_INFINIBAND_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION: the connection was not of InfiniBand type
* @NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION: the InfiniBand connection was invalid
* @NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
* @NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_INFINIBAND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION, /*< nick=NotInfinibandConnection >*/
NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION, /*< nick=InvalidInfinibandConnection >*/
NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
} NMDeviceInfinibandError;
#define NM_DEVICE_INFINIBAND_ERROR nm_device_infiniband_error_quark ()
GQuark nm_device_infiniband_error_quark (void);
#define NM_DEVICE_INFINIBAND_HW_ADDRESS "hw-address"
#define NM_DEVICE_INFINIBAND_CARRIER "carrier"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -49,23 +50,6 @@ enum {
LAST_PROP
};
/**
* nm_device_modem_error_quark:
*
* Registers an error quark for #NMDeviceModem if necessary.
*
* Returns: the error quark used for #NMDeviceModem errors.
**/
GQuark
nm_device_modem_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-modem-error-quark");
return quark;
}
/**
* nm_device_modem_get_modem_capabilities:
* @self: a #NMDeviceModem
@ -125,39 +109,36 @@ get_type_description (NMDevice *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingGsm *s_gsm;
NMSettingCdma *s_cdma;
const char *ctype;
NMDeviceModemCapabilities current_caps;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error))
return FALSE;
ctype = nm_setting_connection_get_connection_type (s_con);
if ( strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) != 0
&& strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION,
"The connection was not a modem connection.");
if ( !nm_connection_is_type (connection, NM_SETTING_GSM_SETTING_NAME)
&& !nm_connection_is_type (connection, NM_SETTING_CDMA_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a modem connection."));
return FALSE;
}
s_gsm = nm_connection_get_setting_gsm (connection);
s_cdma = nm_connection_get_setting_cdma (connection);
if (!s_cdma && !s_gsm) {
g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION,
"The connection was not a valid modem connection.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
_("The connection was not a valid modem connection."));
return FALSE;
}
current_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
if (!(s_gsm && MODEM_CAPS_3GPP (current_caps)) && !(s_cdma && MODEM_CAPS_3GPP2 (current_caps))) {
g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS,
"The device missed capabilities required by the GSM/CDMA connection.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The device is lacking capabilities required by the connection."));
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -37,23 +37,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MODEM))
#define NM_DEVICE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass))
/**
* NMDeviceModemError:
* @NM_DEVICE_MODEM_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION: the connection was not of modem type
* @NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION: the modem connection was invalid
* @NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS: the device missed required capabilities
*/
typedef enum {
NM_DEVICE_MODEM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION, /*< nick=NotModemConnection >*/
NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION, /*< nick=InvalidModemConnection >*/
NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS, /*< nick=MissingDeviceCaps >*/
} NMDeviceModemError;
#define NM_DEVICE_MODEM_ERROR nm_device_modem_error_quark ()
GQuark nm_device_modem_error_quark (void);
#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities"
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -50,23 +51,6 @@ enum {
LAST_PROP
};
/**
* nm_device_olpc_mesh_error_quark:
*
* Registers an error quark for #NMDeviceOlpcMesh if necessary.
*
* Returns: the error quark used for #NMDeviceOlpcMesh errors.
**/
GQuark
nm_device_olpc_mesh_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-olpc-mesh-error-quark");
return quark;
}
/**
* nm_device_olpc_mesh_get_hw_address:
* @device: a #NMDeviceOlpcMesh
@ -125,28 +109,16 @@ get_hw_address (NMDevice *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingOlpcMesh *s_olpc_mesh;
const char *ctype;
if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error))
return FALSE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_OLPC_MESH_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION,
"The connection was not a Olpc Mesh connection.");
if (!nm_connection_is_type (connection, NM_SETTING_OLPC_MESH_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not an OLPC Mesh connection."));
return FALSE;
}
s_olpc_mesh = nm_connection_get_setting_olpc_mesh (connection);
if (!s_olpc_mesh) {
g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION,
"The connection was not a valid Olpc Mesh connection.");
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,21 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OLPC_MESH))
#define NM_DEVICE_OLPC_MESH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshClass))
/**
* NMDeviceOlpcMeshError:
* @NM_DEVICE_OLPC_MESH_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION: the connection was not of Olpc Mesh type
* @NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION: the Olpc Mesh connection was invalid
*/
typedef enum {
NM_DEVICE_OLPC_MESH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION, /*< nick=NotOlpcMeshConnection >*/
NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION, /*< nick=InvalidOlpcMeshConnection >*/
} NMDeviceOlpcMeshError;
#define NM_DEVICE_OLPC_MESH_ERROR nm_device_olpc_mesh_error_quark ()
GQuark nm_device_olpc_mesh_error_quark (void);
#define NM_DEVICE_OLPC_MESH_HW_ADDRESS "hw-address"
#define NM_DEVICE_OLPC_MESH_COMPANION "companion"
#define NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL "active-channel"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -51,23 +52,6 @@ enum {
LAST_PROP
};
/**
* nm_device_team_error_quark:
*
* Registers an error quark for #NMDeviceTeam if necessary.
*
* Returns: the error quark used for #NMDeviceTeam errors.
**/
GQuark
nm_device_team_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-team-error-quark");
return quark;
}
/**
* nm_device_team_get_hw_address:
* @device: a #NMDeviceTeam
@ -128,38 +112,18 @@ get_hw_address (NMDevice *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingTeam *s_team;
const char *ctype, *dev_iface_name, *team_iface_name;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_TEAM_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION,
"The connection was not a team connection.");
if (!NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_team = nm_connection_get_setting_team (connection);
if (!s_team) {
g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION,
"The connection was not a valid team connection.");
return FALSE;
}
dev_iface_name = nm_device_get_iface (device);
team_iface_name = nm_setting_connection_get_interface_name (s_con);
if (g_strcmp0 (dev_iface_name, team_iface_name) != 0) {
g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
if (!nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
_("The connection was not a team connection."));
return FALSE;
}
/* FIXME: check slaves? */
return NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,23 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_TEAM))
#define NM_DEVICE_TEAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeamClass))
/**
* NMDeviceTeamError:
* @NM_DEVICE_TEAM_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION: the connection was not of team type
* @NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION: the team connection was invalid
* @NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_TEAM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION, /*< nick=NotTeamConnection >*/
NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION, /*< nick=InvalidTeamConnection >*/
NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
} NMDeviceTeamError;
#define NM_DEVICE_TEAM_ERROR nm_device_team_error_quark ()
GQuark nm_device_team_error_quark (void);
#define NM_DEVICE_TEAM_HW_ADDRESS "hw-address"
#define NM_DEVICE_TEAM_CARRIER "carrier"
#define NM_DEVICE_TEAM_SLAVES "slaves"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -50,23 +51,6 @@ enum {
LAST_PROP
};
/**
* nm_device_vlan_error_quark:
*
* Registers an error quark for #NMDeviceVlan if necessary.
*
* Returns: the error quark used for #NMDeviceVlan errors.
**/
GQuark
nm_device_vlan_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-vlan-error-quark");
return quark;
}
/**
* nm_device_vlan_get_hw_address:
* @device: a #NMDeviceVlan
@ -117,40 +101,23 @@ nm_device_vlan_get_vlan_id (NMDeviceVlan *device)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingVlan *s_vlan;
NMSettingWired *s_wired;
const char *ctype, *dev_iface_name, *vlan_iface_name;
const char *setting_hwaddr;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (!NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error))
return FALSE;
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_VLAN_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION,
"The connection was not a VLAN connection.");
if (!nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a VLAN connection."));
return FALSE;
}
s_vlan = nm_connection_get_setting_vlan (connection);
if (!s_vlan) {
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION,
"The connection was not a valid VLAN connection.");
return FALSE;
}
if (nm_setting_vlan_get_id (s_vlan) != nm_device_vlan_get_vlan_id (NM_DEVICE_VLAN (device))) {
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_ID_MISMATCH,
"The VLAN identifiers of the device and the connection didn't match.");
return FALSE;
}
dev_iface_name = nm_device_get_iface (device);
vlan_iface_name = nm_setting_connection_get_interface_name (s_con);
if (vlan_iface_name && g_strcmp0 (dev_iface_name, vlan_iface_name) != 0) {
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The VLAN identifiers of the device and the connection didn't match."));
return FALSE;
}
@ -161,13 +128,13 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
setting_hwaddr = NULL;
if (setting_hwaddr) {
if (!nm_utils_hwaddr_matches (setting_hwaddr, -1,
NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address, -1)) {
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_MAC_MISMATCH,
"The hardware address of the device and the connection didn't match.");
NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address, -1)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The hardware address of the device and the connection didn't match."));
}
}
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -36,27 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_VLAN))
#define NM_DEVICE_VLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_VLAN, NMDeviceVlanClass))
/**
* NMDeviceVlanError:
* @NM_DEVICE_VLAN_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION: the connection was not of VLAN type
* @NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION: the VLAN connection was invalid
* @NM_DEVICE_VLAN_ERROR_ID_MISMATCH: the VLAN identifiers of the connection and the device mismatched
* @NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched
* @NM_DEVICE_VLAN_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_VLAN_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION, /*< nick=NotVlanConnection >*/
NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION, /*< nick=InvalidVlanConnection >*/
NM_DEVICE_VLAN_ERROR_ID_MISMATCH, /*< nick=IdMismatch >*/
NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
NM_DEVICE_VLAN_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
} NMDeviceVlanError;
#define NM_DEVICE_VLAN_ERROR nm_device_vlan_error_quark ()
GQuark nm_device_vlan_error_quark (void);
#define NM_DEVICE_VLAN_HW_ADDRESS "hw-address"
#define NM_DEVICE_VLAN_CARRIER "carrier"
#define NM_DEVICE_VLAN_VLAN_ID "vlan-id"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -86,23 +87,6 @@ enum {
};
static guint signals[LAST_SIGNAL] = { 0 };
/**
* nm_device_wifi_error_quark:
*
* Registers an error quark for #NMDeviceWifi if necessary.
*
* Returns: the error quark used for #NMDeviceWifi errors.
**/
GQuark
nm_device_wifi_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-wifi-error-quark");
return quark;
}
/**
* nm_device_wifi_get_hw_address:
* @device: a #NMDeviceWifi
@ -477,28 +461,18 @@ has_proto (NMSettingWirelessSecurity *s_wsec, const char *proto)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingWireless *s_wifi;
NMSettingWirelessSecurity *s_wsec;
const char *ctype;
const char *hwaddr, *setting_hwaddr;
NMDeviceWifiCapabilities wifi_caps;
const char *key_mgmt;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION,
"The connection was not a Wi-Fi connection.");
if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_wifi = nm_connection_get_setting_wireless (connection);
if (!s_wifi) {
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION,
"The connection was not a valid Wi-Fi connection.");
if (!nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a Wi-Fi connection."));
return FALSE;
}
@ -506,20 +480,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
hwaddr = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device));
if (hwaddr) {
if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) {
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC,
"Invalid device MAC address.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
_("Invalid device MAC address."));
return FALSE;
}
s_wifi = nm_connection_get_setting_wireless (connection);
setting_hwaddr = nm_setting_wireless_get_mac_address (s_wifi);
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MAC_MISMATCH,
"The MACs of the device and the connection didn't match.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The MACs of the device and the connection didn't match."));
return FALSE;
}
}
/* Check device capabilities; we assume all devices can do WEP at least */
wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device));
s_wsec = nm_connection_get_setting_wireless_security (connection);
if (s_wsec) {
@ -529,23 +503,25 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|| !g_strcmp0 (key_mgmt, "wpa-psk")
|| !g_strcmp0 (key_mgmt, "wpa-eap")) {
wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device));
/* Is device only WEP capable? */
if (!(wifi_caps & WPA_CAPS)) {
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS,
"The device missed WPA capabilities required by the connection.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The device is lacking WPA capabilities required by the connection."));
return FALSE;
}
/* Make sure WPA2/RSN-only connections don't get chosen for WPA-only cards */
if (has_proto (s_wsec, "rsn") && !has_proto (s_wsec, "wpa") && !(wifi_caps & RSN_CAPS)) {
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS,
"The device missed WPA2/RSN capabilities required by the connection.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The device is lacking WPA2/RSN capabilities required by the connection."));
return FALSE;
}
}
}
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -37,31 +37,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIFI))
#define NM_DEVICE_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass))
/**
* NMDeviceWifiError:
* @NM_DEVICE_WIFI_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION: the connection was not of Wi-Fi type
* @NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION: the Wi-Fi connection was invalid
* @NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
* @NM_DEVICE_WIFI_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
* @NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS: the device missed WPA capabilities
* required by the connection
* @NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS: the device missed RSN capabilities
* required by the connection
*/
typedef enum {
NM_DEVICE_WIFI_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION, /*< nick=NotWifiConnection >*/
NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION, /*< nick=InvalidWifiConnection >*/
NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
NM_DEVICE_WIFI_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS, /*< nick=MissingDeviceWpaCaps >*/
NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS, /*< nick=MissingDeviceRsnCaps >*/
} NMDeviceWifiError;
#define NM_DEVICE_WIFI_ERROR nm_device_wifi_error_quark ()
GQuark nm_device_wifi_error_quark (void);
#define NM_DEVICE_WIFI_HW_ADDRESS "hw-address"
#define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address"
#define NM_DEVICE_WIFI_MODE "mode"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -76,23 +77,6 @@ enum {
};
static guint signals[LAST_SIGNAL] = { 0 };
/**
* nm_device_wimax_error_quark:
*
* Registers an error quark for #NMDeviceWimax if necessary.
*
* Returns: the error quark used for #NMDeviceWimax errors.
**/
GQuark
nm_device_wimax_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-wimax-error-quark");
return quark;
}
/**
* nm_device_wimax_get_hw_address:
* @wimax: a #NMDeviceWimax
@ -306,25 +290,15 @@ nm_device_wimax_get_bsid (NMDeviceWimax *self)
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingWimax *s_wimax;
const char *ctype;
const char *hwaddr, *setting_hwaddr;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION,
"The connection was not a Wimax connection.");
if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error))
return FALSE;
}
s_wimax = nm_connection_get_setting_wimax (connection);
if (!s_wimax) {
g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION,
"The connection was not a valid Wimax connection.");
if (!nm_connection_is_type (connection, NM_SETTING_WIMAX_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a WiMAX connection."));
return FALSE;
}
@ -332,19 +306,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
if (hwaddr) {
if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) {
g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC,
"Invalid device MAC address.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
_("Invalid device MAC address."));
return FALSE;
}
s_wimax = nm_connection_get_setting_wimax (connection);
setting_hwaddr = nm_setting_wimax_get_mac_address (s_wimax);
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH,
"The MACs of the device and the connection didn't match.");
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The MACs of the device and the connection didn't match."));
return FALSE;
}
}
return NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -37,25 +37,6 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIMAX))
#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
/**
* NMDeviceWimaxError:
* @NM_DEVICE_WIMAX_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION: the connection was not of WiMax type
* @NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION: the WiMax connection was invalid
* @NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid
* @NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched
*/
typedef enum {
NM_DEVICE_WIMAX_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION, /*< nick=NotWimaxConnection >*/
NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION, /*< nick=InvalidWimaxConnection >*/
NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/
NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/
} NMDeviceWimaxError;
#define NM_DEVICE_WIMAX_ERROR nm_device_wimax_error_quark ()
GQuark nm_device_wimax_error_quark (void);
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
#define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency"

View file

@ -2115,17 +2115,21 @@ nm_device_connection_valid (NMDevice *device, NMConnection *connection)
gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
const char *config_iface, *device_iface;
GError *local = NULL;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (!nm_connection_verify (connection, &local)) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
_("The connection was not valid: %s"), local->message);
g_error_free (local);
return FALSE;
}
config_iface = nm_setting_connection_get_interface_name (s_con);
config_iface = nm_connection_get_interface_name (connection);
device_iface = nm_device_get_iface (device);
if (config_iface && g_strcmp0 (config_iface, device_iface) != 0) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INTERFACE_MISMATCH,
"The interface names of the device and the connection didn't match.");
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The interface names of the device and the connection didn't match."));
return FALSE;
}

View file

@ -39,13 +39,17 @@ G_BEGIN_DECLS
/**
* NMDeviceError:
* @NM_DEVICE_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_ERROR_INTERFACE_MISMATCH: the interface names of the connection and the
* device mismatched
* @NM_DEVICE_ERROR_FAILED: unknown or unclassified error
* @NM_DEVICE_ERROR_INVALID_CONNECTION: the connection is not valid
* @NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION: the connection is not compatible
* with this device.
*
* Errors from #NMDevice methods.
*/
typedef enum {
NM_DEVICE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
NM_DEVICE_ERROR_FAILED = 0, /*< nick=Failed >*/
NM_DEVICE_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, /*< nick=IncompatibleConnection >*/
} NMDeviceError;
#define NM_DEVICE_ERROR nm_device_error_quark ()

View file

@ -100,6 +100,20 @@ libnm-util/nm-setting-wired.c
libnm-util/nm-setting-wireless-security.c
libnm-util/nm-setting-wireless.c
libnm-util/nm-utils.c
libnm/nm-device-adsl.c
libnm/nm-device-bond.c
libnm/nm-device-bridge.c
libnm/nm-device-bt.c
libnm/nm-device-ethernet.c
libnm/nm-device-generic.c
libnm/nm-device-infiniband.c
libnm/nm-device-modem.c
libnm/nm-device-olpc-mesh.c
libnm/nm-device-team.c
libnm/nm-device-vlan.c
libnm/nm-device-wifi.c
libnm/nm-device-wimax.c
libnm/nm-device.c
libnm/nm-object.c
libnm/nm-remote-connection.c
libnm/nm-vpn-plugin.c