faith revision 197139
1135446Strhodes#!/bin/sh 2193149Sdougb# $FreeBSD: head/etc/rc.d/faith 197139 2009-09-12 22:13:41Z hrs $ 3135446Strhodes# 4135446Strhodes 5193149Sdougb# PROVIDE: faith 6135446Strhodes# REQUIRE: netif routing 7135446Strhodes# KEYWORD: nojail 8135446Strhodes 9135446Strhodes. /etc/rc.subr 10135446Strhodes. /etc/network.subr 11135446Strhodes 12135446Strhodesname="faith" 13135446Strhodesstart_cmd="faith_up" 14135446Strhodesstop_cmd="faith_down" 15135446Strhodes 16135446Strhodesfaith_up() 17135446Strhodes{ 18234010Sdougb case ${ipv6_faith_prefix} in 19135446Strhodes [Nn][Oo] | '') 20135446Strhodes ;; 21135446Strhodes *) 22135446Strhodes echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \ 23193149Sdougb " faith0." 24170222Sdougb ${SYSCTL_W} net.inet6.ip6.keepfaith=1 25135446Strhodes ifconfig faith0 create >/dev/null 2>&1 26135446Strhodes ifconfig faith0 up 27135446Strhodes for prefix in ${ipv6_faith_prefix}; do 28135446Strhodes prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 29135446Strhodes case ${prefixlen} in 30135446Strhodes '') 31135446Strhodes prefixlen=96 32135446Strhodes ;; 33135446Strhodes *) 34135446Strhodes prefix=`expr "${prefix}" : \ 35135446Strhodes "\(.*\)/${prefixlen}"` 36135446Strhodes ;; 37135446Strhodes esac 38135446Strhodes route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1 39135446Strhodes route change -inet6 ${prefix} -prefixlen ${prefixlen} \ 40135446Strhodes -ifp faith0 41 done 42 if [ -z "${rc_quiet}" ]; then 43 ifconfig faith0 44 fi 45 ;; 46 esac 47} 48 49faith_down() 50{ 51 echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0." 52 ifconfig faith0 destroy 53 ${SYSCTL_W} net.inet6.ip6.keepfaith=0 54 55 case ${ipv6_faith_prefix} in 56 [Nn][Oo] | '') 57 ;; 58 *) 59 for prefix in ${ipv6_faith_prefix}; do 60 prefixlen=`expr "${prefix}" : ".*/\(.*\)"` 61 case ${prefixlen} in 62 '') 63 prefixlen=96 64 ;; 65 *) 66 prefix=`expr "${prefix}" : \ 67 "\(.*\)/${prefixlen}"` 68 ;; 69 esac 70 route delete -inet6 ${prefix} -prefixlen ${prefixlen} 71 done 72 ;; 73 esac 74} 75 76load_rc_config $name 77run_rc_command "$1" 78