ramips: use the mtd_get_mac_* helpers
[openwrt/openwrt.git] / target / linux / ramips / base-files / lib / preinit / 06_set_iface_mac
1 #
2 # Copyright (C) 2011 OpenWrt.org
3 #
4
5 preinit_set_mac_address() {
6 local mac
7
8 . /lib/functions.sh
9 . /lib/ramips.sh
10
11 case $(ramips_board_name) in
12 3g-6200n |\
13 3g300m | \
14 mzk-w300nh2 |\
15 wl-330n |\
16 wl-330n3g)
17 mac=$(mtd_get_mac_binary factory 4)
18 ifconfig eth0 hw ether $mac 2>/dev/null
19 ;;
20 bc2 |\
21 broadway |\
22 dir-620-a1 |\
23 esr-9753 |\
24 freestation5 |\
25 nw718 |\
26 psr-680w |\
27 rt-n56u |\
28 sl-r7205)
29 mac=$(mtd_get_mac_binary factory 4)
30 mac=$(maccalc or "$mac" "02:00:00:00:00:00")
31 ifconfig eth0 hw ether $mac 2>/dev/null
32 ;;
33 dir-300-b1 |\
34 dir-300-b2 |\
35 dir-600-b1)
36 mac=$(mtd_get_mac_binary devdata 16388)
37 ifconfig eth0 hw ether $mac 2>/dev/null
38 ;;
39 dir-645)
40 mac=$(mtd_get_mac_ascii nvram lanmac)
41 mac=$(maccalc or "$mac" "02:00:00:00:00:00")
42 ifconfig eth0 hw ether $mac 2>/dev/null
43 ;;
44 dap-1350)
45 mac=$(mtd_get_mac_binary devdata 46)
46 ifconfig eth0 hw ether $mac 2>/dev/null
47 ;;
48 all0239-3g |\
49 all0256n |\
50 all5002 |\
51 carambola |\
52 dir-615-h1 |\
53 fonera20n |\
54 rt-n13u |\
55 hw550-3g |\
56 nbg-419n |\
57 omni-emb |\
58 omni-emb-hpm |\
59 tew-691gr |\
60 tew-692gr |\
61 w306r-v20 |\
62 w502u |\
63 wr6202 |\
64 xdxrn502j)
65 mac=$(mtd_get_mac_binary factory 40)
66 ifconfig eth0 hw ether $mac 2>/dev/null
67 ;;
68 wl341v3)
69 mac=$(mtd_get_mac_binary board-nvram 65440)
70 ifconfig eth0 hw ether $mac 2>/dev/null
71 ;;
72 rt-n10-plus)
73 mac=$(mtd_get_mac_binary devconf 4)
74 ifconfig eth0 hw ether $mac 2>/dev/null
75 ;;
76 esac
77 }
78
79 boot_hook_add preinit_main preinit_set_mac_address