summaryrefslogtreecommitdiff
path: root/luci2/htdocs/luci2/view/status.routes.js
blob: a73cf828adf12d7cda548ede840265edf6f5a7ed (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
L.ui.view.extend({
	title: L.tr('Routes'),
	description: L.tr('The following rules are currently active on this system.'),

	getRoutes: L.rpc.declare({
		object: 'luci2.network',
		method: 'routes',
		expect: { routes: [ ] }
	}),

	getIPv6Routes: L.rpc.declare({
		object: 'luci2.network',
		method: 'routes',
		expect: { routes: [ ] }
	}),

	getARPTable: L.rpc.declare({
		object: 'luci2.network',
		method: 'arp_table',
		expect: { entries: [ ] }
	}),

	execute: function() {
		var self = this;
		return $.when(
			self.getARPTable().then(function(arp) {
				var arpTable = new L.ui.table({
					caption: L.tr('ARP'),
					columns: [{
						caption: L.tr('IPv4-Address'),
						key:     'ipaddr'
					}, {
						caption: L.tr('MAC-Address'),
						key:     'macaddr'
					}, {
						caption: L.tr('Interface'),
						key:     'device'
					}]
				});

				arpTable.rows(arp);
				arpTable.insertInto('#arp_table');
			}),
			self.getRoutes().then(function(routes) {
				var routeTable = new L.ui.table({
					caption: L.tr('Active IPv4-Routes'),
					columns: [{
						caption: L.tr('Target'),
						key:     'target'
					}, {
						caption: L.tr('Gateway'),
						key:     'nexthop'
					}, {
						caption: L.tr('Metric'),
						key:     'metric'
					}, {
						caption: L.tr('Interface'),
						key:     'device'
					}]
				});

				routeTable.rows(routes);
				routeTable.insertInto('#route_table');
			}),
			self.getIPv6Routes().then(function(routes) {
				var route6Table = new L.ui.table({
					caption: L.tr('Active IPv6-Routes'),
					columns: [{
						caption: L.tr('Target'),
						key:     'target'
					}, {
						caption: L.tr('Gateway'),
						key:     'nexthop'
					}, {
						caption: L.tr('Source'),
						key:     'source'
					}, {
						caption: L.tr('Metric'),
						key:     'metric'
					}, {
						caption: L.tr('Interface'),
						key:     'device'
					}]
				});

				for (var i = 0; i < routes.length; i++)
				{
					var prefix = routes[i].target.substr(0, 5).toLowerCase();
					if (prefix == 'fe80:' || prefix == 'fe90:' || prefix == 'fea0:' || prefix == 'feb0:' || prefix == 'ff00:')
						continue;

					route6Table.row(routes[i]);
				}

				route6Table.insertInto('#route6_table');
			})
		)
	}
});