#! /bin/bash

# default libexecdir used to bootstrap scripts
libexecdir=${GLOBUS_LOCATION}/libexec

# load GRIS common code and initialization
. ${libexecdir}/grid-info-net-common

# For ifconfig
. ${libexecdir}/globus-sh-tools.sh

#########################################################################

probe_resource_net ()
{
    ${GLOBUS_SH_NETSTAT} -in | \
    {
	i=0
	read header
	while read name mtu net addr rest
	do

	    if [ "${net#link}" != "${net}" ] ; then
		continue
	    fi

	    if [ "${name}" = "${prev}" ] ; then
		continue
	    fi

	    eval "_net_${i}_name=\"${name}\""
	    eval "_net_${i}_ipaddr=$addr"
	    eval "_net_${i}_netaddr=${net}"
	    eval "_net_${i}_mtu=${mtu}"
	    eval "_net_${i}_up=up"
	    prev=${name}
	    i=`$EXPR $i + 1`
	done
	_net_count=$i

	# run this in initialized subshell environment
	emit_resource_net_descriptions
    }
}

#############
# do the work
probe_resource_net
