utilities.san revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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
#
#
#ident "%Z%%M% %I% %E% SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#
# Process arguments.
#
{
ERR=
USAGE="Usage: %s: [-d]"
do
?) ERR=1;;
esac
done
#
# If the resource is a valid option, then it is a required one
#
if [ $? == 0 ]
then
USAGE="${USAGE} -r resource"
if [ -z "${DHCPRSRC}" ]
then
ERR=1
fi
fi
#
# If the path is a valid option, then it is a required one
#
if [ $? == 0 ]
then
USAGE="${USAGE} -p path"
if [ -z "${DHCPPATH}" ]
then
ERR=1
fi
fi
#
# If the conversion resource is a valid option, then it is a required one
#
if [ $? == 0 ]
then
USAGE="${USAGE} -R resource"
if [ -z "${DHCPRSRC_NEW}" ]
then
ERR=1
fi
fi
#
# If the conversion path is a valid option, then it is a required one
#
if [ $? == 0 ]
then
USAGE="${USAGE} -P path"
if [ -z "${DHCPPATH_NEW}" ]
then
ERR=1
fi
fi
if [ ! -z "${ERR}" ]
then
exit -1
fi
}
#
# Return the primary interface's IP address.
#
{
}
#
# Based on the network specification, determine whether or not network is
# subnetted or supernetted.
# Given a dotted IP network number, convert it to the default class
# network.(used to detect subnetting). Requires one argument, the
# network number. (e.g. 10.0.0.0) Echos the default network and default
# mask for success, null if error.
#
{
NN01=${1%%.*}
tmp=${1#*.}
RETNET=""
RETMASK=""
if [ ${X} -eq 224 ]
then
# Multicast
RETNET="${TMP}.0.0.0"
RETMASK="240.0.0.0"
fi
then
# Class A
RETNET="${NN01}.0.0.0"
RETMASK="255.0.0.0"
fi
then
# Class B
RETNET="${NN01}.${NN02}.0.0"
RETMASK="255.255.0.0"
fi
then
# Class C
RETNET="${NN01}.${NN02}.${NN03}.0"
RETMASK="255.255.255.0"
fi
}
#
# Based on the nsswitch setting, query the netmasks table for a netmask.
# Accepts one argument, a dotted IP address.
#
{
if [ ! -z "${MTMP}" ]
then
print - ${MTMP}
fi
}
# Given a network number and subnetmask, return the broadcast address.
{
tmp=${1#*.}
tmp=${2#*.}
print - "${ONE}.${TWO}.${THREE}.${FOUR}"
}
# Given a network number and subnetmask, return the subnet address.
{
tmp=${1#*.}
tmp=${2#*.}
print - "${ONE}.${TWO}.${THREE}.${FOUR}"
}
#
# defined in SRCH, search the macro definition for the string. If not found, abort.
# If found, remove the string from the definition.
#
{
if [ "${VAL}" = "0" ]
then
echo "${SRCH} not defined as part of the macro definition"
echo "${TESTNAME} - Test failed!"
exit 1
fi
}
#
# Given a macro or option definition, returns its value.
#
function get_value
{
}