aboutsummaryrefslogtreecommitdiffstats
path: root/util/ip.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2013-04-30 18:34:03 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2013-04-30 18:34:03 +0200
commite53d5b4f79b5eab9c8266810b42b0cfa91919ed9 (patch)
tree03f20342d2e906044736e9fae3b598bf4deaee89 /util/ip.lua
parent99c908e11a5ca1b6a26c48f051c1ea1db9117536 (diff)
downloadprosody-e53d5b4f79b5eab9c8266810b42b0cfa91919ed9.tar.gz
prosody-e53d5b4f79b5eab9c8266810b42b0cfa91919ed9.zip
util.rfc{3484,6724}: Update to RFC 6724
Diffstat (limited to 'util/ip.lua')
-rw-r--r--util/ip.lua23
1 files changed, 18 insertions, 5 deletions
diff --git a/util/ip.lua b/util/ip.lua
index 2f09c034..de287b16 100644
--- a/util/ip.lua
+++ b/util/ip.lua
@@ -64,9 +64,6 @@ local function v4scope(ip)
-- Link-local unicast:
elseif fields[1] == 169 and fields[2] == 254 then
return 0x2;
- -- Site-local unicast:
- elseif (fields[1] == 10) or (fields[1] == 192 and fields[2] == 168) or (fields[1] == 172 and (fields[2] >= 16 and fields[2] < 32)) then
- return 0x5;
-- Global unicast:
else
return 0xE;
@@ -97,6 +94,14 @@ local function label(ip)
return 0;
elseif commonPrefixLength(ip, new_ip("2002::", "IPv6")) >= 16 then
return 2;
+ elseif commonPrefixLength(ip, new_ip("2001::", "IPv6")) >= 32 then
+ return 5;
+ elseif commonPrefixLength(ip, new_ip("fc00::", "IPv6")) >= 7 then
+ return 13;
+ elseif commonPrefixLength(ip, new_ip("fec0::", "IPv6")) >= 10 then
+ return 11;
+ elseif commonPrefixLength(ip, new_ip("3ffe::", "IPv6")) >= 16 then
+ return 12;
elseif commonPrefixLength(ip, new_ip("::", "IPv6")) >= 96 then
return 3;
elseif commonPrefixLength(ip, new_ip("::ffff:0:0", "IPv6")) >= 96 then
@@ -111,10 +116,18 @@ local function precedence(ip)
return 50;
elseif commonPrefixLength(ip, new_ip("2002::", "IPv6")) >= 16 then
return 30;
+ elseif commonPrefixLength(ip, new_ip("2001::", "IPv6")) >= 32 then
+ return 5;
+ elseif commonPrefixLength(ip, new_ip("fc00::", "IPv6")) >= 7 then
+ return 3;
+ elseif commonPrefixLength(ip, new_ip("fec0::", "IPv6")) >= 10 then
+ return 1;
+ elseif commonPrefixLength(ip, new_ip("3ffe::", "IPv6")) >= 16 then
+ return 1;
elseif commonPrefixLength(ip, new_ip("::", "IPv6")) >= 96 then
- return 20;
+ return 1;
elseif commonPrefixLength(ip, new_ip("::ffff:0:0", "IPv6")) >= 96 then
- return 10;
+ return 35;
else
return 40;
end