mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-23 21:08:23 +00:00
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>
(cherry picked from commit 00860e485b
)
This commit is contained in:
parent
e20047e5d4
commit
ea80aa938f
@ -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() (
|
||||
@ -945,6 +947,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)"
|
||||
|
||||
@ -991,7 +994,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() {
|
||||
@ -1118,7 +1121,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");
|
||||
|
||||
|
@ -279,6 +279,7 @@ function iface_macaddr_init(phydev, config, macaddr_list)
|
||||
{
|
||||
let macaddr_data = {
|
||||
num_global: config.num_global_macaddr ?? 1,
|
||||
macaddr_base: config.macaddr_base,
|
||||
mbssid: config.mbssid ?? 0,
|
||||
};
|
||||
|
||||
@ -749,6 +750,8 @@ function iface_load_config(phy, radio, filename)
|
||||
|
||||
if (val[0] == "#num_global_macaddr")
|
||||
config[substr(val[0], 1)] = int(val[1]);
|
||||
else if (val[0] == "#macaddr_base")
|
||||
config[substr(val[0], 1)] = val[1];
|
||||
else if (val[0] == "mbssid")
|
||||
config[val[0]] = int(val[1]);
|
||||
|
||||
|
@ -68,7 +68,7 @@ function prepare_config(config, radio)
|
||||
return { config };
|
||||
}
|
||||
|
||||
function set_config(config_name, phy_name, radio, num_global_macaddr, config_list)
|
||||
function set_config(config_name, phy_name, radio, num_global_macaddr, macaddr_base, config_list)
|
||||
{
|
||||
let phy = wpas.data.config[config_name];
|
||||
|
||||
@ -83,6 +83,7 @@ function set_config(config_name, phy_name, radio, num_global_macaddr, config_lis
|
||||
|
||||
phy.radio = radio;
|
||||
phy.num_global_macaddr = num_global_macaddr;
|
||||
phy.macaddr_base = macaddr_base;
|
||||
|
||||
let values = [];
|
||||
for (let config in config_list)
|
||||
@ -106,7 +107,10 @@ function start_pending(phy_name)
|
||||
}
|
||||
|
||||
let macaddr_list = wpas.data.macaddr_list[phy_name];
|
||||
phydev.macaddr_init(macaddr_list, { num_global: phy.num_global_macaddr });
|
||||
phydev.macaddr_init(macaddr_list, {
|
||||
num_global: phy.num_global_macaddr,
|
||||
macaddr_base: phy.macaddr_base,
|
||||
});
|
||||
|
||||
for (let ifname in phy.data)
|
||||
iface_start(phydev, phy.data[ifname]);
|
||||
@ -210,6 +214,7 @@ let main_obj = {
|
||||
phy: "",
|
||||
radio: 0,
|
||||
num_global_macaddr: 0,
|
||||
macaddr_base: "",
|
||||
config: [],
|
||||
defer: true,
|
||||
},
|
||||
@ -221,7 +226,7 @@ let main_obj = {
|
||||
wpas.printf(`Set new config for phy ${phy}`);
|
||||
try {
|
||||
if (req.args.config)
|
||||
set_config(phy, req.args.phy, req.args.radio, req.args.num_global_macaddr, req.args.config);
|
||||
set_config(phy, req.args.phy, req.args.radio, req.args.num_global_macaddr, req.args.macaddr_base, req.args.config);
|
||||
|
||||
if (!req.args.defer)
|
||||
start_pending(phy);
|
||||
|
Loading…
Reference in New Issue
Block a user