head	1.57;
access;
symbols
	RELENG_8_4:1.57.0.2
	RELENG_9_1_0_RELEASE:1.55.4.1.4.2
	RELENG_9_1:1.55.4.1.0.4
	RELENG_9_1_BP:1.55.4.1
	RELENG_8_3_0_RELEASE:1.55.2.1.8.1
	RELENG_8_3:1.55.2.1.0.8
	RELENG_8_3_BP:1.55.2.1
	RELENG_9_0_0_RELEASE:1.55.4.1.2.1
	RELENG_9_0:1.55.4.1.0.2
	RELENG_9_0_BP:1.55.4.1
	RELENG_9:1.55.0.4
	RELENG_9_BP:1.55
	RELENG_7_4_0_RELEASE:1.54.12.1
	RELENG_8_2_0_RELEASE:1.55.2.1.6.1
	RELENG_7_4:1.54.0.12
	RELENG_7_4_BP:1.54
	RELENG_8_2:1.55.2.1.0.6
	RELENG_8_2_BP:1.55.2.1
	RELENG_8_1_0_RELEASE:1.55.2.1.4.1
	RELENG_8_1:1.55.2.1.0.4
	RELENG_8_1_BP:1.55.2.1
	RELENG_7_3_0_RELEASE:1.54.10.1
	RELENG_7_3:1.54.0.10
	RELENG_7_3_BP:1.54
	RELENG_8_0_0_RELEASE:1.55.2.1.2.1
	RELENG_8_0:1.55.2.1.0.2
	RELENG_8_0_BP:1.55.2.1
	RELENG_8:1.55.0.2
	RELENG_8_BP:1.55
	RELENG_7_2_0_RELEASE:1.54.8.1
	RELENG_7_2:1.54.0.8
	RELENG_7_2_BP:1.54
	RELENG_7_1_0_RELEASE:1.54.6.1
	RELENG_6_4_0_RELEASE:1.45.2.5.4.1
	RELENG_7_1:1.54.0.6
	RELENG_7_1_BP:1.54
	RELENG_6_4:1.45.2.5.0.4
	RELENG_6_4_BP:1.45.2.5
	RELENG_7_0_0_RELEASE:1.54
	RELENG_6_3_0_RELEASE:1.45.2.5
	RELENG_7_0:1.54.0.4
	RELENG_7_0_BP:1.54
	RELENG_6_3:1.45.2.5.0.2
	RELENG_6_3_BP:1.45.2.5
	RELENG_7:1.54.0.2
	RELENG_7_BP:1.54
	RELENG_6_2_0_RELEASE:1.45.2.4.2.1
	RELENG_6_2:1.45.2.4.0.2
	RELENG_6_2_BP:1.45.2.4
	RELENG_5_5_0_RELEASE:1.41.2.1
	RELENG_5_5:1.41.2.1.0.4
	RELENG_5_5_BP:1.41.2.1
	RELENG_6_1_0_RELEASE:1.45.2.2
	RELENG_6_1:1.45.2.2.0.2
	RELENG_6_1_BP:1.45.2.2
	RELENG_6_0_0_RELEASE:1.45.2.1
	RELENG_6_0:1.45.2.1.0.2
	RELENG_6_0_BP:1.45.2.1
	RELENG_6:1.45.0.2
	RELENG_6_BP:1.45
	RELENG_5_4_0_RELEASE:1.41.2.1
	RELENG_5_4:1.41.2.1.0.2
	RELENG_5_4_BP:1.41.2.1
	RELENG_4_11_0_RELEASE:1.15.2.11
	RELENG_4_11:1.15.2.11.0.6
	RELENG_4_11_BP:1.15.2.11
	RELENG_5_3_0_RELEASE:1.41
	RELENG_5_3:1.41.0.4
	RELENG_5_3_BP:1.41
	RELENG_5:1.41.0.2
	RELENG_5_BP:1.41
	RELENG_4_10_0_RELEASE:1.15.2.11
	RELENG_4_10:1.15.2.11.0.4
	RELENG_4_10_BP:1.15.2.11
	RELENG_5_2_1_RELEASE:1.38
	RELENG_5_2_0_RELEASE:1.38
	RELENG_5_2:1.38.0.2
	RELENG_5_2_BP:1.38
	RELENG_4_9_0_RELEASE:1.15.2.11
	RELENG_4_9:1.15.2.11.0.2
	RELENG_4_9_BP:1.15.2.11
	RELENG_5_1_0_RELEASE:1.30
	RELENG_5_1:1.30.0.2
	RELENG_5_1_BP:1.30
	RELENG_4_8_0_RELEASE:1.15.2.10
	RELENG_4_8:1.15.2.10.0.8
	RELENG_4_8_BP:1.15.2.10
	RELENG_5_0_0_RELEASE:1.28
	RELENG_5_0:1.28.0.2
	RELENG_5_0_BP:1.28
	RELENG_4_7_0_RELEASE:1.15.2.10
	RELENG_4_7:1.15.2.10.0.6
	RELENG_4_7_BP:1.15.2.10
	RELENG_4_6_2_RELEASE:1.15.2.10
	RELENG_4_6_1_RELEASE:1.15.2.10
	RELENG_4_6_0_RELEASE:1.15.2.10
	RELENG_4_6:1.15.2.10.0.4
	RELENG_4_6_BP:1.15.2.10
	RELENG_4_5_0_RELEASE:1.15.2.10
	RELENG_4_5:1.15.2.10.0.2
	RELENG_4_5_BP:1.15.2.10
	RELENG_4_4_0_RELEASE:1.15.2.9.2.1
	RELENG_4_4:1.15.2.9.0.2
	RELENG_4_4_BP:1.15.2.9
	RELENG_4_3_0_RELEASE:1.15.2.6
	RELENG_4_3:1.15.2.6.0.2
	RELENG_4_3_BP:1.15.2.6
	RELENG_4_2_0_RELEASE:1.15.2.4
	RELENG_4_1_1_RELEASE:1.15.2.3
	PRE_SMPNG:1.17
	RELENG_4_1_0_RELEASE:1.15.2.2
	RELENG_3_5_0_RELEASE:1.9.2.3
	RELENG_4_0_0_RELEASE:1.15
	RELENG_4:1.15.0.2
	RELENG_4_BP:1.15
	RELENG_3_4_0_RELEASE:1.9.2.3
	RELENG_3_3_0_RELEASE:1.9.2.3
	RELENG_3_2_PAO:1.9.2.2.0.2
	RELENG_3_2_PAO_BP:1.9.2.2
	RELENG_3_2_0_RELEASE:1.9.2.2
	RELENG_3_1_0_RELEASE:1.9.2.1
	RELENG_3:1.9.0.2
	RELENG_3_BP:1.9
	RELENG_2_2_8_RELEASE:1.2.4.5
	RELENG_3_0_0_RELEASE:1.9
	RELENG_2_2_7_RELEASE:1.2.4.4
	RELENG_2_2_6_RELEASE:1.2.4.4
	RELENG_2_2_5_RELEASE:1.2.4.1
	RELENG_2_2_2_RELEASE:1.2
	RELENG_2_2_1_RELEASE:1.2
	RELENG_2_2_0_RELEASE:1.2
	RELENG_2_1_7_RELEASE:1.2
	RELENG_2_1_6_1_RELEASE:1.2
	RELENG_2_1_6_RELEASE:1.2
	RELENG_2_2:1.2.0.4
	RELENG_2_2_BP:1.2
	RELENG_2_1_5_RELEASE:1.2
	RELENG_2_1_0:1.2.0.2;
locks; strict;
comment	@# @;


1.57
date	2012.11.17.01.49.02;	author svnexp;	state Exp;
branches
	1.57.2.1;
next	1.56;

1.56
date	2012.11.08.20.34.12;	author n_hibma;	state Exp;
branches;
next	1.55;

1.55
date	2008.06.23.20.50.11;	author mtm;	state Exp;
branches
	1.55.2.1
	1.55.4.1;
next	1.54;

1.54
date	2006.12.08.15.48.42;	author hrs;	state Exp;
branches
	1.54.2.1
	1.54.6.1
	1.54.8.1
	1.54.10.1
	1.54.12.1;
next	1.53;

1.53
date	2006.09.21.01.44.52;	author brooks;	state Exp;
branches;
next	1.52;

1.52
date	2006.09.20.19.48.31;	author brooks;	state Exp;
branches;
next	1.51;

1.51
date	2006.09.20.19.45.30;	author brooks;	state Exp;
branches;
next	1.50;

1.50
date	2006.08.18.13.19.45;	author brooks;	state Exp;
branches;
next	1.49;

1.49
date	2006.08.17.03.03.38;	author brooks;	state Exp;
branches;
next	1.48;

1.48
date	2005.10.03.18.20.44;	author brooks;	state Exp;
branches;
next	1.47;

1.47
date	2005.09.28.19.59.18;	author brooks;	state Exp;
branches;
next	1.46;

1.46
date	2005.08.24.01.23.49;	author brooks;	state Exp;
branches;
next	1.45;

1.45
date	2005.06.16.18.08.04;	author brooks;	state Exp;
branches
	1.45.2.1;
next	1.44;

1.44
date	2005.06.07.04.49.11;	author brooks;	state Exp;
branches;
next	1.43;

1.43
date	2005.01.17.11.44.30;	author ceri;	state Exp;
branches;
next	1.42;

1.42
date	2005.01.04.16.52.15;	author ceri;	state Exp;
branches;
next	1.41;

1.41
date	2004.06.06.11.46.27;	author schweikh;	state Exp;
branches
	1.41.2.1;
next	1.40;

1.40
date	2004.03.05.08.49.59;	author rse;	state Exp;
branches;
next	1.39;

1.39
date	2004.01.25.19.52.16;	author ambrisko;	state Exp;
branches;
next	1.38;

1.38
date	2003.09.15.18.27.38;	author mbr;	state Exp;
branches;
next	1.37;

1.37
date	2003.08.12.22.44.48;	author mbr;	state Exp;
branches;
next	1.36;

1.36
date	2003.08.12.22.27.08;	author mbr;	state Exp;
branches;
next	1.35;

1.35
date	2003.08.12.20.22.44;	author mbr;	state Exp;
branches;
next	1.34;

1.34
date	2003.08.12.15.15.34;	author mbr;	state Exp;
branches;
next	1.33;

1.33
date	2003.08.11.20.32.00;	author mbr;	state Exp;
branches;
next	1.32;

1.32
date	2003.06.16.09.11.29;	author maxim;	state Exp;
branches;
next	1.31;

1.31
date	2003.06.07.19.40.54;	author ume;	state Exp;
branches;
next	1.30;

1.30
date	2003.05.12.11.36.49;	author ume;	state Exp;
branches;
next	1.29;

1.29
date	2003.05.05.19.06.46;	author ume;	state Exp;
branches;
next	1.28;

1.28
date	2002.12.12.09.31.09;	author imp;	state Exp;
branches;
next	1.27;

1.27
date	2002.12.11.23.30.34;	author imp;	state Exp;
branches;
next	1.26;

1.26
date	2001.09.13.06.18.07;	author imp;	state Exp;
branches;
next	1.25;

1.25
date	2001.05.09.20.30.55;	author ume;	state Exp;
branches;
next	1.24;

1.24
date	2001.04.26.17.33.36;	author ume;	state Exp;
branches;
next	1.23;

1.23
date	2000.12.25.09.21.18;	author toshi;	state Exp;
branches;
next	1.22;

