aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--util/rfc3484.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/util/rfc3484.lua b/util/rfc3484.lua
index 373d3c33..dd855a84 100644
--- a/util/rfc3484.lua
+++ b/util/rfc3484.lua
@@ -5,10 +5,20 @@
-- COPYING file in the source package for more information.
--
-local t_sort = table.sort;
local commonPrefixLength = require"util.ip".commonPrefixLength
local new_ip = require"util.ip".new_ip;
+local function t_sort(t, comp)
+ for i = 1, (#t - 1) do
+ for j = (i + 1), #t do
+ local a, b = t[i], t[j];
+ if not comp(a,b) then
+ t[i], t[j] = b, a;
+ end
+ end
+ end
+end
+
function source(dest, candidates)
local function comp(ipA, ipB)
-- Rule 1: Prefer same address
@@ -61,7 +71,6 @@ function source(dest, candidates)
end
function destination(candidates, sources)
- local t_sort = table.sort;
local sourceAddrs = {};
local function comp(ipA, ipB)
local ipAsource = sourceAddrs[ipA];