1#!/bin/sh 2# $FreeBSD$ 3# 4 5# PROVIDE: faith 6# REQUIRE: netif 7# KEYWORD: nojail 8 9. /etc/rc.subr 10. /etc/network.subr 11 12name="faith" 13start_cmd="faith_up" 14stop_cmd="faith_down" 15 16faith_up() 17{ 18 case ${ipv6_faith_prefix} in 19 [Nn][Oo] | '') 20 ;; 21 *) 22 echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \ 23 " faith0." 24 ${SYSCTL} net.inet6.ip6.keepfaith=1 25 ifconfig faith0 create >/dev/null 2>&1 26 ifconfig faith0 up 27 for prefix in ${ipv6_faith_prefix}; do 28 prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 29 case ${prefixlen} in 30 '') 31 prefixlen=96 32 ;; 33 *) 34 prefix=`expr "${prefix}" : \ 35 "\(.*\)/${prefixlen}"` 36 ;; 37 esac 38 route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1 39 route change -inet6 ${prefix} -prefixlen ${prefixlen} \ 40 -ifp faith0 41 done 42 check_startmsgs && ifconfig faith0 43 ;; 44 esac 45} 46 47faith_down() 48{ 49 echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0." 50 ifconfig faith0 destroy 51 ${SYSCTL} net.inet6.ip6.keepfaith=0 52 53 case ${ipv6_faith_prefix} in 54 [Nn][Oo] | '') 55 ;; 56 *) 57 for prefix in ${ipv6_faith_prefix}; do 58 prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 59 case ${prefixlen} in 60 '') 61 prefixlen=96 62 ;; 63 *) 64 prefix=`expr "${prefix}" : \ 65 "\(.*\)/${prefixlen}"` 66 ;; 67 esac 68 route delete -inet6 ${prefix} -prefixlen ${prefixlen} 69 done 70 ;; 71 esac 72} 73 74load_rc_config $name 75run_rc_command "$1" 76