175900Sjoe#!/bin/sh -
275900Sjoe# $FreeBSD$
391853Sluigi
475900Sjoenetwork_pass1() {
575900Sjoe    echo -n 'Doing initial network setup:'
675900Sjoe    # Set the host name if it is not already set
775900Sjoe    if [ -z "`hostname -s`" ] ; then
891853Sluigi	hostname $hostname
991853Sluigi	echo ' hostname'
1075900Sjoe    fi
1175900Sjoe    # Set up all the network interfaces, calling startup scripts if needed
1275900Sjoe    for ifn in ${network_interfaces}; do
1391853Sluigi	[ -e /etc/start_if.${ifn} ] && . /etc/start_if.${ifn}
1491853Sluigi	# Do the primary ifconfig if specified
1591853Sluigi	eval ifconfig_args=\$ifconfig_${ifn}
1691853Sluigi	[ -n "${ifconfig_args}" ] && ifconfig ${ifn} ${ifconfig_args}
1791853Sluigi	# Check to see if aliases need to be added
1891853Sluigi	alias=0
1991853Sluigi	while :
2091853Sluigi	do
2191853Sluigi	    eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
2291853Sluigi	    if [ -n "${ifconfig_args}" ]; then
2391853Sluigi		ifconfig ${ifn} ${ifconfig_args} alias
2491871Sluigi		alias=$((${alias} + 1))
2591853Sluigi	    else
2691853Sluigi		break;
2775900Sjoe	    fi
2891853Sluigi	done
2991853Sluigi	ifconfig ${ifn}
3075900Sjoe    done
3175900Sjoe    # Load the filters if required
3291853Sluigi    if [ -f /etc/rc.firewall -a "${firewall_enable}" = "YES" ] ; then
3391853Sluigi	# Set quiet mode if requested
3491853Sluigi	if [ "${firewall_quiet}" = "YES" ]; then
3591853Sluigi	    fwcmd="/sbin/ipfw -q"
3691853Sluigi	else
3791853Sluigi	    fwcmd="/sbin/ipfw"
3891853Sluigi	fi
3991853Sluigi	$fwcmd -f flush	# Flush out the list before we begin.
4091853Sluigi
4191853Sluigi	. /etc/rc.firewall
4291853Sluigi	echo "Firewall rules loaded."
4375900Sjoe    else
4491853Sluigi	echo "Warning: kernel has firewall functionality, but firewall rules weren't loaded."
4591853Sluigi	echo "         All ip services are ENABLED by default."
4675900Sjoe    fi
4775900Sjoe    # Configure routing
4875900Sjoe    if [ "x$defaultrouter" != "xNO" ] ; then
4991853Sluigi	static_routes="default ${static_routes}"
5091853Sluigi	route_default="default ${defaultrouter}"
5175900Sjoe    fi
5275900Sjoe    # Set up any static routes.  This should be done before router discovery.
5375900Sjoe    if [ "x${static_routes}" != "x" ]; then
5491853Sluigi	for i in ${static_routes}; do
5591853Sluigi	    eval route_args=\$route_${i}
5691853Sluigi	    route add ${route_args}
5791853Sluigi	done
5875900Sjoe    fi
5975900Sjoe    echo -n 'Additional routing options:'
6075900Sjoe    if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then
6191853Sluigi	echo -n ' tcp_extensions=NO'
6296398Sdd	sysctl net.inet.tcp.rfc1323=0 >/dev/null 2>&1
6396398Sdd	sysctl net.inet.tcp.rfc1644=0 >/dev/null 2>&1
6475900Sjoe    fi
6575900Sjoe    if [ "X$gateway_enable" = X"YES" ]; then
6691853Sluigi	echo -n ' IP_gateway=YES'
6796398Sdd	sysctl net.inet.ip.forwarding=1 >/dev/null 2>&1
6875900Sjoe    fi
6975900Sjoe    if [ "X$arpproxy_all" = X"YES" ]; then
7091853Sluigi	echo -n ' turning on ARP_PROXY_ALL: '
7196398Sdd	sysctl net.link.ether.inet.proxyall=1 2>&1
7275900Sjoe    fi
7375900Sjoe    echo '.'
7475900Sjoe    network_pass1_done=YES	# Let future generations know we made it.
7575900Sjoe}
7675900Sjoe
7775900Sjoenetwork_pass2() {
7875900Sjoe    network_pass2_done=YES
7975900Sjoe}
8075900Sjoe
8175900Sjoenetwork_pass3() {
8275900Sjoe    network_pass3_done=YES
8375900Sjoe}
84