6568017b52526ed1a0afbbf1fd6ce8059949449d
[openwrt/openwrt.git] / target / linux / realtek / base-files / etc / board.d / 02_network
1
2 . /lib/functions.sh
3 . /lib/functions/uci-defaults.sh
4 . /lib/functions/system.sh
5
6 ucidef_set_poe() {
7 json_select_object poe
8 json_add_string "budget" "$1"
9 json_select_array ports
10 for port in $2; do
11 json_add_string "" "$port"
12 done
13 json_select ..
14 json_select ..
15 }
16
17 board=$(board_name)
18 board_config_update
19
20 lan_list=""
21 for lan in /sys/class/net/lan*; do
22 lan_list="$lan_list $(basename $lan)"
23 done
24 ucidef_set_bridge_device switch
25 ucidef_set_interface_wan "$lan_list"
26 ucidef_set_interface "lan" device "lan1:t" protocol "static" vlan 100
27
28 lan_mac=""
29 wan_mac=""
30 label_mac=""
31 case $board in
32 *)
33 wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
34 label_mac=$lan_mac
35 ;;
36 esac
37
38 lan_mac=$(macaddr_setbit_la $wan_mac)
39
40 ucidef_set_interface_macaddr "lan" $lan_mac
41 ucidef_set_interface_macaddr "wan" $wan_mac
42 ucidef_set_bridge_mac "$wan_mac"
43 ucidef_set_network_device_mac eth0 $wan_mac
44 for lan in $lan_list; do
45 ucidef_set_network_device_mac $lan $lan_mac
46 lan_mac=$(macaddr_add $lan_mac 1)
47 done
48 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
49
50 case $board in
51 netgear,gs110tpp-v1)
52 ucidef_set_poe 130 "$lan_list"
53 ;;
54 netgear,gs310tp-v1)
55 ucidef_set_poe 55 "$lan_list"
56 ;;
57 zyxel,gs1900-10hp)
58 ucidef_set_poe 77 "$lan_list"
59 ;;
60 zyxel,gs1900-8hp-v1|\
61 zyxel,gs1900-8hp-v2)
62 ucidef_set_poe 70 "$lan_list"
63 ;;
64 esac
65
66 board_config_flush
67
68 exit 0