cli: add VLAN device support
This commit is contained in:
@@ -42,6 +42,7 @@
|
|||||||
#include <nm-device-olpc-mesh.h>
|
#include <nm-device-olpc-mesh.h>
|
||||||
#include <nm-device-infiniband.h>
|
#include <nm-device-infiniband.h>
|
||||||
#include <nm-device-bond.h>
|
#include <nm-device-bond.h>
|
||||||
|
#include <nm-device-vlan.h>
|
||||||
#include <nm-remote-settings.h>
|
#include <nm-remote-settings.h>
|
||||||
#include <nm-vpn-connection.h>
|
#include <nm-vpn-connection.h>
|
||||||
#include <nm-utils.h>
|
#include <nm-utils.h>
|
||||||
@@ -1505,6 +1506,47 @@ check_bond_compatible (NMDeviceBond *device, NMConnection *connection, GError **
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_vlan_compatible (NMDeviceVlan *device, NMConnection *connection, GError **error)
|
||||||
|
{
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
NMSettingVlan *s_vlan;
|
||||||
|
const char *ctype, *dev_iface_name, *vlan_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_VLAN_SETTING_NAME) != 0) {
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
"The connection was not an VLAN connection.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_vlan = nm_connection_get_setting_vlan (connection);
|
||||||
|
if (!s_vlan) {
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
"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, 0, 0,
|
||||||
|
"The connection did not match the device's VLAN ID.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_iface_name = nm_device_get_iface (NM_DEVICE (device));
|
||||||
|
vlan_iface_name = nm_setting_vlan_get_interface_name (s_vlan);
|
||||||
|
if (vlan_iface_name && g_strcmp0 (dev_iface_name, vlan_iface_name) != 0) {
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
"The connection's and device's interface names did not match.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||||
{
|
{
|
||||||
@@ -1529,6 +1571,8 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
|
|||||||
return check_infiniband_compatible (NM_DEVICE_INFINIBAND (device), connection, error);
|
return check_infiniband_compatible (NM_DEVICE_INFINIBAND (device), connection, error);
|
||||||
else if (NM_IS_DEVICE_BOND (device))
|
else if (NM_IS_DEVICE_BOND (device))
|
||||||
return check_bond_compatible (NM_DEVICE_BOND (device), connection, error);
|
return check_bond_compatible (NM_DEVICE_BOND (device), connection, error);
|
||||||
|
else if (NM_IS_DEVICE_VLAN (device))
|
||||||
|
return check_vlan_compatible (NM_DEVICE_VLAN (device), connection, error);
|
||||||
|
|
||||||
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
|
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <nm-device-infiniband.h>
|
#include <nm-device-infiniband.h>
|
||||||
#include <nm-device-bond.h>
|
#include <nm-device-bond.h>
|
||||||
|
#include <nm-device-vlan.h>
|
||||||
#include <nm-utils.h>
|
#include <nm-utils.h>
|
||||||
#include <nm-setting-ip4-config.h>
|
#include <nm-setting-ip4-config.h>
|
||||||
#include <nm-setting-ip6-config.h>
|
#include <nm-setting-ip6-config.h>
|
||||||
@@ -460,6 +461,8 @@ device_type_to_string (NMDevice *device)
|
|||||||
return NM_SETTING_INFINIBAND_SETTING_NAME;
|
return NM_SETTING_INFINIBAND_SETTING_NAME;
|
||||||
case NM_DEVICE_TYPE_BOND:
|
case NM_DEVICE_TYPE_BOND:
|
||||||
return NM_SETTING_BOND_SETTING_NAME;
|
return NM_SETTING_BOND_SETTING_NAME;
|
||||||
|
case NM_DEVICE_TYPE_VLAN:
|
||||||
|
return NM_SETTING_VLAN_SETTING_NAME;
|
||||||
default:
|
default:
|
||||||
return _("Unknown");
|
return _("Unknown");
|
||||||
}
|
}
|
||||||
@@ -739,6 +742,8 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
|
hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
|
||||||
else if (NM_IS_DEVICE_BOND (device))
|
else if (NM_IS_DEVICE_BOND (device))
|
||||||
hwaddr = nm_device_bond_get_hw_address (NM_DEVICE_BOND (device));
|
hwaddr = nm_device_bond_get_hw_address (NM_DEVICE_BOND (device));
|
||||||
|
else if (NM_IS_DEVICE_VLAN (device))
|
||||||
|
hwaddr = nm_device_vlan_get_hw_address (NM_DEVICE_VLAN (device));
|
||||||
|
|
||||||
state_str = g_strdup_printf ("%d (%s)", state, device_state_to_string (state));
|
state_str = g_strdup_printf ("%d (%s)", state, device_state_to_string (state));
|
||||||
reason_str = g_strdup_printf ("%d (%s)", reason, device_reason_to_string (reason));
|
reason_str = g_strdup_printf ("%d (%s)", reason, device_reason_to_string (reason));
|
||||||
|
Reference in New Issue
Block a user