Merge pull request #4429 from jamesmacwhite/mwan3-luci-up-down-defaults
[project/luci.git] / modules / luci-base / htdocs / luci-static / resources / protocol / dhcp.js
1 'use strict';
2 'require rpc';
3 'require form';
4 'require network';
5
6 var callFileRead = rpc.declare({
7 object: 'file',
8 method: 'read',
9 params: [ 'path' ],
10 expect: { data: '' },
11 filter: function(value) { return value.trim() }
12 });
13
14 return network.registerProtocol('dhcp', {
15 getI18n: function() {
16 return _('DHCP client');
17 },
18
19 renderFormOptions: function(s) {
20 var dev = this.getL2Device() || this.getDevice(), o;
21
22 o = s.taboption('general', form.Value, 'hostname', _('Hostname to send when requesting DHCP'));
23 o.default = '';
24 o.value('', _('Send the hostname of this device'));
25 o.value('*', _('Do not send a hostname'));
26 o.datatype = 'or(hostname, "*")';
27 o.load = function(section_id) {
28 return callFileRead('/proc/sys/kernel/hostname').then(L.bind(function(hostname) {
29 this.placeholder = hostname;
30 return form.Value.prototype.load.apply(this, [section_id]);
31 }, this));
32 };
33
34 o = s.taboption('advanced', form.Flag, 'broadcast', _('Use broadcast flag'), _('Required for certain ISPs, e.g. Charter with DOCSIS 3'));
35 o.default = o.disabled;
36
37 o = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
38 o.default = o.enabled;
39
40 o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
41 o.default = o.enabled;
42
43 o = s.taboption('advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
44 o.depends('peerdns', '0');
45 o.datatype = 'ipaddr';
46 o.cast = 'string';
47
48 o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
49 o.placeholder = '0';
50 o.datatype = 'uinteger';
51
52 o = s.taboption('advanced', form.Value, 'clientid', _('Client ID to send when requesting DHCP'));
53 o.datatype = 'hexstring';
54
55 s.taboption('advanced', form.Value, 'vendorid', _('Vendor Class to send when requesting DHCP'));
56
57 o = s.taboption('advanced', form.Value, 'macaddr', _('Override MAC address'));
58 o.datatype = 'macaddr';
59 o.placeholder = dev ? (dev.getMAC() || '') : '';
60
61 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
62 o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
63 o.datatype = 'max(9200)';
64 }
65 });