luci-proto-ppp: pppoe.so has no MTU option; remove it
[project/luci.git] / protocols / luci-proto-ppp / htdocs / luci-static / resources / protocol / pppoe.js
1 'use strict';
2 'require uci';
3 'require form';
4 'require network';
5
6 network.registerPatternVirtual(/^pppoe-.+$/);
7
8 function write_keepalive(section_id, value) {
9 var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
10 i_opt = this.map.lookupOption('_keepalive_interval', section_id),
11 f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
12 i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
13
14 if (f == null || f == '' || isNaN(f))
15 f = 0;
16
17 if (i == null || i == '' || isNaN(i) || i < 1)
18 i = 1;
19
20 if (f > 0)
21 uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
22 else
23 uci.unset('network', section_id, 'keepalive');
24 }
25
26 return network.registerProtocol('pppoe', {
27 getI18n: function() {
28 return _('PPPoE');
29 },
30
31 getIfname: function() {
32 return this._ubus('l3_device') || 'pppoe-%s'.format(this.sid);
33 },
34
35 getOpkgPackage: function() {
36 return 'ppp-mod-pppoe';
37 },
38
39 renderFormOptions: function(s) {
40 var dev = this.getL3Device() || this.getDevice(), o;
41
42 s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
43
44 o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
45 o.password = true;
46
47 o = s.taboption('general', form.Value, 'ac', _('Access Concentrator'), _('Leave empty to autodetect'));
48 o.placeholder = _('auto');
49
50 o = s.taboption('general', form.Value, 'service', _('Service Name'), _('Leave empty to autodetect'));
51 o.placeholder = _('auto');
52
53 if (L.hasSystemFeature('ipv6')) {
54 o = s.taboption('advanced', form.ListValue, 'ppp_ipv6', _('Obtain IPv6 address'), _('Enable IPv6 negotiation on the PPP link'));
55 o.ucioption = 'ipv6';
56 o.value('auto', _('Automatic'));
57 o.value('0', _('Disabled'));
58 o.value('1', _('Manual'));
59 o.default = 'auto';
60 }
61
62 o = s.taboption('advanced', form.Value, '_keepalive_failure', _('LCP echo failure threshold'), _('Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures'));
63 o.placeholder = '0';
64 o.datatype = 'uinteger';
65 o.write = write_keepalive;
66 o.remove = write_keepalive;
67 o.cfgvalue = function(section_id) {
68 var v = uci.get('network', section_id, 'keepalive');
69 if (typeof(v) == 'string' && v != '') {
70 var m = v.match(/^(\d+)[ ,]\d+$/);
71 return m ? m[1] : v;
72 }
73 };
74
75 o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
76 o.placeholder = '5';
77 o.datatype = 'min(1)';
78 o.write = write_keepalive;
79 o.remove = write_keepalive;
80 o.cfgvalue = function(section_id) {
81 var v = uci.get('network', section_id, 'keepalive');
82 if (typeof(v) == 'string' && v != '') {
83 var m = v.match(/^\d+[ ,](\d+)$/);
84 return m ? m[1] : v;
85 }
86 };
87
88 o = s.taboption('advanced', form.Value, 'host_uniq', _('Host-Uniq tag content'), _('Raw hex-encoded bytes. Leave empty unless your ISP require this'));
89 o.placeholder = _('auto');
90 o.datatype = 'hexstring';
91
92 o = s.taboption('advanced', form.Value, 'demand', _('Inactivity timeout'), _('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
93 o.placeholder = '0';
94 o.datatype = 'uinteger';
95
96 /* pppoe.so has no MTU option - only underlying device MTU is possible */
97 }
98 });