6 network
.registerPatternVirtual(/^pppoa-.+$/);
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;
14 if (f
== null || f
== '' || isNaN(f
))
17 if (i
== null || i
== '' || isNaN(i
) || i
< 1)
21 uci
.set('network', section_id
, 'keepalive', '%d %d'.format(f
, i
));
23 uci
.unset('network', section_id
, 'keepalive');
26 return network
.registerProtocol('pppoa', {
31 getIfname: function() {
32 return this._ubus('l3_device') || 'pppoa-%s'.format(this.sid
);
35 getOpkgPackage: function() {
36 return 'ppp-mod-pppoa';
39 isFloating: function() {
43 isVirtual: function() {
47 getDevices: function() {
51 containsDevice: function(ifname
) {
52 return (network
.getIfnameOf(ifname
) == this.getIfname());
55 renderFormOptions: function(s
) {
56 var dev
= this.getL3Device() || this.getDevice(), o
;
58 o
= s
.taboption('general', form
.ListValue
, 'encaps', _('PPPoA Encapsulation'));
59 o
.value('vc', 'VC-Mux');
60 o
.value('llc', 'LLC');
62 o
= s
.taboption('general', form
.Value
, 'atmdev', _('ATM device number'));
64 o
.datatype
= 'uinteger';
66 o
= s
.taboption('general', form
.Value
, 'vci', _('ATM Virtual Channel Identifier (VCI)'));
68 o
.datatype
= 'uinteger';
70 o
= s
.taboption('general', form
.Value
, 'vpi', _('ATM Virtual Path Identifier (VPI)'));
72 o
.datatype
= 'uinteger';
74 s
.taboption('general', form
.Value
, 'username', _('PAP/CHAP username'));
76 o
= s
.taboption('general', form
.Value
, 'password', _('PAP/CHAP password'));
79 if (L
.hasSystemFeature('ipv6')) {
80 o
= s
.taboption('advanced', form
.ListValue
, 'ppp_ipv6', _('Obtain IPv6-Address'), _('Enable IPv6 negotiation on the PPP link'));
82 o
.value('auto', _('Automatic'));
83 o
.value('0', _('Disabled'));
84 o
.value('1', _('Manual'));
88 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'));
90 o
.datatype
= 'uinteger';
91 o
.write
= write_keepalive
;
92 o
.remove
= write_keepalive
;
93 o
.cfgvalue = function(section_id
) {
94 var v
= uci
.get('network', section_id
, 'keepalive');
95 if (typeof(v
) == 'string' && v
!= '') {
96 var m
= v
.match(/^(\d+)[ ,]\d+$/);
101 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'));
103 o
.datatype
= 'min(1)';
104 o
.write
= write_keepalive
;
105 o
.remove
= write_keepalive
;
106 o
.cfgvalue = function(section_id
) {
107 var v
= uci
.get('network', section_id
, 'keepalive');
108 if (typeof(v
) == 'string' && v
!= '') {
109 var m
= v
.match(/^\d+[ ,](\d+)$/);
114 o
= s
.taboption('advanced', form
.Value
, 'demand', _('Inactivity timeout'), _('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
116 o
.datatype
= 'uinteger';
118 o
= s
.taboption('advanced', form
.Value
, 'mtu', _('Override MTU'));
119 o
.placeholder
= dev
? (dev
.getMTU() || '1500') : '1500';
120 o
.datatype
= 'max(9200)';