1.22
date	2000.12.17.08.15.57;	author dougb;	state Exp;
branches;
next	1.21;

1.21
date	2000.10.28.14.31.40;	author joe;	state Exp;
branches;
next	1.20;

1.20
date	2000.10.16.19.11.10;	author joe;	state Exp;
branches;
next	1.19;

1.19
date	2000.10.16.19.03.48;	author joe;	state Exp;
branches;
next	1.18;

1.18
date	2000.09.07.03.06.06;	author ume;	state Exp;
branches;
next	1.17;

1.17
date	2000.07.17.12.33.57;	author ume;	state Exp;
branches;
next	1.16;

1.16
date	2000.04.27.08.43.47;	author sheldonh;	state Exp;
branches;
next	1.15;

1.15
date	2000.02.11.14.49.42;	author nsayer;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	99.09.13.15.44.18;	author sheldonh;	state Exp;
branches;
next	1.13;

1.13
date	99.08.27.23.23.43;	author peter;	state Exp;
branches;
next	1.12;

1.12
date	99.08.25.16.01.33;	author sheldonh;	state Exp;
branches;
next	1.11;

1.11
date	99.02.22.02.55.18;	author steve;	state Exp;
branches;
next	1.10;

1.10
date	99.02.10.18.08.16;	author jkh;	state Exp;
branches;
next	1.9;

1.9
date	98.09.02.01.34.56;	author brian;	state Exp;
branches
	1.9.2.1;
next	1.8;

1.8
date	98.08.14.06.31.58;	author phk;	state Exp;
branches;
next	1.7;

1.7
date	97.12.17.01.57.18;	author pst;	state Exp;
branches;
next	1.6;

1.6
date	97.12.16.02.25.36;	author pst;	state Exp;
branches;
next	1.5;

1.5
date	97.11.20.22.31.11;	author nate;	state Exp;
branches;
next	1.4;

1.4
date	97.11.19.18.51.25;	author nate;	state Exp;
branches;
next	1.3;

1.3
date	97.06.30.19.10.50;	author jkh;	state Exp;
branches;
next	1.2;

1.2
date	96.04.24.00.04.10;	author nate;	state Exp;
branches
	1.2.4.1;
next	1.1;

1.1
date	96.03.12.15.39.22;	author nate;	state Exp;
branches;
next	;

1.57.2.1
date	2012.11.17.01.49.02;	author svnexp;	state dead;
branches;
next	1.57.2.2;

1.57.2.2
date	2013.03.28.13.02.41;	author svnexp;	state Exp;
branches;
next	;

1.55.2.1
date	2009.08.03.08.13.06;	author kensmith;	state Exp;
branches
	1.55.2.1.2.1
	1.55.2.1.4.1
	1.55.2.1.6.1
	1.55.2.1.8.1;
next	1.55.2.2;

1.55.2.2
date	2012.11.17.10.35.56;	author svnexp;	state Exp;
branches;
next	1.55.2.3;

1.55.2.3
date	2012.11.17.11.21.01;	author svnexp;	state Exp;
branches;
next	;

1.55.2.1.2.1
date	2009.10.25.01.10.29;	author kensmith;	state Exp;
branches;
next	;

1.55.2.1.4.1
date	2010.06.14.02.09.06;	author kensmith;	state Exp;
branches;
next	;

1.55.2.1.6.1
date	2010.12.21.17.09.25;	author kensmith;	state Exp;
branches;
next	;

1.55.2.1.8.1
date	2012.03.03.06.15.13;	author kensmith;	state Exp;
branches;
next	1.55.2.1.8.2;

1.55.2.1.8.2
date	2012.11.17.08.24.37;	author svnexp;	state Exp;
branches;
next	;

1.55.4.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches
	1.55.4.1.2.1
	1.55.4.1.4.1;
next	1.55.4.2;

1.55.4.2
date	2012.11.17.11.36.10;	author svnexp;	state Exp;
branches;
next	1.55.4.3;

1.55.4.3
date	2012.11.17.12.30.46;	author svnexp;	state Exp;
branches;
next	;

1.55.4.1.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.55.4.1.2.2;

1.55.4.1.2.2
date	2012.11.17.08.36.10;	author svnexp;	state Exp;
branches;
next	;

1.55.4.1.4.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.55.4.1.4.2;

1.55.4.1.4.2
date	2012.11.17.08.47.00;	author svnexp;	state Exp;
branches;
next	;

1.54.2.1
date	2012.11.17.08.01.15;	author svnexp;	state Exp;
branches;
next	;

1.54.6.1
date	2008.11.25.02.59.29;	author kensmith;	state Exp;
branches;
next	;

1.54.8.1
date	2009.04.15.03.14.26;	author kensmith;	state Exp;
branches;
next	;

1.54.10.1
date	2010.02.10.00.26.20;	author kensmith;	state Exp;
branches;
next	;

1.54.12.1
date	2010.12.21.17.10.29;	author kensmith;	state Exp;
branches;
next	1.54.12.2;

1.54.12.2
date	2012.11.17.08.16.36;	author svnexp;	state Exp;
branches;
next	;

1.45.2.1
date	2005.09.10.17.05.04;	author brooks;	state Exp;
branches;
next	1.45.2.2;

1.45.2.2
date	2005.12.10.02.11.07;	author brooks;	state Exp;
branches;
next	1.45.2.3;

1.45.2.3
date	2006.08.22.19.41.49;	author brooks;	state Exp;
branches;
next	1.45.2.4;

1.45.2.4
date	2006.09.26.02.17.43;	author brooks;	state Exp;
branches
	1.45.2.4.2.1;
next	1.45.2.5;

1.45.2.5
date	2006.12.08.15.52.25;	author hrs;	state Exp;
branches
	1.45.2.5.4.1;
next	1.45.2.6;

1.45.2.6
date	2012.11.17.07.39.02;	author svnexp;	state Exp;
branches;
next	;

1.45.2.4.2.1
date	2006.12.08.15.53.40;	author hrs;	state Exp;
branches;
next	;

1.45.2.5.4.1
date	2008.10.02.02.57.24;	author kensmith;	state Exp;
branches;
next	;

1.41.2.1
date	2005.01.30.13.22.03;	author ceri;	state Exp;
branches;
next	;

1.15.2.1
date	2000.05.28.19.17.15;	author asmodai;	state Exp;
branches;
next	1.15.2.2;

1.15.2.2
date	2000.07.18.20.50.57;	author ume;	state Exp;
branches;
next	1.15.2.3;

1.15.2.3
date	2000.09.15.16.40.07;	author ume;	state Exp;
branches;
next	1.15.2.4;

1.15.2.4
date	2000.10.30.02.42.04;	author joe;	state Exp;
branches;
next	1.15.2.5;

1.15.2.5
date	2001.01.14.09.47.47;	author dougb;	state Exp;
branches;
next	1.15.2.6;

1.15.2.6
date	2001.02.04.04.41.34;	author toshi;	state Exp;
branches;
next	1.15.2.7;

1.15.2.7
date	2001.05.06.15.08.52;	author ume;	state Exp;
branches;
next	1.15.2.8;

1.15.2.8
date	2001.05.28.15.07.37;	author ume;	state Exp;
branches;
next	1.15.2.9;

1.15.2.9
date	2001.08.24.19.47.05;	author nate;	state Exp;
branches
	1.15.2.9.2.1;
next	1.15.2.10;

1.15.2.10
date	2001.09.14.17.28.11;	author imp;	state Exp;
branches;
next	1.15.2.11;

1.15.2.11
date	2003.06.23.07.29.26;	author maxim;	state Exp;
branches;
next	1.15.2.12;

1.15.2.12
date	2012.11.17.07.22.36;	author svnexp;	state Exp;
branches;
next	;

1.15.2.9.2.1
date	2001.09.14.17.32.25;	author imp;	state Exp;
branches;
next	;

1.9.2.1
date	99.02.10.18.08.38;	author jkh;	state Exp;
branches;
next	1.9.2.2;

1.9.2.2
date	99.02.22.02.56.08;	author steve;	state Exp;
branches
	1.9.2.2.2.1;
next	1.9.2.3;

1.9.2.3
date	99.08.29.14.18.52;	author peter;	state Exp;
branches;
next	;

1.9.2.2.2.1
date	99.06.22.02.08.48;	author imp;	state Exp;
branches;
next	;

1.2.4.1
date	97.06.30.19.01.03;	author jkh;	state Exp;
branches;
next	1.2.4.2;

1.2.4.2
date	97.11.19.18.53.36;	author nate;	state Exp;
branches;
next	1.2.4.3;

1.2.4.3
date	97.11.20.22.32.55;	author nate;	state Exp;
branches;
next	1.2.4.4;

1.2.4.4
date	97.12.17.01.57.57;	author pst;	state Exp;
branches;
next	1.2.4.5;

1.2.4.5
date	98.09.03.22.14.37;	author brian;	state Exp;
branches;
next	1.2.4.6;

1.2.4.6
date	99.09.05.11.01.57;	author peter;	state Exp;
branches;
next	;


desc
@@


1.57
log
@Switching exporter and resync
@
text
@#!/bin/sh -
#
# $FreeBSD: head/etc/pccard_ether 242784 2012-11-08 20:34:12Z n_hibma $
#
# pccard_ether interfacename [start|stop|restart]
#
# example: pccard_ether fxp0 start
#

. /etc/rc.subr
. /etc/network.subr

name="pccard_ether"
start_precmd="checkauto"
start_cmd="pccard_ether_start"
stop_precmd="checkauto"
stop_cmd="pccard_ether_stop"
restart_precmd="checkauto"
restart_cmd="pccard_ether_restart"

setup_routes()
{
	# Add default route into $static_routes
	case ${defaultrouter} in
	[Nn][Oo] | '')
		;;
	*)
		static_routes="default ${static_routes}"
		route_default="default ${defaultrouter}"
		;;
	esac

	# Add private route for this interface into $static_routes
	eval ifx_routes=\$static_routes_${ifn}
	if [ -n "${ifx_routes}" ]; then
		static_routes="${ifx_routes} ${static_routes}"
	fi

	# Set up any static routes if specified
	if [ -n "${static_routes}" ]; then
		for i in ${static_routes}; do
			eval route_args=\$route_${i}
			route add ${route_args}
		done
	fi
}

remove_routes()
{
	# Delete static route if specified
	eval ifx_routes=\$static_routes_${ifn}
	if [ -n "${ifx_routes}" ]; then
		for i in ${ifx_routes}; do
			eval route_args=\$route_${i}
			route delete ${route_args}
		done
	fi
}

checkauto()
{
	if [ -z "$rc_force" ]; then
		# Ignore interfaces with the NOAUTO keyword
		autoif $ifn || exit 0
	fi
}

pccard_ether_start()
{
	ifexists $ifn || exit 1

	if [ -z "$rc_force" ]; then
		for uif in `ifconfig -ul`; do
			if [ "${uif}" = "${ifn}" ]; then
				# Interface is already up, so ignore it.
				exit 0
			fi
		done
	fi

	/etc/rc.d/netif quietstart $ifn

	# Do route configuration if needed.
	# XXX: should probably do this by calling rc.d/routing.
	if [ -n "`ifconfig_getargs $ifn`" ]; then
		if ! dhcpif $ifn; then
			setup_routes
		fi
	fi

	# XXX: IPv6 setup should be done in some way.
}

