2 listDeviceNames: L.rpc.declare({
5 expect: { 'devices': [ ] },
6 filter: function(data) {
12 getPhyName: L.rpc.declare({
15 params: [ 'section' ],
16 expect: { 'phyname': '' }
19 getDeviceStatus: L.rpc.declare({
24 filter: function(data, params) {
25 if (!$.isEmptyObject(data))
27 data['device'] = params['device'];
34 getAssocList: L.rpc.declare({
38 expect: { results: [ ] },
39 filter: function(data, params) {
40 for (var i = 0; i < data.length; i++)
41 data[i]['device'] = params['device'];
43 data.sort(function(a, b) {
44 if (a.bssid < b.bssid)
46 else if (a.bssid > b.bssid)
56 getWirelessStatus: function() {
57 return this.listDeviceNames().then(function(names) {
60 for (var i = 0; i < names.length; i++)
61 L.wireless.getDeviceStatus(names[i]);
64 }).then(function(networks) {
66 var net_by_devname = { };
69 'country', 'channel', 'frequency', 'frequency_offset',
70 'txpower', 'txpower_offset', 'hwmodes', 'hardware', 'phy'
74 'ssid', 'bssid', 'mode', 'quality', 'quality_max',
75 'signal', 'noise', 'bitrate', 'encryption'
78 for (var i = 0; i < networks.length; i++)
80 var phy = rv[networks[i].phy] || (
81 rv[networks[i].phy] = { networks: [ ] }
84 var net = net_by_devname[networks[i].device] = {
85 device: networks[i].device
88 for (var j = 0; j < phy_attrs.length; j++)
89 phy[phy_attrs[j]] = networks[i][phy_attrs[j]];
91 for (var j = 0; j < net_attrs.length; j++)
92 net[net_attrs[j]] = networks[i][net_attrs[j]];
94 /* copy parent interface properties to wds interfaces */
95 if (net.device.match(/^(.+)\.sta\d+$/) &&
96 net_by_devname[RegExp.$1])
98 var pnet = net_by_devname[RegExp.$1];
99 for (var j = 0; j < net_attrs.length; j++)
100 if (typeof(networks[i][net_attrs[j]]) === 'undefined' ||
101 net_attrs[j] == 'encryption')
102 net[net_attrs[j]] = pnet[net_attrs[j]];
105 phy.networks.push(net);
112 getAssocLists: function()
114 return this.listDeviceNames().then(function(names) {
117 for (var i = 0; i < names.length; i++)
118 L.wireless.getAssocList(names[i]);
120 return L.rpc.flush();
121 }).then(function(assoclists) {
124 for (var i = 0; i < assoclists.length; i++)
125 for (var j = 0; j < assoclists[i].length; j++)
126 rv.push(assoclists[i][j]);
132 formatEncryption: function(enc, condensed)
134 var format_list = function(l, s)
137 for (var i = 0; i < l.length; i++)
138 rv.push(l[i].toUpperCase());
139 return rv.join(s ? s : ', ');
142 if (!enc || !enc.enabled)
149 else if (enc.wep.length == 2)
150 return L.tr('WEP Open/Shared') + ' (%s)'.format(format_list(enc.ciphers, ', '));
151 else if (enc.wep[0] == 'shared')
152 return L.tr('WEP Shared Auth') + ' (%s)'.format(format_list(enc.ciphers, ', '));
154 return L.tr('WEP Open System') + ' (%s)'.format(format_list(enc.ciphers, ', '));
158 if (condensed && enc.wpa.length == 2)
159 return L.tr('WPA mixed');
161 return (enc.wpa[0] == 2) ? L.tr('WPA2') : L.tr('WPA');
162 else if (enc.wpa.length == 2)
163 return L.tr('mixed WPA/WPA2') + ' %s (%s)'.format(
164 format_list(enc.authentication, '/'),
165 format_list(enc.ciphers, ', ')
167 else if (enc.wpa[0] == 2)
168 return 'WPA2 %s (%s)'.format(
169 format_list(enc.authentication, '/'),
170 format_list(enc.ciphers, ', ')
173 return 'WPA %s (%s)'.format(
174 format_list(enc.authentication, '/'),
175 format_list(enc.ciphers, ', ')
179 return L.tr('Unknown');