Merge pull request #396 from fanthos/master
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_status / routes.htm
1 <%#
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.
5 -%>
6
7 <%-
8 require "luci.tools.webadmin"
9 require "nixio.fs"
10
11 local ip = require "luci.ip"
12 local style = true
13 local _, v
14
15 local rtn = {
16 [255] = "local",
17 [254] = "main",
18 [253] = "default",
19 [0] = "unspec"
20 }
21
22 if nixio.fs.access("/etc/iproute2/rt_tables") then
23 local ln
24 for ln in io.lines("/etc/iproute2/rt_tables") do
25 local i, n = ln:match("^(%d+)%s+(%S+)")
26 if i and n then
27 rtn[tonumber(i)] = n
28 end
29 end
30 end
31 -%>
32
33 <%+header%>
34
35 <div class="cbi-map" id="cbi-network">
36 <h2 name="content"><%:Routes%></h2>
37 <div class="cbi-map-descr"><%:The following rules are currently active on this system.%></div>
38
39 <fieldset class="cbi-section">
40 <legend>ARP</legend>
41 <div class="cbi-section-node">
42 <table class="cbi-section-table">
43 <tr class="cbi-section-table-titles">
44 <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address%></th>
45 <th class="cbi-section-table-cell"><%_<abbr title="Media Access Control">MAC</abbr>-Address%></th>
46 <th class="cbi-section-table-cell"><%:Interface%></th>
47 </tr>
48
49 <%
50 for _, v in ipairs(ip.neighbors({ family = 4 })) do
51 if v.mac then
52 %>
53 <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
54 <td class="cbi-value-field"><%=v.dest%></td>
55 <td class="cbi-value-field"><%=v.mac%></td>
56 <td class="cbi-value-field"><%=v.dev%></td>
57 </tr>
58 <%
59 style = not style
60 end
61 end
62 %>
63 </table>
64 </div>
65 </fieldset>
66 <br />
67
68 <fieldset class="cbi-section">
69 <legend><%_Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes%></legend>
70
71 <div class="cbi-section-node">
72 <table class="cbi-section-table">
73 <tr class="cbi-section-table-titles">
74 <th class="cbi-section-table-cell"><%:Network%></th>
75 <th class="cbi-section-table-cell"><%:Target%></th>
76 <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway%></th>
77 <th class="cbi-section-table-cell"><%:Metric%></th>
78 <th class="cbi-section-table-cell"><%:Table%></th>
79 </tr>
80 <% for _, v in ipairs(ip.routes({ family = 4, type = 1 })) do %>
81 <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
82 <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or v.dev%></td>
83 <td class="cbi-value-field"><%=v.dest%></td>
84 <td class="cbi-value-field"><%=v.gw%></td>
85 <td class="cbi-value-field"><%=v.metric or 0%></td>
86 <td class="cbi-value-field"><%=rtn[v.table] or v.table%></td>
87 </tr>
88 <% style = not style end %>
89 </table>
90 </div>
91 </fieldset>
92 <br />
93
94 <%
95 if nixio.fs.access("/proc/net/ipv6_route") then
96 style = true
97 %>
98 <fieldset class="cbi-section">
99 <legend><%_Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes%></legend>
100
101 <div class="cbi-section-node">
102 <table class="cbi-section-table">
103 <tr class="cbi-section-table-titles">
104 <th class="cbi-section-table-cell"><%:Network%></th>
105 <th class="cbi-section-table-cell"><%:Target%></th>
106 <th class="cbi-section-table-cell"><%:Source%></th>
107 <th class="cbi-section-table-cell"><%:Metric%></th>
108 <th class="cbi-section-table-cell"><%:Table%></th>
109 </tr>
110 <%
111 for _, v in ipairs(ip.routes({ family = 6, type = 1 })) do
112 if v.dest and not v.dest:is6linklocal() then
113 %>
114 <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
115 <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></td>
116 <td class="cbi-value-field"><%=v.dest%></td>
117 <td class="cbi-value-field"><%=v.from%></td>
118 <td class="cbi-value-field"><%=v.metric or 0%></td>
119 <td class="cbi-value-field"><%=rtn[v.table] or v.table%></td>
120 </tr>
121 <%
122 style = not style
123 end
124 end
125 %>
126 </table>
127 </div>
128 </fieldset>
129 <br />
130
131 <fieldset class="cbi-section">
132 <legend><%:IPv6 Neighbours%></legend>
133
134 <div class="cbi-section-node">
135 <table class="cbi-section-table">
136 <tr class="cbi-section-table-titles">
137 <th class="cbi-section-table-cell"><%:IPv6-Address%></th>
138 <th class="cbi-section-table-cell"><%:MAC-Address%></th>
139 <th class="cbi-section-table-cell"><%:Interface%></th>
140 </tr>
141 <%
142 for _, v in ipairs(ip.neighbors({ family = 6 })) do
143 if v.dest and not v.dest:is6linklocal() and v.mac then
144 %>
145 <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
146 <td class="cbi-value-field"><%=v.dest%></td>
147 <td class="cbi-value-field"><%=v.mac%></td>
148 <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></td>
149 </tr>
150 <%
151 style = not style
152 end
153 end
154 %>
155 </table>
156 </div>
157 </fieldset>
158 <br />
159 <% end %>
160 </div>
161
162 <%+footer%>