tui: merge branch 'th/tui-route-input-rh1474295'

https://bugzilla.redhat.com/show_bug.cgi?id=1474295
This commit is contained in:
Thomas Haller 2017-09-05 19:11:17 +02:00
commit 08d7bf5988
24 changed files with 271 additions and 124 deletions

View file

@ -3423,6 +3423,8 @@ clients_tui_newt_libnmt_newt_a_CPPFLAGS = \
bin_PROGRAMS += clients/tui/nmtui
clients_tui_nmtui_SOURCES = \
shared/nm-utils/nm-shared-utils.c \
shared/nm-utils/nm-shared-utils.h \
clients/tui/nmtui.c \
clients/tui/nmtui.h \
clients/tui/nmtui-connect.c \

View file

@ -38,12 +38,14 @@ G_DEFINE_TYPE (NmtNewtEntryNumeric, nmt_newt_entry_numeric, NMT_TYPE_NEWT_ENTRY)
typedef struct {
int min, max;
bool optional;
} NmtNewtEntryNumericPrivate;
enum {
PROP_0,
PROP_MINIMUM,
PROP_MAXIMUM,
PROP_OPTIONAL,
LAST_PROP
};
@ -63,11 +65,36 @@ NmtNewtWidget *
nmt_newt_entry_numeric_new (int width,
int min,
int max)
{
return nmt_newt_entry_numeric_new_full (width,
min,
max,
FALSE);
}
/**
* nmt_newt_entry_numeric_new_full:
* @width: the entry's width in characters
* @min: the minimum valid value
* @max: the maximum valid value
* @optional: whether an empty entry is valid
*
* Creates a new #NmtNewtEntryNumeric, accepting values in the
* indicated range.
*
* Returns: a new #NmtNewtEntryNumeric
*/
NmtNewtWidget *
nmt_newt_entry_numeric_new_full (int width,
int min,
int max,
gboolean optional)
{
return g_object_new (NMT_TYPE_NEWT_ENTRY_NUMERIC,
"width", width,
"minimum", min,
"maximum", max,
"optional", optional,
NULL);
}
@ -96,18 +123,12 @@ newt_entry_numeric_validate (NmtNewtEntry *entry,
{
NmtNewtEntryNumericPrivate *priv = NMT_NEWT_ENTRY_NUMERIC_GET_PRIVATE (entry);
int val;
char *end;
if (!*text)
return FALSE;
return priv->optional ? TRUE : FALSE;
val = strtoul (text, &end, 10);
if (*end)
return FALSE;
if (val < priv->min || val > priv->max)
return FALSE;
return TRUE;
val = _nm_utils_ascii_str_to_int64 (text, 10, priv->min, priv->max, 0);
return val != 0 || errno == 0;
}
static void
@ -147,6 +168,9 @@ nmt_newt_entry_numeric_set_property (GObject *object,
case PROP_MAXIMUM:
priv->max = g_value_get_int (value);
break;
case PROP_OPTIONAL:
priv->optional = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -168,6 +192,9 @@ nmt_newt_entry_numeric_get_property (GObject *object,
case PROP_MAXIMUM:
g_value_set_int (value, priv->max);
break;
case PROP_OPTIONAL:
g_value_set_boolean (value, priv->optional);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -212,4 +239,17 @@ nmt_newt_entry_numeric_class_init (NmtNewtEntryNumericClass *entry_class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* NmtNewtEntryNumeric:optional:
*
* If %TRUE, allow empty string to indicate some default value.
* It means the property is optional and can be left at the default
*/
g_object_class_install_property
(object_class, PROP_OPTIONAL,
g_param_spec_boolean ("optional", "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
}

View file

@ -44,4 +44,9 @@ NmtNewtWidget *nmt_newt_entry_numeric_new (int width,
int min,
int max);
NmtNewtWidget *nmt_newt_entry_numeric_new_full (int width,
int min,
int max,
gboolean optional);
#endif /* NMT_NEWT_ENTRY_NUMERIC_H */

View file

@ -70,45 +70,6 @@ nm_editor_bindings_init (void)
g_value_register_transform_func (G_TYPE_STRING, G_TYPE_UINT, value_transform_string_uint);
}
static gboolean
parse_addr_prefix (const char *text,
int family,
char **addr,
guint32 *prefix)
{
const char *slash;
char *addrstr, *end;
gboolean valid;
slash = strchr (text, '/');
if (slash)
addrstr = g_strndup (text, slash - text);
else
addrstr = g_strdup (text);
valid = nm_utils_ipaddr_valid (family, addrstr);
if (slash) {
*prefix = strtoul (slash + 1, &end, 10);
if ( *end
|| *prefix == 0
|| (family == AF_INET && *prefix > 32)
|| (family == AF_INET6 && *prefix > 128))
valid = FALSE;
} else if (prefix) {
if (family == AF_INET)
*prefix = 32;
else
*prefix = 128;
}
if (addr && valid)
*addr = addrstr;
else
g_free (addrstr);
return valid;
}
static gboolean
ip_addresses_with_prefix_to_strv (GBinding *binding,
const GValue *source_value,
@ -151,7 +112,7 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
GPtrArray *addrs;
NMIPAddress *addr;
char *addrstr;
guint32 prefix;
int prefix;
int i;
strings = g_value_get_boxed (source_value);
@ -170,11 +131,24 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
} else
addr = addrs->pdata[i];
if (!parse_addr_prefix (strings[i], family, &addrstr, &prefix)) {
if (!nm_utils_parse_inaddr_prefix (strings[i], family, &addrstr, &prefix)) {
g_ptr_array_unref (addrs);
return FALSE;
}
if (prefix == -1) {
if (family == AF_INET) {
in_addr_t v4;
inet_pton (family, addrstr, &v4);
if (nm_utils_ip_is_site_local (AF_INET, &v4))
prefix = nm_utils_ip4_get_default_prefix (v4);
else
prefix = 32;
} else
prefix = 64;
}
nm_ip_address_set_address (addr, addrstr);
nm_ip_address_set_prefix (addr, prefix);
g_free (addrstr);
@ -451,10 +425,10 @@ ip_route_transform_from_dest_string (GBinding *binding,
NMIPRoute *route;
const char *text;
char *addrstr;
guint32 prefix;
int prefix;
text = g_value_get_string (source_value);
if (!parse_addr_prefix (text, family, &addrstr, &prefix))
if (!nm_utils_parse_inaddr_prefix (text, family, &addrstr, &prefix))
return FALSE;
/* Fetch the original property value */
@ -462,6 +436,21 @@ ip_route_transform_from_dest_string (GBinding *binding,
g_binding_get_source_property (binding), &route,
NULL);
if (prefix == -1) {
if (family == AF_INET) {
in_addr_t v4;
inet_pton (family, addrstr, &v4);
if (nm_utils_ip_is_site_local (AF_INET, &v4)) {
prefix = nm_utils_ip4_get_default_prefix (v4);
if (v4 & (~nm_utils_ip4_prefix_to_netmask (prefix)))
prefix = 32;
} else
prefix = 32;
} else
prefix = 64;
}
nm_ip_route_set_dest (route, addrstr);
nm_ip_route_set_prefix (route, prefix);
g_free (addrstr);

View file

@ -123,39 +123,12 @@ ip_entry_validate (NmtNewtEntry *entry,
gpointer user_data)
{
NmtIPEntryPrivate *priv = NMT_IP_ENTRY_GET_PRIVATE (entry);
guchar buf[16];
guint32 prefix;
const char *slash;
char *addrstr, *end;
gboolean valid;
if (!*text)
return priv->optional;
slash = strchr (text, '/');
if (slash) {
if (!priv->prefix)
return FALSE;
addrstr = g_strndup (text, slash - text);
} else
addrstr = g_strdup (text);
valid = (inet_pton (priv->family, addrstr, buf) == 1);
g_free (addrstr);
if (!valid)
return FALSE;
if (slash) {
prefix = strtoul (slash + 1, &end, 10);
if ( *end
|| prefix == 0
|| (priv->family == AF_INET && prefix > 32)
|| (priv->family == AF_INET6 && prefix > 128))
valid = FALSE;
}
return valid;
if (priv->prefix)
return nm_utils_parse_inaddr_prefix (text, priv->family, NULL, NULL);
return nm_utils_parse_inaddr (text, priv->family, NULL);
}
static void

View file

@ -126,7 +126,7 @@ nmt_route_entry_constructed (GObject *object)
priv->dest = nmt_ip_entry_new (priv->ip_entry_width, priv->family, TRUE, FALSE);
priv->next_hop = nmt_ip_entry_new (priv->ip_entry_width, priv->family, FALSE, TRUE);
priv->metric = nmt_newt_entry_numeric_new (priv->metric_entry_width, 0, 65535);
priv->metric = nmt_newt_entry_numeric_new_full (priv->metric_entry_width, 0, 65535, TRUE);
nmt_newt_grid_add (grid, priv->dest, 0, 0);
warning_label = create_warning_label (priv->dest);

View file

@ -149,9 +149,9 @@ add_route (NmtWidgetList *list,
NMIPRoute *route;
if (priv->family == AF_INET)
route = nm_ip_route_new (AF_INET, "0.0.0.0", 32, NULL, 0, NULL);
route = nm_ip_route_new (AF_INET, "0.0.0.0", 32, NULL, -1, NULL);
else
route = nm_ip_route_new (AF_INET6, "::", 128, NULL, 0, NULL);
route = nm_ip_route_new (AF_INET6, "::", 128, NULL, -1, NULL);
g_ptr_array_add (priv->routes, route);
nmt_widget_list_set_length (list, priv->routes->len);
g_object_notify (table, "routes");

View file

@ -1490,10 +1490,9 @@ nm_utils_ip4_netmask_to_prefix (guint32 netmask)
guint32
nm_utils_ip4_prefix_to_netmask (guint32 prefix)
{
return prefix < 32 ? ~htonl(0xFFFFFFFF >> prefix) : 0xFFFFFFFF;
return _nm_utils_ip4_prefix_to_netmask (prefix);
}
/**
* nm_utils_ip4_get_default_prefix:
* @ip: an IPv4 address (in network byte order)
@ -1509,12 +1508,7 @@ nm_utils_ip4_prefix_to_netmask (guint32 prefix)
guint32
nm_utils_ip4_get_default_prefix (guint32 ip)
{
if (((ntohl (ip) & 0xFF000000) >> 24) <= 127)
return 8; /* Class A - 255.0.0.0 */
else if (((ntohl (ip) & 0xFF000000) >> 24) <= 191)
return 16; /* Class B - 255.255.0.0 */
return 24; /* Class C - 255.255.255.0 */
return _nm_utils_ip4_get_default_prefix (ip);
}
/**

View file

@ -3249,7 +3249,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_utils_ip4_prefix_to_netmask (i);
int plen = nm_utils_ip4_netmask_to_prefix (netmask);
g_assert_cmpint (i, ==, plen);
@ -3277,8 +3277,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_utils_ip4_prefix_to_netmask (i);
guint32 netmask_lowest_bit = netmask & ~_nm_utils_ip4_prefix_to_netmask (i-1);
g_assert_cmpint (i, ==, nm_utils_ip4_netmask_to_prefix (netmask));

View file

@ -1102,7 +1102,7 @@ nm_utils_ip4_netmask_to_prefix (guint32 netmask)
guint32
nm_utils_ip4_prefix_to_netmask (guint32 prefix)
{
return prefix < 32 ? ~htonl(0xFFFFFFFF >> prefix) : 0xFFFFFFFF;
return _nm_utils_ip4_prefix_to_netmask (prefix);
}
@ -1121,12 +1121,7 @@ nm_utils_ip4_prefix_to_netmask (guint32 prefix)
guint32
nm_utils_ip4_get_default_prefix (guint32 ip)
{
if (((ntohl (ip) & 0xFF000000) >> 24) <= 127)
return 8; /* Class A - 255.0.0.0 */
else if (((ntohl (ip) & 0xFF000000) >> 24) <= 191)
return 16; /* Class B - 255.255.0.0 */
return 24; /* Class C - 255.255.255.0 */
return _nm_utils_ip4_get_default_prefix (ip);
}
/**

View file

@ -24,6 +24,7 @@
#include "nm-shared-utils.h"
#include <errno.h>
#include <arpa/inet.h>
/*****************************************************************************/
@ -110,6 +111,137 @@ nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...)
/*****************************************************************************/
/**
* _nm_utils_ip4_prefix_to_netmask:
* @prefix: a CIDR prefix
*
* Returns: the netmask represented by the prefix, in network byte order
**/
guint32
_nm_utils_ip4_prefix_to_netmask (guint32 prefix)
{
return prefix < 32 ? ~htonl(0xFFFFFFFF >> prefix) : 0xFFFFFFFF;
}
/**
* _nm_utils_ip4_get_default_prefix:
* @ip: an IPv4 address (in network byte order)
*
* When the Internet was originally set up, various ranges of IP addresses were
* segmented into three network classes: A, B, and C. This function will return
* a prefix that is associated with the IP address specified defining where it
* falls in the predefined classes.
*
* Returns: the default class prefix for the given IP
**/
/* The function is originally from ipcalc.c of Red Hat's initscripts. */
guint32
_nm_utils_ip4_get_default_prefix (guint32 ip)
{
if (((ntohl (ip) & 0xFF000000) >> 24) <= 127)
return 8; /* Class A - 255.0.0.0 */
else if (((ntohl (ip) & 0xFF000000) >> 24) <= 191)
return 16; /* Class B - 255.255.0.0 */
return 24; /* Class C - 255.255.255.0 */
}
gboolean
nm_utils_ip_is_site_local (int addr_family,
const void *address)
{
in_addr_t addr4;
switch (addr_family) {
case AF_INET:
/* RFC1918 private addresses
* 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 */
addr4 = ntohl (*((const in_addr_t *) address));
return (addr4 & 0xff000000) == 0x0a000000
|| (addr4 & 0xfff00000) == 0xac100000
|| (addr4 & 0xffff0000) == 0xc0a80000;
case AF_INET6:
return IN6_IS_ADDR_SITELOCAL (address);
default:
g_return_val_if_reached (FALSE);
}
}
/*****************************************************************************/
gboolean
nm_utils_parse_inaddr (const char *text,
int family,
char **out_addr)
{
union {
in_addr_t v4;
struct in6_addr v6;
} addrbin;
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
g_return_val_if_fail (text, FALSE);
if (family == AF_UNSPEC)
family = strchr (text, ':') ? AF_INET6 : AF_INET;
else
g_return_val_if_fail (NM_IN_SET (family, AF_INET, AF_INET6), FALSE);
if (inet_pton (family, text, &addrbin) != 1)
return FALSE;
NM_SET_OUT (out_addr, g_strdup (inet_ntop (family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
return TRUE;
}
gboolean
nm_utils_parse_inaddr_prefix (const char *text,
int family,
char **out_addr,
int *out_prefix)
{
gs_free char *addrstr_free = NULL;
int prefix = -1;
const char *slash;
const char *addrstr;
union {
in_addr_t v4;
struct in6_addr v6;
} addrbin;
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
g_return_val_if_fail (text, FALSE);
if (family == AF_UNSPEC)
family = strchr (text, ':') ? AF_INET6 : AF_INET;
else
g_return_val_if_fail (NM_IN_SET (family, AF_INET, AF_INET6), FALSE);
slash = strchr (text, '/');
if (slash)
addrstr = addrstr_free = g_strndup (text, slash - text);
else
addrstr = text;
if (inet_pton (family, addrstr, &addrbin) != 1)
return FALSE;
if (slash) {
prefix = _nm_utils_ascii_str_to_int64 (slash + 1, 10,
0,
family == AF_INET ? 32 : 128,
-1);
if (prefix == -1)
return FALSE;
}
NM_SET_OUT (out_addr, g_strdup (inet_ntop (family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
NM_SET_OUT (out_prefix, prefix);
return TRUE;
}
/*****************************************************************************/
/* _nm_utils_ascii_str_to_int64:
*
* A wrapper for g_ascii_strtoll, that checks whether the whole string

View file

@ -143,6 +143,23 @@ char **_nm_utils_strv_cleanup (char **strv,
/*****************************************************************************/
guint32 _nm_utils_ip4_prefix_to_netmask (guint32 prefix);
guint32 _nm_utils_ip4_get_default_prefix (guint32 ip);
gboolean nm_utils_ip_is_site_local (int addr_family,
const void *address);
/*****************************************************************************/
gboolean nm_utils_parse_inaddr (const char *text,
int family,
char **out_addr);
gboolean nm_utils_parse_inaddr_prefix (const char *text,
int family,
char **out_addr,
int *out_prefix);
gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback);
gint _nm_utils_ascii_str_to_bool (const char *str,

View file

@ -8385,7 +8385,7 @@ start_sharing (NMDevice *self, NMIP4Config *config)
if (!ip4_addr || !ip4_addr->address)
return FALSE;
netmask = nm_utils_ip4_prefix_to_netmask (ip4_addr->plen);
netmask = _nm_utils_ip4_prefix_to_netmask (ip4_addr->plen);
if (!inet_ntop (AF_INET, &netmask, str_mask, sizeof (str_mask)))
return FALSE;

View file

@ -782,7 +782,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (NMDedupMultiIndex *multi_idx,
/* Get default netmask for the IP according to appropriate class. */
if (!address.plen)
address.plen = nm_utils_ip4_get_default_prefix (address.address);
address.plen = _nm_utils_ip4_get_default_prefix (address.address);
address.timestamp = now_monotonic_ts;
address.lifetime = address.preferred = expiry;

View file

@ -317,8 +317,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_utils_ip4_get_default_prefix (rt_addr);
if (rt_addr & ~_nm_utils_ip4_prefix_to_netmask (route.plen)) {
/* RFC 943: target not "this network"; using host routing */
route.plen = 32;
}
@ -418,7 +418,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
_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_utils_ip4_get_default_prefix (addr);
_LOG2I (LOGD_DHCP4, iface, " plen %d (default)", plen);
}
nm_platform_ip4_address_set_addr (&address, addr, plen);

View file

@ -65,7 +65,7 @@ nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr,
prefix = 24;
}
netmask = nm_utils_ip4_prefix_to_netmask (prefix);
netmask = _nm_utils_ip4_prefix_to_netmask (prefix);
/* treat addresses in host-order from here on. */
netmask = ntohl (netmask);

View file

@ -278,7 +278,7 @@ nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer
in_addr_t
nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen)
{
return addr & nm_utils_ip4_prefix_to_netmask (plen);
return addr & _nm_utils_ip4_prefix_to_netmask (plen);
}
/* nm_utils_ip6_address_clear_host_address:

View file

@ -61,7 +61,7 @@ nm_ip_config_obj_id_equal_ip4_address (const NMPlatformIP4Address *a,
{
return a->address == b->address
&& a->plen == b->plen
&& ((a->peer_address ^ b->peer_address) & nm_utils_ip4_prefix_to_netmask (a->plen)) == 0;
&& ((a->peer_address ^ b->peer_address) & _nm_utils_ip4_prefix_to_netmask (a->plen)) == 0;
}
gboolean
@ -589,8 +589,8 @@ _addresses_sort_cmp (gconstpointer a, gconstpointer b, gpointer user_data)
* subnet (and thus also the primary/secondary role) is
* preserved.
*/
n1 = a1->address & nm_utils_ip4_prefix_to_netmask (a1->plen);
n2 = a2->address & nm_utils_ip4_prefix_to_netmask (a2->plen);
n1 = a1->address & _nm_utils_ip4_prefix_to_netmask (a1->plen);
n2 = a2->address & _nm_utils_ip4_prefix_to_netmask (a2->plen);
return memcmp (&n1, &n2, sizeof (guint32));
}
@ -2698,7 +2698,7 @@ nm_ip4_config_hash (const NMIP4Config *self, GChecksum *sum, gboolean dns_only)
nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, self, &address) {
hash_u32 (sum, address->address);
hash_u32 (sum, address->plen);
hash_u32 (sum, address->peer_address & nm_utils_ip4_prefix_to_netmask (address->plen));
hash_u32 (sum, address->peer_address & _nm_utils_ip4_prefix_to_netmask (address->plen));
}
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, self, &route) {

View file

@ -1071,7 +1071,7 @@ ipx_address_delete (NMPlatform *platform,
|| (addr && address->address != *((guint32 *) addr))
|| (plen && address->plen != *plen)
|| ( peer_addr
&& (((peer_addr_i ^ address->peer_address) & nm_utils_ip4_prefix_to_netmask (address->plen)) != 0)))
&& (((peer_addr_i ^ address->peer_address) & _nm_utils_ip4_prefix_to_netmask (address->plen)) != 0)))
continue;
} else {
const NMPlatformIP6Address *address = NMP_OBJECT_CAST_IP6_ADDRESS (o);

View file

@ -2543,7 +2543,7 @@ _nl_msg_new_address (int nlmsg_type,
&& *((in_addr_t *) address) != 0) {
in_addr_t broadcast;
broadcast = *((in_addr_t *) address) | ~nm_utils_ip4_prefix_to_netmask (plen);
broadcast = *((in_addr_t *) address) | ~_nm_utils_ip4_prefix_to_netmask (plen);
NLA_PUT (msg, IFA_BROADCAST, addr_len, &broadcast);
}

View file

@ -3190,7 +3190,7 @@ ip4_addr_subnets_build_index (const GPtrArray *addresses,
p_address = &addresses->pdata[i];
address = NMP_OBJECT_CAST_IP4_ADDRESS (addresses->pdata[i]);
net = address->address & nm_utils_ip4_prefix_to_netmask (address->plen);
net = address->address & _nm_utils_ip4_prefix_to_netmask (address->plen);
if (!g_hash_table_lookup_extended (subnets, GUINT_TO_POINTER (net), NULL, &p)) {
g_hash_table_insert (subnets, GUINT_TO_POINTER (net), p_address);
continue;
@ -3251,7 +3251,7 @@ ip4_addr_subnets_is_secondary (const NMPObject *address,
a = NMP_OBJECT_CAST_IP4_ADDRESS (address);
net = a->address & nm_utils_ip4_prefix_to_netmask (a->plen);
net = a->address & _nm_utils_ip4_prefix_to_netmask (a->plen);
p = g_hash_table_lookup (subnets, GUINT_TO_POINTER (net));
nm_assert (p);
if (!ip4_addr_subnets_is_plain_address (addresses, p)) {

View file

@ -740,7 +740,7 @@ _vt_cmd_plobj_to_string_id_##type (const NMPlatformObject *_obj, char *buf, gsiz
_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 (obj->peer_address & nm_utils_ip4_prefix_to_netmask (obj->plen), buf2) : "");
obj->peer_address != obj->address ? nm_utils_inet4_ntop (obj->peer_address & _nm_utils_ip4_prefix_to_netmask (obj->plen), buf2) : "");
_vt_cmd_plobj_to_string_id (ip6_address, NMPlatformIP6Address, "%d: %s", obj->ifindex, nm_utils_inet6_ntop (&obj->address, buf1));
guint
@ -1102,7 +1102,7 @@ _vt_cmd_plobj_id_hash (ip4_address, NMPlatformIP4Address, {
hash = NM_HASH_COMBINE (hash, obj->plen);
hash = NM_HASH_COMBINE (hash, obj->address);
/* for IPv4 we must also consider the net-part of the peer-address (IFA_ADDRESS) */
hash = NM_HASH_COMBINE (hash, (obj->peer_address & nm_utils_ip4_prefix_to_netmask (obj->plen)));
hash = NM_HASH_COMBINE (hash, (obj->peer_address & _nm_utils_ip4_prefix_to_netmask (obj->plen)));
})
_vt_cmd_plobj_id_hash (ip6_address, NMPlatformIP6Address, {
hash = (guint) 2907861637u;

View file

@ -399,7 +399,7 @@ read_full_ip4_address (shvarFile *ifcfg,
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_utils_ip4_get_default_prefix (ipaddr);
PARSE_WARNING ("missing %s, assuming %s/%d", prefix_tag, nm_utils_inet4_ntop (ipaddr, inet_buf), prefix);
}
}
@ -588,7 +588,7 @@ read_one_ip4_route (shvarFile *ifcfg,
return FALSE;
if (has_key) {
prefix = nm_utils_ip4_netmask_to_prefix (netmask);
if (prefix == 0 || netmask != nm_utils_ip4_prefix_to_netmask (prefix)) {
if (prefix == 0 || netmask != _nm_utils_ip4_prefix_to_netmask (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));
return FALSE;

View file

@ -2151,7 +2151,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
char buf[INET_ADDRSTRLEN];
svSetValueStr (ifcfg, tag,
nm_utils_inet4_ntop (nm_utils_ip4_prefix_to_netmask (prefix), buf));
nm_utils_inet4_ntop (_nm_utils_ip4_prefix_to_netmask (prefix), buf));
} else
svUnsetValue (ifcfg, tag);
@ -2293,7 +2293,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
svSetValueStr (routefile, addr_key, nm_ip_route_get_dest (route));
memset (buf, 0, sizeof (buf));
netmask = nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route));
netmask = _nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route));
inet_ntop (AF_INET, (const void *) &netmask, &buf[0], sizeof (buf));
svSetValueStr (routefile, netmask_key, &buf[0]);