pccard_ether_stop()
{
	if [ -n "`ifconfig_getargs $ifn`" ]; then
		if ! dhcpif $ifn; then
			remove_routes
		fi
	fi

	/etc/rc.d/netif quietstop $ifn

	# clean ARP table
	ifexists $ifn && arp -d -i $ifn -a
}

pccard_ether_restart()
{
	# Hand implemented because the default implementation runs
	# the equivalent of "$0 start; $0 stop" and this script
	# doesn't support that syntax
	pccard_ether_stop
	pccard_ether_start
}

ifn=$1
shift
if [ -z "$*" ]; then
	args="start"
else
	args=$*
fi

load_rc_config pccard_ether
load_rc_config network
run_rc_command $args
@


1.57.2.1
log
@file pccard_ether was added on branch RELENG_8_4 on 2013-03-28 13:02:41 +0000
@
text
@d1 127
@


1.57.2.2
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/248810
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a0 127
#!/bin/sh -
#
# $FreeBSD: releng/8.4/etc/pccard_ether 243087 2012-11-15 15:49:37Z n_hibma $
#
# pccard_ether interfacename [start|stop|restart]
#
# example: pccard_ether fxp0 start
#

. /etc/rc.subr
. /etc/network.subr

name="pccard_ether"
start_precmd="checkauto"
start_cmd="pccard_ether_start"
stop_precmd="checkauto"
stop_cmd="pccard_ether_stop"
restart_precmd="checkauto"
restart_cmd="pccard_ether_restart"

setup_routes()
{
	# Add default route into $static_routes
	case ${defaultrouter} in
	[Nn][Oo] | '')
		;;
	*)
		static_routes="default ${static_routes}"
		route_default="default ${defaultrouter}"
		;;
	esac

	# Add private route for this interface into $static_routes
	eval ifx_routes=\$static_routes_${ifn}
	if [ -n "${ifx_routes}" ]; then
		static_routes="${ifx_routes} ${static_routes}"
	fi

	# Set up any static routes if specified
	if [ -n "${static_routes}" ]; then
		for i in ${static_routes}; do
			eval route_args=\$route_${i}
			route add ${route_args}
		done
	fi
}

remove_routes()
{
	# Delete static route if specified
	eval ifx_routes=\$static_routes_${ifn}
	if [ -n "${ifx_routes}" ]; then
		for i in ${ifx_routes}; do
			eval route_args=\$route_${i}
			route delete ${route_args}
		done
	fi
}

checkauto()
{
	if [ -z "$rc_force" ]; then
		# Ignore interfaces with the NOAUTO keyword
		autoif $ifn || exit 0
	fi
}

pccard_ether_start()
{
	ifexists $ifn || exit 1

	if [ -z "$rc_force" ]; then
		for uif in `ifconfig -ul`; do
			if [ "${uif}" = "${ifn}" ]; then
				# Interface is already up, so ignore it.
				exit 0
			fi
		done
	fi

	/etc/rc.d/netif quietstart $ifn

	# Do route configuration if needed.
	# XXX: should probably do this by calling rc.d/routing.
	if [ -n "`ifconfig_getargs $ifn`" ]; then
		if ! dhcpif $ifn; then
			setup_routes
		fi
	fi

	# XXX: IPv6 setup should be done in some way.
}

pccard_ether_stop()
{
	if [ -n "`ifconfig_getargs $ifn`" ]; then
		if ! dhcpif $ifn; then
			remove_routes
		fi
	fi

	/etc/rc.d/netif quietstop $ifn

	# clean ARP table
	ifexists $ifn && arp -d -i $ifn -a
}

pccard_ether_restart()
{
	# Hand implemented because the default implementation runs
	# the equivalent of "$0 start; $0 stop" and this script
	# doesn't support that syntax
	pccard_ether_stop
	pccard_ether_start
}

ifn=$1
shift
if [ -z "$*" ]; then
	args="start"
else
	args=$*
fi

load_rc_config pccard_ether
load_rc_config network
run_rc_command $args
@


1.56
log
@SVN rev 242784 on 2012-11-08 20:34:12Z by n_hibma

Not only load pccard_ether settings, also load network settings. This
is only a problem when a /etc/rc.conf.d/network file is being used.

PR:		conf/160373
Submitted by:	n_hibma
MFC after:	1 week
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.55
log
@SVN rev 179961 on 2008-06-23 20:50:11Z by mtm

Implement a "quiet" mode for rc.d/netif, which only outputs
the interface name of interfaces that were configured.

This change has the added benefit that ifn_start() and
ifn_stop() in network.subr no longer write to standard output.
Whether to output and what to output is now handled entirely
in rc.d/netif.
@
text
@d126 1
@


1.55.4.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.55.4.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d3 1
a3 1
# $FreeBSD: stable/9/etc/pccard_ether 179961 2008-06-23 20:50:11Z mtm $
@


1.55.4.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 243086
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r243086 | n_hibma | 2012-11-15 15:48:40 +0000 (Thu, 15 Nov 2012) | 7 lines
## SVN ##
## SVN ## MFC r242784:
## SVN ##   Not only load pccard_ether settings, also load network settings. This
## SVN ##   is only a problem when a /etc/rc.conf.d/network file is being used.
## SVN ##
## SVN ##   PR:		conf/160373
## SVN ##   Submitted by:	n_hibma
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d3 1
a3 1
# $FreeBSD: stable/9/etc/pccard_ether 243086 2012-11-15 15:48:40Z n_hibma $
a125 1
load_rc_config network
@


1.55.4.1.4.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.55.4.1.4.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/9.1/etc/pccard_ether 179961 2008-06-23 20:50:11Z mtm $
@


1.55.4.1.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.55.4.1.2.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/9.0/etc/pccard_ether 179961 2008-06-23 20:50:11Z mtm $
@


1.55.2.1
log
@SVN rev 196045 on 2009-08-03 08:13:06Z by kensmith

Copy head to stable/8 as part of 8.0 Release cycle.

Approved by:	re (Implicit)
@
text
@@


1.55.2.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242909
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242909 | dim | 2012-11-12 07:47:19 +0000 (Mon, 12 Nov 2012) | 20 lines
## SVN ##
## SVN ## MFC r242625:
## SVN ##
## SVN ## Remove duplicate const specifiers in many drivers (I hope I got all of
## SVN ## them, please let me know if not).  Most of these are of the form:
## SVN ##
## SVN ## static const struct bzzt_type {
## SVN ##       [...list of members...]
## SVN ## } const bzzt_devs[] = {
## SVN ##       [...list of initializers...]
## SVN ## };
## SVN ##
## SVN ## The second const is unnecessary, as arrays cannot be modified anyway,
## SVN ## and if the elements are const, the whole thing is const automatically
## SVN ## (e.g. it is placed in .rodata).
## SVN ##
## SVN ## I have verified this does not change the binary output of a full kernel
## SVN ## build (except for build timestamps embedded in the object files).
## SVN ##
## SVN ## Reviewed by:	yongari, marius
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d3 1
a3 1
# $FreeBSD: stable/8/etc/pccard_ether 179961 2008-06-23 20:50:11Z mtm $
@


1.55.2.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 243087
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r243087 | n_hibma | 2012-11-15 15:49:37 +0000 (Thu, 15 Nov 2012) | 7 lines
## SVN ##
## SVN ## MFC 242784:
## SVN ##   Not only load pccard_ether settings, also load network settings. This
## SVN ##   is only a problem when a /etc/rc.conf.d/network file is being used.
## SVN ##
## SVN ##   PR:		conf/160373
## SVN ##   Submitted by:	n_hibma
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d3 1
a3 1
# $FreeBSD: stable/8/etc/pccard_ether 243087 2012-11-15 15:49:37Z n_hibma $
a125 1
load_rc_config network
@


1.55.2.1.8.1
log
@SVN rev 232438 on 2012-03-03 06:15:13Z by kensmith

Copy stable/8 to releng/8.3 as part of 8.3-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.55.2.1.8.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/8.3/etc/pccard_ether 179961 2008-06-23 20:50:11Z mtm $
@


1.55.2.1.6.1
log
@SVN rev 216617 on 2010-12-21 17:09:25Z by kensmith

Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.

Approved by:	re (implicit)
@
text
@@


1.55.2.1.4.1
log
@SVN rev 209145 on 2010-06-14 02:09:06Z by kensmith

Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.

Approved by:	re (implicit)
@
text
@@


1.55.2.1.2.1
log
@SVN rev 198460 on 2009-10-25 01:10:29Z by kensmith

Copy stable/8 to releng/8.0 as part of 8.0-RELEASE release procedure.

Approved by:	re (implicit)
@
text
@@


1.54
log
@Disable IPv6 configuration for interfaces in pccard_ether_start().

After a change of devd.conf, devd(8) handles NIC attach/detach event
by using /etc/pccard_ether with the interface name as the argument.
This model does not work properly with IPv6 configuration because the
implementation of IPv6 stateless auto-configuration in the FreeBSD
rc.d scripts depends on whether there are any explicit configurations
for interfaces or not.  It works this way: if no manual configuration,
it will perform auto-configuration, but otherwise no
auto-configuration will be performed.  So, this behavior can only be
determined by all of the interfaces on a system, not a single one.
For this reason, the network6_interface_setup() function called from
the pccard_ether_start() does not work with a single interface name.
And what is worse, this combination of devd.conf and
pccard_ether_start() caused a bad side-effect that when
ipv6_enable=YES, all of interfaces marked as DOWN would be UP
unconditionally (and router solicitation was sent) just after devd(8)
was invoked.  This should be fixed in a more sophisticated way.
@
text
@d81 1
a81 1
	/etc/rc.d/netif start $ifn
d102 1
a102 1
	/etc/rc.d/netif stop $ifn
@


1.54.2.1
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: stable/7/etc/pccard_ether 165011 2006-12-08 15:48:42Z hrs $
@


1.54.12.1
log
@SVN rev 216618 on 2010-12-21 17:10:29Z by kensmith

Copy stable/7 to releng/7.4 in preparation for FreeBSD-7.4 release.

Approved by:	re (implicit)
@
text
@@


1.54.12.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/7.4/etc/pccard_ether 165011 2006-12-08 15:48:42Z hrs $
@


1.54.10.1
log
@SVN rev 203736 on 2010-02-10 00:26:20Z by kensmith

Copy stable/7 to releng/7.3 as part of the 7.3-RELEASE process.

Approved by:	re (implicit)
@
text
@@


1.54.8.1
log
@SVN rev 191087 on 2009-04-15 03:14:26Z by kensmith

Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.

Approved by:	re (implicit)
@
text
@@


1.54.6.1
log
@SVN rev 185281 on 2008-11-25 02:59:29Z by kensmith

Create releng/7.1 in preparation for moving into RC phase of 7.1 release
cycle.

Approved by:	re (implicit)
@
text
@@


1.53
log
@Introduce a new method ipv6if which attemptes to figure out if an
interface is an IPv6 interface.

Use this method to decide if we should attempt to configure an interface
with an IPv6 address in pccard_ether.  The mechanism pccard_ether uses
to do this is unsuited to the task because it assumes the list of
interfaces it is passed is the full list of IPv6 interfaces and makes
decissions based on that.  This is at least a step in the right
direction and is probably about as much as we can MFC safely.

PR:		conf/103428
MFC after:	3 days
@
text
@d91 1
a91 8
	# IPv6 setup
	if ipv6if $ifn; then
		# XXX: network6_interface_setup assumes you're calling
		# it with ALL the IPv6 interfaces at once and thus isn't
		# really appropraite for this job, but it's the best we've
		# got for now.
		network6_interface_setup $ifn
	fi
