2 Copyright 2008-2009 Steven Barth <steven@midlink.org>
3 Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
4 Licensed to the public under the Apache License 2.0.
8 require "luci.tools.webadmin"
11 local ip = require "luci.ip"
22 if nixio.fs.access("/etc/iproute2/rt_tables") then
24 for ln in io.lines("/etc/iproute2/rt_tables") do
25 local i, n = ln:match("^(%d+)%s+(%S+)")
36 <div class="cbi-map" id="cbi-network">
37 <h2 name="content"><%:Routes%></h2>
38 <div class="cbi-map-descr"><%:The following rules are currently active on this system.%></div>
40 <div class="cbi-section">
42 <div class="cbi-section-node">
44 <div class="tr table-titles">
45 <div class="th"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address%></div>
46 <div class="th"><%_<abbr title="Media Access Control">MAC</abbr>-Address%></div>
47 <div class="th"><%:Interface%></div>
51 for _, v in ipairs(ip.neighbors({ family = 4 })) do
54 <div class="tr cbi-rowstyle-<%=(style and 1 or 2)%>">
55 <div class="td"><%=v.dest%></div>
56 <div class="td"><%=v.mac%></div>
57 <div class="td"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></div>
68 <div class="cbi-section">
69 <legend><%_Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes%></legend>
70 <div class="cbi-section-node">
72 <div class="tr table-titles">
73 <div class="th"><%:Network%></div>
74 <div class="th"><%:Target%></div>
75 <div class="th"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway%></div>
76 <div class="th"><%:Metric%></div>
77 <div class="th"><%:Table%></div>
79 <% for _, v in ipairs(ip.routes({ family = 4, type = 1 })) do %>
80 <div class="tr cbi-rowstyle-<%=(style and 1 or 2)%>">
81 <div class="td"><%=luci.tools.webadmin.iface_get_network(v.dev) or v.dev%></div>
82 <div class="td"><%=v.dest%></div>
83 <div class="td"><%=v.gw or "-"%></div>
84 <div class="td"><%=v.metric or 0%></div>
85 <div class="td"><%=rtn[v.table] or v.table%></div>
87 <% style = not style end %>
93 if nixio.fs.access("/proc/net/ipv6_route") then
96 <div class="cbi-section">
97 <legend><%_Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes%></legend>
98 <div class="cbi-section-node">
100 <div class="tr table-titles">
101 <div class="th"><%:Network%></div>
102 <div class="th"><%:Target%></div>
103 <div class="th"><%:Source%></div>
104 <div class="th"><%:Metric%></div>
105 <div class="th"><%:Table%></div>
108 for _, v in ipairs(ip.routes({ family = 6, type = 1 })) do
109 if v.dest and not v.dest:is6linklocal() then
111 <div class="tr cbi-rowstyle-<%=(style and 1 or 2)%>">
112 <div class="td"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></div>
113 <div class="td"><%=v.dest%></div>
114 <div class="td"><%=v.from%></div>
115 <div class="td"><%=v.metric or 0%></div>
116 <div class="td"><%=rtn[v.table] or v.table%></div>
127 <div class="cbi-section">
128 <legend><%:IPv6 Neighbours%></legend>
129 <div class="cbi-section-node">
131 <div class="tr table-titles">
132 <div class="th"><%:IPv6-Address%></div>
133 <div class="th"><%:MAC-Address%></div>
134 <div class="th"><%:Interface%></div>
137 for _, v in ipairs(ip.neighbors({ family = 6 })) do
138 if v.dest and not v.dest:is6linklocal() and v.mac then
140 <div class="tr cbi-rowstyle-<%=(style and 1 or 2)%>">
141 <div class="td"><%=v.dest%></div>
142 <div class="td"><%=v.mac%></div>
143 <div class="td"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></div>