mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 04:18:07 +02:00
core: add nm_device_get_permanent_hw_address_full() function
This is a partial cherry-pick from commit 5912b2f9a1.
This commit is contained in:
parent
977fbf7089
commit
b071c91eef
2 changed files with 26 additions and 8 deletions
|
|
@ -11609,8 +11609,10 @@ nm_device_update_permanent_hw_address (NMDevice *self)
|
||||||
|
|
||||||
success_read = nm_platform_link_get_permanent_address (NM_PLATFORM_GET, priv->ifindex, buf, &len);
|
success_read = nm_platform_link_get_permanent_address (NM_PLATFORM_GET, priv->ifindex, buf, &len);
|
||||||
if (!success_read || len != priv->hw_addr_len) {
|
if (!success_read || len != priv->hw_addr_len) {
|
||||||
/* Fall back to current address. We use the fake address and keep it
|
priv->hw_addr_perm_fake = TRUE;
|
||||||
* until the device unrealizes.
|
|
||||||
|
/* we failed to read a permanent MAC address, thus we use a fake address,
|
||||||
|
* that is the current MAC address of the device.
|
||||||
*
|
*
|
||||||
* In some cases it might be necessary to know whether this is a "real" or
|
* In some cases it might be necessary to know whether this is a "real" or
|
||||||
* a temporary address (fake). */
|
* a temporary address (fake). */
|
||||||
|
|
@ -11619,14 +11621,16 @@ nm_device_update_permanent_hw_address (NMDevice *self)
|
||||||
? "read HW addr length of permanent MAC address differs"
|
? "read HW addr length of permanent MAC address differs"
|
||||||
: "unable to read permanent MAC address",
|
: "unable to read permanent MAC address",
|
||||||
priv->hw_addr);
|
priv->hw_addr);
|
||||||
priv->hw_addr_perm_fake = TRUE;
|
|
||||||
priv->hw_addr_perm = g_strdup (priv->hw_addr);
|
priv->hw_addr_perm = g_strdup (priv->hw_addr);
|
||||||
} else {
|
goto out;
|
||||||
priv->hw_addr_perm_fake = FALSE;
|
|
||||||
priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, len);
|
|
||||||
_LOGD (LOGD_DEVICE, "hw-addr: read permanent MAC address '%s'",
|
|
||||||
priv->hw_addr_perm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->hw_addr_perm_fake = FALSE;
|
||||||
|
priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, len);
|
||||||
|
_LOGD (LOGD_DEVICE, "hw-addr: read permanent MAC address '%s'",
|
||||||
|
priv->hw_addr_perm);
|
||||||
|
|
||||||
|
out:
|
||||||
_notify (self, PROP_PERM_HW_ADDRESS);
|
_notify (self, PROP_PERM_HW_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11962,6 +11966,18 @@ nm_device_hw_addr_reset (NMDevice *self, const char *detail)
|
||||||
return _hw_addr_set (self, addr, "reset", detail);
|
return _hw_addr_set (self, addr, "reset", detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_device_get_permanent_hw_address_full (NMDevice *self, gboolean *out_is_fake)
|
||||||
|
{
|
||||||
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
NM_SET_OUT (out_is_fake, priv->hw_addr_perm && priv->hw_addr_perm_fake);
|
||||||
|
return priv->hw_addr_perm;
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
nm_device_get_permanent_hw_address (NMDevice *self, gboolean fallback_fake)
|
nm_device_get_permanent_hw_address (NMDevice *self, gboolean fallback_fake)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,8 @@ guint32 nm_device_get_ip6_route_metric (NMDevice *dev);
|
||||||
const char * nm_device_get_hw_address (NMDevice *dev);
|
const char * nm_device_get_hw_address (NMDevice *dev);
|
||||||
const char * nm_device_get_permanent_hw_address (NMDevice *dev,
|
const char * nm_device_get_permanent_hw_address (NMDevice *dev,
|
||||||
gboolean fallback_fake);
|
gboolean fallback_fake);
|
||||||
|
const char * nm_device_get_permanent_hw_address_full (NMDevice *self,
|
||||||
|
gboolean *out_is_fake);
|
||||||
const char * nm_device_get_initial_hw_address (NMDevice *dev);
|
const char * nm_device_get_initial_hw_address (NMDevice *dev);
|
||||||
|
|
||||||
NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev);
|
NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue