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+)")
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>
39 <fieldset class="cbi-section">
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>
50 for _, v in ipairs(ip.neighbors({ family = 4 })) do
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>
68 <fieldset class="cbi-section">
69 <legend><%_Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes%></legend>
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>
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>
88 <% style = not style end %>
95 if nixio.fs.access("/proc/net/ipv6_route") then
98 <fieldset class="cbi-section">
99 <legend><%_Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes%></legend>
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>
111 for _, v in ipairs(ip.routes({ family = 6, type = 1 })) do
112 if v.dest and not v.dest:is6linklocal() then
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>
131 <fieldset class="cbi-section">
132 <legend><%:IPv6 Neighbours%></legend>
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>
142 for _, v in ipairs(ip.neighbors({ family = 6 })) do
143 if v.dest and not v.dest:is6linklocal() and v.mac then
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>