@


1.52
log
@Flushing all IPv4 routes when an interface is removed or unconfigured
makes no sense.  Remove the undocumented removable_route_flush feature
from pccard_ether.

X-MFC after:	never
@
text
@d92 5
a96 1
	if checkyesno ipv6_enable; then
@


1.51
log
@Search the list of up interfaces provided by "ifconfig -ul" instead of
greping for UP in "ifconfig $ifn".  This eliminates a dependancy on
/usr.
@
text
@a108 5

	# Clean the routing table
	if checkyesno removable_route_flush; then
		route -n flush -inet > /dev/null
	fi
@


1.50
log
@Don't try to start interfaces that don't exist.

Reported by:    Dominique Goncalves <dominique.goncalves at gmail.com>
@
text
@d72 7
a78 5
	if [ -z "$rc_force" -a -x /usr/bin/grep ]; then
		if ifconfig $ifn | grep -s '[<,]UP[,>]' > /dev/null 2>&1; then
		    # Interface is already up, so ignore it.
		    exit 0
		fi
@


1.49
log
@Introduce a new function, ifexists and use it to avoid attempting to
touch interfaces that don't actually exist in the stop case.  In the
process move some IPv4 specific code from ifconfig_down to ipv4_down.

This should solve problems with ifconfig: error messages on boot when
interfaces are renamed.
@
text
@d70 2
@


1.48
log
@Use more rc.subr bits to clean up pccard_ether and implement new
features.  Both the presence of a NOAUTO keyword and an interface being
up can be ignored is the forcestart option is used.  Additionally, a
restart option has been added.

Reviewed by:	ume
@
text
@d104 1
a104 1
	arp -d -a
@


1.47
log
@Be less IPv4 centric.  When checking if the interface is already
configured, check if the UP flag is set instead of checking for the
netmask keyword.
@
text
@d5 1
a5 1
# pccard_ether interfacename [start|stop]
d13 7
a19 4
usage()
{
	err 3 'USAGE: $0 interface (start|stop)'
}
d60 7
a66 4
ifn=$1
shift
startstop=$1
shift
d68 3
a70 12
load_rc_config pccard_ether

# Ignore interfaces with the NOAUTO keyword
autoif $ifn || exit 0

if [ -n "$1" ]; then
	usage
fi

case ${startstop} in
[Ss][Tt][Aa][Rr][Tt] | '')
	if [ -x /usr/bin/grep ]; then
d91 1
a91 1
	;;
d93 2
a94 2
# Stop the interface
[Ss][Tt][Oo][Pp])
d110 21
a130 4
	;;
*)
	usage
esac
@


1.46
log
@- Remove the removable_interfaces variable.  /etc/pccard_ether will
  now run on any interface.
- Add a new ifconfig_<ifn> keyword, NOAUTO which prevents configuration
  of an interface at boot or via /etc/pccard_ether.  This allows
  /etc/rc.d/netif to be used to start and stop an interface on a purely
  manual basis.  The decision to affect pccard_ether may be revisited at
  a later date.

Requested by:	imp, gallatin (removable_interfaces)
Discussed with:	sam, Randy Bush (NOAUTO)
@
text
@d74 1
a74 1
		if ifconfig $ifn | grep -s netmask > /dev/null 2>&1; then
@


1.45
log
@Make sure we actually read the config files before testing values from
them.

Reported by:	Darren Pilgrim <dmp at bitfreak dot org>
PR:		conf/82313
Approved by:	re (network interface startup blanket)
@
text
@d64 2
a65 2
# Ignore interfaces not in removable_interfaces
expr "${removable_interfaces}" : ".*${ifn}" > /dev/null || exit 0
@


1.45.2.1
log
@Sync network interface startup code with HEAD.

etc/network.subr: 1.165-1.167
 - kill removable_interfaces
 - add NOAUTO keyword
 - fix quoted entries in ifconfig_<ifn> variables
 - always up the interface
 - if ifconfig_<ifn> is defined, but empty, don't set it to
   ifconfig_DEFAULT
 - always configure lo0 first if it exists
etc/pccard_ether: 1.46
 - kill removable_interfaces
 - add NOAUTO keyword
etc/rc.d/netif: 1.15-1.17
 - block Ctrl-C in dhclient
 - minor cleanup of the interface list generation code

Approved by:	re (scottl)
Requested by:	many (death to removable_interfaces!)
@
text
@d64 2
a65 2
# Ignore interfaces with the NOAUTO keyword
autoif $ifn || exit 0
@


1.45.2.2
log
@MFC 1.47 and 1.48:

1.47:	Be less IPv4 centric.  When checking if the interface is
	already configured, check if the UP flag is set instead of
	checking for the netmask keyword.

1.48:	Use more rc.subr bits to clean up pccard_ether and implement
	new features.  Both the presence of a NOAUTO keyword and an
	interface being up can be ignored is the forcestart option
	is used.  Additionally, a restart option has been added.
@
text
@d5 1
a5 1
# pccard_ether interfacename [start|stop|restart]
d13 4
a16 7
name="pccard_ether"
start_precmd="checkauto"
start_cmd="pccard_ether_start"
stop_precmd="checkauto"
stop_cmd="pccard_ether_stop"
restart_precmd="checkauto"
restart_cmd="pccard_ether_restart"
d57 13
a69 7
checkauto()
{
	if [ -z "$rc_force" ]; then
		# Ignore interfaces with the NOAUTO keyword
		autoif $ifn || exit 0
	fi
}
d71 4
a74 4
pccard_ether_start()
{
	if [ -z "$rc_force" -a -x /usr/bin/grep ]; then
		if ifconfig $ifn | grep -s '[<,]UP[,>]' > /dev/null 2>&1; then
d94 1
a94 1
}
d96 2
a97 2
pccard_ether_stop()
{
d113 4
a116 21
}

pccard_ether_restart()
{
	# Hand implemented because the default implementation runs
	# the equivalent of "$0 start; $0 stop" and this script
	# doesn't support that syntax
	pccard_ether_stop
	pccard_ether_start
}

ifn=$1
shift
if [ -z "$*" ]; then
	args="start"
else
	args=$*
fi

load_rc_config pccard_ether
run_rc_command $args
@


1.45.2.3
log
@MFC: sync /etc/network.subr and /etc/pccard_ether and their defaults
with HEAD.  Key changes include:
 - Support a limited set of punctuation in interface names ".-/+" by
   converting them to '_' before looking up interface variables.
 - Don't flush routes by default when an interface is removed.
 - Don't generate unnecessicary noise on startup when interfaces are
   renamed.

PR:		  conf/92433
@
text
@a69 2
	ifexists $ifn || exit 1

d104 1
a104 1
	ifexists $ifn && arp -d -i $ifn -a
@


1.45.2.4
log
@MFC

pccard_ether rev 1.51:
    Search the list of up interfaces provided by "ifconfig -ul" instead of
    greping for UP in "ifconfig $ifn".  This eliminates a dependancy on /usr.

pccard_ether rev 1.53 and network.subr rev 1.173:
  Introduce a new method ipv6if which attemptes to figure out if an
  interface is an IPv6 interface.

  Use this method to decide if we should attempt to configure an interface
  with an IPv6 address in pccard_ether.  The mechanism pccard_ether uses
  to do this is unsuited to the task because it assumes the list of
  interfaces it is passed is the full list of IPv6 interfaces and makes
  decissions based on that.  This is at least a step in the right
  direction and is probably about as much as we can MFC safely.

PR:		conf/103428
Approved by:	re (hrs)
@
text
@d72 5
a76 7
	if [ -z "$rc_force" ]; then
		for uif in `ifconfig -ul`; do
			if [ "${uif}" = "${ifn}" ]; then
				# Interface is already up, so ignore it.
				exit 0
			fi
		done
d90 1
a90 5
	if ipv6if $ifn; then
		# XXX: network6_interface_setup assumes you're calling
		# it with ALL the IPv6 interfaces at once and thus isn't
		# really appropraite for this job, but it's the best we've
		# got for now.
@


1.45.2.4.2.1
log
@MFC: Disable IPv6 configuration for interfaces in pccard_ether_start().

 After a change of devd.conf, devd(8) handles NIC attach/detach event
 by using /etc/pccard_ether with the interface name as the argument.
 This model does not work properly with IPv6 configuration because the
 implementation of IPv6 stateless auto-configuration in the FreeBSD
 rc.d scripts depends on whether there are any explicit configurations
 for interfaces or not.  It works this way: if no manual configuration,
 it will perform auto-configuration, but otherwise no
 auto-configuration will be performed.  So, this behavior can only be
 determined by all of the interfaces on a system, not a single one.
 For this reason, the network6_interface_setup() function called from
 the pccard_ether_start() does not work with a single interface name.
 And what is worse, this combination of devd.conf and
 pccard_ether_start() caused a bad side-effect that when
 ipv6_enable=YES, all of interfaces marked as DOWN would be UP
 unconditionally (and router solicitation was sent) just after devd(8)
 was invoked.  This should be fixed in a more sophisticated way.

Approved by:	re (kensmith)
@
text
@d91 8
a98 1
	# XXX: IPv6 setup should be done in some way.
@


1.45.2.5
log
@MFC: Disable IPv6 configuration for interfaces in pccard_ether_start().

 After a change of devd.conf, devd(8) handles NIC attach/detach event
 by using /etc/pccard_ether with the interface name as the argument.
 This model does not work properly with IPv6 configuration because the
 implementation of IPv6 stateless auto-configuration in the FreeBSD
 rc.d scripts depends on whether there are any explicit configurations
 for interfaces or not.  It works this way: if no manual configuration,
 it will perform auto-configuration, but otherwise no
 auto-configuration will be performed.  So, this behavior can only be
 determined by all of the interfaces on a system, not a single one.
 For this reason, the network6_interface_setup() function called from
 the pccard_ether_start() does not work with a single interface name.
 And what is worse, this combination of devd.conf and
 pccard_ether_start() caused a bad side-effect that when
 ipv6_enable=YES, all of interfaces marked as DOWN would be UP
 unconditionally (and router solicitation was sent) just after devd(8)
 was invoked.  This should be fixed in a more sophisticated way.
@
text
@d91 8
a98 1
	# XXX: IPv6 setup should be done in some way.
@


1.45.2.6
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: stable/6/etc/pccard_ether 200489 2009-12-14 00:12:07Z dougb $
@


1.45.2.5.4.1
log
@SVN rev 183531 on 2008-10-02 02:57:24Z by kensmith

Create releng/6.4 from stable/6 in preparation for 6.4-RC1.

Approved by:	re (implicit)
@
text
@@


1.44
log
@Support code for the OpenBSD dhclient.  This significantly changes the
way interfaces are configured.  Some key points:

  - At startup, all interfaces are configured through /etc/rc.d/netif.
  - ifconfig_<if> variables my now mix real ifconfig commands the with
    DHCP and WPA directives.  For example, this allows media
    configuration prior to running dhclient.
  - /etc/rc.d/dhclient is not run at startup except by netif to start
    dhclient on specific interfaces.
  - /etc/pccard_ether calls "/etc/rc.d/netif start <if>" to do most of
    it's work.
  - /etc/pccard_ether no longer takes additional arguments to pass to
    ifconfig.  Instead, ifconfig_<if> variables are now honored in favor
    of pccard_ifconfig when available.
  - /etc/pccard_ether will only run on interfaces specified in
    removable_interfaces, even if pccard_ifconfig is set.
