forked from openwrt/openwrt
/
02_network
80 lines (71 loc) · 1.95 KB
/
02_network
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ucidef_set_poe() {
json_select_object poe
json_add_string "budget" "$1"
json_select_array ports
for port in $2; do
json_add_string "" "$port"
done
json_select ..
json_select ..
}
board=$(board_name)
board_config_update
lan_list=$(ls -1 -v -d /sys/class/net/lan* | xargs -n1 basename | xargs)
ucidef_set_bridge_device switch
ucidef_set_interface_lan "$lan_list"
lan_mac=""
lan_mac_start=""
lan_mac_end=""
label_mac=""
case $board in
hpe,1920-8g|\
hpe,1920-16g|\
hpe,1920-24g)
label_mac=$(mtd_get_mac_binary factory 0x68)
lan_mac=$label_mac
mac_count1=$(hexdump -v -n 4 -s 0x110 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null)
mac_count2=$(hexdump -v -n 4 -s 0x114 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null)
lan_mac_start=$(macaddr_add $lan_mac 2)
lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1)))
;;
*)
lan_mac=$(mtd_get_mac_ascii u-boot-env2 mac_start)
lan_mac_end=$(mtd_get_mac_ascii u-boot-env2 mac_end)
label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
[ -z "$lan_mac" ] && lan_mac=$label_mac
;;
esac
ucidef_set_interface_macaddr "lan" $lan_mac
ucidef_set_bridge_mac "$lan_mac"
ucidef_set_network_device_mac eth0 $lan_mac
[ -z "$lan_mac_start" ] && lan_mac_start=$lan_mac
for lan in $lan_list; do
ucidef_set_network_device_mac $lan $lan_mac_start
[ -z "$lan_mac_end" ] || [ "$lan_mac_start" == "$lan_mac_end" ] && lan_mac_start=$(macaddr_setbit_la $lan_mac_start)
lan_mac_start=$(macaddr_add $lan_mac_start 1)
done
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
case $board in
netgear,gs110tpp-v1)
ucidef_set_poe 130 "$lan_list"
;;
netgear,gs310tp-v1)
ucidef_set_poe 55 "$lan_list"
;;
zyxel,gs1900-10hp)
ucidef_set_poe 77 "$lan_list"
;;
zyxel,gs1900-8hp-v1|\
zyxel,gs1900-8hp-v2)
ucidef_set_poe 70 "$lan_list"
;;
zyxel,gs1900-24hp-v1|\
zyxel,gs1900-24hp-v2)
ucidef_set_poe 170 "$lan_list"
;;
esac
board_config_flush
exit 0