[ "$ACTION" == "add" ] || exit 0

PHYNBR=${DEVPATH##*/phy}

[ -n $PHYNBR ] || exit 0

. /lib/functions.sh
. /lib/functions/system.sh

board=$(board_name)

case "$board" in
	dlink,dir-853-a3)
		[ "$PHYNBR" = "0" ] && \
			macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \
				> /sys${DEVPATH}/macaddress
		;;
	dlink,dir-853-r1)
		if [ "$PHYNBR" = "0" ]; then
			base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" -1)
			macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress
		fi
		;;
	glinet,gl-mt1300)
		[ "$PHYNBR" = "1" ] && \
			macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress
		;;
	jcg,q20)
		[ "$PHYNBR" = "1" ] && \
			macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
		;;
	linksys,e5600|\
	linksys,ea7300-v1|\
	linksys,ea7300-v2|\
	linksys,ea7500-v2|\
	linksys,ea8100-v1|\
	linksys,ea8100-v2)
		hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
		[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
		[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
		;;
esac
