summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/faith
blob: 4790ebd0a5720d5ac4ee855aad19c41b5c2f7943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
# $FreeBSD$
#

# PROVIDE: faith
# REQUIRE: netif
# KEYWORD: nojail

. /etc/rc.subr
. /etc/network.subr

name="faith"
start_cmd="faith_up"
stop_cmd="faith_down"

faith_up()
{
	case ${ipv6_faith_prefix} in
	[Nn][Oo] | '')
		;;
	*)
		echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \
		    " faith0."
		${SYSCTL} net.inet6.ip6.keepfaith=1
		ifconfig faith0 create >/dev/null 2>&1
		ifconfig faith0 up
		for prefix in ${ipv6_faith_prefix}; do
			prefixlen=`expr "${prefix}" : ".*/\(.*\)"`
			case ${prefixlen} in
			'')
				prefixlen=96
				;;
			*)
				prefix=`expr "${prefix}" : \
					     "\(.*\)/${prefixlen}"`
				;;
			esac
			route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1
			route change -inet6 ${prefix} -prefixlen ${prefixlen} \
				-ifp faith0
		done
		check_startmsgs && ifconfig faith0
		;;
	esac
}

faith_down()
{
	echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0."
	ifconfig faith0 destroy
	${SYSCTL} net.inet6.ip6.keepfaith=0

	case ${ipv6_faith_prefix} in
	[Nn][Oo] | '')
		;;
	*)
		for prefix in ${ipv6_faith_prefix}; do
			prefixlen=`expr "${prefix}" : ".*/\(.*\)"`
			case ${prefixlen} in
			'')
				prefixlen=96
				;;
			*)
				prefix=`expr "${prefix}" : \
					     "\(.*\)/${prefixlen}"`
				;;
			esac
			route delete -inet6 ${prefix} -prefixlen ${prefixlen}
		done
		;;
	esac
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud