+--- Returns the current ipv6 kernel routing table entries.
+-- @return Table of tables with properties of the corresponding routes.
+-- The following fields are defined for route entry tables:
+-- { "source", "dest", "nexthop", "metric", "refcount", "usecount",
+-- "flags", "device" }
+function net.routes6()
+ if luci.fs.access("/proc/net/ipv6_route", "r") then
+ local routes = { }
+
+ for line in io.lines("/proc/net/ipv6_route") do
+
+ local dst_ip, dst_prefix, src_ip, src_prefix, nexthop,
+ metric, refcnt, usecnt, flags, dev = line:match(
+ "([a-f0-9]+) ([a-f0-9]+) " ..
+ "([a-f0-9]+) ([a-f0-9]+) " ..
+ "([a-f0-9]+) ([a-f0-9]+) " ..
+ "([a-f0-9]+) ([a-f0-9]+) " ..
+ "([a-f0-9]+) +([^%s]+)"
+ )
+
+ src_ip = luci.ip.Hex(
+ src_ip, tonumber(src_prefix, 16), luci.ip.FAMILY_INET6, false
+ )
+
+ dst_ip = luci.ip.Hex(
+ dst_ip, tonumber(dst_prefix, 16), luci.ip.FAMILY_INET6, false
+ )
+
+ nexthop = luci.ip.Hex( nexthop, 128, luci.ip.FAMILY_INET6, false )
+
+ routes[#routes+1] = {
+ source = src_ip,
+ dest = dst_ip,
+ nexthop = nexthop,
+ metric = tonumber(metric, 16),
+ refcount = tonumber(refcnt, 16),
+ usecount = tonumber(usecnt, 16),
+ flags = tonumber(flags, 16),
+ device = dev
+ }
+ end
+
+ return routes
+ end
+end