head	1.18;
access;
symbols
	perseant-exfatfs-base-20250801:1.18
	perseant-exfatfs-base-20240630:1.18
	perseant-exfatfs:1.18.0.46
	perseant-exfatfs-base:1.18
	cjep_sun2x:1.18.0.44
	cjep_sun2x-base:1.18
	cjep_staticlib_x-base1:1.18
	cjep_staticlib_x:1.18.0.42
	cjep_staticlib_x-base:1.18
	phil-wifi-20200421:1.18
	phil-wifi-20200411:1.18
	phil-wifi-20200406:1.18
	pgoyette-compat-merge-20190127:1.18
	pgoyette-compat-20190127:1.18
	pgoyette-compat-20190118:1.18
	pgoyette-compat-1226:1.18
	pgoyette-compat-1126:1.18
	pgoyette-compat-1020:1.18
	pgoyette-compat-0930:1.18
	pgoyette-compat-0906:1.18
	pgoyette-compat-0728:1.18
	pgoyette-compat-0625:1.18
	pgoyette-compat-0521:1.18
	pgoyette-compat-0502:1.18
	pgoyette-compat-0422:1.18
	pgoyette-compat-0415:1.18
	pgoyette-compat-0407:1.18
	pgoyette-compat-0330:1.18
	pgoyette-compat-0322:1.18
	pgoyette-compat-0315:1.18
	pgoyette-compat:1.18.0.40
	pgoyette-compat-base:1.18
	perseant-stdc-iso10646:1.18.0.38
	perseant-stdc-iso10646-base:1.18
	prg-localcount2-base3:1.18
	prg-localcount2-base2:1.18
	prg-localcount2-base1:1.18
	prg-localcount2:1.18.0.36
	prg-localcount2-base:1.18
	pgoyette-localcount-20170426:1.18
	bouyer-socketcan-base1:1.18
	pgoyette-localcount-20170320:1.18
	bouyer-socketcan:1.18.0.34
	bouyer-socketcan-base:1.18
	pgoyette-localcount-20170107:1.18
	pgoyette-localcount-20161104:1.18
	localcount-20160914:1.18
	pgoyette-localcount-20160806:1.18
	pgoyette-localcount-20160726:1.18
	pgoyette-localcount:1.18.0.32
	pgoyette-localcount-base:1.18
	netbsd-5-2-3-RELEASE:1.18
	netbsd-5-1-5-RELEASE:1.18
	yamt-pagecache-base9:1.18
	yamt-pagecache-tag8:1.18
	tls-earlyentropy:1.18.0.28
	tls-earlyentropy-base:1.18
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.18
	riastradh-drm2-base3:1.18
	netbsd-5-2-2-RELEASE:1.18
	netbsd-5-1-4-RELEASE:1.18
	netbsd-5-2-1-RELEASE:1.18
	netbsd-5-1-3-RELEASE:1.18
	agc-symver:1.18.0.30
	agc-symver-base:1.18
	tls-maxphys-base:1.18
	yamt-pagecache-base8:1.18
	netbsd-5-2:1.18.0.26
	yamt-pagecache-base7:1.18
	netbsd-5-2-RELEASE:1.18
	netbsd-5-2-RC1:1.18
	yamt-pagecache-base6:1.18
	yamt-pagecache-base5:1.18
	yamt-pagecache-base4:1.18
	netbsd-5-1-2-RELEASE:1.18
	netbsd-5-1-1-RELEASE:1.18
	yamt-pagecache-base3:1.18
	yamt-pagecache-base2:1.18
	yamt-pagecache:1.18.0.24
	yamt-pagecache-base:1.18
	bouyer-quota2-nbase:1.18
	bouyer-quota2:1.18.0.22
	bouyer-quota2-base:1.18
	matt-nb5-pq3:1.18.0.20
	matt-nb5-pq3-base:1.18
	netbsd-5-1:1.18.0.18
	netbsd-5-1-RELEASE:1.18
	netbsd-5-1-RC4:1.18
	netbsd-5-1-RC3:1.18
	netbsd-5-1-RC2:1.18
	netbsd-5-1-RC1:1.18
	netbsd-5-0-2-RELEASE:1.18
	netbsd-5-0-1-RELEASE:1.18
	jym-xensuspend-nbase:1.18
	netbsd-5-0:1.18.0.16
	netbsd-5-0-RELEASE:1.18
	netbsd-5-0-RC4:1.18
	netbsd-5-0-RC3:1.18
	netbsd-5-0-RC2:1.18
	jym-xensuspend:1.18.0.14
	jym-xensuspend-base:1.18
	netbsd-5-0-RC1:1.18
	netbsd-5:1.18.0.12
	netbsd-5-base:1.18
	mjf-devfs2:1.18.0.10
	mjf-devfs2-base:1.18
	yamt-pf42-base4:1.18
	yamt-pf42-base3:1.18
	hpcarm-cleanup-nbase:1.18
	yamt-pf42-base2:1.18
	yamt-pf42:1.18.0.8
	yamt-pf42-base:1.18
	keiichi-mipv6-nbase:1.18
	keiichi-mipv6:1.18.0.6
	keiichi-mipv6-base:1.18
	cube-autoconf:1.18.0.4
	cube-autoconf-base:1.18
	hpcarm-cleanup:1.18.0.2
	hpcarm-cleanup-base:1.18
	netbsd-1-5-PATCH003:1.11.2.2
	ISC_V3RC8:1.1.1.11
	netbsd-1-5-PATCH001:1.11.2.1
	ISC_V3P2PL24:1.1.1.10
	ISC_V3B2PL23:1.1.1.10
	netbsd-1-5-RELEASE:1.11
	netbsd-1-5-BETA2:1.11
	netbsd-1-5-BETA:1.11
	ISC_V3B2PL9:1.1.1.9
	netbsd-1-4-PATCH003:1.6
	ISC_V3B2PL2:1.1.1.9
	ISC_20000719_MERGE:1.11
	netbsd-1-5-ALPHA2:1.11
	ISC_20000719:1.1.1.9
	ISC_20000708:1.1.1.9
	ISC_20000623:1.1.1.9
	netbsd-1-5:1.11.0.2
	netbsd-1-5-base:1.11
	ISC_200006101802:1.1.1.9
	minoura-xpg4dl-base:1.10
	minoura-xpg4dl:1.10.0.2
	DHCP_20000422:1.1.1.8
	netbsd-1-4-PATCH002:1.6
	wrstuden-devbsize-19991221:1.8
	wrstuden-devbsize:1.8.0.4
	wrstuden-devbsize-base:1.8
	comdex-fall-1999:1.8.0.2
	comdex-fall-1999-base:1.8
	netbsd-1-4-PATCH001:1.6
	netbsd-1-4-RELEASE:1.6
	V2-BETA-1-PATCH-27:1.1.1.7
	V2-BETA-1-PATCH-25:1.1.1.7
	netbsd-1-4:1.6.0.2
	netbsd-1-4-base:1.6
	V2-BETA-1-PATCH-22:1.1.1.7
	V2-BETA-1-PATCH-21:1.1.1.7
	V2-BETA-1-PATCH-20A:1.1.1.7
	V2-BETA-1-PATCH-20:1.1.1.7
	V2-BETA-1-PATCH-19:1.1.1.6
	V2-BETA-1-PATCH-18:1.1.1.6
	V2-BETA-1-PATCH-15:1.1.1.5
	V2-BETA-1-PATCH-14:1.1.1.5
	V2-BETA-1-PATCH-13:1.1.1.5
	netbsd-1-3-PATCH003:1.1.1.3.2.1
	netbsd-1-3-PATCH003-CANDIDATE2:1.1.1.3.2.1
	netbsd-1-3-PATCH003-CANDIDATE1:1.1.1.3.2.1
	netbsd-1-3-PATCH003-CANDIDATE0:1.1.1.3.2.1
	V2-BETA-2:1.1.1.4
	netbsd-1-3-PATCH002:1.1.1.3.2.1
	netbsd-1-3-PATCH001:1.1.1.3.2.1
	netbsd-1-3-RELEASE:1.1.1.3.2.1
	netbsd-1-3-BETA:1.1.1.3.2.1
	DHCP-971122:1.1.1.4
	netbsd-1-3:1.1.1.3.0.2
	netbsd-1-3-base:1.1.1.3
	ISC_NetBSD_1_3_Alpha:1.1.1.3
	DHCP-970607:1.1.1.2
	DHCP-970605:1.1.1.2
	DHCP-970602:1.1.1.2
	DHCP-970331:1.1.1.1
	DHCP-970329A:1.1.1.1
	DHCP-970329:1.1.1.1
	ISC:1.1.1;
