1 *0696600cSBjoern A. Zeeb#!/bin/sh - 2 *0696600cSBjoern A. Zeeb# 3 *0696600cSBjoern A. Zeeb# 4 *0696600cSBjoern A. Zeeb# pccard_ether interfacename [start|stop|restart] 5 *0696600cSBjoern A. Zeeb# 6 *0696600cSBjoern A. Zeeb# example: pccard_ether fxp0 start 7 *0696600cSBjoern A. Zeeb# 8 *0696600cSBjoern A. Zeeb 9 *0696600cSBjoern A. Zeeb. /etc/rc.subr 10 *0696600cSBjoern A. Zeeb. /etc/network.subr 11 *0696600cSBjoern A. Zeeb 12 *0696600cSBjoern A. Zeebname="pccard_ether" 13 *0696600cSBjoern A. Zeebstart_precmd="checkauto" 14 *0696600cSBjoern A. Zeebstart_cmd="pccard_ether_start" 15 *0696600cSBjoern A. Zeebstop_precmd="checkauto" 16 *0696600cSBjoern A. Zeebstop_cmd="pccard_ether_stop" 17 *0696600cSBjoern A. Zeebrestart_precmd="checkauto" 18 *0696600cSBjoern A. Zeebrestart_cmd="pccard_ether_restart" 19 *0696600cSBjoern A. Zeebstartchildren_cmd="pccard_ether_startchildren" 20 *0696600cSBjoern A. Zeebstopchildren_cmd="pccard_ether_stopchildren" 21 *0696600cSBjoern A. Zeebextra_commands="startchildren stopchildren" 22 *0696600cSBjoern A. Zeeb 23 *0696600cSBjoern A. Zeebsetup_routes() 24 *0696600cSBjoern A. Zeeb{ 25 *0696600cSBjoern A. Zeeb # Add default route into $static_routes 26 *0696600cSBjoern A. Zeeb case ${defaultrouter} in 27 *0696600cSBjoern A. Zeeb [Nn][Oo] | '') 28 *0696600cSBjoern A. Zeeb ;; 29 *0696600cSBjoern A. Zeeb *) 30 *0696600cSBjoern A. Zeeb static_routes="default ${static_routes}" 31 *0696600cSBjoern A. Zeeb route_default="default ${defaultrouter}" 32 *0696600cSBjoern A. Zeeb ;; 33 *0696600cSBjoern A. Zeeb esac 34 *0696600cSBjoern A. Zeeb 35 *0696600cSBjoern A. Zeeb # Add private route for this interface into $static_routes 36 *0696600cSBjoern A. Zeeb eval ifx_routes=\$static_routes_${ifn} 37 *0696600cSBjoern A. Zeeb if [ -n "${ifx_routes}" ]; then 38 *0696600cSBjoern A. Zeeb static_routes="${ifx_routes} ${static_routes}" 39 *0696600cSBjoern A. Zeeb fi 40 *0696600cSBjoern A. Zeeb 41 *0696600cSBjoern A. Zeeb # Set up any static routes if specified 42 *0696600cSBjoern A. Zeeb if [ -n "${static_routes}" ]; then 43 *0696600cSBjoern A. Zeeb for i in ${static_routes}; do 44 *0696600cSBjoern A. Zeeb eval route_args=\$route_${i} 45 *0696600cSBjoern A. Zeeb route add ${route_args} 46 *0696600cSBjoern A. Zeeb done 47 *0696600cSBjoern A. Zeeb fi 48 *0696600cSBjoern A. Zeeb} 49 *0696600cSBjoern A. Zeeb 50 *0696600cSBjoern A. Zeebremove_routes() 51 *0696600cSBjoern A. Zeeb{ 52 *0696600cSBjoern A. Zeeb # Delete static route if specified 53 *0696600cSBjoern A. Zeeb eval ifx_routes=\$static_routes_${ifn} 54 *0696600cSBjoern A. Zeeb if [ -n "${ifx_routes}" ]; then 55 *0696600cSBjoern A. Zeeb for i in ${ifx_routes}; do 56 *0696600cSBjoern A. Zeeb eval route_args=\$route_${i} 57 *0696600cSBjoern A. Zeeb route delete ${route_args} 58 *0696600cSBjoern A. Zeeb done 59 *0696600cSBjoern A. Zeeb fi 60 *0696600cSBjoern A. Zeeb} 61 *0696600cSBjoern A. Zeeb 62 *0696600cSBjoern A. Zeebcheckauto() 63 *0696600cSBjoern A. Zeeb{ 64 *0696600cSBjoern A. Zeeb if [ -z "$rc_force" ]; then 65 *0696600cSBjoern A. Zeeb # Ignore interfaces with the NOAUTO keyword 66 *0696600cSBjoern A. Zeeb autoif $ifn || exit 0 67 *0696600cSBjoern A. Zeeb fi 68 *0696600cSBjoern A. Zeeb} 69 *0696600cSBjoern A. Zeeb 70 *0696600cSBjoern A. Zeebpccard_ether_start() 71 *0696600cSBjoern A. Zeeb{ 72 *0696600cSBjoern A. Zeeb ifexists $ifn || exit 1 73 *0696600cSBjoern A. Zeeb 74 *0696600cSBjoern A. Zeeb if [ -z "$rc_force" ]; then 75 *0696600cSBjoern A. Zeeb for uif in `ifconfig -ul`; do 76 *0696600cSBjoern A. Zeeb if [ "${uif}" = "${ifn}" ]; then 77 *0696600cSBjoern A. Zeeb # Interface is already up, so ignore it. 78 *0696600cSBjoern A. Zeeb exit 0 79 *0696600cSBjoern A. Zeeb fi 80 *0696600cSBjoern A. Zeeb done 81 *0696600cSBjoern A. Zeeb fi 82 *0696600cSBjoern A. Zeeb 83 *0696600cSBjoern A. Zeeb /etc/rc.d/netif quietstart $ifn 84 *0696600cSBjoern A. Zeeb 85 *0696600cSBjoern A. Zeeb # Do route configuration if needed. 86 *0696600cSBjoern A. Zeeb # XXX: should probably do this by calling rc.d/routing. 87 *0696600cSBjoern A. Zeeb if [ -n "`ifconfig_getargs $ifn`" ]; then 88 *0696600cSBjoern A. Zeeb if ! dhcpif $ifn; then 89 *0696600cSBjoern A. Zeeb setup_routes 90 *0696600cSBjoern A. Zeeb fi 91 *0696600cSBjoern A. Zeeb fi 92 *0696600cSBjoern A. Zeeb 93 *0696600cSBjoern A. Zeeb # XXX: IPv6 setup should be done in some way. 94 *0696600cSBjoern A. Zeeb} 95 *0696600cSBjoern A. Zeeb 96 *0696600cSBjoern A. Zeebpccard_ether_stop() 97 *0696600cSBjoern A. Zeeb{ 98 *0696600cSBjoern A. Zeeb if [ -n "`ifconfig_getargs $ifn`" ]; then 99 *0696600cSBjoern A. Zeeb if ! dhcpif $ifn; then 100 *0696600cSBjoern A. Zeeb remove_routes 101 *0696600cSBjoern A. Zeeb fi 102 *0696600cSBjoern A. Zeeb fi 103 *0696600cSBjoern A. Zeeb 104 *0696600cSBjoern A. Zeeb /etc/rc.d/netif quietstop $ifn 105 *0696600cSBjoern A. Zeeb 106 *0696600cSBjoern A. Zeeb # clean ARP table 107 *0696600cSBjoern A. Zeeb ifexists $ifn && arp -d -i $ifn -a 108 *0696600cSBjoern A. Zeeb} 109 *0696600cSBjoern A. Zeeb 110 *0696600cSBjoern A. Zeebpccard_ether_restart() 111 *0696600cSBjoern A. Zeeb{ 112 *0696600cSBjoern A. Zeeb # Hand implemented because the default implementation runs 113 *0696600cSBjoern A. Zeeb # the equivalent of "$0 start; $0 stop" and this script 114 *0696600cSBjoern A. Zeeb # doesn't support that syntax 115 *0696600cSBjoern A. Zeeb pccard_ether_stop 116 *0696600cSBjoern A. Zeeb pccard_ether_start 117 *0696600cSBjoern A. Zeeb} 118 *0696600cSBjoern A. Zeeb 119 *0696600cSBjoern A. Zeebpccard_ether_startchildren() 120 *0696600cSBjoern A. Zeeb{ 121 *0696600cSBjoern A. Zeeb for child in `get_if_var $ifn wlans_IF`; do 122 *0696600cSBjoern A. Zeeb if ifexists $child; then 123 *0696600cSBjoern A. Zeeb continue 124 *0696600cSBjoern A. Zeeb fi 125 *0696600cSBjoern A. Zeeb /etc/rc.d/netif quietstart $child 126 *0696600cSBjoern A. Zeeb done 127 *0696600cSBjoern A. Zeeb} 128 *0696600cSBjoern A. Zeeb 129 *0696600cSBjoern A. Zeebpccard_ether_stopchildren() 130 *0696600cSBjoern A. Zeeb{ 131 *0696600cSBjoern A. Zeeb for child in `get_if_var $ifn wlans_IF`; do 132 *0696600cSBjoern A. Zeeb /etc/rc.d/netif quietstop $child 133 *0696600cSBjoern A. Zeeb done 134 *0696600cSBjoern A. Zeeb} 135 *0696600cSBjoern A. Zeeb 136 *0696600cSBjoern A. Zeebifn=$1 137 *0696600cSBjoern A. Zeebshift 138 *0696600cSBjoern A. Zeebif [ -z "$*" ]; then 139 *0696600cSBjoern A. Zeeb args="start" 140 *0696600cSBjoern A. Zeebelse 141 *0696600cSBjoern A. Zeeb args=$* 142 *0696600cSBjoern A. Zeebfi 143 *0696600cSBjoern A. Zeeb 144 *0696600cSBjoern A. Zeebload_rc_config pccard_ether 145 *0696600cSBjoern A. Zeebload_rc_config network 146 *0696600cSBjoern A. Zeebrun_rc_command $args 147