summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2012-03-06 11:31:03 +0100
committerJiří Klimeš <jklimes@redhat.com>2012-03-06 11:31:03 +0100
commit78f09078f1cdeeca2fc52173fd22a88b2b865b3e (patch)
tree663f01ac7f8ea456a99da306a89c33e552e39359 /cli
parent723bab41eae555e712daf72fa48ca55e5a397ed9 (diff)
downloadNetworkManager-78f09078f1cdeeca2fc52173fd22a88b2b865b3e.tar.gz
cli: add Bond device support
Diffstat (limited to 'cli')
-rw-r--r--cli/src/connections.c41
-rw-r--r--cli/src/devices.c6
2 files changed, 46 insertions, 1 deletions
diff --git a/cli/src/connections.c b/cli/src/connections.c
index e3cdbc628e..622134ffb9 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -41,6 +41,7 @@
#include <nm-device-bt.h>
#include <nm-device-olpc-mesh.h>
#include <nm-device-infiniband.h>
+#include <nm-device-bond.h>
#include <nm-remote-settings.h>
#include <nm-vpn-connection.h>
#include <nm-utils.h>
@@ -1467,6 +1468,44 @@ check_infiniband_compatible (NMDeviceInfiniband *device, NMConnection *connectio
}
static gboolean
+check_bond_compatible (NMDeviceBond *device, NMConnection *connection, GError **error)
+{
+ NMSettingConnection *s_con;
+ NMSettingBond *s_bond;
+ const char *connection_type;
+ const char *dev_iface_name, *bond_iface_name;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, 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_BOND_SETTING_NAME)) {
+ g_set_error (error, 0, 0,
+ "The connection was not an Bond connection.");
+ return FALSE;
+ }
+
+ s_bond = nm_connection_get_setting_bond (connection);
+ if (!s_bond) {
+ g_set_error (error, 0, 0,
+ "The connection was not a valid Bond connection.");
+ return FALSE;
+ }
+
+ dev_iface_name = nm_device_get_iface (NM_DEVICE (device));
+ bond_iface_name = nm_setting_bond_get_interface_name (s_bond);
+ if (g_strcmp0 (dev_iface_name, bond_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
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
@@ -1488,6 +1527,8 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
return check_modem_compatible (NM_DEVICE_MODEM (device), connection, error);
else if (NM_IS_DEVICE_INFINIBAND (device))
return check_infiniband_compatible (NM_DEVICE_INFINIBAND (device), connection, error);
+ else if (NM_IS_DEVICE_BOND (device))
+ return check_bond_compatible (NM_DEVICE_BOND (device), connection, error);
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
return FALSE;
diff --git a/cli/src/devices.c b/cli/src/devices.c
index 269ed10934..20a9d5f1a7 100644
--- a/cli/src/devices.c
+++ b/cli/src/devices.c
@@ -38,6 +38,7 @@
#include <nm-device-wimax.h>
#endif
#include <nm-device-infiniband.h>
+#include <nm-device-bond.h>
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
@@ -454,6 +455,8 @@ device_type_to_string (NMDevice *device)
#endif
case NM_DEVICE_TYPE_INFINIBAND:
return NM_SETTING_INFINIBAND_SETTING_NAME;
+ case NM_DEVICE_TYPE_BOND:
+ return NM_SETTING_BOND_SETTING_NAME;
default:
return _("Unknown");
}
@@ -731,7 +734,8 @@ show_device_info (gpointer data, gpointer user_data)
#endif
else if (NM_IS_DEVICE_INFINIBAND (device))
hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
-
+ else if (NM_IS_DEVICE_BOND (device))
+ hwaddr = nm_device_bond_get_hw_address (NM_DEVICE_BOND (device));
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));