lantiq: reorganize 02_network board.d files
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Tue, 17 Dec 2019 13:37:26 +0000 (14:37 +0100)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Tue, 14 Jan 2020 21:04:44 +0000 (22:04 +0100)
This reorganizes 02_network board.d files based on what's done for
ath79 and ramips: Instead of putting all settings into a single big
case, the interface/dsl/MAC address setup is put into separate
functions with a specific switch case for each of them. This makes
grouping of devices much easier and should be easier to read, too.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
target/linux/lantiq/ase/base-files/etc/board.d/02_network
target/linux/lantiq/falcon/base-files/etc/board.d/02_network
target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
target/linux/lantiq/xway/base-files/etc/board.d/02_network
target/linux/lantiq/xway_legacy/base-files/etc/board.d/02_network

index 2334d6c25b49ed2b242fbbf14e4eaf066b3a5109..0bda3e47638060b8b7ad68480cf428f9f6573b09 100755 (executable)
@@ -7,37 +7,50 @@
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh
 
-board_config_update
-
-annex="a"
-
-lan_mac=""
-wan_mac=""
+lantiq_setup_interfaces()
+{
+       local board="$1"
+
+       case "$board" in
+       *)
+               ucidef_set_interface_lan 'eth0'
+               ;;
+       esac
+}
+
+lantiq_setup_dsl()
+{
+       local board="$1"
+       local annex="b"
+
+       case "$board" in
+       esac
+
+       lantiq_setup_dsl_helper "$annex"
+}
+
+lantiq_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
+
+       case "$board" in
+       allnet,all0333cj)
+               lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               ;;
+       esac
+
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+}
 
+board_config_update
 board=$(board_name)
-
-case "$board" in
-allnet,all0333cj)
-       annex="b"
-       lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-netgear,dgn1000b)
-       annex="b"
-       ucidef_set_interface_lan 'eth0'
-       ;;
-*)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-esac
-
-lantiq_setup_dsl_helper "$annex"
-
-[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
-[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
-
+lantiq_setup_interfaces $board
+lantiq_setup_dsl $board
+lantiq_setup_macs $board
 board_config_flush
 
 exit 0
-
index 997f4c741f70eedb47da40551a8d14c092d147fc..7998efc2a0e37908d5e5d5405d87330d225ce155 100755 (executable)
@@ -7,21 +7,46 @@
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh
 
-board_config_update
+lantiq_setup_interfaces()
+{
+       local board="$1"
+
+       case "$board" in
+       *)
+               ucidef_set_interface_lan 'eth0'
+               ;;
+       esac
+}
+
+lantiq_setup_dsl()
+{
+       local board="$1"
+       local annex="a"
 
-annex="a"
+       case "$board" in
+       esac
 
-lan_mac=""
-wan_mac=""
+       lantiq_setup_dsl_helper "$annex"
+}
 
-ucidef_set_interface_lan 'eth0'
+lantiq_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
 
-lantiq_setup_dsl_helper "$annex"
+       case "$board" in
+       esac
 
-[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
-[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+}
 
+board_config_update
+board=$(board_name)
+lantiq_setup_interfaces $board
+lantiq_setup_dsl $board
+lantiq_setup_macs $board
 board_config_flush
 
 exit 0
-
index 05e235b096665b2370ce89d033b77d02dc965704..f39898263d9dbe74d5eeb7592d814441f3602e4e 100755 (executable)
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh
 
-board_config_update
+lantiq_setup_interfaces()
+{
+       local board="$1"
 
-annex="a"
+       case "$board" in
+       alphanetworks,asl56026)
+               ucidef_add_switch "switch0" \
+                       "2:lan" "3:lan" "6t@eth0"
+               ;;
+       arcadyan,arv7519rw22)
+               ucidef_add_switch "switch0" \
+                       "0:lan:5" "2:lan:3" "3:lan:4" "4:lan:1" "5:lan:2" "6t@eth0"
+               ;;
+       arcadyan,vg3503j)
+               ucidef_add_switch "switch0" \
+                       "2:lan:2" "4:lan:1" "6t@eth0"
+               ;;
+       arcadyan,vgv7510kw22-brn|\
+       arcadyan,vgv7510kw22-nor)
+               ucidef_add_switch "switch0" \
+                       "2:lan:2" "3:lan:1" "4:lan:4" "5:lan:3" "0:wan:5" "6t@eth0"
+               ;;
+       arcadyan,vgv7519-brn|\
+       arcadyan,vgv7519-nor|\
+       lantiq,easy80920-nand|\
+       lantiq,easy80920-nor)
+               ucidef_add_switch "switch0" \
+                       "0:lan:4" "1:lan:3" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
+               ;;
+       avm,fritz3370-rev2-hynix|\
+       avm,fritz3370-rev2-micron|\
+       avm,fritz7360sl|\
+       avm,fritz7362sl)
+               ucidef_add_switch "switch0" \
+                       "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0"
+               ;;
+       bt,homehub-v5a)
+               ucidef_add_switch "switch0" \
+                       "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
+               ;;
+       buffalo,wbmr-300hpd)
+               ucidef_add_switch "switch0" \
+                       "5:lan:2" "2:lan:3" "3:lan:4" "4:wan:1" "6t@eth0"
+               ;;
+       tplink,tdw8970|\
+       tplink,tdw8980)
+               ucidef_add_switch "switch0" \
+                       "0:lan:2" "2:lan:3" "4:lan:4" "5:lan:1" "6t@eth0"
+               ;;
+       tplink,vr200|\
+       tplink,vr200v)
+               ucidef_add_switch "switch0" \
+                       "0:lan" "2:lan" "4:lan" "5:lan" "6t@eth0"
+               ;;
+       zyxel,p-2812hnu-f1|\
+       zyxel,p-2812hnu-f3)
+               ucidef_add_switch "switch0" \
+                       "0:lan" "1:lan" "2:lan" "4:lan" "5:wan" "6t@eth0"
+               ;;
+       *)
+               ucidef_set_interface_lan 'eth0'
+               ;;
+       esac
+}
 
