Software /
code /
prosody
Comparison
util/ip.lua @ 5552:40e7a6cf15ff
util.rfc{3484,6724}: Update to RFC 6724
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Tue, 30 Apr 2013 18:34:03 +0200 |
parent | 4433:f0e72fbe4d6a |
child | 5587:e108c3f97f26 |
child | 5597:6fe09707c73b |
comparison
equal
deleted
inserted
replaced
5550:557583904dc5 | 5552:40e7a6cf15ff |
---|---|
62 if fields[1] == 127 then | 62 if fields[1] == 127 then |
63 return 0x2; | 63 return 0x2; |
64 -- Link-local unicast: | 64 -- Link-local unicast: |
65 elseif fields[1] == 169 and fields[2] == 254 then | 65 elseif fields[1] == 169 and fields[2] == 254 then |
66 return 0x2; | 66 return 0x2; |
67 -- Site-local unicast: | |
68 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 | |
69 return 0x5; | |
70 -- Global unicast: | 67 -- Global unicast: |
71 else | 68 else |
72 return 0xE; | 69 return 0xE; |
73 end | 70 end |
74 end | 71 end |
95 local function label(ip) | 92 local function label(ip) |
96 if commonPrefixLength(ip, new_ip("::1", "IPv6")) == 128 then | 93 if commonPrefixLength(ip, new_ip("::1", "IPv6")) == 128 then |
97 return 0; | 94 return 0; |
98 elseif commonPrefixLength(ip, new_ip("2002::", "IPv6")) >= 16 then | 95 elseif commonPrefixLength(ip, new_ip("2002::", "IPv6")) >= 16 then |
99 return 2; | 96 return 2; |
97 elseif commonPrefixLength(ip, new_ip("2001::", "IPv6")) >= 32 then | |
98 return 5; | |
99 elseif commonPrefixLength(ip, new_ip("fc00::", "IPv6")) >= 7 then | |
100 return 13; | |
101 elseif commonPrefixLength(ip, new_ip("fec0::", "IPv6")) >= 10 then | |
102 return 11; | |
103 elseif commonPrefixLength(ip, new_ip("3ffe::", "IPv6")) >= 16 then | |
104 return 12; | |
100 elseif commonPrefixLength(ip, new_ip("::", "IPv6")) >= 96 then | 105 elseif commonPrefixLength(ip, new_ip("::", "IPv6")) >= 96 then |
101 return 3; | 106 return 3; |
102 elseif commonPrefixLength(ip, new_ip("::ffff:0:0", "IPv6")) >= 96 then | 107 elseif commonPrefixLength(ip, new_ip("::ffff:0:0", "IPv6")) >= 96 then |
103 return 4; | 108 return 4; |
104 else | 109 else |
109 local function precedence(ip) | 114 local function precedence(ip) |
110 if commonPrefixLength(ip, new_ip("::1", "IPv6")) == 128 then | 115 if commonPrefixLength(ip, new_ip("::1", "IPv6")) == 128 then |
111 return 50; | 116 return 50; |
112 elseif commonPrefixLength(ip, new_ip("2002::", "IPv6")) >= 16 then | 117 elseif commonPrefixLength(ip, new_ip("2002::", "IPv6")) >= 16 then |
113 return 30; | 118 return 30; |
119 elseif commonPrefixLength(ip, new_ip("2001::", "IPv6")) >= 32 then | |
120 return 5; | |
121 elseif commonPrefixLength(ip, new_ip("fc00::", "IPv6")) >= 7 then | |
122 return 3; | |
123 elseif commonPrefixLength(ip, new_ip("fec0::", "IPv6")) >= 10 then | |
124 return 1; | |
125 elseif commonPrefixLength(ip, new_ip("3ffe::", "IPv6")) >= 16 then | |
126 return 1; | |
114 elseif commonPrefixLength(ip, new_ip("::", "IPv6")) >= 96 then | 127 elseif commonPrefixLength(ip, new_ip("::", "IPv6")) >= 96 then |
115 return 20; | 128 return 1; |
116 elseif commonPrefixLength(ip, new_ip("::ffff:0:0", "IPv6")) >= 96 then | 129 elseif commonPrefixLength(ip, new_ip("::ffff:0:0", "IPv6")) >= 96 then |
117 return 10; | 130 return 35; |
118 else | 131 else |
119 return 40; | 132 return 40; |
120 end | 133 end |
121 end | 134 end |
122 | 135 |