1 #!/usr/bin/ksh
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # with the License.
   9 #
  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 #ident  "%Z%%M% %I%     %E% SMI"
  25 #
  26 # Copyright (c) 2001 by Sun Microsystems, Inc.
  27 # All rights reserved.
  28 #
  29 
  30 #
  31 # Source the utilities.
  32 #
  33 DIRNAME=`dirname $0`
  34 . ${DIRNAME}/utilities.san
  35 
  36 #
  37 # Process the input arguments.
  38 #
  39 VALIDOPTS=dr:p:
  40 process_args $@
  41 
  42 #
  43 # In case the tester wants to see script output, allow them
  44 # to run in debug mode.
  45 #
  46 TESTNAME=`basename $0`
  47 if [ ! -z "${DEBUG}" ]
  48 then
  49     OUTFILE=/tmp/${TESTNAME}.$$
  50     echo "Output from test: ${TESTNAME}" >${OUTFILE}
  51     echo >>${OUTFILE}
  52     echo "debug output can be found at ${OUTFILE}"
  53 else
  54     OUTFILE=/dev/null
  55 fi
  56 
  57 #
  58 # Set variables.
  59 #
  60 TESTNAME=`basename $0`
  61 SRVNAME=`uname -n`
  62 SRVADDR=`get_server_ip`
  63 
  64 #
  65 # Determine subnet, netmask, and broadcast address.
  66 #
  67 get_default_class ${SRVADDR} | read DEFNET DEFMASK
  68 SUBNET=`get_netmask ${SRVADDR}`
  69 if [ -z "${SUBNET}" ]
  70 then
  71     if [ "${DEFNET}" != "${SRVADDR}" ]
  72     then
  73         # likely subnetted/supernetted.
  74         print - "\n\n###\tWarning\t###\n"
  75         print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2
  76         return 1
  77     else
  78         # use the default.
  79         SUBNET="${DEFMASK}"
  80     fi
  81 fi
  82 
  83 SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}`
  84 
  85 #
  86 # Display the table.
  87 #
  88 DATAFILE=/tmp/${TESTNAME}.data.$$
  89 /usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L >${DATAFILE} 2>>${OUTFILE}
  90 RET=$?
  91 if [ "${RET}" != "0" ]
  92 then
  93     rm ${DATAFILE}
  94     echo "Error listing ${SUBNETADDR} table = ${RET}"
  95     echo "${TESTNAME} - Test failed!"
  96     exit 1
  97 fi
  98 
  99 ENTRY=`grep "^${SUBNETADDR}$" ${DATAFILE}`
 100 if [ -z "${ENTRY}" ]
 101 then
 102     rm ${DATAFILE}
 103     echo "Did not find network table, ${SUBNETADDR}"
 104     echo "${TESTNAME} - Test failed!"
 105     exit 1
 106 fi
 107 rm ${DATAFILE}
 108 
 109 echo "${TESTNAME} - Test passed."
 110 exit 0