-lan_mac=""
-wan_mac=""
+lantiq_setup_dsl()
+{
+       local board="$1"
+       local annex="a"
 
-board=$(board_name)
+       case "$board" in
+       arcadyan,vgv7510kw22-brn|\
+       arcadyan,vgv7510kw22-nor|\
+       avm,fritz3370-rev2-hynix|\
+       avm,fritz3370-rev2-micron|\
+       avm,fritz7360sl|\
+       avm,fritz7362sl|\
+       avm,fritz7412)
+               annex="b"
+               ;;
+       esac
+
+       lantiq_setup_dsl_helper "$annex"
+}
 
-case "$board" in
-alphanetworks,asl56026)
-       lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
-       wan_mac=$(mtd_get_mac_ascii uboot_env wanmac)
-       ucidef_add_switch "switch0"\
-               "2:lan" "3:lan" "6t@eth0"
-       ;;
-arcadyan,arv7519rw22)
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0x16)" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:5" "2:lan:3" "3:lan:4" "4:lan:1" "5:lan:2" "6t@eth0"
-       ;;
-arcadyan,vg3503j)
-       lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "2:lan:2" "4:lan:1" "6t@eth0"
-       ;;
-arcadyan,vgv7510kw22-brn|\
-arcadyan,vgv7510kw22-nor)
-       annex="b"
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 0x16)" 2)
-       ucidef_add_switch "switch0" \
-               "2:lan:2" "3:lan:1" "4:lan:4" "5:lan:3" "0:wan:5" "6t@eth0"
-       ;;
-arcadyan,vgv7519-brn|\
-arcadyan,vgv7519-nor)
-       wan_mac=$(mtd_get_mac_binary board_config 0x16)
-       ucidef_add_switch "switch0" \
-               "0:lan:4" "1:lan:3" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
-       ;;
-avm,fritz3370-rev2-hynix|\
-avm,fritz3370-rev2-micron)
-       annex="b"
-       lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
-       wan_mac=$(macaddr_add "$lan_mac" 3)
-       ucidef_add_switch "switch0" \
-               "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0"
-       ;;
-avm,fritz7360sl)
-       annex="b"
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 0xa91)" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0"
-       ;;
-avm,fritz7362sl)
-       annex="b"
-       lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
-       wan_mac=$(fritz_tffs -n macdsl -i $(find_mtd_part "tffs (1)"))
-       ucidef_add_switch "switch0" \
-               "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0"
-       ;;
-avm,fritz7412)
-       tffsdev=$(find_mtd_chardev "nand-tffs")
-       annex="b"
-       lan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n maca -o)
-       wan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n macdsl -o)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-bt,homehub-v5a)
-       lan_mac=$(mtd_get_mac_binary_ubi caldata 0x110c)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
-       ;;
-buffalo,wbmr-300hpd)
-       lan_mac=$(mtd_get_mac_ascii ubootconfig ethaddr)
-       wan_mac="$lan_mac"
-       ucidef_add_switch "switch0" \
-               "5:lan:2" "2:lan:3" "3:lan:4" "4:wan:1" "6t@eth0"
-       ;;
-lantiq,easy80920-nand|\
-lantiq,easy80920-nor)
-       lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:4" "1:lan:3" "2:lan:2" "4:lan:1" "5:wan:5" "6t@eth0"
-       ;;
-netgear,dm200)
-       lan_mac=$(mtd_get_mac_binary ART 0x0)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-tplink,tdw8970|\
-tplink,tdw8980)
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0xf100)" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:2" "2:lan:3" "4:lan:4" "5:lan:1" "6t@eth0"
-       ;;
-tplink,vr200|\
-tplink,vr200v)
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary romfile 0xf100)" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan" "2:lan" "4:lan" "5:lan" "6t@eth0"
-       ;;
-zyxel,p-2812hnu-f1|\
-zyxel,p-2812hnu-f3)
-       lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan" "1:lan" "2:lan" "4:lan" "5:wan" "6t@eth0"
-       ;;
-*)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-esac
+lantiq_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
 
