mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 19:20:12 +01:00
glib-aux: rename IP address related helpers from "nm-inet-utils.h"
- name things related to `in_addr_t`, `struct in6_addr`, `NMIPAddr` as
`nm_ip4_addr_*()`, `nm_ip6_addr_*()`, `nm_ip_addr_*()`, respectively.
- we have a wrapper `nm_inet_ntop()` for `inet_ntop()`. This name
of our wrapper is chosen to be familiar with the libc underlying
function. With this, also name functions that are about string
representations of addresses `nm_inet_*()`, `nm_inet4_*()`,
`nm_inet6_*()`. For example, `nm_inet_parse_str()`,
`nm_inet_is_normalized()`.
<<<<
R() {
git grep -l "$1" | xargs sed -i "s/\<$1\>/$2/g"
}
R NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX
R NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX
R NM_UTILS_INET_ADDRSTRLEN NM_INET_ADDRSTRLEN
R _nm_utils_inet4_ntop nm_inet4_ntop
R _nm_utils_inet6_ntop nm_inet6_ntop
R _nm_utils_ip4_get_default_prefix nm_ip4_addr_get_default_prefix
R _nm_utils_ip4_get_default_prefix0 nm_ip4_addr_get_default_prefix0
R _nm_utils_ip4_netmask_to_prefix nm_ip4_addr_netmask_to_prefix
R _nm_utils_ip4_prefix_to_netmask nm_ip4_addr_netmask_from_prefix
R nm_utils_inet4_ntop_dup nm_inet4_ntop_dup
R nm_utils_inet6_ntop_dup nm_inet6_ntop_dup
R nm_utils_inet_ntop nm_inet_ntop
R nm_utils_inet_ntop_dup nm_inet_ntop_dup
R nm_utils_ip4_address_clear_host_address nm_ip4_addr_clear_host_address
R nm_utils_ip4_address_is_link_local nm_ip4_addr_is_link_local
R nm_utils_ip4_address_is_loopback nm_ip4_addr_is_loopback
R nm_utils_ip4_address_is_zeronet nm_ip4_addr_is_zeronet
R nm_utils_ip4_address_same_prefix nm_ip4_addr_same_prefix
R nm_utils_ip4_address_same_prefix_cmp nm_ip4_addr_same_prefix_cmp
R nm_utils_ip6_address_clear_host_address nm_ip6_addr_clear_host_address
R nm_utils_ip6_address_same_prefix nm_ip6_addr_same_prefix
R nm_utils_ip6_address_same_prefix_cmp nm_ip6_addr_same_prefix_cmp
R nm_utils_ip6_is_ula nm_ip6_addr_is_ula
R nm_utils_ip_address_same_prefix nm_ip_addr_same_prefix
R nm_utils_ip_address_same_prefix_cmp nm_ip_addr_same_prefix_cmp
R nm_utils_ip_is_site_local nm_ip_addr_is_site_local
R nm_utils_ipaddr_is_normalized nm_inet_is_normalized
R nm_utils_ipaddr_is_valid nm_inet_is_valid
R nm_utils_ipx_address_clear_host_address nm_ip_addr_clear_host_address
R nm_utils_parse_inaddr nm_inet_parse_str
R nm_utils_parse_inaddr_bin nm_inet_parse_bin
R nm_utils_parse_inaddr_bin_full nm_inet_parse_bin_full
R nm_utils_parse_inaddr_prefix nm_inet_parse_with_prefix_str
R nm_utils_parse_inaddr_prefix_bin nm_inet_parse_with_prefix_bin
R test_nm_utils_ip6_address_same_prefix test_nm_ip_addr_same_prefix
./contrib/scripts/nm-code-format.sh -F
This commit is contained in:
parent
d65feb26e5
commit
08eff4c46e
83 changed files with 812 additions and 882 deletions
|
|
@ -419,8 +419,8 @@ route_compare(NMIPRoute *route1, NMIPRoute *route2, gint64 default_metric)
|
|||
nm_assert_not_reached();
|
||||
if (!inet_pton(family, nm_ip_route_get_dest(route2), &a2))
|
||||
nm_assert_not_reached();
|
||||
nm_utils_ipx_address_clear_host_address(family, &a1, NULL, plen);
|
||||
nm_utils_ipx_address_clear_host_address(family, &a2, NULL, plen);
|
||||
nm_ip_addr_clear_host_address(family, &a1, NULL, plen);
|
||||
nm_ip_addr_clear_host_address(family, &a2, NULL, plen);
|
||||
NM_CMP_DIRECT_MEMCMP(&a1, &a2, nm_utils_addr_family_to_size(family));
|
||||
|
||||
return 0;
|
||||
|
|
@ -1417,11 +1417,11 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
|
|||
&& g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
|
||||
int prefix;
|
||||
|
||||
if (nm_utils_parse_inaddr_prefix_bin(addr_family,
|
||||
g_variant_get_string(variant, NULL),
|
||||
NULL,
|
||||
&addr,
|
||||
&prefix)) {
|
||||
if (nm_inet_parse_with_prefix_bin(addr_family,
|
||||
g_variant_get_string(variant, NULL),
|
||||
NULL,
|
||||
&addr,
|
||||
&prefix)) {
|
||||
if (prefix < 0)
|
||||
prefix = 128;
|
||||
r6->src = addr.addr6;
|
||||
|
|
@ -1443,7 +1443,7 @@ nm_utils_ip_addresses_to_dbus(int addr_family,
|
|||
const int IS_IPv4 = NM_IS_IPv4(addr_family);
|
||||
GVariantBuilder builder_data;
|
||||
GVariantBuilder builder_legacy;
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
NMDedupMultiIter iter;
|
||||
const NMPObject *obj;
|
||||
guint i;
|
||||
|
|
@ -1478,8 +1478,7 @@ nm_utils_ip_addresses_to_dbus(int addr_family,
|
|||
&addr_builder,
|
||||
"{sv}",
|
||||
"address",
|
||||
g_variant_new_string(
|
||||
nm_utils_inet_ntop(addr_family, address->ax.address_ptr, addr_str)));
|
||||
g_variant_new_string(nm_inet_ntop(addr_family, address->ax.address_ptr, addr_str)));
|
||||
|
||||
g_variant_builder_add(&addr_builder,
|
||||
"{sv}",
|
||||
|
|
@ -1496,11 +1495,10 @@ nm_utils_ip_addresses_to_dbus(int addr_family,
|
|||
p = &address->a6.peer_address;
|
||||
}
|
||||
if (p) {
|
||||
g_variant_builder_add(
|
||||
&addr_builder,
|
||||
"{sv}",
|
||||
"peer",
|
||||
g_variant_new_string(nm_utils_inet_ntop(addr_family, p, addr_str)));
|
||||
g_variant_builder_add(&addr_builder,
|
||||
"{sv}",
|
||||
"peer",
|
||||
g_variant_new_string(nm_inet_ntop(addr_family, p, addr_str)));
|
||||
}
|
||||
|
||||
if (IS_IPv4) {
|
||||
|
|
@ -1558,7 +1556,7 @@ nm_utils_ip_routes_to_dbus(int addr_family,
|
|||
const NMPObject *obj;
|
||||
GVariantBuilder builder_data;
|
||||
GVariantBuilder builder_legacy;
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_assert_addr_family(addr_family);
|
||||
|
||||
|
|
@ -1579,14 +1577,12 @@ nm_utils_ip_routes_to_dbus(int addr_family,
|
|||
nm_assert(r);
|
||||
nm_assert(r->rx.plen <= 8u * nm_utils_addr_family_to_size(addr_family));
|
||||
nm_assert(!IS_IPv4
|
||||
|| r->r4.network
|
||||
== nm_utils_ip4_address_clear_host_address(r->r4.network, r->r4.plen));
|
||||
nm_assert(
|
||||
IS_IPv4
|
||||
|| (memcmp(&r->r6.network,
|
||||
nm_utils_ip6_address_clear_host_address(&n, &r->r6.network, r->r6.plen),
|
||||
sizeof(n))
|
||||
== 0));
|
||||
|| r->r4.network == nm_ip4_addr_clear_host_address(r->r4.network, r->r4.plen));
|
||||
nm_assert(IS_IPv4
|
||||
|| (memcmp(&r->r6.network,
|
||||
nm_ip6_addr_clear_host_address(&n, &r->r6.network, r->r6.plen),
|
||||
sizeof(n))
|
||||
== 0));
|
||||
|
||||
if (r->rx.type_coerced != nm_platform_route_type_coerce(RTN_UNICAST))
|
||||
continue;
|
||||
|
|
@ -1601,7 +1597,7 @@ nm_utils_ip_routes_to_dbus(int addr_family,
|
|||
&route_builder,
|
||||
"{sv}",
|
||||
"dest",
|
||||
g_variant_new_string(nm_utils_inet_ntop(addr_family, r->rx.network_ptr, addr_str)));
|
||||
g_variant_new_string(nm_inet_ntop(addr_family, r->rx.network_ptr, addr_str)));
|
||||
|
||||
g_variant_builder_add(&route_builder,
|
||||
"{sv}",
|
||||
|
|
@ -1614,7 +1610,7 @@ nm_utils_ip_routes_to_dbus(int addr_family,
|
|||
&route_builder,
|
||||
"{sv}",
|
||||
"next-hop",
|
||||
g_variant_new_string(nm_utils_inet_ntop(addr_family, gateway, addr_str)));
|
||||
g_variant_new_string(nm_inet_ntop(addr_family, gateway, addr_str)));
|
||||
}
|
||||
|
||||
g_variant_builder_add(&route_builder,
|
||||
|
|
@ -1679,7 +1675,7 @@ nm_utils_platform_capture_ip_setting(NMPlatform *platform,
|
|||
NMDedupMultiIter iter;
|
||||
const NMPObject *obj;
|
||||
const char *method = NULL;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
const NMPlatformIPXRoute *best_default_route = NULL;
|
||||
|
||||
s_ip =
|
||||
|
|
@ -1781,13 +1777,13 @@ nm_utils_platform_capture_ip_setting(NMPlatform *platform,
|
|||
}
|
||||
|
||||
if (best_default_route && nm_setting_ip_config_get_num_addresses(s_ip) > 0) {
|
||||
g_object_set(s_ip,
|
||||
NM_SETTING_IP_CONFIG_GATEWAY,
|
||||
nm_utils_inet_ntop(
|
||||
addr_family,
|
||||
g_object_set(
|
||||
s_ip,
|
||||
NM_SETTING_IP_CONFIG_GATEWAY,
|
||||
nm_inet_ntop(addr_family,
|
||||
nm_platform_ip_route_get_gateway(addr_family, &best_default_route->rx),
|
||||
sbuf),
|
||||
NULL);
|
||||
NULL);
|
||||
}
|
||||
|
||||
return NM_SETTING(g_steal_pointer(&s_ip));
|
||||
|
|
|
|||
|
|
@ -274,10 +274,10 @@ set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new
|
|||
in_addr_t a4;
|
||||
|
||||
s = new_strv[i];
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &a4)) {
|
||||
if (nm_inet_parse_bin(AF_INET, s, NULL, &a4)) {
|
||||
char sbuf[INET_ADDRSTRLEN];
|
||||
|
||||
_nm_utils_inet4_ntop(a4, sbuf);
|
||||
nm_inet4_ntop(a4, sbuf);
|
||||
if (!nm_streq(s, sbuf)) {
|
||||
if (!free_list)
|
||||
free_list = g_ptr_array_new_with_free_func(g_free);
|
||||
|
|
@ -368,7 +368,7 @@ _bond_arp_ip_target_to_platform(const char *value, in_addr_t out[static NM_BOND_
|
|||
for (i = 0; ip[i]; i++) {
|
||||
if (added > NM_BOND_MAX_ARP_TARGETS - 1)
|
||||
break;
|
||||
if (!nm_utils_parse_inaddr_bin(AF_INET, ip[i], NULL, &in_a))
|
||||
if (!nm_inet_parse_bin(AF_INET, ip[i], NULL, &in_a))
|
||||
nm_assert_not_reached(); /* verify() already validated the IP addresses */
|
||||
|
||||
out[added++] = in_a;
|
||||
|
|
|
|||
|
|
@ -107,12 +107,12 @@ address_equal_pp(int addr_family, const char *a, const char *b)
|
|||
nm_assert_addr_family(addr_family);
|
||||
|
||||
if (a) {
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, a, NULL, &addr_a_val))
|
||||
if (!nm_inet_parse_bin(addr_family, a, NULL, &addr_a_val))
|
||||
nm_assert_not_reached();
|
||||
addr_a = &addr_a_val;
|
||||
}
|
||||
if (b) {
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, b, NULL, &addr_b_val))
|
||||
if (!nm_inet_parse_bin(addr_family, b, NULL, &addr_b_val))
|
||||
nm_assert_not_reached();
|
||||
addr_b = &addr_b_val;
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ address_set(int addr_family, char **p_addr, const NMIPAddr *addr_new)
|
|||
{
|
||||
nm_assert_addr_family(addr_family);
|
||||
nm_assert(p_addr);
|
||||
nm_assert(!*p_addr || nm_utils_ipaddr_is_normalized(addr_family, *p_addr));
|
||||
nm_assert(!*p_addr || nm_inet_is_normalized(addr_family, *p_addr));
|
||||
|
||||
if (!addr_new || nm_ip_addr_is_null(addr_family, addr_new)) {
|
||||
if (nm_clear_g_free(p_addr))
|
||||
|
|
@ -136,7 +136,7 @@ address_set(int addr_family, char **p_addr, const NMIPAddr *addr_new)
|
|||
if (*p_addr) {
|
||||
NMIPAddr addr_val;
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, *p_addr, NULL, &addr_val))
|
||||
if (!nm_inet_parse_bin(addr_family, *p_addr, NULL, &addr_val))
|
||||
nm_assert_not_reached();
|
||||
|
||||
if (nm_ip_addr_equal(addr_family, &addr_val, addr_new))
|
||||
|
|
@ -145,7 +145,7 @@ address_set(int addr_family, char **p_addr, const NMIPAddr *addr_new)
|
|||
g_free(*p_addr);
|
||||
}
|
||||
|
||||
*p_addr = nm_utils_inet_ntop_dup(addr_family, addr_new);
|
||||
*p_addr = nm_inet_ntop_dup(addr_family, addr_new);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,25 +171,25 @@ typedef struct {
|
|||
|
||||
#define _NMLOG_PREFIX_NAME "resolve-addr"
|
||||
#define _NMLOG_DOMAIN LOGD_CORE
|
||||
#define _NMLOG2(level, info, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (nm_logging_enabled((level), (_NMLOG_DOMAIN))) { \
|
||||
ResolveAddrInfo *_info = (info); \
|
||||
char _addr_str[NM_UTILS_INET_ADDRSTRLEN]; \
|
||||
\
|
||||
_nm_log((level), \
|
||||
(_NMLOG_DOMAIN), \
|
||||
0, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
_NMLOG_PREFIX_NAME "[" NM_HASH_OBFUSCATE_PTR_FMT \
|
||||
",%s]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||
NM_HASH_OBFUSCATE_PTR(_info), \
|
||||
nm_utils_inet_ntop(_info->addr_family, &_info->address, _addr_str) \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} \
|
||||
} \
|
||||
#define _NMLOG2(level, info, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (nm_logging_enabled((level), (_NMLOG_DOMAIN))) { \
|
||||
ResolveAddrInfo *_info = (info); \
|
||||
char _addr_str[NM_INET_ADDRSTRLEN]; \
|
||||
\
|
||||
_nm_log((level), \
|
||||
(_NMLOG_DOMAIN), \
|
||||
0, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
_NMLOG_PREFIX_NAME "[" NM_HASH_OBFUSCATE_PTR_FMT \
|
||||
",%s]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||
NM_HASH_OBFUSCATE_PTR(_info), \
|
||||
nm_inet_ntop(_info->addr_family, &_info->address, _addr_str) \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
static void
|
||||
|
|
@ -234,9 +234,9 @@ resolve_addr_helper_cb(GObject *source, GAsyncResult *result, gpointer user_data
|
|||
static void
|
||||
resolve_addr_spawn_helper(ResolveAddrInfo *info)
|
||||
{
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_utils_inet_ntop(info->addr_family, &info->address, addr_str);
|
||||
nm_inet_ntop(info->addr_family, &info->address, addr_str);
|
||||
_LOG2D(info, "start lookup via nm-daemon-helper");
|
||||
nm_utils_spawn_helper(NM_MAKE_STRV("resolve-address", addr_str),
|
||||
g_task_get_cancellable(info->task),
|
||||
|
|
|
|||
|
|
@ -174,15 +174,15 @@ create_and_realize(NMDevice *device,
|
|||
|
||||
str = nm_setting_vxlan_get_local(s_vxlan);
|
||||
if (str) {
|
||||
if (!nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &props.local)
|
||||
&& !nm_utils_parse_inaddr_bin(AF_INET6, str, NULL, &props.local6))
|
||||
if (!nm_inet_parse_bin(AF_INET, str, NULL, &props.local)
|
||||
&& !nm_inet_parse_bin(AF_INET6, str, NULL, &props.local6))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
str = nm_setting_vxlan_get_remote(s_vxlan);
|
||||
if (str) {
|
||||
if (!nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &props.group)
|
||||
&& !nm_utils_parse_inaddr_bin(AF_INET6, str, NULL, &props.group6))
|
||||
if (!nm_inet_parse_bin(AF_INET, str, NULL, &props.group)
|
||||
&& !nm_inet_parse_bin(AF_INET6, str, NULL, &props.group6))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ address_matches(const char *candidate, in_addr_t addr4, struct in6_addr *addr6)
|
|||
if (!candidate)
|
||||
return addr4 == 0u && IN6_IS_ADDR_UNSPECIFIED(addr6);
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin(AF_UNSPEC, candidate, &addr_family, &candidate_addr))
|
||||
if (!nm_inet_parse_bin(AF_UNSPEC, candidate, &addr_family, &candidate_addr))
|
||||
return FALSE;
|
||||
|
||||
if (!nm_ip_addr_equal(addr_family,
|
||||
|
|
@ -401,7 +401,7 @@ update_connection(NMDevice *device, NMConnection *connection)
|
|||
{
|
||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE(device);
|
||||
NMSettingVxlan *s_vxlan = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VXLAN);
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (priv->props.id != nm_setting_vxlan_get_id(s_vxlan))
|
||||
g_object_set(G_OBJECT(s_vxlan), NM_SETTING_VXLAN_ID, priv->props.id, NULL);
|
||||
|
|
@ -417,12 +417,12 @@ update_connection(NMDevice *device, NMConnection *connection)
|
|||
if (priv->props.group) {
|
||||
g_object_set(s_vxlan,
|
||||
NM_SETTING_VXLAN_REMOTE,
|
||||
_nm_utils_inet4_ntop(priv->props.group, sbuf),
|
||||
nm_inet4_ntop(priv->props.group, sbuf),
|
||||
NULL);
|
||||
} else {
|
||||
g_object_set(s_vxlan,
|
||||
NM_SETTING_VXLAN_REMOTE,
|
||||
_nm_utils_inet6_ntop(&priv->props.group6, sbuf),
|
||||
nm_inet6_ntop(&priv->props.group6, sbuf),
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -433,12 +433,12 @@ update_connection(NMDevice *device, NMConnection *connection)
|
|||
if (priv->props.local) {
|
||||
g_object_set(s_vxlan,
|
||||
NM_SETTING_VXLAN_LOCAL,
|
||||
_nm_utils_inet4_ntop(priv->props.local, sbuf),
|
||||
nm_inet4_ntop(priv->props.local, sbuf),
|
||||
NULL);
|
||||
} else if (memcmp(&priv->props.local6, &in6addr_any, sizeof(in6addr_any))) {
|
||||
g_object_set(s_vxlan,
|
||||
NM_SETTING_VXLAN_LOCAL,
|
||||
_nm_utils_inet6_ntop(&priv->props.local6, sbuf),
|
||||
nm_inet6_ntop(&priv->props.local6, sbuf),
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -510,15 +510,15 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
break;
|
||||
case PROP_GROUP:
|
||||
if (priv->props.group)
|
||||
g_value_take_string(value, nm_utils_inet4_ntop_dup(priv->props.group));
|
||||
g_value_take_string(value, nm_inet4_ntop_dup(priv->props.group));
|
||||
else if (!IN6_IS_ADDR_UNSPECIFIED(&priv->props.group6))
|
||||
g_value_take_string(value, nm_utils_inet6_ntop_dup(&priv->props.group6));
|
||||
g_value_take_string(value, nm_inet6_ntop_dup(&priv->props.group6));
|
||||
break;
|
||||
case PROP_LOCAL:
|
||||
if (priv->props.local)
|
||||
g_value_take_string(value, nm_utils_inet4_ntop_dup(priv->props.local));
|
||||
g_value_take_string(value, nm_inet4_ntop_dup(priv->props.local));
|
||||
else if (!IN6_IS_ADDR_UNSPECIFIED(&priv->props.local6))
|
||||
g_value_take_string(value, nm_utils_inet6_ntop_dup(&priv->props.local6));
|
||||
g_value_take_string(value, nm_inet6_ntop_dup(&priv->props.local6));
|
||||
break;
|
||||
case PROP_TOS:
|
||||
g_value_set_uchar(value, priv->props.tos);
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ _auto_default_route_get_enabled(NMSettingWireGuard *s_wg,
|
|||
aip = nm_wireguard_peer_get_allowed_ip(peer, j, &valid);
|
||||
if (!valid)
|
||||
continue;
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC, aip, &addr_family, NULL, &prefix))
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_UNSPEC, aip, &addr_family, NULL, &prefix))
|
||||
continue;
|
||||
if (prefix != 0)
|
||||
continue;
|
||||
|
|
@ -1152,11 +1152,11 @@ _peers_get_platform_list(NMDeviceWireGuardPrivate *priv,
|
|||
|
||||
aip = nm_wireguard_peer_get_allowed_ip(peer_data->peer, i_aip, &valid);
|
||||
if (!valid
|
||||
|| !nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC,
|
||||
aip,
|
||||
&addr_family,
|
||||
&addrbin,
|
||||
&prefix)) {
|
||||
|| !nm_inet_parse_with_prefix_bin(AF_UNSPEC,
|
||||
aip,
|
||||
&addr_family,
|
||||
&addrbin,
|
||||
&prefix)) {
|
||||
/* the address is really not expected to be invalid, because then
|
||||
* the connection would not verify. Anyway, silently skip it. */
|
||||
continue;
|
||||
|
|
@ -1701,8 +1701,7 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family)
|
|||
|
||||
aip = nm_wireguard_peer_get_allowed_ip(peer, j, &valid);
|
||||
|
||||
if (!valid
|
||||
|| !nm_utils_parse_inaddr_prefix_bin(addr_family, aip, NULL, &addrbin, &prefix))
|
||||
if (!valid || !nm_inet_parse_with_prefix_bin(addr_family, aip, NULL, &addrbin, &prefix))
|
||||
continue;
|
||||
|
||||
if (prefix < 0)
|
||||
|
|
@ -1722,7 +1721,7 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family)
|
|||
NM_L3_CONFIG_DAT_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES);
|
||||
}
|
||||
|
||||
nm_utils_ipx_address_clear_host_address(addr_family, &addrbin, NULL, prefix);
|
||||
nm_ip_addr_clear_host_address(addr_family, &addrbin, NULL, prefix);
|
||||
|
||||
rtable_coerced = route_table_coerced;
|
||||
|
||||
|
|
|
|||
|
|
@ -8561,7 +8561,7 @@ nm_device_generate_connection(NMDevice *self,
|
|||
|
||||
pllink = nm_platform_link_get(nm_device_get_platform(self), priv->ifindex);
|
||||
if (pllink && pllink->inet6_token.id) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_object_set(s_ip6,
|
||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE,
|
||||
|
|
@ -10819,7 +10819,7 @@ _dev_ipll6_set_llstate(NMDevice *self, NML3IPv6LLState llstate, const struct in6
|
|||
}
|
||||
|
||||
if (changed) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGT_ipll(AF_INET6,
|
||||
"set state %s (was %s, llstate=%s, lladdr=%s)",
|
||||
|
|
@ -10828,7 +10828,7 @@ _dev_ipll6_set_llstate(NMDevice *self, NML3IPv6LLState llstate, const struct in6
|
|||
nm_l3_ipv6ll_state_to_string(priv->ipll_data_6.v6.llstate),
|
||||
nm_ip_addr_is_null(AF_INET6, &priv->ipll_data_6.v6.lladdr)
|
||||
? "(none)"
|
||||
: _nm_utils_inet6_ntop(&priv->ipll_data_6.v6.lladdr, sbuf));
|
||||
: nm_inet6_ntop(&priv->ipll_data_6.v6.lladdr, sbuf));
|
||||
}
|
||||
|
||||
if (changed)
|
||||
|
|
@ -13847,7 +13847,7 @@ nm_device_start_ip_check(NMDevice *self)
|
|||
NMSettingConnection *s_con;
|
||||
guint timeout = 0;
|
||||
const char *ping_binary = NULL;
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
NMLogDomain log_domain = LOGD_IP4;
|
||||
|
||||
/* Shouldn't be any active ping here, since IP_CHECK happens after the
|
||||
|
|
@ -13878,14 +13878,14 @@ nm_device_start_ip_check(NMDevice *self)
|
|||
} else if (priv->ip_data_4.state == NM_DEVICE_IP_STATE_READY) {
|
||||
gw = nm_l3_config_data_get_best_default_route(l3cd, AF_INET);
|
||||
if (gw) {
|
||||
_nm_utils_inet4_ntop(NMP_OBJECT_CAST_IP4_ROUTE(gw)->gateway, buf);
|
||||
nm_inet4_ntop(NMP_OBJECT_CAST_IP4_ROUTE(gw)->gateway, buf);
|
||||
ping_binary = nm_utils_find_helper("ping", "/usr/bin/ping", NULL);
|
||||
log_domain = LOGD_IP4;
|
||||
}
|
||||
} else if (priv->ip_data_6.state == NM_DEVICE_IP_STATE_READY) {
|
||||
gw = nm_l3_config_data_get_best_default_route(l3cd, AF_INET6);
|
||||
if (gw) {
|
||||
_nm_utils_inet6_ntop(&NMP_OBJECT_CAST_IP6_ROUTE(gw)->gateway, buf);
|
||||
nm_inet6_ntop(&NMP_OBJECT_CAST_IP6_ROUTE(gw)->gateway, buf);
|
||||
ping_binary = nm_utils_find_helper("ping6", "/usr/bin/ping6", NULL);
|
||||
log_domain = LOGD_IP6;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ format_network_address(const guint8 *data, gsize sz)
|
|||
} else
|
||||
return NULL;
|
||||
|
||||
return nm_utils_inet_ntop_dup(family, &a);
|
||||
return nm_inet_ntop_dup(family, &a);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
|
|||
|
|
@ -1591,12 +1591,12 @@ ip4_config_to_iwd_config(GKeyFile *file, NMSettingIPConfig *s_ip, GError **error
|
|||
if (num) {
|
||||
NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, 0);
|
||||
guint prefix = nm_ip_address_get_prefix(addr);
|
||||
in_addr_t netmask = _nm_utils_ip4_prefix_to_netmask(prefix);
|
||||
in_addr_t netmask = nm_ip4_addr_netmask_from_prefix(prefix);
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
nm_ip_address_get_address_binary(addr, &ip);
|
||||
g_key_file_set_string(file, "IPv4", "Address", nm_ip_address_get_address(addr));
|
||||
g_key_file_set_string(file, "IPv4", "Netmask", _nm_utils_inet4_ntop(netmask, buf));
|
||||
g_key_file_set_string(file, "IPv4", "Netmask", nm_inet4_ntop(netmask, buf));
|
||||
} else {
|
||||
inet_pton(AF_INET, "10.42.0.100", &ip);
|
||||
g_key_file_set_string(file, "IPv4", "Address", "10.42.0.100");
|
||||
|
|
@ -1614,7 +1614,7 @@ ip4_config_to_iwd_config(GKeyFile *file, NMSettingIPConfig *s_ip, GError **error
|
|||
val = (ntohl(ip.s_addr) & 0xfffffff0) + 1;
|
||||
if (val == ntohl(ip.s_addr))
|
||||
val += 1;
|
||||
g_key_file_set_string(file, "IPv4", "Gateway", _nm_utils_inet4_ntop(htonl(val), buf));
|
||||
g_key_file_set_string(file, "IPv4", "Gateway", nm_inet4_ntop(htonl(val), buf));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -993,7 +993,7 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho
|
|||
/* Fully fail if invalid IP address retrieved */
|
||||
address_string = mm_bearer_ip_config_get_address(self->_priv.ipv4_config);
|
||||
if (!address_string
|
||||
|| !nm_utils_parse_inaddr_bin(AF_INET, address_string, NULL, &address_network)) {
|
||||
|| !nm_inet_parse_bin(AF_INET, address_string, NULL, &address_network)) {
|
||||
g_set_error(&error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -1005,7 +1005,7 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho
|
|||
|
||||
/* Missing gateway not a hard failure */
|
||||
gw_string = mm_bearer_ip_config_get_gateway(self->_priv.ipv4_config);
|
||||
if (gw_string && !nm_utils_parse_inaddr_bin(AF_INET, gw_string, NULL, &gw)) {
|
||||
if (gw_string && !nm_inet_parse_bin(AF_INET, gw_string, NULL, &gw)) {
|
||||
g_set_error(&error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -1057,8 +1057,7 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho
|
|||
|
||||
dns = mm_bearer_ip_config_get_dns(self->_priv.ipv4_config);
|
||||
for (i = 0; dns && dns[i]; i++) {
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET, dns[i], NULL, &address_network)
|
||||
&& address_network > 0) {
|
||||
if (nm_inet_parse_bin(AF_INET, dns[i], NULL, &address_network) && address_network > 0) {
|
||||
nm_l3_config_data_add_nameserver(l3cd, AF_INET, &address_network);
|
||||
_LOGI(" DNS %s", dns[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -786,7 +786,7 @@ handle_settings(GVariant *v_dict, gpointer user_data)
|
|||
_LOGW("Settings 'Address' missing");
|
||||
goto out;
|
||||
}
|
||||
if (!s || !nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &address_network)) {
|
||||
if (!s || !nm_inet_parse_bin(AF_INET, s, NULL, &address_network)) {
|
||||
_LOGW("can't convert 'Address' %s to addr", s ?: "");
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -801,11 +801,11 @@ handle_settings(GVariant *v_dict, gpointer user_data)
|
|||
_LOGW("Settings 'Netmask' missing");
|
||||
goto out;
|
||||
}
|
||||
if (!s || !nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &address_network)) {
|
||||
if (!s || !nm_inet_parse_bin(AF_INET, s, NULL, &address_network)) {
|
||||
_LOGW("invalid 'Netmask': %s", s ?: "");
|
||||
goto out;
|
||||
}
|
||||
address.plen = _nm_utils_ip4_netmask_to_prefix(address_network);
|
||||
address.plen = nm_ip4_addr_netmask_to_prefix(address_network);
|
||||
|
||||
_LOGI("Address: %s", nm_platform_ip4_address_to_string(&address, sbuf, sizeof(sbuf)));
|
||||
nm_l3_config_data_add_address_4(priv->l3cd_4, &address);
|
||||
|
|
@ -814,7 +814,7 @@ handle_settings(GVariant *v_dict, gpointer user_data)
|
|||
_LOGW("Settings 'Gateway' missing");
|
||||
goto out;
|
||||
}
|
||||
if (!nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &gateway_network)) {
|
||||
if (!nm_inet_parse_bin(AF_INET, s, NULL, &gateway_network)) {
|
||||
_LOGW("invalid 'Gateway': %s", s);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -840,8 +840,7 @@ handle_settings(GVariant *v_dict, gpointer user_data)
|
|||
gboolean any_good = FALSE;
|
||||
|
||||
for (; array[0]; array++) {
|
||||
if (!nm_utils_parse_inaddr_bin(AF_INET, *array, NULL, &address_network)
|
||||
|| !address_network) {
|
||||
if (!nm_inet_parse_bin(AF_INET, *array, NULL, &address_network) || !address_network) {
|
||||
_LOGW("invalid NameServer: %s", *array);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -857,7 +856,7 @@ handle_settings(GVariant *v_dict, gpointer user_data)
|
|||
|
||||
if (g_variant_lookup(v_dict, "MessageProxy", "&s", &s)) {
|
||||
_LOGI("MessageProxy: %s", s);
|
||||
if (s && nm_utils_parse_inaddr_bin(AF_INET, s, NULL, &address_network)) {
|
||||
if (s && nm_inet_parse_bin(AF_INET, s, NULL, &address_network)) {
|
||||
const NMPlatformIP4Route mms_route = {
|
||||
.network = address_network,
|
||||
.plen = 32,
|
||||
|
|
|
|||
|
|
@ -469,10 +469,10 @@ _acd_reglist_data_remove(NMDhcpClient *self, guint idx, gboolean do_log)
|
|||
reglist_data = _acd_reglist_data_get(priv, idx);
|
||||
|
||||
if (do_log) {
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGD("acd: drop check for address %s (l3cd " NM_HASH_OBFUSCATE_PTR_FMT ")",
|
||||
_nm_utils_inet4_ntop(reglist_data->addr, sbuf_addr),
|
||||
nm_inet4_ntop(reglist_data->addr, sbuf_addr),
|
||||
NM_HASH_OBFUSCATE_PTR(reglist_data->l3cd));
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +551,7 @@ static void
|
|||
_acd_check_lease(NMDhcpClient *self, NMOptionBool *out_acd_state)
|
||||
{
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
in_addr_t addr;
|
||||
gboolean addr_changed = FALSE;
|
||||
guint idx;
|
||||
|
|
@ -590,7 +590,7 @@ _acd_check_lease(NMDhcpClient *self, NMOptionBool *out_acd_state)
|
|||
|
||||
_LOGD("acd: %s check for address %s (timeout %u msec, l3cd " NM_HASH_OBFUSCATE_PTR_FMT ")",
|
||||
addr_changed ? "add" : "update",
|
||||
_nm_utils_inet4_ntop(addr, sbuf_addr),
|
||||
nm_inet4_ntop(addr, sbuf_addr),
|
||||
priv->config.v4.acd_timeout_msec,
|
||||
NM_HASH_OBFUSCATE_PTR(priv->l3cd_next));
|
||||
|
||||
|
|
@ -677,7 +677,7 @@ gboolean
|
|||
_nm_dhcp_client_accept_offer(NMDhcpClient *self, gconstpointer p_yiaddr)
|
||||
{
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
NMIPAddr yiaddr;
|
||||
const NML3AcdAddrInfo *acd_info;
|
||||
|
||||
|
|
@ -710,7 +710,7 @@ _nm_dhcp_client_accept_offer(NMDhcpClient *self, gconstpointer p_yiaddr)
|
|||
return TRUE;
|
||||
|
||||
_LOGD("offered lease rejected: address %s failed ACD check",
|
||||
_nm_utils_inet4_ntop(yiaddr.addr4, sbuf_addr));
|
||||
nm_inet4_ntop(yiaddr.addr4, sbuf_addr));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -1078,7 +1078,7 @@ static void
|
|||
l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NMDhcpClient *self)
|
||||
{
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_assert(l3cfg == priv->config.l3cfg);
|
||||
|
||||
|
|
@ -1240,7 +1240,7 @@ wait_dhcp_commit_done:
|
|||
if (acd_state != NM_OPTION_BOOL_DEFAULT) {
|
||||
_LOGD("acd: acd %s for %s",
|
||||
acd_state ? "ready" : "conflict",
|
||||
_nm_utils_inet4_ntop(priv->v4.acd.addr, sbuf_addr));
|
||||
nm_inet4_ntop(priv->v4.acd.addr, sbuf_addr));
|
||||
nm_l3cfg_commit_type_clear(priv->config.l3cfg, &priv->v4.acd.l3cfg_commit_handle);
|
||||
priv->v4.acd.state = acd_state;
|
||||
priv->v4.acd.done_source = nm_g_idle_add_source(_acd_complete_on_idle_cb, self);
|
||||
|
|
@ -1660,14 +1660,14 @@ nm_dhcp_client_server_id_is_rejected(NMDhcpClient *self, gconstpointer addr)
|
|||
in_addr_t mask;
|
||||
int r_prefix;
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_INET,
|
||||
priv->config.reject_servers[i],
|
||||
NULL,
|
||||
&r_addr,
|
||||
&r_prefix))
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_INET,
|
||||
priv->config.reject_servers[i],
|
||||
NULL,
|
||||
&r_addr,
|
||||
&r_prefix))
|
||||
nm_assert_not_reached();
|
||||
|
||||
mask = _nm_utils_ip4_prefix_to_netmask(r_prefix < 0 ? 32 : r_prefix);
|
||||
mask = nm_ip4_addr_netmask_from_prefix(r_prefix < 0 ? 32 : r_prefix);
|
||||
if ((addr4 & mask) == (r_addr & mask))
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,12 +143,12 @@ lease_option_consume_route(const uint8_t **datap,
|
|||
if (!nm_dhcp_lease_data_consume_in_addr(&data, &n_data, &dest))
|
||||
return FALSE;
|
||||
|
||||
plen = _nm_utils_ip4_get_default_prefix0(dest);
|
||||
plen = nm_ip4_addr_get_default_prefix0(dest);
|
||||
if (plen == 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dest = nm_utils_ip4_address_clear_host_address(dest, plen);
|
||||
dest = nm_ip4_addr_clear_host_address(dest, plen);
|
||||
|
||||
if (!nm_dhcp_lease_data_consume_in_addr(&data, &n_data, &gateway))
|
||||
return FALSE;
|
||||
|
|
@ -239,16 +239,16 @@ lease_parse_address(NMDhcpNettools *self /* for logging context only */,
|
|||
|
||||
r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_SUBNET_MASK, &l_data, &l_data_len);
|
||||
if (r == N_DHCP4_E_UNSET) {
|
||||
char str1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str1[NM_INET_ADDRSTRLEN];
|
||||
char str2[NM_INET_ADDRSTRLEN];
|
||||
|
||||
/* Some DHCP servers may not set the subnet-mask (issue#1037).
|
||||
* Do the same as the dhclient plugin and use a default. */
|
||||
a_plen = _nm_utils_ip4_get_default_prefix(a_address.s_addr);
|
||||
a_netmask = _nm_utils_ip4_prefix_to_netmask(a_plen);
|
||||
a_plen = nm_ip4_addr_get_default_prefix(a_address.s_addr);
|
||||
a_netmask = nm_ip4_addr_netmask_from_prefix(a_plen);
|
||||
_LOGT("missing subnet mask (option 1). Guess %s based on IP address %s",
|
||||
_nm_utils_inet4_ntop(a_netmask, str1),
|
||||
_nm_utils_inet4_ntop(a_address.s_addr, str2));
|
||||
nm_inet4_ntop(a_netmask, str1),
|
||||
nm_inet4_ntop(a_address.s_addr, str2));
|
||||
} else {
|
||||
if (r != 0
|
||||
|| !nm_dhcp_lease_data_parse_in_addr(l_data,
|
||||
|
|
@ -261,8 +261,8 @@ lease_parse_address(NMDhcpNettools *self /* for logging context only */,
|
|||
"could not get netmask from lease");
|
||||
return FALSE;
|
||||
}
|
||||
a_plen = _nm_utils_ip4_netmask_to_prefix(a_netmask);
|
||||
a_netmask = _nm_utils_ip4_prefix_to_netmask(a_plen);
|
||||
a_plen = nm_ip4_addr_netmask_to_prefix(a_netmask);
|
||||
a_netmask = nm_ip4_addr_netmask_from_prefix(a_plen);
|
||||
}
|
||||
|
||||
nm_dhcp_option_add_option_in_addr(options,
|
||||
|
|
@ -335,22 +335,22 @@ lease_parse_address_list(NDhcp4ClientLease *lease,
|
|||
nm_str_buf_reset(sbuf);
|
||||
|
||||
for (; l_data_len > 0; l_data_len -= 4, l_data += 4) {
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
const in_addr_t addr = unaligned_read_ne32(l_data);
|
||||
|
||||
nm_str_buf_append_required_delimiter(sbuf, ' ');
|
||||
nm_str_buf_append(sbuf, _nm_utils_inet4_ntop(addr, addr_str));
|
||||
nm_str_buf_append(sbuf, nm_inet4_ntop(addr, addr_str));
|
||||
|
||||
switch (option) {
|
||||
case NM_DHCP_OPTION_DHCP4_DOMAIN_NAME_SERVER:
|
||||
if (addr == 0 || nm_utils_ip4_address_is_loopback(addr)) {
|
||||
if (addr == 0 || nm_ip4_addr_is_loopback(addr)) {
|
||||
/* Skip localhost addresses, like also networkd does.
|
||||
* See https://github.com/systemd/systemd/issues/4524. */
|
||||
nm_dhcp_lease_log_invalid_option(iface,
|
||||
AF_INET,
|
||||
option,
|
||||
"address %s is ignored",
|
||||
_nm_utils_inet4_ntop(addr, addr_str));
|
||||
nm_inet4_ntop(addr, addr_str));
|
||||
continue;
|
||||
}
|
||||
nm_l3_config_data_add_nameserver(l3cd, AF_INET, &addr);
|
||||
|
|
@ -378,8 +378,8 @@ lease_parse_routes(NDhcp4ClientLease *lease,
|
|||
GHashTable *options,
|
||||
NMStrBuf *sbuf)
|
||||
{
|
||||
char dest_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char gateway_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char dest_str[NM_INET_ADDRSTRLEN];
|
||||
char gateway_str[NM_INET_ADDRSTRLEN];
|
||||
in_addr_t dest;
|
||||
in_addr_t gateway;
|
||||
uint8_t plen;
|
||||
|
|
@ -412,8 +412,8 @@ lease_parse_routes(NDhcp4ClientLease *lease,
|
|||
|
||||
nm_str_buf_reset(sbuf);
|
||||
while (lease_option_consume_route(&l_data, &l_data_len, TRUE, &dest, &plen, &gateway)) {
|
||||
_nm_utils_inet4_ntop(dest, dest_str);
|
||||
_nm_utils_inet4_ntop(gateway, gateway_str);
|
||||
nm_inet4_ntop(dest, dest_str);
|
||||
nm_inet4_ntop(gateway, gateway_str);
|
||||
|
||||
nm_str_buf_append_required_delimiter(sbuf, ' ');
|
||||
nm_str_buf_append_printf(sbuf, "%s/%d %s", dest_str, (int) plen, gateway_str);
|
||||
|
|
@ -454,8 +454,8 @@ lease_parse_routes(NDhcp4ClientLease *lease,
|
|||
nm_str_buf_reset(sbuf);
|
||||
|
||||
while (lease_option_consume_route(&l_data, &l_data_len, FALSE, &dest, &plen, &gateway)) {
|
||||
_nm_utils_inet4_ntop(dest, dest_str);
|
||||
_nm_utils_inet4_ntop(gateway, gateway_str);
|
||||
nm_inet4_ntop(dest, dest_str);
|
||||
nm_inet4_ntop(gateway, gateway_str);
|
||||
|
||||
nm_str_buf_append_required_delimiter(sbuf, ' ');
|
||||
nm_str_buf_append_printf(sbuf, "%s/%d %s", dest_str, (int) plen, gateway_str);
|
||||
|
|
@ -501,7 +501,7 @@ lease_parse_routes(NDhcp4ClientLease *lease,
|
|||
|
||||
while (nm_dhcp_lease_data_consume_in_addr(&l_data, &l_data_len, &gateway)) {
|
||||
nm_str_buf_append_required_delimiter(sbuf, ' ');
|
||||
nm_str_buf_append(sbuf, _nm_utils_inet4_ntop(gateway, gateway_str));
|
||||
nm_str_buf_append(sbuf, nm_inet4_ntop(gateway, gateway_str));
|
||||
|
||||
if (gateway == 0) {
|
||||
/* silently skip 0.0.0.0 */
|
||||
|
|
@ -868,7 +868,7 @@ lease_save(NMDhcpNettools *self, NDhcp4ClientLease *lease, const char *lease_fil
|
|||
{
|
||||
struct in_addr a_address;
|
||||
nm_auto_str_buf NMStrBuf sbuf = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE);
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
nm_assert(lease);
|
||||
|
|
@ -879,9 +879,7 @@ lease_save(NMDhcpNettools *self, NDhcp4ClientLease *lease, const char *lease_fil
|
|||
return;
|
||||
|
||||
nm_str_buf_append(&sbuf, "# This is private data. Do not parse.\n");
|
||||
nm_str_buf_append_printf(&sbuf,
|
||||
"ADDRESS=%s\n",
|
||||
_nm_utils_inet4_ntop(a_address.s_addr, addr_str));
|
||||
nm_str_buf_append_printf(&sbuf, "ADDRESS=%s\n", nm_inet4_ntop(a_address.s_addr, addr_str));
|
||||
|
||||
if (!g_file_set_contents(lease_file, nm_str_buf_get_str_unsafe(&sbuf), sbuf.len, &error))
|
||||
_LOGW("error saving lease to %s: %s", lease_file, error->message);
|
||||
|
|
@ -966,7 +964,7 @@ dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event)
|
|||
|
||||
if (nm_dhcp_client_server_id_is_rejected(NM_DHCP_CLIENT(self), &server_id)) {
|
||||
_LOGD("server-id %s is in the reject-list, ignoring",
|
||||
nm_utils_inet_ntop(AF_INET, &server_id, addr_str));
|
||||
nm_inet_ntop(AF_INET, &server_id, addr_str));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -976,8 +974,8 @@ dhcp4_event_handle(NMDhcpNettools *self, NDhcp4ClientEvent *event)
|
|||
}
|
||||
|
||||
_LOGT("selecting offered lease from %s for %s",
|
||||
_nm_utils_inet4_ntop(server_id.s_addr, addr_str),
|
||||
_nm_utils_inet4_ntop(yiaddr.s_addr, addr_str2));
|
||||
nm_inet4_ntop(server_id.s_addr, addr_str),
|
||||
nm_inet4_ntop(yiaddr.s_addr, addr_str2));
|
||||
|
||||
r = n_dhcp4_client_lease_select(event->offer.lease);
|
||||
|
||||
|
|
@ -1336,7 +1334,7 @@ ip4_start(NMDhcpClient *client, GError **error)
|
|||
NULL);
|
||||
nm_parse_env_file(contents, "ADDRESS", &s_addr);
|
||||
if (s_addr)
|
||||
nm_utils_parse_inaddr_bin(AF_INET, s_addr, NULL, &last_addr);
|
||||
nm_inet_parse_bin(AF_INET, s_addr, NULL, &last_addr);
|
||||
}
|
||||
|
||||
if (last_addr.s_addr) {
|
||||
|
|
|
|||
|
|
@ -438,9 +438,9 @@ nm_dhcp_option_add_option_in_addr(GHashTable *options,
|
|||
guint option,
|
||||
in_addr_t value)
|
||||
{
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_dhcp_option_add_option(options, addr_family, option, _nm_utils_inet4_ntop(value, sbuf));
|
||||
nm_dhcp_option_add_option(options, addr_family, option, nm_inet4_ntop(value, sbuf));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ lease_to_ip6_config(NMDhcpSystemd *self, sd_dhcp6_lease *lease, gint32 ts, GErro
|
|||
gs_unref_hashtable GHashTable *options = NULL;
|
||||
struct in6_addr tmp_addr;
|
||||
const struct in6_addr *dns;
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
char **domains;
|
||||
char **ntp_fqdns;
|
||||
const struct in6_addr *ntp_addrs;
|
||||
|
|
@ -107,7 +107,7 @@ lease_to_ip6_config(NMDhcpSystemd *self, sd_dhcp6_lease *lease, gint32 ts, GErro
|
|||
|
||||
nm_l3_config_data_add_address_6(l3cd, &address);
|
||||
|
||||
_nm_utils_inet6_ntop(&tmp_addr, addr_str);
|
||||
nm_inet6_ntop(&tmp_addr, addr_str);
|
||||
g_string_append(nm_gstring_add_space_delimiter(str), addr_str);
|
||||
|
||||
has_any_addresses = TRUE;
|
||||
|
|
@ -133,7 +133,7 @@ lease_to_ip6_config(NMDhcpSystemd *self, sd_dhcp6_lease *lease, gint32 ts, GErro
|
|||
if (num > 0) {
|
||||
nm_gstring_prepare(&str);
|
||||
for (i = 0; i < num; i++) {
|
||||
_nm_utils_inet6_ntop(&dns[i], addr_str);
|
||||
nm_inet6_ntop(&dns[i], addr_str);
|
||||
g_string_append(nm_gstring_add_space_delimiter(str), addr_str);
|
||||
nm_l3_config_data_add_nameserver(l3cd, AF_INET6, &dns[i]);
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ lease_to_ip6_config(NMDhcpSystemd *self, sd_dhcp6_lease *lease, gint32 ts, GErro
|
|||
num = sd_dhcp6_lease_get_ntp_addrs(lease, &ntp_addrs);
|
||||
if (num > 0) {
|
||||
for (i = 0; i < num; i++) {
|
||||
_nm_utils_inet6_ntop(&ntp_addrs[i], addr_str);
|
||||
nm_inet6_ntop(&ntp_addrs[i], addr_str);
|
||||
g_string_append(nm_gstring_add_space_delimiter(str), addr_str);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ ip4_process_dhcpcd_rfc3442_routes(const char *iface,
|
|||
l3cd,
|
||||
&((const NMPlatformIP4Route){
|
||||
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
|
||||
.network = nm_utils_ip4_address_clear_host_address(rt_addr, rt_cidr),
|
||||
.network = nm_ip4_addr_clear_host_address(rt_addr, rt_cidr),
|
||||
.plen = rt_cidr,
|
||||
.gateway = rt_route,
|
||||
.pref_src = address,
|
||||
|
|
@ -139,7 +139,7 @@ process_dhclient_rfc3442_route(const char *const **p_octets, NMPlatformIP4Route
|
|||
str_addr = g_strjoin(".", addr[0], addr[1], addr[2], addr[3], NULL);
|
||||
if (inet_pton(AF_INET, str_addr, &tmp_addr) <= 0)
|
||||
return FALSE;
|
||||
v_network = nm_utils_ip4_address_clear_host_address(tmp_addr, v_plen);
|
||||
v_network = nm_ip4_addr_clear_host_address(tmp_addr, v_plen);
|
||||
}
|
||||
|
||||
next_hop = g_strjoin(".", o[0], o[1], o[2], o[3], NULL);
|
||||
|
|
@ -203,9 +203,9 @@ ip4_process_dhclient_rfc3442_routes(const char *iface,
|
|||
_LOG2I(LOGD_DHCP4,
|
||||
iface,
|
||||
" classless static route %s/%d gw %s",
|
||||
_nm_utils_inet4_ntop(route.network, b1),
|
||||
nm_inet4_ntop(route.network, b1),
|
||||
route.plen,
|
||||
_nm_utils_inet4_ntop(route.gateway, b2));
|
||||
nm_inet4_ntop(route.gateway, b2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -324,8 +324,8 @@ process_classful_routes(const char *iface,
|
|||
* The Static Routes option (option 33) does not provide a subnet mask
|
||||
* for each route - it is assumed that the subnet mask is implicit in
|
||||
* whatever network number is specified in each route entry */
|
||||
route.plen = _nm_utils_ip4_get_default_prefix(rt_addr);
|
||||
if (rt_addr & ~_nm_utils_ip4_prefix_to_netmask(route.plen)) {
|
||||
route.plen = nm_ip4_addr_get_default_prefix(rt_addr);
|
||||
if (rt_addr & ~nm_ip4_addr_netmask_from_prefix(route.plen)) {
|
||||
/* RFC 943: target not "this network"; using host routing */
|
||||
route.plen = 32;
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ process_classful_routes(const char *iface,
|
|||
route.metric_any = TRUE;
|
||||
route.metric = 0;
|
||||
|
||||
route.network = nm_utils_ip4_address_clear_host_address(route.network, route.plen);
|
||||
route.network = nm_ip4_addr_clear_host_address(route.network, route.plen);
|
||||
|
||||
nm_l3_config_data_add_route_4(l3cd, &route);
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
gboolean gateway_has = FALSE;
|
||||
guint32 gateway = 0;
|
||||
guint8 plen = 0;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
guint32 now;
|
||||
|
||||
g_return_val_if_fail(options != NULL, NULL);
|
||||
|
|
@ -414,7 +414,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
};
|
||||
|
||||
str = g_hash_table_lookup(options, "ip_address");
|
||||
if (!str || !nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &addr))
|
||||
if (!str || !nm_inet_parse_bin(AF_INET, str, NULL, &addr))
|
||||
return NULL;
|
||||
if (addr == INADDR_ANY)
|
||||
return NULL;
|
||||
|
|
@ -423,11 +423,11 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
|
||||
str = g_hash_table_lookup(options, "subnet_mask");
|
||||
if (str && (inet_pton(AF_INET, str, &tmp_addr) > 0)) {
|
||||
plen = _nm_utils_ip4_netmask_to_prefix(tmp_addr);
|
||||
plen = nm_ip4_addr_netmask_to_prefix(tmp_addr);
|
||||
_LOG2I(LOGD_DHCP4, iface, " plen %d (%s)", plen, str);
|
||||
} else {
|
||||
/* Get default netmask for the IP according to appropriate class. */
|
||||
plen = _nm_utils_ip4_get_default_prefix(addr);
|
||||
plen = nm_ip4_addr_get_default_prefix(addr);
|
||||
_LOG2I(LOGD_DHCP4, iface, " plen %d (default)", plen);
|
||||
}
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
process_classful_routes(iface, options, l3cd, address.address);
|
||||
|
||||
if (gateway) {
|
||||
_LOG2I(LOGD_DHCP4, iface, " gateway %s", _nm_utils_inet4_ntop(gateway, sbuf));
|
||||
_LOG2I(LOGD_DHCP4, iface, " gateway %s", nm_inet4_ntop(gateway, sbuf));
|
||||
gateway_has = TRUE;
|
||||
} else {
|
||||
/* If the gateway wasn't provided as a classless static route with a
|
||||
|
|
|
|||
|
|
@ -801,13 +801,13 @@ add_dnsmasq_nameserver(NMDnsDnsmasq *self,
|
|||
g_variant_builder_close(servers);
|
||||
}
|
||||
|
||||
#define IP_ADDR_TO_STRING_BUFLEN (NM_UTILS_INET_ADDRSTRLEN + 1 + IFNAMSIZ)
|
||||
#define IP_ADDR_TO_STRING_BUFLEN (NM_INET_ADDRSTRLEN + 1 + IFNAMSIZ)
|
||||
|
||||
static const char *
|
||||
ip_addr_to_string(int addr_family, gconstpointer addr, const char *iface, char *out_buf)
|
||||
{
|
||||
int n_written;
|
||||
char buf2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf2[NM_INET_ADDRSTRLEN];
|
||||
const char *separator;
|
||||
|
||||
nm_assert_addr_family(addr_family);
|
||||
|
|
@ -815,13 +815,13 @@ ip_addr_to_string(int addr_family, gconstpointer addr, const char *iface, char *
|
|||
nm_assert(out_buf);
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
nm_utils_inet_ntop(addr_family, addr, buf2);
|
||||
nm_inet_ntop(addr_family, addr, buf2);
|
||||
separator = "@";
|
||||
} else {
|
||||
if (IN6_IS_ADDR_V4MAPPED(addr))
|
||||
_nm_utils_inet4_ntop(((const struct in6_addr *) addr)->s6_addr32[3], buf2);
|
||||
nm_inet4_ntop(((const struct in6_addr *) addr)->s6_addr32[3], buf2);
|
||||
else
|
||||
_nm_utils_inet6_ntop(addr, buf2);
|
||||
nm_inet6_ntop(addr, buf2);
|
||||
/* Need to scope link-local addresses with %<zone-id>. Before dnsmasq 2.58,
|
||||
* only '@' was supported as delimiter. Since 2.58, '@' and '%' are
|
||||
* supported. Due to a bug, since 2.73 only '%' works properly as "server"
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ add_dns_domains(GPtrArray *array,
|
|||
static void
|
||||
merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3ConfigData *l3cd)
|
||||
{
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN + 50];
|
||||
char buf[NM_INET_ADDRSTRLEN + 50];
|
||||
gboolean has_trust_ad;
|
||||
guint num_nameservers;
|
||||
guint num;
|
||||
|
|
@ -569,11 +569,11 @@ merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3Con
|
|||
addr = nm_ip_addr_from_packed_array(addr_family, nameservers, i);
|
||||
|
||||
if (addr_family == AF_INET)
|
||||
nm_utils_inet_ntop(addr_family, addr, buf);
|
||||
nm_inet_ntop(addr_family, addr, buf);
|
||||
else if (IN6_IS_ADDR_V4MAPPED(addr))
|
||||
_nm_utils_inet4_ntop(addr->addr6.s6_addr32[3], buf);
|
||||
nm_inet4_ntop(addr->addr6.s6_addr32[3], buf);
|
||||
else {
|
||||
_nm_utils_inet6_ntop(&addr->addr6, buf);
|
||||
nm_inet6_ntop(&addr->addr6, buf);
|
||||
if (IN6_IS_ADDR_LINKLOCAL(addr)) {
|
||||
const char *ifname;
|
||||
|
||||
|
|
@ -619,7 +619,7 @@ merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3Con
|
|||
|
||||
nis_servers = nm_l3_config_data_get_nis_servers(l3cd, &num);
|
||||
for (i = 0; i < num; i++)
|
||||
add_string_item(rc->nis_servers, _nm_utils_inet4_ntop(nis_servers[i], buf), TRUE);
|
||||
add_string_item(rc->nis_servers, nm_inet4_ntop(nis_servers[i], buf), TRUE);
|
||||
|
||||
if ((nis_domain = nm_l3_config_data_get_nis_domain(l3cd))) {
|
||||
/* FIXME: handle multiple domains */
|
||||
|
|
@ -1258,7 +1258,7 @@ merge_global_dns_config(NMResolvConfData *rc, NMGlobalDnsConfig *global_conf)
|
|||
static const char *
|
||||
get_nameserver_list(int addr_family, const NML3ConfigData *l3cd, NMStrBuf *tmp_strbuf)
|
||||
{
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
guint num;
|
||||
guint i;
|
||||
gconstpointer nameservers;
|
||||
|
|
@ -1270,7 +1270,7 @@ get_nameserver_list(int addr_family, const NML3ConfigData *l3cd, NMStrBuf *tmp_s
|
|||
const NMIPAddr *addr;
|
||||
|
||||
addr = nm_ip_addr_from_packed_array(addr_family, nameservers, i);
|
||||
nm_utils_inet_ntop(addr_family, addr->addr_ptr, buf);
|
||||
nm_inet_ntop(addr_family, addr->addr_ptr, buf);
|
||||
if (i > 0)
|
||||
nm_str_buf_append_c(tmp_strbuf, ' ');
|
||||
nm_str_buf_append(tmp_strbuf, buf);
|
||||
|
|
@ -2083,8 +2083,7 @@ nm_dns_manager_set_hostname(NMDnsManager *self, const char *hostname, gboolean s
|
|||
|
||||
/* Certain hostnames we don't want to include in resolv.conf 'searches' */
|
||||
if (hostname && nm_utils_is_specific_hostname(hostname)
|
||||
&& !g_str_has_suffix(hostname, ".in-addr.arpa")
|
||||
&& !nm_utils_ipaddr_is_valid(AF_UNSPEC, hostname)) {
|
||||
&& !g_str_has_suffix(hostname, ".in-addr.arpa") && !nm_inet_is_valid(AF_UNSPEC, hostname)) {
|
||||
domain = strchr(hostname, '.');
|
||||
if (domain) {
|
||||
domain++;
|
||||
|
|
@ -2628,7 +2627,7 @@ _get_config_variant(NMDnsManager *self)
|
|||
guint num_domains;
|
||||
guint num_searches;
|
||||
guint i;
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
const char *ifname;
|
||||
gconstpointer nameservers;
|
||||
|
||||
|
|
@ -2645,7 +2644,7 @@ _get_config_variant(NMDnsManager *self)
|
|||
addr = nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i);
|
||||
g_variant_builder_add(&strv_builder,
|
||||
"s",
|
||||
nm_utils_inet_ntop(ip_data->addr_family, addr, buf));
|
||||
nm_inet_ntop(ip_data->addr_family, addr, buf));
|
||||
}
|
||||
g_variant_builder_add(&entry_builder,
|
||||
"{sv}",
|
||||
|
|
|
|||
|
|
@ -1066,7 +1066,7 @@ nm_dns_systemd_resolved_resolve_address(NMDnsSystemdResolved
|
|||
{
|
||||
NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self);
|
||||
NMDnsSystemdResolvedResolveHandle *handle;
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_return_val_if_fail(NM_IS_DNS_SYSTEMD_RESOLVED(self), NULL);
|
||||
nm_assert_addr_family(addr_family);
|
||||
|
|
@ -1092,7 +1092,7 @@ nm_dns_systemd_resolved_resolve_address(NMDnsSystemdResolved
|
|||
_LOG2T(handle,
|
||||
"resolve-address(ifindex=%d, %s, flags=%" G_GINT64_MODIFIER "x): new request",
|
||||
handle->r_address.ifindex,
|
||||
nm_utils_inet_ntop(handle->r_address.addr_family, &handle->r_address.addr, addr_str),
|
||||
nm_inet_ntop(handle->r_address.addr_family, &handle->r_address.addr, addr_str),
|
||||
handle->r_address.flags);
|
||||
|
||||
_resolve_start(self, handle);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ create_dm_cmd_line(const char *iface,
|
|||
*/
|
||||
nm_strv_ptrarray_add_string_dup(cmd, "--strict-order");
|
||||
|
||||
_nm_utils_inet4_ntop(listen_address->address, listen_address_s);
|
||||
nm_inet4_ntop(listen_address->address, listen_address_s);
|
||||
|
||||
nm_strv_ptrarray_add_string_concat(cmd, "--listen-address=", listen_address_s);
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ create_dm_cmd_line(const char *iface,
|
|||
g_string_append(s, "--dhcp-option=option:dns-server");
|
||||
for (i = 0; i < n; i++) {
|
||||
g_string_append_c(s, ',');
|
||||
g_string_append(s, _nm_utils_inet4_ntop(ipv4arr[i], sbuf_addr));
|
||||
g_string_append(s, nm_inet4_ntop(ipv4arr[i], sbuf_addr));
|
||||
}
|
||||
nm_strv_ptrarray_take_gstring(cmd, &s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ nm_dnsmasq_utils_get_range(const NMPlatformIP4Address *addr,
|
|||
prefix = 24;
|
||||
}
|
||||
|
||||
netmask = _nm_utils_ip4_prefix_to_netmask(prefix);
|
||||
netmask = nm_ip4_addr_netmask_from_prefix(prefix);
|
||||
|
||||
/* treat addresses in host-order from here on. */
|
||||
netmask = ntohl(netmask);
|
||||
|
|
@ -96,8 +96,8 @@ nm_dnsmasq_utils_get_range(const NMPlatformIP4Address *addr,
|
|||
first = htonl(first);
|
||||
last = htonl(last);
|
||||
|
||||
_nm_utils_inet4_ntop(first, out_first);
|
||||
_nm_utils_inet4_ntop(last, out_last);
|
||||
nm_inet4_ntop(first, out_first);
|
||||
nm_inet4_ntop(last, out_last);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,9 +202,7 @@ receive_ra(struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
r_plen = ndp_msg_opt_prefix_len(msg, offset);
|
||||
if (r_plen == 0 || r_plen > 128)
|
||||
continue;
|
||||
nm_utils_ip6_address_clear_host_address(&r_network,
|
||||
ndp_msg_opt_prefix(msg, offset),
|
||||
r_plen);
|
||||
nm_ip6_addr_clear_host_address(&r_network, ndp_msg_opt_prefix(msg, offset), r_plen);
|
||||
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&r_network) || IN6_IS_ADDR_LINKLOCAL(&r_network))
|
||||
continue;
|
||||
|
|
@ -244,9 +242,7 @@ receive_ra(struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
if (plen == 0 || plen > 128)
|
||||
continue;
|
||||
|
||||
nm_utils_ip6_address_clear_host_address(&network,
|
||||
ndp_msg_opt_route_prefix(msg, offset),
|
||||
plen);
|
||||
nm_ip6_addr_clear_host_address(&network, ndp_msg_opt_route_prefix(msg, offset), plen);
|
||||
|
||||
{
|
||||
const NMNDiscRoute route = {
|
||||
|
|
|
|||
|
|
@ -1233,9 +1233,9 @@ nm_ndisc_dad_failed(NMNDisc *ndisc, const struct in6_addr *address, gboolean emi
|
|||
NMNDiscAddress *item = &g_array_index(rdata->addresses, NMNDiscAddress, i);
|
||||
|
||||
if (IN6_ARE_ADDR_EQUAL(&item->address, address)) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGD("DAD failed for discovered address %s", _nm_utils_inet6_ntop(address, sbuf));
|
||||
_LOGD("DAD failed for discovered address %s", nm_inet6_ntop(address, sbuf));
|
||||
changed = TRUE;
|
||||
if (!complete_address(ndisc, item)) {
|
||||
g_array_remove_index(rdata->addresses, i);
|
||||
|
|
@ -1278,7 +1278,7 @@ _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed)
|
|||
NMNDiscDataInternal *rdata;
|
||||
guint i;
|
||||
char changedstr[CONFIG_MAP_MAX_STR];
|
||||
char addrstr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addrstr[NM_INET_ADDRSTRLEN];
|
||||
char str_pref[35];
|
||||
char str_exp[100];
|
||||
gint64 now_msec;
|
||||
|
|
@ -1306,7 +1306,7 @@ _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed)
|
|||
const NMNDiscGateway *gateway = &g_array_index(rdata->gateways, NMNDiscGateway, i);
|
||||
|
||||
_LOGD(" gateway %s pref %s exp %s",
|
||||
_nm_utils_inet6_ntop(&gateway->address, addrstr),
|
||||
nm_inet6_ntop(&gateway->address, addrstr),
|
||||
nm_icmpv6_router_pref_to_string(gateway->preference, str_pref, sizeof(str_pref)),
|
||||
get_exp(str_exp, now_msec, gateway));
|
||||
}
|
||||
|
|
@ -1314,17 +1314,17 @@ _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed)
|
|||
const NMNDiscAddress *address = &g_array_index(rdata->addresses, NMNDiscAddress, i);
|
||||
|
||||
_LOGD(" address %s exp %s",
|
||||
_nm_utils_inet6_ntop(&address->address, addrstr),
|
||||
nm_inet6_ntop(&address->address, addrstr),
|
||||
get_exp(str_exp, now_msec, address));
|
||||
}
|
||||
for (i = 0; i < rdata->routes->len; i++) {
|
||||
const NMNDiscRoute *route = &g_array_index(rdata->routes, NMNDiscRoute, i);
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGD(" route %s/%u via %s pref %s exp %s",
|
||||
_nm_utils_inet6_ntop(&route->network, addrstr),
|
||||
nm_inet6_ntop(&route->network, addrstr),
|
||||
(guint) route->plen,
|
||||
_nm_utils_inet6_ntop(&route->gateway, sbuf),
|
||||
nm_inet6_ntop(&route->gateway, sbuf),
|
||||
nm_icmpv6_router_pref_to_string(route->preference, str_pref, sizeof(str_pref)),
|
||||
get_exp(str_exp, now_msec, route));
|
||||
}
|
||||
|
|
@ -1333,7 +1333,7 @@ _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed)
|
|||
&g_array_index(rdata->dns_servers, NMNDiscDNSServer, i);
|
||||
|
||||
_LOGD(" dns_server %s exp %s",
|
||||
_nm_utils_inet6_ntop(&dns_server->address, addrstr),
|
||||
nm_inet6_ntop(&dns_server->address, addrstr),
|
||||
get_exp(str_exp, now_msec, dns_server));
|
||||
}
|
||||
for (i = 0; i < rdata->dns_domains->len; i++) {
|
||||
|
|
|
|||
|
|
@ -1168,8 +1168,7 @@ load_global_dns(GKeyFile *keyfile, gboolean internal)
|
|||
if (strv) {
|
||||
nm_strv_cleanup(strv, TRUE, TRUE, TRUE);
|
||||
for (i = 0, j = 0; strv[i]; i++) {
|
||||
if (nm_utils_ipaddr_is_valid(AF_INET, strv[i])
|
||||
|| nm_utils_ipaddr_is_valid(AF_INET6, strv[i]))
|
||||
if (nm_inet_is_valid(AF_INET, strv[i]) || nm_inet_is_valid(AF_INET6, strv[i]))
|
||||
strv[j++] = strv[i];
|
||||
else
|
||||
g_free(strv[i]);
|
||||
|
|
@ -1305,8 +1304,7 @@ global_dns_domain_from_dbus(char *name, GVariant *variant)
|
|||
strv = g_variant_dup_strv(val, NULL);
|
||||
nm_strv_cleanup(strv, TRUE, TRUE, TRUE);
|
||||
for (i = 0, j = 0; strv && strv[i]; i++) {
|
||||
if (nm_utils_ipaddr_is_valid(AF_INET, strv[i])
|
||||
|| nm_utils_ipaddr_is_valid(AF_INET6, strv[i]))
|
||||
if (nm_inet_is_valid(AF_INET, strv[i]) || nm_inet_is_valid(AF_INET6, strv[i]))
|
||||
strv[j++] = strv[i];
|
||||
else
|
||||
g_free(strv[i]);
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ system_resolver_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer u
|
|||
|
||||
for (iter = list; iter; iter = iter->next) {
|
||||
GInetAddress *a = iter->data;
|
||||
char str_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_addr[NM_INET_ADDRSTRLEN];
|
||||
int addr_family;
|
||||
|
||||
switch (g_inet_address_get_family(a)) {
|
||||
|
|
@ -830,7 +830,7 @@ system_resolver_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer u
|
|||
nm_str_buf_append_c(&strbuf_hosts, ',');
|
||||
|
||||
nm_str_buf_append(&strbuf_hosts,
|
||||
nm_utils_inet_ntop(addr_family, g_inet_address_to_bytes(a), str_addr));
|
||||
nm_inet_ntop(addr_family, g_inet_address_to_bytes(a), str_addr));
|
||||
next:;
|
||||
}
|
||||
|
||||
|
|
@ -905,7 +905,7 @@ systemd_resolved_resolve_cb(GObject *object, GAsyncResult *res, gpointer user_da
|
|||
|
||||
for (i = 0; i < no_addresses; i++) {
|
||||
gs_unref_variant GVariant *address = NULL;
|
||||
char str_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_addr[NM_INET_ADDRSTRLEN];
|
||||
const guchar *address_buf;
|
||||
|
||||
g_variant_get_child(addresses, i, "(ii@ay)", &ifindex, &addr_family, &address);
|
||||
|
|
@ -928,7 +928,7 @@ systemd_resolved_resolve_cb(GObject *object, GAsyncResult *res, gpointer user_da
|
|||
} else
|
||||
nm_str_buf_append_c(&strbuf_hosts, ',');
|
||||
|
||||
nm_str_buf_append(&strbuf_hosts, nm_utils_inet_ntop(addr_family, address_buf, str_addr));
|
||||
nm_str_buf_append(&strbuf_hosts, nm_inet_ntop(addr_family, address_buf, str_addr));
|
||||
}
|
||||
if (strbuf_hosts.len == 0) {
|
||||
_LOG2D("systemd-resolve returned no usable IPv%c addresses",
|
||||
|
|
|
|||
|
|
@ -4186,7 +4186,7 @@ nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GP
|
|||
return;
|
||||
|
||||
memcpy(&addr, ip, sizeof(struct in6_addr));
|
||||
nm_utils_ip6_address_clear_host_address(&addr, NULL, plen);
|
||||
nm_ip6_addr_clear_host_address(&addr, NULL, plen);
|
||||
|
||||
/* Number of nibbles to include in domains */
|
||||
nibbles = (plen - 1) / 4 + 1;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ nm_hash_update_in6addr_prefix(NMHashState *h, const struct in6_addr *addr, guint
|
|||
|
||||
nm_assert(addr);
|
||||
|
||||
nm_utils_ip6_address_clear_host_address(&a, addr, plen);
|
||||
nm_ip6_addr_clear_host_address(&a, addr, plen);
|
||||
/* we don't hash plen itself. The caller may want to do that.*/
|
||||
nm_hash_update_in6addr(h, &a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ _share_iptables_subnet_to_str(char buf[static _SHARE_IPTABLES_SUBNET_TO_STR
|
|||
in_addr_t netmask;
|
||||
int l;
|
||||
|
||||
netmask = _nm_utils_ip4_prefix_to_netmask(plen);
|
||||
netmask = nm_ip4_addr_netmask_from_prefix(plen);
|
||||
|
||||
l = g_snprintf(buf,
|
||||
_SHARE_IPTABLES_SUBNET_TO_STR_LEN,
|
||||
"%s/%u",
|
||||
_nm_utils_inet4_ntop(addr & netmask, buf_addr),
|
||||
nm_inet4_ntop(addr & netmask, buf_addr),
|
||||
plen);
|
||||
nm_assert(l < _SHARE_IPTABLES_SUBNET_TO_STR_LEN);
|
||||
return buf;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec
|
|||
NMIPConfig *self = NM_IP_CONFIG(object);
|
||||
NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self);
|
||||
const int addr_family = nm_ip_config_get_addr_family(self);
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
const char *const *strv;
|
||||
guint len;
|
||||
int v_i;
|
||||
|
|
@ -108,7 +108,7 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec
|
|||
NMP_OBJECT_CAST_IP_ROUTE(priv->v_gateway.best_default_route));
|
||||
g_value_set_variant(
|
||||
value,
|
||||
g_variant_new_string(nm_utils_inet_ntop(addr_family, gateway, sbuf_addr)));
|
||||
g_variant_new_string(nm_inet_ntop(addr_family, gateway, sbuf_addr)));
|
||||
} else
|
||||
g_value_set_variant(value, nm_g_variant_singleton_s_empty());
|
||||
break;
|
||||
|
|
@ -333,7 +333,7 @@ get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
|
|||
{
|
||||
NMIPConfig *self = NM_IP_CONFIG(object);
|
||||
NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self);
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
GVariantBuilder builder;
|
||||
const in_addr_t *addrs;
|
||||
guint len;
|
||||
|
|
@ -361,7 +361,7 @@ get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
|
|||
for (i = 0; i < len; i++) {
|
||||
GVariantBuilder nested_builder;
|
||||
|
||||
_nm_utils_inet4_ntop(addrs[i], addr_str);
|
||||
nm_inet4_ntop(addrs[i], addr_str);
|
||||
|
||||
g_variant_builder_init(&nested_builder, G_VARIANT_TYPE("a{sv}"));
|
||||
g_variant_builder_add(&nested_builder,
|
||||
|
|
@ -387,7 +387,7 @@ get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
|
|||
else {
|
||||
g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
|
||||
for (i = 0; i < len; i++)
|
||||
g_variant_builder_add(&builder, "s", _nm_utils_inet4_ntop(addrs[i], addr_str));
|
||||
g_variant_builder_add(&builder, "s", nm_inet4_ntop(addrs[i], addr_str));
|
||||
g_value_take_variant(value, g_variant_builder_end(&builder));
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ nm_l3_config_data_log(const NML3ConfigData *self,
|
|||
NMLogDomain log_domain)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
int IS_IPv4;
|
||||
guint i;
|
||||
|
||||
|
|
@ -484,9 +484,9 @@ nm_l3_config_data_log(const NML3ConfigData *self,
|
|||
_L("nameserver%c[%u]: %s",
|
||||
nm_utils_addr_family_to_char(addr_family),
|
||||
i,
|
||||
nm_utils_inet_ntop(addr_family,
|
||||
_garray_inaddr_at(self->nameservers_x[IS_IPv4], IS_IPv4, i),
|
||||
sbuf_addr));
|
||||
nm_inet_ntop(addr_family,
|
||||
_garray_inaddr_at(self->nameservers_x[IS_IPv4], IS_IPv4, i),
|
||||
sbuf_addr));
|
||||
}
|
||||
|
||||
for (i = 0; i < nm_g_ptr_array_len(self->domains_x[IS_IPv4]); i++) {
|
||||
|
|
@ -514,12 +514,12 @@ nm_l3_config_data_log(const NML3ConfigData *self,
|
|||
for (i = 0; i < nm_g_array_len(self->wins); i++) {
|
||||
_L("wins[%u]: %s",
|
||||
i,
|
||||
_nm_utils_inet4_ntop(g_array_index(self->wins, in_addr_t, i), sbuf_addr));
|
||||
nm_inet4_ntop(g_array_index(self->wins, in_addr_t, i), sbuf_addr));
|
||||
}
|
||||
for (i = 0; i < nm_g_array_len(self->nis_servers); i++) {
|
||||
_L("nis-server[%u]: %s",
|
||||
i,
|
||||
_nm_utils_inet4_ntop(g_array_index(self->nis_servers, in_addr_t, i), sbuf_addr));
|
||||
nm_inet4_ntop(g_array_index(self->nis_servers, in_addr_t, i), sbuf_addr));
|
||||
}
|
||||
if (self->nis_domain)
|
||||
_L("nis-domain: %s", self->nis_domain->str);
|
||||
|
|
@ -621,8 +621,7 @@ nm_l3_config_data_log(const NML3ConfigData *self,
|
|||
static gboolean
|
||||
_route_valid_4(const NMPlatformIP4Route *r)
|
||||
{
|
||||
return r && r->plen <= 32
|
||||
&& r->network == nm_utils_ip4_address_clear_host_address(r->network, r->plen);
|
||||
return r && r->plen <= 32 && r->network == nm_ip4_addr_clear_host_address(r->network, r->plen);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -632,7 +631,7 @@ _route_valid_6(const NMPlatformIP6Route *r)
|
|||
|
||||
return r && r->plen <= 128
|
||||
&& (memcmp(&r->network,
|
||||
nm_utils_ip6_address_clear_host_address(&n, &r->network, r->plen),
|
||||
nm_ip6_addr_clear_host_address(&n, &r->network, r->plen),
|
||||
sizeof(n))
|
||||
== 0);
|
||||
}
|
||||
|
|
@ -2185,8 +2184,7 @@ _dedup_multi_index_cmp(const NML3ConfigData *a,
|
|||
|
||||
NM_CMP_DIRECT(ra.metric, rb.metric);
|
||||
NM_CMP_DIRECT(ra.plen, rb.plen);
|
||||
NM_CMP_RETURN_DIRECT(
|
||||
nm_utils_ip4_address_same_prefix_cmp(ra.network, rb.network, ra.plen));
|
||||
NM_CMP_RETURN_DIRECT(nm_ip4_addr_same_prefix_cmp(ra.network, rb.network, ra.plen));
|
||||
break;
|
||||
}
|
||||
case NMP_OBJECT_TYPE_IP6_ROUTE:
|
||||
|
|
@ -2197,7 +2195,7 @@ _dedup_multi_index_cmp(const NML3ConfigData *a,
|
|||
NM_CMP_DIRECT(ra.metric, rb.metric);
|
||||
NM_CMP_DIRECT(ra.plen, rb.plen);
|
||||
NM_CMP_RETURN_DIRECT(
|
||||
nm_utils_ip6_address_same_prefix_cmp(&ra.network, &rb.network, ra.plen));
|
||||
nm_ip6_addr_same_prefix_cmp(&ra.network, &rb.network, ra.plen));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -2298,8 +2296,7 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a,
|
|||
|
||||
NM_CMP_DIRECT(ra.metric, rb.metric);
|
||||
NM_CMP_DIRECT(ra.plen, rb.plen);
|
||||
NM_CMP_RETURN_DIRECT(
|
||||
nm_utils_ip4_address_same_prefix_cmp(ra.network, rb.network, ra.plen));
|
||||
NM_CMP_RETURN_DIRECT(nm_ip4_addr_same_prefix_cmp(ra.network, rb.network, ra.plen));
|
||||
} else {
|
||||
NMPlatformIP6Route ra = def_route_a->ip6_route;
|
||||
NMPlatformIP6Route rb = def_route_b->ip6_route;
|
||||
|
|
@ -2307,7 +2304,7 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a,
|
|||
NM_CMP_DIRECT(ra.metric, rb.metric);
|
||||
NM_CMP_DIRECT(ra.plen, rb.plen);
|
||||
NM_CMP_RETURN_DIRECT(
|
||||
nm_utils_ip6_address_same_prefix_cmp(&ra.network, &rb.network, ra.plen));
|
||||
nm_ip6_addr_same_prefix_cmp(&ra.network, &rb.network, ra.plen));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2425,10 +2422,7 @@ _data_get_direct_route_for_host(const NML3ConfigData *self,
|
|||
if (nm_platform_route_table_uncoerce(item->rx.table_coerced, TRUE) != route_table)
|
||||
continue;
|
||||
|
||||
if (!nm_utils_ip_address_same_prefix(addr_family,
|
||||
host,
|
||||
item->rx.network_ptr,
|
||||
item->rx.plen))
|
||||
if (!nm_ip_addr_same_prefix(addr_family, host, item->rx.network_ptr, item->rx.plen))
|
||||
continue;
|
||||
|
||||
if (best_route && best_route->rx.metric <= item->rx.metric)
|
||||
|
|
@ -2478,9 +2472,9 @@ nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *self, gboolea
|
|||
if (my_addr->plen == 0)
|
||||
continue;
|
||||
|
||||
network_4 = nm_utils_ip4_address_clear_host_address(my_addr->peer_address, my_addr->plen);
|
||||
network_4 = nm_ip4_addr_clear_host_address(my_addr->peer_address, my_addr->plen);
|
||||
|
||||
if (nm_utils_ip4_address_is_zeronet(network_4)) {
|
||||
if (nm_ip4_addr_is_zeronet(network_4)) {
|
||||
/* Kernel doesn't add device-routes for destinations that
|
||||
* start with 0.x.y.z. Skip them. */
|
||||
continue;
|
||||
|
|
@ -2672,9 +2666,9 @@ nm_l3_config_data_add_dependent_device_routes(NML3ConfigData *self,
|
|||
a6 = &addr_src->a6.peer_address;
|
||||
plen = 128;
|
||||
} else {
|
||||
a6 = nm_utils_ip6_address_clear_host_address(&a6_stack,
|
||||
&addr_src->a6.address,
|
||||
addr_src->a6.plen);
|
||||
a6 = nm_ip6_addr_clear_host_address(&a6_stack,
|
||||
&addr_src->a6.address,
|
||||
addr_src->a6.plen);
|
||||
plen = addr_src->a6.plen;
|
||||
}
|
||||
|
||||
|
|
@ -2819,7 +2813,7 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co
|
|||
|
||||
plen = nm_ip_route_get_prefix(s_route);
|
||||
|
||||
nm_utils_ipx_address_clear_host_address(addr_family, &network_bin, &network_bin, plen);
|
||||
nm_ip_addr_clear_host_address(addr_family, &network_bin, &network_bin, plen);
|
||||
|
||||
if (IS_IPv4) {
|
||||
r.r4 = (NMPlatformIP4Route){
|
||||
|
|
@ -2854,7 +2848,7 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co
|
|||
NMIPAddr ip;
|
||||
|
||||
s = nm_setting_ip_config_get_dns(s_ip, i);
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, s, NULL, &ip))
|
||||
if (!nm_inet_parse_bin(addr_family, s, NULL, &ip))
|
||||
continue;
|
||||
nm_l3_config_data_add_nameserver(self, addr_family, &ip);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,17 +104,17 @@ NM_UTILS_ENUM2STR_DEFINE(nm_l3_ipv4ll_state_to_string,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _ASSERT(self) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
NML3IPv4LL *const _self = (self); \
|
||||
\
|
||||
nm_assert(NM_IS_L3_IPV4LL(_self)); \
|
||||
if (NM_MORE_ASSERTS > 5) { \
|
||||
nm_assert(_self->addr == 0u || nm_utils_ip4_address_is_link_local(_self->addr)); \
|
||||
nm_assert(!_self->l3cd || NM_IS_L3_CONFIG_DATA(_self->l3cd)); \
|
||||
} \
|
||||
} \
|
||||
#define _ASSERT(self) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
NML3IPv4LL *const _self = (self); \
|
||||
\
|
||||
nm_assert(NM_IS_L3_IPV4LL(_self)); \
|
||||
if (NM_MORE_ASSERTS > 5) { \
|
||||
nm_assert(_self->addr == 0u || nm_ip4_addr_is_link_local(_self->addr)); \
|
||||
nm_assert(!_self->l3cd || NM_IS_L3_CONFIG_DATA(_self->l3cd)); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -290,7 +290,7 @@ _ip4_address_is_link_local(const NMPlatformIP4Address *a)
|
|||
{
|
||||
nm_assert(a);
|
||||
|
||||
return nm_utils_ip4_address_is_link_local(a->address) && a->plen == ADDR_IPV4LL_PREFIX_LEN
|
||||
return nm_ip4_addr_is_link_local(a->address) && a->plen == ADDR_IPV4LL_PREFIX_LEN
|
||||
&& a->address == a->peer_address;
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ _l3cd_config_create(int ifindex, in_addr_t addr, NMDedupMultiIndex *multi_idx)
|
|||
{
|
||||
nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL;
|
||||
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(addr));
|
||||
nm_assert(nm_ip4_addr_is_link_local(addr));
|
||||
nm_assert(ifindex > 0);
|
||||
nm_assert(multi_idx);
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ static void
|
|||
_ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
|
||||
{
|
||||
CSipHash state;
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
gboolean seed_changed = FALSE;
|
||||
in_addr_t addr_new;
|
||||
guint64 h;
|
||||
|
|
@ -459,7 +459,7 @@ _ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
|
|||
if (!seed_changed && !generate_new_addr) {
|
||||
/* neither did the caller request a new address, nor was the seed changed. The current
|
||||
* address is still to be used. */
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(self->addr));
|
||||
nm_assert(nm_ip4_addr_is_link_local(self->addr));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -492,9 +492,9 @@ gen_addr:
|
|||
if (self->addr == addr_new || NM_IN_SET(ntohl(addr_new) & 0x0000FF00u, 0x0000u, 0xFF00u))
|
||||
goto gen_addr;
|
||||
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(addr_new));
|
||||
nm_assert(nm_ip4_addr_is_link_local(addr_new));
|
||||
|
||||
_LOGT("addr-gen: set address %s", _nm_utils_inet4_ntop(addr_new, sbuf_addr));
|
||||
_LOGT("addr-gen: set address %s", nm_inet4_ntop(addr_new, sbuf_addr));
|
||||
self->addr = addr_new;
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +549,7 @@ static void
|
|||
_l3cd_config_add(NML3IPv4LL *self)
|
||||
{
|
||||
nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL;
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
gboolean changed;
|
||||
|
||||
_ASSERT(self);
|
||||
|
|
@ -571,7 +571,7 @@ _l3cd_config_add(NML3IPv4LL *self)
|
|||
self->l3cd_timeout_msec_changed = FALSE;
|
||||
|
||||
_LOGT("add l3cd config with %s (acd-timeout %u msec%s)",
|
||||
_nm_utils_inet4_ntop(self->addr, sbuf_addr),
|
||||
nm_inet4_ntop(self->addr, sbuf_addr),
|
||||
self->reg_timeout_msec,
|
||||
changed ? "" : " changed");
|
||||
|
||||
|
|
@ -639,7 +639,7 @@ _ipv4ll_platform_ip4_address_lookup(NML3IPv4LL *self, in_addr_t addr)
|
|||
if (addr == 0u)
|
||||
return NULL;
|
||||
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(addr));
|
||||
nm_assert(nm_ip4_addr_is_link_local(addr));
|
||||
|
||||
pladdr = nm_platform_ip4_address_get(nm_l3_ipv4ll_get_platform(self),
|
||||
nm_l3_ipv4ll_get_ifindex(self),
|
||||
|
|
@ -658,7 +658,7 @@ _ipv4ll_l3cfg_get_acd_addr_info(NML3IPv4LL *self, in_addr_t addr)
|
|||
if (addr == 0u)
|
||||
return NULL;
|
||||
|
||||
nm_assert(nm_utils_ip4_address_is_link_local(addr));
|
||||
nm_assert(nm_ip4_addr_is_link_local(addr));
|
||||
return nm_l3cfg_get_acd_addr_info(self->l3cfg, addr);
|
||||
}
|
||||
|
||||
|
|
@ -766,7 +766,7 @@ _ipv4ll_set_timed_out_update(NML3IPv4LL *self, TimedOutState new_state)
|
|||
static gboolean
|
||||
_ipv4ll_set_state(NML3IPv4LL *self, NML3IPv4LLState state)
|
||||
{
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
char sbuf100[100];
|
||||
|
||||
if (self->state == state)
|
||||
|
|
@ -775,7 +775,7 @@ _ipv4ll_set_state(NML3IPv4LL *self, NML3IPv4LLState state)
|
|||
self->notify_on_idle = TRUE;
|
||||
_LOGT("state: set state %s (addr=%s)",
|
||||
nm_l3_ipv4ll_state_to_string(state, sbuf100, sizeof(sbuf100)),
|
||||
_nm_utils_inet4_ntop(self->addr, sbuf_addr));
|
||||
nm_inet4_ntop(self->addr, sbuf_addr));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ _emit_changed_on_idle_cb(gpointer user_data)
|
|||
_LOGT("emit changed signal (state=%s%s%s)",
|
||||
nm_l3_ipv6ll_state_to_string(state),
|
||||
lladdr ? ", " : "",
|
||||
lladdr ? _nm_utils_inet6_ntop(lladdr, sbuf) : "");
|
||||
lladdr ? nm_inet6_ntop(lladdr, sbuf) : "");
|
||||
|
||||
self->notify_fcn(self, state, lladdr, self->user_data);
|
||||
|
||||
|
|
@ -525,14 +525,14 @@ _check(NML3IPv6LL *self)
|
|||
if (_pladdr_is_ll_tentative(pladdr)) {
|
||||
if (_set_cur_lladdr_obj(self, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, pladdr)) {
|
||||
_LOGT("changed: waiting for address %s to complete DAD",
|
||||
_nm_utils_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
nm_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
_lladdr_handle_changed(self);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_set_cur_lladdr_obj(self, NM_L3_IPV6LL_STATE_READY, pladdr)) {
|
||||
_LOGT("changed: address %s is ready", _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
_LOGT("changed: address %s is ready", nm_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
_lladdr_handle_changed(self);
|
||||
}
|
||||
return;
|
||||
|
|
@ -545,9 +545,9 @@ _check(NML3IPv6LL *self)
|
|||
NM_IN_SET(self->state, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, NM_L3_IPV6LL_STATE_READY));
|
||||
if (self->state == NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS)
|
||||
_LOGT("changed: address %s did not complete DAD",
|
||||
_nm_utils_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
nm_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
else {
|
||||
_LOGT("changed: address %s is gone", _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
_LOGT("changed: address %s is gone", nm_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
}
|
||||
|
||||
/* reset the state here, so that we are sure that the following
|
||||
|
|
@ -579,8 +579,7 @@ _check(NML3IPv6LL *self)
|
|||
* If that does not happen within timeout, we assume that this address failed DAD. */
|
||||
self->wait_for_addr_source = nm_g_timeout_add_source(2000, _wait_for_addr_timeout_cb, self);
|
||||
if (_set_cur_lladdr_bin(self, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, &lladdr)) {
|
||||
_LOGT("changed: starting DAD for address %s",
|
||||
_nm_utils_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
_LOGT("changed: starting DAD for address %s", nm_inet6_ntop(&self->cur_lladdr, sbuf));
|
||||
_lladdr_handle_changed(self);
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -358,16 +358,16 @@ G_DEFINE_TYPE(NML3Cfg, nm_l3cfg, G_TYPE_OBJECT)
|
|||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define _LOGT_acd(acd_data, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char _sbuf_acd[NM_UTILS_INET_ADDRSTRLEN]; \
|
||||
\
|
||||
_LOGT("acd[%s, %s]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||
_nm_utils_inet4_ntop((acd_data)->info.addr, _sbuf_acd), \
|
||||
_l3_acd_addr_state_to_string((acd_data)->info.state) \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} \
|
||||
#define _LOGT_acd(acd_data, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char _sbuf_acd[NM_INET_ADDRSTRLEN]; \
|
||||
\
|
||||
_LOGT("acd[%s, %s]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||
nm_inet4_ntop((acd_data)->info.addr, _sbuf_acd), \
|
||||
_l3_acd_addr_state_to_string((acd_data)->info.state) \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -548,7 +548,7 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
|||
char *sbuf,
|
||||
gsize sbuf_size)
|
||||
{
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
char sbuf100[100];
|
||||
char sbufobf[NM_HASH_OBFUSCATE_PTR_STR_BUF_SIZE];
|
||||
char *s = sbuf;
|
||||
|
|
@ -577,7 +577,7 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
|||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", addr=%s, state=%s",
|
||||
_nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr),
|
||||
nm_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr),
|
||||
_l3_acd_addr_state_to_string(notify_data->acd_event.info.state));
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE:
|
||||
|
|
@ -603,7 +603,7 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
|||
&l,
|
||||
", ipv4ll=" NM_HASH_OBFUSCATE_PTR_FMT "%s%s, state=%s",
|
||||
NM_HASH_OBFUSCATE_PTR(notify_data->ipv4ll_event.ipv4ll),
|
||||
NM_PRINT_FMT_QUOTED2(addr4 != 0, ", addr=", _nm_utils_inet4_ntop(addr4, sbuf_addr), ""),
|
||||
NM_PRINT_FMT_QUOTED2(addr4 != 0, ", addr=", nm_inet4_ntop(addr4, sbuf_addr), ""),
|
||||
nm_l3_ipv4ll_state_to_string(nm_l3_ipv4ll_get_state(notify_data->ipv4ll_event.ipv4ll),
|
||||
sbuf100,
|
||||
sizeof(sbuf100)));
|
||||
|
|
@ -2230,7 +2230,7 @@ _l3_acd_data_state_change(NML3Cfg *self,
|
|||
gint64 now_msec;
|
||||
const char *log_reason;
|
||||
char sbuf256[256];
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (!p_now_msec) {
|
||||
now_msec = 0;
|
||||
|
|
@ -2550,7 +2550,7 @@ handle_init:
|
|||
if (!_l3_acd_data_defendconflict_warning_ratelimited(acd_data, p_now_msec)) {
|
||||
_LOGI("IPv4 address %s is used on network connected to interface %d%s%s%s from "
|
||||
"host %s",
|
||||
_nm_utils_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
self->priv.ifindex,
|
||||
NM_PRINT_FMT_QUOTED(self->priv.plobj_next,
|
||||
" (",
|
||||
|
|
@ -2565,7 +2565,7 @@ handle_init:
|
|||
nm_assert(acd_data->info.state == NM_L3_ACD_ADDR_STATE_DEFENDING);
|
||||
_LOGT_acd(acd_data,
|
||||
"address %s defended from %s",
|
||||
_nm_utils_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_ether_addr_to_string_a(sender_addr));
|
||||
/* we just log an info message. Nothing else to do. */
|
||||
return;
|
||||
|
|
@ -2575,7 +2575,7 @@ handle_init:
|
|||
|
||||
_LOGT_acd(acd_data,
|
||||
"address conflict for %s detected with %s",
|
||||
_nm_utils_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_ether_addr_to_string_a(sender_addr));
|
||||
|
||||
if (!_l3_acd_data_defendconflict_warning_ratelimited(acd_data, p_now_msec)) {
|
||||
|
|
@ -2587,7 +2587,7 @@ handle_init:
|
|||
NMP_OBJECT_CAST_LINK(self->priv.plobj_next)->name,
|
||||
")",
|
||||
""),
|
||||
_nm_utils_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_inet4_ntop(acd_data->info.addr, sbuf_addr),
|
||||
nm_ether_addr_to_string_a(sender_addr));
|
||||
}
|
||||
|
||||
|
|
@ -4371,9 +4371,9 @@ _l3_commit_mptcp_af(NML3Cfg *self,
|
|||
default:
|
||||
if (IS_IPv4) {
|
||||
/* We take all addresses, including rfc1918 private addresses
|
||||
* (nm_utils_ip_is_site_local()). */
|
||||
* (nm_ip_addr_is_site_local()). */
|
||||
} else {
|
||||
if (nm_utils_ip6_is_ula(&addr->a6.address)) {
|
||||
if (nm_ip6_addr_is_ula(&addr->a6.address)) {
|
||||
/* Exclude unique local IPv6 addresses fc00::/7. */
|
||||
goto skip_addr;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ nm_netns_shared_ip_reserve(NMNetns *self)
|
|||
NMNetnsSharedIPHandle *handle;
|
||||
const in_addr_t addr_start = ntohl(0x0a2a0001u); /* 10.42.0.1 */
|
||||
in_addr_t addr;
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
/* Find an unused address in the 10.42.x.x range */
|
||||
|
||||
|
|
@ -284,10 +284,10 @@ nm_netns_shared_ip_reserve(NMNetns *self)
|
|||
if (count > 0xFFu) {
|
||||
if (handle->_ref_count == 1) {
|
||||
_LOGE("shared-ip4: ran out of shared IP addresses. Reuse %s/24",
|
||||
_nm_utils_inet4_ntop(handle->addr, sbuf_addr));
|
||||
nm_inet4_ntop(handle->addr, sbuf_addr));
|
||||
} else {
|
||||
_LOGD("shared-ip4: reserved IP address range %s/24 (duplicate)",
|
||||
_nm_utils_inet4_ntop(handle->addr, sbuf_addr));
|
||||
nm_inet4_ntop(handle->addr, sbuf_addr));
|
||||
}
|
||||
handle->_ref_count++;
|
||||
return handle;
|
||||
|
|
@ -304,8 +304,7 @@ nm_netns_shared_ip_reserve(NMNetns *self)
|
|||
|
||||
g_hash_table_add(priv->shared_ips, handle);
|
||||
|
||||
_LOGD("shared-ip4: reserved IP address range %s/24",
|
||||
_nm_utils_inet4_ntop(handle->addr, sbuf_addr));
|
||||
_LOGD("shared-ip4: reserved IP address range %s/24", nm_inet4_ntop(handle->addr, sbuf_addr));
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +313,7 @@ nm_netns_shared_ip_release(NMNetnsSharedIPHandle *handle)
|
|||
{
|
||||
NMNetns *self;
|
||||
NMNetnsPrivate *priv;
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_return_if_fail(handle);
|
||||
|
||||
|
|
@ -331,7 +330,7 @@ nm_netns_shared_ip_release(NMNetnsSharedIPHandle *handle)
|
|||
nm_assert(handle->addr == ntohl(0x0A2AFF01u)); /* 10.42.255.1 */
|
||||
handle->_ref_count--;
|
||||
_LOGD("shared-ip4: release IP address range %s/24 (%d more references held)",
|
||||
_nm_utils_inet4_ntop(handle->addr, sbuf_addr),
|
||||
nm_inet4_ntop(handle->addr, sbuf_addr),
|
||||
handle->_ref_count);
|
||||
return;
|
||||
}
|
||||
|
|
@ -344,8 +343,7 @@ nm_netns_shared_ip_release(NMNetnsSharedIPHandle *handle)
|
|||
g_object_unref(self);
|
||||
}
|
||||
|
||||
_LOGD("shared-ip4: release IP address range %s/24",
|
||||
_nm_utils_inet4_ntop(handle->addr, sbuf_addr));
|
||||
_LOGD("shared-ip4: release IP address range %s/24", nm_inet4_ntop(handle->addr, sbuf_addr));
|
||||
|
||||
handle->_self = NULL;
|
||||
nm_g_slice_free(handle);
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ get_ip_domains(GPtrArray *domains, const NML3ConfigData *l3cd, int addr_family)
|
|||
char *cidr;
|
||||
guint num;
|
||||
guint i;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
const NMPlatformIPAddress *address;
|
||||
const NMPlatformIPRoute *route;
|
||||
const char *const *strv;
|
||||
|
|
@ -144,7 +144,7 @@ get_ip_domains(GPtrArray *domains, const NML3ConfigData *l3cd, int addr_family)
|
|||
|
||||
nm_l3_config_data_iter_ip_address_for_each (&ipconf_iter, l3cd, addr_family, &address) {
|
||||
cidr = g_strdup_printf("%s/%u",
|
||||
nm_utils_inet_ntop(addr_family, address->address_ptr, sbuf),
|
||||
nm_inet_ntop(addr_family, address->address_ptr, sbuf),
|
||||
address->plen);
|
||||
g_ptr_array_add(domains, cidr);
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ get_ip_domains(GPtrArray *domains, const NML3ConfigData *l3cd, int addr_family)
|
|||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route))
|
||||
continue;
|
||||
cidr = g_strdup_printf("%s/%u",
|
||||
nm_utils_inet_ntop(addr_family, route->network_ptr, sbuf),
|
||||
nm_inet_ntop(addr_family, route->network_ptr, sbuf),
|
||||
route->plen);
|
||||
g_ptr_array_add(domains, cidr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,11 +167,11 @@ static void
|
|||
clear_ip6_prefix_delegation(gpointer data)
|
||||
{
|
||||
IP6PrefixDelegation *delegation = data;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGD(LOGD_IP6,
|
||||
"ipv6-pd: undelegating prefix %s/%d",
|
||||
_nm_utils_inet6_ntop(&delegation->prefix.address, sbuf),
|
||||
nm_inet6_ntop(&delegation->prefix.address, sbuf),
|
||||
delegation->prefix.plen);
|
||||
|
||||
g_hash_table_foreach(delegation->subnets, _clear_ip6_subnet, NULL);
|
||||
|
|
@ -204,7 +204,7 @@ ip6_subnet_from_delegation(IP6PrefixDelegation *delegation, NMDevice *device)
|
|||
{
|
||||
NMPlatformIP6Address *subnet;
|
||||
int ifindex = nm_device_get_ifindex(device);
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
subnet = g_hash_table_lookup(delegation->subnets, GINT_TO_POINTER(ifindex));
|
||||
if (!subnet) {
|
||||
|
|
@ -212,7 +212,7 @@ ip6_subnet_from_delegation(IP6PrefixDelegation *delegation, NMDevice *device)
|
|||
if (delegation->next_subnet >= (1 << (64 - delegation->prefix.plen))) {
|
||||
_LOGD(LOGD_IP6,
|
||||
"ipv6-pd: no more prefixes in %s/%d",
|
||||
_nm_utils_inet6_ntop(&delegation->prefix.address, sbuf),
|
||||
nm_inet6_ntop(&delegation->prefix.address, sbuf),
|
||||
delegation->prefix.plen);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ ip6_subnet_from_delegation(IP6PrefixDelegation *delegation, NMDevice *device)
|
|||
|
||||
_LOGD(LOGD_IP6,
|
||||
"ipv6-pd: %s allocated from a /%d prefix on %s",
|
||||
_nm_utils_inet6_ntop(&subnet->address, sbuf),
|
||||
nm_inet6_ntop(&subnet->address, sbuf),
|
||||
delegation->prefix.plen,
|
||||
nm_device_get_iface(device));
|
||||
|
||||
|
|
@ -312,11 +312,11 @@ device_ip6_prefix_delegated(NMDevice *device,
|
|||
guint i;
|
||||
const CList *tmp_list;
|
||||
NMActiveConnection *ac;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGI(LOGD_IP6,
|
||||
"ipv6-pd: received a prefix %s/%d from %s",
|
||||
_nm_utils_inet6_ntop(&prefix->address, sbuf),
|
||||
nm_inet6_ntop(&prefix->address, sbuf),
|
||||
prefix->plen,
|
||||
nm_device_get_iface(device));
|
||||
|
||||
|
|
|
|||
|
|
@ -980,7 +980,7 @@ ipx_address_delete(NMPlatform *platform,
|
|||
|| (plen && address->plen != *plen)
|
||||
|| (peer_addr
|
||||
&& (((peer_addr_i ^ address->peer_address)
|
||||
& _nm_utils_ip4_prefix_to_netmask(address->plen))
|
||||
& nm_ip4_addr_netmask_from_prefix(address->plen))
|
||||
!= 0)))
|
||||
continue;
|
||||
} else {
|
||||
|
|
@ -1151,8 +1151,8 @@ ip_route_add(NMPlatform *platform,
|
|||
&o) {
|
||||
if (addr_family == AF_INET) {
|
||||
const NMPlatformIP4Route *item = NMP_OBJECT_CAST_IP4_ROUTE(o);
|
||||
guint32 n = nm_utils_ip4_address_clear_host_address(item->network, item->plen);
|
||||
guint32 g = nm_utils_ip4_address_clear_host_address(r4->gateway, item->plen);
|
||||
guint32 n = nm_ip4_addr_clear_host_address(item->network, item->plen);
|
||||
guint32 g = nm_ip4_addr_clear_host_address(r4->gateway, item->plen);
|
||||
|
||||
if (r->ifindex == item->ifindex && n == g) {
|
||||
has_route_to_gw = TRUE;
|
||||
|
|
@ -1162,21 +1162,21 @@ ip_route_add(NMPlatform *platform,
|
|||
const NMPlatformIP6Route *item = NMP_OBJECT_CAST_IP6_ROUTE(o);
|
||||
|
||||
if (r->ifindex == item->ifindex
|
||||
&& nm_utils_ip6_address_same_prefix(&r6->gateway, &item->network, item->plen)) {
|
||||
&& nm_ip6_addr_same_prefix(&r6->gateway, &item->network, item->plen)) {
|
||||
has_route_to_gw = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!has_route_to_gw) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
nm_log_warn(
|
||||
LOGD_PLATFORM,
|
||||
"Fake platform: failure adding ip4-route '%d: %s/%d %d': Network Unreachable",
|
||||
r->ifindex,
|
||||
_nm_utils_inet4_ntop(r4->network, sbuf),
|
||||
nm_inet4_ntop(r4->network, sbuf),
|
||||
r->plen,
|
||||
r->metric);
|
||||
} else {
|
||||
|
|
@ -1184,7 +1184,7 @@ ip_route_add(NMPlatform *platform,
|
|||
LOGD_PLATFORM,
|
||||
"Fake platform: failure adding ip6-route '%d: %s/%d %d': Network Unreachable",
|
||||
r->ifindex,
|
||||
_nm_utils_inet6_ntop(&r6->network, sbuf),
|
||||
nm_inet6_ntop(&r6->network, sbuf),
|
||||
r->plen,
|
||||
r->metric);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,13 +217,13 @@ _nmtstp_platform_ip_addresses_assert(const char *filename,
|
|||
}
|
||||
|
||||
if (!addr_bin->found) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_error("%s:%d: IPv%c address %s was not found on ifindex %d",
|
||||
filename,
|
||||
lineno,
|
||||
nm_utils_addr_family_to_char(addr_bin->addr_family),
|
||||
nm_utils_inet_ntop(addr_bin->addr_family, &addr_bin->addr, sbuf),
|
||||
nm_inet_ntop(addr_bin->addr_family, &addr_bin->addr, sbuf),
|
||||
ifindex);
|
||||
}
|
||||
}
|
||||
|
|
@ -582,7 +582,7 @@ _nmtstp_assert_ip4_route_exists(const char *file,
|
|||
r = _ip4_route_get(platform, ifindex, network, plen, metric, tos, &c);
|
||||
|
||||
if (c != c_exists && c_exists != -1) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("[%s:%u] %s(): The ip4 route %s/%d metric %u tos %u shall exist %u times, but "
|
||||
|
|
@ -590,7 +590,7 @@ _nmtstp_assert_ip4_route_exists(const char *file,
|
|||
file,
|
||||
line,
|
||||
func,
|
||||
_nm_utils_inet4_ntop(network, sbuf),
|
||||
nm_inet4_ntop(network, sbuf),
|
||||
plen,
|
||||
metric,
|
||||
tos,
|
||||
|
|
@ -676,8 +676,8 @@ _nmtstp_assert_ip6_route_exists(const char *file,
|
|||
r = _ip6_route_get(platform, ifindex, network, plen, metric, src, src_plen, &c);
|
||||
|
||||
if (c != c_exists && c_exists != -1) {
|
||||
char s_src[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_network[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_src[NM_INET_ADDRSTRLEN];
|
||||
char s_network[NM_INET_ADDRSTRLEN];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("[%s:%u] %s(): The ip6 route %s/%d metric %u src %s/%d shall exist %u times, but "
|
||||
|
|
@ -685,10 +685,10 @@ _nmtstp_assert_ip6_route_exists(const char *file,
|
|||
file,
|
||||
line,
|
||||
func,
|
||||
_nm_utils_inet6_ntop(network, s_network),
|
||||
nm_inet6_ntop(network, s_network),
|
||||
plen,
|
||||
metric,
|
||||
_nm_utils_inet6_ntop(src, s_src),
|
||||
nm_inet6_ntop(src, s_src),
|
||||
src_plen,
|
||||
c_exists,
|
||||
c);
|
||||
|
|
@ -1051,8 +1051,8 @@ _ip_address_add(NMPlatform *platform,
|
|||
gs_free char *s_valid = NULL;
|
||||
gs_free char *s_preferred = NULL;
|
||||
gs_free char *s_label = NULL;
|
||||
char b1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b1[NM_INET_ADDRSTRLEN];
|
||||
char b2[NM_INET_ADDRSTRLEN];
|
||||
|
||||
ifname = nm_platform_link_get_name(platform, ifindex);
|
||||
g_assert(ifname);
|
||||
|
|
@ -1065,18 +1065,18 @@ _ip_address_add(NMPlatform *platform,
|
|||
s_label = g_strdup_printf("%s:%s", ifname, label);
|
||||
|
||||
if (is_v4) {
|
||||
char s_peer[NM_UTILS_INET_ADDRSTRLEN + 50];
|
||||
char s_peer[NM_INET_ADDRSTRLEN + 50];
|
||||
|
||||
g_assert(flags == 0);
|
||||
|
||||
if (peer_address->addr4 != address->addr4 || nmtst_get_rand_uint32() % 2) {
|
||||
/* If the peer is the same as the local address, we can omit it. The result should be identical */
|
||||
nm_sprintf_buf(s_peer, " peer %s", _nm_utils_inet4_ntop(peer_address->addr4, b2));
|
||||
nm_sprintf_buf(s_peer, " peer %s", nm_inet4_ntop(peer_address->addr4, b2));
|
||||
} else
|
||||
s_peer[0] = '\0';
|
||||
|
||||
nmtstp_run_command_check("ip address change %s%s/%d dev %s%s%s%s",
|
||||
_nm_utils_inet4_ntop(address->addr4, b1),
|
||||
nm_inet4_ntop(address->addr4, b1),
|
||||
s_peer,
|
||||
plen,
|
||||
ifname,
|
||||
|
|
@ -1089,10 +1089,10 @@ _ip_address_add(NMPlatform *platform,
|
|||
/* flags not implemented (yet) */
|
||||
g_assert(flags == 0);
|
||||
nmtstp_run_command_check("ip address change %s%s%s/%d dev %s%s%s%s",
|
||||
_nm_utils_inet6_ntop(&address->addr6, b1),
|
||||
nm_inet6_ntop(&address->addr6, b1),
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&peer_address->addr6) ? " peer " : "",
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&peer_address->addr6)
|
||||
? _nm_utils_inet6_ntop(&peer_address->addr6, b2)
|
||||
? nm_inet6_ntop(&peer_address->addr6, b2)
|
||||
: "",
|
||||
plen,
|
||||
ifname,
|
||||
|
|
@ -1299,8 +1299,8 @@ _ip_address_del(NMPlatform *platform,
|
|||
|
||||
if (external_command) {
|
||||
const char *ifname;
|
||||
char b1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b1[NM_INET_ADDRSTRLEN];
|
||||
char b2[NM_INET_ADDRSTRLEN];
|
||||
int success;
|
||||
gboolean had_address;
|
||||
|
||||
|
|
@ -1318,18 +1318,17 @@ _ip_address_del(NMPlatform *platform,
|
|||
had_address = !!nm_platform_ip6_address_get(platform, ifindex, &address->addr6);
|
||||
|
||||
if (is_v4) {
|
||||
success = nmtstp_run_command("ip address delete %s%s%s/%d dev %s",
|
||||
_nm_utils_inet4_ntop(address->addr4, b1),
|
||||
peer_address->addr4 != address->addr4 ? " peer " : "",
|
||||
peer_address->addr4 != address->addr4
|
||||
? _nm_utils_inet4_ntop(peer_address->addr4, b2)
|
||||
: "",
|
||||
plen,
|
||||
ifname);
|
||||
success = nmtstp_run_command(
|
||||
"ip address delete %s%s%s/%d dev %s",
|
||||
nm_inet4_ntop(address->addr4, b1),
|
||||
peer_address->addr4 != address->addr4 ? " peer " : "",
|
||||
peer_address->addr4 != address->addr4 ? nm_inet4_ntop(peer_address->addr4, b2) : "",
|
||||
plen,
|
||||
ifname);
|
||||
} else {
|
||||
g_assert(!peer_address);
|
||||
success = nmtstp_run_command("ip address delete %s/%d dev %s",
|
||||
_nm_utils_inet6_ntop(&address->addr6, b1),
|
||||
nm_inet6_ntop(&address->addr6, b1),
|
||||
plen,
|
||||
ifname);
|
||||
}
|
||||
|
|
@ -1732,8 +1731,8 @@ nmtstp_link_gre_add(NMPlatform *platform,
|
|||
name,
|
||||
type,
|
||||
dev ?: "",
|
||||
_nm_utils_inet4_ntop(lnk->local, b1),
|
||||
_nm_utils_inet4_ntop(lnk->remote, b2),
|
||||
nm_inet4_ntop(lnk->local, b1),
|
||||
nm_inet4_ntop(lnk->remote, b2),
|
||||
lnk->ttl,
|
||||
lnk->tos,
|
||||
lnk->path_mtu_discovery ? "pmtudisc" : "nopmtudisc");
|
||||
|
|
@ -1756,8 +1755,8 @@ nmtstp_link_ip6tnl_add(NMPlatform *platform,
|
|||
{
|
||||
const NMPlatformLink *pllink = NULL;
|
||||
gboolean success;
|
||||
char b1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b1[NM_INET_ADDRSTRLEN];
|
||||
char b2[NM_INET_ADDRSTRLEN];
|
||||
char encap[20];
|
||||
char tclass[20];
|
||||
gboolean encap_ignore;
|
||||
|
|
@ -1798,8 +1797,8 @@ nmtstp_link_ip6tnl_add(NMPlatform *platform,
|
|||
name,
|
||||
mode,
|
||||
dev,
|
||||
_nm_utils_inet6_ntop(&lnk->local, b1),
|
||||
_nm_utils_inet6_ntop(&lnk->remote, b2),
|
||||
nm_inet6_ntop(&lnk->local, b1),
|
||||
nm_inet6_ntop(&lnk->remote, b2),
|
||||
lnk->ttl,
|
||||
tclass_inherit ? "inherit" : nm_sprintf_buf(tclass, "%02x", lnk->tclass),
|
||||
encap_ignore ? "none" : nm_sprintf_buf(encap, "%u", lnk->encap_limit),
|
||||
|
|
@ -1822,8 +1821,8 @@ nmtstp_link_ip6gre_add(NMPlatform *platform,
|
|||
{
|
||||
const NMPlatformLink *pllink = NULL;
|
||||
gboolean success;
|
||||
char b1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b1[NM_INET_ADDRSTRLEN];
|
||||
char b2[NM_INET_ADDRSTRLEN];
|
||||
char tclass[20];
|
||||
gboolean tclass_inherit;
|
||||
|
||||
|
|
@ -1848,8 +1847,8 @@ nmtstp_link_ip6gre_add(NMPlatform *platform,
|
|||
name,
|
||||
lnk->is_tap ? "ip6gretap" : "ip6gre",
|
||||
dev,
|
||||
_nm_utils_inet6_ntop(&lnk->local, b1),
|
||||
_nm_utils_inet6_ntop(&lnk->remote, b2),
|
||||
nm_inet6_ntop(&lnk->local, b1),
|
||||
nm_inet6_ntop(&lnk->remote, b2),
|
||||
lnk->ttl,
|
||||
tclass_inherit ? "inherit" : nm_sprintf_buf(tclass, "%02x", lnk->tclass),
|
||||
lnk->flow_label);
|
||||
|
|
@ -1901,8 +1900,8 @@ nmtstp_link_ipip_add(NMPlatform *platform,
|
|||
"ip tunnel add %s mode ipip %s local %s remote %s ttl %u tos %02x %s",
|
||||
name,
|
||||
dev,
|
||||
_nm_utils_inet4_ntop(lnk->local, b1),
|
||||
_nm_utils_inet4_ntop(lnk->remote, b2),
|
||||
nm_inet4_ntop(lnk->local, b1),
|
||||
nm_inet4_ntop(lnk->remote, b2),
|
||||
lnk->ttl,
|
||||
lnk->tos,
|
||||
lnk->path_mtu_discovery ? "pmtudisc" : "nopmtudisc");
|
||||
|
|
@ -1997,8 +1996,8 @@ nmtstp_link_sit_add(NMPlatform *platform,
|
|||
!nmtstp_run_command("ip tunnel add %s mode sit%s local %s remote %s ttl %u tos %02x %s",
|
||||
name,
|
||||
dev,
|
||||
_nm_utils_inet4_ntop(lnk->local, b1),
|
||||
_nm_utils_inet4_ntop(lnk->remote, b2),
|
||||
nm_inet4_ntop(lnk->local, b1),
|
||||
nm_inet4_ntop(lnk->remote, b2),
|
||||
lnk->ttl,
|
||||
lnk->tos,
|
||||
lnk->path_mtu_discovery ? "pmtudisc" : "nopmtudisc");
|
||||
|
|
@ -2132,24 +2131,24 @@ nmtstp_link_vxlan_add(NMPlatform *platform,
|
|||
|
||||
if (external_command) {
|
||||
gs_free char *dev = NULL;
|
||||
char local[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char group[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char local[NM_INET_ADDRSTRLEN];
|
||||
char group[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (lnk->parent_ifindex)
|
||||
dev =
|
||||
g_strdup_printf("dev %s", nm_platform_link_get_name(platform, lnk->parent_ifindex));
|
||||
|
||||
if (lnk->local)
|
||||
_nm_utils_inet4_ntop(lnk->local, local);
|
||||
nm_inet4_ntop(lnk->local, local);
|
||||
else if (memcmp(&lnk->local6, &in6addr_any, sizeof(in6addr_any)))
|
||||
_nm_utils_inet6_ntop(&lnk->local6, local);
|
||||
nm_inet6_ntop(&lnk->local6, local);
|
||||
else
|
||||
local[0] = '\0';
|
||||
|
||||
if (lnk->group)
|
||||
_nm_utils_inet4_ntop(lnk->group, group);
|
||||
nm_inet4_ntop(lnk->group, group);
|
||||
else if (memcmp(&lnk->group6, &in6addr_any, sizeof(in6addr_any)))
|
||||
_nm_utils_inet6_ntop(&lnk->group6, group);
|
||||
nm_inet6_ntop(&lnk->group6, group);
|
||||
else
|
||||
group[0] = '\0';
|
||||
|
||||
|
|
@ -2732,7 +2731,7 @@ nmtstp_acd_defender_new(int ifindex, in_addr_t ip_addr, const NMEtherAddr *mac_a
|
|||
NAcdProbe *probe = NULL;
|
||||
int fd;
|
||||
int r;
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_assert_cmpint(ifindex, >, 0);
|
||||
g_assert(mac_addr);
|
||||
|
|
@ -2773,7 +2772,7 @@ nmtstp_acd_defender_new(int ifindex, in_addr_t ip_addr, const NMEtherAddr *mac_a
|
|||
NM_HASH_OBFUSCATE_PTR(defender),
|
||||
ifindex,
|
||||
NM_ETHER_ADDR_FORMAT_VAL(mac_addr),
|
||||
_nm_utils_inet4_ntop(ip_addr, sbuf_addr));
|
||||
nm_inet4_ntop(ip_addr, sbuf_addr));
|
||||
|
||||
n_acd_probe_set_userdata(defender->probe, defender);
|
||||
|
||||
|
|
|
|||
|
|
@ -1183,7 +1183,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode)
|
|||
|
||||
for (i = 0; i < num_peers; i++) {
|
||||
NMPWireGuardPeer peer;
|
||||
char s_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_addr[NM_INET_ADDRSTRLEN];
|
||||
NMSockAddrUnion endpoint;
|
||||
guint i_allowed_ips, n_allowed_ips;
|
||||
NMPWireGuardAllowedIP *allowed_ips;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ _wait_for_ipv4_addr_device_route(NMPlatform *platform,
|
|||
/* Wait that the addresses gets a device-route. After adding a address,
|
||||
* the device route is not added immediately. It takes a moment... */
|
||||
|
||||
addr = nm_utils_ip4_address_clear_host_address(addr, plen);
|
||||
addr = nm_ip4_addr_clear_host_address(addr, plen);
|
||||
NMTST_WAIT_ASSERT(400, {
|
||||
NMDedupMultiIter iter;
|
||||
NMPLookup lookup;
|
||||
|
|
@ -41,7 +41,7 @@ _wait_for_ipv4_addr_device_route(NMPlatform *platform,
|
|||
&o) {
|
||||
const NMPlatformIP4Route *r = NMP_OBJECT_CAST_IP4_ROUTE(o);
|
||||
|
||||
if (r->plen == plen && addr == nm_utils_ip4_address_clear_host_address(r->network, plen)
|
||||
if (r->plen == plen && addr == nm_ip4_addr_clear_host_address(r->network, plen)
|
||||
&& r->metric == 0 && r->scope_inv == nm_platform_route_scope_inv(RT_SCOPE_LINK)
|
||||
&& r->rt_source == NM_IP_CONFIG_SOURCE_RTPROT_KERNEL)
|
||||
return;
|
||||
|
|
@ -918,7 +918,7 @@ test_ip(gconstpointer test_data)
|
|||
const NMPlatformLink *l;
|
||||
char ifname[IFNAMSIZ];
|
||||
char ifname2[IFNAMSIZ];
|
||||
char s1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s1[NM_INET_ADDRSTRLEN];
|
||||
NMPlatform *platform = NM_PLATFORM_GET;
|
||||
const int EX_ = -1;
|
||||
struct {
|
||||
|
|
@ -1278,7 +1278,7 @@ _rule_create_random(NMPlatform *platform)
|
|||
guint32 p;
|
||||
int addr_size;
|
||||
guint i;
|
||||
char saddr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char saddr[NM_INET_ADDRSTRLEN];
|
||||
static struct {
|
||||
guint32 uid;
|
||||
guint32 euid;
|
||||
|
|
|
|||
|
|
@ -739,7 +739,7 @@ read_full_ip4_address(shvarFile *ifcfg,
|
|||
int prefix = 0;
|
||||
gboolean has_key;
|
||||
guint32 a;
|
||||
char inet_buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char inet_buf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_return_val_if_fail(which >= -1, FALSE);
|
||||
g_return_val_if_fail(ifcfg != NULL, FALSE);
|
||||
|
|
@ -761,7 +761,7 @@ read_full_ip4_address(shvarFile *ifcfg,
|
|||
if (!read_ip4_address(ifcfg, numbered_tag(tag, "GATEWAY", which), &has_key, &a, error))
|
||||
return FALSE;
|
||||
if (has_key)
|
||||
*out_gateway = nm_utils_inet4_ntop_dup(a);
|
||||
*out_gateway = nm_inet4_ntop_dup(a);
|
||||
}
|
||||
|
||||
/* Prefix */
|
||||
|
|
@ -782,16 +782,16 @@ read_full_ip4_address(shvarFile *ifcfg,
|
|||
if (!read_ip4_address(ifcfg, numbered_tag(tag, "NETMASK", which), &has_key, &a, error))
|
||||
return FALSE;
|
||||
if (has_key)
|
||||
prefix = _nm_utils_ip4_netmask_to_prefix(a);
|
||||
prefix = nm_ip4_addr_netmask_to_prefix(a);
|
||||
else {
|
||||
if (base_addr)
|
||||
prefix = nm_ip_address_get_prefix(base_addr);
|
||||
else {
|
||||
/* Try to autodetermine the prefix for the address' class */
|
||||
prefix = _nm_utils_ip4_get_default_prefix(ipaddr);
|
||||
prefix = nm_ip4_addr_get_default_prefix(ipaddr);
|
||||
PARSE_WARNING("missing %s, assuming %s/%d",
|
||||
prefix_tag,
|
||||
_nm_utils_inet4_ntop(ipaddr, inet_buf),
|
||||
nm_inet4_ntop(ipaddr, inet_buf),
|
||||
prefix);
|
||||
}
|
||||
}
|
||||
|
|
@ -1282,7 +1282,7 @@ parse_line_type_addr_with_prefix:
|
|||
int prefix = -1;
|
||||
|
||||
if (p_info->type == PARSE_LINE_TYPE_ADDR) {
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, s, NULL, &p_data->v.addr.addr)) {
|
||||
if (!nm_inet_parse_bin(addr_family, s, NULL, &p_data->v.addr.addr)) {
|
||||
if (p_info == &parse_infos[PARSE_LINE_ATTR_ROUTE_VIA]
|
||||
&& nm_streq(s, "(null)")) {
|
||||
/* Due to a bug, would older versions of NM write "via (null)"
|
||||
|
|
@ -1313,11 +1313,11 @@ parse_line_type_addr_with_prefix:
|
|||
if (p_info == &parse_infos[PARSE_LINE_ATTR_ROUTE_TO] && nm_streq(s, "default")) {
|
||||
memset(&p_data->v.addr.addr, 0, sizeof(p_data->v.addr.addr));
|
||||
prefix = 0;
|
||||
} else if (!nm_utils_parse_inaddr_prefix_bin(addr_family,
|
||||
s,
|
||||
NULL,
|
||||
&p_data->v.addr.addr,
|
||||
&prefix)) {
|
||||
} else if (!nm_inet_parse_with_prefix_bin(addr_family,
|
||||
s,
|
||||
NULL,
|
||||
&p_data->v.addr.addr,
|
||||
&prefix)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -1468,7 +1468,7 @@ read_one_ip4_route(shvarFile *ifcfg, guint32 which, NMIPRoute **out_route, GErro
|
|||
const char *v;
|
||||
gs_free char *value = NULL;
|
||||
gint64 prefix, metric;
|
||||
char inet_buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char inet_buf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_return_val_if_fail(ifcfg != NULL, FALSE);
|
||||
g_return_val_if_fail(out_route && !*out_route, FALSE);
|
||||
|
|
@ -1496,14 +1496,14 @@ read_one_ip4_route(shvarFile *ifcfg, guint32 which, NMIPRoute **out_route, GErro
|
|||
error))
|
||||
return FALSE;
|
||||
if (has_key) {
|
||||
prefix = _nm_utils_ip4_netmask_to_prefix(netmask);
|
||||
if (netmask != _nm_utils_ip4_prefix_to_netmask(prefix)) {
|
||||
prefix = nm_ip4_addr_netmask_to_prefix(netmask);
|
||||
if (netmask != nm_ip4_addr_netmask_from_prefix(prefix)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"Invalid IP4 netmask '%s' \"%s\"",
|
||||
netmask_tag,
|
||||
_nm_utils_inet4_ntop(netmask, inet_buf));
|
||||
nm_inet4_ntop(netmask, inet_buf));
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1667,7 +1667,7 @@ parse_full_ip6_address(shvarFile *ifcfg,
|
|||
nm_assert(out_address && !*out_address);
|
||||
nm_assert(!error || !*error);
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_INET6, addr_str, NULL, &addr_bin, &prefix)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_INET6, addr_str, NULL, &addr_bin, &prefix)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -2027,7 +2027,7 @@ make_ip4_setting(shvarFile *ifcfg,
|
|||
"because the connection has no static addresses",
|
||||
f);
|
||||
} else
|
||||
gateway = nm_utils_inet4_ntop_dup(a);
|
||||
gateway = nm_inet4_ntop_dup(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2055,10 +2055,10 @@ make_ip4_setting(shvarFile *ifcfg,
|
|||
if (!v)
|
||||
break;
|
||||
|
||||
if (nm_utils_ipaddr_is_valid(AF_INET, v)) {
|
||||
if (nm_inet_is_valid(AF_INET, v)) {
|
||||
if (!nm_setting_ip_config_add_dns(s_ip4, v))
|
||||
PARSE_WARNING("duplicate DNS server %s", tag);
|
||||
} else if (nm_utils_ipaddr_is_valid(AF_INET6, v)) {
|
||||
} else if (nm_inet_is_valid(AF_INET6, v)) {
|
||||
/* Ignore IPv6 addresses */
|
||||
} else {
|
||||
g_set_error(error,
|
||||
|
|
@ -2546,7 +2546,7 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea
|
|||
|
||||
if ((ptr = strchr(v, '%')) != NULL)
|
||||
*ptr = '\0'; /* remove %interface prefix if present */
|
||||
if (!nm_utils_ipaddr_is_valid(AF_INET6, v)) {
|
||||
if (!nm_inet_is_valid(AF_INET6, v)) {
|
||||
if (!is_disabled) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
|
|
@ -2594,14 +2594,14 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea
|
|||
if (!v)
|
||||
break;
|
||||
|
||||
if (nm_utils_ipaddr_is_valid(AF_INET6, v)) {
|
||||
if (nm_inet_is_valid(AF_INET6, v)) {
|
||||
if (is_disabled) {
|
||||
PARSE_WARNING("ignore DNS server addresses with method disabled/ignore");
|
||||
break;
|
||||
}
|
||||
if (!nm_setting_ip_config_add_dns(s_ip6, v))
|
||||
PARSE_WARNING("duplicate DNS server %s", tag);
|
||||
} else if (nm_utils_ipaddr_is_valid(AF_INET, v)) {
|
||||
} else if (nm_inet_is_valid(AF_INET, v)) {
|
||||
/* Ignore IPv4 addresses */
|
||||
} else {
|
||||
if (is_disabled)
|
||||
|
|
|
|||
|
|
@ -2409,8 +2409,8 @@ write_route_file_svformat(const char *filename, NMSettingIPConfig *s_ip4)
|
|||
|
||||
svSetValueStr(routefile, addr_key, nm_ip_route_get_dest(route));
|
||||
|
||||
netmask = _nm_utils_ip4_prefix_to_netmask(nm_ip_route_get_prefix(route));
|
||||
svSetValueStr(routefile, netmask_key, _nm_utils_inet4_ntop(netmask, buf));
|
||||
netmask = nm_ip4_addr_netmask_from_prefix(nm_ip_route_get_prefix(route));
|
||||
svSetValueStr(routefile, netmask_key, nm_inet4_ntop(netmask, buf));
|
||||
|
||||
svSetValueStr(routefile, gw_key, nm_ip_route_get_next_hop(route));
|
||||
|
||||
|
|
@ -2819,9 +2819,7 @@ write_ip4_setting(NMConnection *connection,
|
|||
if (has_netmask) {
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
svSetValueStr(ifcfg,
|
||||
tag,
|
||||
_nm_utils_inet4_ntop(_nm_utils_ip4_prefix_to_netmask(prefix), buf));
|
||||
svSetValueStr(ifcfg, tag, nm_inet4_ntop(nm_ip4_addr_netmask_from_prefix(prefix), buf));
|
||||
}
|
||||
|
||||
n++;
|
||||
|
|
|
|||
|
|
@ -2082,7 +2082,7 @@ test_read_wired_aliases_good(gconstpointer test_data)
|
|||
g_assert(ip4_addr != NULL);
|
||||
|
||||
addr = nm_ip_address_get_address(ip4_addr);
|
||||
g_assert(nm_utils_ipaddr_is_valid(AF_INET, addr));
|
||||
g_assert(nm_inet_is_valid(AF_INET, addr));
|
||||
|
||||
for (j = 0; j < expected_num_addresses; j++) {
|
||||
if (!g_strcmp0(addr, expected_address[j]))
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GErr
|
|||
netmask_v);
|
||||
return FALSE;
|
||||
} else {
|
||||
netmask_int = _nm_utils_ip4_netmask_to_prefix(tmp_mask);
|
||||
netmask_int = nm_ip4_addr_netmask_to_prefix(tmp_mask);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -470,7 +470,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GErr
|
|||
/* gateway */
|
||||
gateway_v = ifparser_getkey(block, "gateway");
|
||||
if (gateway_v) {
|
||||
if (!nm_utils_ipaddr_is_valid(AF_INET, gateway_v)) {
|
||||
if (!nm_inet_is_valid(AF_INET, gateway_v)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -579,7 +579,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, if_block *block, GErr
|
|||
|
||||
gateway_v = ifparser_getkey(block, "gateway");
|
||||
if (gateway_v) {
|
||||
if (!nm_utils_ipaddr_is_valid(AF_INET6, gateway_v)) {
|
||||
if (!nm_inet_is_valid(AF_INET6, gateway_v)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
|
|||
|
|
@ -3174,7 +3174,7 @@ _signal_handle(NMSupplicantInterface *self,
|
|||
|
||||
_set_p2p_assigned_addr(iface,
|
||||
addr_data,
|
||||
_nm_utils_ip4_netmask_to_prefix(netmask));
|
||||
nm_ip4_addr_netmask_to_prefix(netmask));
|
||||
} else {
|
||||
_LOGW("P2P: GroupStarted signaled invalid IP Address information");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ test_config_h(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Reference implementation for nm_utils_ip6_address_clear_host_address.
|
||||
/* Reference implementation for nm_ip6_addr_clear_host_address.
|
||||
* Taken originally from set_address_masked(), src/ndisc/nm-lndp-ndisc.c
|
||||
**/
|
||||
static void
|
||||
|
|
@ -95,14 +95,14 @@ test_nm_utils_ip6_address_clear_host_address(void)
|
|||
_randomize_in6_addr(&addr1, r);
|
||||
_randomize_in6_addr(&addr2, r);
|
||||
addr1 = addr_src;
|
||||
nm_utils_ip6_address_clear_host_address(&addr2, &addr1, plen);
|
||||
nm_ip6_addr_clear_host_address(&addr2, &addr1, plen);
|
||||
g_assert_cmpint(memcmp(&addr1, &addr_src, sizeof(struct in6_addr)), ==, 0);
|
||||
g_assert_cmpint(memcmp(&addr2, &addr_ref, sizeof(struct in6_addr)), ==, 0);
|
||||
|
||||
/* test for self assignment/inplace update. */
|
||||
_randomize_in6_addr(&addr1, r);
|
||||
addr1 = addr_src;
|
||||
nm_utils_ip6_address_clear_host_address(&addr1, &addr1, plen);
|
||||
nm_ip6_addr_clear_host_address(&addr1, &addr1, plen);
|
||||
g_assert_cmpint(memcmp(&addr1, &addr_ref, sizeof(struct in6_addr)), ==, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -155,11 +155,11 @@ _test_same_prefix(const char *a1, const char *a2, guint8 plen)
|
|||
struct in6_addr a = *nmtst_inet6_from_string(a1);
|
||||
struct in6_addr b = *nmtst_inet6_from_string(a2);
|
||||
|
||||
g_assert(nm_utils_ip6_address_same_prefix(&a, &b, plen));
|
||||
g_assert(nm_ip6_addr_same_prefix(&a, &b, plen));
|
||||
}
|
||||
|
||||
static void
|
||||
test_nm_utils_ip6_address_same_prefix(void)
|
||||
test_nm_ip_addr_same_prefix(void)
|
||||
{
|
||||
guint n, i;
|
||||
const guint N = 100;
|
||||
|
|
@ -202,7 +202,7 @@ again_plen:
|
|||
} else
|
||||
b = a;
|
||||
|
||||
result = nm_utils_ip6_address_same_prefix(&a.val, &b.val, plen);
|
||||
result = nm_ip6_addr_same_prefix(&a.val, &b.val, plen);
|
||||
g_assert(result == is_same);
|
||||
g_assert(NM_IN_SET(result, TRUE, FALSE));
|
||||
}
|
||||
|
|
@ -214,12 +214,12 @@ again_plen:
|
|||
plen = nmtst_get_rand_uint32() % 129;
|
||||
|
||||
memset(addrmask.ptr, 0xFF, sizeof(addrmask));
|
||||
nm_utils_ip6_address_clear_host_address(&addrmask.val, &addrmask.val, plen);
|
||||
nm_ip6_addr_clear_host_address(&addrmask.val, &addrmask.val, plen);
|
||||
|
||||
for (i = 0; i < sizeof(a); i++)
|
||||
b.ptr[i] = (a.ptr[i] & addrmask.ptr[i]) | (b.ptr[i] & ~addrmask.ptr[i]);
|
||||
|
||||
g_assert(nm_utils_ip6_address_same_prefix(&a.val, &b.val, plen) == TRUE);
|
||||
g_assert(nm_ip6_addr_same_prefix(&a.val, &b.val, plen) == TRUE);
|
||||
}
|
||||
|
||||
/* test#3 */
|
||||
|
|
@ -234,10 +234,10 @@ again_plen:
|
|||
continue;
|
||||
|
||||
memset(addrmask.ptr, 0xFF, sizeof(addrmask));
|
||||
nm_utils_ip6_address_clear_host_address(&addrmask.val, &addrmask.val, plen);
|
||||
nm_ip6_addr_clear_host_address(&addrmask.val, &addrmask.val, plen);
|
||||
|
||||
memset(addrmask_bit.ptr, 0xFF, sizeof(addrmask_bit));
|
||||
nm_utils_ip6_address_clear_host_address(&addrmask_bit.val, &addrmask_bit.val, plen - 1);
|
||||
nm_ip6_addr_clear_host_address(&addrmask_bit.val, &addrmask_bit.val, plen - 1);
|
||||
|
||||
for (i = 0; i < sizeof(a); i++)
|
||||
b.ptr[i] = (a.ptr[i] & addrmask.ptr[i]) | (b.ptr[i] & ~addrmask.ptr[i]);
|
||||
|
|
@ -254,7 +254,7 @@ again_plen:
|
|||
}
|
||||
g_assert(reached);
|
||||
|
||||
g_assert(nm_utils_ip6_address_same_prefix(&a.val, &b.val, plen) == FALSE);
|
||||
g_assert(nm_ip6_addr_same_prefix(&a.val, &b.val, plen) == FALSE);
|
||||
}
|
||||
|
||||
/* test#4 */
|
||||
|
|
@ -2594,10 +2594,9 @@ main(int argc, char **argv)
|
|||
|
||||
g_test_add_func("/general/nm_strbuf_append", test_nm_utils_strbuf_append);
|
||||
|
||||
g_test_add_func("/general/nm_utils_ip6_address_clear_host_address",
|
||||
g_test_add_func("/general/nm_ip6_addr_clear_host_address",
|
||||
test_nm_utils_ip6_address_clear_host_address);
|
||||
g_test_add_func("/general/nm_utils_ip6_address_same_prefix",
|
||||
test_nm_utils_ip6_address_same_prefix);
|
||||
g_test_add_func("/general/nm_ip6_addr_same_prefix", test_nm_ip_addr_same_prefix);
|
||||
g_test_add_func("/general/nm_utils_log_connection_diff", test_nm_utils_log_connection_diff);
|
||||
|
||||
g_test_add_func("/general/nm_utils_sysctl_ip_conf_path", test_nm_utils_sysctl_ip_conf_path);
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg *l3cfg,
|
|||
const NML3ConfigNotifyData *notify_data,
|
||||
TestL3IPv4LLData *tdata)
|
||||
{
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_assert(NM_IS_L3CFG(l3cfg));
|
||||
g_assert(tdata);
|
||||
|
|
@ -593,9 +593,9 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg *l3cfg,
|
|||
if (tdata->f->test_idx == 2 && nmtst_get_rand_bool()) {
|
||||
tdata->addr_commit++;
|
||||
tdata->addr_commit_addr = nm_l3_ipv4ll_get_addr(tdata->l3ipv4ll);
|
||||
g_assert(nm_utils_ip4_address_is_link_local(tdata->addr_commit_addr));
|
||||
g_assert(nm_ip4_addr_is_link_local(tdata->addr_commit_addr));
|
||||
_LOGT("add address %s that passed ACD",
|
||||
_nm_utils_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
|
||||
nm_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
|
||||
if (!nm_l3cfg_add_config(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll),
|
||||
TEST_L3_IPV4LL_TAG(tdata, 1),
|
||||
nmtst_get_rand_bool(),
|
||||
|
|
@ -630,9 +630,9 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg *l3cfg,
|
|||
if (tdata->addr_commit > 0) {
|
||||
g_assert_cmpint(tdata->addr_commit, ==, 1);
|
||||
tdata->addr_commit--;
|
||||
g_assert(nm_utils_ip4_address_is_link_local(tdata->addr_commit_addr));
|
||||
g_assert(nm_ip4_addr_is_link_local(tdata->addr_commit_addr));
|
||||
_LOGT("remove address %s that previously passed ACD",
|
||||
_nm_utils_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
|
||||
nm_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
|
||||
if (!nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll),
|
||||
TEST_L3_IPV4LL_TAG(tdata, 1)))
|
||||
g_assert_not_reached();
|
||||
|
|
@ -663,7 +663,7 @@ test_l3_ipv4ll(gconstpointer test_data)
|
|||
gint64 start_time_msec;
|
||||
gint64 total_poll_time_msec;
|
||||
nm_auto_remove_l3ipv4ll_registration NML3IPv4LLRegistration *l3ipv4ll_reg = NULL;
|
||||
char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGD("test start (/l3-ipv4ll/%d)", TEST_IDX);
|
||||
|
||||
|
|
@ -733,12 +733,12 @@ test_l3_ipv4ll(gconstpointer test_data)
|
|||
if (tdata->f->test_idx == 2 && nmtst_get_rand_one_case_in(3)) {
|
||||
in_addr_t a = nm_l3_ipv4ll_get_addr(l3ipv4ll);
|
||||
|
||||
g_assert(nm_utils_ip4_address_is_link_local(a));
|
||||
g_assert(nm_ip4_addr_is_link_local(a));
|
||||
_test_l3_ipv4ll_maybe_add_addr_4(tdata,
|
||||
tdata->f->ifindex1,
|
||||
2,
|
||||
&tdata->add_conflict_done,
|
||||
_nm_utils_inet4_ntop(a, sbuf_addr));
|
||||
nm_inet4_ntop(a, sbuf_addr));
|
||||
g_assert_cmpint(tdata->f->hwaddr1.len, ==, sizeof(NMEtherAddr));
|
||||
acd_defender_2 =
|
||||
nmtstp_acd_defender_new(tdata->f->ifindex1, a, &tdata->f->hwaddr1.ether_addr);
|
||||
|
|
@ -768,12 +768,11 @@ test_l3_ipv4ll(gconstpointer test_data)
|
|||
|
||||
if (tdata->addr_commit == 1 && !tdata->add_conflict_checked) {
|
||||
tdata->add_conflict_checked = TRUE;
|
||||
_test_l3_ipv4ll_maybe_add_addr_4(
|
||||
tdata,
|
||||
tdata->f->ifindex1,
|
||||
2,
|
||||
&tdata->add_conflict_done,
|
||||
_nm_utils_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
|
||||
_test_l3_ipv4ll_maybe_add_addr_4(tdata,
|
||||
tdata->f->ifindex1,
|
||||
2,
|
||||
&tdata->add_conflict_done,
|
||||
nm_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
|
||||
if (tdata->add_conflict_done)
|
||||
total_poll_time_msec += L3IPV4LL_ACD_TIMEOUT_MSEC / 2;
|
||||
g_assert_cmpint(tdata->f->hwaddr1.len, ==, sizeof(NMEtherAddr));
|
||||
|
|
|
|||
|
|
@ -1217,7 +1217,7 @@ _parent_device_l3cd_add_gateway_route(NML3ConfigData *l3cd,
|
|||
if (!nm_ip_addr_is_null(addr_family, gw)) {
|
||||
nm_ip_addr_set(addr_family, &parent_gw, gw);
|
||||
has_parent_gw = TRUE;
|
||||
} else if (nm_utils_ip_is_site_local(addr_family, vpn_gw))
|
||||
} else if (nm_ip_addr_is_site_local(addr_family, vpn_gw))
|
||||
has_parent_gw = TRUE;
|
||||
else if ((obj = nm_device_get_best_default_route(parent_device, addr_family))
|
||||
&& nm_ip_addr_is_null(
|
||||
|
|
@ -2104,9 +2104,8 @@ _dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict
|
|||
|
||||
if (plen > 32)
|
||||
break;
|
||||
route.r4.plen = plen;
|
||||
route.r4.network =
|
||||
nm_utils_ip4_address_clear_host_address(route.r4.network, plen);
|
||||
route.r4.plen = plen;
|
||||
route.r4.network = nm_ip4_addr_clear_host_address(route.r4.network, plen);
|
||||
|
||||
if (priv->ip_data_4.gw_external.addr4
|
||||
&& route.r4.network == priv->ip_data_4.gw_external.addr4
|
||||
|
|
@ -2146,9 +2145,7 @@ _dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict
|
|||
|
||||
nm_ip_addr_set_from_variant(AF_INET6, &route.r6.gateway, next_hop, NULL);
|
||||
|
||||
nm_utils_ip6_address_clear_host_address(&route.r6.network,
|
||||
&route.r6.network,
|
||||
route.r6.plen);
|
||||
nm_ip6_addr_clear_host_address(&route.r6.network, &route.r6.network, route.r6.plen);
|
||||
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&priv->ip_data_6.gw_external.addr6)
|
||||
&& IN6_ARE_ADDR_EQUAL(&route.r6.network, &priv->ip_data_6.gw_external.addr6)
|
||||
|
|
|
|||
|
|
@ -271,11 +271,11 @@ nm_conn_wireguard_import(const char *filename, GError **error)
|
|||
int addr_family;
|
||||
int prefix_len;
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC,
|
||||
value_word,
|
||||
&addr_family,
|
||||
&addr_bin,
|
||||
&prefix_len))
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_UNSPEC,
|
||||
value_word,
|
||||
&addr_family,
|
||||
&addr_bin,
|
||||
&prefix_len))
|
||||
goto fail_invalid_value;
|
||||
|
||||
p_data_addr = (addr_family == AF_INET) ? &data_addr_v4 : &data_addr_v6;
|
||||
|
|
@ -315,13 +315,12 @@ nm_conn_wireguard_import(const char *filename, GError **error)
|
|||
NMIPAddr addr_bin;
|
||||
int addr_family;
|
||||
|
||||
if (nm_utils_parse_inaddr_bin(AF_UNSPEC, value_word, &addr_family, &addr_bin)) {
|
||||
if (nm_inet_parse_bin(AF_UNSPEC, value_word, &addr_family, &addr_bin)) {
|
||||
p_data_dns = (addr_family == AF_INET) ? &data_dns_v4 : &data_dns_v6;
|
||||
if (!*p_data_dns)
|
||||
*p_data_dns = g_ptr_array_new_with_free_func(g_free);
|
||||
|
||||
g_ptr_array_add(*p_data_dns,
|
||||
nm_utils_inet_ntop_dup(addr_family, &addr_bin));
|
||||
g_ptr_array_add(*p_data_dns, nm_inet_ntop_dup(addr_family, &addr_bin));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -175,9 +175,7 @@ _notify_update_prop_nameservers(NMClient *client,
|
|||
|
||||
if (!g_variant_is_of_type(val, G_VARIANT_TYPE_STRING))
|
||||
goto next;
|
||||
if (!nm_utils_parse_inaddr(AF_INET,
|
||||
g_variant_get_string(val, NULL),
|
||||
&val_str))
|
||||
if (!nm_inet_parse_str(AF_INET, g_variant_get_string(val, NULL), &val_str))
|
||||
goto next;
|
||||
if (!arr)
|
||||
arr = g_ptr_array_new();
|
||||
|
|
|
|||
|
|
@ -1306,11 +1306,11 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters)
|
|||
&& nm_setting_ip6_config_get_addr_gen_mode((NMSettingIP6Config *) s_ip6)
|
||||
== NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) {
|
||||
struct in6_addr i6_token;
|
||||
char normalized[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char normalized[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (inet_pton(AF_INET6, token, &i6_token) == 1
|
||||
&& _nm_utils_inet6_is_token(&i6_token)) {
|
||||
_nm_utils_inet6_ntop(&i6_token, normalized);
|
||||
nm_inet6_ntop(&i6_token, normalized);
|
||||
if (g_strcmp0(token, normalized)) {
|
||||
g_object_set(s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, normalized, NULL);
|
||||
changed = TRUE;
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ build_route(KeyfileReaderInfo *info,
|
|||
|
||||
/* Next hop */
|
||||
if (gateway_str && gateway_str[0]) {
|
||||
if (!nm_utils_ipaddr_is_valid(family, gateway_str)) {
|
||||
if (!nm_inet_is_valid(family, gateway_str)) {
|
||||
/* Try workaround for routes written by broken keyfile writer.
|
||||
* Due to bug bgo#719851, an older version of writer would have
|
||||
* written "a:b:c:d::/plen,metric" if the gateway was ::, instead
|
||||
|
|
@ -3692,7 +3692,7 @@ _read_setting_wireguard_peer(KeyfileReaderInfo *info)
|
|||
gsize i;
|
||||
|
||||
for (i = 0; i < n_sa; i++) {
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC, sa[i], NULL, NULL, NULL)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_UNSPEC, sa[i], NULL, NULL, NULL)) {
|
||||
has_error = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ validate_ip(const char *name, const char *value, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
for (i = 0; addrs[i]; i++) {
|
||||
if (!nm_utils_parse_inaddr_bin(AF_INET, addrs[i], NULL, NULL)) {
|
||||
if (!nm_inet_parse_bin(AF_INET, addrs[i], NULL, NULL)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ canonicalize_ip_binary(int family, const NMIPAddr *ip, gboolean null_any)
|
|||
if (null_any && nm_ip_addr_is_null(family, ip))
|
||||
return NULL;
|
||||
|
||||
return nm_utils_inet_ntop_dup(family, ip);
|
||||
return nm_inet_ntop_dup(family, ip);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -80,7 +80,7 @@ valid_ip(int family, const char *ip, NMIPAddr *addr, GError **error)
|
|||
family == AF_INET ? _("Missing IPv4 address") : _("Missing IPv6 address"));
|
||||
return FALSE;
|
||||
}
|
||||
if (!nm_utils_parse_inaddr_bin(family, ip, NULL, addr)) {
|
||||
if (!nm_inet_parse_bin(family, ip, NULL, addr)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_FAILED,
|
||||
|
|
@ -210,7 +210,7 @@ nm_ip_address_new_binary(int family, gconstpointer addr, guint prefix, GError **
|
|||
*address = (NMIPAddress){
|
||||
.refcount = 1,
|
||||
.family = family,
|
||||
.address = nm_utils_inet_ntop_dup(family, addr),
|
||||
.address = nm_inet_ntop_dup(family, addr),
|
||||
.prefix = prefix,
|
||||
};
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ nm_ip_address_set_address(NMIPAddress *address, const char *addr)
|
|||
|
||||
if (!valid_ip(address->family, addr, &addr_bin, NULL)) {
|
||||
g_return_if_fail(addr != NULL);
|
||||
g_return_if_fail(nm_utils_ipaddr_is_valid(address->family, addr));
|
||||
g_return_if_fail(nm_inet_is_valid(address->family, addr));
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ nm_ip_address_set_address_binary(NMIPAddress *address, gconstpointer addr)
|
|||
g_return_if_fail(addr != NULL);
|
||||
|
||||
g_free(address->address);
|
||||
address->address = nm_utils_inet_ntop_dup(address->family, addr);
|
||||
address->address = nm_inet_ntop_dup(address->family, addr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -883,7 +883,7 @@ nm_ip_route_get_dest(NMIPRoute *route)
|
|||
* Sets the destination property of this route object.
|
||||
*
|
||||
* @dest must be a valid address of @route's family. If you aren't sure you
|
||||
* have a valid address, use nm_utils_ipaddr_is_valid() to check it.
|
||||
* have a valid address, use nm_inet_is_valid() to check it.
|
||||
**/
|
||||
void
|
||||
nm_ip_route_set_dest(NMIPRoute *route, const char *dest)
|
||||
|
|
@ -893,7 +893,7 @@ nm_ip_route_set_dest(NMIPRoute *route, const char *dest)
|
|||
g_return_if_fail(route != NULL);
|
||||
|
||||
if (!valid_ip(route->family, dest, &dest_bin, NULL)) {
|
||||
g_return_if_fail(nm_utils_ipaddr_is_valid(route->family, dest));
|
||||
g_return_if_fail(nm_inet_is_valid(route->family, dest));
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
|
|
@ -935,7 +935,7 @@ nm_ip_route_set_dest_binary(NMIPRoute *route, gconstpointer dest)
|
|||
g_return_if_fail(dest != NULL);
|
||||
|
||||
g_free(route->dest);
|
||||
route->dest = nm_utils_inet_ntop_dup(route->family, dest);
|
||||
route->dest = nm_inet_ntop_dup(route->family, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1008,7 +1008,7 @@ nm_ip_route_set_next_hop(NMIPRoute *route, const char *next_hop)
|
|||
g_return_if_fail(route != NULL);
|
||||
|
||||
if (next_hop && !valid_ip(route->family, next_hop, &next_hop_bin, NULL)) {
|
||||
g_return_if_fail(!next_hop || nm_utils_ipaddr_is_valid(route->family, next_hop));
|
||||
g_return_if_fail(!next_hop || nm_inet_is_valid(route->family, next_hop));
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
|
|
@ -1352,7 +1352,7 @@ _ip_route_attribute_validate(const char *name,
|
|||
switch (spec->type_detail) {
|
||||
case 'a': /* IP address */
|
||||
string = g_variant_get_string(value, NULL);
|
||||
if (!nm_utils_ipaddr_is_valid(family, string)) {
|
||||
if (!nm_inet_is_valid(family, string)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_FAILED,
|
||||
|
|
@ -1384,7 +1384,7 @@ _ip_route_attribute_validate(const char *name,
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!nm_utils_ipaddr_is_valid(family, addr)) {
|
||||
if (!nm_inet_is_valid(family, addr)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_FAILED,
|
||||
|
|
@ -1911,7 +1911,7 @@ nm_ip_routing_rule_get_from(const NMIPRoutingRule *self)
|
|||
if (!self->from_str) {
|
||||
nm_assert(self->from_valid);
|
||||
((NMIPRoutingRule *) self)->from_str =
|
||||
nm_utils_inet_ntop_dup(_ip_routing_rule_get_addr_family(self), &self->from_bin);
|
||||
nm_inet_ntop_dup(_ip_routing_rule_get_addr_family(self), &self->from_bin);
|
||||
}
|
||||
return self->from_str;
|
||||
}
|
||||
|
|
@ -1968,12 +1968,10 @@ nm_ip_routing_rule_set_from(NMIPRoutingRule *self, const char *from, guint8 len)
|
|||
}
|
||||
|
||||
nm_clear_g_free(&self->from_str);
|
||||
self->from_has = TRUE;
|
||||
self->from_len = len;
|
||||
self->from_valid = nm_utils_parse_inaddr_bin(_ip_routing_rule_get_addr_family(self),
|
||||
from,
|
||||
NULL,
|
||||
&self->from_bin);
|
||||
self->from_has = TRUE;
|
||||
self->from_len = len;
|
||||
self->from_valid =
|
||||
nm_inet_parse_bin(_ip_routing_rule_get_addr_family(self), from, NULL, &self->from_bin);
|
||||
if (!self->from_valid)
|
||||
self->from_str = g_strdup(from);
|
||||
}
|
||||
|
|
@ -2013,7 +2011,7 @@ nm_ip_routing_rule_get_to(const NMIPRoutingRule *self)
|
|||
if (!self->to_str) {
|
||||
nm_assert(self->to_valid);
|
||||
((NMIPRoutingRule *) self)->to_str =
|
||||
nm_utils_inet_ntop_dup(_ip_routing_rule_get_addr_family(self), &self->to_bin);
|
||||
nm_inet_ntop_dup(_ip_routing_rule_get_addr_family(self), &self->to_bin);
|
||||
}
|
||||
return self->to_str;
|
||||
}
|
||||
|
|
@ -2074,7 +2072,7 @@ nm_ip_routing_rule_set_to(NMIPRoutingRule *self, const char *to, guint8 len)
|
|||
self->to_has = TRUE;
|
||||
self->to_len = len;
|
||||
self->to_valid =
|
||||
nm_utils_parse_inaddr_bin(_ip_routing_rule_get_addr_family(self), to, NULL, &self->to_bin);
|
||||
nm_inet_parse_bin(_ip_routing_rule_get_addr_family(self), to, NULL, &self->to_bin);
|
||||
if (!self->to_valid)
|
||||
self->to_str = g_strdup(to);
|
||||
}
|
||||
|
|
@ -3167,7 +3165,7 @@ GVariant *
|
|||
nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self)
|
||||
{
|
||||
GVariantBuilder builder;
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
|
||||
g_return_val_if_fail(NM_IS_IP_ROUTING_RULE(self, TRUE), NULL);
|
||||
|
||||
|
|
@ -3220,9 +3218,9 @@ nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self)
|
|||
&builder,
|
||||
RR_DBUS_ATTR_FROM,
|
||||
g_variant_new_string(self->from_str
|
||||
?: nm_utils_inet_ntop(_ip_routing_rule_get_addr_family(self),
|
||||
&self->from_bin,
|
||||
addr_str)));
|
||||
?: nm_inet_ntop(_ip_routing_rule_get_addr_family(self),
|
||||
&self->from_bin,
|
||||
addr_str)));
|
||||
_rr_to_dbus_add(&builder, RR_DBUS_ATTR_FROM_LEN, g_variant_new_byte(self->from_len));
|
||||
}
|
||||
|
||||
|
|
@ -3231,9 +3229,9 @@ nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self)
|
|||
&builder,
|
||||
RR_DBUS_ATTR_TO,
|
||||
g_variant_new_string(self->to_str
|
||||
?: nm_utils_inet_ntop(_ip_routing_rule_get_addr_family(self),
|
||||
&self->to_bin,
|
||||
addr_str)));
|
||||
?: nm_inet_ntop(_ip_routing_rule_get_addr_family(self),
|
||||
&self->to_bin,
|
||||
addr_str)));
|
||||
_rr_to_dbus_add(&builder, RR_DBUS_ATTR_TO_LEN, g_variant_new_byte(self->to_len));
|
||||
}
|
||||
|
||||
|
|
@ -3632,11 +3630,11 @@ next_words_consumed:
|
|||
}
|
||||
|
||||
if (!NM_IN_STRSET(word_from, NULL, "all")) {
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(addr_family,
|
||||
word_from,
|
||||
&addr_family,
|
||||
&val_from,
|
||||
&val_from_len)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(addr_family,
|
||||
word_from,
|
||||
&addr_family,
|
||||
&val_from,
|
||||
&val_from_len)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_FAILED,
|
||||
|
|
@ -3648,11 +3646,11 @@ next_words_consumed:
|
|||
}
|
||||
|
||||
if (!NM_IN_STRSET(word_to, NULL, "all")) {
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(addr_family,
|
||||
word_to,
|
||||
&addr_family,
|
||||
&val_to,
|
||||
&val_to_len)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(addr_family,
|
||||
word_to,
|
||||
&addr_family,
|
||||
&val_to,
|
||||
&val_to_len)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_FAILED,
|
||||
|
|
@ -3751,7 +3749,7 @@ _rr_string_append_inet_addr(NMStrBuf *str,
|
|||
const NMIPAddr *addr_bin,
|
||||
guint8 addr_len)
|
||||
{
|
||||
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addr_str[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (addr_len == 0) {
|
||||
if (required) {
|
||||
|
|
@ -3766,7 +3764,7 @@ _rr_string_append_inet_addr(NMStrBuf *str,
|
|||
nm_str_buf_append_printf(nm_str_buf_append_required_delimiter(str, ' '),
|
||||
"%s %s",
|
||||
is_from ? "from" : "to",
|
||||
nm_utils_inet_ntop(addr_family, addr_bin, addr_str));
|
||||
nm_inet_ntop(addr_family, addr_bin, addr_str));
|
||||
if (addr_len != nm_utils_addr_family_to_size(addr_family) * 8) {
|
||||
nm_str_buf_append_printf(str, "/%u", addr_len);
|
||||
}
|
||||
|
|
@ -4058,7 +4056,7 @@ nm_setting_ip_config_add_dns(NMSettingIPConfig *setting, const char *dns)
|
|||
NMSettingIPConfigPrivate *priv;
|
||||
int addr_family;
|
||||
NMIPAddr dns_bin;
|
||||
char dns_canonical[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char dns_canonical[NM_INET_ADDRSTRLEN];
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), FALSE);
|
||||
|
|
@ -4067,13 +4065,13 @@ nm_setting_ip_config_add_dns(NMSettingIPConfig *setting, const char *dns)
|
|||
|
||||
if (!valid_ip(addr_family, dns, &dns_bin, NULL)) {
|
||||
g_return_val_if_fail(dns != NULL, FALSE);
|
||||
g_return_val_if_fail(nm_utils_ipaddr_is_valid(addr_family, dns), FALSE);
|
||||
g_return_val_if_fail(nm_inet_is_valid(addr_family, dns), FALSE);
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting);
|
||||
|
||||
nm_utils_inet_ntop(addr_family, &dns_bin, dns_canonical);
|
||||
nm_inet_ntop(addr_family, &dns_bin, dns_canonical);
|
||||
|
||||
for (i = 0; i < priv->dns->len; i++) {
|
||||
if (nm_streq(dns_canonical, priv->dns->pdata[i]))
|
||||
|
|
@ -4121,7 +4119,7 @@ nm_setting_ip_config_remove_dns_by_value(NMSettingIPConfig *setting, const char
|
|||
NMSettingIPConfigPrivate *priv;
|
||||
int addr_family;
|
||||
NMIPAddr dns_bin;
|
||||
char dns_canonical[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char dns_canonical[NM_INET_ADDRSTRLEN];
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), FALSE);
|
||||
|
|
@ -4130,13 +4128,13 @@ nm_setting_ip_config_remove_dns_by_value(NMSettingIPConfig *setting, const char
|
|||
|
||||
if (!valid_ip(addr_family, dns, &dns_bin, NULL)) {
|
||||
g_return_val_if_fail(dns != NULL, FALSE);
|
||||
g_return_val_if_fail(nm_utils_ipaddr_is_valid(addr_family, dns), FALSE);
|
||||
g_return_val_if_fail(nm_inet_is_valid(addr_family, dns), FALSE);
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting);
|
||||
|
||||
nm_utils_inet_ntop(addr_family, &dns_bin, dns_canonical);
|
||||
nm_inet_ntop(addr_family, &dns_bin, dns_canonical);
|
||||
|
||||
for (i = 0; i < priv->dns->len; i++) {
|
||||
if (nm_streq(dns_canonical, priv->dns->pdata[i])) {
|
||||
|
|
@ -5441,7 +5439,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
for (i = 0; i < priv->dns->len; i++) {
|
||||
const char *dns = priv->dns->pdata[i];
|
||||
|
||||
if (!nm_utils_ipaddr_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), dns)) {
|
||||
if (!nm_inet_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), dns)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -5517,7 +5515,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!nm_utils_ipaddr_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), priv->gateway)) {
|
||||
if (!nm_inet_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), priv->gateway)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -5649,7 +5647,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
|
||||
for (i = 0; i < priv->dhcp_reject_servers->len; i++) {
|
||||
if (!nm_utils_parse_inaddr_prefix(
|
||||
if (!nm_inet_parse_with_prefix_str(
|
||||
NM_SETTING_IP_CONFIG_GET_FAMILY(setting),
|
||||
g_array_index(priv->dhcp_reject_servers, const char *, i),
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->local && !nm_utils_ipaddr_is_valid(family, priv->local)) {
|
||||
if (priv->local && !nm_inet_is_valid(family, priv->local)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -392,7 +392,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!nm_utils_ipaddr_is_valid(family, priv->remote)) {
|
||||
if (!nm_inet_is_valid(family, priv->remote)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
if (priv->token) {
|
||||
if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) {
|
||||
struct in6_addr i6_token;
|
||||
char s_token[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_token[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (inet_pton(AF_INET6, priv->token, &i6_token) != 1
|
||||
|| !_nm_utils_inet6_is_token(&i6_token)) {
|
||||
|
|
@ -320,7 +320,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(priv->token, _nm_utils_inet6_ntop(&i6_token, s_token)))
|
||||
if (g_strcmp0(priv->token, nm_inet6_ntop(&i6_token, s_token)))
|
||||
token_needs_normalization = TRUE;
|
||||
} else {
|
||||
g_set_error_literal(error,
|
||||
|
|
|
|||
|
|
@ -344,9 +344,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
gboolean remote_is_valid = TRUE;
|
||||
gboolean local_is_valid = TRUE;
|
||||
|
||||
if (priv->remote && !nm_utils_parse_inaddr_bin(addr_family, priv->remote, &addr_family, NULL))
|
||||
if (priv->remote && !nm_inet_parse_bin(addr_family, priv->remote, &addr_family, NULL))
|
||||
remote_is_valid = FALSE;
|
||||
if (priv->local && !nm_utils_parse_inaddr_bin(addr_family, priv->local, &addr_family, NULL))
|
||||
if (priv->local && !nm_inet_parse_bin(addr_family, priv->local, &addr_family, NULL))
|
||||
local_is_valid = FALSE;
|
||||
|
||||
if (!remote_is_valid) {
|
||||
|
|
|
|||
|
|
@ -628,18 +628,18 @@ _peer_append_allowed_ip(NMWireGuardPeer *self, const char *allowed_ip, gboolean
|
|||
|
||||
/* normalize the address (if it is valid. Otherwise, take it
|
||||
* as-is (it will render the instance invalid). */
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC, allowed_ip, &addr_family, &addrbin, &prefix)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_UNSPEC, allowed_ip, &addr_family, &addrbin, &prefix)) {
|
||||
if (!accept_invalid)
|
||||
return FALSE;
|
||||
/* mark the entry as invalid by having a "X" prefix. */
|
||||
str = g_strconcat(ALLOWED_IP_INVALID_X_STR, allowed_ip, NULL);
|
||||
is_valid = FALSE;
|
||||
} else {
|
||||
char addrstr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addrstr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_assert_addr_family(addr_family);
|
||||
|
||||
nm_utils_inet_ntop(addr_family, &addrbin, addrstr);
|
||||
nm_inet_ntop(addr_family, &addrbin, addrstr);
|
||||
if (prefix >= 0)
|
||||
str = g_strdup_printf("%s/%d", addrstr, prefix);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ nm_sock_addr_endpoint_get_fixed_sockaddr(NMSockAddrEndpoint *self, gpointer sock
|
|||
if (!self->host)
|
||||
return FALSE;
|
||||
|
||||
if (nm_utils_parse_inaddr_bin(AF_UNSPEC, self->host, &addr_family, &addrbin))
|
||||
if (nm_inet_parse_bin(AF_UNSPEC, self->host, &addr_family, &addrbin))
|
||||
goto good;
|
||||
|
||||
/* See if there is an IPv6 scope-id...
|
||||
|
|
@ -295,7 +295,7 @@ nm_sock_addr_endpoint_get_fixed_sockaddr(NMSockAddrEndpoint *self, gpointer sock
|
|||
const char *host_part;
|
||||
|
||||
host_part = nm_strndup_a(200, self->host, s - self->host, &tmp_str);
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET6, host_part, &addr_family, &addrbin))
|
||||
if (nm_inet_parse_bin(AF_INET6, host_part, &addr_family, &addrbin))
|
||||
goto good;
|
||||
}
|
||||
|
||||
|
|
@ -1346,7 +1346,7 @@ nm_utils_ip4_dns_from_variant(GVariant *value)
|
|||
array = g_variant_get_fixed_array(value, &length, sizeof(guint32));
|
||||
dns = g_new(char *, length + 1u);
|
||||
for (i = 0; i < length; i++)
|
||||
dns[i] = nm_utils_inet4_ntop_dup(array[i]);
|
||||
dns[i] = nm_inet4_ntop_dup(array[i]);
|
||||
dns[i] = NULL;
|
||||
|
||||
return dns;
|
||||
|
|
@ -1449,7 +1449,7 @@ nm_utils_ip4_addresses_from_variant(GVariant *value, char **out_gateway)
|
|||
g_ptr_array_add(addresses, addr);
|
||||
|
||||
if (addr_array[2] && out_gateway && !*out_gateway)
|
||||
*out_gateway = nm_utils_inet4_ntop_dup(addr_array[2]);
|
||||
*out_gateway = nm_inet4_ntop_dup(addr_array[2]);
|
||||
} else {
|
||||
g_warning("Ignoring invalid IP4 address: %s", error->message);
|
||||
g_clear_error(&error);
|
||||
|
|
@ -1571,7 +1571,7 @@ nm_utils_ip4_routes_from_variant(GVariant *value)
|
|||
guint32
|
||||
nm_utils_ip4_netmask_to_prefix(guint32 netmask)
|
||||
{
|
||||
return _nm_utils_ip4_netmask_to_prefix(netmask);
|
||||
return nm_ip4_addr_netmask_to_prefix(netmask);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1585,7 +1585,7 @@ nm_utils_ip4_prefix_to_netmask(guint32 prefix)
|
|||
{
|
||||
g_return_val_if_fail(prefix <= 32, 0xffffffffu);
|
||||
|
||||
return _nm_utils_ip4_prefix_to_netmask(prefix);
|
||||
return nm_ip4_addr_netmask_from_prefix(prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1603,7 +1603,7 @@ nm_utils_ip4_prefix_to_netmask(guint32 prefix)
|
|||
guint32
|
||||
nm_utils_ip4_get_default_prefix(guint32 ip)
|
||||
{
|
||||
return _nm_utils_ip4_get_default_prefix(ip);
|
||||
return nm_ip4_addr_get_default_prefix(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1676,7 +1676,7 @@ nm_utils_ip6_dns_from_variant(GVariant *value)
|
|||
const struct in6_addr *ip = g_variant_get_fixed_array(ip_var, &length, 1);
|
||||
|
||||
if (length == sizeof(struct in6_addr))
|
||||
dns[i++] = nm_utils_inet6_ntop_dup(ip);
|
||||
dns[i++] = nm_inet6_ntop_dup(ip);
|
||||
|
||||
g_variant_unref(ip_var);
|
||||
}
|
||||
|
|
@ -1798,7 +1798,7 @@ nm_utils_ip6_addresses_from_variant(GVariant *value, char **out_gateway)
|
|||
goto next;
|
||||
}
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(gateway_bytes))
|
||||
*out_gateway = nm_utils_inet6_ntop_dup(gateway_bytes);
|
||||
*out_gateway = nm_inet6_ntop_dup(gateway_bytes);
|
||||
}
|
||||
} else {
|
||||
g_warning("Ignoring invalid IP6 address: %s", error->message);
|
||||
|
|
@ -3825,13 +3825,13 @@ _nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip, gboolean
|
|||
if (!ip)
|
||||
return NULL;
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, ip, &addr_family, &addr_bin))
|
||||
if (!nm_inet_parse_bin(addr_family, ip, &addr_family, &addr_bin))
|
||||
return g_strdup(ip);
|
||||
|
||||
if (map_zero_to_null && nm_ip_addr_is_null(addr_family, &addr_bin))
|
||||
return NULL;
|
||||
|
||||
return nm_utils_inet_ntop_dup(addr_family, &addr_bin);
|
||||
return nm_inet_ntop_dup(addr_family, &addr_bin);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -4363,13 +4363,13 @@ nm_utils_is_uuid(const char *str)
|
|||
return nm_uuid_is_valid_nmlegacy(str);
|
||||
}
|
||||
|
||||
static _nm_thread_local char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN];
|
||||
static _nm_thread_local char _nm_utils_inet_ntop_buffer[NM_INET_ADDRSTRLEN];
|
||||
|
||||
/**
|
||||
* nm_utils_inet4_ntop: (skip)
|
||||
* @inaddr: the address that should be converted to string.
|
||||
* @dst: the destination buffer, it must contain at least
|
||||
* <literal>INET_ADDRSTRLEN</literal> or %NM_UTILS_INET_ADDRSTRLEN
|
||||
* <literal>INET_ADDRSTRLEN</literal> or %NM_INET_ADDRSTRLEN
|
||||
* characters. If set to %NULL, it will return a pointer to an internal, static
|
||||
* buffer (shared with nm_utils_inet6_ntop()). Beware, that the internal
|
||||
* buffer will be overwritten with ever new call of nm_utils_inet4_ntop() or
|
||||
|
|
@ -4391,14 +4391,14 @@ nm_utils_inet4_ntop(in_addr_t inaddr, char *dst)
|
|||
*
|
||||
* However, still support it to be lenient against mistakes and because
|
||||
* this is public API of libnm. */
|
||||
return _nm_utils_inet4_ntop(inaddr, dst ?: _nm_utils_inet_ntop_buffer);
|
||||
return nm_inet4_ntop(inaddr, dst ?: _nm_utils_inet_ntop_buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_inet6_ntop: (skip)
|
||||
* @in6addr: the address that should be converted to string.
|
||||
* @dst: the destination buffer, it must contain at least
|
||||
* <literal>INET6_ADDRSTRLEN</literal> or %NM_UTILS_INET_ADDRSTRLEN
|
||||
* <literal>INET6_ADDRSTRLEN</literal> or %NM_INET_ADDRSTRLEN
|
||||
* characters. If set to %NULL, it will return a pointer to an internal, static
|
||||
* buffer (shared with nm_utils_inet4_ntop()). Beware, that the internal
|
||||
* buffer will be overwritten with ever new call of nm_utils_inet4_ntop() or
|
||||
|
|
@ -4422,7 +4422,7 @@ nm_utils_inet6_ntop(const struct in6_addr *in6addr, char *dst)
|
|||
* However, still support it to be lenient against mistakes and because
|
||||
* this is public API of libnm. */
|
||||
g_return_val_if_fail(in6addr, NULL);
|
||||
return _nm_utils_inet6_ntop(in6addr, dst ?: _nm_utils_inet_ntop_buffer);
|
||||
return nm_inet6_ntop(in6addr, dst ?: _nm_utils_inet_ntop_buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4440,7 +4440,7 @@ nm_utils_ipaddr_valid(int family, const char *ip)
|
|||
{
|
||||
g_return_val_if_fail(family == AF_INET || family == AF_INET6 || family == AF_UNSPEC, FALSE);
|
||||
|
||||
return nm_utils_ipaddr_is_valid(family, ip);
|
||||
return nm_inet_is_valid(family, ip);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5058,7 +5058,7 @@ _netmask_to_prefix(guint32 netmask)
|
|||
|
||||
/* we re-implemented the netmask-to-prefix code differently. Check
|
||||
* that they agree. */
|
||||
g_assert_cmpint(prefix, ==, _nm_utils_ip4_netmask_to_prefix(netmask));
|
||||
g_assert_cmpint(prefix, ==, nm_ip4_addr_netmask_to_prefix(netmask));
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
|
@ -5069,7 +5069,7 @@ test_ip4_prefix_to_netmask(void)
|
|||
int i;
|
||||
|
||||
for (i = 0; i <= 32; i++) {
|
||||
guint32 netmask = _nm_utils_ip4_prefix_to_netmask(i);
|
||||
guint32 netmask = nm_ip4_addr_netmask_from_prefix(i);
|
||||
int plen = _netmask_to_prefix(netmask);
|
||||
|
||||
g_assert_cmpint(i, ==, plen);
|
||||
|
|
@ -5097,8 +5097,8 @@ test_ip4_netmask_to_prefix(void)
|
|||
g_rand_set_seed(rand, 1);
|
||||
|
||||
for (i = 2; i <= 32; i++) {
|
||||
guint32 netmask = _nm_utils_ip4_prefix_to_netmask(i);
|
||||
guint32 netmask_lowest_bit = netmask & ~_nm_utils_ip4_prefix_to_netmask(i - 1);
|
||||
guint32 netmask = nm_ip4_addr_netmask_from_prefix(i);
|
||||
guint32 netmask_lowest_bit = netmask & ~nm_ip4_addr_netmask_from_prefix(i - 1);
|
||||
|
||||
g_assert_cmpint(i, ==, _netmask_to_prefix(netmask));
|
||||
|
||||
|
|
@ -7140,7 +7140,7 @@ _sock_addr_endpoint_fixed(const char *endpoint, const char *host, guint16 port,
|
|||
g_assert(host);
|
||||
g_assert(port > 0);
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin(AF_UNSPEC, host, &addr_family, &addrbin))
|
||||
if (!nm_inet_parse_bin(AF_UNSPEC, host, &addr_family, &addrbin))
|
||||
g_assert_not_reached();
|
||||
|
||||
ep = nm_sock_addr_endpoint_new(endpoint);
|
||||
|
|
@ -10247,7 +10247,7 @@ test_nm_ip_addr_zero(void)
|
|||
{
|
||||
in_addr_t a4 = nmtst_inet4_from_string("0.0.0.0");
|
||||
struct in6_addr a6 = *nmtst_inet6_from_string("::");
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
NMIPAddr a = NM_IP_ADDR_INIT;
|
||||
|
||||
g_assert(memcmp(&a, &nm_ip_addr_zero, sizeof(a)) == 0);
|
||||
|
|
@ -10258,11 +10258,11 @@ test_nm_ip_addr_zero(void)
|
|||
g_assert(memcmp(&nm_ip_addr_zero, &a4, sizeof(a4)) == 0);
|
||||
g_assert(memcmp(&nm_ip_addr_zero, &a6, sizeof(a6)) == 0);
|
||||
|
||||
g_assert_cmpstr(_nm_utils_inet4_ntop(nm_ip_addr_zero.addr4, buf), ==, "0.0.0.0");
|
||||
g_assert_cmpstr(_nm_utils_inet6_ntop(&nm_ip_addr_zero.addr6, buf), ==, "::");
|
||||
g_assert_cmpstr(nm_inet4_ntop(nm_ip_addr_zero.addr4, buf), ==, "0.0.0.0");
|
||||
g_assert_cmpstr(nm_inet6_ntop(&nm_ip_addr_zero.addr6, buf), ==, "::");
|
||||
|
||||
g_assert_cmpstr(nm_utils_inet_ntop(AF_INET, &nm_ip_addr_zero, buf), ==, "0.0.0.0");
|
||||
g_assert_cmpstr(nm_utils_inet_ntop(AF_INET6, &nm_ip_addr_zero, buf), ==, "::");
|
||||
g_assert_cmpstr(nm_inet_ntop(AF_INET, &nm_ip_addr_zero, buf), ==, "0.0.0.0");
|
||||
g_assert_cmpstr(nm_inet_ntop(AF_INET6, &nm_ip_addr_zero, buf), ==, "::");
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(a) == sizeof(a.array));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3755,7 +3755,7 @@ test_roundtrip_conversion(gconstpointer test_data)
|
|||
for (is_ipv4 = 0; is_ipv4 < 2; is_ipv4++) {
|
||||
g_assert(NM_IS_SETTING_IP_CONFIG(s_ip.s_x[is_ipv4]));
|
||||
for (i = 0; i < 3; i++) {
|
||||
char addrstr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char addrstr[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -171,12 +171,12 @@ gboolean nm_utils_is_valid_iface_name(const char *name, GError **error);
|
|||
gboolean nm_utils_is_uuid(const char *str);
|
||||
|
||||
/**
|
||||
* NM_UTILS_INET_ADDRSTRLEN:
|
||||
* NM_INET_ADDRSTRLEN:
|
||||
*
|
||||
* Defines the minimal length for a char buffer that is suitable as @dst argument
|
||||
* for both nm_utils_inet4_ntop() and nm_utils_inet6_ntop().
|
||||
**/
|
||||
#define NM_UTILS_INET_ADDRSTRLEN INET6_ADDRSTRLEN
|
||||
#define NM_INET_ADDRSTRLEN INET6_ADDRSTRLEN
|
||||
|
||||
const char *nm_utils_inet4_ntop(guint32 inaddr, char *dst);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ nm_ip_addr_set_from_variant(int addr_family, gpointer dst, GVariant *variant, in
|
|||
/*****************************************************************************/
|
||||
|
||||
guint32
|
||||
_nm_utils_ip4_get_default_prefix0(in_addr_t ip)
|
||||
nm_ip4_addr_get_default_prefix0(in_addr_t ip)
|
||||
{
|
||||
/* The function is originally from ipcalc.c of Red Hat's initscripts. */
|
||||
switch (ntohl(ip) >> 24) {
|
||||
|
|
@ -130,13 +130,13 @@ _nm_utils_ip4_get_default_prefix0(in_addr_t ip)
|
|||
}
|
||||
|
||||
guint32
|
||||
_nm_utils_ip4_get_default_prefix(in_addr_t ip)
|
||||
nm_ip4_addr_get_default_prefix(in_addr_t ip)
|
||||
{
|
||||
return _nm_utils_ip4_get_default_prefix0(ip) ?: 24;
|
||||
return nm_ip4_addr_get_default_prefix0(ip) ?: 24;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_ip_is_site_local(int addr_family, const void *address)
|
||||
nm_ip_addr_is_site_local(int addr_family, const void *address)
|
||||
{
|
||||
in_addr_t addr4;
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ nm_utils_ip_is_site_local(int addr_family, const void *address)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_ip6_is_ula(const struct in6_addr *address)
|
||||
nm_ip6_addr_is_ula(const struct in6_addr *address)
|
||||
{
|
||||
/* Unique local IPv6 address (ULA) fc00::/7 */
|
||||
return (address->s6_addr32[0] & htonl(0xfe000000u)) == htonl(0xfc000000u);
|
||||
|
|
@ -167,7 +167,7 @@ nm_utils_ip6_is_ula(const struct in6_addr *address)
|
|||
/*****************************************************************************/
|
||||
|
||||
gconstpointer
|
||||
nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer src, guint32 plen)
|
||||
nm_ip_addr_clear_host_address(int family, gpointer dst, gconstpointer src, guint32 plen)
|
||||
{
|
||||
g_return_val_if_fail(dst, NULL);
|
||||
|
||||
|
|
@ -180,10 +180,10 @@ nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer
|
|||
src = dst;
|
||||
}
|
||||
|
||||
*((guint32 *) dst) = nm_utils_ip4_address_clear_host_address(*((guint32 *) src), plen);
|
||||
*((guint32 *) dst) = nm_ip4_addr_clear_host_address(*((guint32 *) src), plen);
|
||||
break;
|
||||
case AF_INET6:
|
||||
nm_utils_ip6_address_clear_host_address(dst, src, plen);
|
||||
nm_ip6_addr_clear_host_address(dst, src, plen);
|
||||
break;
|
||||
default:
|
||||
g_return_val_if_reached(NULL);
|
||||
|
|
@ -191,7 +191,7 @@ nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer
|
|||
return dst;
|
||||
}
|
||||
|
||||
/* nm_utils_ip6_address_clear_host_address:
|
||||
/* nm_ip6_addr_clear_host_address:
|
||||
* @dst: destination output buffer, will contain the network part of the @src address
|
||||
* @src: source ip6 address. If NULL, this does an in-place update of @dst.
|
||||
* Also, @src and @dst are allowed to be the same pointers.
|
||||
|
|
@ -201,9 +201,7 @@ nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer
|
|||
* @dst and @src to the same destination or set @src NULL.
|
||||
*/
|
||||
const struct in6_addr *
|
||||
nm_utils_ip6_address_clear_host_address(struct in6_addr *dst,
|
||||
const struct in6_addr *src,
|
||||
guint32 plen)
|
||||
nm_ip6_addr_clear_host_address(struct in6_addr *dst, const struct in6_addr *src, guint32 plen)
|
||||
{
|
||||
g_return_val_if_fail(plen <= 128, NULL);
|
||||
g_return_val_if_fail(dst, NULL);
|
||||
|
|
@ -230,9 +228,9 @@ nm_utils_ip6_address_clear_host_address(struct in6_addr *dst,
|
|||
}
|
||||
|
||||
int
|
||||
nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a,
|
||||
const struct in6_addr *addr_b,
|
||||
guint32 plen)
|
||||
nm_ip6_addr_same_prefix_cmp(const struct in6_addr *addr_a,
|
||||
const struct in6_addr *addr_b,
|
||||
guint32 plen)
|
||||
{
|
||||
int nbytes;
|
||||
guint8 va, vb, m;
|
||||
|
|
@ -360,11 +358,11 @@ _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_bin_full(int addr_family,
|
||||
gboolean accept_legacy,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr)
|
||||
nm_inet_parse_bin_full(int addr_family,
|
||||
gboolean accept_legacy,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr)
|
||||
{
|
||||
NMIPAddr addrbin;
|
||||
|
||||
|
|
@ -399,7 +397,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family,
|
|||
g_error("unexpected assertion failure: could parse \"%s\" as %s, but not accepted by "
|
||||
"legacy parser: %s",
|
||||
text,
|
||||
_nm_utils_inet4_ntop(addrbin.addr4, buf),
|
||||
nm_inet4_ntop(addrbin.addr4, buf),
|
||||
error->message);
|
||||
}
|
||||
nm_assert(addrbin.addr4 == a);
|
||||
|
|
@ -414,7 +412,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family,
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr(int addr_family, const char *text, char **out_addr)
|
||||
nm_inet_parse_str(int addr_family, const char *text, char **out_addr)
|
||||
{
|
||||
NMIPAddr addrbin;
|
||||
char addrstr_buf[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||
|
|
@ -435,11 +433,11 @@ nm_utils_parse_inaddr(int addr_family, const char *text, char **out_addr)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_prefix_bin(int addr_family,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr,
|
||||
int *out_prefix)
|
||||
nm_inet_parse_with_prefix_bin(int addr_family,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr,
|
||||
int *out_prefix)
|
||||
{
|
||||
gs_free char *addrstr_free = NULL;
|
||||
int prefix = -1;
|
||||
|
|
@ -481,12 +479,12 @@ nm_utils_parse_inaddr_prefix_bin(int addr_family,
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_prefix(int addr_family, const char *text, char **out_addr, int *out_prefix)
|
||||
nm_inet_parse_with_prefix_str(int addr_family, const char *text, char **out_addr, int *out_prefix)
|
||||
{
|
||||
NMIPAddr addrbin;
|
||||
char addrstr_buf[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(addr_family, text, &addr_family, &addrbin, out_prefix))
|
||||
if (!nm_inet_parse_with_prefix_bin(addr_family, text, &addr_family, &addrbin, out_prefix))
|
||||
return FALSE;
|
||||
NM_SET_OUT(out_addr,
|
||||
g_strdup(inet_ntop(addr_family, &addrbin, addrstr_buf, sizeof(addrstr_buf))));
|
||||
|
|
@ -496,28 +494,28 @@ nm_utils_parse_inaddr_prefix(int addr_family, const char *text, char **out_addr,
|
|||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_utils_ipaddr_is_valid(int addr_family, const char *str_addr)
|
||||
nm_inet_is_valid(int addr_family, const char *str_addr)
|
||||
{
|
||||
nm_assert(NM_IN_SET(addr_family, AF_UNSPEC, AF_INET, AF_INET6));
|
||||
|
||||
return str_addr && nm_utils_parse_inaddr_bin(addr_family, str_addr, NULL, NULL);
|
||||
return str_addr && nm_inet_parse_bin(addr_family, str_addr, NULL, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_ipaddr_is_normalized(int addr_family, const char *str_addr)
|
||||
nm_inet_is_normalized(int addr_family, const char *str_addr)
|
||||
{
|
||||
NMIPAddr addr;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
nm_assert(NM_IN_SET(addr_family, AF_UNSPEC, AF_INET, AF_INET6));
|
||||
|
||||
if (!str_addr)
|
||||
return FALSE;
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, str_addr, &addr_family, &addr))
|
||||
if (!nm_inet_parse_bin(addr_family, str_addr, &addr_family, &addr))
|
||||
return FALSE;
|
||||
|
||||
nm_utils_inet_ntop(addr_family, &addr, sbuf);
|
||||
nm_inet_ntop(addr_family, &addr, sbuf);
|
||||
return nm_streq(sbuf, str_addr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ nm_ip_addr_from_packed_array(int addr_family, gconstpointer ipaddr_arr, gsize id
|
|||
/*****************************************************************************/
|
||||
|
||||
static inline guint32
|
||||
_nm_utils_ip4_netmask_to_prefix(in_addr_t subnetmask)
|
||||
nm_ip4_addr_netmask_to_prefix(in_addr_t subnetmask)
|
||||
{
|
||||
G_STATIC_ASSERT_EXPR(__SIZEOF_INT__ == 4);
|
||||
G_STATIC_ASSERT_EXPR(sizeof(int) == 4);
|
||||
|
|
@ -139,104 +139,95 @@ _nm_utils_ip4_netmask_to_prefix(in_addr_t subnetmask)
|
|||
}
|
||||
|
||||
/**
|
||||
* _nm_utils_ip4_prefix_to_netmask:
|
||||
* nm_ip4_addr_netmask_from_prefix:
|
||||
* @prefix: a CIDR prefix
|
||||
*
|
||||
* Returns: the netmask represented by the prefix, in network byte order
|
||||
**/
|
||||
static inline in_addr_t
|
||||
_nm_utils_ip4_prefix_to_netmask(guint32 prefix)
|
||||
nm_ip4_addr_netmask_from_prefix(guint32 prefix)
|
||||
{
|
||||
nm_assert(prefix <= 32);
|
||||
return prefix < 32 ? ~htonl(0xFFFFFFFFu >> prefix) : 0xFFFFFFFFu;
|
||||
}
|
||||
|
||||
guint32 _nm_utils_ip4_get_default_prefix0(in_addr_t ip);
|
||||
guint32 _nm_utils_ip4_get_default_prefix(in_addr_t ip);
|
||||
guint32 nm_ip4_addr_get_default_prefix0(in_addr_t ip);
|
||||
guint32 nm_ip4_addr_get_default_prefix(in_addr_t ip);
|
||||
|
||||
gconstpointer
|
||||
nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer src, guint32 plen);
|
||||
nm_ip_addr_clear_host_address(int family, gpointer dst, gconstpointer src, guint32 plen);
|
||||
|
||||
/* nm_utils_ip4_address_clear_host_address:
|
||||
/* nm_ip4_addr_clear_host_address:
|
||||
* @addr: source ip6 address
|
||||
* @plen: prefix length of network
|
||||
*
|
||||
* returns: the input address, with the host address set to 0.
|
||||
*/
|
||||
static inline in_addr_t
|
||||
nm_utils_ip4_address_clear_host_address(in_addr_t addr, guint32 plen)
|
||||
nm_ip4_addr_clear_host_address(in_addr_t addr, guint32 plen)
|
||||
{
|
||||
return addr & _nm_utils_ip4_prefix_to_netmask(plen);
|
||||
return addr & nm_ip4_addr_netmask_from_prefix(plen);
|
||||
}
|
||||
|
||||
const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr *dst,
|
||||
const struct in6_addr *src,
|
||||
guint32 plen);
|
||||
const struct in6_addr *
|
||||
nm_ip6_addr_clear_host_address(struct in6_addr *dst, const struct in6_addr *src, guint32 plen);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline int
|
||||
nm_utils_ip4_address_same_prefix_cmp(in_addr_t addr_a, in_addr_t addr_b, guint32 plen)
|
||||
nm_ip4_addr_same_prefix_cmp(in_addr_t addr_a, in_addr_t addr_b, guint32 plen)
|
||||
{
|
||||
NM_CMP_DIRECT(htonl(nm_utils_ip4_address_clear_host_address(addr_a, plen)),
|
||||
htonl(nm_utils_ip4_address_clear_host_address(addr_b, plen)));
|
||||
NM_CMP_DIRECT(htonl(nm_ip4_addr_clear_host_address(addr_a, plen)),
|
||||
htonl(nm_ip4_addr_clear_host_address(addr_b, plen)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a,
|
||||
const struct in6_addr *addr_b,
|
||||
guint32 plen);
|
||||
int nm_ip6_addr_same_prefix_cmp(const struct in6_addr *addr_a,
|
||||
const struct in6_addr *addr_b,
|
||||
guint32 plen);
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip4_address_same_prefix(in_addr_t addr_a, in_addr_t addr_b, guint32 plen)
|
||||
nm_ip4_addr_same_prefix(in_addr_t addr_a, in_addr_t addr_b, guint32 plen)
|
||||
{
|
||||
return nm_utils_ip4_address_same_prefix_cmp(addr_a, addr_b, plen) == 0;
|
||||
return nm_ip4_addr_same_prefix_cmp(addr_a, addr_b, plen) == 0;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip6_address_same_prefix(const struct in6_addr *addr_a,
|
||||
const struct in6_addr *addr_b,
|
||||
guint8 plen)
|
||||
nm_ip6_addr_same_prefix(const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen)
|
||||
{
|
||||
return nm_utils_ip6_address_same_prefix_cmp(addr_a, addr_b, plen) == 0;
|
||||
return nm_ip6_addr_same_prefix_cmp(addr_a, addr_b, plen) == 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_utils_ip_address_same_prefix_cmp(int addr_family,
|
||||
gconstpointer addr_a,
|
||||
gconstpointer addr_b,
|
||||
guint8 plen)
|
||||
nm_ip_addr_same_prefix_cmp(int addr_family, gconstpointer addr_a, gconstpointer addr_b, guint8 plen)
|
||||
{
|
||||
NM_CMP_SELF(addr_a, addr_b);
|
||||
|
||||
if (NM_IS_IPv4(addr_family)) {
|
||||
return nm_utils_ip4_address_same_prefix_cmp(*((const in_addr_t *) addr_a),
|
||||
*((const in_addr_t *) addr_b),
|
||||
plen);
|
||||
return nm_ip4_addr_same_prefix_cmp(*((const in_addr_t *) addr_a),
|
||||
*((const in_addr_t *) addr_b),
|
||||
plen);
|
||||
}
|
||||
|
||||
return nm_utils_ip6_address_same_prefix_cmp(addr_a, addr_b, plen);
|
||||
return nm_ip6_addr_same_prefix_cmp(addr_a, addr_b, plen);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip_address_same_prefix(int addr_family,
|
||||
gconstpointer addr_a,
|
||||
gconstpointer addr_b,
|
||||
guint8 plen)
|
||||
nm_ip_addr_same_prefix(int addr_family, gconstpointer addr_a, gconstpointer addr_b, guint8 plen)
|
||||
{
|
||||
return nm_utils_ip_address_same_prefix_cmp(addr_family, addr_a, addr_b, plen) == 0;
|
||||
return nm_ip_addr_same_prefix_cmp(addr_family, addr_a, addr_b, plen) == 0;
|
||||
}
|
||||
|
||||
#define NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a, b, plen) \
|
||||
NM_CMP_RETURN(nm_utils_ip4_address_same_prefix_cmp((a), (b), (plen)))
|
||||
#define NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a, b, plen) \
|
||||
NM_CMP_RETURN(nm_ip4_addr_same_prefix_cmp((a), (b), (plen)))
|
||||
|
||||
#define NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(a, b, plen) \
|
||||
NM_CMP_RETURN(nm_utils_ip6_address_same_prefix_cmp((a), (b), (plen)))
|
||||
#define NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(a, b, plen) \
|
||||
NM_CMP_RETURN(nm_ip6_addr_same_prefix_cmp((a), (b), (plen)))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_utils_ip_is_site_local(int addr_family, const void *address);
|
||||
gboolean nm_utils_ip6_is_ula(const struct in6_addr *address);
|
||||
gboolean nm_ip_addr_is_site_local(int addr_family, const void *address);
|
||||
gboolean nm_ip6_addr_is_ula(const struct in6_addr *address);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -244,7 +235,7 @@ gboolean nm_utils_ip6_is_ula(const struct in6_addr *address);
|
|||
#define NM_IPV4LL_NETMASK ((in_addr_t) htonl(0xFFFF0000lu))
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip4_address_is_loopback(in_addr_t addr)
|
||||
nm_ip4_addr_is_loopback(in_addr_t addr)
|
||||
{
|
||||
/* There is also IN_LOOPBACK() in <linux/in.h>, but there the
|
||||
* argument is in host order not `in_addr_t`. */
|
||||
|
|
@ -252,13 +243,13 @@ nm_utils_ip4_address_is_loopback(in_addr_t addr)
|
|||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip4_address_is_link_local(in_addr_t addr)
|
||||
nm_ip4_addr_is_link_local(in_addr_t addr)
|
||||
{
|
||||
return (addr & NM_IPV4LL_NETMASK) == NM_IPV4LL_NETWORK;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip4_address_is_zeronet(in_addr_t network)
|
||||
nm_ip4_addr_is_zeronet(in_addr_t network)
|
||||
{
|
||||
/* Same as ipv4_is_zeronet() from kernel's include/linux/in.h. */
|
||||
return (network & htonl(0xFF000000u)) == htonl(0x00000000u);
|
||||
|
|
@ -266,13 +257,13 @@ nm_utils_ip4_address_is_zeronet(in_addr_t network)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_UTILS_INET_ADDRSTRLEN INET6_ADDRSTRLEN
|
||||
#define NM_INET_ADDRSTRLEN INET6_ADDRSTRLEN
|
||||
|
||||
/* Forward declare function so we don't have to drag in <arpa/inet.h>. */
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
|
||||
static inline const char *
|
||||
nm_utils_inet_ntop(int addr_family, gconstpointer addr, char *dst)
|
||||
nm_inet_ntop(int addr_family, gconstpointer addr, char *dst)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
|
|
@ -289,69 +280,66 @@ nm_utils_inet_ntop(int addr_family, gconstpointer addr, char *dst)
|
|||
}
|
||||
|
||||
static inline const char *
|
||||
_nm_utils_inet4_ntop(in_addr_t addr, char dst[static INET_ADDRSTRLEN])
|
||||
nm_inet4_ntop(in_addr_t addr, char dst[static INET_ADDRSTRLEN])
|
||||
{
|
||||
return nm_utils_inet_ntop(AF_INET, &addr, dst);
|
||||
return nm_inet_ntop(AF_INET, &addr, dst);
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
_nm_utils_inet6_ntop(const struct in6_addr *addr, char dst[static INET6_ADDRSTRLEN])
|
||||
nm_inet6_ntop(const struct in6_addr *addr, char dst[static INET6_ADDRSTRLEN])
|
||||
{
|
||||
return nm_utils_inet_ntop(AF_INET6, addr, dst);
|
||||
return nm_inet_ntop(AF_INET6, addr, dst);
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_utils_inet_ntop_dup(int addr_family, gconstpointer addr)
|
||||
nm_inet_ntop_dup(int addr_family, gconstpointer addr)
|
||||
{
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
return g_strdup(nm_utils_inet_ntop(addr_family, addr, buf));
|
||||
return g_strdup(nm_inet_ntop(addr_family, addr, buf));
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_utils_inet4_ntop_dup(in_addr_t addr)
|
||||
nm_inet4_ntop_dup(in_addr_t addr)
|
||||
{
|
||||
return nm_utils_inet_ntop_dup(AF_INET, &addr);
|
||||
return nm_inet_ntop_dup(AF_INET, &addr);
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_utils_inet6_ntop_dup(const struct in6_addr *addr)
|
||||
nm_inet6_ntop_dup(const struct in6_addr *addr)
|
||||
{
|
||||
return nm_utils_inet_ntop_dup(AF_INET6, addr);
|
||||
return nm_inet_ntop_dup(AF_INET6, addr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_utils_parse_inaddr_bin_full(int addr_family,
|
||||
gboolean accept_legacy,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr);
|
||||
gboolean nm_inet_parse_bin_full(int addr_family,
|
||||
gboolean accept_legacy,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr);
|
||||
static inline gboolean
|
||||
nm_utils_parse_inaddr_bin(int addr_family,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr)
|
||||
nm_inet_parse_bin(int addr_family, const char *text, int *out_addr_family, gpointer out_addr)
|
||||
{
|
||||
return nm_utils_parse_inaddr_bin_full(addr_family, FALSE, text, out_addr_family, out_addr);
|
||||
return nm_inet_parse_bin_full(addr_family, FALSE, text, out_addr_family, out_addr);
|
||||
}
|
||||
|
||||
gboolean nm_utils_parse_inaddr(int addr_family, const char *text, char **out_addr);
|
||||
gboolean nm_inet_parse_str(int addr_family, const char *text, char **out_addr);
|
||||
|
||||
gboolean nm_utils_parse_inaddr_prefix_bin(int addr_family,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr,
|
||||
int *out_prefix);
|
||||
gboolean nm_inet_parse_with_prefix_bin(int addr_family,
|
||||
const char *text,
|
||||
int *out_addr_family,
|
||||
gpointer out_addr,
|
||||
int *out_prefix);
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_prefix(int addr_family, const char *text, char **out_addr, int *out_prefix);
|
||||
nm_inet_parse_with_prefix_str(int addr_family, const char *text, char **out_addr, int *out_prefix);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_utils_ipaddr_is_valid(int addr_family, const char *str_addr);
|
||||
gboolean nm_inet_is_valid(int addr_family, const char *str_addr);
|
||||
|
||||
gboolean nm_utils_ipaddr_is_normalized(int addr_family, const char *str_addr);
|
||||
gboolean nm_inet_is_normalized(int addr_family, const char *str_addr);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid, const
|
|||
/**
|
||||
* nm_utils_inet6_interface_identifier_to_token:
|
||||
* @iid: %NMUtilsIPv6IfaceId interface identifier
|
||||
* @buf: the destination buffer of at least %NM_UTILS_INET_ADDRSTRLEN
|
||||
* @buf: the destination buffer of at least %NM_INET_ADDRSTRLEN
|
||||
* bytes.
|
||||
*
|
||||
* Converts the interface identifier to a string token.
|
||||
|
|
@ -156,7 +156,7 @@ nm_utils_inet6_interface_identifier_to_token(const NMUtilsIPv6IfaceId *iid,
|
|||
|
||||
nm_assert(buf);
|
||||
nm_utils_ipv6_addr_set_interface_identifier(&i6_token, iid);
|
||||
return _nm_utils_inet6_ntop(&i6_token, buf);
|
||||
return nm_inet6_ntop(&i6_token, buf);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1944,9 +1944,9 @@ nmtst_setting_ip_config_add_address(NMSettingIPConfig *s_ip, const char *address
|
|||
|
||||
g_assert(s_ip);
|
||||
|
||||
if (nm_utils_ipaddr_is_valid(AF_INET, address))
|
||||
if (nm_inet_is_valid(AF_INET, address))
|
||||
family = AF_INET;
|
||||
else if (nm_utils_ipaddr_is_valid(AF_INET6, address))
|
||||
else if (nm_inet_is_valid(AF_INET6, address))
|
||||
family = AF_INET6;
|
||||
else
|
||||
g_assert_not_reached();
|
||||
|
|
@ -1969,9 +1969,9 @@ nmtst_setting_ip_config_add_route(NMSettingIPConfig *s_ip,
|
|||
|
||||
g_assert(s_ip);
|
||||
|
||||
if (nm_utils_ipaddr_is_valid(AF_INET, dest))
|
||||
if (nm_inet_is_valid(AF_INET, dest))
|
||||
family = AF_INET;
|
||||
else if (nm_utils_ipaddr_is_valid(AF_INET6, dest))
|
||||
else if (nm_inet_is_valid(AF_INET6, dest))
|
||||
family = AF_INET6;
|
||||
else
|
||||
g_assert_not_reached();
|
||||
|
|
@ -2913,7 +2913,7 @@ nmtst_ip_address_new(int addr_family, const char *str)
|
|||
GError *error = NULL;
|
||||
NMIPAddress *a;
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(addr_family, str, &addr_family, &addr, &plen))
|
||||
if (!nm_inet_parse_with_prefix_bin(addr_family, str, &addr_family, &addr, &plen))
|
||||
g_assert_not_reached();
|
||||
|
||||
if (plen == -1)
|
||||
|
|
|
|||
|
|
@ -253,12 +253,12 @@ test_nm_strndup_a(void)
|
|||
static void
|
||||
test_nm_utils_ip4_address_is_loopback(void)
|
||||
{
|
||||
g_assert(nm_utils_ip4_address_is_loopback(nmtst_inet4_from_string("127.0.0.0")));
|
||||
g_assert(nm_utils_ip4_address_is_loopback(nmtst_inet4_from_string("127.0.0.1")));
|
||||
g_assert(nm_utils_ip4_address_is_loopback(nmtst_inet4_from_string("127.5.0.1")));
|
||||
g_assert(!nm_utils_ip4_address_is_loopback(nmtst_inet4_from_string("126.5.0.1")));
|
||||
g_assert(!nm_utils_ip4_address_is_loopback(nmtst_inet4_from_string("128.5.0.1")));
|
||||
g_assert(!nm_utils_ip4_address_is_loopback(nmtst_inet4_from_string("129.5.0.1")));
|
||||
g_assert(nm_ip4_addr_is_loopback(nmtst_inet4_from_string("127.0.0.0")));
|
||||
g_assert(nm_ip4_addr_is_loopback(nmtst_inet4_from_string("127.0.0.1")));
|
||||
g_assert(nm_ip4_addr_is_loopback(nmtst_inet4_from_string("127.5.0.1")));
|
||||
g_assert(!nm_ip4_addr_is_loopback(nmtst_inet4_from_string("126.5.0.1")));
|
||||
g_assert(!nm_ip4_addr_is_loopback(nmtst_inet4_from_string("128.5.0.1")));
|
||||
g_assert(!nm_ip4_addr_is_loopback(nmtst_inet4_from_string("129.5.0.1")));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -266,22 +266,22 @@ test_nm_utils_ip4_address_is_loopback(void)
|
|||
static void
|
||||
test_nm_utils_ip4_prefix_to_netmask(void)
|
||||
{
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(0), ==, nmtst_inet4_from_string("0.0.0.0"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(1), ==, nmtst_inet4_from_string("128.0.0.0"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(2), ==, nmtst_inet4_from_string("192.0.0.0"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(16),
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(0), ==, nmtst_inet4_from_string("0.0.0.0"));
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(1), ==, nmtst_inet4_from_string("128.0.0.0"));
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(2), ==, nmtst_inet4_from_string("192.0.0.0"));
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(16),
|
||||
==,
|
||||
nmtst_inet4_from_string("255.255.0.0"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(24),
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(24),
|
||||
==,
|
||||
nmtst_inet4_from_string("255.255.255.0"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(30),
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(30),
|
||||
==,
|
||||
nmtst_inet4_from_string("255.255.255.252"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(31),
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(31),
|
||||
==,
|
||||
nmtst_inet4_from_string("255.255.255.254"));
|
||||
g_assert_cmpint(_nm_utils_ip4_prefix_to_netmask(32),
|
||||
g_assert_cmpint(nm_ip4_addr_netmask_from_prefix(32),
|
||||
==,
|
||||
nmtst_inet4_from_string("255.255.255.255"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8122,7 +8122,7 @@ static gboolean
|
|||
link_set_token(NMPlatform *platform, int ifindex, const NMUtilsIPv6IfaceId *iid)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_LOGD("link: change %d: token: set IPv6 address generation token to %s",
|
||||
ifindex,
|
||||
|
|
|
|||
|
|
@ -3588,7 +3588,7 @@ nm_platform_ip_address_match(int addr_family,
|
|||
nm_assert(NM_FLAGS_ANY(match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY));
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
if (nm_utils_ip4_address_is_link_local(((NMPlatformIP4Address *) address)->address)) {
|
||||
if (nm_ip4_addr_is_link_local(((NMPlatformIP4Address *) address)->address)) {
|
||||
if (!NM_FLAGS_HAS(match_flag, NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL))
|
||||
return FALSE;
|
||||
} else {
|
||||
|
|
@ -3723,8 +3723,8 @@ nm_platform_ip4_address_delete(NMPlatform *self,
|
|||
in_addr_t peer_address)
|
||||
{
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE];
|
||||
char b1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b2[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char b1[NM_INET_ADDRSTRLEN];
|
||||
char b2[NM_INET_ADDRSTRLEN];
|
||||
char str_peer[INET_ADDRSTRLEN + 50];
|
||||
|
||||
_CHECK_SELF(self, klass, FALSE);
|
||||
|
|
@ -3733,10 +3733,10 @@ nm_platform_ip4_address_delete(NMPlatform *self,
|
|||
g_return_val_if_fail(plen <= 32, FALSE);
|
||||
|
||||
_LOG3D("address: deleting IPv4 address %s/%d, %s%s",
|
||||
_nm_utils_inet4_ntop(address, b1),
|
||||
nm_inet4_ntop(address, b1),
|
||||
plen,
|
||||
peer_address != address
|
||||
? nm_sprintf_buf(str_peer, "peer %s, ", _nm_utils_inet4_ntop(peer_address, b2))
|
||||
? nm_sprintf_buf(str_peer, "peer %s, ", nm_inet4_ntop(peer_address, b2))
|
||||
: "",
|
||||
_to_string_dev(self, ifindex, str_dev, sizeof(str_dev)));
|
||||
return klass->ip4_address_delete(self, ifindex, address, plen, peer_address);
|
||||
|
|
@ -3746,7 +3746,7 @@ gboolean
|
|||
nm_platform_ip6_address_delete(NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen)
|
||||
{
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE];
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
_CHECK_SELF(self, klass, FALSE);
|
||||
|
||||
|
|
@ -3754,7 +3754,7 @@ nm_platform_ip6_address_delete(NMPlatform *self, int ifindex, struct in6_addr ad
|
|||
g_return_val_if_fail(plen <= 128, FALSE);
|
||||
|
||||
_LOG3D("address: deleting IPv6 address %s/%d, %s",
|
||||
_nm_utils_inet6_ntop(&address, sbuf),
|
||||
nm_inet6_ntop(&address, sbuf),
|
||||
plen,
|
||||
_to_string_dev(self, ifindex, str_dev, sizeof(str_dev)));
|
||||
return klass->ip6_address_delete(self, ifindex, address, plen);
|
||||
|
|
@ -3943,9 +3943,7 @@ _ip4_addr_subnets_hash(gconstpointer ptr)
|
|||
NMHashState h;
|
||||
|
||||
nm_hash_init(&h, 3282159733);
|
||||
nm_hash_update_vals(&h,
|
||||
addr->plen,
|
||||
nm_utils_ip4_address_clear_host_address(addr->address, addr->plen));
|
||||
nm_hash_update_vals(&h, addr->plen, nm_ip4_addr_clear_host_address(addr->address, addr->plen));
|
||||
return nm_hash_complete(&h);
|
||||
}
|
||||
|
||||
|
|
@ -3956,8 +3954,8 @@ _ip4_addr_subnets_equal(gconstpointer p_a, gconstpointer p_b)
|
|||
const NMPlatformIP4Address *b = NMP_OBJECT_CAST_IP4_ADDRESS(p_b);
|
||||
|
||||
return a->plen == b->plen
|
||||
&& (nm_utils_ip4_address_clear_host_address(a->address, a->plen)
|
||||
== nm_utils_ip4_address_clear_host_address(b->address, b->plen));
|
||||
&& (nm_ip4_addr_clear_host_address(a->address, a->plen)
|
||||
== nm_ip4_addr_clear_host_address(b->address, b->plen));
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
|
|
@ -5251,15 +5249,15 @@ nm_platform_ip_route_normalize(int addr_family, NMPlatformIPRoute *route)
|
|||
r4 = (NMPlatformIP4Route *) route;
|
||||
route->metric = nm_platform_ip4_route_get_effective_metric(r4);
|
||||
route->metric_any = FALSE;
|
||||
r4->network = nm_utils_ip4_address_clear_host_address(r4->network, r4->plen);
|
||||
r4->network = nm_ip4_addr_clear_host_address(r4->network, r4->plen);
|
||||
r4->scope_inv = _ip_route_scope_inv_get_normalized(r4);
|
||||
break;
|
||||
case AF_INET6:
|
||||
r6 = (NMPlatformIP6Route *) route;
|
||||
route->metric = nm_platform_ip6_route_get_effective_metric(r6);
|
||||
route->metric_any = FALSE;
|
||||
nm_utils_ip6_address_clear_host_address(&r6->network, &r6->network, r6->plen);
|
||||
nm_utils_ip6_address_clear_host_address(&r6->src, &r6->src, r6->src_plen);
|
||||
nm_ip6_addr_clear_host_address(&r6->network, &r6->network, r6->plen);
|
||||
nm_ip6_addr_clear_host_address(&r6->src, &r6->src, r6->src_plen);
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
|
|
@ -5364,7 +5362,7 @@ nm_platform_ip_route_get(NMPlatform *self,
|
|||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
nm_auto_nmpobj NMPObject *route = NULL;
|
||||
int result;
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
char buf_oif[64];
|
||||
|
||||
_CHECK_SELF(self, klass, FALSE);
|
||||
|
|
@ -5893,7 +5891,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len)
|
|||
char str_address[_NM_UTILS_HWADDR_LEN_MAX * 3];
|
||||
char str_perm_address[_NM_UTILS_HWADDR_LEN_MAX * 3];
|
||||
char str_broadcast[_NM_UTILS_HWADDR_LEN_MAX * 3];
|
||||
char str_inet6_token[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_inet6_token[NM_INET_ADDRSTRLEN];
|
||||
const char *str_link_type;
|
||||
|
||||
if (!nm_utils_to_string_buffer_init_null(link, &buf, &len))
|
||||
|
|
@ -6186,7 +6184,7 @@ nm_platform_lnk_bond_to_string(const NMPlatformLnkBond *lnk, char *buf, gsize le
|
|||
char target[INET_ADDRSTRLEN];
|
||||
|
||||
nm_strbuf_append_c(&buf, &len, ' ');
|
||||
nm_strbuf_append_str(&buf, &len, _nm_utils_inet4_ntop(lnk->arp_ip_target[i], target));
|
||||
nm_strbuf_append_str(&buf, &len, nm_inet4_ntop(lnk->arp_ip_target[i], target));
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
|
@ -6196,18 +6194,18 @@ const char *
|
|||
nm_platform_lnk_gre_to_string(const NMPlatformLnkGre *lnk, char *buf, gsize len)
|
||||
{
|
||||
char str_local[30];
|
||||
char str_local1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_local1[NM_INET_ADDRSTRLEN];
|
||||
char str_remote[30];
|
||||
char str_remote1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_remote1[NM_INET_ADDRSTRLEN];
|
||||
char str_ttl[30];
|
||||
char str_tos[30];
|
||||
char str_parent_ifindex[30];
|
||||
char str_input_flags[30];
|
||||
char str_output_flags[30];
|
||||
char str_input_key[30];
|
||||
char str_input_key1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_input_key1[NM_INET_ADDRSTRLEN];
|
||||
char str_output_key[30];
|
||||
char str_output_key1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_output_key1[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (!nm_utils_to_string_buffer_init_null(lnk, &buf, &len))
|
||||
return buf;
|
||||
|
|
@ -6228,13 +6226,11 @@ nm_platform_lnk_gre_to_string(const NMPlatformLnkGre *lnk, char *buf, gsize len)
|
|||
"%s" /* okey */
|
||||
"",
|
||||
lnk->is_tap ? "tap" : "",
|
||||
lnk->remote ? nm_sprintf_buf(str_remote,
|
||||
" remote %s",
|
||||
_nm_utils_inet4_ntop(lnk->remote, str_remote1))
|
||||
: "",
|
||||
lnk->local
|
||||
? nm_sprintf_buf(str_local, " local %s", _nm_utils_inet4_ntop(lnk->local, str_local1))
|
||||
lnk->remote
|
||||
? nm_sprintf_buf(str_remote, " remote %s", nm_inet4_ntop(lnk->remote, str_remote1))
|
||||
: "",
|
||||
lnk->local ? nm_sprintf_buf(str_local, " local %s", nm_inet4_ntop(lnk->local, str_local1))
|
||||
: "",
|
||||
lnk->parent_ifindex ? nm_sprintf_buf(str_parent_ifindex, " dev %d", lnk->parent_ifindex)
|
||||
: "",
|
||||
lnk->ttl ? nm_sprintf_buf(str_ttl, " ttl %u", lnk->ttl) : " ttl inherit",
|
||||
|
|
@ -6247,12 +6243,12 @@ nm_platform_lnk_gre_to_string(const NMPlatformLnkGre *lnk, char *buf, gsize len)
|
|||
NM_FLAGS_HAS(lnk->input_flags, GRE_KEY) || lnk->input_key
|
||||
? nm_sprintf_buf(str_input_key,
|
||||
" ikey %s",
|
||||
_nm_utils_inet4_ntop(lnk->input_key, str_input_key1))
|
||||
nm_inet4_ntop(lnk->input_key, str_input_key1))
|
||||
: "",
|
||||
NM_FLAGS_HAS(lnk->output_flags, GRE_KEY) || lnk->output_key
|
||||
? nm_sprintf_buf(str_output_key,
|
||||
" okey %s",
|
||||
_nm_utils_inet4_ntop(lnk->output_key, str_output_key1))
|
||||
nm_inet4_ntop(lnk->output_key, str_output_key1))
|
||||
: "");
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -6281,9 +6277,9 @@ const char *
|
|||
nm_platform_lnk_ip6tnl_to_string(const NMPlatformLnkIp6Tnl *lnk, char *buf, gsize len)
|
||||
{
|
||||
char str_local[30];
|
||||
char str_local1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_local1[NM_INET_ADDRSTRLEN];
|
||||
char str_remote[30];
|
||||
char str_remote1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_remote1[NM_INET_ADDRSTRLEN];
|
||||
char str_ttl[30];
|
||||
char str_tclass[30];
|
||||
char str_flow[30];
|
||||
|
|
@ -6300,32 +6296,32 @@ nm_platform_lnk_ip6tnl_to_string(const NMPlatformLnkIp6Tnl *lnk, char *buf, gsiz
|
|||
else
|
||||
str_type = "ip6tnl";
|
||||
|
||||
g_snprintf(
|
||||
buf,
|
||||
len,
|
||||
"%s" /* type */
|
||||
"%s" /* remote */
|
||||
"%s" /* local */
|
||||
"%s" /* parent_ifindex */
|
||||
"%s" /* ttl */
|
||||
"%s" /* tclass */
|
||||
"%s" /* encap limit */
|
||||
"%s" /* flow label */
|
||||
"%s" /* proto */
|
||||
" flags 0x%x"
|
||||
"",
|
||||
str_type,
|
||||
nm_sprintf_buf(str_remote, " remote %s", _nm_utils_inet6_ntop(&lnk->remote, str_remote1)),
|
||||
nm_sprintf_buf(str_local, " local %s", _nm_utils_inet6_ntop(&lnk->local, str_local1)),
|
||||
lnk->parent_ifindex ? nm_sprintf_buf(str_parent_ifindex, " dev %d", lnk->parent_ifindex)
|
||||
: "",
|
||||
lnk->ttl ? nm_sprintf_buf(str_ttl, " ttl %u", lnk->ttl) : " ttl inherit",
|
||||
lnk->tclass == 1 ? " tclass inherit"
|
||||
: nm_sprintf_buf(str_tclass, " tclass 0x%x", lnk->tclass),
|
||||
nm_sprintf_buf(str_encap, " encap-limit %u", lnk->encap_limit),
|
||||
nm_sprintf_buf(str_flow, " flow-label 0x05%x", lnk->flow_label),
|
||||
nm_sprintf_buf(str_proto, " proto %u", lnk->proto),
|
||||
(guint) lnk->flags);
|
||||
g_snprintf(buf,
|
||||
len,
|
||||
"%s" /* type */
|
||||
"%s" /* remote */
|
||||
"%s" /* local */
|
||||
"%s" /* parent_ifindex */
|
||||
"%s" /* ttl */
|
||||
"%s" /* tclass */
|
||||
"%s" /* encap limit */
|
||||
"%s" /* flow label */
|
||||
"%s" /* proto */
|
||||
" flags 0x%x"
|
||||
"",
|
||||
str_type,
|
||||
nm_sprintf_buf(str_remote, " remote %s", nm_inet6_ntop(&lnk->remote, str_remote1)),
|
||||
nm_sprintf_buf(str_local, " local %s", nm_inet6_ntop(&lnk->local, str_local1)),
|
||||
lnk->parent_ifindex
|
||||
? nm_sprintf_buf(str_parent_ifindex, " dev %d", lnk->parent_ifindex)
|
||||
: "",
|
||||
lnk->ttl ? nm_sprintf_buf(str_ttl, " ttl %u", lnk->ttl) : " ttl inherit",
|
||||
lnk->tclass == 1 ? " tclass inherit"
|
||||
: nm_sprintf_buf(str_tclass, " tclass 0x%x", lnk->tclass),
|
||||
nm_sprintf_buf(str_encap, " encap-limit %u", lnk->encap_limit),
|
||||
nm_sprintf_buf(str_flow, " flow-label 0x05%x", lnk->flow_label),
|
||||
nm_sprintf_buf(str_proto, " proto %u", lnk->proto),
|
||||
(guint) lnk->flags);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -6333,9 +6329,9 @@ const char *
|
|||
nm_platform_lnk_ipip_to_string(const NMPlatformLnkIpIp *lnk, char *buf, gsize len)
|
||||
{
|
||||
char str_local[30];
|
||||
char str_local1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_local1[NM_INET_ADDRSTRLEN];
|
||||
char str_remote[30];
|
||||
char str_remote1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_remote1[NM_INET_ADDRSTRLEN];
|
||||
char str_ttl[30];
|
||||
char str_tos[30];
|
||||
char str_parent_ifindex[30];
|
||||
|
|
@ -6354,13 +6350,11 @@ nm_platform_lnk_ipip_to_string(const NMPlatformLnkIpIp *lnk, char *buf, gsize le
|
|||
"%s" /* tos */
|
||||
"%s" /* path_mtu_discovery */
|
||||
"",
|
||||
lnk->remote ? nm_sprintf_buf(str_remote,
|
||||
" remote %s",
|
||||
_nm_utils_inet4_ntop(lnk->remote, str_remote1))
|
||||
: "",
|
||||
lnk->local
|
||||
? nm_sprintf_buf(str_local, " local %s", _nm_utils_inet4_ntop(lnk->local, str_local1))
|
||||
lnk->remote
|
||||
? nm_sprintf_buf(str_remote, " remote %s", nm_inet4_ntop(lnk->remote, str_remote1))
|
||||
: "",
|
||||
lnk->local ? nm_sprintf_buf(str_local, " local %s", nm_inet4_ntop(lnk->local, str_local1))
|
||||
: "",
|
||||
lnk->parent_ifindex ? nm_sprintf_buf(str_parent_ifindex, " dev %d", lnk->parent_ifindex)
|
||||
: "",
|
||||
lnk->ttl ? nm_sprintf_buf(str_ttl, " ttl %u", lnk->ttl) : " ttl inherit",
|
||||
|
|
@ -6423,9 +6417,9 @@ const char *
|
|||
nm_platform_lnk_sit_to_string(const NMPlatformLnkSit *lnk, char *buf, gsize len)
|
||||
{
|
||||
char str_local[30];
|
||||
char str_local1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_local1[NM_INET_ADDRSTRLEN];
|
||||
char str_remote[30];
|
||||
char str_remote1[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_remote1[NM_INET_ADDRSTRLEN];
|
||||
char str_ttl[30];
|
||||
char str_tos[30];
|
||||
char str_flags[30];
|
||||
|
|
@ -6448,13 +6442,11 @@ nm_platform_lnk_sit_to_string(const NMPlatformLnkSit *lnk, char *buf, gsize len)
|
|||
"%s" /* flags */
|
||||
"%s" /* proto */
|
||||
"",
|
||||
lnk->remote ? nm_sprintf_buf(str_remote,
|
||||
" remote %s",
|
||||
_nm_utils_inet4_ntop(lnk->remote, str_remote1))
|
||||
: "",
|
||||
lnk->local
|
||||
? nm_sprintf_buf(str_local, " local %s", _nm_utils_inet4_ntop(lnk->local, str_local1))
|
||||
lnk->remote
|
||||
? nm_sprintf_buf(str_remote, " remote %s", nm_inet4_ntop(lnk->remote, str_remote1))
|
||||
: "",
|
||||
lnk->local ? nm_sprintf_buf(str_local, " local %s", nm_inet4_ntop(lnk->local, str_local1))
|
||||
: "",
|
||||
lnk->parent_ifindex ? nm_sprintf_buf(str_parent_ifindex, " dev %d", lnk->parent_ifindex)
|
||||
: "",
|
||||
lnk->ttl ? nm_sprintf_buf(str_ttl, " ttl %u", lnk->ttl) : " ttl inherit",
|
||||
|
|
@ -6547,7 +6539,7 @@ nm_platform_lnk_vxlan_to_string(const NMPlatformLnkVxlan *lnk, char *buf, gsize
|
|||
char str_dst_port[25];
|
||||
char str_tos[25];
|
||||
char str_ttl[25];
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
if (!nm_utils_to_string_buffer_init_null(lnk, &buf, &len))
|
||||
return buf;
|
||||
|
|
@ -6559,7 +6551,7 @@ nm_platform_lnk_vxlan_to_string(const NMPlatformLnkVxlan *lnk, char *buf, gsize
|
|||
sizeof(str_group),
|
||||
" %s %s",
|
||||
IN_MULTICAST(ntohl(lnk->group)) ? "group" : "remote",
|
||||
_nm_utils_inet4_ntop(lnk->group, sbuf));
|
||||
nm_inet4_ntop(lnk->group, sbuf));
|
||||
}
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&lnk->group6))
|
||||
str_group6[0] = '\0';
|
||||
|
|
@ -6569,16 +6561,13 @@ nm_platform_lnk_vxlan_to_string(const NMPlatformLnkVxlan *lnk, char *buf, gsize
|
|||
" %s%s %s",
|
||||
IN6_IS_ADDR_MULTICAST(&lnk->group6) ? "group" : "remote",
|
||||
str_group[0] ? "6" : "", /* usually, a vxlan has either v4 or v6 only. */
|
||||
_nm_utils_inet6_ntop(&lnk->group6, sbuf));
|
||||
nm_inet6_ntop(&lnk->group6, sbuf));
|
||||
}
|
||||
|
||||
if (lnk->local == 0)
|
||||
str_local[0] = '\0';
|
||||
else {
|
||||
g_snprintf(str_local,
|
||||
sizeof(str_local),
|
||||
" local %s",
|
||||
_nm_utils_inet4_ntop(lnk->local, sbuf));
|
||||
g_snprintf(str_local, sizeof(str_local), " local %s", nm_inet4_ntop(lnk->local, sbuf));
|
||||
}
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&lnk->local6))
|
||||
str_local6[0] = '\0';
|
||||
|
|
@ -6587,7 +6576,7 @@ nm_platform_lnk_vxlan_to_string(const NMPlatformLnkVxlan *lnk, char *buf, gsize
|
|||
sizeof(str_local6),
|
||||
" local%s %s",
|
||||
str_local[0] ? "6" : "", /* usually, a vxlan has either v4 or v6 only. */
|
||||
_nm_utils_inet6_ntop(&lnk->local6, sbuf));
|
||||
nm_inet6_ntop(&lnk->local6, sbuf));
|
||||
}
|
||||
|
||||
g_snprintf(
|
||||
|
|
@ -6637,9 +6626,9 @@ nm_platform_wireguard_peer_to_string(const NMPWireGuardPeer *peer, char *buf, gs
|
|||
{
|
||||
char *buf0 = buf;
|
||||
gs_free char *public_key_b64 = NULL;
|
||||
char s_sockaddr[NM_UTILS_INET_ADDRSTRLEN + 100];
|
||||
char s_sockaddr[NM_INET_ADDRSTRLEN + 100];
|
||||
char s_endpoint[20 + sizeof(s_sockaddr)];
|
||||
char s_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_addr[NM_INET_ADDRSTRLEN];
|
||||
char s_keepalive[100];
|
||||
guint i;
|
||||
|
||||
|
|
@ -6683,7 +6672,7 @@ nm_platform_wireguard_peer_to_string(const NMPWireGuardPeer *peer, char *buf, gs
|
|||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s/%u",
|
||||
nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr),
|
||||
nm_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr),
|
||||
allowed_ip->mask);
|
||||
}
|
||||
|
||||
|
|
@ -6809,7 +6798,7 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf
|
|||
? (address->use_ip4_broadcast_address ? " brd " : " brd* ")
|
||||
: "",
|
||||
broadcast_address != 0u || address->use_ip4_broadcast_address
|
||||
? _nm_utils_inet4_ntop(broadcast_address, str_broadcast)
|
||||
? nm_inet4_ntop(broadcast_address, str_broadcast)
|
||||
: "",
|
||||
str_lft_p,
|
||||
str_pref_p,
|
||||
|
|
@ -7231,7 +7220,7 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz
|
|||
route->src_plen || !IN6_IS_ADDR_UNSPECIFIED(&route->src)
|
||||
? nm_sprintf_buf(s_src_all,
|
||||
" src %s/%u",
|
||||
_nm_utils_inet6_ntop(&route->src, s_src),
|
||||
nm_inet6_ntop(&route->src, s_src),
|
||||
(unsigned) route->src_plen)
|
||||
: "",
|
||||
_rtm_flags_to_string_full(str_rtm_flags, sizeof(str_rtm_flags), route->r_rtm_flags),
|
||||
|
|
@ -7285,7 +7274,7 @@ _routing_rule_addr_to_string(char **buf,
|
|||
guint8 plen,
|
||||
gboolean is_src)
|
||||
{
|
||||
char s_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_addr[NM_INET_ADDRSTRLEN];
|
||||
gboolean is_zero;
|
||||
gsize addr_size;
|
||||
|
||||
|
|
@ -7306,7 +7295,7 @@ _routing_rule_addr_to_string(char **buf,
|
|||
|
||||
nm_strbuf_append_str(buf, len, is_src ? " from " : " to ");
|
||||
|
||||
nm_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr));
|
||||
nm_strbuf_append_str(buf, len, nm_inet_ntop(addr_family, addr, s_addr));
|
||||
|
||||
if (plen != (addr_size * 8))
|
||||
nm_strbuf_append(buf, len, "/%u", plen);
|
||||
|
|
@ -7747,7 +7736,7 @@ static NM_UTILS_FLAGS2STR_DEFINE(_mptcp_flags_to_string,
|
|||
const char *
|
||||
nm_platform_mptcp_addr_to_string(const NMPlatformMptcpAddr *mptcp_addr, char *buf, gsize len)
|
||||
{
|
||||
char str_addr[30 + NM_UTILS_INET_ADDRSTRLEN];
|
||||
char str_addr[30 + NM_INET_ADDRSTRLEN];
|
||||
char str_port[30];
|
||||
char str_id[30];
|
||||
char str_flags[200];
|
||||
|
|
@ -7760,7 +7749,7 @@ nm_platform_mptcp_addr_to_string(const NMPlatformMptcpAddr *mptcp_addr, char *bu
|
|||
if (mptcp_addr->addr_family == 0)
|
||||
nm_sprintf_buf(str_addr, "no-addr");
|
||||
else if (NM_IN_SET(mptcp_addr->addr_family, AF_INET, AF_INET6))
|
||||
nm_utils_inet_ntop(mptcp_addr->addr_family, &mptcp_addr->addr, str_addr);
|
||||
nm_inet_ntop(mptcp_addr->addr_family, &mptcp_addr->addr, str_addr);
|
||||
else
|
||||
nm_sprintf_buf(str_addr, "af %d", mptcp_addr->addr_family);
|
||||
|
||||
|
|
@ -8471,7 +8460,7 @@ nm_platform_lnk_wireguard_cmp(const NMPlatformLnkWireGuard *a, const NMPlatformL
|
|||
static int
|
||||
_address_pretty_sort_get_prio_4(in_addr_t addr)
|
||||
{
|
||||
if (nm_utils_ip4_address_is_link_local(addr))
|
||||
if (nm_ip4_addr_is_link_local(addr))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -8501,8 +8490,8 @@ nm_platform_ip4_address_pretty_sort_cmp(const NMPlatformIP4Address *a1,
|
|||
* subnet (and thus also the primary/secondary role) is
|
||||
* preserved.
|
||||
*/
|
||||
n1 = nm_utils_ip4_address_clear_host_address(a1->address, a1->plen);
|
||||
n2 = nm_utils_ip4_address_clear_host_address(a2->address, a2->plen);
|
||||
n1 = nm_ip4_addr_clear_host_address(a1->address, a1->plen);
|
||||
n2 = nm_ip4_addr_clear_host_address(a2->address, a2->plen);
|
||||
NM_CMP_DIRECT_MEMCMP(&n1, &n2, sizeof(guint32));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -8637,7 +8626,7 @@ nm_platform_ip4_address_cmp(const NMPlatformIP4Address *a,
|
|||
case NM_PLATFORM_IP_ADDRESS_CMP_TYPE_ID:
|
||||
/* for IPv4 addresses, you can add the same local address with differing peer-address
|
||||
* (IFA_ADDRESS), provided that their net-part differs. */
|
||||
NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a->peer_address, b->peer_address, a->plen);
|
||||
NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->peer_address, b->peer_address, a->plen);
|
||||
return 0;
|
||||
case NM_PLATFORM_IP_ADDRESS_CMP_TYPE_SEMANTICALLY:
|
||||
case NM_PLATFORM_IP_ADDRESS_CMP_TYPE_FULL:
|
||||
|
|
@ -8749,7 +8738,7 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj,
|
|||
nm_hash_update_vals(
|
||||
h,
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(obj)),
|
||||
nm_utils_ip4_address_clear_host_address(obj->network, obj->plen),
|
||||
nm_ip4_addr_clear_host_address(obj->network, obj->plen),
|
||||
obj->plen,
|
||||
obj->metric,
|
||||
obj->tos,
|
||||
|
|
@ -8760,7 +8749,7 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj,
|
|||
h,
|
||||
obj->type_coerced,
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(obj)),
|
||||
nm_utils_ip4_address_clear_host_address(obj->network, obj->plen),
|
||||
nm_ip4_addr_clear_host_address(obj->network, obj->plen),
|
||||
obj->plen,
|
||||
obj->metric,
|
||||
obj->tos,
|
||||
|
|
@ -8795,7 +8784,7 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj,
|
|||
obj->type_coerced,
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(obj)),
|
||||
obj->ifindex,
|
||||
nm_utils_ip4_address_clear_host_address(obj->network, obj->plen),
|
||||
nm_ip4_addr_clear_host_address(obj->network, obj->plen),
|
||||
obj->plen,
|
||||
obj->metric,
|
||||
obj->gateway,
|
||||
|
|
@ -8870,7 +8859,7 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a,
|
|||
NM_CMP_FIELD_UNSAFE(a, b, table_any);
|
||||
NM_CMP_DIRECT(nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(a)),
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(b)));
|
||||
NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a->network, b->network, MIN(a->plen, b->plen));
|
||||
NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->network, b->network, MIN(a->plen, b->plen));
|
||||
NM_CMP_FIELD(a, b, plen);
|
||||
NM_CMP_FIELD_UNSAFE(a, b, metric_any);
|
||||
NM_CMP_FIELD(a, b, metric);
|
||||
|
|
@ -8912,7 +8901,7 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a,
|
|||
NM_CMP_FIELD(a, b, table_coerced);
|
||||
NM_CMP_FIELD(a, b, ifindex);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
|
||||
NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a->network, b->network, MIN(a->plen, b->plen));
|
||||
NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->network, b->network, MIN(a->plen, b->plen));
|
||||
else
|
||||
NM_CMP_FIELD(a, b, network);
|
||||
NM_CMP_FIELD(a, b, plen);
|
||||
|
|
@ -8968,10 +8957,10 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj,
|
|||
nm_hash_update_vals(
|
||||
h,
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(obj)),
|
||||
*nm_utils_ip6_address_clear_host_address(&a1, &obj->network, obj->plen),
|
||||
*nm_ip6_addr_clear_host_address(&a1, &obj->network, obj->plen),
|
||||
obj->plen,
|
||||
obj->metric,
|
||||
*nm_utils_ip6_address_clear_host_address(&a2, &obj->src, obj->src_plen),
|
||||
*nm_ip6_addr_clear_host_address(&a2, &obj->src, obj->src_plen),
|
||||
obj->src_plen,
|
||||
NM_HASH_COMBINE_BOOLS(guint8, obj->metric_any, obj->table_any));
|
||||
break;
|
||||
|
|
@ -8980,10 +8969,10 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj,
|
|||
h,
|
||||
obj->type_coerced,
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(obj)),
|
||||
*nm_utils_ip6_address_clear_host_address(&a1, &obj->network, obj->plen),
|
||||
*nm_ip6_addr_clear_host_address(&a1, &obj->network, obj->plen),
|
||||
obj->plen,
|
||||
obj->metric,
|
||||
*nm_utils_ip6_address_clear_host_address(&a2, &obj->src, obj->src_plen),
|
||||
*nm_ip6_addr_clear_host_address(&a2, &obj->src, obj->src_plen),
|
||||
obj->src_plen,
|
||||
NM_HASH_COMBINE_BOOLS(guint8, obj->metric_any, obj->table_any),
|
||||
/* on top of WEAK_ID: */
|
||||
|
|
@ -8996,12 +8985,12 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj,
|
|||
obj->type_coerced,
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(obj)),
|
||||
obj->ifindex,
|
||||
*nm_utils_ip6_address_clear_host_address(&a1, &obj->network, obj->plen),
|
||||
*nm_ip6_addr_clear_host_address(&a1, &obj->network, obj->plen),
|
||||
obj->plen,
|
||||
obj->metric,
|
||||
obj->gateway,
|
||||
obj->pref_src,
|
||||
*nm_utils_ip6_address_clear_host_address(&a2, &obj->src, obj->src_plen),
|
||||
*nm_ip6_addr_clear_host_address(&a2, &obj->src, obj->src_plen),
|
||||
obj->src_plen,
|
||||
nmp_utils_ip_config_source_round_trip_rtprot(obj->rt_source),
|
||||
obj->mss,
|
||||
|
|
@ -9072,11 +9061,11 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a,
|
|||
NM_CMP_FIELD_UNSAFE(a, b, table_any);
|
||||
NM_CMP_DIRECT(nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(a)),
|
||||
nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(b)));
|
||||
NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(&a->network, &b->network, MIN(a->plen, b->plen));
|
||||
NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->network, &b->network, MIN(a->plen, b->plen));
|
||||
NM_CMP_FIELD(a, b, plen);
|
||||
NM_CMP_FIELD_UNSAFE(a, b, metric_any);
|
||||
NM_CMP_FIELD(a, b, metric);
|
||||
NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(&a->src, &b->src, MIN(a->src_plen, b->src_plen));
|
||||
NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->src, &b->src, MIN(a->src_plen, b->src_plen));
|
||||
NM_CMP_FIELD(a, b, src_plen);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) {
|
||||
NM_CMP_FIELD(a, b, ifindex);
|
||||
|
|
@ -9095,7 +9084,7 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a,
|
|||
NM_CMP_FIELD(a, b, table_coerced);
|
||||
NM_CMP_FIELD(a, b, ifindex);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY)
|
||||
NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(&a->network, &b->network, MIN(a->plen, b->plen));
|
||||
NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->network, &b->network, MIN(a->plen, b->plen));
|
||||
else
|
||||
NM_CMP_FIELD_IN6ADDR(a, b, network);
|
||||
NM_CMP_FIELD(a, b, plen);
|
||||
|
|
@ -9104,7 +9093,7 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a,
|
|||
NM_CMP_FIELD_IN6ADDR(a, b, gateway);
|
||||
NM_CMP_FIELD_IN6ADDR(a, b, pref_src);
|
||||
if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) {
|
||||
NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(&a->src, &b->src, MIN(a->src_plen, b->src_plen));
|
||||
NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->src, &b->src, MIN(a->src_plen, b->src_plen));
|
||||
NM_CMP_FIELD(a, b, src_plen);
|
||||
NM_CMP_DIRECT(nmp_utils_ip_config_source_round_trip_rtprot(a->rt_source),
|
||||
nmp_utils_ip_config_source_round_trip_rtprot(b->rt_source));
|
||||
|
|
@ -9473,9 +9462,9 @@ nm_platform_ip4_address_generate_device_route(const NMPlatformIP4Address *addr,
|
|||
if (addr->plen == 0)
|
||||
return NULL;
|
||||
|
||||
network_4 = nm_utils_ip4_address_clear_host_address(addr->peer_address, addr->plen);
|
||||
network_4 = nm_ip4_addr_clear_host_address(addr->peer_address, addr->plen);
|
||||
|
||||
if (nm_utils_ip4_address_is_zeronet(network_4)) {
|
||||
if (nm_ip4_addr_is_zeronet(network_4)) {
|
||||
/* Kernel doesn't add device-routes for destinations that
|
||||
* start with 0.x.y.z. Skip them. */
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -1431,7 +1431,7 @@ GType nm_platform_get_type(void);
|
|||
static inline in_addr_t
|
||||
nm_platform_ip4_broadcast_address_create(in_addr_t address, guint8 plen)
|
||||
{
|
||||
return address | ~_nm_utils_ip4_prefix_to_netmask(plen);
|
||||
return address | ~nm_ip4_addr_netmask_from_prefix(plen);
|
||||
}
|
||||
|
||||
static inline in_addr_t
|
||||
|
|
@ -1591,9 +1591,9 @@ nm_platform_ip4_address_get_scope(in_addr_t addr)
|
|||
/* For IPv4 addresses, we can set any scope we want (for any address).
|
||||
* However, there are scopes that make sense based on the address,
|
||||
* so choose those. */
|
||||
return nm_utils_ip4_address_is_loopback(addr) ? (254 /* RT_SCOPE_HOST */)
|
||||
: nm_utils_ip4_address_is_link_local(addr) ? (253 /* RT_SCOPE_LINK */)
|
||||
: (0 /* RT_SCOPE_UNIVERSE */);
|
||||
return nm_ip4_addr_is_loopback(addr) ? (254 /* RT_SCOPE_HOST */)
|
||||
: nm_ip4_addr_is_link_local(addr) ? (253 /* RT_SCOPE_LINK */)
|
||||
: (0 /* RT_SCOPE_UNIVERSE */);
|
||||
}
|
||||
|
||||
static inline guint8
|
||||
|
|
@ -1614,7 +1614,7 @@ nm_platform_ip_address_get_scope(int addr_family, gconstpointer addr)
|
|||
/* Note that this function returns the scope as we configure
|
||||
* it in kernel (for IPv4) or as kernel chooses it (for IPv6).
|
||||
*
|
||||
* That means, rfc1918 private addresses nm_utils_ip_is_site_local() are
|
||||
* That means, rfc1918 private addresses nm_ip_addr_is_site_local() are
|
||||
* considered RT_SCOPE_UNIVERSE.
|
||||
*
|
||||
* Also, the deprecated IN6_IS_ADDR_SITELOCAL() addresses (fec0::/10)
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ nm_sock_addr_union_cpy_untrusted(NMSockAddrUnion *dst,
|
|||
const char *
|
||||
nm_sock_addr_union_to_string(const NMSockAddrUnion *sa, char *buf, gsize len)
|
||||
{
|
||||
char s_addr[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_addr[NM_INET_ADDRSTRLEN];
|
||||
char s_scope_id[40];
|
||||
|
||||
if (!nm_utils_to_string_buffer_init_null(sa, &buf, &len))
|
||||
|
|
@ -232,14 +232,14 @@ nm_sock_addr_union_to_string(const NMSockAddrUnion *sa, char *buf, gsize len)
|
|||
g_snprintf(buf,
|
||||
len,
|
||||
"%s:%u",
|
||||
_nm_utils_inet4_ntop(sa->in.sin_addr.s_addr, s_addr),
|
||||
nm_inet4_ntop(sa->in.sin_addr.s_addr, s_addr),
|
||||
(guint) htons(sa->in.sin_port));
|
||||
break;
|
||||
case AF_INET6:
|
||||
g_snprintf(buf,
|
||||
len,
|
||||
"[%s%s]:%u",
|
||||
_nm_utils_inet6_ntop(&sa->in6.sin6_addr, s_addr),
|
||||
nm_inet6_ntop(&sa->in6.sin6_addr, s_addr),
|
||||
(sa->in6.sin6_scope_id != 0
|
||||
? nm_sprintf_buf(s_scope_id, "%u", sa->in6.sin6_scope_id)
|
||||
: ""),
|
||||
|
|
@ -1106,8 +1106,8 @@ _vt_cmd_obj_to_string_lnk_wireguard(const NMPObject *obj,
|
|||
gsize buf_len) \
|
||||
{ \
|
||||
plat_type *const obj = (plat_type *) _obj; \
|
||||
_nm_unused char buf1[NM_UTILS_INET_ADDRSTRLEN]; \
|
||||
_nm_unused char buf2[NM_UTILS_INET_ADDRSTRLEN]; \
|
||||
_nm_unused char buf1[NM_INET_ADDRSTRLEN]; \
|
||||
_nm_unused char buf2[NM_INET_ADDRSTRLEN]; \
|
||||
\
|
||||
g_snprintf(buf, buf_len, __VA_ARGS__); \
|
||||
return buf; \
|
||||
|
|
@ -1116,24 +1116,23 @@ _vt_cmd_obj_to_string_lnk_wireguard(const NMPObject *obj,
|
|||
|
||||
_vt_cmd_plobj_to_string_id(link, NMPlatformLink, "%d", obj->ifindex);
|
||||
|
||||
_vt_cmd_plobj_to_string_id(ip4_address,
|
||||
NMPlatformIP4Address,
|
||||
"%d: %s/%d%s%s",
|
||||
obj->ifindex,
|
||||
_nm_utils_inet4_ntop(obj->address, buf1),
|
||||
obj->plen,
|
||||
obj->peer_address != obj->address ? "," : "",
|
||||
obj->peer_address != obj->address ? _nm_utils_inet4_ntop(
|
||||
nm_utils_ip4_address_clear_host_address(obj->peer_address,
|
||||
obj->plen),
|
||||
buf2)
|
||||
: "");
|
||||
_vt_cmd_plobj_to_string_id(
|
||||
ip4_address,
|
||||
NMPlatformIP4Address,
|
||||
"%d: %s/%d%s%s",
|
||||
obj->ifindex,
|
||||
nm_inet4_ntop(obj->address, buf1),
|
||||
obj->plen,
|
||||
obj->peer_address != obj->address ? "," : "",
|
||||
obj->peer_address != obj->address
|
||||
? nm_inet4_ntop(nm_ip4_addr_clear_host_address(obj->peer_address, obj->plen), buf2)
|
||||
: "");
|
||||
|
||||
_vt_cmd_plobj_to_string_id(ip6_address,
|
||||
NMPlatformIP6Address,
|
||||
"%d: %s",
|
||||
obj->ifindex,
|
||||
_nm_utils_inet6_ntop(&obj->address, buf1));
|
||||
nm_inet6_ntop(&obj->address, buf1));
|
||||
|
||||
_vt_cmd_plobj_to_string_id(qdisc, NMPlatformQdisc, "%d: %d", obj->ifindex, obj->parent);
|
||||
|
||||
|
|
@ -1637,7 +1636,7 @@ _vt_cmd_plobj_id_hash_update(ip4_address, NMPlatformIP4Address, {
|
|||
obj->plen,
|
||||
obj->address,
|
||||
/* for IPv4 we must also consider the net-part of the peer-address (IFA_ADDRESS) */
|
||||
nm_utils_ip4_address_clear_host_address(obj->peer_address, obj->plen));
|
||||
nm_ip4_addr_clear_host_address(obj->peer_address, obj->plen));
|
||||
});
|
||||
|
||||
_vt_cmd_plobj_id_hash_update(ip6_address, NMPlatformIP6Address, {
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ _parse_ip_route(int family, const char *str, GError **error)
|
|||
for (i = 1; routev[i]; i++) {
|
||||
gint64 tmp64;
|
||||
|
||||
if (nm_utils_ipaddr_is_valid(family, routev[i])) {
|
||||
if (nm_inet_is_valid(family, routev[i])) {
|
||||
if (metric != -1 || attrs) {
|
||||
g_set_error(error, 1, 0, _("the next hop ('%s') must be first"), routev[i]);
|
||||
return NULL;
|
||||
|
|
@ -2276,7 +2276,7 @@ _multilist_validate_fcn_is_domain(const char *domain, GError **error)
|
|||
static const char *
|
||||
_multilist_validate_fcn_is_ipv4_addr_or_subnet(const char *value, GError **error)
|
||||
{
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(AF_INET, value, NULL, NULL, NULL)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_INET, value, NULL, NULL, NULL)) {
|
||||
nm_utils_error_set(error,
|
||||
NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
_("invalid IPv4 or subnet \"%s\""),
|
||||
|
|
@ -3414,7 +3414,7 @@ _multilist_validate2_fcn_ip_config_dns(NMSetting *setting, const char *value, GE
|
|||
{
|
||||
int addr_family = nm_setting_ip_config_get_addr_family(NM_SETTING_IP_CONFIG(setting));
|
||||
|
||||
if (!nm_utils_parse_inaddr(addr_family, value, NULL)) {
|
||||
if (!nm_inet_parse_str(addr_family, value, NULL)) {
|
||||
nm_utils_error_set(error,
|
||||
NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
_("invalid IPv%c address '%s'"),
|
||||
|
|
@ -3541,7 +3541,7 @@ _set_fcn_ip_config_gateway(ARGS_SET_FCN)
|
|||
|
||||
value = nm_strstrip_avoid_copy_a(300, value, &value_to_free);
|
||||
|
||||
if (!nm_utils_ipaddr_is_valid(addr_family, value)) {
|
||||
if (!nm_inet_is_valid(addr_family, value)) {
|
||||
g_set_error(error,
|
||||
NM_UTILS_ERROR,
|
||||
NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ _nmc_mangle_connection(NMDevice *device,
|
|||
NMIPRoute *route_entry;
|
||||
NMIPRoutingRule *rule_entry;
|
||||
in_addr_t gateway;
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char sbuf[NM_INET_ADDRSTRLEN];
|
||||
|
||||
for (i = 0; i < config_data->ipv4s_len; i++) {
|
||||
addr_entry = nm_ip_address_new_binary(AF_INET,
|
||||
|
|
@ -357,8 +357,8 @@ _nmc_mangle_connection(NMDevice *device,
|
|||
if (config_data->has_gateway && config_data->gateway) {
|
||||
gateway = config_data->gateway;
|
||||
} else {
|
||||
gateway = nm_utils_ip4_address_clear_host_address(config_data->cidr_addr,
|
||||
config_data->cidr_prefix);
|
||||
gateway =
|
||||
nm_ip4_addr_clear_host_address(config_data->cidr_addr, config_data->cidr_prefix);
|
||||
if (config_data->cidr_prefix < 32)
|
||||
((guint8 *) &gateway)[3] += 1;
|
||||
}
|
||||
|
|
@ -366,7 +366,7 @@ _nmc_mangle_connection(NMDevice *device,
|
|||
for (i = 0; i < config_data->ipv4s_len; i++) {
|
||||
in_addr_t a = config_data->ipv4s_arr[i];
|
||||
|
||||
a = nm_utils_ip4_address_clear_host_address(a, config_data->cidr_prefix);
|
||||
a = nm_ip4_addr_clear_host_address(a, config_data->cidr_prefix);
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(gsize) >= sizeof(in_addr_t));
|
||||
if (g_hash_table_add(unique_subnets, GSIZE_TO_POINTER(a))) {
|
||||
|
|
@ -381,7 +381,7 @@ _nmc_mangle_connection(NMDevice *device,
|
|||
rule_entry = nm_ip_routing_rule_new(AF_INET);
|
||||
nm_ip_routing_rule_set_priority(rule_entry, 30200 + config_data->iface_idx);
|
||||
nm_ip_routing_rule_set_from(rule_entry,
|
||||
_nm_utils_inet4_ntop(config_data->ipv4s_arr[i], sbuf),
|
||||
nm_inet4_ntop(config_data->ipv4s_arr[i], sbuf),
|
||||
32);
|
||||
nm_ip_routing_rule_set_table(rule_entry, 30200 + config_data->iface_idx);
|
||||
nm_assert(nm_ip_routing_rule_validate(rule_entry, NULL));
|
||||
|
|
@ -405,7 +405,7 @@ _nmc_mangle_connection(NMDevice *device,
|
|||
rule_entry = nm_ip_routing_rule_new(AF_INET);
|
||||
nm_ip_routing_rule_set_priority(rule_entry, 30400 + config_data->iface_idx);
|
||||
nm_ip_routing_rule_set_from(rule_entry,
|
||||
_nm_utils_inet4_ntop(config_data->ipv4s_arr[i], sbuf),
|
||||
nm_inet4_ntop(config_data->ipv4s_arr[i], sbuf),
|
||||
32);
|
||||
nm_ip_routing_rule_set_table(rule_entry, 30400 + config_data->iface_idx);
|
||||
nm_assert(nm_ip_routing_rule_validate(rule_entry, NULL));
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ nmcs_utils_ipaddr_normalize_bin(int addr_family,
|
|||
|
||||
g_strstrip(ad);
|
||||
|
||||
return nm_utils_parse_inaddr_bin(addr_family, ad, out_addr_family, out_addr_bin);
|
||||
return nm_inet_parse_bin(addr_family, ad, out_addr_family, out_addr_bin);
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
@ -518,7 +518,7 @@ nmcs_utils_ipaddr_normalize(int addr_family, const char *addr, gssize len)
|
|||
if (!nmcs_utils_ipaddr_normalize_bin(addr_family, addr, len, &addr_family, &ipaddr))
|
||||
return NULL;
|
||||
|
||||
return nm_utils_inet_ntop_dup(addr_family, &ipaddr);
|
||||
return nm_inet_ntop_dup(addr_family, &ipaddr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
config_iface_data->ipv4s_arr = g_new(in_addr_t, len);
|
||||
for (i = 0; i < len; i++) {
|
||||
filter_chars((char *) s_addrs[i], "[]\"");
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET, s_addrs[i], NULL, &tmp_addr)) {
|
||||
if (nm_inet_parse_bin(AF_INET, s_addrs[i], NULL, &tmp_addr)) {
|
||||
config_iface_data->ipv4s_arr[config_iface_data->ipv4s_len++] = tmp_addr;
|
||||
}
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
|
||||
case GET_CONFIG_FETCH_DONE_TYPE_PRIMARY_IP_ADDRESS:
|
||||
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET, g_bytes_get_data(response, NULL), NULL, &tmp_addr)) {
|
||||
if (nm_inet_parse_bin(AF_INET, g_bytes_get_data(response, NULL), NULL, &tmp_addr)) {
|
||||
nm_assert(config_iface_data->priv.aliyun.primary_ip_address == 0);
|
||||
nm_assert(!config_iface_data->priv.aliyun.has_primary_ip_address);
|
||||
config_iface_data->priv.aliyun.primary_ip_address = tmp_addr;
|
||||
|
|
@ -186,11 +186,11 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
|
||||
case GET_CONFIG_FETCH_DONE_TYPE_SUBNET_VPC_CIDR_BLOCK:
|
||||
|
||||
if (nm_utils_parse_inaddr_prefix_bin(AF_INET,
|
||||
g_bytes_get_data(response, NULL),
|
||||
NULL,
|
||||
&tmp_addr,
|
||||
&tmp_prefix)) {
|
||||
if (nm_inet_parse_with_prefix_bin(AF_INET,
|
||||
g_bytes_get_data(response, NULL),
|
||||
NULL,
|
||||
&tmp_addr,
|
||||
&tmp_prefix)) {
|
||||
nm_assert(!config_iface_data->has_cidr);
|
||||
config_iface_data->has_cidr = TRUE;
|
||||
config_iface_data->cidr_addr = tmp_addr;
|
||||
|
|
@ -199,20 +199,14 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
|
||||
case GET_CONFIG_FETCH_DONE_TYPE_NETMASK:
|
||||
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET,
|
||||
g_bytes_get_data(response, NULL),
|
||||
NULL,
|
||||
&netmask_bin)) {
|
||||
config_iface_data->cidr_prefix = _nm_utils_ip4_netmask_to_prefix(netmask_bin);
|
||||
if (nm_inet_parse_bin(AF_INET, g_bytes_get_data(response, NULL), NULL, &netmask_bin)) {
|
||||
config_iface_data->cidr_prefix = nm_ip4_addr_netmask_to_prefix(netmask_bin);
|
||||
};
|
||||
break;
|
||||
|
||||
case GET_CONFIG_FETCH_DONE_TYPE_GATEWAY:
|
||||
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET,
|
||||
g_bytes_get_data(response, NULL),
|
||||
NULL,
|
||||
&gateway_bin)) {
|
||||
if (nm_inet_parse_bin(AF_INET, g_bytes_get_data(response, NULL), NULL, &gateway_bin)) {
|
||||
config_iface_data->has_gateway = TRUE;
|
||||
config_iface_data->gateway = gateway_bin;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
gs_free_error GError *error = NULL;
|
||||
const char *resp_str = NULL;
|
||||
gsize resp_len;
|
||||
char tmp_addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char tmp_addr_str[NM_INET_ADDRSTRLEN];
|
||||
in_addr_t tmp_addr;
|
||||
int tmp_prefix = -1;
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
}
|
||||
_LOGD("interface[%" G_GSSIZE_FORMAT "]: received address %s",
|
||||
iface_data->intern_iface_idx,
|
||||
_nm_utils_inet4_ntop(tmp_addr, tmp_addr_str));
|
||||
nm_inet4_ntop(tmp_addr, tmp_addr_str));
|
||||
iface_get_config->ipv4s_arr[iface_get_config->ipv4s_len] = tmp_addr;
|
||||
iface_get_config->has_ipv4s = TRUE;
|
||||
iface_get_config->ipv4s_len++;
|
||||
|
|
@ -159,7 +159,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
}
|
||||
_LOGD("interface[%" G_GSSIZE_FORMAT "]: received subnet address %s",
|
||||
iface_data->intern_iface_idx,
|
||||
_nm_utils_inet4_ntop(tmp_addr, tmp_addr_str));
|
||||
nm_inet4_ntop(tmp_addr, tmp_addr_str));
|
||||
iface_get_config->cidr_addr = tmp_addr;
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -151,16 +151,16 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
config_iface_data->ipv4s_arr = g_new(in_addr_t, len);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (nm_utils_parse_inaddr_bin(AF_INET, s_addrs[i], NULL, &tmp_addr))
|
||||
if (nm_inet_parse_bin(AF_INET, s_addrs[i], NULL, &tmp_addr))
|
||||
config_iface_data->ipv4s_arr[config_iface_data->ipv4s_len++] = tmp_addr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nm_utils_parse_inaddr_prefix_bin(AF_INET,
|
||||
g_bytes_get_data(response, NULL),
|
||||
NULL,
|
||||
&tmp_addr,
|
||||
&tmp_prefix)) {
|
||||
if (nm_inet_parse_with_prefix_bin(AF_INET,
|
||||
g_bytes_get_data(response, NULL),
|
||||
NULL,
|
||||
&tmp_addr,
|
||||
&tmp_prefix)) {
|
||||
nm_assert(!config_iface_data->has_cidr);
|
||||
config_iface_data->has_cidr = TRUE;
|
||||
config_iface_data->cidr_prefix = tmp_prefix;
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ get_ip_address_family(const char *str, gboolean with_prefix)
|
|||
return AF_UNSPEC;
|
||||
|
||||
if (with_prefix) {
|
||||
if (nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC, str, &addr_family, NULL, NULL))
|
||||
if (nm_inet_parse_with_prefix_bin(AF_UNSPEC, str, &addr_family, NULL, NULL))
|
||||
return addr_family;
|
||||
} else {
|
||||
if (nm_utils_parse_inaddr_bin(AF_UNSPEC, str, &addr_family, NULL))
|
||||
if (nm_inet_parse_bin(AF_UNSPEC, str, &addr_family, NULL))
|
||||
return addr_family;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -632,8 +632,8 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||
gboolean is_ipv4 = client_ip_family == AF_INET;
|
||||
NMIPAddr addr;
|
||||
|
||||
if (is_ipv4 && nm_utils_parse_inaddr_bin(AF_INET, netmask, NULL, &addr))
|
||||
client_ip_prefix = _nm_utils_ip4_netmask_to_prefix(addr.addr4);
|
||||
if (is_ipv4 && nm_inet_parse_bin(AF_INET, netmask, NULL, &addr))
|
||||
client_ip_prefix = nm_ip4_addr_netmask_to_prefix(addr.addr4);
|
||||
else
|
||||
client_ip_prefix = _nm_utils_ascii_str_to_int64(netmask, 10, 0, is_ipv4 ? 32 : 128, -1);
|
||||
|
||||
|
|
@ -646,15 +646,15 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||
NMIPAddress *address = NULL;
|
||||
NMIPAddr addr;
|
||||
|
||||
if (nm_utils_parse_inaddr_prefix_bin(client_ip_family,
|
||||
client_ip,
|
||||
NULL,
|
||||
&addr,
|
||||
client_ip_prefix == -1 ? &client_ip_prefix : NULL)) {
|
||||
if (nm_inet_parse_with_prefix_bin(client_ip_family,
|
||||
client_ip,
|
||||
NULL,
|
||||
&addr,
|
||||
client_ip_prefix == -1 ? &client_ip_prefix : NULL)) {
|
||||
if (client_ip_prefix == -1) {
|
||||
switch (client_ip_family) {
|
||||
case AF_INET:
|
||||
client_ip_prefix = _nm_utils_ip4_get_default_prefix(addr.addr4);
|
||||
client_ip_prefix = nm_ip4_addr_get_default_prefix(addr.addr4);
|
||||
break;
|
||||
case AF_INET6:
|
||||
client_ip_prefix = 64;
|
||||
|
|
@ -842,7 +842,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||
for (i = 0; i < 2; i++) {
|
||||
if (dns_addr_family[i] == AF_UNSPEC)
|
||||
break;
|
||||
nm_assert(nm_utils_ipaddr_is_valid(dns_addr_family[i], dns[i]));
|
||||
nm_assert(nm_inet_is_valid(dns_addr_family[i], dns[i]));
|
||||
nm_setting_ip_config_add_dns(NM_IS_IPv4(dns_addr_family[i]) ? s_ip4 : s_ip6, dns[i]);
|
||||
}
|
||||
|
||||
|
|
@ -964,14 +964,14 @@ reader_add_routes(Reader *reader, GPtrArray *array)
|
|||
connection = reader_get_default_connection(reader);
|
||||
|
||||
if (net && *net) {
|
||||
if (!nm_utils_parse_inaddr_prefix_bin(family, net, &family, &net_addr, &net_prefix)) {
|
||||
if (!nm_inet_parse_with_prefix_bin(family, net, &family, &net_addr, &net_prefix)) {
|
||||
_LOGW(LOGD_CORE, "Unrecognized address: %s", net);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (gateway && *gateway) {
|
||||
if (!nm_utils_parse_inaddr_bin(family, gateway, &family, &gateway_addr)) {
|
||||
if (!nm_inet_parse_bin(family, gateway, &family, &gateway_addr)) {
|
||||
_LOGW(LOGD_CORE, "Unrecognized address: %s", gateway);
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ str_addr(const char *str, int *family)
|
|||
{
|
||||
NMIPAddr addr_bin;
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin_full(*family, TRUE, str, family, &addr_bin)) {
|
||||
if (!nm_inet_parse_bin_full(*family, TRUE, str, family, &addr_bin)) {
|
||||
_LOGW(LOGD_CORE, "Malformed IP address: '%s'", str);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ nmi_dt_reader_parse(const char *sysfs_dir)
|
|||
guint32 netmask_v4;
|
||||
|
||||
nm_ip_address_get_address_binary(netmask, &netmask_v4);
|
||||
prefix = _nm_utils_ip4_netmask_to_prefix(netmask_v4);
|
||||
prefix = nm_ip4_addr_netmask_to_prefix(netmask_v4);
|
||||
}
|
||||
|
||||
if (prefix == -1)
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ ip_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **er
|
|||
FALSE,
|
||||
NULL);
|
||||
|
||||
if (s_gateway && !nm_utils_ipaddr_is_valid(family, s_gateway)) {
|
||||
if (s_gateway && !nm_inet_is_valid(family, s_gateway)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -226,7 +226,7 @@ ip_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **er
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (s_dns1 && !nm_utils_ipaddr_is_valid(family, s_dns1)) {
|
||||
if (s_dns1 && !nm_inet_is_valid(family, s_dns1)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
@ -235,7 +235,7 @@ ip_setting_add_from_block(GHashTable *nic, NMConnection *connection, GError **er
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (s_dns2 && !nm_utils_ipaddr_is_valid(family, s_dns2)) {
|
||||
if (s_dns2 && !nm_inet_is_valid(family, s_dns2)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ ip_addresses_with_prefix_from_strv(GBinding *binding,
|
|||
} else
|
||||
addr = addrs->pdata[i];
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix(addr_family, strings[i], &addrstr, &prefix)) {
|
||||
if (!nm_inet_parse_with_prefix_str(addr_family, strings[i], &addrstr, &prefix)) {
|
||||
g_ptr_array_unref(addrs);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ ip_addresses_with_prefix_from_strv(GBinding *binding,
|
|||
in_addr_t v4;
|
||||
|
||||
inet_pton(addr_family, addrstr, &v4);
|
||||
if (nm_utils_ip_is_site_local(AF_INET, &v4))
|
||||
if (nm_ip_addr_is_site_local(AF_INET, &v4))
|
||||
prefix = nm_utils_ip4_get_default_prefix(v4);
|
||||
else
|
||||
prefix = 32;
|
||||
|
|
@ -194,7 +194,7 @@ ip_addresses_check_and_copy(GBinding *binding,
|
|||
strings = g_value_get_boxed(source_value);
|
||||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (!nm_utils_ipaddr_is_valid(addr_family, strings[i]))
|
||||
if (!nm_inet_is_valid(addr_family, strings[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ ip_gateway_from_string(GBinding *binding,
|
|||
const char *gateway;
|
||||
|
||||
gateway = g_value_get_string(source_value);
|
||||
if (gateway && !nm_utils_ipaddr_is_valid(addr_family, gateway))
|
||||
if (gateway && !nm_inet_is_valid(addr_family, gateway))
|
||||
gateway = NULL;
|
||||
|
||||
g_value_set_string(target_value, gateway);
|
||||
|
|
@ -428,7 +428,7 @@ ip_route_transform_from_dest_string(GBinding *binding,
|
|||
int prefix;
|
||||
|
||||
text = g_value_get_string(source_value);
|
||||
if (!nm_utils_parse_inaddr_prefix(addr_family, text, &addrstr, &prefix))
|
||||
if (!nm_inet_parse_with_prefix_str(addr_family, text, &addrstr, &prefix))
|
||||
return FALSE;
|
||||
|
||||
/* Fetch the original property value */
|
||||
|
|
@ -442,9 +442,9 @@ ip_route_transform_from_dest_string(GBinding *binding,
|
|||
in_addr_t v4;
|
||||
|
||||
inet_pton(addr_family, addrstr, &v4);
|
||||
if (nm_utils_ip_is_site_local(AF_INET, &v4)) {
|
||||
if (nm_ip_addr_is_site_local(AF_INET, &v4)) {
|
||||
prefix = nm_utils_ip4_get_default_prefix(v4);
|
||||
if (v4 & (~_nm_utils_ip4_prefix_to_netmask(prefix)))
|
||||
if (v4 & (~nm_ip4_addr_netmask_from_prefix(prefix)))
|
||||
prefix = 32;
|
||||
} else
|
||||
prefix = 32;
|
||||
|
|
@ -472,7 +472,7 @@ ip_route_transform_from_next_hop_string(GBinding *binding,
|
|||
|
||||
text = g_value_get_string(source_value);
|
||||
if (*text) {
|
||||
if (!nm_utils_ipaddr_is_valid(addr_family, text))
|
||||
if (!nm_inet_is_valid(addr_family, text))
|
||||
return FALSE;
|
||||
} else
|
||||
text = NULL;
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ ip_entry_validate(NmtNewtEntry *entry, const char *text, gpointer user_data)
|
|||
if (!*text)
|
||||
return priv->optional;
|
||||
if (priv->prefix)
|
||||
return nm_utils_parse_inaddr_prefix(priv->family, text, NULL, NULL);
|
||||
return nm_utils_parse_inaddr(priv->family, text, NULL);
|
||||
return nm_inet_parse_with_prefix_str(priv->family, text, NULL, NULL);
|
||||
return nm_inet_parse_str(priv->family, text, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue