faith revision 197701
1#!/bin/sh 2# $FreeBSD: head/etc/rc.d/faith 197701 2009-10-02 06:19:34Z hrs $ 3# 4 5# PROVIDE: faith 6# REQUIRE: netif routing 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_W} 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 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