5 'require tools.widgets as widgets';
9 return network.getDevices();
12 render: function(netdevs) {
15 m = new form.Map('network', _('Routes'), _('Routes specify over which interface and gateway a certain host or network can be reached.'));
18 for (var i = 4; i <= 6; i += 2) {
19 s = m.section(form.GridSection, (i == 4) ? 'route' : 'route6', (i == 4) ? _('Static IPv4 Routes') : _('Static IPv6 Routes'));
24 s.tab('general', _('General Settings'));
25 s.tab('advanced', _('Advanced Settings'));
27 o = s.taboption('general', widgets.NetworkSelect, 'interface', _('Interface'));
31 o = s.taboption('general', form.Value, 'target', _('Target'), (i == 4) ? _('Host-<abbr title="Internet Protocol Address">IP</abbr> or Network') : _('<abbr title="Internet Protocol Version 6">IPv6</abbr>-Address or Network (CIDR)'));
32 o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
36 o = s.taboption('general', form.Value, 'netmask', _('<abbr title="Internet Protocol Version 4">IPv4</abbr>-Netmask'), _('if target is a network'));
37 o.placeholder = '255.255.255.255';
38 o.datatype = 'ip4addr';
42 o = s.taboption('general', form.Value, 'gateway', (i == 4) ? _('<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway') : _('<abbr title="Internet Protocol Version 6">IPv6</abbr>-Gateway'));
43 o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
46 o = s.taboption('advanced', form.Value, 'metric', _('Metric'));
48 o.datatype = (i == 4) ? 'range(0,255)' : 'range(0,65535)';
50 o.textvalue = function(section_id) {
51 return this.cfgvalue(section_id) || 0;
54 o = s.taboption('advanced', form.Value, 'mtu', _('MTU'));
56 o.datatype = 'range(64,9000)';
60 o = s.taboption('advanced', form.ListValue, 'type', _('Route type'));
61 o.value('', 'unicast');
65 o.value('unreachable');
73 o = s.taboption('advanced', form.Value, 'table', _('Route table'));
74 o.value('local', 'local (255)');
75 o.value('main', 'main (254)');
76 o.value('default', 'default (253)');
79 o.cfgvalue = function(section_id) {
80 var cfgvalue = this.super('cfgvalue', [section_id]);
81 return cfgvalue || 'main';
84 o = s.taboption('advanced', form.Value, 'source', _('Source Address'));
85 o.placeholder = E('em', _('automatic'));
86 for (var j = 0; j < netdevs.length; j++) {
87 var addrs = netdevs[j].getIPAddrs();
88 for (var k = 0; k < addrs.length; k++)
89 o.value(addrs[k].split('/')[0]);
91 o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
96 o = s.taboption('advanced', form.Flag, 'onlink', _('On-Link route'));
97 o.default = o.disabled;