rtadvd revision 104980
1187423Sgonzo#!/bin/sh
2187423Sgonzo#
3187423Sgonzo# $NetBSD: rtadvd,v 1.5 2002/03/22 04:34:00 thorpej Exp $
4187423Sgonzo# $FreeBSD: head/etc/rc.d/rtadvd 104980 2002-10-12 10:31:31Z schweikh $
5187423Sgonzo#
6187423Sgonzo
7187423Sgonzo# PROVIDE: rtadvd
8187423Sgonzo# REQUIRE: DAEMON
9187423Sgonzo# BEFORE:  LOGIN
10187423Sgonzo# KEYWORD: FreeBSD NetBSD
11187423Sgonzo
12187423Sgonzo. /etc/rc.subr
13187423Sgonzo
14187423Sgonzoname="rtadvd"
15187423Sgonzorcvar=`set_rcvar`
16187423Sgonzocommand="/usr/sbin/${name}"
17187423Sgonzostart_precmd="rtadvd_precmd"
18187423Sgonzo
19187423Sgonzocase ${OSTYPE} in
20187423SgonzoFreeBSD)
21187423Sgonzo	IS_GATEWAY="checkyesno ipv6_gateway_enable"
22187423Sgonzo	;;
23187423SgonzoNetBSD)
24187423Sgonzo	IS_GATEWAY="eval [ \"$ip6mode\" = \"router\" ]"
25187423Sgonzo	;;
26187423Sgonzoesac
27187423Sgonzo
28187423Sgonzortadvd_precmd()
29187423Sgonzo{
30187423Sgonzo	if ! ${IS_GATEWAY}; then
31187423Sgonzo		warn \
32187423Sgonzo		  "${name} cannot be used on IPv6 host, only on an IPv6 router."
33187423Sgonzo		return 1
34187423Sgonzo	fi
35187423Sgonzo
36187423Sgonzo	# This should be enabled with a great care.
37187423Sgonzo	# You may want to fine-tune /etc/rtadvd.conf.
38187423Sgonzo	#
39187423Sgonzo	# And if you wish your rtadvd to receive and process
40187423Sgonzo	# router renumbering messages, specify your Router Renumbering
41187456Sgonzo	# security policy by -R option.
42191289Sgonzo	#
43187423Sgonzo	# See `man 3 ipsec_set_policy` for IPsec policy specification
44187423Sgonzo	# details.
45187423Sgonzo	# (CAUTION: This enables your routers prefix renumbering
46187423Sgonzo	# from another machine, so if you enable this, do it with
47187423Sgonzo	# enough care.)
48187423Sgonzo	#
49187423Sgonzo	case ${OSTYPE} in
50187423Sgonzo	FreeBSD)
51187423Sgonzo		# If specific interfaces haven't been specified,
52187423Sgonzo		# get a list of interfaces and enable it on them
53187423Sgonzo		#
54187423Sgonzo		case ${rtadvd_interfaces} in
55187423Sgonzo		'')
56187423Sgonzo			for i in `ifconfig -l` ; do
57187423Sgonzo				case $i in
58191293Sgonzo				lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*)
59187423Sgonzo					continue
60187423Sgonzo					;;
61187423Sgonzo				*)
62187423Sgonzo					rtadvd_interfaces="${rtadvd_interfaces} ${i}"
63187423Sgonzo					;;
64187423Sgonzo				esac
65187423Sgonzo			done
66187423Sgonzo			;;
67187516Sgonzo		esac
68191289Sgonzo		command_args="${rtadvd_interfaces}"
69191293Sgonzo
70187516Sgonzo		# Enable Router Renumbering, unicast case
71187516Sgonzo		# (use correct src/dst addr)
72187516Sgonzo		# rtadvd -R "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" ${ipv6_network_interfaces}
73187516Sgonzo		# Enable Router Renumbering, multicast case
74187516Sgonzo		# (use correct src addr)
75187516Sgonzo		# rtadvd -R "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" ${ipv6_network_interfaces}
76187516Sgonzo		;;
77191289Sgonzo	esac
78187423Sgonzo	return 0
79187423Sgonzo}
80
81load_rc_config $name
82run_rc_command "$1"
83