02_network 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2011-2015 OpenWrt.org
  4. #
  5. . /lib/functions/system.sh
  6. . /lib/functions/uci-defaults.sh
  7. . /lib/ar71xx.sh
  8. ar71xx_setup_interfaces()
  9. {
  10. local board="$1"
  11. case "$board" in
  12. airgatewaypro)
  13. ucidef_add_switch "switch0" \
  14. "0@eth0" "4:lan" "5:wan"
  15. ;;
  16. airrouter|\
  17. ap121|\
  18. ap121-mini|\
  19. ap96|\
  20. dir-600-a1|\
  21. dir-615-c1|\
  22. dir-615-e1|\
  23. dir-615-e4|\
  24. hiwifi-hc6361|\
  25. ja76pf|\
  26. mc-mac1200r|\
  27. minibox-v1|\
  28. mynet-n600|\
  29. oolite|\
  30. qihoo-c301|\
  31. rb-750|\
  32. rb-751|\
  33. som9331|\
  34. tew-632brp|\
  35. tew-712br|\
  36. tew-732br|\
  37. tl-mr3220|\
  38. tl-mr3220-v2|\
  39. tl-mr3420|\
  40. tl-wdr3320-v2|\
  41. tl-wdr3500|\
  42. tl-wr741nd-v4|\
  43. tl-wr841n-v11|\
  44. tl-wr841n-v9|\
  45. tl-wr842n-v3|\
  46. whr-g301n|\
  47. whr-hp-g300n|\
  48. whr-hp-gn|\
  49. wzr-hp-ag300h|\
  50. zbt-we1526)
  51. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  52. ucidef_add_switch "switch0" \
  53. "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
  54. ;;
  55. alfa-ap120c|\
  56. all0305|\
  57. antminer-s1|\
  58. antminer-s3|\
  59. antrouter-r1|\
  60. ap121f|\
  61. aw-nr580|\
  62. bullet-m|\
  63. c-55|\
  64. cap4200ag|\
  65. cf-e380ac-v1|\
  66. cf-e380ac-v2|\
  67. eap120|\
  68. eap300v2|\
  69. eap7660d|\
  70. el-mini|\
  71. loco-m-xw|\
  72. mr12|\
  73. mr16|\
  74. mr1750|\
  75. mr1750v2|\
  76. mr18|\
  77. mr600|\
  78. mr600v2|\
  79. mr900|\
  80. mr900v2|\
  81. mynet-rext|\
  82. rb-411|\
  83. rb-411u|\
  84. rb-911g-2hpnd|\
  85. rb-911g-5hpacd|\
  86. rb-911g-5hpnd|\
  87. rb-912uag-2hpnd|\
  88. rb-912uag-5hpnd|\
  89. rb-sxt2n|\
  90. rb-sxt5n|\
  91. re450|\
  92. rocket-m-xw|\
  93. tl-mr10u|\
  94. tl-mr11u|\
  95. tl-mr12u|\
  96. tl-mr13u|\
  97. tl-mr3020|\
  98. tl-mr3040|\
  99. tl-mr3040-v2|\
  100. tl-wa701nd-v2|\
  101. tl-wa7210n-v2|\
  102. tl-wa750re|\
  103. tl-wa801nd-v2|\
  104. tl-wa830re-v2|\
  105. tl-wa850re|\
  106. tl-wa901nd|\
  107. tl-wa901nd-v2|\
  108. tl-wa901nd-v3|\
  109. tl-wa901nd-v4|\
  110. tl-wr703n|\
  111. tl-wr802n-v1|\
  112. tube2h|\
  113. unifiac-lite|\
  114. wndap360|\
  115. wp543)
  116. ucidef_set_interface_lan "eth0"
  117. ;;
  118. a40|\
  119. a60|\
  120. alfa-ap96|\
  121. alfa-nx|\
  122. dr344|\
  123. gl-ar150|\
  124. gl-ar300m|\
  125. gl-domino|\
  126. gl-inet|\
  127. gl-mifi|\
  128. jwap003|\
  129. om2pv4|\
  130. om2p-hsv4|\
  131. pb42|\
  132. pb44|\
  133. rb-951ui-2hnd|\
  134. routerstation|\
  135. tl-wr710n|\
  136. tl-wr720n-v3|\
  137. tl-wr810n|\
  138. wpe72|\
  139. wrtnode2q)
  140. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  141. ;;
  142. rb-750-r2|\
  143. rb-750up-r2)
  144. ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
  145. ucidef_add_switch "switch0" \
  146. "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
  147. ;;
  148. all0258n|\
  149. all0315n|\
  150. dlan-hotspot|\
  151. dlan-pro-500-wp|\
  152. ja76pf2|\
  153. rocket-m-ti|\
  154. ubnt-unifi-outdoor)
  155. ucidef_set_interface_lan "eth0 eth1"
  156. ;;
  157. wzr-hp-g300nh2)
  158. ucidef_add_switch "switch0" \
  159. "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
  160. ;;
  161. ap132|\
  162. ap136|\
  163. ap152|\
  164. rb-750gl|\
  165. rb-751g|\
  166. rb-951g-2hnd|\
  167. wlr8100|\
  168. wzr-hp-g450h)
  169. ucidef_add_switch "switch0" \
  170. "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
  171. ;;
  172. ap135-020|\
  173. ap136-020|\
  174. bhr-4grv2|\
  175. tew-823dru|\
  176. tl-wr1043nd-v2|\
  177. wzr-450hp2)
  178. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  179. ucidef_add_switch "switch0" \
  180. "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
  181. ;;
  182. ap136-010|\
  183. ap147-010|\
  184. nbg6616|\
  185. nbg6716)
  186. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  187. ucidef_add_switch "switch0" \
  188. "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
  189. ;;
  190. ap143|\
  191. rb-433|\
  192. rb-433u)
  193. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  194. ucidef_add_switch "switch0" \
  195. "1:lan" "2:lan" "5@eth1"
  196. ;;
  197. archer-c5|\
  198. archer-c7|\
  199. tl-wdr4900-v2)
  200. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  201. ucidef_add_switch "switch0" \
  202. "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
  203. ;;
  204. arduino-yun|\
  205. dir-505-a1|\
  206. tl-wa801nd-v3)
  207. ucidef_set_interface_lan "eth1"
  208. ;;
  209. bsb)
  210. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  211. ucidef_add_switch "switch0" \
  212. "0@eth1" "1:lan" "3:lan"
  213. ;;
  214. c-60)
  215. ucidef_add_switch "switch0" \
  216. "0@eth0" "3:wan" "4:lan"
  217. ;;
  218. cap324)
  219. ucidef_set_interface_lan "eth0" "dhcp"
  220. ;;
  221. cpe210|\
  222. cpe510|\
  223. wbs210|\
  224. wbs510)
  225. ucidef_add_switch "switch0" \
  226. "0@eth0" "5:lan" "4:wan"
  227. ;;
  228. cr3000)
  229. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  230. ucidef_add_switch "switch0" \
  231. "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
  232. ;;
  233. cr5000|\
  234. dgl-5500-a1|\
  235. dhp-1565-a1|\
  236. dir-825-c1|\
  237. dir-835-a1|\
  238. esr900|\
  239. mynet-n750|\
  240. sr3200|\
  241. wndr3700v4|\
  242. wndr4300)
  243. ucidef_add_switch "switch0" \
  244. "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
  245. ;;
  246. dap-2695-a1)
  247. ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
  248. ;;
  249. rb-941-2nd)
  250. ucidef_add_switch "switch0" \
  251. "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
  252. ;;
  253. db120|\
  254. rb-2011l|\
  255. rb-2011uas|\
  256. rb-2011uas-2hnd|\
  257. rb-2011uias|\
  258. rb-2011uias-2hnd)
  259. case "$board" in
  260. rb-2011uas*|\
  261. rb-2011uias|\
  262. rb-2011uias-2hnd)
  263. ucidef_add_switch "switch0" \
  264. "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
  265. ;;
  266. *)
  267. ucidef_add_switch "switch0" \
  268. "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
  269. ;;
  270. esac
  271. ucidef_add_switch "switch1" \
  272. "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
  273. ;;
  274. dir-615-i1|\
  275. omy-g1|\
  276. r6100|\
  277. smart-300|\
  278. tl-mr3420-v2|\
  279. tl-wdr6500-v2|\
  280. tl-wr841n-v8|\
  281. tl-wr940n-v4|\
  282. tl-wr941nd-v5|\
  283. tl-wr941nd-v6|\
  284. wnr1000-v2|\
  285. wnr2000-v4|\
  286. wnr2200|\
  287. wnr612-v2|\
  288. wpn824n)
  289. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  290. ucidef_add_switch "switch0" \
  291. "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth1"
  292. ;;
  293. dir-825-b1|\
  294. nbg460n_550n_550nh|\
  295. tew-673gru|\
  296. wzr-hp-g300nh)
  297. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  298. ucidef_add_switch "switch0" \
  299. "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
  300. ;;
  301. dlan-pro-1200-ac)
  302. ucidef_set_interface_lan "eth0"
  303. ucidef_add_switch "switch0" \
  304. "0@eth0" "2:lan" "3:lan" "4:lan"
  305. ucidef_add_switch_attr "switch0" "enable" "false"
  306. ;;
  307. el-m150)
  308. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  309. ucidef_add_switch "switch0" \
  310. "0:lan" "1:lan" "3@eth1"
  311. ;;
  312. dir-869-a1|\
  313. epg5000|\
  314. esr1750|\
  315. tl-wr1043nd-v4)
  316. ucidef_add_switch "switch0" \
  317. "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
  318. ;;
  319. ew-dorin)
  320. ucidef_add_switch "switch0" \
  321. "0@eth0" "1:lan" "2:lan" "3:wan"
  322. ;;
  323. ew-dorin-router)
  324. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  325. ucidef_add_switch "switch0" \
  326. "0@eth0" "2:lan" "3:lan"
  327. ;;
  328. dw33d|\
  329. f9k1115v2)
  330. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  331. ucidef_add_switch "switch0" \
  332. "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
  333. ;;
  334. gl-ar300|\
  335. wnr2000-v3)
  336. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  337. ucidef_add_switch "switch0" \
  338. "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
  339. ;;
  340. jwap230)
  341. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  342. ucidef_add_switch "switch0" \
  343. "0@eth0" "1:lan" "5:wan" "6@eth1"
  344. ;;
  345. nanostation-m-xw)
  346. ucidef_add_switch "switch0" \
  347. "0@eth0" "5:lan" "1:wan"
  348. ;;
  349. onion-omega)
  350. ucidef_set_interface_lan "wlan0"
  351. ;;
  352. rb-435g)
  353. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  354. ucidef_add_switch "switch0" \
  355. "0@eth1" "1:lan" "2:lan"
  356. ;;
  357. rb-450)
  358. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  359. ucidef_add_switch "switch0" \
  360. "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
  361. ;;
  362. rb-450g)
  363. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  364. ucidef_add_switch "switch0" \
  365. "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
  366. ;;
  367. routerstation-pro)
  368. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  369. ucidef_add_switch "switch0" \
  370. "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
  371. ;;
  372. rb-493g)
  373. ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
  374. ucidef_add_switch "switch0" \
  375. "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
  376. ucidef_add_switch "switch1" \
  377. "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
  378. ;;
  379. tellstick-znet-lite)
  380. ucidef_set_interface_wan "eth0"
  381. ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
  382. ;;
  383. tl-wdr4300|\
  384. tl-wr1041n-v2)
  385. ucidef_add_switch "switch0" \
  386. "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
  387. ;;
  388. tl-wpa8630)
  389. ucidef_add_switch "switch0" \
  390. "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
  391. ;;
  392. tl-wr1043nd)
  393. ucidef_add_switch "switch0" \
  394. "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
  395. ;;
  396. tl-wr2543n)
  397. ucidef_add_switch "switch0" \
  398. "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
  399. ;;
  400. tl-wr841n-v1|\
  401. tl-wr941nd)
  402. ucidef_set_interface_raw "eth" "eth0"
  403. ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
  404. ;;
  405. tl-wr741nd|\
  406. tl-wr841n-v7)
  407. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  408. ucidef_add_switch "switch0" \
  409. "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
  410. ;;
  411. tl-wr842n-v2)
  412. ucidef_set_interfaces_lan_wan "eth1" "eth0"
  413. ucidef_add_switch "switch0" \
  414. "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
  415. ;;
  416. uap-pro|\
  417. wpj342)
  418. ucidef_add_switch "switch0" \
  419. "0@eth0" "1:lan" "2:wan"
  420. ;;
  421. unifiac-pro|\
  422. xd3200)
  423. ucidef_add_switch "switch0" \
  424. "0@eth0" "2:lan" "3:wan"
  425. ;;
  426. wndr3700|\
  427. wndr3700v2|\
  428. wndr3800|\
  429. wndr3800ch)
  430. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  431. ucidef_add_switch "switch0" \
  432. "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
  433. ucidef_add_switch_attr "switch0" "blinkrate" 2
  434. ucidef_add_switch_port_attr "switch0" 1 led 6
  435. ucidef_add_switch_port_attr "switch0" 2 led 9
  436. ucidef_add_switch_port_attr "switch0" 5 led 2
  437. ;;
  438. wpj344)
  439. ucidef_add_switch "switch0" \
  440. "0@eth0" "3:lan" "2:wan"
  441. ;;
  442. wpj558)
  443. ucidef_add_switch "switch0" \
  444. "5:lan" "1:wan" "6@eth0"
  445. ;;
  446. wrt160nl)
  447. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  448. ucidef_add_switch "switch0" \
  449. "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
  450. ;;
  451. wzr-hp-g450h)
  452. ucidef_add_switch "switch0" \
  453. "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
  454. ;;
  455. z1)
  456. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  457. ucidef_add_switch "switch0" \
  458. "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
  459. ;;
  460. *)
  461. ucidef_set_interfaces_lan_wan "eth0" "eth1"
  462. ;;
  463. esac
  464. }
  465. ar71xx_setup_macs()
  466. {
  467. local board="$1"
  468. local lan_mac=""
  469. local wan_mac=""
  470. case $board in
  471. dgl-5500-a1|\
  472. dir-825-c1)
  473. wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
  474. ;;
  475. dhp-1565-a1|\
  476. dir-835-a1|\
  477. wndr3700v4|\
  478. wndr4300)
  479. lan_mac=$(mtd_get_mac_binary caldata 0)
  480. wan_mac=$(mtd_get_mac_binary caldata 6)
  481. ;;
  482. tl-wr1043nd-v4)
  483. lan_mac=$(mtd_get_mac_binary product-info 8)
  484. wan_mac=$(macaddr_add "$lan_mac" 1)
  485. ;;
  486. esr900)
  487. wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
  488. ;;
  489. dir-869-a1|\
  490. mynet-n750)
  491. wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
  492. ;;
  493. esac
  494. [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
  495. [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
  496. }
  497. board_config_update
  498. board=$(ar71xx_board_name)
  499. ar71xx_setup_interfaces $board
  500. ar71xx_setup_macs $board
  501. board_config_flush
  502. exit 0