# hdw - linux /etc/conf/network
#
# defining {start,stop}_net functions used by /etc/init.d/network
# (copied from ROCK Linux + some additions)
#

DHCP="on"

IF_0="eth0"
IPADDR_0="192.168.10.20"
NETMASK_0="255.255.255.0"
GATEWAY_0="192.168.10.10"
#OPTIONS_0="mtu 1412"

#
# start and stop functions (called by /etc/init.d/network)
#

xx() { echo ">> $*" ; eval "$*" ; }

start_net() {
	if [ ".$DHCP" = ".on" ] ; then
		echo "starting dhclient."
		/usr/sbin/dhclient -q $IF_0
	else
		echo "setting up network ..."
		# xx insmod ip_tables
		# xx iptables -A chain rule-specification [options]
		# xx echo 1 '>' /proc/sys/net/ipv4/ip_forward
		xx ifconfig $IF_0 $IPADDR_0 netmask $NETMASK_0 up # $OPTIONS_0
		xx route add default gw $GATEWAY_0 dev $IF_0
	fi
	# ipsec
	[ -f /etc/setkey.conf -a -f /usr/sbin/setkey ] &&
		xx /usr/sbin/setkey -f /etc/setkey.conf
}

stop_net() {
	if [ ".$DHCP" = ".on" ] ; then
		echo "stopping dhclient."
		killall -15 /usr/sbin/dhclient
		ifconfig $IF_0 down
	else
		echo "shutting down network ..."
		xx route del default gw $GATEWAY_0 dev $IF_0
		xx ifconfig $IF_0 down
		# xx echo 0 '>' /proc/sys/net/ipv4/ip_forward
		# xx iptables -D chain rule-specification [options]
		# xx rmmod ip_tables
	fi
}
