mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 08:58:28 +02:00
nmcli: add Infiniband support
This commit is contained in:
parent
e9cd59b654
commit
f49e88efe0
2 changed files with 62 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
@ -959,6 +962,57 @@ check_modem_compatible (NMDeviceModem *device, NMConnection *connection, GError
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue