15d9d7f34SNate Williams#!/bin/sh - 25d9d7f34SNate Williams# 3a19eda1fSBrian Somers# 4721d95b6SBrooks Davis# pccard_ether interfacename [start|stop|restart] 55d9d7f34SNate Williams# 68e9e71f8SBrooks Davis# example: pccard_ether fxp0 start 75d9d7f34SNate Williams# 85d9d7f34SNate Williams 98e9e71f8SBrooks Davis. /etc/rc.subr 10d7c24a75SMartin Blapp. /etc/network.subr 11d7c24a75SMartin Blapp 12721d95b6SBrooks Davisname="pccard_ether" 13721d95b6SBrooks Davisstart_precmd="checkauto" 14721d95b6SBrooks Davisstart_cmd="pccard_ether_start" 15721d95b6SBrooks Davisstop_precmd="checkauto" 16721d95b6SBrooks Davisstop_cmd="pccard_ether_stop" 17721d95b6SBrooks Davisrestart_precmd="checkauto" 18721d95b6SBrooks Davisrestart_cmd="pccard_ether_restart" 19e5607910SGleb Smirnoffstartchildren_cmd="pccard_ether_startchildren" 20e5607910SGleb Smirnoffstopchildren_cmd="pccard_ether_stopchildren" 21e5607910SGleb Smirnoffextra_commands="startchildren stopchildren" 2269d1f468SJosef Karthauser 238e9e71f8SBrooks Davissetup_routes() 248e9e71f8SBrooks Davis{ 256b91b72bSToshihiko ARAI # Add default route into $static_routes 2632170429SSheldon Hearn case ${defaultrouter} in 2732170429SSheldon Hearn [Nn][Oo] | '') 2832170429SSheldon Hearn ;; 2932170429SSheldon Hearn *) 3052f2ef0bSNate Williams static_routes="default ${static_routes}" 3152f2ef0bSNate Williams route_default="default ${defaultrouter}" 3232170429SSheldon Hearn ;; 3332170429SSheldon Hearn esac 3452f2ef0bSNate Williams 356b91b72bSToshihiko ARAI # Add private route for this interface into $static_routes 368e9e71f8SBrooks Davis eval ifx_routes=\$static_routes_${ifn} 376b91b72bSToshihiko ARAI if [ -n "${ifx_routes}" ]; then 386b91b72bSToshihiko ARAI static_routes="${ifx_routes} ${static_routes}" 396b91b72bSToshihiko ARAI fi 406b91b72bSToshihiko ARAI 416b91b72bSToshihiko ARAI # Set up any static routes if specified 42b68adff6SSheldon Hearn if [ -n "${static_routes}" ]; then 4352f2ef0bSNate Williams for i in ${static_routes}; do 4452f2ef0bSNate Williams eval route_args=\$route_${i} 4552f2ef0bSNate Williams route add ${route_args} 4652f2ef0bSNate Williams done 4752f2ef0bSNate Williams fi 488e9e71f8SBrooks Davis} 49feeff035SHajimu UMEMOTO 508e9e71f8SBrooks Davisremove_routes() 518e9e71f8SBrooks Davis{ 5233e268e7SMaxim Konovalov # Delete static route if specified 538e9e71f8SBrooks Davis eval ifx_routes=\$static_routes_${ifn} 546b91b72bSToshihiko ARAI if [ -n "${ifx_routes}" ]; then 556b91b72bSToshihiko ARAI for i in ${ifx_routes}; do 566b91b72bSToshihiko ARAI eval route_args=\$route_${i} 576b91b72bSToshihiko ARAI route delete ${route_args} 586b91b72bSToshihiko ARAI done 596b91b72bSToshihiko ARAI fi 608e9e71f8SBrooks Davis} 616b91b72bSToshihiko ARAI 62721d95b6SBrooks Davischeckauto() 63721d95b6SBrooks Davis{ 64721d95b6SBrooks Davis if [ -z "$rc_force" ]; then 6541f7ee42SBrooks Davis # Ignore interfaces with the NOAUTO keyword 6641f7ee42SBrooks Davis autoif $ifn || exit 0 67d873676aSBrooks Davis fi 68721d95b6SBrooks Davis} 69d873676aSBrooks Davis 70721d95b6SBrooks Davispccard_ether_start() 71721d95b6SBrooks Davis{ 72*6d3bc576SEugene Grosbein ifisup $ifn 73*6d3bc576SEugene Grosbein case $? in 74*6d3bc576SEugene Grosbein 0) # Interface is already up, so ignore it. 750e409e4bSBrooks Davis if [ -z "$rc_force"]; then 768e9e71f8SBrooks Davis exit 0 776b91b72bSToshihiko ARAI fi 78*6d3bc576SEugene Grosbein ;; 79*6d3bc576SEugene Grosbein 2) # Interface does not exist. 80*6d3bc576SEugene Grosbein exit 1 81*6d3bc576SEugene Grosbein ;; 82*6d3bc576SEugene Grosbein esac 836b91b72bSToshihiko ARAI 84b0640498SMike Makonnen /etc/rc.d/netif quietstart $ifn 858e9e71f8SBrooks Davis 868e9e71f8SBrooks Davis # Do route configuration if needed. 878e9e71f8SBrooks Davis # XXX: should probably do this by calling rc.d/routing. 888e9e71f8SBrooks Davis if [ -n "`ifconfig_getargs $ifn`" ]; then 898e9e71f8SBrooks Davis if ! dhcpif $ifn; then 908e9e71f8SBrooks Davis setup_routes 918e9e71f8SBrooks Davis fi 928e9e71f8SBrooks Davis fi 938e9e71f8SBrooks Davis 942c615e1aSHiroki Sato # XXX: IPv6 setup should be done in some way. 95721d95b6SBrooks Davis} 968e9e71f8SBrooks Davis 97721d95b6SBrooks Davispccard_ether_stop() 98721d95b6SBrooks Davis{ 998e9e71f8SBrooks Davis if [ -n "`ifconfig_getargs $ifn`" ]; then 1008e9e71f8SBrooks Davis if ! dhcpif $ifn; then 1018e9e71f8SBrooks Davis remove_routes 1028e9e71f8SBrooks Davis fi 1038e9e71f8SBrooks Davis fi 1048e9e71f8SBrooks Davis 105b0640498SMike Makonnen /etc/rc.d/netif quietstop $ifn 1068e9e71f8SBrooks Davis 1078e9e71f8SBrooks Davis # clean ARP table 1084e7ff69aSBrooks Davis ifexists $ifn && arp -d -i $ifn -a 109721d95b6SBrooks Davis} 110721d95b6SBrooks Davis 111721d95b6SBrooks Davispccard_ether_restart() 112721d95b6SBrooks Davis{ 113721d95b6SBrooks Davis # Hand implemented because the default implementation runs 114721d95b6SBrooks Davis # the equivalent of "$0 start; $0 stop" and this script 115721d95b6SBrooks Davis # doesn't support that syntax 116721d95b6SBrooks Davis pccard_ether_stop 117721d95b6SBrooks Davis pccard_ether_start 118721d95b6SBrooks Davis} 119721d95b6SBrooks Davis 120e5607910SGleb Smirnoffpccard_ether_startchildren() 121e5607910SGleb Smirnoff{ 122e5607910SGleb Smirnoff for child in `get_if_var $ifn wlans_IF`; do 1237d3a36a8SAndriy Voskoboinyk if ifexists $child; then 1247d3a36a8SAndriy Voskoboinyk continue 1257d3a36a8SAndriy Voskoboinyk fi 126e5607910SGleb Smirnoff /etc/rc.d/netif quietstart $child 127e5607910SGleb Smirnoff done 128e5607910SGleb Smirnoff} 129e5607910SGleb Smirnoff 130e5607910SGleb Smirnoffpccard_ether_stopchildren() 131e5607910SGleb Smirnoff{ 132e5607910SGleb Smirnoff for child in `get_if_var $ifn wlans_IF`; do 133e5607910SGleb Smirnoff /etc/rc.d/netif quietstop $child 134e5607910SGleb Smirnoff done 135e5607910SGleb Smirnoff} 136e5607910SGleb Smirnoff 137721d95b6SBrooks Davisifn=$1 138721d95b6SBrooks Davisshift 139721d95b6SBrooks Davisif [ -z "$*" ]; then 140721d95b6SBrooks Davis args="start" 141721d95b6SBrooks Daviselse 142721d95b6SBrooks Davis args=$* 143721d95b6SBrooks Davisfi 144721d95b6SBrooks Davis 145721d95b6SBrooks Davisload_rc_config pccard_ether 146fa020d40SNick Hibmaload_rc_config network 147721d95b6SBrooks Davisrun_rc_command $args 148