mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 06:28:05 +02:00
libnm-core: add MAC address handling to _property_direct_set_strv function
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1803
This commit is contained in:
parent
641e717797
commit
66887fafef
2 changed files with 27 additions and 2 deletions
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "nm-setting.h"
|
||||
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "libnm-glib-aux/nm-ref-string.h"
|
||||
#include "libnm-glib-aux/nm-secret-utils.h"
|
||||
|
|
@ -739,10 +741,29 @@ _property_direct_set_strv(const NMSettInfoSetting *sett_info,
|
|||
if (!property_info->direct_strv_preserve_empty && strv && !strv[0])
|
||||
strv = NULL;
|
||||
|
||||
if (nm_strvarray_equal_strv(p_val->arr, strv, -1))
|
||||
return FALSE;
|
||||
if (property_info->direct_set_strv_normalize_hwaddr) {
|
||||
gs_unref_array GArray *arr = NULL;
|
||||
if (strv) {
|
||||
nm_strvarray_ensure(&arr);
|
||||
|
||||
for (; strv[0]; strv++) {
|
||||
nm_strvarray_add_take(arr,
|
||||
_nm_utils_hwaddr_canonical_or_invalid(strv[0], ETH_ALEN));
|
||||
}
|
||||
}
|
||||
|
||||
if (nm_strvarray_equal(p_val->arr, arr))
|
||||
return FALSE;
|
||||
|
||||
NM_SWAP(&p_val->arr, &arr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (nm_strvarray_equal_strv(p_val->arr, strv, -1)) {
|
||||
return FALSE;
|
||||
}
|
||||
nm_strvarray_set_strv_full(&p_val->arr, strv, property_info->direct_strv_preserve_empty);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -815,6 +815,10 @@ struct _NMSettInfoProperty {
|
|||
* normalize the string via g_ascii_strdown(). */
|
||||
bool direct_set_string_ascii_strdown : 1;
|
||||
|
||||
/* If TRUE, this is a NM_VALUE_TYPE_STRV direct property holding MAC addresses,
|
||||
* and the setter will normalize them via _nm_utils_hwaddr_canonical_or_invalid(). */
|
||||
bool direct_set_strv_normalize_hwaddr : 1;
|
||||
|
||||
/* If TRUE, this is a NM_VALUE_TYPE_STRING direct property, and the setter will
|
||||
* normalize the string via g_strstrip(). */
|
||||
bool direct_set_string_strip : 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue