| 1 | #!/bin/sh |
| 2 | |
| 3 | . /etc/functions.sh |
| 4 | . /lib/ramips.sh |
| 5 | . /lib/functions/uci-defaults.sh |
| 6 | |
| 7 | if [ ! -x /usr/sbin/maccalc ]; then |
| 8 | echo "$0: maccalc not found!" |
| 9 | return |
| 10 | fi |
| 11 | |
| 12 | ramips_setup_interfaces() |
| 13 | { |
| 14 | local board="$1" |
| 15 | |
| 16 | ucidef_set_interface_loopback |
| 17 | |
| 18 | case $board in |
| 19 | all0256n) |
| 20 | ucidef_set_interface_lan "eth0.1" |
| 21 | ;; |
| 22 | |
| 23 | argus-atp52b | \ |
| 24 | b2c | \ |
| 25 | nw718 | \ |
| 26 | sl-r7205 | \ |
| 27 | w502u | \ |
| 28 | wr6202) |
| 29 | ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" |
| 30 | ;; |
| 31 | |
| 32 | f5d8235-v1 | \ |
| 33 | f5d8235-v2 | \ |
| 34 | v11st-fe) |
| 35 | ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" |
| 36 | ucidef_add_switch "switch0" "1" "1" |
| 37 | ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t" |
| 38 | ucidef_add_switch_vlan "switch0" "2" "0 5t" |
| 39 | ;; |
| 40 | |
| 41 | rt-n15 | \ |
| 42 | wl-351) |
| 43 | ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" |
| 44 | ucidef_add_switch "switch0" "1" "1" |
| 45 | ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t" |
| 46 | ucidef_add_switch_vlan "switch0" "2" "4 5t" |
| 47 | ;; |
| 48 | |
| 49 | rt-n56u) |
| 50 | ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" |
| 51 | ucidef_add_switch "switch0" "1" "1" |
| 52 | ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t" |
| 53 | ucidef_add_switch_vlan "switch0" "2" "4 8t" |
| 54 | ;; |
| 55 | |
| 56 | wcr-150gn) |
| 57 | ucidef_set_interface_lan_wan "eth0.2" "eth0.1" |
| 58 | ;; |
| 59 | |
| 60 | wli-tx4-ag300n) |
| 61 | ucidef_set_interface_lan "eth0" |
| 62 | ;; |
| 63 | |
| 64 | *) |
| 65 | RT3X5X=`cat /proc/cpuinfo | grep RT3.5` |
| 66 | if [ -n "${RT3X5X}" ]; then |
| 67 | ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" |
| 68 | else |
| 69 | ucidef_set_interfaces_lan_wan "eth0" "eth1" |
| 70 | fi |
| 71 | ;; |
| 72 | esac |
| 73 | } |
| 74 | |
| 75 | ramips_setup_macs() |
| 76 | { |
| 77 | local board="$1" |
| 78 | local lan_mac="" |
| 79 | local wan_mac="" |
| 80 | |
| 81 | case $board in |
| 82 | all0256n) |
| 83 | lan_mac=$(ramips_get_mac_binary factory 40) |
| 84 | ;; |
| 85 | |
| 86 | argus-atp52b | \ |
| 87 | b2c | \ |
| 88 | f5d8235-v1 | \ |
| 89 | nw718 | \ |
| 90 | rt-n15 | \ |
| 91 | sl-r7205 | \ |
| 92 | wl-351) |
| 93 | lan_mac=$(ramips_get_mac_binary factory 4) |
| 94 | wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) |
| 95 | ;; |
| 96 | |
| 97 | dir-300-b1 |\ |
| 98 | dir-300-b2 |\ |
| 99 | dir-600-b1) |
| 100 | lan_mac=$(ramips_get_mac_binary devdata 16388) |
| 101 | wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) |
| 102 | ;; |
| 103 | |
| 104 | esr-9753 | \ |
| 105 | nbg-419n | \ |
| 106 | wcr-150gn) |
| 107 | lan_mac=$(ramips_get_mac_binary factory 4) |
| 108 | wan_mac=$(ramips_get_mac_binary factory 40) |
| 109 | ;; |
| 110 | |
| 111 | f5d8235-v2) |
| 112 | lan_mac=$(ramips_get_mac_binary "u-boot" 262148) |
| 113 | wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) |
| 114 | ;; |
| 115 | |
| 116 | rt-n56u) |
| 117 | lan_mac=$(ramips_get_mac_binary factory 4) |
| 118 | wan_mac=$(ramips_get_mac_binary factory 32772) |
| 119 | ;; |
| 120 | |
| 121 | w502u) |
| 122 | lan_mac=$(ramips_get_mac_binary factory 40) |
| 123 | wan_mac=$(ramips_get_mac_binary factory 46) |
| 124 | ;; |
| 125 | |
| 126 | wl341v3) |
| 127 | lan_mac=$(ramips_get_mac_binary board-nvram 65440) |
| 128 | wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) |
| 129 | ;; |
| 130 | |
| 131 | wli-tx4-ag300n) |
| 132 | lan_mac=$(ramips_get_mac_binary factory 4) |
| 133 | ;; |
| 134 | |
| 135 | esac |
| 136 | |
| 137 | [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac |
| 138 | [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac |
| 139 | } |
| 140 | |
| 141 | [ -e /etc/config/network ] && exit 0 |
| 142 | |
| 143 | touch /etc/config/network |
| 144 | |
| 145 | board=$(ramips_board_name) |
| 146 | |
| 147 | ramips_setup_interfaces $board |
| 148 | ramips_setup_macs $board |
| 149 | |
| 150 | uci commit network |
| 151 | |
| 152 | exit 0 |
| 153 | |