summaryrefslogtreecommitdiffstats
path: root/ipv6.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-04-21 19:27:31 +0000
committerRoy Marples <roy@marples.name>2016-04-21 19:27:31 +0000
commit663d44bf12e0f7178fc7a54837690275e7b24bd3 (patch)
treed33f9b1bebbec9370789dfa0b76bbff58ba2e06e /ipv6.c
parent19cbf0c71da0376fb407ec0e7dd05d4a1b646c2b (diff)
downloaddhcpcd-663d44bf12e0f7178fc7a54837690275e7b24bd3.tar.xz
RFC3315 Section 12.1 is a little vague about adding bits to the prefix.
The correct interpretation is that we must add bits to the prefix length, thus having a sla_id of 0 is valid because the prefix_length is always extended.
Diffstat (limited to 'ipv6.c')
-rw-r--r--ipv6.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ipv6.c b/ipv6.c
index 1c16e08a..3bd52068 100644
--- a/ipv6.c
+++ b/ipv6.c
@@ -510,8 +510,7 @@ ipv6_userprefix(
uint64_t vh, vl, user_low, user_high;
if (prefix_len < 1 || prefix_len > 128 ||
- result_len < 1 || result_len > 128 ||
- user_number == 0)
+ result_len < 1 || result_len > 128)
{
errno = EINVAL;
return -1;
@@ -525,6 +524,12 @@ ipv6_userprefix(
return -1;
}
+ /* If user_number is zero, just copy the prefix into the result. */
+ if (user_number == 0) {
+ *result = *prefix;
+ return 0;
+ }
+
/* Shift user_number so it fit's just inside result_len.
* Shifting by 0 or sizeof(user_number) is undefined,
* so we cater for that. */