locks; strict;
comment	@# @;


1.18
date	2001.08.03.14.14.00;	author drochner;	state dead;
branches;
next	1.17;

1.17
date	2001.06.18.19.43.55;	author christos;	state Exp;
branches;
next	1.16;

1.16
date	2001.06.18.19.01.52;	author drochner;	state Exp;
branches;
next	1.15;

1.15
date	2001.04.17.23.25.38;	author kleink;	state Exp;
branches;
next	1.14;

1.14
date	2001.04.11.21.53.26;	author christos;	state Exp;
branches;
next	1.13;

1.13
date	2001.04.11.21.22.53;	author christos;	state Exp;
branches;
next	1.12;

1.12
date	2001.04.02.23.45.54;	author mellon;	state Exp;
branches;
next	1.11;

1.11
date	2000.06.10.18.17.20;	author mellon;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2000.04.28.16.34.31;	author thorpej;	state Exp;
branches
	1.10.2.1;
next	1.9;

1.9
date	2000.04.22.08.18.13;	author mellon;	state Exp;
branches;
next	1.8;

1.8
date	99.06.04.20.40.50;	author thorpej;	state Exp;
branches;
next	1.7;

1.7
date	99.06.04.20.12.52;	author thorpej;	state Exp;
branches;
next	1.6;

1.6
date	99.03.05.22.37.43;	author mycroft;	state Exp;
branches;
next	1.5;

1.5
date	99.03.05.17.52.45;	author mellon;	state Exp;
branches;
next	1.4;

1.4
date	99.02.03.00.19.00;	author tron;	state Exp;
branches;
next	1.3;

