Skip to content

Commit

Permalink
wifi-scripts: various minor fixes to the new ucode scripts
Browse files Browse the repository at this point in the history
* cosmetic clean up
* properly import the digest module
* typo fixes

Signed-off-by: John Crispin <[email protected]>
  • Loading branch information
blogic committed Dec 3, 2024
1 parent 53ee2e8 commit 3ba6737
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ']';

Expand Down

0 comments on commit 3ba6737

Please sign in to comment.