From: Michael Tremer Date: Sat, 17 Oct 2015 14:51:26 +0000 (+0200) Subject: Add functionality to identify tun/tap devices X-Git-Tag: 008~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d6dab20db9ed98f631b6d0ae31056a227b1c06b;p=network.git Add functionality to identify tun/tap devices Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.device b/src/functions/functions.device index a851b669..a79b81d5 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -313,6 +313,13 @@ device_is_serial() { serial_exists $@ } +# Returns true if a device is a tun device +device_is_tun() { + local device="${1}" + + [ -e "${SYS_CLASS_NET}/${device}/tun_flags" ] +} + # Check if the device is a physical network interface device_is_ethernet() { local device=${1} @@ -338,6 +345,9 @@ device_is_ethernet() { device_is_dummy ${device} && \ return ${EXIT_ERROR} + device_is_tun ${device} && \ + return ${EXIT_ERROR} + return ${EXIT_OK} } @@ -377,6 +387,9 @@ device_get_type() { elif device_is_dummy ${device}; then echo "dummy" + elif device_is_tun ${device}; then + echo "tun" + elif device_is_ethernet ${device}; then echo "ethernet"