[BACK]Return to ip6addrctl CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / ip6addrctl (download)

Revision 1.2, Wed Dec 23 04:38:00 2015 UTC (3 years, 3 months ago) by christos
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, HEAD
Changes since 1.1: +2 -8 lines

remove some stuff we don't have; rename rc command variable.

#!/bin/sh
#
# $FreeBSD: head/etc/rc.d/ip6addrctl 270836 2014-08-30 07:08:10Z hrs $
#

# PROVIDE: ip6addrctl
# REQUIRE: root bootconf mountcritlocal tty

. /etc/rc.subr

name="ip6addrctl"
rcvar="ip6addrctl"
start_cmd="ip6addrctl_start"
stop_cmd="ip6addrctl_stop"
extra_commands="status prefer_ipv6 prefer_ipv4"
status_cmd="ip6addrctl"
prefer_ipv6_cmd="ip6addrctl_prefer_ipv6"
prefer_ipv4_cmd="ip6addrctl_prefer_ipv4"
config_file="/etc/ip6addrctl.conf"

IP6ADDRCTL_CMD="/usr/sbin/ip6addrctl"

ip6addrctl_prefer_ipv6()
{
	${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
	cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
	::1/128		 50	 0
	::/0		 40	 1
	::ffff:0:0/96	 35	 4
	2002::/16	 30	 2
	2001::/32	  5	 5
	fc00::/7	  3	13
	::/96		  1	 3
	fec0::/10	  1	11
	3ffe::/16	  1	12
EOT
}

ip6addrctl_prefer_ipv4()
{
	${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
	cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
	::1/128		 50	 0
	::/0		 40	 1
	::ffff:0:0/96	100	 4
	2002::/16	 30	 2
	2001::/32	  5	 5
	fc00::/7	  3	13
	::/96		  1	 3
	fec0::/10	  1	11
	3ffe::/16	  1	12
EOT
}

ip6addrctl_start()
{
	# install the policy of the address selection algorithm.
	case "${ip6addrctl_policy}" in
	[Aa][Uu][Tt][Oo])
		if [ -r "${config_file}" -a -s "${config_file}" ]; then
			${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
			${IP6ADDRCTL_CMD} install "${config_file}"
		else
			ip6addrctl_prefer_ipv6
		fi
	;;
	ipv4_prefer)
		ip6addrctl_prefer_ipv4
	;;
	ipv6_prefer)
		ip6addrctl_prefer_ipv6
	;;
	*)
		warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
		    " \"ipv4_prefer\" is used instead."
		ip6addrctl_prefer_ipv4
	;;
	esac

	if checkyesno ip6addrctl_verbose; then
		echo 'Address selection policy table for IPv4 and IPv6:'
		${IP6ADDRCTL_CMD}
	fi
}

ip6addrctl_stop()
{
	ip6addrctl flush >/dev/null 2>&1
}

load_rc_config $name
run_rc_command "$1"