#
# Functions for hotplugable net device
#					Shuu Yamaguchi <shuu@dotAster.com>
# $Id: net_functions,v 1.3 2004/03/03 22:22:00 shuu Exp shuu $

. ${MURASAKI_SCRIPT_DIR}/func_log

# check network device
# waiting for 6 sec until the device is found.
wait_dev() {
	for sec in 1 2 3
	do
		grep $INTERFACE /proc/net/dev > /dev/null
		if [ $? -eq 0 ];then
			break;
		fi
		sleep $sec
	done
}

# INTERFACE: network interface name
# IGNORE_INTERFACES: ignored interface list
get_interface()
{
	if [ -z "$INTERFACE" ];then
		if [ -n "$DEVPATH" ];then
			INTERFACE=`basename $DEVPATH`
		else
			log "daemon.err" "murasaki:get_interface" "Network Interface is not found"
			exit 1
		fi
	fi
	for inf in $IGNORE_INTERFACES
	do
		NUM=`expr "$INTERFACE" : "${inf}[[:digit:]]"`
		if [ $NUM -gt 0 ];then
			log "daemon.info" "murasaki:get_interface" "Network Interface is ignored"
			INTERFACE=""
			break
		fi
	done
}
