pccard_ether revision 179961
10SN/A#!/bin/sh - 22362SN/A# 30SN/A# $FreeBSD: head/etc/pccard_ether 179961 2008-06-23 20:50:11Z mtm $ 40SN/A# 50SN/A# pccard_ether interfacename [start|stop|restart] 60SN/A# 72362SN/A# example: pccard_ether fxp0 start 80SN/A# 92362SN/A 100SN/A. /etc/rc.subr 110SN/A. /etc/network.subr 120SN/A 130SN/Aname="pccard_ether" 140SN/Astart_precmd="checkauto" 150SN/Astart_cmd="pccard_ether_start" 160SN/Astop_precmd="checkauto" 170SN/Astop_cmd="pccard_ether_stop" 180SN/Arestart_precmd="checkauto" 190SN/Arestart_cmd="pccard_ether_restart" 200SN/A 212362SN/Asetup_routes() 222362SN/A{ 232362SN/A # Add default route into $static_routes 240SN/A case ${defaultrouter} in 250SN/A [Nn][Oo] | '') 260SN/A ;; 270SN/A *) 280SN/A static_routes="default ${static_routes}" 290SN/A route_default="default ${defaultrouter}" 300SN/A ;; 310SN/A esac 320SN/A 330SN/A # Add private route for this interface into $static_routes 340SN/A eval ifx_routes=\$static_routes_${ifn} 350SN/A if [ -n "${ifx_routes}" ]; then 360SN/A static_routes="${ifx_routes} ${static_routes}" 370SN/A fi 380SN/A 390SN/A # Set up any static routes if specified 400SN/A if [ -n "${static_routes}" ]; then 410SN/A for i in ${static_routes}; do 420SN/A eval route_args=\$route_${i} 430SN/A route add ${route_args} 440SN/A done 450SN/A fi 460SN/A} 470SN/A 480SN/Aremove_routes() 490SN/A{ 500SN/A # Delete static route if specified 510SN/A eval ifx_routes=\$static_routes_${ifn} 520SN/A if [ -n "${ifx_routes}" ]; then 530SN/A for i in ${ifx_routes}; do 540SN/A eval route_args=\$route_${i} 550SN/A route delete ${route_args} 560SN/A done 570SN/A fi 580SN/A} 590SN/A 600SN/Acheckauto() 610SN/A{ 620SN/A if [ -z "$rc_force" ]; then 630SN/A # Ignore interfaces with the NOAUTO keyword 640SN/A autoif $ifn || exit 0 650SN/A fi 660SN/A} 670SN/A 680SN/Apccard_ether_start() 690SN/A{ 700SN/A ifexists $ifn || exit 1 710SN/A 720SN/A if [ -z "$rc_force" ]; then 730SN/A for uif in `ifconfig -ul`; do 740SN/A if [ "${uif}" = "${ifn}" ]; then 750SN/A # Interface is already up, so ignore it. 760SN/A exit 0 770SN/A fi 780SN/A done 790SN/A fi 800SN/A 810SN/A /etc/rc.d/netif quietstart $ifn 820SN/A 830SN/A # Do route configuration if needed. 840SN/A # XXX: should probably do this by calling rc.d/routing. 850SN/A if [ -n "`ifconfig_getargs $ifn`" ]; then 860SN/A if ! dhcpif $ifn; then 870SN/A setup_routes 88 fi 89 fi 90 91 # XXX: IPv6 setup should be done in some way. 92} 93 94pccard_ether_stop() 95{ 96 if [ -n "`ifconfig_getargs $ifn`" ]; then 97 if ! dhcpif $ifn; then 98 remove_routes 99 fi 100 fi 101 102 /etc/rc.d/netif quietstop $ifn 103 104 # clean ARP table 105 ifexists $ifn && arp -d -i $ifn -a 106} 107 108pccard_ether_restart() 109{ 110 # Hand implemented because the default implementation runs 111 # the equivalent of "$0 start; $0 stop" and this script 112 # doesn't support that syntax 113 pccard_ether_stop 114 pccard_ether_start 115} 116 117ifn=$1 118shift 119if [ -z "$*" ]; then 120 args="start" 121else 122 args=$* 123fi 124 125load_rc_config pccard_ether 126run_rc_command $args 127