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 # Verify that the network table exists.
87 #
88 NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}`
89 NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}`
90 if [ -z ${NETTAB} ]
91 then
92 echo "Network table for ${SUBNETADDR} does not exist."
93 echo "${TESTNAME} - Test failed!"
94 exit 1
95 fi
96
97 #
98 # Display the table.
99 #
100 CLIENTID="01AABBCCDDEEFF"
101 FLAGS="01"
102 CADDR=${SRVADDR}
103 SADDR=${SRVADDR}
104 EXPIRE="03/15/2001"
105 MACRO="UNKNOWN"
106 COMMENT=Modified
107 DATAFILE=/tmp/${TESTNAME}.data.$$
108
109 /usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -P ${SUBNETADDR} >${DATAFILE} 2>>${OUTFILE}
110 RET=$?
111 if [ "${RET}" != "0" ]
112 then
113 rm ${DATAFILE}
114 echo "Error listing table for ${SUBNETADDR} = ${RET}"
115 echo "${TESTNAME} - Test failed!"
116 exit 1
117 fi
118
119 ENTRY=`grep "^${CLIENTID}" ${DATAFILE}`
120 if [ -z "${ENTRY}" ]
121 then
122 rm ${DATAFILE}
123 echo "Client entry not found in ${SUBNETADDR}"
124 echo "${TESTNAME} - Test failed!"
125 exit 1
126 fi
127 rm ${DATAFILE}
128
129 #
130 # Verify that the entry fields are correct.
131 #
132 FIELD=`echo $ENTRY | cut -d " " -f1,1`
133 if [ "${FIELD}" != "${CLIENTID}" ]
134 then
135 echo "ClientID of entry is not correct in ${SUBNETADDR}"
136 echo "${FIELD} != ${CLIENTID}"
137 echo "${TESTNAME} - Test failed!"
138 exit 1
139 fi
140
141 FIELD=`echo $ENTRY | cut -d " " -f2,2`
142 if [ "${FIELD}" != "${FLAGS}" ]
143 then
144 echo "Flags of entry is not correct in ${SUBNETADDR}"
145 echo "${FIELD} != ${FLAGS}"
146 echo "${TESTNAME} - Test failed!"
147 exit 1
148 fi
149
150 FIELD=`echo $ENTRY | cut -d " " -f3,3`
151 if [ "${FIELD}" != "${CADDR}" ]
152 then
153 echo "Client address of entry is not correct in ${SUBNETADDR}"
154 echo "${FIELD} != ${CADDR}"
155 echo "${TESTNAME} - Test failed!"
156 exit 1
157 fi
158
159 FIELD=`echo $ENTRY | cut -d " " -f4,4`
160 if [ "${FIELD}" != "${SADDR}" ]
161 then
162 echo "Server address of entry is not correct in ${SUBNETADDR}"
163 echo "${FIELD} != ${SADDR}"
164 echo "${TESTNAME} - Test failed!"
165 exit 1
166 fi
167
168 FIELD=`echo $ENTRY | cut -d " " -f5,5`
169 if [ "${FIELD}" != "${EXPIRE}" ]
170 then
171 echo "Lease expiration of entry is not correct in ${SUBNETADDR}"
172 echo "${FIELD} != ${EXPIRE}"
173 echo "${TESTNAME} - Test failed!"
174 exit 1
175 fi
176
177 FIELD=`echo $ENTRY | cut -d " " -f6,6`
178 if [ "${FIELD}" != "${MACRO}" ]
179 then
180 echo "Macro of entry is not correct in ${SUBNETADDR}"
181 echo "${FIELD} != ${MACRO}"
182 echo "${TESTNAME} - Test failed!"
183 exit 1
184 fi
185
186 FIELD=`echo $ENTRY | cut -d " " -f7,7`
187 if [ "${FIELD}" != "${COMMENT}" ]
188 then
189 echo "Comment field of entry is not correct in ${SUBNETADDR}"
190 echo "${FIELD} != ${COMMENT}"
191 echo "${TESTNAME} - Test failed!"
192 exit 1
193 fi
194
195 echo "${TESTNAME} - Test passed."
196 exit 0