1.3
date	99.01.28.23.09.07;	author thorpej;	state Exp;
branches;
next	1.2;

1.2
date	98.08.26.02.11.59;	author enami;	state Exp;
branches;
next	1.1;

1.1
date	97.03.29.21.52.16;	author mellon;	state Exp;
branches
	1.1.1.1;
next	;

1.11.2.1
date	2001.04.04.20.55.43;	author he;	state Exp;
branches;
next	1.11.2.2;

1.11.2.2
date	2001.08.17.20.43.00;	author tv;	state dead;
branches;
next	;

1.10.2.1
date	2000.06.22.18.00.44;	author minoura;	state Exp;
branches;
next	;

1.1.1.1
date	97.03.29.21.52.16;	author mellon;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	97.06.03.02.49.16;	author mellon;	state Exp;
branches;
next	1.1.1.3;

1.1.1.3
date	97.10.20.23.28.22;	author mellon;	state Exp;
branches
	1.1.1.3.2.1;
next	1.1.1.4;

1.1.1.4
date	97.11.22.09.13.41;	author mellon;	state Exp;
branches;
next	1.1.1.5;

1.1.1.5
date	99.02.18.21.48.48;	author mellon;	state Exp;
branches;
next	1.1.1.6;

1.1.1.6
date	99.03.05.17.43.42;	author mellon;	state Exp;
branches;
next	1.1.1.7;

1.1.1.7
date	99.03.29.23.00.50;	author mellon;	state Exp;
branches;
next	1.1.1.8;

1.1.1.8
date	2000.04.22.07.11.31;	author mellon;	state Exp;
branches;
next	1.1.1.9;

1.1.1.9
date	2000.06.10.18.04.36;	author mellon;	state Exp;
branches;
next	1.1.1.10;

1.1.1.10
date	2001.04.02.21.56.50;	author mellon;	state Exp;
branches;
next	1.1.1.11;

1.1.1.11
date	2001.06.18.18.13.14;	author drochner;	state Exp;
branches;
next	;

1.1.1.3.2.1
date	97.11.22.09.28.24;	author mellon;	state Exp;
branches;
next	;


desc
@@


1.18
log
@switch to reachover build from src/dist/dhcp
@
text
@#!/bin/sh
#
# $NetBSD: netbsd,v 1.17 2001/06/18 19:43:55 christos Exp $

ENTERHOOKS=/etc/dhclient-enter-hooks
EXITHOOKS=/etc/dhclient-exit-hooks
RESOLV=/etc/resolv.conf

make_resolv_conf() {
	if [ \( ! -z "$new_domain_name" \) -a \
	     \( ! -z "$new_domain_name_servers" \) ]; then
		echo search $new_domain_name > $RESOLV
		for nameserver in $new_domain_name_servers; do
			echo nameserver $nameserver
		done >> $RESOLV
	fi
}

# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
	exit_status=$1
	if [ -f "$EXITHOOKS" ]; then
		. "$EXITHOOKS"
	fi
	# probably should do something with exit status of the local script
	exit $exit_status
}


add_new_routes() {
	for router in $new_routers; do
		route add default $router
	done >/dev/null 2>&1

	set -- $new_static_routes
	while [ $# -gt 1 ]; do
		route add $0 $1
		shift; shift
	done
}

delete_old_routes() {
	for router in $old_routers; do
		route delete default $router
	done >/dev/null 2>&1

	set -- $old_static_routes
	while [ $# -gt 1 ]; do
		route delete $1 $2
		shift; shift
	done

	arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' | sh
}

# Invoke the local dhcp client enter hooks, if they exist.
if [ -f $ENTERHOOKS ]; then
	exit_status=0
	. $ENTERHOOKS
	# allow the local script to abort processing of this state
	# local script must set exit_status variable to nonzero.
	if [ $exit_status -ne 0 ]; then
		exit $exit_status
	fi
fi

if [ ! -z "$new_host_name" ]; then
	echo New Host Name: $new_host_name
fi

if [ ! -z "$new_nis_domain" ]; then
	echo New NIS Domain: $new_nis_domain
fi

if [ ! -z "$new_network_number" ]; then
	echo New Network Number: $new_network_number
fi

if [ ! -z "$new_broadcast_address" ]; then
	echo New Broadcast Address: $new_broadcast_address
	new_broadcast_arg="broadcast $new_broadcast_address"
fi

if [ ! -z "$old_broadcast_address" ]; then
	old_broadcast_arg="broadcast $old_broadcast_address"
fi

if [ ! -z "$new_subnet_mask" ]; then
	new_netmask_arg="netmask $new_subnet_mask"
fi

if [ ! -z "$old_subnet_mask" ]; then
	old_netmask_arg="netmask $old_subnet_mask"
fi

if [ ! -z "$alias_subnet_mask" ]; then
	alias_subnet_arg="netmask $alias_subnet_mask"
fi

case "$reason" in
MEDIUM)
	eval "ifconfig $interface $medium"
	eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1

	sleep 1

	exit_with_hooks 0
	;;

PREINIT)
	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet \
		    -alias $alias_ip_address >/dev/null 2>&1
		route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
	fi

	ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
	    broadcast 255.255.255.255 up

	exit_with_hooks 0
	;;

