mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 00:10:15 +01:00
core: reuse _nm_utils_iaid_verify() for parsing
There should be one function for parsing the string. Use it everywhere. Also, because we will accept specifying the IAID as hex string so the same parsing code should be used everywhere. (cherry picked from commit69106d0aef) (cherry picked from commit99825e727b)
This commit is contained in:
parent
68da283941
commit
5dcfb89a48
1 changed files with 12 additions and 4 deletions
|
|
@ -1804,6 +1804,7 @@ _prop_get_ipvx_dhcp_iaid(NMDevice *self,
|
|||
const char *iface;
|
||||
const char *fail_reason;
|
||||
gboolean is_explicit = TRUE;
|
||||
gint64 i64;
|
||||
|
||||
s_ip = nm_connection_get_setting_ip_config(connection, addr_family);
|
||||
iaid_str = nm_setting_ip_config_get_dhcp_iaid(s_ip);
|
||||
|
|
@ -1862,7 +1863,7 @@ _prop_get_ipvx_dhcp_iaid(NMDevice *self,
|
|||
|
||||
iaid = unaligned_read_be32(&hwaddr_buf[hwaddr_len - 4]);
|
||||
goto out_good;
|
||||
} else if (nm_streq(iaid_str, "stable")) {
|
||||
} else if (nm_streq(iaid_str, NM_IAID_STABLE)) {
|
||||
nm_auto_free_checksum GChecksum *sum = NULL;
|
||||
guint8 digest[NM_UTILS_CHECKSUM_LENGTH_SHA1];
|
||||
NMUtilsStableType stable_type;
|
||||
|
|
@ -1885,14 +1886,21 @@ _prop_get_ipvx_dhcp_iaid(NMDevice *self,
|
|||
|
||||
iaid = unaligned_read_be32(digest);
|
||||
goto out_good;
|
||||
} else if ((iaid = _nm_utils_ascii_str_to_int64(iaid_str, 10, 0, G_MAXUINT32, -1)) != -1) {
|
||||
goto out_good;
|
||||
} else {
|
||||
} else if (nm_streq(iaid_str, NM_IAID_IFNAME)) {
|
||||
iface = nm_device_get_ip_iface(self);
|
||||
iaid = nm_utils_create_dhcp_iaid(TRUE, (const guint8 *) iface, strlen(iface));
|
||||
goto out_good;
|
||||
} else if (_nm_utils_iaid_verify(iaid_str, &i64)) {
|
||||
if (i64 < 0) {
|
||||
fail_reason = nm_assert_unreachable_val("bug handling iaid value");
|
||||
goto out_fail;
|
||||
}
|
||||
nm_assert(i64 <= G_MAXUINT32);
|
||||
iaid = (guint32) i64;
|
||||
goto out_good;
|
||||
}
|
||||
|
||||
fail_reason = nm_assert_unreachable_val("bug handling iaid code");
|
||||
out_fail:
|
||||
nm_assert(fail_reason);
|
||||
if (!log_silent) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue