1996-03-12 15:39:26 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
1998-09-02 01:34:57 +00:00
|
|
|
#
|
2005-10-03 18:20:44 +00:00
|
|
|
# pccard_ether interfacename [start|stop|restart]
|
1996-03-12 15:39:26 +00:00
|
|
|
#
|
2005-06-07 04:49:12 +00:00
|
|
|
# example: pccard_ether fxp0 start
|
1996-03-12 15:39:26 +00:00
|
|
|
#
|
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
. /etc/rc.subr
|
2003-08-12 20:22:44 +00:00
|
|
|
. /etc/network.subr
|
|
|
|
|
2005-10-03 18:20:44 +00:00
|
|
|
name="pccard_ether"
|
|
|
|
start_precmd="checkauto"
|
|
|
|
start_cmd="pccard_ether_start"
|
|
|
|
stop_precmd="checkauto"
|
|
|
|
stop_cmd="pccard_ether_stop"
|
|
|
|
restart_precmd="checkauto"
|
|
|
|
restart_cmd="pccard_ether_restart"
|
2015-09-02 12:46:42 +00:00
|
|
|
startchildren_cmd="pccard_ether_startchildren"
|
|
|
|
stopchildren_cmd="pccard_ether_stopchildren"
|
|
|
|
extra_commands="startchildren stopchildren"
|
2003-08-12 20:22:44 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
setup_routes()
|
|
|
|
{
|
|
|
|
# Add default route into $static_routes
|
|
|
|
case ${defaultrouter} in
|
|
|
|
[Nn][Oo] | '')
|
2003-08-12 20:22:44 +00:00
|
|
|
;;
|
|
|
|
*)
|
2005-06-07 04:49:12 +00:00
|
|
|
static_routes="default ${static_routes}"
|
|
|
|
route_default="default ${defaultrouter}"
|
2003-08-12 20:22:44 +00:00
|
|
|
;;
|
|
|
|
esac
|
2000-10-16 19:11:11 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
# Add private route for this interface into $static_routes
|
|
|
|
eval ifx_routes=\$static_routes_${ifn}
|
|
|
|
if [ -n "${ifx_routes}" ]; then
|
|
|
|
static_routes="${ifx_routes} ${static_routes}"
|
2003-08-12 20:22:44 +00:00
|
|
|
fi
|
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
# Set up any static routes if specified
|
|
|
|
if [ -n "${static_routes}" ]; then
|
|
|
|
for i in ${static_routes}; do
|
|
|
|
eval route_args=\$route_${i}
|
|
|
|
route add ${route_args}
|
|
|
|
done
|
2000-10-16 19:11:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
remove_routes()
|
|
|
|
{
|
|
|
|
# Delete static route if specified
|
|
|
|
eval ifx_routes=\$static_routes_${ifn}
|
|
|
|
if [ -n "${ifx_routes}" ]; then
|
|
|
|
for i in ${ifx_routes}; do
|
|
|
|
eval route_args=\$route_${i}
|
|
|
|
route delete ${route_args}
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
2000-02-11 14:49:42 +00:00
|
|
|
|
2005-10-03 18:20:44 +00:00
|
|
|
checkauto()
|
|
|
|
{
|
|
|
|
if [ -z "$rc_force" ]; then
|
|
|
|
# Ignore interfaces with the NOAUTO keyword
|
|
|
|
autoif $ifn || exit 0
|
|
|
|
fi
|
|
|
|
}
|
2005-06-16 18:08:04 +00:00
|
|
|
|
2005-10-03 18:20:44 +00:00
|
|
|
pccard_ether_start()
|
|
|
|
{
|
2006-08-18 13:19:45 +00:00
|
|
|
ifexists $ifn || exit 1
|
|
|
|
|
2006-09-20 19:45:30 +00:00
|
|
|
if [ -z "$rc_force" ]; then
|
|
|
|
for uif in `ifconfig -ul`; do
|
|
|
|
if [ "${uif}" = "${ifn}" ]; then
|
|
|
|
# Interface is already up, so ignore it.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
2002-12-11 23:30:34 +00:00
|
|
|
fi
|
|
|
|
|
2008-06-23 20:50:11 +00:00
|
|
|
/etc/rc.d/netif quietstart $ifn
|
2000-12-25 09:21:18 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
# Do route configuration if needed.
|
|
|
|
# XXX: should probably do this by calling rc.d/routing.
|
|
|
|
if [ -n "`ifconfig_getargs $ifn`" ]; then
|
|
|
|
if ! dhcpif $ifn; then
|
|
|
|
setup_routes
|
2000-12-25 09:21:18 +00:00
|
|
|
fi
|
2005-06-07 04:49:12 +00:00
|
|
|
fi
|
1999-09-13 15:44:20 +00:00
|
|
|
|
2006-12-08 15:48:42 +00:00
|
|
|
# XXX: IPv6 setup should be done in some way.
|
2005-10-03 18:20:44 +00:00
|
|
|
}
|
2000-12-25 09:21:18 +00:00
|
|
|
|
2005-10-03 18:20:44 +00:00
|
|
|
pccard_ether_stop()
|
|
|
|
{
|
2005-06-07 04:49:12 +00:00
|
|
|
if [ -n "`ifconfig_getargs $ifn`" ]; then
|
|
|
|
if ! dhcpif $ifn; then
|
|
|
|
remove_routes
|
2000-12-25 09:21:18 +00:00
|
|
|
fi
|
2005-06-07 04:49:12 +00:00
|
|
|
fi
|
2000-12-25 09:21:18 +00:00
|
|
|
|
2008-06-23 20:50:11 +00:00
|
|
|
/etc/rc.d/netif quietstop $ifn
|
2000-12-25 09:21:18 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
# clean ARP table
|
2006-08-17 03:03:38 +00:00
|
|
|
ifexists $ifn && arp -d -i $ifn -a
|
2005-10-03 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pccard_ether_restart()
|
|
|
|
{
|
|
|
|
# Hand implemented because the default implementation runs
|
|
|
|
# the equivalent of "$0 start; $0 stop" and this script
|
|
|
|
# doesn't support that syntax
|
|
|
|
pccard_ether_stop
|
|
|
|
pccard_ether_start
|
|
|
|
}
|
|
|
|
|
2015-09-02 12:46:42 +00:00
|
|
|
pccard_ether_startchildren()
|
|
|
|
{
|
|
|
|
for child in `get_if_var $ifn wlans_IF`; do
|
2016-12-04 15:58:34 +00:00
|
|
|
if ifexists $child; then
|
|
|
|
continue
|
|
|
|
fi
|
2015-09-02 12:46:42 +00:00
|
|
|
/etc/rc.d/netif quietstart $child
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
pccard_ether_stopchildren()
|
|
|
|
{
|
|
|
|
for child in `get_if_var $ifn wlans_IF`; do
|
|
|
|
/etc/rc.d/netif quietstop $child
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2005-10-03 18:20:44 +00:00
|
|
|
ifn=$1
|
|
|
|
shift
|
|
|
|
if [ -z "$*" ]; then
|
|
|
|
args="start"
|
|
|
|
else
|
|
|
|
args=$*
|
|
|
|
fi
|
|
|
|
|
|
|
|
load_rc_config pccard_ether
|
2012-11-08 20:34:12 +00:00
|
|
|
load_rc_config network
|
2005-10-03 18:20:44 +00:00
|
|
|
run_rc_command $args
|