ARPCHECK|ARPSEND)
	exit_with_hooks 0
	;;

BOUND|RENEW|REBIND|REBOOT)
	if [ ! -z "$new_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			domainname $new_nis_domain
		fi
	fi

	if type hostname > /dev/null 2>&1; then
		if [ \( -z "$current_hostname" \) -o \
		    \( "x$new_host_name" = "x$old_hostname" \) ]; then
			current_hostname=`hostname`
		fi
		if [ \( -z "$current_hostname" \) -o \
		    \( "x$new_host_name" != "x$old_hostname" \) ]; then
			hostname $new_host_name
		fi
	fi
    
	if [ \( ! -z "$old_ip_address" \) -a \( ! -z "$alias_ip_address" \) -a \
	    \( "x$alias_ip_address" != "x$old_ip_address" \) ]; then
		ifconfig $interface inet \
		    -alias $alias_ip_address > /dev/null 2>&1
		route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
	fi

	if [ \( ! -z "$old_ip_address" \) -a \
	    \( "x$old_ip_address" != "x$new_ip_address" \) ]; then
		eval "ifconfig $interface inet -alias $old_ip_address $medium"
		route delete $old_ip_address 127.0.0.1 >/dev/null 2>&1

		delete_old_routes
	fi

	if [ \( -z "$old_ip_address" \) -o \
	    \( "x$old_ip_address" != "x$new_ip_address" \) -o \
	    \( "x$reason" = "xBOUND" \) -o \( "x$reason" = "xREBOOT" \) ]; then
		eval "ifconfig $interface inet $new_ip_address \
		    $new_netmask_arg $new_broadcast_arg $medium"
		route add $new_ip_address 127.0.0.1 >/dev/null 2>&1

		add_new_routes
	fi

	if [ \( ! -z "$alias_ip_address" \) -a \
	    \( "x$new_ip_address" != "x$alias_ip_address" \) ]; then
		ifconfig $interface inet alias $alias_ip_address \
		    $alias_subnet_arg
		route add $alias_ip_address 127.0.0.1
	fi
	make_resolv_conf
	exit_with_hooks 0
	;;

EXPIRE|FAIL|RELEASE|STOP)
	if [ ! -z "$old_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			# delete the old nis domain name
			domainname ""
		fi
	fi

	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet -alias $alias_ip_address 
		route delete $alias_ip_address 127.0.0.1
	fi > /dev/null 2>&1

	if [ ! -z "$old_ip_address" ]; then
		eval "ifconfig $interface inet -alias $old_ip_address $medium"
		route delete $old_ip_address 127.0.0.1 >/dev/null 2>&1
		delete_old_routes

	fi

	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet alias $alias_ip_address \
		    $alias_subnet_arg
		route add $alias_ip_address 127.0.0.1
	fi

	exit_with_hooks 0
	;;

TIMEOUT)
	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet -alias $alias_ip_address
		route delete $alias_ip_address 127.0.0.1
	fi > /dev/null 2>&1

	if [ ! -z "$new_host_name" ]; then
		if type hostname > /dev/null 2>&1; then
			hostname $new_host_name
		fi
	fi

	if [ ! -z "$new_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			domainname $new_nis_domain
		fi
	fi

	eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
	    $new_broadcast_arg $medium"
	sleep 1

	if [ ! -z "$new_routers" ]; then
		set -- $new_routers
		if ping -n -q -c 1 -w 1 $1; then
			if [ \( ! -z "$alias_ip_address" \) -a \
			    \( "x$new_ip_address" != "x$alias_ip_address" \) ]
			then
				ifconfig $interface inet alias \
				    $alias_ip_address $alias_subnet_arg
				route add $alias_ip_address 127.0.0.1
			fi

			route add $new_ip_address 127.0.0.1 >/dev/null 2>&1

			add_new_routes
			make_resolv_conf
			exit_with_hooks 0
		fi
	fi

	eval "ifconfig $interface inet -alias $new_ip_address $medium"

	delete_old_routes

	exit_with_hooks 1
	;;
*)
	exit_with_hooks 0
	;;
esac
@


1.17
log
@use better/quicker shell syntax
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.16 2001/06/18 19:01:52 drochner Exp $
@


1.16
log
@merge 3.0rc8
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.15 2001/04/17 23:25:38 kleink Exp $
d10 2
a11 2
	if [ "x$new_domain_name" != x ] && \
	   [ x"$new_domain_name_servers" != x ]; then
d14 2
a15 2
			echo nameserver $nameserver >> $RESOLV
		done
@


1.15
log
@Add missing quotes to test -z argument; from Tim Preston in PR bin/12687.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.14 2001/04/11 21:53:26 christos Exp $
d10 7
a16 4
	echo search $new_domain_name > $RESOLV
	for nameserver in $new_domain_name_servers; do
		echo nameserver $nameserver >> $RESOLV
	done
d22 1
a22 1
	if [ -x "$EXITHOOKS" ]; then
d57 1
a57 1
if [ -x $ENTERHOOKS ]; then
d180 1
a180 1
EXPIRE|FAIL)
@