@
text
@a17 12
ifn=$1
shift
startstop=$1
shift

# Ignore interfaces not in removable_interfaces
expr "${removable_interfaces}" : ".*${ifn}" > /dev/null || exit 0

if [ -n "$1" ]; then
	usage
fi

d57 5
d64 7
@


1.43
log
@The submitter of bin/75786 turned out to not have removable interfaces,
and so the fix committed in r1.42 was not quite correct for the case
where there are two or more DHCP consuming removable interfaces - dhclient
must be restarted so that the other interfaces continue to function
correctly.

Approved by:	murray
MFC After:	7 days
@
text
@d5 1
a5 1
# pccard_ether interfacename [start|stop] [ifconfig option]
d7 1
a7 1
# example: pccard_ether fxp0 start link0
d10 1
d13 12
a24 13
stop_dhcp() {
	# If dhclient is already running, record
	# its interfaces.
	if [ -x /usr/bin/grep ]; then
		eval _active_list=\"`/bin/ps -axwww | \
			/usr/bin/grep dhclient | \
			/usr/bin/grep -v grep | \
			/usr/bin/sed -e 's|^.*dhclient||' | \
			/usr/bin/awk '{for (i=1;i<=NF;i++) \
				{ if ($i~/[a-zA-Z].[0-9]$/) \
				{ printf(" %s",$i) } }}'` \
			\"
	fi
d26 3
a28 2
	# Get the rc.conf list of dhcp configured interfaces
	static_dhcp_list="`list_net_interfaces dhcp`"
d30 5
a34 48
	# Get the current ifconfig list of interfaces
	_aprefix=
	_nlist=
	for _if in ${_active_list} ; do
		_test_if=`ifconfig ${_if} 2>&1`
		case "$_test_if" in
		"ifconfig: interface $_if does not exist")
			;;
		${interface})
			# Don't record the same device twice.
			;;
		*)
			#
			# Catch devices which were specified before,
			# but have not been part of the rc. We need
			# them again for the restart.
			#
			for _cif in ${static_dhcp_list} ; do
				case "$_cif" in
				${_if})
					# Nothing to add
					;;
				*)
					# Found interface beside rc.conf
					_nlist="${_nlist}${_aprefix}${_if}"
					;;
				esac
			done
			_dhcplist="${_dhcplist}${_aprefix}${_if}"
			[ -z "$_aprefix" ] && _aprefix=' '
			;;
		esac
	done

	if [ -s /var/run/dhclient.pid ]; then
		pidfile="/var/run/dhclient.pid"
	else
		return
	fi
	/sbin/dhclient -r ${interface}
	rm -f ${pidfile}
	case ${startstop} in
	[Ss][Tt][Oo][Pp])
		if [ -z "${_nlist}" ]; then
			sh /etc/rc.d/dhclient start
		else
			start_dhcp_keep_current
		fi
d37 2
a40 1
}
d42 12
a53 16
start_dhcp() {
	stop_dhcp
	case ${pccard_ether_delay} in
	[Nn][Oo])
		;;
	[0-9]*)
		sleep ${pccard_ether_delay}
		;;
        esac
	[ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
	[ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
	if [ -x "${dhclient_program}" ]; then
		interfaces=`echo $_dhcplist ${interface} | xargs -n 1 echo | sort -u`
		${dhclient_program} ${dhclient_flags}  ${interfaces}
	else
		echo "${dhclient_program}: DHCP client software not available"
d57 9
a65 10
# Called after detaching a card, if dhclient has been
# used for more than one interface.
start_dhcp_keep_current() {
	[ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
	[ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
	if [ -x "${dhclient_program}" ]; then
		${dhclient_program} ${dhclient_flags} \
			${_dhcplist}
	else
		echo "${dhclient_program}: DHCP client software not available"
d69 1
a69 23
# Suck in the configuration variables
#
if [ -r /etc/defaults/rc.conf ]; then
	. /etc/defaults/rc.conf
	source_rc_confs
elif [ -r /etc/rc.conf ]; then
	. /etc/rc.conf
fi

interface=$1
shift
startstop=$1
shift

case ${pccard_ifconfig} in
[Nn][Oo] | '')
	expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0
	;;
*)
	# Backward compatible
	eval ifconfig_${interface}=\${pccard_ifconfig}
	;;
esac
d74 1
a74 1
		if ifconfig ${interface} | grep -s netmask > /dev/null 2>&1; then
d80 1
a80 3
	if [ -r /etc/start_if.${interface} ]; then
		. /etc/start_if.${interface}
	fi
d82 5
a86 45
	eval ifconfig_args=\$ifconfig_${interface}
	case ${ifconfig_args} in
	[Nn][Oo] | '')
		;;
	[Dd][Hh][Cc][Pp])
		# Start up the DHCP client program
		start_dhcp
		;;
	*)
		# Do the primary ifconfig if specified
		ifconfig ${interface} ${ifconfig_args} $*

		# Check to see if aliases need to be added
		alias=0
		while :
		do
			eval ifx_args=\$ifconfig_${interface}_alias${alias}
			if [ -n "${ifx_args}" ]; then
				ifconfig ${interface} ${ifx_args} alias
				alias=`expr ${alias} + 1`
			else
				break;
			fi
		done

		# Do ipx address if specified
		eval ifx_args=\$ifconfig_${interface}_ipx
		if [ -n "${ifx_args}" ]; then
			ifconfig ${interface} ${ifx_args}
		fi

		# Add default route into $static_routes
		case ${defaultrouter} in
		[Nn][Oo] | '')
		        ;;
		*)
			static_routes="default ${static_routes}"
			route_default="default ${defaultrouter}"
			;;
		esac

		# Add private route for this interface into $static_routes
		eval ifx_routes=\$static_routes_${interface}
		if [ -n "${ifx_routes}" ]; then
			static_routes="${ifx_routes} ${static_routes}"
d88 1
a88 10

		# Set up any static routes if specified
		if [ -n "${static_routes}" ]; then
			for i in ${static_routes}; do
				eval route_args=\$route_${i}
				route add ${route_args}
			done
		fi
		;;
	esac
d91 3
a93 8
	case ${ipv6_enable} in
	[Yy][Ee][Ss])
		if [ -r /etc/network.subr ]; then
			. /etc/network.subr
			network6_interface_setup ${interface}
		fi
		;;
	esac
d95 1
d97 5
a101 3
*)
	if [ -r /etc/stop_if.${interface} ]; then
		. /etc/stop_if.${interface}
d104 1
a104 32
	eval ifconfig_args=\$ifconfig_${interface}
	case ${ifconfig_args} in
	[Nn][Oo] | '')
	        ;;
	[Dd][Hh][Cc][Pp])
		# Stop the DHCP client for this interface
		stop_dhcp
		;;
	*)
		# Delete static route if specified
		eval ifx_routes=\$static_routes_${interface}
		if [ -n "${ifx_routes}" ]; then
			for i in ${ifx_routes}; do
				eval route_args=\$route_${i}
				route delete ${route_args}
			done
		fi

		# Delete aliases if exist
		alias=0
		while :
		do
			eval ifx_args=\$ifconfig_${interface}_alias${alias}
			if [ -n "${ifx_args}" ]; then
				ifconfig ${interface} ${ifx_args} alias delete
				alias=`expr ${alias} + 1`
			else
				break;
			fi
		done
		;;
	esac
d106 1
a106 2
	# Remove the network interface and cleaning ARP table
	ifconfig ${interface} delete
d110 3
a112 8
	case ${removable_route_flush} in
	[Nn][Oo])
	        ;;
	*)
		# flush beforehand, just in case....
		route -n flush -inet
		;;
	esac
d114 2
@


1.42
log
@Correct syntactical weirdness in a call to /etc/rc.d/dhclient. Fixes:

PR:		bin/75786
Reported by:	Radko Keves <rado at daemon dot sk>
Approved by:	murray
MFC After:	5 days	( to RELENG_5 )
@
text
@d73 1
a73 1
			sh /etc/rc.d/dhclient stop
@


1.41
log
@Removed whitespace at BOF, EOL & EOF.
@
text
@d73 1
a73 1
			sh `/etc/rc.d/dhclient start`
@


1.41.2.1
log
@MFC the result of revisions 1.42 and 1.43:

	Fix syntax error encountered with two DHCP consuming removable
	interfaces.

Approved by:	murray
@
text
@d73 1
a73 1
			sh /etc/rc.d/dhclient start
@


1.40
log
@remove superfluous space before end of backtick expression
@
text
@d266 1
a266 1
	*)	
@


1.39
log
@- Existing code would ignore pccard_ether_delay when more then 9 seconds
- If there was an exiting dhclient running on the same interface as the
  new iface that left and returned then dhclient would be told to use the
  same interface twice.  Dhclient would fail and exit after getting
  confused.  Use "sort -u" on them to ensure no duplicates.
  This is a mostly a race condition on suspend and resume and how things
  happen to occur.
- Check for netmask being set on an interface rather then up.  An interface
  can be up but not configured.

Reviewed by:	mbr
@
text
@d95 1
a95 1
		interfaces=`echo $_dhcplist ${interface} | xargs -n 1 echo | sort -u `
@


1.38
log
@Release a previous lease if there is any, instead of
just killing dhclient. Needed my some broken dhcpd
implementations to be able to get a lease again.
@
text
@d88 1
a88 1
	[0-9])
d95 2
a96 1
		${dhclient_program} ${dhclient_flags}  $_dhcplist ${interface}
d142 1
a142 1
		if ifconfig ${interface} | grep -s UP, > /dev/null 2>&1; then
@


1.37
log
@Move the stop_dhcp in start_dhcp again before the
delay. It seems that dhclient really needs the time
to get killed.
@
text
@d68 1
a68 1
	kill `cat ${pidfile}`
@


1.36
log
@Remove the dhclient.${interface}.pid defines. They are now
obsolete. A working dhclient with OMAPI will also not need
this.
@
text
@d84 1
a91 1
	stop_dhcp
@


1.35
log
@Make this working with two or more pccards and with more than
one internal device. Don't call the startup procedure again if
we already use start.

Support a manually started dhclient and keep its configured
interfaces after pccard removal.

Make pccard_ether working in single-user mode without /usr mounted.
@
text
@d63 1
a63 5
	if [ -s /var/run/dhclient.${interface}.pid ]; then
		pidfile="/var/run/dhclient.${interface}.pid"
	elif [ -s /var/run/dhcpc.${interface}.pid ]; then
		pidfile="/var/run/dhcpc.${interface}.pid"
	elif [ -s /var/run/dhclient.pid ]; then
a94 4
		if [ `basename ${dhclient_program}` = "dhclient" ]; then
			pidfile="/var/run/dhclient.${interface}.pid"
			dhclient_flags="${dhclient_flags} -pf ${pidfile}"
		fi
@


1.34
log
@Fix typo
@
text
@d10 2
d13 50
a67 26
		# If dhclient is already running, record
		# it's interfaces.
		if [ -x /usr/bin/grep ]; then
			eval _active_list=\"`/bin/ps -axwww | \
				/usr/bin/grep dhclient | \
				/usr/bin/grep -v grep | \
				/usr/bin/sed -e 's|^.*dhclient||' | \
				/usr/bin/awk '{for (i=1;i<=NF;i++) \
					{ if ($i~/[a-zA-Z].[0-9]$/) \
					{ printf(" %s",$i) } }}'` \
				\"
		fi

		_aprefix=
		for _if in ${_active_list} ; do
			_test_if=`ifconfig ${_if} 2>&1`
			case "$_test_if" in
			"ifconfig: interface $_if does not exist")
				;;
			*)
				_dhcplist="${_dhcplist}${_aprefix}${_if}"
				[ -z "$_aprefix" ] && _aprefix=' '
				;;
			esac
		done

