7824e2b252db5b514d3c0baa6be19fc001f69c31
[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 3g-6200nl |\
14 3g300m | \
15 w150m | \
16 mzk-w300nh2 |\
17 wl-330n |\
18 wl-330n3g)
19 mac=$(mtd_get_mac_binary factory 4)
20 ifconfig eth0 hw ether $mac 2>/dev/null
21 ;;
22 bc2 |\
23 broadway |\
24 d105 |\
25 dir-620-a1 |\
26 esr-9753 |\
27 freestation5 |\
28 nw718 |\
29 psr-680w |\
30 rt-n56u |\
31 sl-r7205)
32 mac=$(mtd_get_mac_binary factory 4)
33 mac=$(macaddr_setbit_la "$mac")
34 ifconfig eth0 hw ether $mac 2>/dev/null
35 ;;
36 dir-300-b1 |\
37 dir-300-b2 |\
38 dir-600-b1)
39 mac=$(mtd_get_mac_binary devdata 16388)
40 ifconfig eth0 hw ether $mac 2>/dev/null
41 ;;
42 dir-645)
43 mac=$(mtd_get_mac_ascii nvram lanmac)
44 mac=$(macaddr_setbit_la "$mac")
45 ifconfig eth0 hw ether $mac 2>/dev/null
46 ;;
47 dap-1350)
48 mac=$(mtd_get_mac_binary devdata 46)
49 ifconfig eth0 hw ether $mac 2>/dev/null
50 ;;
51 all0239-3g |\
52 all0256n |\
53 all5002 |\
54 carambola |\
55 dir-615-h1 |\
56 fonera20n |\
57 rt-n13u |\
58 hw550-3g |\
59 nbg-419n |\
60 omni-emb |\
61 omni-emb-hpm |\
62 tew-691gr |\
63 tew-692gr |\
64 w306r-v20 |\
65 w502u |\
66 wr6202 |\
67 xdxrn502j)
68 mac=$(mtd_get_mac_binary factory 40)
69 ifconfig eth0 hw ether $mac 2>/dev/null
70 ;;
71 wl341v3)
72 mac=$(mtd_get_mac_binary board-nvram 65440)
73 ifconfig eth0 hw ether $mac 2>/dev/null
74 ;;
75 rt-n10-plus)
76 mac=$(mtd_get_mac_binary devconf 4)
77 ifconfig eth0 hw ether $mac 2>/dev/null
78 ;;
79 esac
80 }
81
82 boot_hook_add preinit_main preinit_set_mac_address