f9dd0f7d07ec7fd2786b64cf1f49a3af1ec18308
[openwrt/openwrt.git] / target / linux / ipq40xx / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (c) 2015 The Linux Foundation. All rights reserved.
4 # Copyright (c) 2011-2015 OpenWrt.org
5 #
6
7 . /lib/functions/uci-defaults.sh
8 . /lib/functions/system.sh
9
10 ipq40xx_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 8dev,jalapeno)
16 ucidef_set_interfaces_lan_wan "eth0" "eth1"
17 ;;
18 asus,rt-ac58u|\
19 avm,fritzbox-4040|\
20 linksys,ea6350v3)
21 ucidef_set_interfaces_lan_wan "eth0" "eth1"
22 ucidef_add_switch "switch0" \
23 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
24 ;;
25 compex,wpj428)
26 ucidef_set_interface_lan "eth0 eth1"
27 ;;
28 engenius,eap1300|\
29 meraki,mr33|\
30 netgear,ex6100v2|\
31 netgear,ex6150v2|\
32 zyxel,wre6606)
33 ucidef_set_interface_lan "eth0"
34 ;;
35 glinet,gl-b1300)
36 ucidef_set_interfaces_lan_wan "eth0" "eth1"
37 ucidef_add_switch "switch0" \
38 "0u@eth0" "3:lan" "4:lan"
39 ;;
40 openmesh,a42|\
41 openmesh,a62)
42 ucidef_set_interfaces_lan_wan "eth1" "eth0"
43 ;;
44 zyxel,nbg6617)
45 ucidef_set_interfaces_lan_wan "eth0" "eth1"
46 ucidef_add_switch "switch0" \
47 "0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
48 ;;
49 *)
50 echo "Unsupported hardware. Network interfaces not initialized"
51 ;;
52 esac
53 }
54
55 ipq40xx_setup_macs()
56 {
57 local board="$1"
58
59 case "$board" in
60 asus,rt-ac58u)
61 CI_UBIPART=UBI_DEV
62 wan_mac=$(mtd_get_mac_binary_ubi Factory 20486)
63 lan_mac=$(mtd_get_mac_binary_ubi Factory 4102)
64 ;;
65 linksys,ea6350v3)
66 wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
67 lan_mac=$(macaddr_add $(wan_mac) +1)
68 ;;
69 esac
70
71 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
72 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
73 }
74
75 board_config_update
76 board=$(board_name)
77 ipq40xx_setup_interfaces $board
78 ipq40xx_setup_macs $board
79 board_config_flush
80
81 exit 0