dev/ow: Tag an unreachable switch default.
[freebsd-src.git] / etc / pccard_ether
blob7d324a11b89b16de0969a0d838ac3be87682c103
1 #!/bin/sh -
3 # $FreeBSD$
5 # pccard_ether interfacename [start|stop|restart]
7 # example: pccard_ether fxp0 start
10 . /etc/rc.subr
11 . /etc/network.subr
13 name="pccard_ether"
14 start_precmd="checkauto"
15 start_cmd="pccard_ether_start"
16 stop_precmd="checkauto"
17 stop_cmd="pccard_ether_stop"
18 restart_precmd="checkauto"
19 restart_cmd="pccard_ether_restart"
20 startchildren_cmd="pccard_ether_startchildren"
21 stopchildren_cmd="pccard_ether_stopchildren"
22 extra_commands="startchildren stopchildren"
24 setup_routes()
26 # Add default route into $static_routes
27 case ${defaultrouter} in
28 [Nn][Oo] | '')
31 static_routes="default ${static_routes}"
32 route_default="default ${defaultrouter}"
34 esac
36 # Add private route for this interface into $static_routes
37 eval ifx_routes=\$static_routes_${ifn}
38 if [ -n "${ifx_routes}" ]; then
39 static_routes="${ifx_routes} ${static_routes}"
42 # Set up any static routes if specified
43 if [ -n "${static_routes}" ]; then
44 for i in ${static_routes}; do
45 eval route_args=\$route_${i}
46 route add ${route_args}
47 done
51 remove_routes()
53 # Delete static route if specified
54 eval ifx_routes=\$static_routes_${ifn}
55 if [ -n "${ifx_routes}" ]; then
56 for i in ${ifx_routes}; do
57 eval route_args=\$route_${i}
58 route delete ${route_args}
59 done
63 checkauto()
65 if [ -z "$rc_force" ]; then
66 # Ignore interfaces with the NOAUTO keyword
67 autoif $ifn || exit 0
71 pccard_ether_start()
73 ifexists $ifn || exit 1
75 if [ -z "$rc_force" ]; then
76 for uif in `ifconfig -ul`; do
77 if [ "${uif}" = "${ifn}" ]; then
78 # Interface is already up, so ignore it.
79 exit 0
81 done
84 /etc/rc.d/netif quietstart $ifn
86 # Do route configuration if needed.
87 # XXX: should probably do this by calling rc.d/routing.
88 if [ -n "`ifconfig_getargs $ifn`" ]; then
89 if ! dhcpif $ifn; then
90 setup_routes
94 # XXX: IPv6 setup should be done in some way.
97 pccard_ether_stop()
99 if [ -n "`ifconfig_getargs $ifn`" ]; then
100 if ! dhcpif $ifn; then
101 remove_routes
105 /etc/rc.d/netif quietstop $ifn
107 # clean ARP table
108 ifexists $ifn && arp -d -i $ifn -a
111 pccard_ether_restart()
113 # Hand implemented because the default implementation runs
114 # the equivalent of "$0 start; $0 stop" and this script
115 # doesn't support that syntax
116 pccard_ether_stop
117 pccard_ether_start
120 pccard_ether_startchildren()
122 for child in `get_if_var $ifn wlans_IF`; do
123 /etc/rc.d/netif quietstart $child
124 done
127 pccard_ether_stopchildren()
129 for child in `get_if_var $ifn wlans_IF`; do
130 /etc/rc.d/netif quietstop $child
131 done
134 ifn=$1
135 shift
136 if [ -z "$*" ]; then
137 args="start"
138 else
139 args=$*
142 load_rc_config pccard_ether
143 load_rc_config network
144 run_rc_command $args