From c96148167795596b106b51cf0de5e838ac7edfc8 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 21 Apr 2008 20:31:23 +0000 Subject: [PATCH] 2008-04-21 Dan Williams * src/nm-ip4-config.c - (nm_ip4_config_to_rtnl_addr): fill in the broadcast address if it's not specified (rh #443474) git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3581 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 6 ++++++ src/nm-ip4-config.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fe522673..118d05231 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-04-21 Dan Williams + + * src/nm-ip4-config.c + - (nm_ip4_config_to_rtnl_addr): fill in the broadcast address if it's + not specified (rh #443474) + 2008-04-20 Dan Williams * src/NetworkManagerUtils.c diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 46fe62dc7..4e849a22b 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -460,8 +460,20 @@ struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flag if (flags & NM_RTNL_ADDR_NETMASK) ip4_addr_to_rtnl_prefixlen (priv->ip4_netmask, addr); - if (flags & NM_RTNL_ADDR_BROADCAST) - success = (ip4_addr_to_rtnl_broadcast (priv->ip4_broadcast, addr) >= 0); + if (flags & NM_RTNL_ADDR_BROADCAST) { + guint32 bcast = priv->ip4_broadcast; + + /* Calculate the broadcast address if needed */ + if (!bcast) { + guint32 hostmask, network; + + network = ntohl (priv->ip4_address) & ntohl (priv->ip4_netmask); + hostmask = ~ntohl (priv->ip4_netmask); + bcast = htonl (network | hostmask); + } + + success = (ip4_addr_to_rtnl_broadcast (bcast, addr) >= 0); + } if (!success) {