02_network 11 KB

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