summaryrefslogtreecommitdiffstats
path: root/etc/network.subr
diff options
context:
space:
mode:
Diffstat (limited to 'etc/network.subr')
-rw-r--r--etc/network.subr111
1 files changed, 107 insertions, 4 deletions
diff --git a/etc/network.subr b/etc/network.subr
index dfd2feb..a3059dd 100644
--- a/etc/network.subr
+++ b/etc/network.subr
@@ -34,16 +34,30 @@
# Evaluate ifconfig(8) arguments for interface $if and
# run ifconfig(8) with those arguments. It returns 0 if
# arguments were found and executed or 1 if the interface
-# had no arguments.
+# had no arguments. Pseudo arguments DHCP and WPA are handled
+# here.
#
ifconfig_up()
{
- eval ifconfig_args=\$ifconfig_$1
+ _cfg=1
+
+ ifconfig_args=`ifconfig_getargs $1`
if [ -n "${ifconfig_args}" ]; then
ifconfig $1 ${ifconfig_args}
- return 0
+ _cfg=0
fi
- return 1
+
+ if wpaif $1; then
+ #/etc/rc.d/wpa_supplicant start $1
+ _cfg=0 # XXX: not sure this should count
+ fi
+
+ if dhcpif $1; then
+ /etc/rc.d/dhclient start $1
+ _cfg=0
+ fi
+
+ return ${cfg}
}
# ifconfig_down if
@@ -74,9 +88,98 @@ ifconfig_down()
done
IFS="$oldifs"
+ if wpaif $1; then
+ #/etc/rc.d/wpa_supplicant stop $1
+ fi
+
+ if dhcpif $1; then
+ /etc/rc.d/dhclient stop $1
+ _cfg=0
+ fi
+
return $_ret
}
+# _ifconfig_getargs if
+# Echos the arguments for the supplied interface to stdout.
+# returns 1 if empty. In general, ifconfig_getargs should be used
+# outside this file.
+_ifconfig_getargs()
+{
+ _ifn=$1
+ if [ -z "$_ifn" ]; then
+ return 1
+ fi
+
+ eval _args=\$ifconfig_$1
+ if [ -z "$_args" -a -n "${pccard_ifconfig}" ]; then
+ for _if in ${removable_interfaces} ; do
+ if [ "$_if" = "$_ifn" ] ; then
+ _args=${pccard_ifconfig}
+ break
+ fi
+ done
+ fi
+
+ echo $_args
+}
+
+# ifconfig_getargs if
+# Takes the result from _ifconfig_getargs and removes pseudo
+# args such as DHCP and WPA.
+ifconfig_getargs()
+{
+ _tmpargs=`_ifconfig_getargs $1`
+ if [ $? -eq 1 ]; then
+ return 1
+ fi
+ _args=
+
+ for _arg in $_tmpargs; do
+ case $_arg in
+ [Dd][Hh][Cc][Pp])
+ ;;
+ [Ww][Pp][Aa])
+ ;;
+ *)
+ _args="$_args $_arg"
+ ;;
+ esac
+ done
+
+ echo $_args
+}
+
+# dhcpif if
+# Returns 0 if the interface is a DHCP interface and 1 otherwise.
+dhcpif()
+{
+ _tmpargs=`_ifconfig_getargs $1`
+ for _arg in $_tmpargs; do
+ case $_arg in
+ [Dd][Hh][Cc][Pp])
+ return 0
+ ;;
+ esac
+ done
+ return 1
+}
+
+# wpaif if
+# Returns 0 if the interface is a WPA interface and 1 otherwise.
+wpaif()
+{
+ _tmpargs=`_ifconfig_getargs $1`
+ for _arg in $_tmpargs; do
+ case $_arg in
+ [Ww][Pp][Aa])
+ return 0
+ ;;
+ esac
+ done
+ return 1
+}
+
# ifalias_up if
# Configure aliases for network interface $if.
# It returns 0 if at least one alias was configured or
OpenPOWER on IntegriCloud