mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 17:10:21 +01:00
core: use nm_utils_parse_inaddr_prefix_bin() in nm_utils_ip_route_attribute_to_platform()
We already have an implementation for parsing an address/plen string. Use it.
This commit is contained in:
parent
4127c88ad2
commit
5c273efb36
1 changed files with 9 additions and 12 deletions
|
|
@ -1349,20 +1349,17 @@ nm_utils_ip_route_attribute_to_platform (int addr_family,
|
|||
if ( addr_family == AF_INET6
|
||||
&& (variant = nm_ip_route_get_attribute (s_route, NM_IP_ROUTE_ATTRIBUTE_FROM))
|
||||
&& g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)) {
|
||||
gs_free char *string = NULL;
|
||||
guint8 plen = 128;
|
||||
char *sep;
|
||||
int prefix;
|
||||
|
||||
string = g_variant_dup_string (variant, NULL);
|
||||
sep = strchr (string, '/');
|
||||
if (sep) {
|
||||
*sep = 0;
|
||||
plen = _nm_utils_ascii_str_to_int64 (sep + 1, 10, 1, 128, 255);
|
||||
}
|
||||
if ( plen <= 128
|
||||
&& inet_pton (AF_INET6, string, &addr) == 1) {
|
||||
if (nm_utils_parse_inaddr_prefix_bin (addr_family,
|
||||
g_variant_get_string (variant, NULL),
|
||||
NULL,
|
||||
&addr,
|
||||
&prefix)) {
|
||||
if (prefix < 0)
|
||||
prefix = 128;
|
||||
r6->src = addr.addr6;
|
||||
r6->src_plen = plen;
|
||||
r6->src_plen = prefix;
|
||||
}
|
||||
}
|
||||
#undef GET_ATTR
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue