7 var callTTYDevices
= rpc
.declare({
9 method
: 'getTTYDevices',
10 params
: [ 'with_cdc', 'with_tts' ],
11 expect
: { result
: [] }
14 network
.registerPatternVirtual(/^ppp-.+$/);
16 function write_keepalive(section_id
, value
) {
17 var f_opt
= this.map
.lookupOption('_keepalive_failure', section_id
),
18 i_opt
= this.map
.lookupOption('_keepalive_interval', section_id
),
19 f
= (f_opt
!= null) ? +f_opt
[0].formvalue(section_id
) : null,
20 i
= (i_opt
!= null) ? +i_opt
[0].formvalue(section_id
) : null;
22 if (f
== null || f
== '' || isNaN(f
))
25 if (i
== null || i
== '' || isNaN(i
) || i
< 1)
29 uci
.set('network', section_id
, 'keepalive', '%d %d'.format(f
, i
));
31 uci
.unset('network', section_id
, 'keepalive');
34 return network
.registerProtocol('ppp', {
39 getIfname: function() {
40 return this._ubus('l3_device') || 'ppp-%s'.format(this.sid
);
43 getOpkgPackage: function() {
47 isFloating: function() {
51 isVirtual: function() {
55 getDevices: function() {
59 containsDevice: function(ifname
) {
60 return (network
.getIfnameOf(ifname
) == this.getIfname());
63 renderFormOptions: function(s
) {
64 var dev
= this.getL3Device() || this.getDevice(), o
;
66 o
= s
.taboption('general', form
.Value
, 'device', _('Modem device'));
68 o
.load = function(section_id
) {
69 return callTTYDevices(true, true).then(L
.bind(function(devices
) {
70 if (Array
.isArray(devices
))
71 for (var i
= 0; i
< devices
.length
; i
++)
72 this.value(devices
[i
]);
74 return form
.Value
.prototype.load
.apply(this, [section_id
]);
78 s
.taboption('general', form
.Value
, 'username', _('PAP/CHAP username'));
80 o
= s
.taboption('general', form
.Value
, 'password', _('PAP/CHAP password'));
83 if (L
.hasSystemFeature('ipv6')) {
84 o
= s
.taboption('advanced', form
.ListValue
, 'ipv6', _('Obtain IPv6-Address'), _('Enable IPv6 negotiation on the PPP link'));
85 o
.value('auto', _('Automatic'));
86 o
.value('0', _('Disabled'));
87 o
.value('1', _('Manual'));
91 o
= s
.taboption('advanced', form
.Flag
, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
92 o
.default = o
.enabled
;
94 o
= s
.taboption('advanced', form
.Flag
, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
95 o
.default = o
.enabled
;
97 o
= s
.taboption('advanced', form
.DynamicList
, 'dns', _('Use custom DNS servers'));
98 o
.depends('peerdns', '0');
99 o
.datatype
= 'ipaddr';
102 o
= s
.taboption('advanced', form
.Value
, 'metric', _('Use gateway metric'));
104 o
.datatype
= 'uinteger';
106 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'));
108 o
.datatype
= 'uinteger';
109 o
.write
= write_keepalive
;
110 o
.remove
= write_keepalive
;
111 o
.cfgvalue = function(section_id
) {
112 var v
= uci
.get('network', section_id
, 'keepalive');
113 if (typeof(v
) == 'string' && v
!= '') {
114 var m
= v
.match(/^(\d+)[ ,]\d+$/);
119 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'));
121 o
.datatype
= 'min(1)';
122 o
.write
= write_keepalive
;
123 o
.remove
= write_keepalive
;
124 o
.cfgvalue = function(section_id
) {
125 var v
= uci
.get('network', section_id
, 'keepalive');
126 if (typeof(v
) == 'string' && v
!= '') {
127 var m
= v
.match(/^\d+[ ,](\d+)$/);
132 o
= s
.taboption('advanced', form
.Value
, 'demand', _('Inactivity timeout'), _('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
134 o
.datatype
= 'uinteger';
136 o
= s
.taboption('advanced', form
.Value
, 'mtu', _('Override MTU'));
137 o
.placeholder
= dev
? (dev
.getMTU() || '1500') : '1500';
138 o
.datatype
= 'max(9200)';