mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 11:40:08 +01:00
all/trivial: rename hexstr<>bin conversion functions
"bin2str" and "str2bin" are not very clear. These strings are
hex-strings. Rename.
(cherry picked from commit 6714440669)
This commit is contained in:
parent
68d1f1cee8
commit
cc93cf46ad
5 changed files with 32 additions and 32 deletions
|
|
@ -219,15 +219,15 @@ guint nm_setting_ethtool_init_features (NMSettingEthtool *setting,
|
|||
guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_length, gsize *out_length);
|
||||
const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len);
|
||||
|
||||
char *_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case);
|
||||
void _nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
|
||||
char *_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case);
|
||||
void _nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
|
||||
|
||||
guint8 *_nm_utils_str2bin_full (const char *asc,
|
||||
gboolean delimiter_required,
|
||||
const char *delimiter_candidates,
|
||||
guint8 *buffer,
|
||||
gsize buffer_length,
|
||||
gsize *out_len);
|
||||
guint8 *_nm_utils_hexstr2bin_full (const char *asc,
|
||||
gboolean delimiter_required,
|
||||
const char *delimiter_candidates,
|
||||
guint8 *buffer,
|
||||
gsize buffer_length,
|
||||
gsize *out_len);
|
||||
|
||||
GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
|
||||
|
||||
|
|
|
|||
|
|
@ -3613,12 +3613,12 @@ nm_utils_hwaddr_len (int type)
|
|||
}
|
||||
|
||||
guint8 *
|
||||
_nm_utils_str2bin_full (const char *asc,
|
||||
gboolean delimiter_required,
|
||||
const char *delimiter_candidates,
|
||||
guint8 *buffer,
|
||||
gsize buffer_length,
|
||||
gsize *out_len)
|
||||
_nm_utils_hexstr2bin_full (const char *asc,
|
||||
gboolean delimiter_required,
|
||||
const char *delimiter_candidates,
|
||||
guint8 *buffer,
|
||||
gsize buffer_length,
|
||||
gsize *out_len)
|
||||
{
|
||||
const char *in = asc;
|
||||
guint8 *out = buffer;
|
||||
|
|
@ -3688,7 +3688,7 @@ _nm_utils_str2bin_full (const char *asc,
|
|||
return buffer;
|
||||
}
|
||||
|
||||
#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_str2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
|
||||
#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_hexstr2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
|
||||
|
||||
/**
|
||||
* nm_utils_hexstr2bin:
|
||||
|
|
@ -3714,7 +3714,7 @@ nm_utils_hexstr2bin (const char *hex)
|
|||
|
||||
buffer_length = strlen (hex) / 2 + 3;
|
||||
buffer = g_malloc (buffer_length);
|
||||
if (!_nm_utils_str2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
|
||||
if (!_nm_utils_hexstr2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
|
||||
g_free (buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -3815,7 +3815,7 @@ nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize length)
|
|||
}
|
||||
|
||||
void
|
||||
_nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
|
||||
_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
|
||||
{
|
||||
const guint8 *in = addr;
|
||||
const char *LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
|
|
@ -3865,7 +3865,7 @@ nm_utils_bin2hexstr (gconstpointer src, gsize len, int final_len)
|
|||
g_return_val_if_fail (final_len < 0 || (gsize) final_len < buflen, NULL);
|
||||
|
||||
result = g_malloc (buflen);
|
||||
_nm_utils_bin2str_full (src, len, '\0', FALSE, result);
|
||||
_nm_utils_bin2hexstr_full (src, len, '\0', FALSE, result);
|
||||
|
||||
/* Cut converted key off at the correct length for this cipher type */
|
||||
if (final_len >= 0 && (gsize) final_len < buflen)
|
||||
|
|
@ -3892,7 +3892,7 @@ nm_utils_hwaddr_ntoa (gconstpointer addr, gsize length)
|
|||
g_return_val_if_fail (length > 0, g_strdup (""));
|
||||
|
||||
result = g_malloc (length * 3);
|
||||
_nm_utils_bin2str_full (addr, length, ':', TRUE, result);
|
||||
_nm_utils_bin2hexstr_full (addr, length, ':', TRUE, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -3905,12 +3905,12 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
|
|||
if (buf_len < addr_len * 3)
|
||||
g_return_val_if_reached (NULL);
|
||||
|
||||
_nm_utils_bin2str_full (addr, addr_len, ':', upper_case, buf);
|
||||
_nm_utils_bin2hexstr_full (addr, addr_len, ':', upper_case, buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* _nm_utils_bin2str:
|
||||
* _nm_utils_bin2hexstr:
|
||||
* @addr: (type guint8) (array length=length): a binary hardware address
|
||||
* @length: the length of @addr
|
||||
* @upper_case: the case for the hexadecimal digits.
|
||||
|
|
@ -3920,7 +3920,7 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
|
|||
* Return value: (transfer full): the textual form of @addr
|
||||
*/
|
||||
char *
|
||||
_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case)
|
||||
_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case)
|
||||
{
|
||||
char *result;
|
||||
|
||||
|
|
@ -3928,7 +3928,7 @@ _nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case)
|
|||
g_return_val_if_fail (length > 0, g_strdup (""));
|
||||
|
||||
result = g_malloc (length * 3);
|
||||
_nm_utils_bin2str_full (addr, length, ':', upper_case, result);
|
||||
_nm_utils_bin2hexstr_full (addr, length, ':', upper_case, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -4596,7 +4596,7 @@ _nm_utils_dhcp_duid_valid (const char *duid, GBytes **out_duid_bin)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (_nm_utils_str2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
|
||||
if (_nm_utils_hexstr2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
|
||||
/* MAX DUID length is 128 octects + the type code (2 octects). */
|
||||
if ( duid_len > 2
|
||||
&& duid_len <= (128 + 2)) {
|
||||
|
|
|
|||
|
|
@ -14384,9 +14384,9 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
if (client_id) {
|
||||
g_ptr_array_add (argv, g_strdup ("--dhcp4-clientid"));
|
||||
g_ptr_array_add (argv,
|
||||
_nm_utils_bin2str (g_bytes_get_data (client_id, NULL),
|
||||
g_bytes_get_size (client_id),
|
||||
FALSE));
|
||||
_nm_utils_bin2hexstr (g_bytes_get_data (client_id, NULL),
|
||||
g_bytes_get_size (client_id),
|
||||
FALSE));
|
||||
}
|
||||
|
||||
hostname = nm_dhcp_client_get_hostname (priv->dhcp4.client);
|
||||
|
|
@ -14424,9 +14424,9 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) {
|
||||
g_ptr_array_add (argv, g_strdup ("--iid"));
|
||||
g_ptr_array_add (argv,
|
||||
_nm_utils_bin2str (iid.id_u8,
|
||||
sizeof (NMUtilsIPv6IfaceId),
|
||||
FALSE));
|
||||
_nm_utils_bin2hexstr (iid.id_u8,
|
||||
sizeof (NMUtilsIPv6IfaceId),
|
||||
FALSE));
|
||||
}
|
||||
|
||||
g_ptr_array_add (argv, g_strdup ("--addr-gen-mode"));
|
||||
|
|
|
|||
|
|
@ -729,7 +729,7 @@ nm_dhcp_utils_duid_to_string (GBytes *duid)
|
|||
g_return_val_if_fail (duid != NULL, NULL);
|
||||
|
||||
data = g_bytes_get_data (duid, &len);
|
||||
return _nm_utils_bin2str (data, len, FALSE);
|
||||
return _nm_utils_bin2hexstr (data, len, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ _secret_password_raw_to_bytes (const char *ifcfg_key,
|
|||
password_raw += 2;
|
||||
|
||||
secret = nm_secret_buf_new (strlen (password_raw) / 2 + 3);
|
||||
if (!_nm_utils_str2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
|
||||
if (!_nm_utils_hexstr2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"Invalid hex password in %s",
|
||||
ifcfg_key);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue