faith revision 197139
1197139Shrs#!/bin/sh 2197139Shrs# $FreeBSD: head/etc/rc.d/faith 197139 2009-09-12 22:13:41Z hrs $ 3197139Shrs# 4197139Shrs 5197139Shrs# PROVIDE: faith 6197139Shrs# REQUIRE: netif routing 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." 24197139Shrs ${SYSCTL_W} 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 42197139Shrs if [ -z "${rc_quiet}" ]; then 43197139Shrs ifconfig faith0 44197139Shrs fi 45197139Shrs ;; 46197139Shrs esac 47197139Shrs} 48197139Shrs 49197139Shrsfaith_down() 50197139Shrs{ 51197139Shrs echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0." 52197139Shrs ifconfig faith0 destroy 53197139Shrs ${SYSCTL_W} net.inet6.ip6.keepfaith=0 54197139Shrs 55197139Shrs case ${ipv6_faith_prefix} in 56197139Shrs [Nn][Oo] | '') 57197139Shrs ;; 58197139Shrs *) 59197139Shrs for prefix in ${ipv6_faith_prefix}; do 60197139Shrs prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 61197139Shrs case ${prefixlen} in 62197139Shrs '') 63197139Shrs prefixlen=96 64197139Shrs ;; 65197139Shrs *) 66197139Shrs prefix=`expr "${prefix}" : \ 67197139Shrs "\(.*\)/${prefixlen}"` 68197139Shrs ;; 69197139Shrs esac 70197139Shrs route delete -inet6 ${prefix} -prefixlen ${prefixlen} 71197139Shrs done 72197139Shrs ;; 73197139Shrs esac 74197139Shrs} 75197139Shrs 76197139Shrsload_rc_config $name 77197139Shrsrun_rc_command "$1" 78