summaryrefslogtreecommitdiff
path: root/accel-pppd/extra/ippool.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2011-01-18 18:07:28 +0300
committerDmitry Kozlov <xeb@mail.ru>2011-01-18 18:07:28 +0300
commitf350fd852cd4870c72736cba154153cfad4ceea9 (patch)
tree6cac723b25e0b24447880bb3ef135671defdd57c /accel-pppd/extra/ippool.c
parent24a7ea1cdcba91f15670c50ba0e1ea456fa2a5ca (diff)
downloadaccel-ppp-f350fd852cd4870c72736cba154153cfad4ceea9.tar.gz
accel-ppp-f350fd852cd4870c72736cba154153cfad4ceea9.zip
ippool: fixed parser
Diffstat (limited to 'accel-pppd/extra/ippool.c')
-rw-r--r--accel-pppd/extra/ippool.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/accel-pppd/extra/ippool.c b/accel-pppd/extra/ippool.c
index 6136a14d..20da17c0 100644
--- a/accel-pppd/extra/ippool.c
+++ b/accel-pppd/extra/ippool.c
@@ -59,12 +59,12 @@ static int parse1(const char *str, uint32_t *begin, uint32_t *end)
if (m == 0 || m > 32)
return -1;
- for (n = 0; n < m ; n++)
- mask |= 1 << n;
-
*begin = (f4 << 24) | (f3 << 16) | (f2 << 8) | f1;
- *end = *begin | ~mask;
-
+
+ mask = htonl(~((1 << (32 - m)) - 1));
+ *end = ntohl(*begin | ~mask);
+ *begin = ntohl(*begin);
+
return 0;
}
@@ -87,8 +87,8 @@ static int parse2(const char *str, uint32_t *begin, uint32_t *end)
if (m < f4 || m > 255)
return -1;
- *begin = (f4 << 24) | (f3 << 16) | (f2 << 8) | f1;
- *end = (m << 24) | (f3 << 16) | (f2 << 8) | f1;
+ *begin = ntohl((f4 << 24) | (f3 << 16) | (f2 << 8) | f1);
+ *end = ntohl((m << 24) | (f3 << 16) | (f2 << 8) | f1);
return 0;
}
@@ -104,7 +104,7 @@ static void add_range(struct list_head *list, const char *name)
_exit(EXIT_FAILURE);
}
- for (i = ntohl(startip); i <= ntohl(endip); i++) {
+ for (i = startip; i <= endip; i++) {
ip = malloc(sizeof(*ip));
ip->addr = htonl(i);
list_add_tail(&ip->entry, list);