7 var callFileList = rpc.declare({
11 expect: { entries: [] },
12 filter: function(list, params) {
14 for (var i = 0; i < list.length; i++)
15 if (list[i].name.match(/^tty[A-Z]/) || list[i].name.match(/^cdc-wdm/) || list[i].name.match(/^[0-9]+$/))
16 rv.push(params.path + list[i].name);
21 network.registerPatternVirtual(/^3g-.+$/);
23 function write_keepalive(section_id, value) {
24 var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
25 i_opt = this.map.lookupOption('_keepalive_interval', section_id),
26 f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
27 i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
29 if (f == null || f == '' || isNaN(f))
32 if (i == null || i == '' || isNaN(i) || i < 1)
36 uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
38 uci.unset('network', section_id, 'keepalive');
41 return network.registerProtocol('3g', {
43 return _('UMTS/GPRS/EV-DO');
46 getIfname: function() {
47 return this._ubus('l3_device') || '3g-%s'.format(this.sid);
50 getOpkgPackage: function() {
54 isFloating: function() {
58 isVirtual: function() {
62 getDevices: function() {
66 containsDevice: function(ifname) {
67 return (network.getIfnameOf(ifname) == this.getIfname());
70 renderFormOptions: function(s) {
73 o = s.taboption('general', form.Value, 'device', _('Modem device'));
75 o.load = function(section_id) {
76 return callFileList('/dev/').then(L.bind(function(devices) {
77 for (var i = 0; i < devices.length; i++)
78 this.value(devices[i]);
79 return callFileList('/dev/tts/');
80 }, this)).then(L.bind(function(devices) {
81 for (var i = 0; i < devices.length; i++)
82 this.value(devices[i]);
83 return form.Value.prototype.load.apply(this, [section_id]);
87 o = s.taboption('general', form.Value, 'service', _('Service Type'));
88 o.value('', _('-- Please choose --'));
89 o.value('umts', 'UMTS/GPRS');
90 o.value('umts_only', _('UMTS only'));
91 o.value('gprs_only', _('GPRS only'));
92 o.value('evdo', 'CDMA/EV-DO');
94 s.taboption('general', form.Value, 'apn', _('APN'));
95 s.taboption('general', form.Value, 'pincode', _('PIN'));
96 s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
98 o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
101 o = s.taboption('general', form.Value, 'dialnumber', _('Dial number'));
102 o.placeholder = '*99***1#';
104 if (L.hasSystemFeature('ipv6')) {
105 o = s.taboption('advanced', form.ListValue, 'ipv6', _('Obtain IPv6-Address'));
106 o.value('auto', _('Automatic'));
107 o.value('0', _('Disabled'));
108 o.value('1', _('Manual'));
112 o = s.taboption('advanced', form.Value, 'delay', _('Modem init timeout'), _('Maximum amount of seconds to wait for the modem to become ready'));
113 o.placeholder = '10';
114 o.datatype = 'min(1)';
116 o = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
117 o.default = o.enabled;
119 o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
121 o.datatype = 'uinteger';
122 o.depends('defaultroute', '1');
124 o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
125 o.default = o.enabled;
127 o = s.taboption('advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
128 o.depends('peerdns', '0');
129 o.datatype = 'ipaddr';
131 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'));
133 o.datatype = 'uinteger';
134 o.write = write_keepalive;
135 o.remove = write_keepalive;
136 o.cfgvalue = function(section_id) {
137 var v = uci.get('network', section_id, 'keepalive');
138 if (typeof(v) == 'string' && v != '') {
139 var m = v.match(/^(\d+)[ ,]\d+$/);
144 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'));
146 o.datatype = 'min(1)';
147 o.write = write_keepalive;
148 o.remove = write_keepalive;
149 o.cfgvalue = function(section_id) {
150 var v = uci.get('network', section_id, 'keepalive');
151 if (typeof(v) == 'string' && v != '') {
152 var m = v.match(/^\d+[ ,](\d+)$/);
157 o = s.taboption('advanced', form.Value, 'demand', _('Inactivity timeout'), _('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
159 o.datatype = 'uinteger';