Bring RCNG in from 5.x and adjust config files and scripts accordingly.
[dragonfly.git] / etc / rc.d / rtadvd
1 #!/bin/sh
2 #
3 # $NetBSD: rtadvd,v 1.5 2002/03/22 04:34:00 thorpej Exp $
4 # $FreeBSD: src/etc/rc.d/rtadvd,v 1.5 2003/01/24 00:37:52 mtm Exp $
5 # $DragonFly: src/etc/rc.d/rtadvd,v 1.1 2003/07/24 06:35:37 dillon Exp $
6 #
7
8 # PROVIDE: rtadvd
9 # REQUIRE: DAEMON
10 # BEFORE:  LOGIN
11 # KEYWORD: DragonFly FreeBSD NetBSD
12
13 . /etc/rc.subr
14
15 name="rtadvd"
16 rcvar=`set_rcvar`
17 command="/usr/sbin/${name}"
18 start_precmd="rtadvd_precmd"
19
20 rtadvd_precmd()
21 {
22         case ${OSTYPE} in
23         DragonFly)
24                 IS_GATEWAY="checkyesno ipv6_gateway_enable"
25                 ;;
26         FreeBSD)
27                 IS_GATEWAY="checkyesno ipv6_gateway_enable"
28                 ;;
29         NetBSD)
30                 IS_GATEWAY="eval [ \"$ip6mode\" = \"router\" ]"
31                 ;;
32         esac
33         if ! ${IS_GATEWAY}; then
34                 warn \
35                   "${name} cannot be used on IPv6 host, only on an IPv6 router."
36                 return 1
37         fi
38
39         # This should be enabled with a great care.
40         # You may want to fine-tune /etc/rtadvd.conf.
41         #
42         # And if you wish your rtadvd to receive and process
43         # router renumbering messages, specify your Router Renumbering
44         # security policy by -R option.
45         #
46         # See `man 3 ipsec_set_policy` for IPsec policy specification
47         # details.
48         # (CAUTION: This enables your routers prefix renumbering
49         # from another machine, so if you enable this, do it with
50         # enough care.)
51         #
52         case ${OSTYPE} in
53         DragonFly)
54                 # If specific interfaces haven't been specified,
55                 # get a list of interfaces and enable it on them
56                 #
57                 case ${rtadvd_interfaces} in
58                 '')
59                         for i in `ifconfig -l` ; do
60                                 case $i in
61                                 lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*)
62                                         continue
63                                         ;;
64                                 *)
65                                         rtadvd_interfaces="${rtadvd_interfaces} ${i}"
66                                         ;;
67                                 esac
68                         done
69                         ;;
70                 esac
71                 command_args="${rtadvd_interfaces}"
72                 # Enable Router Renumbering, unicast case
73                 # (use correct src/dst addr)
74                 # rtadvd -R "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" ${ipv6_network_interf
75                 ;;
76         FreeBSD)
77                 # If specific interfaces haven't been specified,
78                 # get a list of interfaces and enable it on them
79                 #
80                 case ${rtadvd_interfaces} in
81                 '')
82                         for i in `ifconfig -l` ; do
83                                 case $i in
84                                 lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*)
85                                         continue
86                                         ;;
87                                 *)
88                                         rtadvd_interfaces="${rtadvd_interfaces} ${i}"
89                                         ;;
90                                 esac
91                         done
92                         ;;
93                 esac
94                 command_args="${rtadvd_interfaces}"
95
96                 # Enable Router Renumbering, unicast case
97                 # (use correct src/dst addr)
98                 # rtadvd -R "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" ${ipv6_network_interfaces}
99                 # Enable Router Renumbering, multicast case
100                 # (use correct src addr)
101                 # rtadvd -R "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" ${ipv6_network_interfaces}
102                 ;;
103         esac
104         return 0
105 }
106
107 load_rc_config $name
108 run_rc_command "$1"