summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-03-07 16:33:40 +0100
committerThomas Haller <thaller@redhat.com>2014-05-03 03:44:22 +0200
commit38ffd3eb9b2ae03266edbf328b656d76b54be28c (patch)
treefda365ca2fda5d6baf74c29c40ce66ed4359f6f4
parent857e5e0b21d265e46371c3f2d24a360cc93cb0e4 (diff)
downloadNetworkManager-38ffd3eb9b2ae03266edbf328b656d76b54be28c.tar.gz
platform: refactor build_rtnl_addr() by replacing addr4_to_broadcast()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/platform/nm-linux-platform.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 0eb297a115..de186d9c5a 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2953,25 +2953,6 @@ ip6_address_get_all (NMPlatform *platform, int ifindex)
return addresses;
}
-static void
-addr4_to_broadcast (struct in_addr *dst, const struct in_addr *src, guint8 plen)
-{
- guint nbytes = plen / 8;
- guint nbits = plen % 8;
-
- g_return_if_fail (plen <= 32);
- g_assert (src);
- g_assert (dst);
-
- if (plen >= 32)
- *dst = *src;
- else {
- dst->s_addr = 0xFFFFFFFF;
- memcpy (dst, src, nbytes);
- ((guint8 *) dst)[nbytes] = (((const guint8 *) src)[nbytes] | (0xFF >> nbits));
- }
-}
-
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
#define IPV4LL_NETMASK (htonl (0xFFFF0000L))
@@ -3010,10 +2991,10 @@ build_rtnl_addr (int family,
/* IPv4 Broadcast address */
if (family == AF_INET) {
- struct in_addr bcast;
+ in_addr_t bcast;
auto_nl_addr struct nl_addr *bcaddr = NULL;
- addr4_to_broadcast (&bcast, addr, plen);
+ bcast = *((in_addr_t *) addr) | ~nm_utils_ip4_prefix_to_netmask (plen);
bcaddr = nl_addr_build (family, &bcast, addrlen);
g_assert (bcaddr);
rtnl_addr_set_broadcast (rtnladdr, bcaddr);