
readonly XID_NETWORK="NET"


net_defaults()
{

	eval ${XID_NETWORK}_IP=\"192.168.0.100\"
	eval ${XID_NETWORK}_NM=\"255.255.255.0\"
	eval ${XID_NETWORK}_GW=\"192.168.0.1\"
	return 0
}

validate_hostname()
{
	local host=`trim "$1"`
	local -i ret=1
	
	expr match "$host" "^[[:alnum:]_-]\+$" >/dev/null 2>&1
	if test $? -eq 0; then
		ret=0
	fi
	return $ret
}

validate_ip()
{
	local ip=`trim "$1"`
	local -i octet=0
	local -i ret=0
	local -a octets

	octets=(`echo $ip | sed -ne 's@^[ \t]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)[ \t]*$@\1 \2 \3 \4@p' 2>/dev/null`)
	if test ${#octets[*]} -eq 4; then
		for octet in ${octets[*]}; do
			if test $octet -gt 255; then
				ret=1
			fi
		done
	else
		ret=1
	fi

	return $ret
}

validate_netmask()
{
	validate_ip "$1"
}

validate_gateway()
{
	validate_ip "$1"
}