1.14
log
@make the remove route code look exactly the same like the add code.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.13 2001/04/11 21:22:53 christos Exp $
d136 1
a136 1
		if [ \( -z $current_hostname \) -o \
@


1.13
log
@general cleanup:
1. Use standard shell indentation
2. Use [ expr -a expr ] instead of [ expr ] && [ expr ] (same with -o and ||)
3. Cleanup 0 length string tests
4. Factor out the routing code
5. Use a large switch statement based on $reason instead of the endless
   if elif's
6. Use variables for filenames used
7. Test in all cases for the existance of domainname and hostname
8. No need for individual command redirections in structured statements.

Thanks to kleink for testing and fixing my typos!
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.12 2001/04/02 23:45:54 mellon Exp $
d41 7
a47 1
		route delete default $router >/dev/null 2>&1
d49 1
a49 7
	if [ ! -z "$old_static_routes" ]; then
		set -- $old_static_routes
		while [ $# -gt 1 ]; do
			route delete $1 $2
			shift; shift
		done
	fi
@


1.12
log
@Merge of 3.0b2pl23
@
text
@d3 5
a7 1
# $NetBSD: netbsd,v 1.11 2000/06/10 18:17:20 mellon Exp $
d10 4
a13 4
  echo search $new_domain_name >/etc/resolv.conf
  for nameserver in $new_domain_name_servers; do
    echo nameserver $nameserver >>/etc/resolv.conf
  done
d18 33
a50 6
  exit_status=$1
  if [ -x /etc/dhclient-exit-hooks ]; then
    . /etc/dhclient-exit-hooks
  fi
# probably should do something with exit status of the local script
  exit $exit_status
d54 41
a94 205
if [ -x /etc/dhclient-enter-hooks ]; then
  exit_status=0
  . /etc/dhclient-enter-hooks
  # allow the local script to abort processing of this state
  # local script must set exit_status variable to nonzero.
  if [ $exit_status -ne 0 ]; then
    exit $exit_status
  fi
fi

if [ x$new_host_name != x ]; then
   echo New Host Name: $new_host_name
fi

if [ x$new_nis_domain != x ]; then
   echo New NIS Domain: $new_nis_domain
fi

if [ x$new_network_number != x ]; then
   echo New Network Number: $new_network_number
fi

if [ x$new_broadcast_address != x ]; then
 echo New Broadcast Address: $new_broadcast_address
  new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
  old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
  new_netmask_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
  old_netmask_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
  alias_subnet_arg="netmask $alias_subnet_mask"
fi

if [ x$reason = xMEDIUM ]; then
  eval "ifconfig $interface $medium"
  eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
  sleep 1
  exit_with_hooks 0
fi

if [ x$reason = xPREINIT ]; then
  if [ x$alias_ip_address != x ]; then
    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
  fi
  ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
		broadcast 255.255.255.255 up
  exit_with_hooks 0
fi

if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
  exit_with_hooks 0
fi
  
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
  if type domainname > /dev/null 2>&1; then
    if [ x$new_nis_domain != x ]; then
      domainname $new_nis_domain
    fi
  fi
  if type hostname > /dev/null 2>&1; then
    current_hostname=`hostname`
    if [ x$current_hostname = x ] || \
       [ x$current_hostname = x$old_host_name ]; then
      if [ x$current_hostname = x ] || \
         [ x$new_host_name != x$old_host_name ]; then
        hostname $new_host_name
      fi
    fi
  fi
    
  if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
		[ x$alias_ip_address != x$old_ip_address ]; then
    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
  fi
  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
   then
    eval "ifconfig $interface inet -alias $old_ip_address $medium"
    route delete $old_ip_address 127.1 >/dev/null 2>&1
    for router in $old_routers; do
      route delete default $router >/dev/null 2>&1
    done
    if [ "$old_static_routes" != "" ]; then
      set $old_static_routes
      while [ $# -gt 1 ]; do
	route delete $1 $2
	shift; shift
      done
    fi
    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
  fi
  if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
     [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
    eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium"
    route add $new_ip_address 127.1 >/dev/null 2>&1
    for router in $new_routers; do
      route add default $router >/dev/null 2>&1
    done
    if [ "$new_static_routes" != "" ]; then
      set $new_static_routes
      while [ $# -gt 1 ]; do
	route add $1 $2
	shift; shift
      done
    fi
  fi
  if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
   then
    ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
    route add $alias_ip_address 127.0.0.1
  fi
  make_resolv_conf
  exit_with_hooks 0
fi

if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
  if [ x$old_nis_domain != x ]; then
    # delete the old nis domain name
    domainname ""
  fi
  if [ x$alias_ip_address != x ]; then
    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
  fi
  if [ x$old_ip_address != x ]; then
    eval "ifconfig $interface inet -alias $old_ip_address $medium"
    route delete $old_ip_address 127.1 >/dev/null 2>&1
    for router in $old_routers; do
      route delete default $router >/dev/null 2>&1
    done
    if [ "$old_static_routes" != "" ]; then
      set $old_static_routes
      while [ $# -gt 1 ]; do
	route delete $1 $2
	shift; shift
      done
    fi
    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
						|sh >/dev/null 2>&1
  fi
  if [ x$alias_ip_address != x ]; then
    ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
    route add $alias_ip_address 127.0.0.1
  fi
  exit_with_hooks 0
fi

if [ x$reason = xTIMEOUT ]; then
  if [ x$alias_ip_address != x ]; then
    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
  fi
  if [ x$new_host_name != x ]; then
    hostname $new_host_name
  fi
  if [ x$new_nis_domain != x ]; then
    domainname $new_nis_domain
  fi
  eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium"
  sleep 1
  if [ "$new_routers" != "" ]; then
    set $new_routers
    if ping -n -q -c 1 -w 1 $1; then
      if [ x$new_ip_address != x$alias_ip_address ] && \
			[ x$alias_ip_address != x ]; then
	ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
	route add $alias_ip_address 127.0.0.1
      fi
      route add $new_ip_address 127.1 >/dev/null 2>&1
      for router in $new_routers; do
	route add default $router >/dev/null 2>&1
      done
      set $new_static_routes
      while [ $# -gt 1 ]; do
	route add $0 $1
	shift; shift
      done
      make_resolv_conf
      exit_with_hooks 0
    fi
  fi
  eval "ifconfig $interface inet -alias $new_ip_address $medium"
  for router in $old_routers; do
    route delete default $router >/dev/null 2>&1
  done
  if [ "$old_static_routes" != "" ]; then
    set $old_static_routes
    while [ $# -gt 1 ]; do
      route delete $1 $2
      shift; shift
    done
  fi
  arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
							|sh >/dev/null 2>&1
  exit_with_hooks 1
d97 160
a256 1
exit_with_hooks 0
@


1.11
log
@Fix conflicts in merge.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.10 2000/04/28 16:34:31 thorpej Exp $
d63 2
a64 2
  ifconfig $interface $medium
  ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1
d108 1
a108 1
    ifconfig $interface inet -alias $old_ip_address $medium
d124 2
a125 2
    ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium
d157 1
a157 1
    ifconfig $interface inet -alias $old_ip_address $medium
d190 2
a191 2
  ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium
d214 1
a214 1
  ifconfig $interface inet -alias $new_ip_address $medium
@


1.11.2.1
log
@Pull up revision 1.12 (requested by mellon):
  Update DHCP software to ISC version 3, Beta 2, Patchlevel 23.
@
text
@d3 1
a3 1
# $NetBSD$
d63 2
a64 2
  eval "ifconfig $interface $medium"
  eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
d108 1
a108 1
    eval "ifconfig $interface inet -alias $old_ip_address $medium"
d124 2
a125 2
    eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium"
d157 1
a157 1
    eval "ifconfig $interface inet -alias $old_ip_address $medium"
d190 2
a191 2
  eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium"
d214 1
a214 1
  eval "ifconfig $interface inet -alias $new_ip_address $medium"
@


1.11.2.2
log
@Remove files from dhcp pullup that cvs missed the first time around.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.11.2.1 2001/04/04 20:55:43 he Exp $
@


1.10
log
@Only invoke hostname(1) and domainname(1) if they exist (tested with the
`type' shell built-in).  Makes it possible to save some space on install
media which uses DHCP.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.9 2000/04/22 08:18:13 mellon Exp $
d94 2
a95 1
      if [ x$new_host_name != x$old_host_name ]; then
@


1.10.2.1
log
@Sync w/ netbsd-1-5-base.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.11 2000/06/10 18:17:20 mellon Exp $
d94 1
a94 2
      if [ x$current_hostname = x ] || \
         [ x$new_host_name != x$old_host_name ]; then
@


1.9
log
@Initial merge of ISC DHCP 3.0 into NetBSD tree (incomplete)
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.8 1999/06/04 20:40:50 thorpej Exp $
d85 4
a88 2
  if [ x$new_nis_domain != x ]; then
    domainname $new_nis_domain
d90 7
a96 5
  current_hostname=`/bin/hostname`
  if [ x$current_hostname = x ] || \
     [ x$current_hostname = x$old_host_name ]; then
    if [ x$new_host_name != x$old_host_name ]; then
      hostname $new_host_name
@


1.8
log
@If we get an NIS domain name, set it.  If we set, clear it when the
lease is released.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.7 1999/06/04 20:12:52 thorpej Exp $
a84 3
  if [ x$new_host_name != x ]; then
    hostname $new_host_name
  fi
d88 8
d101 2
a102 1
  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
@


1.7
log
@If we get a host-name option, set it.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.6 1999/03/05 22:37:43 mycroft Exp $
d37 4
d88 3
d137 4
d175 3
@


1.6
log
@Remove bashism, so this actually works.
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.5 1999/03/05 17:52:45 mellon Exp $
d33 4
d81 3
d161 3
@


1.5
log
@Merge with 2.0b1pl18
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.4 1999/02/03 00:19:00 tron Exp $
d5 1
a5 1
function make_resolv_conf() {
d13 1
a13 1
function exit_with_hooks() {
@


1.4
log
@Add RCS Id as suggested by Rob Windsor in PR bin/6931.
@
text
@d3 29
a31 1
# $NetBSD$
d58 1
a58 1
  exit 0
d68 1
a68 1
  exit 0
d72 1
a72 1
  exit 0;
d118 2
a119 5
  echo search $new_domain_name >/etc/resolv.conf
  for nameserver in $new_domain_name_servers; do
    echo nameserver $nameserver >>/etc/resolv.conf
  done
  exit 0
d147 1
a147 1
  exit 0
d175 2
a176 9
      echo search $new_domain_name >/etc/resolv.conf.std
      for nameserver in $new_domain_name_servers; do
	echo nameserver $nameserver >>/etc/resolv.conf.std
      done
      if [ -f /etc/resolv.conf ]; then
	rm -f /etc/resolv.conf
      fi
      mv /etc/resolv.conf.std /etc/resolv.conf
      exit 0
d192 1
a192 1
  exit 1
d195 1
a195 1
exit 0
@


1.3
log
@Use ping -n; if we're running a local nameserver, it may try to
reverse-resolve the IP address we're given, which will take a while
to time out, since we're still scanning cached leases (i.e. the network
isn't up yet).
@
text
@d2 2
@


1.2
log
@add missing endif.
@
text
@d133 1
a133 1
    if ping -q -c 1 -w 1 $1; then
@


1.1
log
@Initial revision
@
text
@d3 4
d8 1
a26 1
  ifconfig $interface
d58 7
d75 7
d106 8
a113 1
    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p'i \
d131 4
a134 3
  set $new_routers
  if ping -q -c 1 -w 1 $1; then
    if [ x$new_ip_address != x$alias_ip_address ] && \
d136 21
a156 2
      ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
      route add $alias_ip_address 127.0.0.1
a157 13
    route add $new_ip_address 127.1 >/dev/null 2>&1
    for router in $new_routers; do
      route add default $router >/dev/null 2>&1
    done
    echo search $new_domain_name >/etc/resolv.conf.std
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf.std
    done
    if [ -f /etc/resolv.conf ]; then
      rm -f /etc/resolv.conf
      ln /etc/resolv.conf.std /etc/resolv.conf
    fi
    exit 0
d163 7
@


1.1.1.1
log
@March 29 snapshot
@
text
@@


1.1.1.2
log
@970602 snapshot
@
text
@d88 1
a88 1
    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
@


1.1.1.3
log
@NetBSD 1.3 Alpha snapshot of ISC dhcp
@
text
@a53 5
    set $old_static_routes
    while [ $# -gt 1 ]; do
      route delete $1 $2
      shift; shift
    done
a63 5
    set $new_static_routes
    while [ $# -gt 1 ]; do
      route add $1 $2
      shift; shift
    done
a87 5
    set $old_static_routes
    while [ $# -gt 1 ]; do
      route delete $1 $2
      shift; shift
    done
a116 5
    set $new_static_routes
    while [ $# -gt 1 ]; do
      route add $0 $1
      shift; shift
    done
d123 1
a124 1
    mv /etc/resolv.conf.std /etc/resolv.conf
a129 5
  done
  set $old_static_routes
  while [ $# -gt 1 ]; do
    route delete $1 $2
    shift; shift
@


1.1.1.3.2.1
log
@Pull latest DHCP snapshot up from release branch
@
text
@a2 4
if [ x$new_network_number != x ]; then
   echo New Network Number: $new_network_number
fi

a3 1
 echo New Broadcast Address: $new_broadcast_address
d22 1
d54 5
a58 7
    if [ "$old_static_routes" != "" ]; then
      set $old_static_routes
      while [ $# -gt 1 ]; do
	route delete $1 $2
	shift; shift
      done
    fi
d69 5
a73 7
    if [ "$new_static_routes" != "" ]; then
      set $new_static_routes
      while [ $# -gt 1 ]; do
	route add $1 $2
	shift; shift
      done
    fi
d98 5
a102 7
    if [ "$old_static_routes" != "" ]; then
      set $old_static_routes
      while [ $# -gt 1 ]; do
	route delete $1 $2
	shift; shift
      done
    fi
d121 3
a123 4
  if [ "$new_routers" != "" ]; then
    set $new_routers
    if ping -q -c 1 -w 1 $1; then
      if [ x$new_ip_address != x$alias_ip_address ] && \
d125 2
a126 21
	ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
	route add $alias_ip_address 127.0.0.1
      fi
      route add $new_ip_address 127.1 >/dev/null 2>&1
      for router in $new_routers; do
	route add default $router >/dev/null 2>&1
      done
      set $new_static_routes
      while [ $# -gt 1 ]; do
	route add $0 $1
	shift; shift
      done
      echo search $new_domain_name >/etc/resolv.conf.std
      for nameserver in $new_domain_name_servers; do
	echo nameserver $nameserver >>/etc/resolv.conf.std
      done
      if [ -f /etc/resolv.conf ]; then
	rm -f /etc/resolv.conf
      fi
      mv /etc/resolv.conf.std /etc/resolv.conf
      exit 0
d128 19
d151 5
a155 7
  if [ "$old_static_routes" != "" ]; then
    set $old_static_routes
    while [ $# -gt 1 ]; do
      route delete $1 $2
      shift; shift
    done
  fi
@


1.1.1.4
log
@ISC DHCP Snapshot on November 22, 1997
@
text
@a2 4
if [ x$new_network_number != x ]; then
   echo New Network Number: $new_network_number
fi

a3 1
 echo New Broadcast Address: $new_broadcast_address
d22 1
d54 5
a58 7
    if [ "$old_static_routes" != "" ]; then
      set $old_static_routes
      while [ $# -gt 1 ]; do
	route delete $1 $2
	shift; shift
      done
    fi
d69 5
a73 7
    if [ "$new_static_routes" != "" ]; then
      set $new_static_routes
      while [ $# -gt 1 ]; do
	route add $1 $2
	shift; shift
      done
    fi
d98 5
a102 7
    if [ "$old_static_routes" != "" ]; then
      set $old_static_routes
      while [ $# -gt 1 ]; do
	route delete $1 $2
	shift; shift
      done
    fi
d121 3
a123 4
  if [ "$new_routers" != "" ]; then
    set $new_routers
    if ping -q -c 1 -w 1 $1; then
      if [ x$new_ip_address != x$alias_ip_address ] && \
d125 2
a126 21
	ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
	route add $alias_ip_address 127.0.0.1
      fi
      route add $new_ip_address 127.1 >/dev/null 2>&1
      for router in $new_routers; do
	route add default $router >/dev/null 2>&1
      done
      set $new_static_routes
      while [ $# -gt 1 ]; do
	route add $0 $1
	shift; shift
      done
      echo search $new_domain_name >/etc/resolv.conf.std
      for nameserver in $new_domain_name_servers; do
	echo nameserver $nameserver >>/etc/resolv.conf.std
      done
      if [ -f /etc/resolv.conf ]; then
	rm -f /etc/resolv.conf
      fi
      mv /etc/resolv.conf.std /etc/resolv.conf
      exit 0
d128 19
d151 5
a155 7
  if [ "$old_static_routes" != "" ]; then
    set $old_static_routes
    while [ $# -gt 1 ]; do
      route delete $1 $2
      shift; shift
    done
  fi
@


1.1.1.5
log
@DHCP 2.0b1pl13
@
text
@a157 1
  fi
@


1.1.1.6
log
@2.0 Beta 1 Patchlevel 18
@
text
@a2 28
function make_resolv_conf() {
  echo search $new_domain_name >/etc/resolv.conf
  for nameserver in $new_domain_name_servers; do
    echo nameserver $nameserver >>/etc/resolv.conf
  done
}

# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
function exit_with_hooks() {
  exit_status=$1
  if [ -x /etc/dhclient-exit-hooks ]; then
    . /etc/dhclient-exit-hooks
  fi
# probably should do something with exit status of the local script
  exit $exit_status
}

# Invoke the local dhcp client enter hooks, if they exist.
if [ -x /etc/dhclient-enter-hooks ]; then
  exit_status=0
  . /etc/dhclient-enter-hooks
  # allow the local script to abort processing of this state
  # local script must set exit_status variable to nonzero.
  if [ $exit_status -ne 0 ]; then
    exit $exit_status
  fi
fi

d28 1
a28 1
  exit_with_hooks 0
d38 1
a38 1
  exit_with_hooks 0
d42 1
a42 1
  exit_with_hooks 0
d88 5
a92 2
  make_resolv_conf
  exit_with_hooks 0
d120 1
a120 1
  exit_with_hooks 0
d148 9
a156 2
      make_resolv_conf
      exit_with_hooks 0
d172 1
a172 1
  exit_with_hooks 1
d175 1
a175 1
exit_with_hooks 0
@


1.1.1.7
log
@Patchlevel 20
@
text
@d3 1
a3 1
make_resolv_conf() {
d11 1
a11 1
exit_with_hooks() {
@


1.1.1.8
log
@Initial import of version 3 of the ISC DHCP distribution.
@
text
@a74 8
  current_hostname=`/bin/hostname`
  if [ x$current_hostname = x ] || \
     [ x$current_hostname = x$old_host_name ]; then
    if [ x$new_host_name != x$old_host_name ]; then
      hostname $new_host_name
    fi
  fi
    
d80 1
a80 2
  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
   then
@


1.1.1.9
log
@Belated import of recent DHCP core dumps, etc.   Approved by releng.
@
text
@d75 1
a75 1
  current_hostname=`hostname`
d78 1
a78 2
    if [ x$current_hostname = x ] || \
       [ x$new_host_name != x$old_host_name ]; then
@


1.1.1.10
log
@ISC DHCP 3.0b2pl23
@
text
@d53 2
a54 2
  eval "ifconfig $interface $medium"
  eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
d91 1
a91 1
    eval "ifconfig $interface inet -alias $old_ip_address $medium"
d107 2
a108 2
    eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium"
d136 1
a136 1
    eval "ifconfig $interface inet -alias $old_ip_address $medium"
d163 2
a164 2
  eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
					$new_broadcast_arg $medium"
d187 1
a187 1
  eval "ifconfig $interface inet -alias $new_ip_address $medium"
@


1.1.1.11
log
@ISC DHCP 3.0rc8
@
text
@d4 4
a7 6
  if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
    echo search $new_domain_name >/etc/resolv.conf
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf
    done
  fi
d13 1
a13 1
  if [ -f /etc/dhclient-exit-hooks ]; then
d21 1
a21 1
if [ -f /etc/dhclient-enter-hooks ]; then
d130 1
a130 2
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
   || [ x$reason = xSTOP ]; then
@


