aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2013-09-02 14:39:42 +0200
committerLukas Nykryn <lnykryn@redhat.com>2013-09-02 14:39:42 +0200
commit515af1d015295f3562f6ab4de8da66424ecd8f7a (patch)
tree1848e9a8d16a123ec1d281c9abf11a850571a293 /src
parentb873be923e1ba63b0cbd98aee317d34964b42280 (diff)
downloadinitscripts-515af1d015295f3562f6ab4de8da66424ecd8f7a.tar
initscripts-515af1d015295f3562f6ab4de8da66424ecd8f7a.tar.gz
initscripts-515af1d015295f3562f6ab4de8da66424ecd8f7a.tar.bz2
initscripts-515af1d015295f3562f6ab4de8da66424ecd8f7a.tar.xz
initscripts-515af1d015295f3562f6ab4de8da66424ecd8f7a.zip
ipcalc: support RFC3021 (#997271)
Diffstat (limited to 'src')
-rw-r--r--src/ipcalc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ipcalc.c b/src/ipcalc.c
index 7316f058..bec14eb5 100644
--- a/src/ipcalc.c
+++ b/src/ipcalc.c
@@ -141,7 +141,12 @@ struct in_addr calc_broadcast(struct in_addr addr, int prefix)
struct in_addr broadcast;
memset(&broadcast, 0, sizeof(broadcast));
- broadcast.s_addr = (addr.s_addr & mask.s_addr) | ~mask.s_addr;
+
+/* if prefix is set to 31 return 255.255.255.255 (RFC3021) */
+ if (mask.s_addr == htonl(0xFFFFFFFE))
+ broadcast.s_addr = htonl(0xFFFFFFFF);
+ else
+ broadcast.s_addr = (addr.s_addr & mask.s_addr) | ~mask.s_addr;
return broadcast;
}