summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-08-15 15:13:27 +0200
committerPetr Štetiar <ynezz@true.cz>2019-09-19 23:43:27 +0200
commit469e347f19ce9eefdc16f421b8e1f18ed60c310c (patch)
treec470df73ff45a454e9c3f37ecc53fce8c55ffb77 /package
parent0340718863040919ecaba74b2173ed52ebc194ce (diff)
downloadopenwrt-469e347f19ce9eefdc16f421b8e1f18ed60c310c.tar.gz
openwrt-469e347f19ce9eefdc16f421b8e1f18ed60c310c.tar.bz2
openwrt-469e347f19ce9eefdc16f421b8e1f18ed60c310c.zip
base-files: provide option to specify label MAC address in board.d
For many devices, MAC addresses cannot be retrieved via the device tree alias. To still provide the label MAC address for those, this implements a second mechanism that will put the address into uci config. Note that this stores the actual MAC address, whereas in DTS we reference the bearing device. This is based on the work of Rosy Song <rosysong@rosinson.com> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'package')
-rwxr-xr-xpackage/base-files/files/bin/config_generate5
-rw-r--r--package/base-files/files/lib/functions/system.sh1
-rwxr-xr-xpackage/base-files/files/lib/functions/uci-defaults.sh8
3 files changed, 14 insertions, 0 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 3ca035ca8b..0b26afe57f 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -260,6 +260,11 @@ generate_static_system() {
uci -q set "system.@system[-1].hostname=$hostname"
fi
+ local label_macaddr
+ if json_get_var label_macaddr label_macaddr; then
+ uci -q set "system.@system[-1].label_macaddr=$label_macaddr"
+ fi
+
if json_is_a ntpserver array; then
local keys key
json_get_keys keys ntpserver
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 3051ac8476..cb0508fe9c 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -19,6 +19,7 @@ get_mac_label() {
[ -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)
+ [ -n "$macaddr" ] || macaddr=$(uci -q get system.@system[0].label_macaddr)
echo $macaddr
}
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 2fb7555969..c2c6dc3fdc 100755
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -307,6 +307,14 @@ ucidef_set_interface_macaddr() {
ucidef_set_interface "$network" macaddr "$macaddr"
}
+ucidef_set_label_macaddr() {
+ local macaddr="$1"
+
+ json_select_object system
+ json_add_string label_macaddr "$macaddr"
+ json_select ..
+}
+
ucidef_add_atm_bridge() {
local vpi="$1"
local vci="$2"