diff options
author | Manas Sambhus <manas.sambhus+github@gmail.com> | 2022-08-09 13:14:40 +0530 |
---|---|---|
committer | Paul Spooren <mail@aparcar.org> | 2022-08-11 12:56:15 +0200 |
commit | 1ea563ae13637f55ec3a1a1056ba4f3595752a37 (patch) | |
tree | 425b697e24d2c506145268bad779069ee0a8bcae /package/kernel/mac80211/files/lib | |
parent | 37c0d15a8e9eb30920091bff1bf466640bc64dad (diff) | |
download | upstream-1ea563ae13637f55ec3a1a1056ba4f3595752a37.tar.gz upstream-1ea563ae13637f55ec3a1a1056ba4f3595752a37.tar.bz2 upstream-1ea563ae13637f55ec3a1a1056ba4f3595752a37.zip |
base-files: wifi: add random MAC support for wifi-iface
Add support for randomly generating a MAC address for a wifi-iface
instance by setting `macaddr` to `random`
When set to `random`, a new locally administered unicast MAC address
is generated and assigned to the iface everytime it is (re-)configured
Signed-off-by: Manas Sambhus <manas.sambhus+github@gmail.com>
Diffstat (limited to 'package/kernel/mac80211/files/lib')
-rw-r--r-- | package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh index 5d6ca7c0e3..62afd9e6a0 100644 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -1,6 +1,7 @@ #!/bin/sh . /lib/netifd/netifd-wireless.sh . /lib/netifd/hostapd.sh +. /lib/functions/system.sh init_wireless_driver "$@" @@ -667,10 +668,12 @@ mac80211_prepare_vif() { json_select .. - [ -n "$macaddr" ] || { + if [ -z "$macaddr" ]; then macaddr="$(mac80211_generate_mac $phy)" macidx="$(($macidx + 1))" - } + elif [ "$macaddr" = 'random' ]; then + macaddr="$(macaddr_random)" + fi json_add_object data json_add_string ifname "$ifname" |