Commit 44768f03 authored by Thomas Haller's avatar Thomas Haller

platform: change @plen field of NMPlatformIPxAddress to type guint8

On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.
parent 14ee5dd2
...@@ -870,7 +870,8 @@ static_stage3_ip4_done (NMModemBroadband *self) ...@@ -870,7 +870,8 @@ static_stage3_ip4_done (NMModemBroadband *self)
address.peer_address = address_network; address.peer_address = address_network;
address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv4_config); address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv4_config);
address.source = NM_IP_CONFIG_SOURCE_WWAN; address.source = NM_IP_CONFIG_SOURCE_WWAN;
nm_ip4_config_add_address (config, &address); if (address.plen <= 32)
nm_ip4_config_add_address (config, &address);
nm_log_info (LOGD_MB, " address %s/%d", address_string, address.plen); nm_log_info (LOGD_MB, " address %s/%d", address_string, address.plen);
...@@ -960,7 +961,8 @@ stage3_ip6_done (NMModemBroadband *self) ...@@ -960,7 +961,8 @@ stage3_ip6_done (NMModemBroadband *self)
config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port));
address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv6_config); address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv6_config);
nm_ip6_config_add_address (config, &address); if (address.plen <= 128)
nm_ip6_config_add_address (config, &address);
nm_log_info (LOGD_MB, " address %s/%d", address_string, address.plen); nm_log_info (LOGD_MB, " address %s/%d", address_string, address.plen);
......
...@@ -382,7 +382,8 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex, ...@@ -382,7 +382,8 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
in_addr_t addr; in_addr_t addr;
NMPlatformIP4Address address; NMPlatformIP4Address address;
char *str = NULL; char *str = NULL;
guint32 gwaddr = 0, plen = 0; guint32 gwaddr = 0;
guint8 plen = 0;
g_return_val_if_fail (options != NULL, NULL); g_return_val_if_fail (options != NULL, NULL);
......
...@@ -34,7 +34,7 @@ nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr, ...@@ -34,7 +34,7 @@ nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr,
char **out_error_desc) char **out_error_desc)
{ {
guint32 host = addr->address; guint32 host = addr->address;
guint32 prefix = addr->plen; guint8 prefix = addr->plen;
guint32 netmask = nm_utils_ip4_prefix_to_netmask (prefix); guint32 netmask = nm_utils_ip4_prefix_to_netmask (prefix);
guint32 first, last, reserved; guint32 first, last, reserved;
......
...@@ -365,6 +365,8 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu ...@@ -365,6 +365,8 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu
if (addr->plen == 0) if (addr->plen == 0)
continue; continue;
nm_assert (addr->plen <= 32);
route.ifindex = ifindex; route.ifindex = ifindex;
route.source = NM_IP_CONFIG_SOURCE_KERNEL; route.source = NM_IP_CONFIG_SOURCE_KERNEL;
...@@ -466,6 +468,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu ...@@ -466,6 +468,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu
nm_ip_address_get_address_binary (s_addr, &address.address); nm_ip_address_get_address_binary (s_addr, &address.address);
address.peer_address = address.address; address.peer_address = address.address;
address.plen = nm_ip_address_get_prefix (s_addr); address.plen = nm_ip_address_get_prefix (s_addr);
nm_assert (address.plen <= 32);
address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; address.preferred = NM_PLATFORM_LIFETIME_PERMANENT;
address.source = NM_IP_CONFIG_SOURCE_USER; address.source = NM_IP_CONFIG_SOURCE_USER;
...@@ -564,6 +567,10 @@ nm_ip4_config_create_setting (const NMIP4Config *config) ...@@ -564,6 +567,10 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
continue; continue;
} }
/* FIXME: NMIPAddress doesn't support zero prefixes. */
if (address->plen == 0)
continue;
/* Static address found. */ /* Static address found. */
if (!method) if (!method)
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
......
...@@ -454,6 +454,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu ...@@ -454,6 +454,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu
memset (&address, 0, sizeof (address)); memset (&address, 0, sizeof (address));
nm_ip_address_get_address_binary (s_addr, &address.address); nm_ip_address_get_address_binary (s_addr, &address.address);
address.plen = nm_ip_address_get_prefix (s_addr); address.plen = nm_ip_address_get_prefix (s_addr);
nm_assert (address.plen <= 128);
address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; address.preferred = NM_PLATFORM_LIFETIME_PERMANENT;
address.source = NM_IP_CONFIG_SOURCE_USER; address.source = NM_IP_CONFIG_SOURCE_USER;
...@@ -555,6 +556,10 @@ nm_ip6_config_create_setting (const NMIP6Config *config) ...@@ -555,6 +556,10 @@ nm_ip6_config_create_setting (const NMIP6Config *config)
continue; continue;
} }
/* FIXME: NMIPAddress does not support zero prefixes. */
if (address->plen == 0)
continue;
/* Static address found. */ /* Static address found. */
if (!method || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) if (!method || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0)
method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
......
...@@ -91,17 +91,17 @@ static void link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboo ...@@ -91,17 +91,17 @@ static void link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboo
static gboolean ip6_address_add (NMPlatform *platform, static gboolean ip6_address_add (NMPlatform *platform,
int ifindex, int ifindex,
struct in6_addr addr, struct in6_addr addr,
int plen, guint8 plen,
struct in6_addr peer_addr, struct in6_addr peer_addr,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
guint flags); guint flags);
static gboolean ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen); static gboolean ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen);
/******************************************************************/ /******************************************************************/
static gboolean static gboolean
_ip4_address_equal_peer_net (in_addr_t peer1, in_addr_t peer2, int plen) _ip4_address_equal_peer_net (in_addr_t peer1, in_addr_t peer2, guint8 plen)
{ {
return ((peer1 ^ peer2) & nm_utils_ip4_prefix_to_netmask (plen)) == 0; return ((peer1 ^ peer2) & nm_utils_ip4_prefix_to_netmask (plen)) == 0;
} }
...@@ -886,7 +886,7 @@ static gboolean ...@@ -886,7 +886,7 @@ static gboolean
ip4_address_add (NMPlatform *platform, ip4_address_add (NMPlatform *platform,
int ifindex, int ifindex,
in_addr_t addr, in_addr_t addr,
int plen, guint8 plen,
in_addr_t peer_addr, in_addr_t peer_addr,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
...@@ -938,7 +938,7 @@ static gboolean ...@@ -938,7 +938,7 @@ static gboolean
ip6_address_add (NMPlatform *platform, ip6_address_add (NMPlatform *platform,
int ifindex, int ifindex,
struct in6_addr addr, struct in6_addr addr,
int plen, guint8 plen,
struct in6_addr peer_addr, struct in6_addr peer_addr,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
...@@ -982,7 +982,7 @@ ip6_address_add (NMPlatform *platform, ...@@ -982,7 +982,7 @@ ip6_address_add (NMPlatform *platform,
} }
static gboolean static gboolean
ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in_addr_t peer_address) ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, in_addr_t peer_address)
{ {
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
int i; int i;
...@@ -1007,7 +1007,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, ...@@ -1007,7 +1007,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen,
} }
static gboolean static gboolean
ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen) ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen)
{ {
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
int i; int i;
...@@ -1031,7 +1031,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int ...@@ -1031,7 +1031,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int
} }
static const NMPlatformIP4Address * static const NMPlatformIP4Address *
ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in_addr_t peer_address) ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, in_addr_t peer_address)
{ {
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
int i; int i;
...@@ -1050,7 +1050,7 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in ...@@ -1050,7 +1050,7 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in
} }
static const NMPlatformIP6Address * static const NMPlatformIP6Address *
ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen) ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen)
{ {
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
int i; int i;
...@@ -1058,8 +1058,9 @@ ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, int pl ...@@ -1058,8 +1058,9 @@ ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, int pl
for (i = 0; i < priv->ip6_addresses->len; i++) { for (i = 0; i < priv->ip6_addresses->len; i++) {
NMPlatformIP6Address *address = &g_array_index (priv->ip6_addresses, NMPlatformIP6Address, i); NMPlatformIP6Address *address = &g_array_index (priv->ip6_addresses, NMPlatformIP6Address, i);
if (address->ifindex == ifindex && address->plen == plen && if ( address->ifindex == ifindex
IN6_ARE_ADDR_EQUAL (&address->address, &addr)) && address->plen == plen
&& IN6_ARE_ADDR_EQUAL (&address->address, &addr))
return address; return address;
} }
......
...@@ -1640,6 +1640,9 @@ _new_from_nl_addr (struct nlmsghdr *nlh, gboolean id_only) ...@@ -1640,6 +1640,9 @@ _new_from_nl_addr (struct nlmsghdr *nlh, gboolean id_only)
? sizeof (in_addr_t) ? sizeof (in_addr_t)
: sizeof (struct in6_addr); : sizeof (struct in6_addr);
if (ifa->ifa_prefixlen > (is_v4 ? 32 : 128))
goto errout;
/*****************************************************************/ /*****************************************************************/
obj = nmp_object_new (is_v4 ? NMP_OBJECT_TYPE_IP4_ADDRESS : NMP_OBJECT_TYPE_IP6_ADDRESS, NULL); obj = nmp_object_new (is_v4 ? NMP_OBJECT_TYPE_IP4_ADDRESS : NMP_OBJECT_TYPE_IP6_ADDRESS, NULL);
...@@ -2160,7 +2163,7 @@ _nl_msg_new_address (int nlmsg_type, ...@@ -2160,7 +2163,7 @@ _nl_msg_new_address (int nlmsg_type,
int family, int family,
int ifindex, int ifindex,
gconstpointer address, gconstpointer address,
int plen, guint8 plen,
gconstpointer peer_address, gconstpointer peer_address,
guint32 flags, guint32 flags,
int scope, int scope,
...@@ -5268,7 +5271,7 @@ static gboolean ...@@ -5268,7 +5271,7 @@ static gboolean
ip4_address_add (NMPlatform *platform, ip4_address_add (NMPlatform *platform,
int ifindex, int ifindex,
in_addr_t addr, in_addr_t addr,
int plen, guint8 plen,
in_addr_t peer_addr, in_addr_t peer_addr,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
...@@ -5299,7 +5302,7 @@ static gboolean ...@@ -5299,7 +5302,7 @@ static gboolean
ip6_address_add (NMPlatform *platform, ip6_address_add (NMPlatform *platform,
int ifindex, int ifindex,
struct in6_addr addr, struct in6_addr addr,
int plen, guint8 plen,
struct in6_addr peer_addr, struct in6_addr peer_addr,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
...@@ -5326,7 +5329,7 @@ ip6_address_add (NMPlatform *platform, ...@@ -5326,7 +5329,7 @@ ip6_address_add (NMPlatform *platform,
} }
static gboolean static gboolean
ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in_addr_t peer_address) ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, in_addr_t peer_address)
{ {
nm_auto_nlmsg struct nl_msg *nlmsg = NULL; nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
NMPObject obj_id; NMPObject obj_id;
...@@ -5351,7 +5354,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, ...@@ -5351,7 +5354,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen,
} }
static gboolean static gboolean
ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen) ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen)
{ {
nm_auto_nlmsg struct nl_msg *nlmsg = NULL; nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
NMPObject obj_id; NMPObject obj_id;
...@@ -5376,7 +5379,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int ...@@ -5376,7 +5379,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int
} }
static const NMPlatformIP4Address * static const NMPlatformIP4Address *
ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in_addr_t peer_address) ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, in_addr_t peer_address)
{ {
NMPObject obj_id; NMPObject obj_id;
const NMPObject *obj; const NMPObject *obj;
...@@ -5389,7 +5392,7 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in ...@@ -5389,7 +5392,7 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, int plen, in
} }
static const NMPlatformIP6Address * static const NMPlatformIP6Address *
ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen) ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen)
{ {
NMPObject obj_id; NMPObject obj_id;
const NMPObject *obj; const NMPObject *obj;
......
...@@ -2459,8 +2459,10 @@ nm_platform_ethtool_get_link_speed (NMPlatform *self, const char *ifname, guint3 ...@@ -2459,8 +2459,10 @@ nm_platform_ethtool_get_link_speed (NMPlatform *self, const char *ifname, guint3
/******************************************************************/ /******************************************************************/
void void
nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, int plen) nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, guint8 plen)
{ {
nm_assert (plen <= 32);
addr->address = address; addr->address = address;
addr->peer_address = address; addr->peer_address = address;
addr->plen = plen; addr->plen = plen;
...@@ -2499,7 +2501,7 @@ gboolean ...@@ -2499,7 +2501,7 @@ gboolean
nm_platform_ip4_address_add (NMPlatform *self, nm_platform_ip4_address_add (NMPlatform *self,
int ifindex, int ifindex,
in_addr_t address, in_addr_t address,
int plen, guint8 plen,
in_addr_t peer_address, in_addr_t peer_address,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
...@@ -2509,7 +2511,7 @@ nm_platform_ip4_address_add (NMPlatform *self, ...@@ -2509,7 +2511,7 @@ nm_platform_ip4_address_add (NMPlatform *self,
_CHECK_SELF (self, klass, FALSE); _CHECK_SELF (self, klass, FALSE);
g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (plen <= 32, FALSE);
g_return_val_if_fail (lifetime > 0, FALSE); g_return_val_if_fail (lifetime > 0, FALSE);
g_return_val_if_fail (preferred <= lifetime, FALSE); g_return_val_if_fail (preferred <= lifetime, FALSE);
g_return_val_if_fail (!label || strlen (label) < sizeof (((NMPlatformIP4Address *) NULL)->label), FALSE); g_return_val_if_fail (!label || strlen (label) < sizeof (((NMPlatformIP4Address *) NULL)->label), FALSE);
...@@ -2537,7 +2539,7 @@ gboolean ...@@ -2537,7 +2539,7 @@ gboolean
nm_platform_ip6_address_add (NMPlatform *self, nm_platform_ip6_address_add (NMPlatform *self,
int ifindex, int ifindex,
struct in6_addr address, struct in6_addr address,
int plen, guint8 plen,
struct in6_addr peer_address, struct in6_addr peer_address,
guint32 lifetime, guint32 lifetime,
guint32 preferred, guint32 preferred,
...@@ -2546,7 +2548,7 @@ nm_platform_ip6_address_add (NMPlatform *self, ...@@ -2546,7 +2548,7 @@ nm_platform_ip6_address_add (NMPlatform *self,
_CHECK_SELF (self, klass, FALSE); _CHECK_SELF (self, klass, FALSE);
g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (plen <= 128, FALSE);
g_return_val_if_fail (lifetime > 0, FALSE); g_return_val_if_fail (lifetime > 0, FALSE);
g_return_val_if_fail (preferred <= lifetime, FALSE); g_return_val_if_fail (preferred <= lifetime, FALSE);
...@@ -2568,7 +2570,7 @@ nm_platform_ip6_address_add (NMPlatform *self, ...@@ -2568,7 +2570,7 @@ nm_platform_ip6_address_add (NMPlatform *self,
} }
gboolean gboolean
nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address) nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address)
{ {
char str_dev[TO_STRING_DEV_BUF_SIZE]; char str_dev[TO_STRING_DEV_BUF_SIZE];
char str_peer2[NM_UTILS_INET_ADDRSTRLEN]; char str_peer2[NM_UTILS_INET_ADDRSTRLEN];
...@@ -2577,7 +2579,7 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address ...@@ -2577,7 +2579,7 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address
_CHECK_SELF (self, klass, FALSE); _CHECK_SELF (self, klass, FALSE);
g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (plen <= 32, FALSE);
_LOGD ("address: deleting IPv4 address %s/%d, %sifindex %d%s", _LOGD ("address: deleting IPv4 address %s/%d, %sifindex %d%s",
nm_utils_inet4_ntop (address, NULL), plen, nm_utils_inet4_ntop (address, NULL), plen,
...@@ -2589,14 +2591,14 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address ...@@ -2589,14 +2591,14 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address
} }
gboolean gboolean
nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen) nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen)
{ {
char str_dev[TO_STRING_DEV_BUF_SIZE]; char str_dev[TO_STRING_DEV_BUF_SIZE];
_CHECK_SELF (self, klass, FALSE); _CHECK_SELF (self, klass, FALSE);
g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (plen <= 128, FALSE);
_LOGD ("address: deleting IPv6 address %s/%d, ifindex %d%s", _LOGD ("address: deleting IPv6 address %s/%d, ifindex %d%s",
nm_utils_inet6_ntop (&address, NULL), plen, ifindex, nm_utils_inet6_ntop (&address, NULL), plen, ifindex,
...@@ -2605,21 +2607,21 @@ nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr a ...@@ -2605,21 +2607,21 @@ nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr a
} }
const NMPlatformIP4Address * const NMPlatformIP4Address *
nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, int plen, guint32 peer_address) nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, guint32 peer_address)
{ {
_CHECK_SELF (self, klass, NULL); _CHECK_SELF (self, klass, NULL);
g_return_val_if_fail (plen > 0, NULL); g_return_val_if_fail (plen <= 32, NULL);
return klass->ip4_address_get (self, ifindex, address, plen, peer_address); return klass->ip4_address_get (self, ifindex, address, plen, peer_address);
} }
const NMPlatformIP6Address * const NMPlatformIP6Address *
nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, int plen) nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen)
{ {
_CHECK_SELF (self, klass, NULL); _CHECK_SELF (self, klass, NULL);
g_return_val_if_fail (plen > 0, NULL); g_return_val_if_fail (plen <= 128, NULL);
return klass->ip6_address_get (self, ifindex, address, plen); return klass->ip6_address_get (self, ifindex, address, plen);
} }
......
...@@ -226,7 +226,7 @@ typedef struct { ...@@ -226,7 +226,7 @@ typedef struct {
* IFA_FLAGS attribute. */ \ * IFA_FLAGS attribute. */ \
guint32 n_ifa_flags; \ guint32 n_ifa_flags; \
\ \
int plen; \ guint8 plen; \
; ;
/** /**
...@@ -593,7 +593,7 @@ typedef struct { ...@@ -593,7 +593,7 @@ typedef struct {
gboolean (*ip4_address_add) (NMPlatform *, gboolean (*ip4_address_add) (NMPlatform *,
int ifindex, int ifindex,
in_addr_t address, in_addr_t address,
int plen, guint8 plen,
in_addr_t peer_address, in_addr_t peer_address,
guint32 lifetime, guint32 lifetime,
guint32 preferred_lft, guint32 preferred_lft,
...@@ -602,15 +602,15 @@ typedef struct { ...@@ -602,15 +602,15 @@ typedef struct {
gboolean (*ip6_address_add) (NMPlatform *, gboolean (*ip6_address_add) (NMPlatform *,
int ifindex, int ifindex,
struct in6_addr address, struct in6_addr address,
int plen, guint8 plen,
struct in6_addr peer_address, struct in6_addr peer_address,
guint32 lifetime, guint32 lifetime,
guint32 preferred_lft, guint32 preferred_lft,
guint32 flags); guint32 flags);
gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, int plen, in_addr_t peer_address); gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, int plen); gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen);
const NMPlatformIP4Address *(*ip4_address_get) (NMPlatform *, int ifindex, in_addr_t address, int plen, in_addr_t peer_address); const NMPlatformIP4Address *(*ip4_address_get) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
const NMPlatformIP6Address *(*ip6_address_get) (NMPlatform *, int ifindex, struct in6_addr address, int plen); const NMPlatformIP6Address *(*ip6_address_get) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen);
GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags); GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags); GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
...@@ -835,10 +835,10 @@ guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex); ...@@ -835,10 +835,10 @@ guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel); gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len); gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len);
void nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, int plen); void nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, guint8 plen);
const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr); const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr);
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address); const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
NMPlatformError nm_platform_link_gre_add (NMPlatform *self, NMPlatformError nm_platform_link_gre_add (NMPlatform *self,
const char *name, const char *name,
...@@ -862,13 +862,13 @@ NMPlatformError nm_platform_link_sit_add (NMPlatform *self, ...@@ -862,13 +862,13 @@ NMPlatformError nm_platform_link_sit_add (NMPlatform *self,
const NMPlatformLnkSit *props, const NMPlatformLnkSit *props,
const NMPlatformLink **out_link); const NMPlatformLink **out_link);
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, int plen); const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen);
GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex); GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
GArray *nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex); GArray *nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex);
gboolean nm_platform_ip4_address_add (NMPlatform *self, gboolean nm_platform_ip4_address_add (NMPlatform *self,
int ifindex, int ifindex,
in_addr_t address, in_addr_t address,
int plen, guint8 plen,
in_addr_t peer_address, in_addr_t peer_address,
guint32 lifetime, guint32 lifetime,
guint32 preferred_lft, guint32 preferred_lft,
...@@ -877,13 +877,13 @@ gboolean nm_platform_ip4_address_add (NMPlatform *self, ...@@ -877,13 +877,13 @@ gboolean nm_platform_ip4_address_add (NMPlatform *self,
gboolean nm_platform_ip6_address_add (NMPlatform *self, gboolean nm_platform_ip6_address_add (NMPlatform *self,
int ifindex, int ifindex,
struct in6_addr address, struct in6_addr address,
int plen, guint8 plen,
struct in6_addr peer_address, struct in6_addr peer_address,
guint32 lifetime, guint32 lifetime,
guint32 preferred_lft, guint32 preferred_lft,
guint32 flags); guint32 flags);
gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address); gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen); gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen);
gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, GPtrArray **out_added_addresses); gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, GPtrArray **out_added_addresses);
gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, gboolean keep_link_local); gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, gboolean keep_link_local);
gboolean nm_platform_address_flush (NMPlatform *self, int ifindex); gboolean nm_platform_address_flush (NMPlatform *self, int ifindex);
......
...@@ -343,7 +343,7 @@ _vt_cmd_obj_stackinit_id_link (NMPObject *obj, const NMPObject *src) ...@@ -343,7 +343,7 @@ _vt_cmd_obj_stackinit_id_link (NMPObject *obj, const NMPObject *src)
} }
const NMPObject * const NMPObject *
nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, int plen, guint32 peer_address) nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, guint8 plen, guint32 peer_address)
{ {
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP4_ADDRESS, NULL); nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP4_ADDRESS, NULL);
obj->ip4_address.ifindex = ifindex; obj->ip4_address.ifindex = ifindex;
...@@ -360,7 +360,7 @@ _vt_cmd_obj_stackinit_id_ip4_address (NMPObject *obj, const NMPObject *src) ...@@ -360,7 +360,7 @@ _vt_cmd_obj_stackinit_id_ip4_address (NMPObject *obj, const NMPObject *src)
} }
const NMPObject * const NMPObject *
nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, int plen) nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, guint8 plen)
{ {
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP6_ADDRESS, NULL); nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP6_ADDRESS, NULL);
obj->ip4_address.ifindex = ifindex; obj->ip4_address.ifindex = ifindex;
......
...@@ -345,8 +345,8 @@ NMPObject *nmp_object_new_link (int ifindex); ...@@ -345,8 +345,8 @@ NMPObject *nmp_object_new_link (int ifindex);
const NMPObject *nmp_object_stackinit (NMPObject *obj, NMPObjectType obj_type, const NMPlatformObject *plobj); const NMPObject *nmp_object_stackinit (NMPObject *obj, NMPObjectType obj_type, const NMPlatformObject *plobj);
const NMPObject *nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src); const NMPObject *nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src);
const NMPObject *nmp_object_stackinit_id_link (NMPObject *obj, int ifindex); const NMPObject *nmp_object_stackinit_id_link (NMPObject *obj, int ifindex);
const NMPObject *nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, int plen, guint32 peer_address); const NMPObject *nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, guint8 plen, guint32 peer_address);
const NMPObject *nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, int plen); const NMPObject *nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, guint8 plen);
const NMPObject *nmp_object_stackinit_id_ip4_route (NMPObject *obj, int ifindex, guint32 network, guint8 plen, guint32 metric); const NMPObject *nmp_object_stackinit_id_ip4_route (NMPObject *obj, int ifindex, guint32 network, guint8 plen, guint32 metric);
const NMPObject *nmp_object_stackinit_id_ip6_route (NMPObject *obj, int ifindex, const struct in6_addr *network, guint8 plen, guint32 metric); const NMPObject *nmp_object_stackinit_id_ip6_route (NMPObject *obj, int ifindex, const struct in6_addr *network, guint8 plen, guint32 metric);
......
...@@ -308,7 +308,7 @@ test_ip4_address_peer_zero (void) ...@@ -308,7 +308,7 @@ test_ip4_address_peer_zero (void)
in_addr_t addr, addr_peer; in_addr_t addr, addr_peer;
guint32 lifetime = 2000; guint32 lifetime = 2000;
guint32 preferred = 1000; guint32 preferred = 1000;
const int plen = 24; const gint8 plen = 24;
const char *label = NULL; const char *label = NULL;
in_addr_t peers[3], r_peers[3]; in_addr_t peers[3], r_peers[3];
int i; int i;
......
...@@ -481,7 +481,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager, ...@@ -481,7 +481,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32)) if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32))
address.plen = u32;