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