1197139Shrs#!/bin/sh 2197139Shrs# $FreeBSD$ 3197139Shrs# 4197139Shrs 5197139Shrs# PROVIDE: faith 6198190Sdougb# REQUIRE: netif 7197139Shrs# KEYWORD: nojail 8197139Shrs 9197139Shrs. /etc/rc.subr 10197139Shrs. /etc/network.subr 11197139Shrs 12197139Shrsname="faith" 13197139Shrsstart_cmd="faith_up" 14197139Shrsstop_cmd="faith_down" 15197139Shrs 16197139Shrsfaith_up() 17197139Shrs{ 18197139Shrs case ${ipv6_faith_prefix} in 19197139Shrs [Nn][Oo] | '') 20197139Shrs ;; 21197139Shrs *) 22197139Shrs echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \ 23197139Shrs " faith0." 24220153Semaste ${SYSCTL} net.inet6.ip6.keepfaith=1 25197139Shrs ifconfig faith0 create >/dev/null 2>&1 26197139Shrs ifconfig faith0 up 27197139Shrs for prefix in ${ipv6_faith_prefix}; do 28197139Shrs prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 29197139Shrs case ${prefixlen} in 30197139Shrs '') 31197139Shrs prefixlen=96 32197139Shrs ;; 33197139Shrs *) 34197139Shrs prefix=`expr "${prefix}" : \ 35197139Shrs "\(.*\)/${prefixlen}"` 36197139Shrs ;; 37197139Shrs esac 38197139Shrs route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1 39197139Shrs route change -inet6 ${prefix} -prefixlen ${prefixlen} \ 40197139Shrs -ifp faith0 41197139Shrs done 42197947Sdougb check_startmsgs && ifconfig faith0 43197139Shrs ;; 44197139Shrs esac 45197139Shrs} 46197139Shrs 47197139Shrsfaith_down() 48197139Shrs{ 49197139Shrs echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0." 50197139Shrs ifconfig faith0 destroy 51220153Semaste ${SYSCTL} net.inet6.ip6.keepfaith=0 52197139Shrs 53197139Shrs case ${ipv6_faith_prefix} in 54197139Shrs [Nn][Oo] | '') 55197139Shrs ;; 56197139Shrs *) 57197139Shrs for prefix in ${ipv6_faith_prefix}; do 58197139Shrs prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 59197139Shrs case ${prefixlen} in 60197139Shrs '') 61197139Shrs prefixlen=96 62197139Shrs ;; 63197139Shrs *) 64197139Shrs prefix=`expr "${prefix}" : \ 65197139Shrs "\(.*\)/${prefixlen}"` 66197139Shrs ;; 67197139Shrs esac 68197139Shrs route delete -inet6 ${prefix} -prefixlen ${prefixlen} 69197139Shrs done 70197139Shrs ;; 71197139Shrs esac 72197139Shrs} 73197139Shrs 74197139Shrsload_rc_config $name 75197139Shrsrun_rc_command "$1" 76