wifi-scripts: various minor fixes to the new ucode scripts
* cosmetic clean up * properly import the digest module * typo fixes Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
parent
53ee2e8c03
commit
3ba6737f2f
@ -58,7 +58,7 @@ function get_hardware_id(iface) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let path = `/sys/class/ieee80211/phy${iface.wiphy}/device/`;
|
let path = `/sys/class/ieee80211/phy${iface.wiphy}/device/`;
|
||||||
if (stat(path) + 'vendor') {
|
if (stat(path + 'vendor')) {
|
||||||
let data = [];
|
let data = [];
|
||||||
for (let lookup in [ 'vendor', 'device', 'subsystem_vendor', 'subsystem_device' ])
|
for (let lookup in [ 'vendor', 'device', 'subsystem_vendor', 'subsystem_device' ])
|
||||||
push(data, trim(readfile(path + lookup), '\n'));
|
push(data, trim(readfile(path + lookup), '\n'));
|
||||||
@ -162,16 +162,11 @@ function format_band(freq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function format_frequency(freq) {
|
function format_frequency(freq) {
|
||||||
if (!freq)
|
return freq ? sprintf('%.03f', freq / 1000.0) : 'unknown';
|
||||||
return 'unknown';
|
|
||||||
freq = '' + freq;
|
|
||||||
return substr(freq, 0, 1) + '.' + substr(freq, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_rate(rate) {
|
function format_rate(rate) {
|
||||||
if (!rate)
|
return rate ? sprintf('%.01f', rate / 10.0) : 'unknown';
|
||||||
return 'unknown';
|
|
||||||
return '' + (rate / 10) + '.' + (rate % 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_mgmt_key(key) {
|
function format_mgmt_key(key) {
|
||||||
@ -269,7 +264,7 @@ function dbm2mw(dbm) {
|
|||||||
for (let k = 0; k < ip; k++)
|
for (let k = 0; k < ip; k++)
|
||||||
res *= 10;
|
res *= 10;
|
||||||
for (let k = 0; k < fp; k++)
|
for (let k = 0; k < fp; k++)
|
||||||
res *= 1.25892541179;
|
res *= LOG10_MAGIC;
|
||||||
|
|
||||||
return int(res);
|
return int(res);
|
||||||
}
|
}
|
||||||
@ -554,23 +549,23 @@ export function scan(dev) {
|
|||||||
|
|
||||||
case 48:
|
case 48:
|
||||||
cell.crypto = {
|
cell.crypto = {
|
||||||
group: rsn_cipher[+ord(ie.data, 5)] ?? '',
|
group: rsn_cipher[ord(ie.data, 5)] ?? '',
|
||||||
pair: [],
|
pair: [],
|
||||||
key_mgmt: [],
|
key_mgmt: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
let offset = 6;
|
let offset = 6;
|
||||||
let count = +ord(ie.data, offset);
|
let count = ord(ie.data, offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
let key = rsn_cipher[+ord(ie.data, offset + 3)];
|
let key = rsn_cipher[ord(ie.data, offset + 3)];
|
||||||
if (key)
|
if (key)
|
||||||
push(cell.crypto.pair, key);
|
push(cell.crypto.pair, key);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = +ord(ie.data, offset);
|
count = ord(ie.data, offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import * as libuci from 'uci';
|
import * as libuci from 'uci';
|
||||||
|
import { md5 } from 'digest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import { append, append_raw, append_value, append_vars, comment, push_config, set_default, touch_file } from 'wifi.common';
|
import { append, append_raw, append_value, append_vars, comment, push_config, set_default, touch_file } from 'wifi.common';
|
||||||
@ -140,10 +141,10 @@ function iface_auth_type(config) {
|
|||||||
config.vlan_possible = 1;
|
config.vlan_possible = 1;
|
||||||
|
|
||||||
if (config.fils) {
|
if (config.fils) {
|
||||||
set_default(config, 'erp_domain', substr(digest.md5(config.ssid), 0, 4));
|
set_default(config, 'erp_domain', substr(md5(config.ssid), 0, 4));
|
||||||
set_default(config, 'fils_realm', config.erp_domain);
|
set_default(config, 'fils_realm', config.erp_domain);
|
||||||
set_default(config, 'erp_send_reauth_start', 1);
|
set_default(config, 'erp_send_reauth_start', 1);
|
||||||
set_default(config, 'fils_cache_id', substr(digest.md5(config.fils_realm), 0, 4));
|
set_default(config, 'fils_cache_id', substr(md5(config.fils_realm), 0, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.eap_server) {
|
if (!config.eap_server) {
|
||||||
@ -329,7 +330,7 @@ function iface_roaming(config) {
|
|||||||
if (!config.ieee80211r || config.wpa < 2)
|
if (!config.ieee80211r || config.wpa < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_default(config, 'mobility_domain', substr(digest.md5(config.ssid), 0, 4));
|
set_default(config, 'mobility_domain', substr(md5(config.ssid), 0, 4));
|
||||||
set_default(config, 'ft_psk_generate_local', config.auth_type == 'psk');
|
set_default(config, 'ft_psk_generate_local', config.auth_type == 'psk');
|
||||||
set_default(config, 'ft_iface', config.network_ifname);
|
set_default(config, 'ft_iface', config.network_ifname);
|
||||||
|
|
||||||
@ -338,7 +339,7 @@ function iface_roaming(config) {
|
|||||||
if (!config.auth_secret && !config.key)
|
if (!config.auth_secret && !config.key)
|
||||||
netifd.setup_failed('FT_KEY_CANT_BE_DERIVED');
|
netifd.setup_failed('FT_KEY_CANT_BE_DERIVED');
|
||||||
|
|
||||||
let ft_key = digest.md5(`${mobility_domain}/${auth_secret ?? key}`);
|
let ft_key = md5(`${mobility_domain}/${auth_secret ?? key}`);
|
||||||
|
|
||||||
set_default(config, 'r0kh', 'ff:ff:ff:ff:ff:ff,*,' + ft_key);
|
set_default(config, 'r0kh', 'ff:ff:ff:ff:ff:ff,*,' + ft_key);
|
||||||
set_default(config, 'r1kh', '00:00:00:00:00:00,00:00:00:00:00:00,' + ft_key);
|
set_default(config, 'r1kh', '00:00:00:00:00:00,00:00:00:00:00:00,' + ft_key);
|
||||||
|
@ -333,7 +333,7 @@ function device_htmode_append(config) {
|
|||||||
config.vht_capab += rx_stbc[min(config.rx_stbc, (vht_capab >> 8) & 7)];
|
config.vht_capab += rx_stbc[min(config.rx_stbc, (vht_capab >> 8) & 7)];
|
||||||
|
|
||||||
if (vht_capab & 0x800 && config.su_beamformer)
|
if (vht_capab & 0x800 && config.su_beamformer)
|
||||||
config.vht_capab += '[SOUNDING-DIMENSION' + min(((vht_capab >> 16) & 3) + 1, config.beamformer_antennas) + ']';
|
config.vht_capab += '[SOUNDING-DIMENSION-' + min(((vht_capab >> 16) & 3) + 1, config.beamformer_antennas) + ']';
|
||||||
if (vht_capab & 0x1000 && config.su_beamformee)
|
if (vht_capab & 0x1000 && config.su_beamformee)
|
||||||
config.vht_capab += '[BF-ANTENNA-' + min(((vht_capab >> 13) & 3) + 1, config.beamformer_antennas) + ']';
|
config.vht_capab += '[BF-ANTENNA-' + min(((vht_capab >> 13) & 3) + 1, config.beamformer_antennas) + ']';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user