d74 11
a84 1
	sh `/etc/rc.d/dhclient start`
a87 1
	stop_dhcp
d95 1
d103 14
a116 1
		${dhclient_program} ${dhclient_flags} $_dhcplist ${interface}
d148 5
a152 3
	if ifconfig ${interface} | grep -s UP, > /dev/null 2>&1; then
	    # Interface is already up, so ignore it.
	    exit 0
@


1.33
log
@Improve the handling dhcp handling of pccard_ether.

There are now many configurations which have a NIC on board, and
pccard slots. If a dhclient is running on the internal nic, the
Improve the handling dhcp handling of pccard_ether.

Improve the dhcp handling of pccard_ether.

There are now many configurations which have a NIC on board and
Improve the dhcp handling of pccard_ether.

There are now many configurations which have a NIC on board and
cardbus slots too. If a dhclient was already running on the internal
NIC, the user was forced to kill a running dhclient manually.

If now a pccard is included at startup time, /etc/rc.d/dhclient
start does include it into the startup list for dhcp devices.
That means you can now do dhcp on the internal and the pccard devices
at the same time. If the card is plugged in later, a running dhclient
(working for the internal interface only) is killed, and restarted,
but the interface name of the new pccard is added to the internal
name. After removal, /etc/rc.d/dhclient is started again. This
script does nothing if there are no devices in /etc/rc.conf

This is only a workaround for a well known problem. After we have
a dhcp client which handles device adding and removal, it will go
away.
@
text
@d30 1
a30 1
		for _if in _active_list ; do
@


1.32
log
@o Correct usage example: ep(4) does not have 'link0' option.
o Fix a typo.

PR:		misc/51955
Submitted by:	Xander <x+freebsd-gnats@@surfnet.nl>
MFC after:	1 week
@
text
@d15 28
d48 1
d67 1
a67 1
		${dhclient_program} ${dhclient_flags} ${interface}
@


1.31
log
@follow dhcp_* changes.
@
text
@d7 1
a7 1
# example: pccard_ether ep0 start -link0
d161 1
a161 1
		# Delelte static route if specified
@


1.30
log
@pccard_ether didn't setup IPv6 after rcTOS sweep.

Reviewed by:	mtm and dougb
Approved by:	re (scott)
@
text
@d31 4
a34 2
	if [ -x "${dhcp_program}" ]; then
		if [ `basename ${dhcp_program}` = "dhclient" ]; then
d36 1
a36 1
			dhcp_flags="${dhcp_flags} -pf ${pidfile}"
d38 1
a38 1
		${dhcp_program} ${dhcp_flags} ${interface}
d40 1
a40 1
		echo "${dhcp_program}: DHCP client software not available"
@


1.29
log
@use /etc/rc.d/network_ipv6 instead of obsoleted /etc/rc.network6.
@
text
@d137 2
a138 2
		if [ -r /etc/rc.d/network_ipv6 ]; then
			. /etc/rc.d/network_ipv6
@


1.28
log
@o redirect the grep to /dev/null
o use ifn rather than interface in rc.network
o merge into rc.d/network1

Approved by: (re blanket)
@
text
@d137 2
a138 2
		if [ -r /etc/rc.network6 ]; then
			. /etc/rc.network6
@


1.27
log
@o Don't do anything if the interface is already up.
o Only delay in pccard_ether when we're doing dhcp and starting the interface.

Approved: (re blanket for devd)
@
text
@d68 1
a68 1
	if ifconfig ${interface} | grep -s UP,; then
@


1.26
log
@Due to a bug in the ed driver, which leads to hangs when using it with
dhclient and pccard_ether, introduce the concept of a "settle time" to
pccard_ether with the new pccard_ether_delay variable.  Defaults to 5
seconds, which is enough time for the ed driver to finish its
autoconfiguration for newer Linksys based cards.  This also can
eliminate the ed0: timeout messages that happen at startup as well.

MFC: after RE says OK.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.25 2001/05/09 20:30:55 ume Exp $
d24 7
a55 11
case ${pccard_ether_delay} in
[Nn][Oo])
	;;
[0-9])
	sleep ${pccard_ether_delay}
	;;
*)	# Default until it has had a chance to make it to /etc/defaults/rc.conf
	sleep 5
	;;
esac

d68 5
@


