From 2569eb644e6e8e010a44a693e7dfa86e73c0d750 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Mon, 12 Dec 2011 18:48:11 -0800 Subject: net/ifconfig, net/iproute2: admin/oper state check functions Provide consistent methods using iproute2/ifconfig to check operational and administrative up/down state of interfaces. This is not the same as ethtool's "Link detected" field, which is the state of the layer 2 medium. TODO: How to check operational state in BSD? Signed-off-by: Robin H. Johnson --- net/ifconfig.sh.BSD.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'net/ifconfig.sh.BSD.in') diff --git a/net/ifconfig.sh.BSD.in b/net/ifconfig.sh.BSD.in index 15c8fb8..c7e98a2 100644 --- a/net/ifconfig.sh.BSD.in +++ b/net/ifconfig.sh.BSD.in @@ -242,3 +242,23 @@ ifconfig_post_start() eend 0 fi } + +# Is the interface administratively/operationally up? +# The 'UP' status in ifconfig is the administrative status +# Operational state does not seem to be available in BSD? +# 0: up +# 1: down +# 2: invalid arguments +is_admin_up() +{ + local iface="$1" + [ -z "$iface" ] && iface="$IFACE" + ifconfig "${iface}" | \ + sed -n '1,1{ /flags=.*[<,]UP[,>]/{ q 0 }}; q 1; ' +} + +is_oper_up() +{ + eerror "TODO: is_oper_up not available on BSD" + return 2 +} -- cgit v1.2.3