summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm
blob: af803713538e79da0cc53b19111cdcba4680ccb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<%#
 Copyright 2008-2009 Steven Barth <steven@midlink.org>
 Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
 Licensed to the public under the Apache License 2.0.
-%>

<%-
	require "luci.tools.webadmin"
	require "nixio.fs"

	local ip = require "luci.ip"
	local style = true
	local _, v

	local rtn = {
		[255] = "local",
		[254] = "main",
		[253] = "default",
		[0]   = "unspec"
	}

	if nixio.fs.access("/etc/iproute2/rt_tables") then
		local ln
		for ln in io.lines("/etc/iproute2/rt_tables") do
			local i, n = ln:match("^(%d+)%s+(%S+)")
			if i and n then
				rtn[tonumber(i)] = n
			end
		end
	end
-%>

<%+header%>

<div class="cbi-map" id="cbi-network">
	<h2 name="content"><%:Routes%></h2>
	<div class="cbi-map-descr"><%:The following rules are currently active on this system.%></div>

	<fieldset class="cbi-section">
		<legend>ARP</legend>
		<div class="cbi-section-node">
			<div class="table cbi-section-table">
				<div class="tr cbi-section-table-titles">
					<div class="th cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address%></div>
					<div class="th cbi-section-table-cell"><%_<abbr title="Media Access Control">MAC</abbr>-Address%></div>
					<div class="th cbi-section-table-cell"><%:Interface%></div>
				</div>

				<%
					for _, v in ipairs(ip.neighbors({ family = 4 })) do
						if v.mac then
				%>
				<div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
					<div class="td cbi-value-field"><%=v.dest%></div>
					<div class="td cbi-value-field"><%=v.mac%></div>
					<div class="td cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></div>
				</div>
				<%
							style = not style
						end
					end
				%>
			</div>
		</div>
	</fieldset>
	<br />

	<fieldset class="cbi-section">
		<legend><%_Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes%></legend>

		<div class="cbi-section-node">
			<div class="table cbi-section-table">
				<div class="tr cbi-section-table-titles">
					<div class="th cbi-section-table-cell"><%:Network%></div>
					<div class="th cbi-section-table-cell"><%:Target%></div>
					<div class="th cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway%></div>
					<div class="th cbi-section-table-cell"><%:Metric%></div>
					<div class="th cbi-section-table-cell"><%:Table%></div>
				</div>
				<% for _, v in ipairs(ip.routes({ family = 4, type = 1 })) do %>
				<div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
					<div class="td cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or v.dev%></div>
					<div class="td cbi-value-field"><%=v.dest%></div>
					<div class="td cbi-value-field"><%=v.gw%></div>
					<div class="td cbi-value-field"><%=v.metric or 0%></div>
					<div class="td cbi-value-field"><%=rtn[v.table] or v.table%></div>
				</div>
				<% style = not style end %>
			</div>
		</div>
	</fieldset>
	<br />

	<%
		if nixio.fs.access("/proc/net/ipv6_route") then
			style = true
	%>
	<fieldset class="cbi-section">
		<legend><%_Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes%></legend>

		<div class="cbi-section-node">
			<div class="table cbi-section-table">
				<div class="tr cbi-section-table-titles">
					<div class="th cbi-section-table-cell"><%:Network%></div>
					<div class="th cbi-section-table-cell"><%:Target%></div>
					<div class="th cbi-section-table-cell"><%:Source%></div>
					<div class="th cbi-section-table-cell"><%:Metric%></div>
					<div class="th cbi-section-table-cell"><%:Table%></div>
				</div>
				<%
					for _, v in ipairs(ip.routes({ family = 6, type = 1 })) do
						if v.dest and not v.dest:is6linklocal() then
				%>
				<div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
					<div class="td cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></div>
					<div class="td cbi-value-field"><%=v.dest%></div>
					<div class="td cbi-value-field"><%=v.from%></div>
					<div class="td cbi-value-field"><%=v.metric or 0%></div>
					<div class="td cbi-value-field"><%=rtn[v.table] or v.table%></div>
				</div>
				<%
							style = not style
						end
					end
				%>
			</div>
		</div>
	</fieldset>
	<br />

	<fieldset class="cbi-section">
		<legend><%:IPv6 Neighbours%></legend>

		<div class="cbi-section-node">
			<div class="table cbi-section-table">
				<div class="tr cbi-section-table-titles">
					<div class="th cbi-section-table-cell"><%:IPv6-Address%></div>
					<div class="th cbi-section-table-cell"><%:MAC-Address%></div>
					<div class="th cbi-section-table-cell"><%:Interface%></div>
				</div>
				<%
					for _, v in ipairs(ip.neighbors({ family = 6 })) do
						if v.dest and not v.dest:is6linklocal() and v.mac then
				%>
				<div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
					<div class="td cbi-value-field"><%=v.dest%></div>
					<div class="td cbi-value-field"><%=v.mac%></div>
					<div class="td cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></div>
				</div>
				<%
							style = not style
						end
					end
				%>
			</div>
		</div>
	</fieldset>
	<br />
	<% end %>
</div>

<%+footer%>