platform: expose nmp_utils_ip4_address_is_link_local() function

This commit is contained in:
Thomas Haller
2016-02-18 20:21:27 +01:00
parent b76d4b6b09
commit 328c733a6a
4 changed files with 18 additions and 12 deletions

View File

@@ -288,17 +288,6 @@ _support_user_ipv6ll_detect (struct nlattr **tb)
* Various utilities * Various utilities
******************************************************************/ ******************************************************************/
const NMIPAddr nm_ip_addr_zero = NMIPAddrInit;
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
#define IPV4LL_NETMASK (htonl (0xFFFF0000L))
static gboolean
ip4_address_is_link_local (in_addr_t addr)
{
return (addr & IPV4LL_NETMASK) == IPV4LL_NETWORK;
}
static guint static guint
_nm_ip_config_source_to_rtprot (NMIPConfigSource source) _nm_ip_config_source_to_rtprot (NMIPConfigSource source)
{ {
@@ -5203,7 +5192,7 @@ ip4_address_add (NMPlatform *platform,
plen, plen,
&peer_addr, &peer_addr,
0, 0,
ip4_address_is_link_local (addr) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE, nmp_utils_ip4_address_is_link_local (addr) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE,
lifetime, lifetime,
preferred, preferred,
label); label);

View File

@@ -415,6 +415,15 @@ out:
* utils * utils
******************************************************************/ ******************************************************************/
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
#define IPV4LL_NETMASK (htonl (0xFFFF0000L))
gboolean
nmp_utils_ip4_address_is_link_local (in_addr_t addr)
{
return (addr & IPV4LL_NETMASK) == IPV4LL_NETWORK;
}
/** /**
* Takes a pair @timestamp and @duration, and returns the remaining duration based * Takes a pair @timestamp and @duration, and returns the remaining duration based
* on the new timestamp @now. * on the new timestamp @now.

View File

@@ -69,4 +69,6 @@ gboolean nmp_utils_lifetime_get (guint32 timestamp,
gboolean nmp_utils_device_exists (const char *name); gboolean nmp_utils_device_exists (const char *name);
gboolean nmp_utils_ip4_address_is_link_local (in_addr_t addr);
#endif /* __NM_PLATFORM_UTILS_H__ */ #endif /* __NM_PLATFORM_UTILS_H__ */

View File

@@ -42,6 +42,12 @@
#include "nm-enum-types.h" #include "nm-enum-types.h"
#include "nm-core-internal.h" #include "nm-core-internal.h"
/*****************************************************************************/
const NMIPAddr nm_ip_addr_zero = NMIPAddrInit;
/*****************************************************************************/
#define ADDRESS_LIFETIME_PADDING 5 #define ADDRESS_LIFETIME_PADDING 5
G_STATIC_ASSERT (sizeof ( ((NMPlatformLink *) NULL)->addr.data ) == NM_UTILS_HWADDR_LEN_MAX); G_STATIC_ASSERT (sizeof ( ((NMPlatformLink *) NULL)->addr.data ) == NM_UTILS_HWADDR_LEN_MAX);