summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/base-files/lib/preinit/06_set_iface_mac
blob: ff27fc952f01ab93d83eaf212a46577f0f9d1672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
# Copyright (C) 2014 OpenWrt.org
#

preinit_set_mac_address() {
	local mac

	. /lib/functions.sh
	. /lib/realtek.sh

	case $(realtek_board_name) in
	generic |\
	nprove |\
	nprove2)
		mac=$(rtkmib --get mac0)
		ifconfig eth0 hw ether $mac 2>/dev/null
		;;
	sl-r7205)
		mac=$(mtd_get_mac_binary factory 4)
		mac=$(macaddr_setbit_la "$mac")
		ifconfig eth0 hw ether $mac 2>/dev/null
		;;
	dir-645)
		mac=$(mtd_get_mac_ascii nvram lanmac)
		mac=$(macaddr_setbit_la "$mac")
		ifconfig eth0 hw ether $mac 2>/dev/null
		;;
	xdxrn502j)
		mac=$(mtd_get_mac_binary factory 40)
		ifconfig eth0 hw ether $mac 2>/dev/null
		;;
	esac
}

boot_hook_add preinit_main preinit_set_mac_address