mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 01:40:16 +01:00
core: add nm_utils_new_infiniband_name() util
This commit is contained in:
parent
67d45ea1d3
commit
8f7029d132
2 changed files with 28 additions and 0 deletions
|
|
@ -1866,6 +1866,33 @@ nm_utils_new_vlan_name (const char *parent_iface, guint32 vlan_id)
|
|||
return ifname;
|
||||
}
|
||||
|
||||
/* nm_utils_new_infiniband_name:
|
||||
* @name: the output-buffer where the value will be written. Must be
|
||||
* not %NULL and point to a string buffer of at least IFNAMSIZ bytes.
|
||||
* @parent_name: the parent interface name
|
||||
* @p_key: the partition key.
|
||||
*
|
||||
* Returns: the infiniband name will be written to @name and @name
|
||||
* is returned.
|
||||
*/
|
||||
const char *
|
||||
nm_utils_new_infiniband_name (char *name, const char *parent_name, int p_key)
|
||||
{
|
||||
g_return_val_if_fail (name, NULL);
|
||||
g_return_val_if_fail (parent_name && parent_name[0], NULL);
|
||||
g_return_val_if_fail (strlen (parent_name) < IFNAMSIZ, NULL);
|
||||
|
||||
/* technically, p_key of 0x0000 and 0x8000 is not allowed either. But we don't
|
||||
* want to assert against that in nm_utils_new_infiniband_name(). So be more
|
||||
* resilient here, and accept those. */
|
||||
g_return_val_if_fail (p_key >= 0 && p_key <= 0xffff, NULL);
|
||||
|
||||
/* If parent+suffix is too long, kernel would just truncate
|
||||
* the name. We do the same. See ipoib_vlan_add(). */
|
||||
g_snprintf (name, IFNAMSIZ, "%s.%04x", parent_name, p_key);
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_read_resolv_conf_nameservers():
|
||||
* @rc_contents: contents of a resolv.conf; or %NULL to read /etc/resolv.conf
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ const char *nm_utils_get_ip_config_method (NMConnection *connection,
|
|||
GType ip_setting_type);
|
||||
|
||||
char *nm_utils_new_vlan_name (const char *parent_iface, guint32 vlan_id);
|
||||
const char *nm_utils_new_infiniband_name (char *name, const char *parent_name, int p_key);
|
||||
|
||||
GPtrArray *nm_utils_read_resolv_conf_nameservers (const char *rc_contents);
|
||||
GPtrArray *nm_utils_read_resolv_conf_dns_options (const char *rc_contents);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue