summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2011-11-03 11:04:38 -0400
committerDan Williams <dcbw@redhat.com>2011-12-02 13:09:16 -0600
commitf49e88efe00ed92c0d7c09c3f0680e486f81a48f (patch)
tree8366ea9730ba937e99e70c98fc2af37d96952f94 /cli
parente9cd59b654271e4435a821d07384696f6bcaa96c (diff)
downloadNetworkManager-f49e88efe00ed92c0d7c09c3f0680e486f81a48f.tar.gz
nmcli: add Infiniband support
Diffstat (limited to 'cli')
-rw-r--r--cli/src/connections.c56
-rw-r--r--cli/src/devices.c6
2 files changed, 62 insertions, 0 deletions
diff --git a/cli/src/connections.c b/cli/src/connections.c
index acb396ec2c..b7e7f592c5 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -43,6 +43,7 @@
#if WITH_WIMAX
#include <nm-setting-wimax.h>
#endif
+#include <nm-setting-infiniband.h>
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
#if WITH_WIMAX
@@ -51,8 +52,10 @@
#include <nm-device-modem.h>
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
+#include <nm-device-infiniband.h>
#include <nm-remote-settings.h>
#include <nm-vpn-connection.h>
+#include <nm-utils.h>
#include "utils.h"
#include "settings.h"
@@ -960,6 +963,57 @@ check_modem_compatible (NMDeviceModem *device, NMConnection *connection, GError
}
static gboolean
+check_infiniband_compatible (NMDeviceInfiniband *device, NMConnection *connection, GError **error)
+{
+ NMSettingConnection *s_con;
+ NMSettingInfiniband *s_infiniband;
+ const char *connection_type;
+
+ 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_INFINIBAND_SETTING_NAME)) {
+ g_set_error (error, 0, 0,
+ "The connection was not an Infiniband connection.");
+ return FALSE;
+ }
+
+ s_infiniband = nm_connection_get_setting_infiniband (connection);
+ if (!s_infiniband) {
+ g_set_error (error, 0, 0,
+ "The connection was not a valid Infiniband connection.");
+ return FALSE;
+ }
+
+ if (s_infiniband) {
+ const GByteArray *mac;
+ const char *device_mac_str;
+ GByteArray *device_mac;
+
+ device_mac_str = nm_device_infiniband_get_hw_address (device);
+ device_mac = nm_utils_hwaddr_atoba (device_mac_str, ARPHRD_INFINIBAND);
+ if (!device_mac) {
+ g_set_error (error, 0, 0, "Invalid device MAC address.");
+ return FALSE;
+ }
+
+ mac = nm_setting_infiniband_get_mac_address (s_infiniband);
+ if (mac && memcmp (mac->data, device_mac->data, mac->len)) {
+ g_byte_array_unref (device_mac);
+ g_set_error (error, 0, 0,
+ "The connection's MAC address did not match this device.");
+ return FALSE;
+ }
+ g_byte_array_unref (device_mac);
+ }
+
+ 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);
@@ -979,6 +1033,8 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
#endif
else if (NM_IS_DEVICE_MODEM (device))
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);
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 0b19edba20..3d46afe8fc 100644
--- a/cli/src/devices.c
+++ b/cli/src/devices.c
@@ -41,6 +41,7 @@
#if WITH_WIMAX
#include <nm-device-wimax.h>
#endif
+#include <nm-device-infiniband.h>
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
@@ -56,6 +57,7 @@
#if WITH_WIMAX
#include <nm-setting-wimax.h>
#endif
+#include <nm-setting-infiniband.h>
#include "utils.h"
#include "devices.h"
@@ -327,6 +329,8 @@ device_type_to_string (NMDevice *device)
case NM_DEVICE_TYPE_WIMAX:
return NM_SETTING_WIMAX_SETTING_NAME;
#endif
+ case NM_DEVICE_TYPE_INFINIBAND:
+ return NM_SETTING_INFINIBAND_SETTING_NAME;
default:
return _("Unknown");
}
@@ -640,6 +644,8 @@ show_device_info (gpointer data, gpointer user_data)
else if (NM_IS_DEVICE_WIMAX (device))
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
#endif
+ else if (NM_IS_DEVICE_INFINIBAND (device))
+ hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/
nmc->allowed_fields[1].value = nm_device_get_iface (device);