shared: add ether_addr field of type NMEtherAddr to NMIPAddr union

This commit is contained in:
Thomas Haller
2020-10-01 13:27:07 +02:00
parent 77ad359442
commit c36eedf4d8
4 changed files with 9 additions and 6 deletions

View File

@@ -122,7 +122,8 @@ typedef struct {
/* NMIPAddr is really a union for IP addresses.
* However, as ethernet addresses fit in here nicely, use
* it also for an ethernet MAC address. */
guint8 addr_eth[6 /*ETH_ALEN*/];
guint8 ether_addr_octet[6 /*ETH_ALEN*/];
NMEtherAddr ether_addr;
guint8 array[sizeof(struct in6_addr)];
};
@@ -135,6 +136,8 @@ typedef struct {
extern const NMIPAddr nm_ip_addr_zero;
#define nm_ether_addr_zero (nm_ip_addr_zero.ether_addr)
static inline int
nm_ip_addr_cmp(int addr_family, gconstpointer a, gconstpointer b)
{

View File

@@ -760,7 +760,7 @@ bridge_set_vlan_options(NMDevice *device, NMSettingBridge *s_bridge)
hwaddr = nm_platform_link_get_address(plat, ifindex, &length);
g_return_val_if_fail(length == ETH_ALEN, FALSE);
if (nm_utils_hwaddr_matches(hwaddr, ETH_ALEN, nm_ip_addr_zero.addr_eth, ETH_ALEN)) {
if (nm_utils_hwaddr_matches(hwaddr, length, &nm_ether_addr_zero, ETH_ALEN)) {
/* We need a non-zero MAC address to set the default pvid.
* Retry later. */
return TRUE;

View File

@@ -16808,8 +16808,8 @@ nm_device_update_hw_address(NMDevice *self)
if (priv->type == NM_DEVICE_TYPE_ETHERNET && hwaddr
&& nm_utils_hwaddr_matches(hwaddr,
hwaddrlen,
nm_ip_addr_zero.addr_eth,
sizeof(nm_ip_addr_zero.addr_eth)))
&nm_ether_addr_zero,
sizeof(nm_ether_addr_zero)))
hwaddrlen = 0;
if (!hwaddrlen)

View File

@@ -658,7 +658,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self,
v_v = nm_g_variant_lookup_value(properties, "BSSID", G_VARIANT_TYPE_BYTESTRING);
if (v_v) {
arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1);
if (arr_len == ETH_ALEN && memcmp(arr_data, nm_ip_addr_zero.addr_eth, ETH_ALEN) != 0
if (arr_len == ETH_ALEN && memcmp(arr_data, &nm_ether_addr_zero, ETH_ALEN) != 0
&& memcmp(arr_data, (char[ETH_ALEN]){0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, ETH_ALEN)
!= 0) {
/* pass */
@@ -881,7 +881,7 @@ _peer_info_properties_changed(NMSupplicantInterface *self,
v_v = nm_g_variant_lookup_value(properties, "DeviceAddress", G_VARIANT_TYPE_BYTESTRING);
if (v_v) {
arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1);
if (arr_len == ETH_ALEN && memcmp(arr_data, nm_ip_addr_zero.addr_eth, ETH_ALEN) != 0
if (arr_len == ETH_ALEN && memcmp(arr_data, &nm_ether_addr_zero, ETH_ALEN) != 0
&& memcmp(arr_data, (char[ETH_ALEN]){0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, ETH_ALEN)
!= 0) {
/* pass */