Add definitions for LONG_BIT and WORD_BIT.
[dragonfly.git] / etc / pccard_ether
blob0fe975c7fed95b3b940eb8344711c0c3b1890f63
1 #!/bin/sh -
3 # $FreeBSD: src/etc/pccard_ether,v 1.15.2.10 2001/09/14 17:28:11 imp Exp $
4 # $DragonFly: src/etc/pccard_ether,v 1.4 2003/10/09 15:39:36 dillon Exp $
6 # pccard_ether interfacename [start|stop] [ifconfig option]
8 # example: pccard_ether ep0 start -link0
11 stop_dhcp() {
12 if [ -s /var/run/dhclient.${interface}.pid ]; then
13 pidfile="/var/run/dhclient.${interface}.pid"
14 elif [ -s /var/run/dhcpc.${interface}.pid ]; then
15 pidfile="/var/run/dhcpc.${interface}.pid"
16 else
17 return
19 kill `cat ${pidfile}`
20 rm -f ${pidfile}
23 start_dhcp() {
24 stop_dhcp
25 case ${pccard_ether_delay} in
26 [Nn][Oo])
28 [0-9])
29 sleep ${pccard_ether_delay}
31 esac
32 [ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
33 [ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
34 if [ -x "${dhclient_program}" ]; then
35 if [ `basename ${dhclient_program}` = "dhclient" ]; then
36 pidfile="/var/run/dhclient.${interface}.pid"
37 dhclient_flags="${dhclient_flags} -pf ${pidfile}"
39 ${dhclient_program} ${dhclient_flags} ${interface}
40 else
41 echo "${dhclient_program}: DHCP client software not available"
45 # Suck in the configuration variables
47 if [ -r /etc/defaults/rc.conf ]; then
48 . /etc/defaults/rc.conf
49 source_rc_confs
50 elif [ -r /etc/rc.conf ]; then
51 . /etc/rc.conf
54 interface=$1
55 shift
56 startstop=$1
57 shift
59 case ${pccard_ifconfig} in
60 [Nn][Oo] | '')
61 expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0
64 # Backward compatible
65 eval ifconfig_${interface}=\${pccard_ifconfig}
67 esac
69 case ${startstop} in
70 [Ss][Tt][Aa][Rr][Tt] | '')
71 if ifconfig ${interface} | grep -s UP, > /dev/null 2>&1; then
72 # Interface is already up, so ignore it.
73 exit 0
76 if [ -r /etc/start_if.${interface} ]; then
77 . /etc/start_if.${interface}
80 eval ifconfig_args=\$ifconfig_${interface}
81 case ${ifconfig_args} in
82 [Nn][Oo] | '')
84 [Dd][Hh][Cc][Pp])
85 # Start up the DHCP client program
86 start_dhcp
89 # Do the primary ifconfig if specified
90 ifconfig ${interface} ${ifconfig_args} $*
92 # Check to see if aliases need to be added
93 alias=0
94 while :
96 eval ifx_args=\$ifconfig_${interface}_alias${alias}
97 if [ -n "${ifx_args}" ]; then
98 ifconfig ${interface} ${ifx_args} alias
99 alias=`expr ${alias} + 1`
100 else
101 break;
103 done
105 # Do ipx address if specified
106 eval ifx_args=\$ifconfig_${interface}_ipx
107 if [ -n "${ifx_args}" ]; then
108 ifconfig ${interface} ${ifx_args}
111 # Add default route into $static_routes
112 case ${defaultrouter} in
113 [Nn][Oo] | '')
116 static_routes="default ${static_routes}"
117 route_default="default ${defaultrouter}"
119 esac
121 # Add private route for this interface into $static_routes
122 eval ifx_routes=\$static_routes_${interface}
123 if [ -n "${ifx_routes}" ]; then
124 static_routes="${ifx_routes} ${static_routes}"
127 # Set up any static routes if specified
128 if [ -n "${static_routes}" ]; then
129 for i in ${static_routes}; do
130 eval route_args=\$route_${i}
131 route add ${route_args}
132 done
135 esac
137 # IPv6 setup
138 case ${ipv6_enable} in
139 [Yy][Ee][Ss])
140 if [ -r /etc/network.subr ]; then
141 . /etc/network.subr
142 network6_interface_setup ${interface}
145 esac
147 # Stop the interface
149 if [ -r /etc/stop_if.${interface} ]; then
150 . /etc/stop_if.${interface}
153 eval ifconfig_args=\$ifconfig_${interface}
154 case ${ifconfig_args} in
155 [Nn][Oo] | '')
157 [Dd][Hh][Cc][Pp])
158 # Stop the DHCP client for this interface
159 stop_dhcp
162 # Delete static route if specified
163 eval ifx_routes=\$static_routes_${interface}
164 if [ -n "${ifx_routes}" ]; then
165 for i in ${ifx_routes}; do
166 eval route_args=\$route_${i}
167 route delete ${route_args}
168 done
171 # Delete aliases if exist
172 alias=0
173 while :
175 eval ifx_args=\$ifconfig_${interface}_alias${alias}
176 if [ -n "${ifx_args}" ]; then
177 ifconfig ${interface} ${ifx_args} alias delete
178 alias=`expr ${alias} + 1`
179 else
180 break;
182 done
184 esac
186 # Remove the network interface and clean the ARP table
187 ifconfig ${interface} delete
188 arp -d -a
190 # Clean the routing table
191 case ${removable_route_flush} in
192 [Nn][Oo])
195 # flush beforehand, just in case....
196 route -n flush -inet
198 esac
200 esac