-lantiq_setup_dsl_helper "$annex"
+       case "$board" in
+       alphanetworks,asl56026)
+               lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
+               wan_mac=$(mtd_get_mac_ascii uboot_env wanmac)
+               ;;
+       arcadyan,arv7519rw22)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0x16)" 1)
+               ;;
+       arcadyan,vg3503j|\
+       lantiq,easy80920-nand|\
+       lantiq,easy80920-nor|\
+       zyxel,p-2812hnu-f1|\
+       zyxel,p-2812hnu-f3)
+               lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               ;;
+       arcadyan,vgv7510kw22-brn|\
+       arcadyan,vgv7510kw22-nor)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 0x16)" 2)
+               ;;
+       arcadyan,vgv7519-brn|\
+       arcadyan,vgv7519-nor)
+               wan_mac=$(mtd_get_mac_binary board_config 0x16)
+               ;;
+       avm,fritz3370-rev2-hynix|\
+       avm,fritz3370-rev2-micron)
+               lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
+               wan_mac=$(macaddr_add "$lan_mac" 3)
+               ;;
+       avm,fritz7360sl)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 0xa91)" 1)
+               ;;
+       avm,fritz7362sl)
+               lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
+               wan_mac=$(fritz_tffs -n macdsl -i $(find_mtd_part "tffs (1)"))
+               ;;
+       avm,fritz7412)
+               tffsdev=$(find_mtd_chardev "nand-tffs")
+               lan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n maca -o)
+               wan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n macdsl -o)
+               ;;
+       bt,homehub-v5a)
+               lan_mac=$(mtd_get_mac_binary_ubi caldata 0x110c)
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               ;;
+       buffalo,wbmr-300hpd)
+               lan_mac=$(mtd_get_mac_ascii ubootconfig ethaddr)
+               wan_mac="$lan_mac"
+               ;;
+       netgear,dm200)
+               lan_mac=$(mtd_get_mac_binary ART 0x0)
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               ;;
+       tplink,tdw8970|\
+       tplink,tdw8980)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0xf100)" 1)
+               ;;
+       tplink,vr200|\
+       tplink,vr200v)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary romfile 0xf100)" 1)
+               ;;
+       esac
 
