1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00
freebsd/etc/pccard_ether
Warner Losh 8dac8c268d Due to a bug in the ed driver, which leads to hangs when using it with
dhclient and pccard_ether, introduce the concept of a "settle time" to
pccard_ether with the new pccard_ether_delay variable.  Defaults to 5
seconds, which is enough time for the ed driver to finish its
autoconfiguration for newer Linksys based cards.  This also can
eliminate the ed0: timeout messages that happen at startup as well.

MFC: after RE says OK.
2001-09-13 06:18:07 +00:00

197 lines
3.9 KiB
Bash
Executable File

#!/bin/sh -
#
# $FreeBSD$
#
# pccard_ether interfacename [start|stop] [ifconfig option]
#
# example: pccard_ether ep0 start -link0
#
stop_dhcp() {
if [ -s /var/run/dhclient.${interface}.pid ]; then
pidfile="/var/run/dhclient.${interface}.pid"
elif [ -s /var/run/dhcpc.${interface}.pid ]; then
pidfile="/var/run/dhcpc.${interface}.pid"
else
return
fi
kill `cat ${pidfile}`
rm -f ${pidfile}
}
start_dhcp() {
stop_dhcp
if [ -x "${dhcp_program}" ]; then
if [ `basename ${dhcp_program}` = "dhclient" ]; then
pidfile="/var/run/dhclient.${interface}.pid"
dhcp_flags="${dhcp_flags} -pf ${pidfile}"
fi
${dhcp_program} ${dhcp_flags} ${interface}
else
echo "${dhcp_program}: DHCP client software not available"
fi
}
# Suck in the configuration variables
#
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
interface=$1
shift
startstop=$1
shift
case ${pccard_ether_delay} in
[Nn][Oo])
;;
[0-9])
sleep ${pccard_ether_delay}
;;
*) # Default until it has had a chance to make it to /etc/defaults/rc.conf
sleep 5
;;
esac
case ${pccard_ifconfig} in
[Nn][Oo] | '')
expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0
;;
*)
# Backward compatible
eval ifconfig_${interface}=\${pccard_ifconfig}
;;
esac
case ${startstop} in
[Ss][Tt][Aa][Rr][Tt] | '')
if [ -r /etc/start_if.${interface} ]; then
. /etc/start_if.${interface}
fi
eval ifconfig_args=\$ifconfig_${interface}
case ${ifconfig_args} in
[Nn][Oo] | '')
;;
[Dd][Hh][Cc][Pp])
# Start up the DHCP client program
start_dhcp
;;
*)
# Do the primary ifconfig if specified
ifconfig ${interface} ${ifconfig_args} $*
# Check to see if aliases need to be added
alias=0
while :
do
eval ifx_args=\$ifconfig_${interface}_alias${alias}
if [ -n "${ifx_args}" ]; then
ifconfig ${interface} ${ifx_args} alias
alias=`expr ${alias} + 1`
else
break;
fi
done
# Do ipx address if specified
eval ifx_args=\$ifconfig_${interface}_ipx
if [ -n "${ifx_args}" ]; then
ifconfig ${interface} ${ifx_args}
fi
# Add default route into $static_routes
case ${defaultrouter} in
[Nn][Oo] | '')
;;
*)
static_routes="default ${static_routes}"
route_default="default ${defaultrouter}"
;;
esac
# Add private route for this interface into $static_routes
eval ifx_routes=\$static_routes_${interface}
if [ -n "${ifx_routes}" ]; then
static_routes="${ifx_routes} ${static_routes}"
fi
# 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
fi
;;
esac
# IPv6 setup
case ${ipv6_enable} in
[Yy][Ee][Ss])
if [ -r /etc/rc.network6 ]; then
. /etc/rc.network6
network6_interface_setup ${interface}
fi
;;
esac
;;
# Stop the interface
*)
if [ -r /etc/stop_if.${interface} ]; then
. /etc/stop_if.${interface}
fi
eval ifconfig_args=\$ifconfig_${interface}
case ${ifconfig_args} in
[Nn][Oo] | '')
;;
[Dd][Hh][Cc][Pp])
# Stop the DHCP client for this interface
stop_dhcp
;;
*)
# Delelte static route if specified
eval ifx_routes=\$static_routes_${interface}
if [ -n "${ifx_routes}" ]; then
for i in ${ifx_routes}; do
eval route_args=\$route_${i}
route delete ${route_args}
done
fi
# Delete aliases if exist
alias=0
while :
do
eval ifx_args=\$ifconfig_${interface}_alias${alias}
if [ -n "${ifx_args}" ]; then
ifconfig ${interface} ${ifx_args} alias delete
alias=`expr ${alias} + 1`
else
break;
fi
done
;;
esac
# Remove the network interface and cleaning ARP table
ifconfig ${interface} delete
arp -d -a
# Clean the routing table
case ${removable_route_flush} in
[Nn][Oo])
;;
*)
# flush beforehand, just in case....
route -n flush -inet
;;
esac
;;
esac