02_network 10 KB

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