-[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
-[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+}
 
+board_config_update
+board=$(board_name)
+lantiq_setup_interfaces $board
+lantiq_setup_dsl $board
+lantiq_setup_macs $board
 board_config_flush
 
 exit 0
-
index 71d36696db3fce51ff52dcd672b11ca2ad441ce8..89368d8bfb475245d604f81c3cad51e455a00449 100755 (executable)
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh
 
-board_config_update
+lantiq_setup_interfaces()
+{
+       local board="$1"
 
-annex="a"
+       case "$board" in
+       arcadyan,arv4510pw)
+               ucidef_add_switch "switch0" \
+                       "0:lan:4" "2:lan:2" "1:lan:3" "3:lan:1" "5t@eth0"
+               ;;
+       arcadyan,arv4519pw|\
+       arcadyan,arv7510pw22|\
+       arcadyan,arv7518pw|\
+       arcadyan,arv752dpw22|\
+       arcadyan,arv8539pw22|\
+       buffalo,wbmr-hp-g300h)
+               ucidef_add_switch "switch0" \
+                       "0t@eth0" "2:lan" "3:lan" "4:lan" "5:lan"
+               ;;
+       arcadyan,arv7506pw11|\
+       audiocodes,mp-252|\
+       siemens,gigaset-sx76x)
+               ucidef_add_switch "switch0" \
+                       "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5t@eth0"
+               ;;
+       arcadyan,arv7519pw|\
+       zte,h201l)
+               ucidef_add_switch "switch0" \
+                       "0:lan" "1:lan" "2:lan" "3:lan" "4t@eth0"
+               ;;
+       bt,homehub-v2b)
+               ucidef_add_switch "switch0" \
+                       "1:lan" "2:lan" "3:lan" "4:lan" "5t@eth0"
+               ;;
+       netgear,dgn3500|\
+       netgear,dgn3500b)
+               ucidef_add_switch "switch0" \
+                       "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5t@eth0"
+               ;;
+       zyxel,p-2601hn)
+               ucidef_add_switch "switch0" \
+                       "0:lan" "1:lan" "2:lan" "3:lan" "5t@eth0"
+               ;;
+       *)
+               ucidef_set_interface_lan 'eth0'
+               ;;
+       esac
+}
 
-lan_mac=""
-wan_mac=""
+lantiq_setup_dsl()
+{
+       local board="$1"
+       local annex="a"
 
-board=$(board_name)
+       case "$board" in
+       arcadyan,arv7506pw11|\
+       arcadyan,arv7525pw|\
+       arcadyan,arv752dpw|\
+       arcadyan,arv752dpw22|\
+       arcadyan,arv8539pw22|\
+       avm,fritz7312|\
+       avm,fritz7320|\
+       siemens,gigaset-sx76x|\
+       zte,h201l)
+               annex="b"
+               ;;
+       esac
+
+       lantiq_setup_dsl_helper "$annex"
+}
 
