aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-08-15 15:13:21 +0200
committerPetr Štetiar <ynezz@true.cz>2019-09-19 23:43:27 +0200
commit0340718863040919ecaba74b2173ed52ebc194ce (patch)
tree3b756b31f43b2be24419b56627757f1c1afcd79a /package/base-files
parent71cf4a272c9cf7d6e604e6327d0c94aeceac26e7 (diff)
downloadupstream-0340718863040919ecaba74b2173ed52ebc194ce.tar.gz
upstream-0340718863040919ecaba74b2173ed52ebc194ce.tar.bz2
upstream-0340718863040919ecaba74b2173ed52ebc194ce.zip
base-files: add function to retrieve label MAC address
To refer to the MAC address on a device's label, one can specify the alias label-mac-device in the DTS which should point to the bearer of the corresponding MAC address. With the function get_mac_label, the user can retrieve then retrieve this address and use it as a value that uniquely identifies his device. This is severely helpful for several downstream functionalities, e.g. define MAC addresses of custom netifs or change the SSID to be easily recognizable. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/files/lib/functions/system.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 5084c0052b..3051ac8476 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -12,6 +12,16 @@ get_mac_binary() {
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
}
+get_mac_label() {
+ local basepath="/proc/device-tree"
+ local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)"
+ local macaddr
+
+ [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null)
+ [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null)
+ echo $macaddr
+}
+
find_mtd_chardev() {
local INDEX=$(find_mtd_index "$1")
local PREFIX=/dev/mtd