1996-03-12 16:39:26 +01:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1999-08-28 01:37:10 +02:00
|
|
|
# $FreeBSD$
|
1998-09-02 03:34:57 +02:00
|
|
|
#
|
2005-06-07 06:49:12 +02:00
|
|
|
# pccard_ether interfacename [start|stop]
|
1996-03-12 16:39:26 +01:00
|
|
|
#
|
2005-06-07 06:49:12 +02:00
|
|
|
# example: pccard_ether fxp0 start
|
1996-03-12 16:39:26 +01:00
|
|
|
#
|
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
. /etc/rc.subr
|
2003-08-12 22:22:44 +02:00
|
|
|
. /etc/network.subr
|
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
err 3 'USAGE: $0 interface (start|stop)'
|
|
|
|
}
|
2003-08-12 22:22:44 +02:00
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
setup_routes()
|
|
|
|
{
|
|
|
|
# Add default route into $static_routes
|
|
|
|
case ${defaultrouter} in
|
|
|
|
[Nn][Oo] | '')
|
2003-08-12 22:22:44 +02:00
|
|
|
;;
|
|
|
|
*)
|
2005-06-07 06:49:12 +02:00
|
|
|
static_routes="default ${static_routes}"
|
|
|
|
route_default="default ${defaultrouter}"
|
2003-08-12 22:22:44 +02:00
|
|
|
;;
|
|
|
|
esac
|
2000-10-16 21:11:11 +02:00
|
|
|
|
2005-06-07 06:49:12 +02: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 22:22:44 +02:00
|
|
|
fi
|
|
|
|
|
2005-06-07 06:49:12 +02: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 21:11:11 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-06-07 06:49:12 +02: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 15:49:42 +01:00
|
|
|
|
2005-06-16 20:08:04 +02:00
|
|
|
ifn=$1
|
|
|
|
shift
|
|
|
|
startstop=$1
|
|
|
|
shift
|
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
load_rc_config pccard_ether
|
2000-12-25 10:21:18 +01:00
|
|
|
|
2005-08-24 03:23:49 +02:00
|
|
|
# Ignore interfaces with the NOAUTO keyword
|
|
|
|
autoif $ifn || exit 0
|
2005-06-16 20:08:04 +02:00
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2000-10-16 21:11:11 +02:00
|
|
|
case ${startstop} in
|
|
|
|
[Ss][Tt][Aa][Rr][Tt] | '')
|
2003-08-12 22:22:44 +02:00
|
|
|
if [ -x /usr/bin/grep ]; then
|
2005-06-07 06:49:12 +02:00
|
|
|
if ifconfig $ifn | grep -s netmask > /dev/null 2>&1; then
|
2003-08-12 22:22:44 +02:00
|
|
|
# Interface is already up, so ignore it.
|
|
|
|
exit 0
|
|
|
|
fi
|
2002-12-12 00:30:34 +01:00
|
|
|
fi
|
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
/etc/rc.d/netif start $ifn
|
2000-12-25 10:21:18 +01:00
|
|
|
|
2005-06-07 06:49:12 +02: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 10:21:18 +01:00
|
|
|
fi
|
2005-06-07 06:49:12 +02:00
|
|
|
fi
|
1999-09-13 17:44:20 +02:00
|
|
|
|
2000-10-16 21:11:11 +02:00
|
|
|
# IPv6 setup
|
2005-06-07 06:49:12 +02:00
|
|
|
if checkyesno ipv6_enable; then
|
|
|
|
network6_interface_setup $ifn
|
2000-12-25 10:21:18 +01:00
|
|
|
fi
|
2005-06-07 06:49:12 +02:00
|
|
|
;;
|
2000-12-25 10:21:18 +01:00
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
# Stop the interface
|
|
|
|
[Ss][Tt][Oo][Pp])
|
|
|
|
if [ -n "`ifconfig_getargs $ifn`" ]; then
|
|
|
|
if ! dhcpif $ifn; then
|
|
|
|
remove_routes
|
2000-12-25 10:21:18 +01:00
|
|
|
fi
|
2005-06-07 06:49:12 +02:00
|
|
|
fi
|
2000-12-25 10:21:18 +01:00
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
/etc/rc.d/netif stop $ifn
|
2000-12-25 10:21:18 +01:00
|
|
|
|
2005-06-07 06:49:12 +02:00
|
|
|
# clean ARP table
|
2000-12-25 10:21:18 +01:00
|
|
|
arp -d -a
|
|
|
|
|
|
|
|
# Clean the routing table
|
2005-06-07 06:49:12 +02:00
|
|
|
if checkyesno removable_route_flush; then
|
|
|
|
route -n flush -inet > /dev/null
|
|
|
|
fi
|
2000-10-16 21:11:11 +02:00
|
|
|
;;
|
2005-06-07 06:49:12 +02:00
|
|
|
*)
|
|
|
|
usage
|
2000-07-17 14:33:57 +02:00
|
|
|
esac
|