7b73f9394434b3ce7de41debef9d20da91c4e012
[openwrt/openwrt.git] / target / linux / ramips / rt3883 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/system.sh
6
7 ramips_setup_interfaces()
8 {
9 local board="$1"
10
11 case $board in
12 asus,rt-n56u)
13 ucidef_add_switch "switch0" \
14 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "8@eth0"
15 ;;
16 belkin,f9k1109v1)
17 ucidef_add_switch "switch0" \
18 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
19 ;;
20 dlink,dir-645)
21 ucidef_add_switch "switch0" \
22 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
23 ;;
24 edimax,br-6475nd)
25 ucidef_add_switch "switch0" \
26 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
27 ;;
28 loewe,wmdr-143n|\
29 omnima,hpm)
30 ucidef_set_interface_lan "eth0"
31 ;;
32 samsung,cy-swr1100)
33 ucidef_add_switch "switch0" \
34 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
35 ;;
36 sitecom,wlr-6000|\
37 trendnet,tew-691gr|\
38 trendnet,tew-692gr)
39 ucidef_add_switch "switch0" \
40 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
41 ;;
42 esac
43 }
44
45 ramips_setup_macs()
46 {
47 local board="$1"
48 local lan_mac=""
49 local wan_mac=""
50 local label_mac=""
51
52 case $board in
53 asus,rt-n56u)
54 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
55 wan_mac=$(mtd_get_mac_binary factory 0x8004)
56 ;;
57 belkin,f9k1109v1)
58 wan_mac=$(mtd_get_mac_ascii uboot-env HW_WAN_MAC)
59 lan_mac=$(mtd_get_mac_ascii uboot-env HW_LAN_MAC)
60 label_mac=$wan_mac
61 ;;
62 dlink,dir-645)
63 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
64 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
65 ;;
66 edimax,br-6475nd)
67 wan_mac=$(mtd_get_mac_binary devdata 0x7)
68 ;;
69 samsung,cy-swr1100)
70 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
71 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
72 label_mac=$wan_mac
73 ;;
74 sitecom,wlr-6000)
75 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x8004)" 2)
76 ;;
77 trendnet,tew-691gr)
78 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 3)
79 ;;
80 trendnet,tew-692gr)
81 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
82 ;;
83 esac
84
85 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
86 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
87 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
88 }
89
90 board_config_update
91 board=$(board_name)
92 ramips_setup_interfaces $board
93 ramips_setup_macs $board
94 board_config_flush
95
96 exit 0