summaryrefslogtreecommitdiffstats
path: root/dhcp.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-10-20 09:56:21 +0000
committerRoy Marples <roy@marples.name>2008-10-20 09:56:21 +0000
commite99d18942d888d1af56220cd4a2fa67cedc5cc80 (patch)
tree65297dcfe77bfb9cdce86b05a55c2e397bbb7407 /dhcp.c
parent37a08d5cf66c62ac30d1d1f07146986b1d80f69c (diff)
downloaddhcpcd-e99d18942d888d1af56220cd4a2fa67cedc5cc80.tar.xz
Calculate netmask from cidr more efficiently.
Diffstat (limited to 'dhcp.c')
-rw-r--r--dhcp.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/dhcp.c b/dhcp.c
index 79d7b003..bdcc04ea 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -534,13 +534,8 @@ decode_rfc3442_rt(int dl, const uint8_t *data)
/* If we have ocets then we have a destination and netmask */
if (ocets > 0) {
memcpy(&rt->dest.s_addr, p, ocets);
- memset(&rt->net.s_addr, 255, ocets);
- memset((uint8_t *)&rt->net.s_addr + (ocets - 1),
- (256 - (1 << (32 - cidr) % 8)), 1);
p += ocets;
- } else {
- rt->dest.s_addr = 0;
- rt->net.s_addr = 0;
+ rt->net.s_addr = htonl(~0 << (32 - cidr));
}
/* Finally, snag the router */