xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/routeadm/svc-forwarding (revision 12016:0248e987199b)
13048Samaguire#!/sbin/sh
23048Samaguire#
33048Samaguire# CDDL HEADER START
43048Samaguire#
53048Samaguire# The contents of this file are subject to the terms of the
63048Samaguire# Common Development and Distribution License (the "License").
73048Samaguire# You may not use this file except in compliance with the License.
83048Samaguire#
93048Samaguire# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
103048Samaguire# or http://www.opensolaris.org/os/licensing.
113048Samaguire# See the License for the specific language governing permissions
123048Samaguire# and limitations under the License.
133048Samaguire#
143048Samaguire# When distributing Covered Code, include this CDDL HEADER in each
153048Samaguire# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
163048Samaguire# If applicable, add the following below this CDDL HEADER, with the
173048Samaguire# fields enclosed by brackets "[]" replaced with your own identifying
183048Samaguire# information: Portions Copyright [yyyy] [name of copyright owner]
193048Samaguire#
203048Samaguire# CDDL HEADER END
213048Samaguire#
223048Samaguire#
23*12016SGirish.Moodalbail@Sun.COM# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
243048Samaguire# Use is subject to license terms.
253048Samaguire#
263048Samaguire
273048Samaguire# This script is the shared method script for the ipv4-routing, ipv6-routing,
283048Samaguire# ipv4-forwarding and ipv6-forwarding services.
293048Samaguire
303048Samaguire. /lib/svc/share/smf_include.sh
313048Samaguire
323048Samaguireusage() {
333048Samaguire	echo "Usage: $0 { start | stop | refresh } { ipv4 | ipv6 }"
343048Samaguire}
353048Samaguire
363048Samaguirenumv6ifs=`/usr/sbin/ifconfig -au6 | /usr/bin/grep -c inet6`
373048Samaguire
383048Samaguiremethod="$1"
393048Samaguireproto="$2"
403048Samaguire
413048Samaguireif [ -z "$proto" ]; then
423048Samaguire	usage
433048Samaguire	exit $SMF_ERROR_FATAL
443048Samaguirefi
453048Samaguire
463048Samaguirecase "$1" in
473048Samaguire'start' | 'refresh' )
483448Sdh155122	smf_configure_ip || exit $SMF_EXIT_OK
493048Samaguire	#
503048Samaguire	# Start ip forwarding.
513048Samaguire	#
523048Samaguire	if [ "$proto" = "ipv6" -a "$numv6ifs" = 0 ]; then
533048Samaguire		echo "Error: no IPv6 interface configured"
543048Samaguire		exit $SMF_EXIT_ERR_CONFIG
553048Samaguire	fi
56*12016SGirish.Moodalbail@Sun.COM
57*12016SGirish.Moodalbail@Sun.COM	/usr/sbin/ipadm set-prop -p forwarding=on $proto
58*12016SGirish.Moodalbail@Sun.COM	[ "$proto" = "ipv6" ] && /usr/sbin/ipadm set-prop \
59*12016SGirish.Moodalbail@Sun.COM				    -p ip6_send_redirects=1 ip
603048Samaguire        ;;
613048Samaguire'stop')
62*12016SGirish.Moodalbail@Sun.COM	/usr/sbin/ipadm set-prop -p forwarding=off $proto
63*12016SGirish.Moodalbail@Sun.COM	[ "$proto" = "ipv6" ] && /usr/sbin/ipadm set-prop \
64*12016SGirish.Moodalbail@Sun.COM				    -p ip6_send_redirects=0 ip
653048Samaguire	;;
663048Samaguire*)
673048Samaguire	usage
683048Samaguire        exit $SMF_ERROR_FATAL
693048Samaguire        ;;
703048Samaguireesac
713048Samaguire
723048Samaguireexit "$SMF_EXIT_OK"
73