1.25
log
@Avoid flushing IPv6 routes.  `route flush' removes necessary
routes for IPv6 as well as IPv4 routes.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.24 2001/04/26 17:33:36 ume Exp $
d48 11
@


1.24
log
@Enable static IPv6 address assignment on PCMCIA NIC.

PR:		conf/26633
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.23 2000/12/25 09:21:18 toshi Exp $
d181 1
a181 1
		route -n flush
@


1.23
log
@Add support for PC-card router configuration. (MFPAO)

o Add the removable_interfaces variable for list of removable network
  interfaces (PC-card ethernet, wireless network and USB ethernet etc).
o ifconfig_<ifn>_alias0, static_routes_<ifn>, removable_route_flush,
  /etc/start_if.<ifn> and /etc/stop_if.<ifn> are support.
o removable_route_flush variable is set to "NO" if you want to use the
  machine as gateway using two or more removable network cards. If
  static routing is needed use static_routes_<ifn> instead of
  static_routes or defaultrouter.
o The optional static_routes_<ifn> variable is likely static_routes.
o /etc/start_if.<ifn> and /etc/stop_if.<ifn> are shell script to be
  specified that are called when a card is inserted or removed.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.22 2000/12/17 08:15:57 dougb Exp $
d125 4
a128 10
		case ${ipv6_gateway_enable} in
		[Yy][Ee][Ss])
			;;
		*)
			sysctl -w net.inet6.ip6.forwarding=0
			sysctl -w net.inet6.ip6.accept_rtadv=1
			ifconfig ${interface} up
			rtsol ${interface}
			;;
		esac
@


1.22
log
@Apply a more consistent style to the echo statements in /etc/ scripts.
* Put quotes around each line
* Single quotes for lines with no variable interpolation
* Double quotes if there is
* Capitalize each word that begins a line
* Make echo -n 'Doing foo:' ... echo '.' more of a standard

No functionality changes
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.21 2000/10/28 14:31:40 joe Exp $
d11 1
a11 1
	if [ -r /sbin/dhclient ]; then
d13 1
a13 5
		if [ -s ${pidfile} ]; then
			kill `cat ${pidfile}`
			rm ${pidfile}
		fi
	elif [ -r /usr/local/sbin/dhcpc ]; then
d15 2
a16 4
		if [ -s ${pidfile} ]; then
			kill `cat ${pidfile}`
			rm ${pidfile}
		fi
d18 2
d24 6
a29 5
	if [ -r /sbin/dhclient ]; then
		pidfile="/var/run/dhclient.${interface}.pid"
		/sbin/dhclient -pf ${pidfile} $interface
	elif [ -r /usr/local/sbin/dhcpc ]; then
		/usr/local/sbin/dhcpc $interface
d31 1
a31 1
		echo 'DHCP client software not available (isc-dhcp2)'
d49 10
d61 6
a66 1
	case ${pccard_ifconfig} in
d70 1
d74 37
a110 3
		ifconfig ${interface} ${pccard_ifconfig} $*
		;;
	esac
d112 7
a118 6
	case ${defaultrouter} in
	[Nn][Oo] | '')
		;;
	*)
		static_routes="default ${static_routes}"
		route_default="default ${defaultrouter}"
a121 12
	# Set up any static routes.
	#
	if [ -n "${static_routes}" ]; then
		# flush beforehand, just in case....
		route -n flush
		arp -d -a
		for i in ${static_routes}; do
			eval route_args=\$route_${i}
			route add ${route_args}
		done
	fi

d140 50
a189 2
	/sbin/ifconfig ${interface} delete
	stop_dhcp
@


1.21
log
@Fix a blatant bug when running '/etc/pccard_ether device stop'.
I wasn't dropping the interface correctly, but not noticing because
the interface was going away when the card was ejected.

Submitted by:	Motomichi Matsuzaki <mzaki@@e-mail.ne.jp>
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.20 2000/10/16 19:11:10 joe Exp $
d34 1
a34 1
		echo "DHCP client software not available (isc-dhcp2)"
@


1.20
log
@Add an optional start/stop argument to pccard_ether, and migrate
the 'ifconfig ifN delete' into pccard_ether under the 'stop'
function.

In addition start dhclient with a pid file based on the interface
name, e.g. /var/run/dhclient.ep0.pid, and kill the correct dhclient
(or dhcpc) process when the card is removed.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.19 2000/10/16 19:03:48 joe Exp $
d49 1
a49 1
startstop=$2
d104 1
a104 1
	/sbin/ifconfig $device delete
@


1.19
log
@Avoid passing the optional ifconfig arguments to dhcpc as well as ifconfig.
This bug has been here since revision 1.8.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.18 2000/09/07 03:06:06 ume Exp $
d5 1
a5 1
# pccard_ether interfacename [ifconfig option]
d7 1
a7 1
# example: pccard_ether ep0 -link0
d10 28
d49 2
d52 12
a63 24
case ${pccard_ifconfig} in
[Nn][Oo] | '')
        ;;
[Dd][Hh][Cc][Pp])
	if [ -r /sbin/dhclient ]; then
		if [ -s /var/run/dhclient.pid ]; then
			kill `cat /var/run/dhclient.pid`
			rm /var/run/dhclient.pid
		fi
		/sbin/dhclient $interface
	elif [ -r /usr/local/sbin/dhcpc ]; then
		if [ -s /var/run/dhcpc.pid ]; then
			kill `cat /var/run/dhcpc.pid`
			rm /var/run/dhcpc.pid
		fi
		/usr/local/sbin/dhcpc $interface
	else
		echo "DHCP client software not available (isc-dhcp2)"
	fi
	;;
*)
	ifconfig ${interface} ${pccard_ifconfig} $*
	;;
esac
d65 8
a72 8
case ${defaultrouter} in
[Nn][Oo] | '')
        ;;
*)
	static_routes="default ${static_routes}"
	route_default="default ${defaultrouter}"
	;;
esac
d74 11
a84 11
# Set up any static routes.
#
if [ -n "${static_routes}" ]; then
	# flush beforehand, just in case....
        route -n flush
	arp -d -a
	for i in ${static_routes}; do
		eval route_args=\$route_${i}
		route add ${route_args}
	done
fi
d86 2
a87 4
# IPv6 setup
case ${ipv6_enable} in
[Yy][Ee][Ss])
	case ${ipv6_gateway_enable} in
d89 10
a98 6
		;;
	*)
		sysctl -w net.inet6.ip6.forwarding=0
		sysctl -w net.inet6.ip6.accept_rtadv=1
		ifconfig ${interface} up
		rtsol ${interface}
d101 5
@


1.18
log
@Make sure to accept RA.  Some laptops run /etc/pccard_ether before
/etc/rc.network6.

PR:		bin/21062
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.17 2000/07/17 12:33:57 ume Exp $
d37 1
a37 1
		/usr/local/sbin/dhcpc $interface $*
@


1.17
log
@If ipv6_enable is set to yes, do IPv6 setup for PCCARD ethernet
card.  This is still at staring point and end node case only.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.16 2000/04/27 08:43:47 sheldonh Exp $
d75 2
@


1.16
log
@Add to defaults/rc.conf a new function source_rc_confs which rc
scripts may use to source safely overrides in ${rc_conf_files}
files.

This protects users who insist on the bad practice of copying
/etc/defaults/rc.conf to /etc/rc.conf from a recursive loop
that exhausts available file descriptors.

Several people have expressed interest in breaking this function
out into its own shell script.  Anyone who wants to embark on
such an undertaking would do well to study the attributed PR.

PR:		17595
Reported by:	adrian
Submitted by:	Doug Barton <Doug@@gorean.org>
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15 2000/02/11 14:49:42 nsayer Exp $
d67 14
@


1.15
log
@When running dhclient on a PC-Card insertion, specify the inserted
interface on the dhclient command line. Not doing so screws up vmware's
network interface by attempting to configure it for DHCP (which will
never work, of course). It also would impact any other interface that
may be present that, again, would likely be manually configured for
some other purpose.

Approved by: jkh
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.14 1999/09/13 15:44:18 sheldonh Exp $
d14 1
@


1.15.2.1
log
@MFC:	- add source_rc_confs

Reminded of, while working on the readline MFC, by:
	Mike Harding <mvh@@ix.netcom.com>
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15 2000/02/11 14:49:42 nsayer Exp $
a13 1
	source_rc_confs
@


1.15.2.2
log
@MFC: (rev 1.16 -> 1.17) If ipv6_enable is set to yes, do IPv6 setup
for PCCARD ethernet card.  This is still at staring point and end
node case only.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.1 2000/05/28 19:17:15 asmodai Exp $
a66 14

# IPv6 setup
case ${ipv6_enable} in
[Yy][Ee][Ss])
	case ${ipv6_gateway_enable} in
	[Yy][Ee][Ss])
		;;
	*)
		ifconfig ${interface} up
		rtsol ${interface}
		;;
	esac
	;;
esac
@


1.15.2.3
log
@MFC rev 1.17 -> 1.18: Make sure to accept RA.  Some laptops run
/etc/pccard_ether before /etc/rc.network6.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.2 2000/07/18 20:50:57 ume Exp $
a74 2
		sysctl -w net.inet6.ip6.forwarding=0
		sysctl -w net.inet6.ip6.accept_rtadv=1
@


1.15.2.4
log
@MFC: Revisions 1.19 - 1.21

For reference:

o Add an optional start/stop argument to pccard_ether to allow
  pccard_ether to bring an interface down as well as up.
o Start the dhcp client with a pid file based on the interface name,
  i.e. /var/run/dbclient.ep0.pid, and use this to kill the dhcp client
  when evoked with a 'stop' argument.
o Stop passing the optional ifconfig arguments to dhcpc as well as
  ifconfig. This bug has been here since revision 1.8.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.3 2000/09/15 16:40:07 ume Exp $
d5 1
a5 1
# pccard_ether interfacename [start|stop] [ifconfig option]
d7 1
a7 1
# example: pccard_ether ep0 start -link0
a9 28
stop_dhcp() {
	if [ -r /sbin/dhclient ]; then
		pidfile="/var/run/dhclient.${interface}.pid"
		if [ -s ${pidfile} ]; then
			kill `cat ${pidfile}`
			rm ${pidfile}
		fi
	elif [ -r /usr/local/sbin/dhcpc ]; then
		pidfile="/var/run/dhcpc.${interface}.pid"
		if [ -s ${pidfile} ]; then
			kill `cat ${pidfile}`
			rm ${pidfile}
		fi
	fi
}

start_dhcp() {
	stop_dhcp
	if [ -r /sbin/dhclient ]; then
		pidfile="/var/run/dhclient.${interface}.pid"
		/sbin/dhclient -pf ${pidfile} $interface
	elif [ -r /usr/local/sbin/dhcpc ]; then
		/usr/local/sbin/dhcpc $interface
	else
		echo "DHCP client software not available (isc-dhcp2)"
	fi
}

a20 2
startstop=$1
shift
d22 24
a45 12
case ${startstop} in
[Ss][Tt][Aa][Rr][Tt] | '')
	case ${pccard_ifconfig} in
	[Nn][Oo] | '')
		;;
	[Dd][Hh][Cc][Pp])
		start_dhcp
		;;
	*)
		ifconfig ${interface} ${pccard_ifconfig} $*
		;;
	esac
d47 8
a54 8
	case ${defaultrouter} in
	[Nn][Oo] | '')
		;;
	*)
		static_routes="default ${static_routes}"
		route_default="default ${defaultrouter}"
		;;
	esac
d56 11
a66 11
	# Set up any static routes.
	#
	if [ -n "${static_routes}" ]; then
		# flush beforehand, just in case....
		route -n flush
		arp -d -a
		for i in ${static_routes}; do
			eval route_args=\$route_${i}
			route add ${route_args}
		done
	fi
d68 4
a71 2
	# IPv6 setup
	case ${ipv6_enable} in
d73 6
a78 10
		case ${ipv6_gateway_enable} in
		[Yy][Ee][Ss])
			;;
		*)
			sysctl -w net.inet6.ip6.forwarding=0
			sysctl -w net.inet6.ip6.accept_rtadv=1
			ifconfig ${interface} up
			rtsol ${interface}
			;;
		esac
a80 5
	;;
# Stop the interface
*)
	/sbin/ifconfig ${interface} delete
	stop_dhcp
@


1.15.2.5
log
@MFC, Apply a more consistent style to the echo statements in /etc/ scripts.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.4 2000/10/30 02:42:04 joe Exp $
d34 1
a34 1
		echo 'DHCP client software not available (isc-dhcp2)'
@


1.15.2.6
log
@MFC (1.23): Add support for PC-card router configuration. (MFPAO)
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.5 2001/01/14 09:47:47 dougb Exp $
d11 1
a11 1
	if [ -s /var/run/dhclient.${interface}.pid ]; then
d13 5
a17 1
	elif [ -s /var/run/dhcpc.${interface}.pid ]; then
d19 4
a22 2
	else
		return
a23 2
	kill `cat ${pidfile}`
	rm -f ${pidfile}
d28 5
a32 6
	if [ -x "${dhcp_program}" ]; then
		if [ `basename ${dhcp_program}` = "dhclient" ]; then
			pidfile="/var/run/dhclient.${interface}.pid"
			dhcp_flags="${dhcp_flags} -pf ${pidfile}"
		fi
		${dhcp_program} ${dhcp_flags} ${interface}
d34 1
a34 1
		echo "${dhcp_program}: DHCP client software not available"
a51 10
case ${pccard_ifconfig} in
[Nn][Oo] | '')
	expr "${removable_interfaces}" : ".*${interface}" > /dev/null || exit 0
	;;
*)
	# Backward compatible
	eval ifconfig_${interface}=\${pccard_ifconfig}
	;;
esac

d54 1
a54 6
	if [ -r /etc/start_if.${interface} ]; then
		. /etc/start_if.${interface}
	fi

	eval ifconfig_args=\$ifconfig_${interface}
	case ${ifconfig_args} in
a57 1
		# Start up the DHCP client program
d61 3
a63 2
		# Do the primary ifconfig if specified
		ifconfig ${interface} ${ifconfig_args} $*
d65 6
a70 42
		# Check to see if aliases need to be added
		alias=0
		while :
		do
			eval ifx_args=\$ifconfig_${interface}_alias${alias}
			if [ -n "${ifx_args}" ]; then
				ifconfig ${interface} ${ifx_args} alias
				alias=`expr ${alias} + 1`
			else
				break;
			fi
		done

		# Do ipx address if specified
		eval ifx_args=\$ifconfig_${interface}_ipx
		if [ -n "${ifx_args}" ]; then
			ifconfig ${interface} ${ifx_args}
		fi

		# Add default route into $static_routes
		case ${defaultrouter} in
		[Nn][Oo] | '')
		        ;;
		*)
			static_routes="default ${static_routes}"
			route_default="default ${defaultrouter}"
			;;
		esac

		# Add private route for this interface into $static_routes
		eval ifx_routes=\$static_routes_${interface}
		if [ -n "${ifx_routes}" ]; then
			static_routes="${ifx_routes} ${static_routes}"
		fi

		# Set up any static routes if specified
		if [ -n "${static_routes}" ]; then
			for i in ${static_routes}; do
				eval route_args=\$route_${i}
				route add ${route_args}
			done
		fi
d74 12
d104 2
a105 50
	if [ -r /etc/stop_if.${interface} ]; then
		. /etc/stop_if.${interface}
	fi

	eval ifconfig_args=\$ifconfig_${interface}
	case ${ifconfig_args} in
	[Nn][Oo] | '')
	        ;;
	[Dd][Hh][Cc][Pp])
		# Stop the DHCP client for this interface
		stop_dhcp
		;;
	*)
		# Delelte static route if specified
		eval ifx_routes=\$static_routes_${interface}
		if [ -n "${ifx_routes}" ]; then
			for i in ${ifx_routes}; do
				eval route_args=\$route_${i}
				route delete ${route_args}
			done
		fi

		# Delete aliases if exist
		alias=0
		while :
		do
			eval ifx_args=\$ifconfig_${interface}_alias${alias}
			if [ -n "${ifx_args}" ]; then
				ifconfig ${interface} ${ifx_args} alias delete
				alias=`expr ${alias} + 1`
			else
				break;
			fi
		done
		;;
	esac

	# Remove the network interface and cleaning ARP table
	ifconfig ${interface} delete
	arp -d -a

	# Clean the routing table
	case ${removable_route_flush} in
	[Nn][Oo])
	        ;;
	*)	
		# flush beforehand, just in case....
		route -n flush
		;;
	esac
@


1.15.2.7
log
@MFC: Enable static IPv6 address assignment on PCMCIA NIC.

	etc/pccard_ether:	1.23->1.24
	etc/rc.network6:	1.17->1.18
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.6 2001/02/04 04:41:34 toshi Exp $
d125 10
a134 4
		if [ -r /etc/rc.network6 ]; then
			. /etc/rc.network6
			network6_interface_setup ${interface}
		fi
@


1.15.2.8
log
@MFC 1.24->1.25: Avoid flushing IPv6 routes.  `route flush' removes necessary
routes for IPv6 as well as IPv4 routes.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.7 2001/05/06 15:08:52 ume Exp $
d181 1
a181 1
		route -n flush -inet
@


1.15.2.9
log
@- Remove use of un-documented 'removable_interface' and
  'removable_route_flush' variables which can cause routing and configuration
  to fail when not using DHCP.

Submitted by:	Toshihiko ARAI <toshi@@jp.FreeBSD.org>,
Reviewed by:	imp
Approved by:	jkh
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.8 2001/05/28 15:07:37 ume Exp $
d51 1
d171 1
a171 1
	# Remove the network interface and clean the ARP table
d174 10
@


1.15.2.9.2.1
log
@MFS: small delay when starting up dhclient to avoid ed hang bug.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.9 2001/08/24 19:47:05 nate Exp $
a47 11

case ${pccard_ether_delay} in
[Nn][Oo])
	;;
[0-9])
	sleep ${pccard_ether_delay}
	;;
*)	# Default until it has had a chance to make it to /etc/defaults/rc.conf
	sleep 5
	;;
esac
@


