routing_include.sh revision efa39fc653b61b21d59f6ac13c2431c9e5cbc2fc
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# IPfilter's firewall
#
# routed and its siblings use ICMP Router Discovery protocol, simply allow
# these packets so the client portion of routed can work.
#
{
# Allow incoming icmp from routers for successful discovery.
# IRDP - ICMP type 9 and 10, advertisement and solicitation, respectively.
#
echo "pass in log quick proto icmp from any to any icmp-type 10" >>${1}
echo "pass in log quick proto icmp from any to any icmp-type 9" >>${1}
}
#
# These functions are used to help map daemon arguments to appropriate
# routing properties and back, allowing legacy specifications of daemon
# arguments to be reflected in SMF property values for daemon services.
#
#
# set_routeadm_property inst_fmri propname propvalue
#
# Functions sets appropriate property value in routeadm property group
# (via routeadm -m) for inst_fmri to propvalue.
#
{
}
#
# The functions below are used to map from daemon arguments to appropriate
# routeadm properties (properties that the service user can manipulate
# to control daemon functionality. getopts is used extensively to
# are used to set properties appropriately.
#
#
# set_daemon_value_property inst_fmri optstring options option prop
# default_value
#
# property if found. If a default is specified, and the option is not
# in the argument string, it will be used.
#
{
OPTIND=1
value_set=""
while getopts $3 opt $2; do
value_set="true"
;;
? )
esac
done
# No value set - use default if specified.
set_routeadm_property $1 $5 $6
fi
}
#
# set_daemon_ordered_multivalue_property inst_fmri optstring options option prop
# default_value
#
# property if found. If a default is specified, and the option is not
# in the argument string, it will be used. Use ";" as delimiter for
# multiple values.
#
{
OPTIND=1
value_set=""
while getopts $3 opt $2; do
value_set="${OPTARG}"
else
value_set="$value_set;${OPTARG}"
fi
;;
? )
esac
done
set_routeadm_property $1 $5 "$value_set"
fi
# No value set - use default if specified.
set_routeadm_property $1 $5 $6
fi
}
#
# set_daemon_boolean_property inst_fmri optstring options option
# prop value_if_found default
#
# Function looks for option in argument string, and sets associated
# property, if found, to value_if_found. If a default is specified, and
# the option is not found, it will be used.
#
{
OPTIND=1
value_set=""
while getopts $3 opt $2; do
value_set="true"
;;
? )
esac
done
# No value set - use default if specified.
set_routeadm_property $1 $5 $7
fi
}
#
# set_daemon_nonoption_properties inst_fmri optstring options propnames
# default
#
# Function looks past option list for addition values, and sets properties
# specified in propnames to additional positional values. If no value
# is found for additional property, default is used.
#
{
OPTIND=1
# Skip options
while getopts $3 opt $2; do
? )
esac
done
do
'{ print $POS }'`
val="$5"
fi
done
}
#
# get_daemon_args $inst_fmri
#
# Retrieves routeadm/daemon-args property values, if any. Removes
# quotes around values including spaces.
#
{
echo "$args"
}
#
# clear_daemon_args $inst_fmri
#
# Blanks routeadm/daemon-args property used in upgrade.
#
{
}
#
# The functions below are used to map back from property settings to
# commandline arguments to launch daemons.
#
{
'($1 == PROP) { for (i = 3; i < NF; i++) printf $i" "; \
if (NF >= 3) {printf $NF}}'`
echo "$propval"
}
#
# get_daemon_option_from_boolean_property inst_fmri prop option value_set
#
# Returns appropriate daemon option for boolean property prop - if current
# value matches value_set.
#
{
propval=`get_routeadm_property $1 $2`
echo "${3}"
fi
}
#
# get_daemon_option_from_property inst_fmri prop option ignore_value
#
# Returns appropriate daemon option and associated value (unless value
# matches ignore_value, in which case nothing is returned).
#
{
propval=`get_routeadm_property $1 $2`
echo "-${3} $propval"
fi
}
#
# get_daemon_ordered_multivalue_option_from_property inst_fmri prop
# option
#
# Returns appropriate daemon option and associated values. Values are
# unquoted, i.e. -A value1 -A value2
#
{
# get property values, removing trailing delimiter.
propvals=`get_routeadm_property $1 $2 | \
# Substitute switch for internal delimiters.
fixed_propvals=`/usr/bin/echo $propvals | \
'{sub(/;/, SWITCH); print }'`
echo "-${3} $fixed_propvals"
fi
}
#
# get_nonoption_property inst_fmri prop ignore_value
#
# Returns appropriate non-option property (at end of option list), unless
# value matches ignore value, in which case nothing is returned.
#
{
propval=`get_routeadm_property $1 $2`
echo "$propval"
fi
}