aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files/files/lib')
-rw-r--r--package/base-files/files/lib/functions/system.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index f3c901ff79..80e417182a 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -174,6 +174,18 @@ macaddr_setbit_la() {
macaddr_setbit $1 7
}
+macaddr_unsetbit_mc() {
+ local mac=$1
+
+ printf "%02x:%s" $((0x${mac%%:*} & ~0x01)) ${mac#*:}
+}
+
+macaddr_random() {
+ local randsrc=$(get_mac_binary /dev/urandom 0)
+
+ echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${randsrc}")")"
+}
+
macaddr_2bin() {
local mac=$1