1.15.2.10
log
@MFC: small delay before launching dhclient.
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.15.2.9 2001/08/24 19:47:05 nate Exp $
a47 11

case ${pccard_ether_delay} in
[Nn][Oo])
	;;
[0-9])
	sleep ${pccard_ether_delay}
	;;
*)	# Default until it has had a chance to make it to /etc/defaults/rc.conf
	sleep 5
	;;
esac
@


1.15.2.11
log
@MFC rev. 1.32: correct usage example, fix a typo.
@
text
@d3 1
a3 1
# $FreeBSD$
d7 1
a7 1
# example: pccard_ether fxp0 start link0
d157 1
a157 1
		# Delete static route if specified
@


1.15.2.12
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: stable/4/etc/pccard_ether 116713 2003-06-23 07:29:26Z maxim $
@


1.14
log
@Apply a consistent style to most of the etc scripts.  Particularly, use
case instead of test where appropriate, since case allows case is a sh
builtin and (as a side-effect) allows case-insensitivity.

Changes discussed on freebsd-hackers.

Submitted by:	Doug Barton <Doug@@gorean.org>
@
text
@d3 1
a3 1
# $FreeBSD: src/etc/pccard_ether,v 1.13 1999/08/27 23:23:43 peter Exp $
d18 3
d30 1
a30 1
		/sbin/dhclient
d36 1
a36 1
		/usr/local/sbin/dhcpc $*
a41 2
	interface=$1
	shift
@


1.13
log
@$Id$ -> $FreeBSD$
@
text
@d3 1
a3 1
# $FreeBSD$
d11 2
a12 1
if [ -f /etc/defaults/rc.conf ]; then
d14 1
a14 1
elif [ -f /etc/rc.conf ]; then
d18 6
a23 4
if [ "${pccard_ifconfig}" != "NO" ] ; then
	if [ "${pccard_ifconfig}" = "DHCP" ] ; then
		if [ -f /sbin/dhclient ] ; then
		    if [ -s /var/run/dhclient.pid ] ; then
a25 10
		    fi
		    /sbin/dhclient
		elif [ -f /usr/local/sbin/dhcpc ] ; then
		    if [ -s /var/run/dhcpc.pid ] ; then
		        kill `cat /var/run/dhcpc.pid`
		        rm /var/run/dhcpc.pid
		    fi
		    /usr/local/sbin/dhcpc $* 
		else
		    echo "DHCP client software not available (isc-dhcp2)"
d27 7
d35 1
a35 3
		interface=$1
		shift
		ifconfig ${interface} ${pccard_ifconfig} $*
d37 7
a43 1
fi
d45 4
a48 1
if [ "${defaultrouter}" != "NO" ] ; then
d51 3
a53 2
fi
    
d55 1
@


1.12
log
@Style clean-up:

	* All variables are now embraced: ${foo}

	* All comparisons against some value now take the form:
	  [ "${foo}" ? "value" ]
	  where ? is a comparison operator

	* All empty string tests now take the form:
	  [ -z "${foo}" ]

	* All non-empty string tests now take the form:
	  [ -n "${foo}" ]

Submitted by:	jkh
@
text
@d3 1
a3 1
#	$Id: pccard_ether,v 1.11 1999/02/22 02:55:18 steve Exp $
@


1.11
log
@dhclient is now in /sbin.
@
text
@d3 1
a3 1
#	$Id: pccard_ether,v 1.10 1999/02/10 18:08:16 jkh Exp $
d17 2
a18 2
if [ "x$pccard_ifconfig" != "xNO" ] ; then
	if [ "x$pccard_ifconfig" = "xDHCP" ] ; then
d37 1
a37 1
		ifconfig $interface $pccard_ifconfig $*
d41 1
a41 1
if [ "x$defaultrouter" != "xNO" ] ; then
d47 1
a47 1
if [ "x${static_routes}" != "x" ]; then
@


1.10
log
@Use /etc/defaults/rc.conf everywhere, falling back to /etc/rc.conf
as necessary (for half-assed upgrades).
@
text
@d3 1
a3 1
#	$Id: pccard_ether,v 1.9 1998/09/02 01:34:56 brian Exp $
d19 1
a19 1
		if [ -f /usr/local/sbin/dhclient ] ; then
d24 1
a24 1
		    /usr/local/sbin/dhclient
@


1.9
log
@Add Id keywords
@
text
@d3 1
a3 1
#	$Id:$
d10 4
a13 2
# Suck in the /etc/rc.conf variables
if [ -f /etc/rc.conf ]; then
@


1.9.2.1
log
@MFC: Use rc.conf from new location.
@
text
@d3 1
a3 1
#	$Id: pccard_ether,v 1.9 1998/09/02 01:34:56 brian Exp $
d10 2
a11 4
# Suck in the configuration variables
if [ -f /etc/defaults/rc.conf ]; then
	. /etc/defaults/rc.conf
elif [ -f /etc/rc.conf ]; then
@


1.9.2.2
log
@MFC: new path for dhclient.
@
text
@d3 1
a3 1
#	$Id: pccard_ether,v 1.9.2.1 1999/02/10 18:08:38 jkh Exp $
d19 1
a19 1
		if [ -f /sbin/dhclient ] ; then
d24 1
a24 1
		    /sbin/dhclient
@


1.9.2.3
log
@$Id$ -> $FreeBSD$
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.9.2.2.2.1
log
@Merge /etc/Makefile from PAO3-19990605 into Makefile.
Merge other changes from said PAO3 version.

Obtained from:	PAO3-19990605.tar.gz
@
text
@d3 2
d7 1
a7 4
# example: pccard_ether ep0 link1
#
# $Id: pccard_ether,v 1.1 1999/03/17 14:55:48 toshi Exp $
# HOSOKAWA, Tatsumi <hosokawa@@jp.FreeBSD.org>
d10 1
a10 1
# Suck in the rc.conf variables
d13 2
d17 14
a30 18
interface=$1
shift

if [ "x$pccard_ether" != "xNO" ]; then
	eval ifconfig_args=\$ifconfig_${interface}
	if [ "x$ifconfig_args" = "xDHCP" ]; then
		if [ -x /usr/local/sbin/dhclient ]; then
			if [ -s /var/run/dhclient.pid ]; then
				kill `cat /var/run/dhclient.pid`
				rm -f /var/run/dhclient.pid
			fi
			/usr/local/sbin/dhclient
		elif [ -x /usr/local/sbin/dhcpc ]; then
			if [ -s /var/run/dhcpc.$interface.pid ]; then
				kill `cat /var/run/dhcpc.$interface.pid`
				rm -f /var/run/dhcpc.$interface.pid
			fi
			/usr/local/sbin/dhcpc $dhcp_flags $interface
d32 1
a32 31
			echo "DHCP client software not available"
		fi
	elif [ -n "$ifconfig_args" ]; then
		# Do the primary ifconfig if specified
		if [ "x$ifconfig_args" != "xNO" ]; then
			ifconfig $interface $ifconfig_args $*
		fi
		# Check to see if aliases need to be added
		alias=0
		while :
		do
			eval ifx_args=\$ifconfig_${interface}_alias${alias}
			if [ -n "$ifx_args" ]; then
				ifconfig $interface $ifx_args alias
				alias=`expr ${alias} + 1`
			else
				break;
			fi
		done
		# Do ipx address if specified
		eval ifx_args=\$ifconfig_${interface}_ipx
		if [ -n "$ifx_args" ]; then
			ifconfig $interface $ifx_args
		fi
		# Add to static route if specified
		eval ifx_routes=\$static_routes_${interface}
		if [ -n "$ifx_routes" ]; then
			for i in ${ifx_routes}; do
				eval route_args=\$route_${i}
				route add ${route_args}
			done
d34 4
d41 1
a41 1
if [ -n "$defaultrouter" -a "x$defaultrouter" != "xNO" -a "x$ifconfig_args" != "xDHCP" ]; then
d45 2
a46 2

# Set up any static routes.  This should be done before router discovery.
d48 3
a50 1
	route -n flush
@


1.8
log
@Wrapper script for PC Card Ethernet Adapters only supports ISC DHCP;
I prefer wide-dhcp, and since both are packages, it should get
equal billing.

PR:		7568
Reviewed by:	phk
Submitted by:	Drew Derbyshire <software@@kew.com>
@
text
@d3 2
@


1.7
log
@Warn if ISC-DHCP not available.
@
text
@d21 6
@


1.6
log
@Support ISC-DHCP if the package is available.
@
text
@d21 2
@


1.5
log
@- In addtition to flushing the routes, also flush the arp cache when bringing
  up the new network link.

Submitted by:	Guido van Rooij <guido@@gvr.org>
@
text
@d15 7
a21 1
		# DHCP currently not implemented
@


1.4
log
@- Setup a default route (if one is set) when the card is inserted.  This
  needs to be re-thought, but should work better for 95% of the users.

Stolen from:	rc.network
@
text
@d3 1
a3 1
# pccardether interfacename [ifconfig option]
d5 1
a5 1
# example: pccardether ep0 -link0
d32 1
@


1.3
log
@sysconfig -> rc.conf
PR:		3978
Submitted by:	Janick.Taillandier@@ratp.fr
@
text
@d22 15
@


1.2
log
@Fix reverse logic bug which caused the ethernet configuration to never work.
@
text
@d8 3
a10 3
# Suck in the /etc/sysconfig variables
if [ -f /etc/sysconfig ]; then
	. /etc/sysconfig
@


1.2.4.1
log
@sysconfig -> rc.conf
@
text
@d8 3
a10 3
# Suck in the /etc/rc.conf variables
if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
@


1.2.4.2
log
@- MFC:
 * new ACCTON card settings
 * setup a default route when an ethernet card is inserted.
@
text
@a21 15

if [ "x$defaultrouter" != "xNO" ] ; then
	static_routes="default ${static_routes}"
	route_default="default ${defaultrouter}"
fi
    
# Set up any static routes.
if [ "x${static_routes}" != "x" ]; then
	# flush beforehand, just in case....
        route -n flush
	for i in ${static_routes}; do
		eval route_args=\$route_${i}
		route add ${route_args}
	done
fi
@


1.2.4.3
log
@MFC: - Flush the arp cache when bringing up a new network link.
@
text
@d3 1
a3 1
# pccard_ether interfacename [ifconfig option]
d5 1
a5 1
# example: pccard_ether ep0 -link0
a31 1
	arp -d -a
@


1.2.4.4
log
@Merge from -current
@
text
@d15 1
a15 9
		if [ -f /usr/local/sbin/dhclient ] ; then
		    if [ -s /var/run/dhclient.pid ] ; then
			kill `cat /var/run/dhclient.pid`
			rm /var/run/dhclient.pid
		    fi
		    /usr/local/sbin/dhclient
		else
		    echo "DHCP client software not available (isc-dhcp2)"
		fi
@


1.2.4.5
log
@MFC: Add Id keyword
@
text
@a2 2
#	$Id:$
#
@


1.2.4.6
log
@$Id$ -> $FreeBSD$
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.1
log
@PC-CARD hooks.  Someday it will actually enable working code. :)

Reviewed by:	phk
Submitted by:	Tatsumi Hosokawa <hosokawa@@mt.cs.keio.ac.jp> & BSD Nomads

I re-wrote alot of this, but the ideas are based on the code from the
most recent pccard-snapshot.
@
text
@d13 1
a13 1
if [ "x$pccard_ifconfig" = "xNO" ] ; then
@
