From: John Crispin Date: Tue, 3 Dec 2024 13:22:26 +0000 (+0100) Subject: wifi-scripts: various minor fixes to the new ucode scripts X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3ba6737f2f4750e4f7c2b921ff023a99b9a27318;p=openwrt%2Fstaging%2Fwigyori.git 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 --- diff --git a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc index 71672c23ad..a266092bea 100644 --- a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc +++ b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc @@ -58,7 +58,7 @@ function get_hardware_id(iface) { }; let path = `/sys/class/ieee80211/phy${iface.wiphy}/device/`; - if (stat(path) + 'vendor') { + if (stat(path + 'vendor')) { let data = []; for (let lookup in [ 'vendor', 'device', 'subsystem_vendor', 'subsystem_device' ]) push(data, trim(readfile(path + lookup), '\n')); @@ -162,16 +162,11 @@ function format_band(freq) { } function format_frequency(freq) { - if (!freq) - return 'unknown'; - freq = '' + freq; - return substr(freq, 0, 1) + '.' + substr(freq, 1); + return freq ? sprintf('%.03f', freq / 1000.0) : 'unknown'; } function format_rate(rate) { - if (!rate) - return 'unknown'; - return '' + (rate / 10) + '.' + (rate % 10); + return rate ? sprintf('%.01f', rate / 10.0) : 'unknown'; } function format_mgmt_key(key) { @@ -269,7 +264,7 @@ function dbm2mw(dbm) { for (let k = 0; k < ip; k++) res *= 10; for (let k = 0; k < fp; k++) - res *= 1.25892541179; + res *= LOG10_MAGIC; return int(res); } @@ -554,23 +549,23 @@ export function scan(dev) { case 48: cell.crypto = { - group: rsn_cipher[+ord(ie.data, 5)] ?? '', + group: rsn_cipher[ord(ie.data, 5)] ?? '', pair: [], key_mgmt: [], }; let offset = 6; - let count = +ord(ie.data, offset); + let count = ord(ie.data, offset); offset += 2; 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) push(cell.crypto.pair, key); offset += 4; } - count = +ord(ie.data, offset); + count = ord(ie.data, offset); offset += 2; for (let i = 0; i < count; i++) { diff --git a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/ap.uc b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/ap.uc index cc2900de9d..37864487c3 100644 --- a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/ap.uc +++ b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/ap.uc @@ -1,6 +1,7 @@ 'use strict'; import * as libuci from 'uci'; +import { md5 } from 'digest'; import * as fs from 'fs'; 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; 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, '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) { @@ -329,7 +330,7 @@ function iface_roaming(config) { if (!config.ieee80211r || config.wpa < 2) 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_iface', config.network_ifname); @@ -338,7 +339,7 @@ function iface_roaming(config) { if (!config.auth_secret && !config.key) 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, 'r1kh', '00:00:00:00:00:00,00:00:00:00:00:00,' + ft_key); diff --git a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/hostapd.uc b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/hostapd.uc index a17f6b5474..78b38ff633 100644 --- a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/hostapd.uc +++ b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/hostapd.uc @@ -333,7 +333,7 @@ function device_htmode_append(config) { config.vht_capab += rx_stbc[min(config.rx_stbc, (vht_capab >> 8) & 7)]; 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) config.vht_capab += '[BF-ANTENNA-' + min(((vht_capab >> 13) & 3) + 1, config.beamformer_antennas) + ']';