-case "$board" in
-arcadyan,arv4510pw)
-       lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:4" "2:lan:2" "1:lan:3" "3:lan:1" "5t@eth0"
-       ;;
-arcadyan,arv4519pw|\
-arcadyan,arv7510pw22|\
-arcadyan,arv7518pw)
-       ucidef_add_switch "switch0" \
-               "0t@eth0" "2:lan" "3:lan" "4:lan" "5:lan"
-       ;;
-arcadyan,arv7506pw11)
-       annex="b"
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 0x16)" 2)
-       ucidef_add_switch "switch0" \
-               "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5t@eth0"
-       ;;
-arcadyan,arv7519pw)
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 0x16)" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan" "1:lan" "2:lan" "3:lan" "4t@eth0"
-       ;;
-arcadyan,arv7525pw|\
-arcadyan,arv752dpw)
-       annex="b"
-       ucidef_set_interface_lan 'eth0'
-       ;;
-arcadyan,arv752dpw22|\
-arcadyan,arv8539pw22)
-       annex="b"
-       ucidef_add_switch "switch0" \
-               "0t@eth0" "2:lan" "3:lan" "4:lan" "5:lan"
-       ;;
-audiocodes,mp-252)
-       ucidef_add_switch "switch0" \
-               "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5t@eth0"
-       ;;
-avm,fritz7312|\
-avm,fritz7320)
-       annex="b"
-       wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 0xa91)" 1)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-bt,homehub-v2b)
-       lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "1:lan" "2:lan" "3:lan" "4:lan" "5t@eth0"
-       ;;
-bt,homehub-v3a)
-       lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-buffalo,wbmr-hp-g300h)
-       ucidef_add_switch "switch0" \
-               "0t@eth0" "2:lan" "3:lan" "4:lan" "5:lan"
-       ;;
-netgear,dgn3500|\
-netgear,dgn3500b)
-       lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
-       wan_mac=$(macaddr_add "$lan_mac" 1)
-       ucidef_add_switch "switch0" \
-               "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5t@eth0"
-       ;;
-siemens,gigaset-sx76x)
-       annex="b"
-       ucidef_add_switch "switch0" \
-               "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5t@eth0"
-       ;;
-zte,h201l)
-       annex="b"
-       ucidef_add_switch "switch0" \
-               "0:lan" "1:lan" "2:lan" "3:lan" "4t@eth0"
-       ;;
-zyxel,p-2601hn)
-       ucidef_add_switch "switch0" \
-               "0:lan" "1:lan" "2:lan" "3:lan" "5t@eth0"
-       ;;
-*)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-esac
+lantiq_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
 
-lantiq_setup_dsl_helper "$annex"
+       case "$board" in
+       arcadyan,arv4510pw|\
+       bt,homehub-v2b|\
+       bt,homehub-v3a|\
+       netgear,dgn3500|\
+       netgear,dgn3500b)
+               lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               ;;
+       arcadyan,arv7506pw11)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 0x16)" 2)
+               ;;
+       arcadyan,arv7519pw)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary board_config 0x16)" 1)
+               ;;
+       avm,fritz7312|\
+       avm,fritz7320)
+               wan_mac=$(macaddr_add "$(mtd_get_mac_binary urlader 0xa91)" 1)
+               ;;
+       esac
 
-[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
-[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+}
 
+board_config_update
+board=$(board_name)
+lantiq_setup_interfaces $board
+lantiq_setup_dsl $board
+lantiq_setup_macs $board
 board_config_flush
 
 exit 0
-
index 2d5dbade62d9a5833ebeafb90d1006be45d92be2..c29beb832d3afeb49252f0da6bfe40d020082c92 100755 (executable)
@@ -7,37 +7,55 @@
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh
 
-board_config_update
-
-annex="a"
-
-lan_mac=""
-wan_mac=""
+lantiq_setup_interfaces()
+{
+       local board="$1"
+
+       case "$board" in
+       arcadyan,arv4520pw)
+               ucidef_add_switch "switch0" \
+                       "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5t@eth0"
+               ;;
+       *)
+               ucidef_set_interface_lan 'eth0'
+               ;;
+       esac
+}
+
+lantiq_setup_dsl()
+{
+       local board="$1"
+       local annex="a"
+
+       case "$board" in
+       arcadyan,arv4520pw|\
+       arcadyan,arv4525pw|\
+       arcadyan,arv452cqw)
+               annex="b"
+               ;;
+       esac
+
+       lantiq_setup_dsl_helper "$annex"
+}
+
+lantiq_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
+
+       case "$board" in
+       esac
+
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
+}
 
+board_config_update
 board=$(board_name)
-
-case "$board" in
-arcadyan,arv4520pw)
-       annex="b"
-       ucidef_add_switch "switch0" \
-               "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5t@eth0"
-       ;;
-arcadyan,arv4525pw|\
-arcadyan,arv452cqw)
-       annex="b"
-       ucidef_set_interface_lan 'eth0'
-       ;;
-*)
-       ucidef_set_interface_lan 'eth0'
-       ;;
-esac
-
-lantiq_setup_dsl_helper "$annex"
-
-[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
-[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
-
+lantiq_setup_interfaces $board
+lantiq_setup_dsl $board
+lantiq_setup_macs $board
 board_config_flush
 
 exit 0
-