core: add nm_ipX_config_get_direct_route_for_host() functions

add two functions nm_ip4_config_get_direct_route_for_host()
and nm_ip6_config_get_direct_route_for_host() to check if we have
a direct (non-gw) route to a certain host.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=738590
This commit is contained in:
Thomas Haller
2014-08-28 23:36:45 +02:00
parent 22911696f4
commit ff145486d1
6 changed files with 77 additions and 6 deletions

View File

@@ -120,15 +120,15 @@ nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen)
* @src: source ip6 address
* @plen: prefix length of network
*
* Note: this function is self assignment save, to update @src inplace, set both
* Note: this function is self assignment safe, to update @src inplace, set both
* @dst and @src to the same destination.
*/
void
const struct in6_addr *
nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen)
{
g_return_if_fail (plen <= 128);
g_return_if_fail (src);
g_return_if_fail (dst);
g_return_val_if_fail (plen <= 128, NULL);
g_return_val_if_fail (src, NULL);
g_return_val_if_fail (dst, NULL);
if (plen < 128) {
guint nbytes = plen / 8;
@@ -144,6 +144,8 @@ nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_
memset (&dst->s6_addr[nbytes], 0, 16 - nbytes);
} else if (src != dst)
*dst = *src;
return dst;
}