# Utility functions for the Ebee networking

###############################################
# Returns if a given network interface exists
# $1 - name of network interface 
# Returns 0 on success, 1 on failures

net_interface_exists()
{
    ip link show $1 >/dev/null 2>&1
}


###############################################
# Returns the name of a network interface
# given its IP address.
# @$1 - MAC address
# Returns name of net interface on succes,
# empty string on failure

find_net_interface_by_mac()
{
    for if in /sys/class/net/*
	do
        if [ "$(cat ${if}/address)" = "$1" ]
		then
		   basename "${if}"
		   return
        fi
    done
    false
}
