#!/bin/sh

########################################################################
# Author:      Chris Williams
#              E-mail: cbwilliams@mail.rit.edu
#                      kermit6306@yahoo.com
#              AIM: kermit6306
#              WWW: http://www.rit.edu/~cbw8398
# Filename:    dhinfo.sh
# Date:        March 16, 2003
# Description: Bourne Shell script. Displays important information 
#              from the DHCP server for a particular interface.
#              Sun Solaris DHCP client dhcpagent(1) must be installed 
#
# References:  Assigned Numbers RFC: http://www.ietf.org/rfc/rfc1700.txt
#              Sun manuals: dhcpinfo(1), dhcpagent(1) 
#
#
########################################################################

if [ $# -ne 1 ]; then
	echo "Usage: $0 <iface>"
	exit
fi

if [ ! -x /sbin/dhcpinfo ]; then
	echo "Error: /sbin/dhcpinfo not executable. Check \c"
	echo "dhcpagent installation."
	exit
fi

echo ""

# initialize variables
iface=$1
count=1
while test $count -lt 77
do
	case $count in
        1) echo "Subnet Mask: \c" 
	   if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
           	echo ""
           fi;;

        3) echo "Gateway: \c" 
	   if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
           	echo ""
           fi;;

        5) echo "Name Server: \c"
	   if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
           	echo ""
           fi;;

        6) echo "Domain Server: \c"
       	   if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
           	echo ""
           fi;;

        12) echo "Hostname: \c"
	   if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
           	echo ""
           fi;;

	15) echo "Domain Name: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
	    	echo ""	
            fi;;

	19) echo "IP Fowarding On/Off: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	20) echo "Source Routing On/Off: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	21) echo "Filtering Policy: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	28) echo "Broadcast Adress: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	23) echo "Default IP TTL: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	37) echo "Default TCP TTL: \c"
            if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	40) echo "NIS Domain: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	41) echo "NIS Server: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	44) echo "NetBIOS Server: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	50) echo "Requested IP Address: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	51) echo "IP Address Lease Time: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	53) echo "DCHP Message Type: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	54) echo "DHCP Server Name: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

	56) echo "DHCP Error Message: \c"
	    if [ -z "`/sbin/dhcpinfo -i $iface $count`" ]; then
                echo "" 
            fi;;

        esac
	/sbin/dhcpinfo -i $iface $count
	count=`expr $count + 1`
done
