summaryrefslogtreecommitdiff
path: root/accel-pppd/extra/ipv6pool.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-12-01 16:40:04 +0300
committerDmitry Kozlov <xeb@mail.ru>2014-12-01 16:40:04 +0300
commit574912df113888ea19b4811b406612544514d9eb (patch)
treea7fec6d150d8710b31d4730ef7fab5c4c9ce4417 /accel-pppd/extra/ipv6pool.c
parent3cc7fd0165e096be25761710b66b44fda9d09190 (diff)
parente09279c7491a8bd16a25b123e03ddd0cd77b566d (diff)
downloadaccel-ppp-574912df113888ea19b4811b406612544514d9eb.tar.gz
accel-ppp-574912df113888ea19b4811b406612544514d9eb.zip
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
Diffstat (limited to 'accel-pppd/extra/ipv6pool.c')
-rw-r--r--accel-pppd/extra/ipv6pool.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c
index 0ca270c0..6887ea32 100644
--- a/accel-pppd/extra/ipv6pool.c
+++ b/accel-pppd/extra/ipv6pool.c
@@ -79,7 +79,7 @@ static void generate_ippool(struct in6_addr *addr, int mask, int prefix_len)
*(uint64_t *)(step.s6_addr + 8) = htobe64(1llu << (128 - prefix_len));
else
*(uint64_t *)step.s6_addr = htobe64(1llu << (64 - prefix_len));
-
+
while (in6_addr_cmp(&ip, &end) <= 0) {
it = malloc(sizeof(*it));
it->it.owner = &ipdb;
@@ -115,7 +115,7 @@ static void generate_dppool(struct in6_addr *addr, int mask, int prefix_len)
*(uint64_t *)(step.s6_addr + 8) = htobe64(1llu << (128 - prefix_len));
else
*(uint64_t *)step.s6_addr = htobe64(1llu << (64 - prefix_len));
-
+
while (in6_addr_cmp(&ip, &end) <= 0) {
it = malloc(sizeof(*it));
it->it.owner = &ipdb;
@@ -138,34 +138,34 @@ static void add_prefix(int type, const char *_val)
struct in6_addr addr;
int prefix_len;
int mask;
-
+
ptr1 = strchr(val, '/');
if (!ptr1)
goto err;
-
+
*ptr1 = 0;
ptr2 = strchr(ptr1 + 1, ',');
if (!ptr2)
goto err;
-
+
*ptr2 = 0;
if (inet_pton(AF_INET6, val, &addr) == 0)
goto err;
-
+
if (sscanf(ptr1 + 1, "%i", &mask) != 1)
goto err;
-
+
if (mask < 7 || mask > 127)
goto err;
-
+
if (sscanf(ptr2 + 1, "%i", &prefix_len) != 1)
goto err;
-
+
if (prefix_len > 128 || prefix_len < mask)
goto err;
-
+
if (type)
generate_dppool(&addr, mask, prefix_len);
else
@@ -173,7 +173,7 @@ static void add_prefix(int type, const char *_val)
_free(val);
return;
-
+
err:
log_error("ipv6_pool: failed to parse '%s'\n", _val);
_free(val);
@@ -245,7 +245,7 @@ static void ippool_init(void)
if (!s)
return;
-
+
list_for_each_entry(opt, &s->items, entry) {
if (!strcmp(opt->name, "delegate"))
add_prefix(1, opt->val);