1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: rtadvd
7# REQUIRE: DAEMON
8# BEFORE:  LOGIN
9# KEYWORD: nojail shutdown
10
11. /etc/rc.subr
12. /etc/network.subr
13
14name="rtadvd"
15rcvar="rtadvd_enable"
16command="/usr/sbin/${name}"
17extra_commands="reload"
18reload_cmd="rtadvd_reload"
19start_precmd="rtadvd_precmd"
20
21rtadvd_precmd()
22{
23	# This should be enabled with a great care.
24	# You may want to fine-tune /etc/rtadvd.conf.
25	#
26	# And if you wish your rtadvd to receive and process
27	# router renumbering messages, specify your Router Renumbering
28	# security policy by -R option.
29	#
30	# See `man 3 ipsec_set_policy` for IPsec policy specification
31	# details.
32	# (CAUTION: This enables your routers prefix renumbering
33	# from another machine, so if you enable this, do it with
34	# enough care.)
35	#
36	# If specific interfaces haven't been specified,
37	# get a list of interfaces and enable it on them
38	#
39	case ${rtadvd_interfaces} in
40	[Aa][Uu][Tt][Oo]|'')
41		command_args=
42		for i in `list_net_interfaces`; do
43			case $i in
44			lo0)	continue ;;
45			esac
46			if ipv6if $i; then
47				command_args="${command_args} ${i}"
48			fi
49		done
50		;;
51	[Nn][Oo][Nn][Ee])
52		;;
53	*)
54		command_args="${rtadvd_interfaces}"
55		;;
56	esac
57
58	# Enable Router Renumbering, unicast case
59	# (use correct src/dst addr)
60	# rtadvd -R "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" ${ipv6_network_interfaces}
61	# Enable Router Renumbering, multicast case
62	# (use correct src addr)
63	# rtadvd -R "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" ${ipv6_network_interfaces}
64	return 0
65}
66
67rtadvd_reload() {
68	/usr/sbin/rtadvctl reload
69}
70
71load_rc_config $name
72run_rc_command "$1"
73