wifi-scripts: add macaddr_base wifi-device option
This can be used to configure the base mac address from which all interface mac addresses are derived Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
@@ -302,7 +302,7 @@ function setup() {
|
||||
if (mode != "ap")
|
||||
data.config.noscan = true;
|
||||
validate('iface', v.config);
|
||||
iface.prepare(v.config, data.phy + data.phy_suffix, data.config.num_global_macaddr);
|
||||
iface.prepare(v.config, data.phy + data.phy_suffix, data.config.num_global_macaddr, data.config.macaddr_base);
|
||||
netifd.set_vif(k, v.config.ifname);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -490,6 +490,10 @@
|
||||
"type": "alias",
|
||||
"default": "bssid"
|
||||
},
|
||||
"macaddr_base": {
|
||||
"type": "string",
|
||||
"description": "Base MAC address used for deriving interface MAC addresses"
|
||||
},
|
||||
"max_amsdu": {
|
||||
"description": "Maximum A-MSDU length of 7935 octects (3839 octets if option set to 0)",
|
||||
"type": "boolean",
|
||||
|
||||
@@ -544,6 +544,8 @@ export function setup(data) {
|
||||
|
||||
if (data.config.num_global_macaddr)
|
||||
append('\n#num_global_macaddr', data.config.num_global_macaddr);
|
||||
if (data.config.macaddr_base)
|
||||
append('\n#macaddr_base', data.config.macaddr_base);
|
||||
|
||||
for (let k, interface in data.interfaces) {
|
||||
if (interface.config.mode != 'ap')
|
||||
|
||||
@@ -178,9 +178,9 @@ function macaddr_random() {
|
||||
}
|
||||
|
||||
let mac_idx = 0;
|
||||
export function prepare(data, phy, num_global_macaddr) {
|
||||
export function prepare(data, phy, num_global_macaddr, macaddr_base) {
|
||||
if (!data.macaddr) {
|
||||
let pipe = fs.popen(`ucode /usr/share/hostap/wdev.uc ${phy} get_macaddr id=${mac_idx} num_global=${num_global_macaddr} mbssid=${data.mbssid ?? 0}`);
|
||||
let pipe = fs.popen(`ucode /usr/share/hostap/wdev.uc ${phy} get_macaddr id=${mac_idx} num_global=${num_global_macaddr} mbssid=${data.mbssid ?? 0} macaddr_base=${macaddr_base}`);
|
||||
|
||||
data.macaddr = trim(pipe.read("all"), '\n');
|
||||
pipe.close();
|
||||
|
||||
@@ -221,6 +221,7 @@ export function setup(config, data) {
|
||||
config,
|
||||
defer: true,
|
||||
num_global_macaddr: data.config.num_global_macaddr,
|
||||
macaddr_base: data.config.macaddr_base,
|
||||
});
|
||||
|
||||
if (ret)
|
||||
@@ -235,5 +236,6 @@ export function start(data) {
|
||||
phy: data.phy,
|
||||
radio: data.config.radio,
|
||||
num_global_macaddr: data.config.num_global_macaddr,
|
||||
macaddr_base: data.config.macaddr_base,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ drv_mac80211_init_device_config() {
|
||||
config_add_string tx_burst
|
||||
config_add_string distance
|
||||
config_add_string ifname_prefix
|
||||
config_add_string macaddr_base
|
||||
config_add_int radio beacon_int chanbw frag rts
|
||||
config_add_int rxantenna txantenna txpower min_tx_power
|
||||
config_add_int num_global_macaddr multiple_bssid
|
||||
@@ -530,6 +531,7 @@ ${hostapd_noscan:+noscan=1}
|
||||
${tx_burst:+tx_queue_data2_burst=$tx_burst}
|
||||
${multiple_bssid:+mbssid=$multiple_bssid}
|
||||
#num_global_macaddr=$num_global_macaddr
|
||||
#macaddr_base=$macaddr_base
|
||||
$base_cfg
|
||||
|
||||
EOF
|
||||
@@ -577,7 +579,7 @@ mac80211_generate_mac() {
|
||||
local phy="$1"
|
||||
local id="${macidx:-0}"
|
||||
|
||||
wdev_tool "$phy$phy_suffix" get_macaddr id=$id num_global=$num_global_macaddr mbssid=${multiple_bssid:-0}
|
||||
wdev_tool "$phy$phy_suffix" get_macaddr id=$id num_global=$num_global_macaddr mbssid=${multiple_bssid:-0} macaddr_base=${macaddr_base}
|
||||
}
|
||||
|
||||
get_board_phy_name() (
|
||||
@@ -939,6 +941,7 @@ wpa_supplicant_set_config() {
|
||||
json_add_string phy "$phy"
|
||||
json_add_int radio "$radio"
|
||||
json_add_int num_global_macaddr "$num_global_macaddr"
|
||||
json_add_string macaddr_base "$macaddr_base"
|
||||
json_add_boolean defer 1
|
||||
local data="$(json_dump)"
|
||||
|
||||
@@ -985,7 +988,7 @@ wpa_supplicant_start() {
|
||||
|
||||
[ -n "$wpa_supp_init" ] || return 0
|
||||
|
||||
ubus_call wpa_supplicant config_set '{ "phy": "'"$phy"'", "radio": '"$radio"', "num_global_macaddr": '"$num_global_macaddr"' }' > /dev/null
|
||||
ubus_call wpa_supplicant config_set '{ "phy": "'"$phy"'", "radio": '"$radio"', "num_global_macaddr": '"$num_global_macaddr"', "macaddr_base": "'"$macaddr_base"'" }' > /dev/null
|
||||
}
|
||||
|
||||
mac80211_setup_supplicant() {
|
||||
@@ -1112,7 +1115,7 @@ drv_mac80211_setup() {
|
||||
rxantenna txantenna \
|
||||
frag rts beacon_int:100 htmode \
|
||||
num_global_macaddr:1 multiple_bssid \
|
||||
ifname_prefix
|
||||
ifname_prefix macaddr_base
|
||||
json_get_values basic_rate_list basic_rate
|
||||
json_get_values scan_list scan_list
|
||||
json_select ..
|
||||
|
||||
@@ -213,7 +213,9 @@ const phy_proto = {
|
||||
if (!base_mask)
|
||||
return null;
|
||||
|
||||
if (base_mask == "00:00:00:00:00:00" &&
|
||||
if (data.macaddr_base)
|
||||
base_addr = data.macaddr_base;
|
||||
else if (base_mask == "00:00:00:00:00:00" &&
|
||||
(radio_idx > 0 || idx >= num_global)) {
|
||||
let addrs = split(phy_sysfs_file(phy, "addresses"), "\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user