diff options
author | Thomas Haller <thaller@redhat.com> | 2022-08-19 13:15:20 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-08-25 19:05:51 +0200 |
commit | 08eff4c46ee618fcf00ddde28a425d10ba0df041 (patch) | |
tree | 8c94bcb61a7043ee3a3cbd4e5050cc4a7d280ecf /src/nm-cloud-setup | |
parent | d65feb26e53bb6442f2a61cd97ad70bc3b9aad4b (diff) | |
download | NetworkManager-08eff4c46ee618fcf00ddde28a425d10ba0df041.tar.gz |
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
Diffstat (limited to 'src/nm-cloud-setup')
-rw-r--r-- | src/nm-cloud-setup/main.c | 12 | ||||
-rw-r--r-- | src/nm-cloud-setup/nm-cloud-setup-utils.c | 4 | ||||
-rw-r--r-- | src/nm-cloud-setup/nmcs-provider-aliyun.c | 26 | ||||
-rw-r--r-- | src/nm-cloud-setup/nmcs-provider-azure.c | 6 | ||||
-rw-r--r-- | src/nm-cloud-setup/nmcs-provider-ec2.c | 12 |
5 files changed, 27 insertions, 33 deletions
diff --git a/src/nm-cloud-setup/main.c b/src/nm-cloud-setup/main.c index 0c452acfe3..6f4e06605a 100644 --- a/src/nm-cloud-setup/main.c +++ b/src/nm-cloud-setup/main.c @@ -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)); diff --git a/src/nm-cloud-setup/nm-cloud-setup-utils.c b/src/nm-cloud-setup/nm-cloud-setup-utils.c index e505f8bd03..e8c9943d78 100644 --- a/src/nm-cloud-setup/nm-cloud-setup-utils.c +++ b/src/nm-cloud-setup/nm-cloud-setup-utils.c @@ -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); } /*****************************************************************************/ diff --git a/src/nm-cloud-setup/nmcs-provider-aliyun.c b/src/nm-cloud-setup/nmcs-provider-aliyun.c index 34ab5ecc87..4b1096094d 100644 --- a/src/nm-cloud-setup/nmcs-provider-aliyun.c +++ b/src/nm-cloud-setup/nmcs-provider-aliyun.c @@ -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; }; diff --git a/src/nm-cloud-setup/nmcs-provider-azure.c b/src/nm-cloud-setup/nmcs-provider-azure.c index 9b27af288a..b59235bfee 100644 --- a/src/nm-cloud-setup/nmcs-provider-azure.c +++ b/src/nm-cloud-setup/nmcs-provider-azure.c @@ -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; diff --git a/src/nm-cloud-setup/nmcs-provider-ec2.c b/src/nm-cloud-setup/nmcs-provider-ec2.c index d6fa03118d..58d691c79e 100644 --- a/src/nm-cloud-setup/nmcs-provider-ec2.c +++ b/src/nm-cloud-setup/nmcs-provider-ec2.c @@ -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; |