1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 1996 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*0Sstevel@tonic-gate 
28*0Sstevel@tonic-gate #include <sys/types.h>
29*0Sstevel@tonic-gate #include <netinet/in.h>
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #include "impl.h"
32*0Sstevel@tonic-gate #include "asn1.h"
33*0Sstevel@tonic-gate #include "error.h"
34*0Sstevel@tonic-gate #include "snmp.h"
35*0Sstevel@tonic-gate #include "trap.h"
36*0Sstevel@tonic-gate #include "pdu.h"
37*0Sstevel@tonic-gate #include "node.h"
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #include "snmpdx_stub.h"
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate /***** regTblEntry          ********************************/
44*0Sstevel@tonic-gate 
get_regTblEntry(int search_type,RegTblEntry_t ** regTblEntry_data,IndexType * index)45*0Sstevel@tonic-gate extern int get_regTblEntry(int search_type, RegTblEntry_t **regTblEntry_data, IndexType *index)
46*0Sstevel@tonic-gate {
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate 	int res;
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate 	*regTblEntry_data = (RegTblEntry_t*)calloc(1,sizeof(RegTblEntry_t));
51*0Sstevel@tonic-gate 	if(regTblEntry_data == NULL) return SNMP_ERR_GENERR;
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate 	res = get_regTblIndex(
54*0Sstevel@tonic-gate 	        search_type,
55*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblIndex),
56*0Sstevel@tonic-gate 	        index);
57*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate 	res = get_regTblAgentID(
60*0Sstevel@tonic-gate 	        search_type,
61*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblAgentID),
62*0Sstevel@tonic-gate 	        index);
63*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate 	res = get_regTblOID(
66*0Sstevel@tonic-gate 	        search_type,
67*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblOID),
68*0Sstevel@tonic-gate 	        index);
69*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate 	res = get_regTblStartColumn(
72*0Sstevel@tonic-gate 	        search_type,
73*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblStartColumn),
74*0Sstevel@tonic-gate 	        index);
75*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate 	res = get_regTblEndColumn(
78*0Sstevel@tonic-gate 	        search_type,
79*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblEndColumn),
80*0Sstevel@tonic-gate 	        index);
81*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate 	res = get_regTblStartRow(
84*0Sstevel@tonic-gate 	        search_type,
85*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblStartRow),
86*0Sstevel@tonic-gate 	        index);
87*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate 	res = get_regTblEndRow(
90*0Sstevel@tonic-gate 	        search_type,
91*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblEndRow),
92*0Sstevel@tonic-gate 	        index);
93*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate 	res = get_regTblStatus(
96*0Sstevel@tonic-gate 	        search_type,
97*0Sstevel@tonic-gate 	        &((*regTblEntry_data)->regTblStatus),
98*0Sstevel@tonic-gate 	        index);
99*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate 	 return res;
102*0Sstevel@tonic-gate }
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate 
free_regTblEntry(RegTblEntry_t * regTblEntry)105*0Sstevel@tonic-gate void free_regTblEntry(RegTblEntry_t *regTblEntry)
106*0Sstevel@tonic-gate {
107*0Sstevel@tonic-gate 	free_regTblOID(&(regTblEntry->regTblOID));
108*0Sstevel@tonic-gate }
109*0Sstevel@tonic-gate 
get_regTblIndex(int search_type,Integer * regTblIndex,IndexType * index)110*0Sstevel@tonic-gate int get_regTblIndex(int search_type, Integer *regTblIndex, IndexType *index)
111*0Sstevel@tonic-gate {
112*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
113*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
114*0Sstevel@tonic-gate 	/* appropriate value */
115*0Sstevel@tonic-gate 	switch(search_type)
116*0Sstevel@tonic-gate 	{
117*0Sstevel@tonic-gate 		case FIRST_ENTRY:
118*0Sstevel@tonic-gate 			if(index->type == INTEGER){
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate 				/* assume 1 is the first index */
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 				index->value[0] = 1;
123*0Sstevel@tonic-gate 				index->len = 1;
124*0Sstevel@tonic-gate 			}else{
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate 				/* index type will be array of integer */
127*0Sstevel@tonic-gate 				/* assume that there are two index */
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate 				index->value[0] = 1;
130*0Sstevel@tonic-gate 				index->value[1]= 1;
131*0Sstevel@tonic-gate 				index->len = 2;
132*0Sstevel@tonic-gate 			}
133*0Sstevel@tonic-gate 			break;
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate 		case NEXT_ENTRY:
136*0Sstevel@tonic-gate 			if(index->type == INTEGER){
137*0Sstevel@tonic-gate 				index->value[0]++;
138*0Sstevel@tonic-gate 			}else{
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate 				/* index type will be array of integer */
141*0Sstevel@tonic-gate 				/* assume that there are two index */
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate 				index->value[index->len-1]++;
144*0Sstevel@tonic-gate 			}
145*0Sstevel@tonic-gate 			break;
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate 		case EXACT_ENTRY:
148*0Sstevel@tonic-gate 			break;
149*0Sstevel@tonic-gate 	}
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
152*0Sstevel@tonic-gate 
153*0Sstevel@tonic-gate 	*regTblIndex = 1;
154*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
155*0Sstevel@tonic-gate }
156*0Sstevel@tonic-gate 
get_regTblAgentID(int search_type,Integer * regTblAgentID,IndexType * index)157*0Sstevel@tonic-gate int get_regTblAgentID(int search_type, Integer *regTblAgentID, IndexType *index)
158*0Sstevel@tonic-gate {
159*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
160*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
161*0Sstevel@tonic-gate 	/* appropriate value */
162*0Sstevel@tonic-gate 	switch(search_type)
163*0Sstevel@tonic-gate 	{
164*0Sstevel@tonic-gate 		case FIRST_ENTRY:
165*0Sstevel@tonic-gate 			if(index->type == INTEGER){
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate 				/* assume 1 is the first index */
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate 				index->value[0] = 1;
170*0Sstevel@tonic-gate 				index->len = 1;
171*0Sstevel@tonic-gate 			}else{
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate 				/* index type will be array of integer */
174*0Sstevel@tonic-gate 				/* assume that there are two index */
175*0Sstevel@tonic-gate 
176*0Sstevel@tonic-gate 				index->value[0] = 1;
177*0Sstevel@tonic-gate 				index->value[1]= 1;
178*0Sstevel@tonic-gate 				index->len = 2;
179*0Sstevel@tonic-gate 			}
180*0Sstevel@tonic-gate 			break;
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate 		case NEXT_ENTRY:
183*0Sstevel@tonic-gate 			if(index->type == INTEGER){
184*0Sstevel@tonic-gate 				index->value[0]++;
185*0Sstevel@tonic-gate 			}else{
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate 				/* index type will be array of integer */
188*0Sstevel@tonic-gate 				/* assume that there are two index */
189*0Sstevel@tonic-gate 
190*0Sstevel@tonic-gate 				index->value[index->len-1]++;
191*0Sstevel@tonic-gate 			}
192*0Sstevel@tonic-gate 			break;
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate 		case EXACT_ENTRY:
195*0Sstevel@tonic-gate 			break;
196*0Sstevel@tonic-gate 	}
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
199*0Sstevel@tonic-gate 
200*0Sstevel@tonic-gate 	*regTblAgentID = 1;
201*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
202*0Sstevel@tonic-gate }
203*0Sstevel@tonic-gate 
get_regTblOID(int search_type,Oid * regTblOID,IndexType * index)204*0Sstevel@tonic-gate int get_regTblOID(int search_type, Oid *regTblOID, IndexType *index)
205*0Sstevel@tonic-gate {
206*0Sstevel@tonic-gate 	Subid *sub;
207*0Sstevel@tonic-gate 	Subid fake_sub[] = {1,3,6,1,4,1,4,42};
208*0Sstevel@tonic-gate 	int len;
209*0Sstevel@tonic-gate 
210*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
211*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
212*0Sstevel@tonic-gate 	/* appropriate value */
213*0Sstevel@tonic-gate 	switch(search_type)
214*0Sstevel@tonic-gate 	{
215*0Sstevel@tonic-gate 		case FIRST_ENTRY:
216*0Sstevel@tonic-gate 			if(index->type == INTEGER){
217*0Sstevel@tonic-gate 
218*0Sstevel@tonic-gate 				/* assume 1 is the first index */
219*0Sstevel@tonic-gate 
220*0Sstevel@tonic-gate 				index->value[0] = 1;
221*0Sstevel@tonic-gate 				index->len = 1;
222*0Sstevel@tonic-gate 			}else{
223*0Sstevel@tonic-gate 
224*0Sstevel@tonic-gate 				/* index type will be array of integer */
225*0Sstevel@tonic-gate 				/* assume that there are two index */
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate 				index->value[0] = 1;
228*0Sstevel@tonic-gate 				index->value[1]= 1;
229*0Sstevel@tonic-gate 				index->len = 2;
230*0Sstevel@tonic-gate 			}
231*0Sstevel@tonic-gate 			break;
232*0Sstevel@tonic-gate 
233*0Sstevel@tonic-gate 		case NEXT_ENTRY:
234*0Sstevel@tonic-gate 			if(index->type == INTEGER){
235*0Sstevel@tonic-gate 				index->value[0]++;
236*0Sstevel@tonic-gate 			}else{
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate 				/* index type will be array of integer */
239*0Sstevel@tonic-gate 				/* assume that there are two index */
240*0Sstevel@tonic-gate 
241*0Sstevel@tonic-gate 				index->value[index->len-1]++;
242*0Sstevel@tonic-gate 			}
243*0Sstevel@tonic-gate 			break;
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate 		case EXACT_ENTRY:
246*0Sstevel@tonic-gate 			break;
247*0Sstevel@tonic-gate 	}
248*0Sstevel@tonic-gate 
249*0Sstevel@tonic-gate 	/* It is required to allocate memory to the pointers */
250*0Sstevel@tonic-gate 	/* inside the input argument */
251*0Sstevel@tonic-gate 	/* Here, we assume that "1.3.6.1.4.1.42" is the value */
252*0Sstevel@tonic-gate 	/* of the mib variable */
253*0Sstevel@tonic-gate 	/* please change it to the real one */
254*0Sstevel@tonic-gate 
255*0Sstevel@tonic-gate 	/* 1.3.6.1.4.1.42 has 7 number separated by "." */
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate 	len =7 ;
258*0Sstevel@tonic-gate 	sub = (Subid*)calloc(len,sizeof(Subid));
259*0Sstevel@tonic-gate 	if(sub==NULL) return SNMP_ERR_GENERR;
260*0Sstevel@tonic-gate 	memcpy(sub,fake_sub,len*sizeof(Subid));
261*0Sstevel@tonic-gate 
262*0Sstevel@tonic-gate 	/* fill in the contents of the argument */
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate 	regTblOID->subids = sub;
265*0Sstevel@tonic-gate 	regTblOID->len = len;
266*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
267*0Sstevel@tonic-gate }
268*0Sstevel@tonic-gate 
set_regTblOID(int pass,IndexType index,Oid * regTblOID)269*0Sstevel@tonic-gate int set_regTblOID(int pass, IndexType index, Oid *regTblOID)
270*0Sstevel@tonic-gate {
271*0Sstevel@tonic-gate 	switch(pass)
272*0Sstevel@tonic-gate 	{
273*0Sstevel@tonic-gate 		case FIRST_PASS:
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate 			/* check the existence of the element which */
276*0Sstevel@tonic-gate 			/* corresponding to the given index and */
277*0Sstevel@tonic-gate 			/* check the validity fo the input value */
278*0Sstevel@tonic-gate 			/* if not valid or not exist, */
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
281*0Sstevel@tonic-gate 
282*0Sstevel@tonic-gate 		case SECOND_PASS:
283*0Sstevel@tonic-gate 
284*0Sstevel@tonic-gate 			/* change the following coding, such that */
285*0Sstevel@tonic-gate 			/* the input value will be stored in the */
286*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
287*0Sstevel@tonic-gate 			/* index */
288*0Sstevel@tonic-gate 			printf("The new value is %s\n",SSAOidString(regTblOID));
289*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
290*0Sstevel@tonic-gate 	}
291*0Sstevel@tonic-gate }
292*0Sstevel@tonic-gate 
293*0Sstevel@tonic-gate 
free_regTblOID(Oid * regTblOID)294*0Sstevel@tonic-gate void free_regTblOID(Oid *regTblOID)
295*0Sstevel@tonic-gate {
296*0Sstevel@tonic-gate 	 if(regTblOID->subids!=NULL && regTblOID->len !=0)
297*0Sstevel@tonic-gate 	{
298*0Sstevel@tonic-gate 		free(regTblOID->subids);
299*0Sstevel@tonic-gate 		regTblOID->len = 0;
300*0Sstevel@tonic-gate 	}
301*0Sstevel@tonic-gate }
302*0Sstevel@tonic-gate 
get_regTblStartColumn(int search_type,Integer * regTblStartColumn,IndexType * index)303*0Sstevel@tonic-gate int get_regTblStartColumn(int search_type, Integer *regTblStartColumn, IndexType *index)
304*0Sstevel@tonic-gate {
305*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
306*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
307*0Sstevel@tonic-gate 	/* appropriate value */
308*0Sstevel@tonic-gate 	switch(search_type)
309*0Sstevel@tonic-gate 	{
310*0Sstevel@tonic-gate 		case FIRST_ENTRY:
311*0Sstevel@tonic-gate 			if(index->type == INTEGER){
312*0Sstevel@tonic-gate 
313*0Sstevel@tonic-gate 				/* assume 1 is the first index */
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate 				index->value[0] = 1;
316*0Sstevel@tonic-gate 				index->len = 1;
317*0Sstevel@tonic-gate 			}else{
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate 				/* index type will be array of integer */
320*0Sstevel@tonic-gate 				/* assume that there are two index */
321*0Sstevel@tonic-gate 
322*0Sstevel@tonic-gate 				index->value[0] = 1;
323*0Sstevel@tonic-gate 				index->value[1]= 1;
324*0Sstevel@tonic-gate 				index->len = 2;
325*0Sstevel@tonic-gate 			}
326*0Sstevel@tonic-gate 			break;
327*0Sstevel@tonic-gate 
328*0Sstevel@tonic-gate 		case NEXT_ENTRY:
329*0Sstevel@tonic-gate 			if(index->type == INTEGER){
330*0Sstevel@tonic-gate 				index->value[0]++;
331*0Sstevel@tonic-gate 			}else{
332*0Sstevel@tonic-gate 
333*0Sstevel@tonic-gate 				/* index type will be array of integer */
334*0Sstevel@tonic-gate 				/* assume that there are two index */
335*0Sstevel@tonic-gate 
336*0Sstevel@tonic-gate 				index->value[index->len-1]++;
337*0Sstevel@tonic-gate 			}
338*0Sstevel@tonic-gate 			break;
339*0Sstevel@tonic-gate 
340*0Sstevel@tonic-gate 		case EXACT_ENTRY:
341*0Sstevel@tonic-gate 			break;
342*0Sstevel@tonic-gate 	}
343*0Sstevel@tonic-gate 
344*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
345*0Sstevel@tonic-gate 
346*0Sstevel@tonic-gate 	*regTblStartColumn = 1;
347*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
348*0Sstevel@tonic-gate }
349*0Sstevel@tonic-gate 
set_regTblStartColumn(int pass,IndexType index,Integer * regTblStartColumn)350*0Sstevel@tonic-gate int set_regTblStartColumn(int pass, IndexType index, Integer *regTblStartColumn)
351*0Sstevel@tonic-gate {
352*0Sstevel@tonic-gate 	switch(pass)
353*0Sstevel@tonic-gate 	{
354*0Sstevel@tonic-gate 		case FIRST_PASS:
355*0Sstevel@tonic-gate 
356*0Sstevel@tonic-gate 			/* check the existence of the element which */
357*0Sstevel@tonic-gate 			/* corresponding to the given index and */
358*0Sstevel@tonic-gate 			/* check the validity fo the input value */
359*0Sstevel@tonic-gate 			/* if not valid or not exist, */
360*0Sstevel@tonic-gate 
361*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
362*0Sstevel@tonic-gate 
363*0Sstevel@tonic-gate 		case SECOND_PASS:
364*0Sstevel@tonic-gate 
365*0Sstevel@tonic-gate 			/* change the following coding, such that */
366*0Sstevel@tonic-gate 			/* the input value will be stored in the */
367*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
368*0Sstevel@tonic-gate 			/* index */
369*0Sstevel@tonic-gate 			printf("The new value is %d\n",regTblStartColumn);
370*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
371*0Sstevel@tonic-gate 	}
372*0Sstevel@tonic-gate }
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate 
get_regTblEndColumn(int search_type,Integer * regTblEndColumn,IndexType * index)375*0Sstevel@tonic-gate int get_regTblEndColumn(int search_type, Integer *regTblEndColumn, IndexType *index)
376*0Sstevel@tonic-gate {
377*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
378*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
379*0Sstevel@tonic-gate 	/* appropriate value */
380*0Sstevel@tonic-gate 	switch(search_type)
381*0Sstevel@tonic-gate 	{
382*0Sstevel@tonic-gate 		case FIRST_ENTRY:
383*0Sstevel@tonic-gate 			if(index->type == INTEGER){
384*0Sstevel@tonic-gate 
385*0Sstevel@tonic-gate 				/* assume 1 is the first index */
386*0Sstevel@tonic-gate 
387*0Sstevel@tonic-gate 				index->value[0] = 1;
388*0Sstevel@tonic-gate 				index->len = 1;
389*0Sstevel@tonic-gate 			}else{
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate 				/* index type will be array of integer */
392*0Sstevel@tonic-gate 				/* assume that there are two index */
393*0Sstevel@tonic-gate 
394*0Sstevel@tonic-gate 				index->value[0] = 1;
395*0Sstevel@tonic-gate 				index->value[1]= 1;
396*0Sstevel@tonic-gate 				index->len = 2;
397*0Sstevel@tonic-gate 			}
398*0Sstevel@tonic-gate 			break;
399*0Sstevel@tonic-gate 
400*0Sstevel@tonic-gate 		case NEXT_ENTRY:
401*0Sstevel@tonic-gate 			if(index->type == INTEGER){
402*0Sstevel@tonic-gate 				index->value[0]++;
403*0Sstevel@tonic-gate 			}else{
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate 				/* index type will be array of integer */
406*0Sstevel@tonic-gate 				/* assume that there are two index */
407*0Sstevel@tonic-gate 
408*0Sstevel@tonic-gate 				index->value[index->len-1]++;
409*0Sstevel@tonic-gate 			}
410*0Sstevel@tonic-gate 			break;
411*0Sstevel@tonic-gate 
412*0Sstevel@tonic-gate 		case EXACT_ENTRY:
413*0Sstevel@tonic-gate 			break;
414*0Sstevel@tonic-gate 	}
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
417*0Sstevel@tonic-gate 
418*0Sstevel@tonic-gate 	*regTblEndColumn = 1;
419*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
420*0Sstevel@tonic-gate }
421*0Sstevel@tonic-gate 
set_regTblEndColumn(int pass,IndexType index,Integer * regTblEndColumn)422*0Sstevel@tonic-gate int set_regTblEndColumn(int pass, IndexType index, Integer *regTblEndColumn)
423*0Sstevel@tonic-gate {
424*0Sstevel@tonic-gate 	switch(pass)
425*0Sstevel@tonic-gate 	{
426*0Sstevel@tonic-gate 		case FIRST_PASS:
427*0Sstevel@tonic-gate 
428*0Sstevel@tonic-gate 			/* check the existence of the element which */
429*0Sstevel@tonic-gate 			/* corresponding to the given index and */
430*0Sstevel@tonic-gate 			/* check the validity fo the input value */
431*0Sstevel@tonic-gate 			/* if not valid or not exist, */
432*0Sstevel@tonic-gate 
433*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
434*0Sstevel@tonic-gate 
435*0Sstevel@tonic-gate 		case SECOND_PASS:
436*0Sstevel@tonic-gate 
437*0Sstevel@tonic-gate 			/* change the following coding, such that */
438*0Sstevel@tonic-gate 			/* the input value will be stored in the */
439*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
440*0Sstevel@tonic-gate 			/* index */
441*0Sstevel@tonic-gate 			printf("The new value is %d\n",regTblEndColumn);
442*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
443*0Sstevel@tonic-gate 	}
444*0Sstevel@tonic-gate }
445*0Sstevel@tonic-gate 
446*0Sstevel@tonic-gate 
get_regTblStartRow(int search_type,Integer * regTblStartRow,IndexType * index)447*0Sstevel@tonic-gate int get_regTblStartRow(int search_type, Integer *regTblStartRow, IndexType *index)
448*0Sstevel@tonic-gate {
449*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
450*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
451*0Sstevel@tonic-gate 	/* appropriate value */
452*0Sstevel@tonic-gate 	switch(search_type)
453*0Sstevel@tonic-gate 	{
454*0Sstevel@tonic-gate 		case FIRST_ENTRY:
455*0Sstevel@tonic-gate 			if(index->type == INTEGER){
456*0Sstevel@tonic-gate 
457*0Sstevel@tonic-gate 				/* assume 1 is the first index */
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate 				index->value[0] = 1;
460*0Sstevel@tonic-gate 				index->len = 1;
461*0Sstevel@tonic-gate 			}else{
462*0Sstevel@tonic-gate 
463*0Sstevel@tonic-gate 				/* index type will be array of integer */
464*0Sstevel@tonic-gate 				/* assume that there are two index */
465*0Sstevel@tonic-gate 
466*0Sstevel@tonic-gate 				index->value[0] = 1;
467*0Sstevel@tonic-gate 				index->value[1]= 1;
468*0Sstevel@tonic-gate 				index->len = 2;
469*0Sstevel@tonic-gate 			}
470*0Sstevel@tonic-gate 			break;
471*0Sstevel@tonic-gate 
472*0Sstevel@tonic-gate 		case NEXT_ENTRY:
473*0Sstevel@tonic-gate 			if(index->type == INTEGER){
474*0Sstevel@tonic-gate 				index->value[0]++;
475*0Sstevel@tonic-gate 			}else{
476*0Sstevel@tonic-gate 
477*0Sstevel@tonic-gate 				/* index type will be array of integer */
478*0Sstevel@tonic-gate 				/* assume that there are two index */
479*0Sstevel@tonic-gate 
480*0Sstevel@tonic-gate 				index->value[index->len-1]++;
481*0Sstevel@tonic-gate 			}
482*0Sstevel@tonic-gate 			break;
483*0Sstevel@tonic-gate 
484*0Sstevel@tonic-gate 		case EXACT_ENTRY:
485*0Sstevel@tonic-gate 			break;
486*0Sstevel@tonic-gate 	}
487*0Sstevel@tonic-gate 
488*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
489*0Sstevel@tonic-gate 
490*0Sstevel@tonic-gate 	*regTblStartRow = 1;
491*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
492*0Sstevel@tonic-gate }
493*0Sstevel@tonic-gate 
set_regTblStartRow(int pass,IndexType index,Integer * regTblStartRow)494*0Sstevel@tonic-gate int set_regTblStartRow(int pass, IndexType index, Integer *regTblStartRow)
495*0Sstevel@tonic-gate {
496*0Sstevel@tonic-gate 	switch(pass)
497*0Sstevel@tonic-gate 	{
498*0Sstevel@tonic-gate 		case FIRST_PASS:
499*0Sstevel@tonic-gate 
500*0Sstevel@tonic-gate 			/* check the existence of the element which */
501*0Sstevel@tonic-gate 			/* corresponding to the given index and */
502*0Sstevel@tonic-gate 			/* check the validity fo the input value */
503*0Sstevel@tonic-gate 			/* if not valid or not exist, */
504*0Sstevel@tonic-gate 
505*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
506*0Sstevel@tonic-gate 
507*0Sstevel@tonic-gate 		case SECOND_PASS:
508*0Sstevel@tonic-gate 
509*0Sstevel@tonic-gate 			/* change the following coding, such that */
510*0Sstevel@tonic-gate 			/* the input value will be stored in the */
511*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
512*0Sstevel@tonic-gate 			/* index */
513*0Sstevel@tonic-gate 			printf("The new value is %d\n",regTblStartRow);
514*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
515*0Sstevel@tonic-gate 	}
516*0Sstevel@tonic-gate }
517*0Sstevel@tonic-gate 
518*0Sstevel@tonic-gate 
get_regTblEndRow(int search_type,Integer * regTblEndRow,IndexType * index)519*0Sstevel@tonic-gate int get_regTblEndRow(int search_type, Integer *regTblEndRow, IndexType *index)
520*0Sstevel@tonic-gate {
521*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
522*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
523*0Sstevel@tonic-gate 	/* appropriate value */
524*0Sstevel@tonic-gate 	switch(search_type)
525*0Sstevel@tonic-gate 	{
526*0Sstevel@tonic-gate 		case FIRST_ENTRY:
527*0Sstevel@tonic-gate 			if(index->type == INTEGER){
528*0Sstevel@tonic-gate 
529*0Sstevel@tonic-gate 				/* assume 1 is the first index */
530*0Sstevel@tonic-gate 
531*0Sstevel@tonic-gate 				index->value[0] = 1;
532*0Sstevel@tonic-gate 				index->len = 1;
533*0Sstevel@tonic-gate 			}else{
534*0Sstevel@tonic-gate 
535*0Sstevel@tonic-gate 				/* index type will be array of integer */
536*0Sstevel@tonic-gate 				/* assume that there are two index */
537*0Sstevel@tonic-gate 
538*0Sstevel@tonic-gate 				index->value[0] = 1;
539*0Sstevel@tonic-gate 				index->value[1]= 1;
540*0Sstevel@tonic-gate 				index->len = 2;
541*0Sstevel@tonic-gate 			}
542*0Sstevel@tonic-gate 			break;
543*0Sstevel@tonic-gate 
544*0Sstevel@tonic-gate 		case NEXT_ENTRY:
545*0Sstevel@tonic-gate 			if(index->type == INTEGER){
546*0Sstevel@tonic-gate 				index->value[0]++;
547*0Sstevel@tonic-gate 			}else{
548*0Sstevel@tonic-gate 
549*0Sstevel@tonic-gate 				/* index type will be array of integer */
550*0Sstevel@tonic-gate 				/* assume that there are two index */
551*0Sstevel@tonic-gate 
552*0Sstevel@tonic-gate 				index->value[index->len-1]++;
553*0Sstevel@tonic-gate 			}
554*0Sstevel@tonic-gate 			break;
555*0Sstevel@tonic-gate 
556*0Sstevel@tonic-gate 		case EXACT_ENTRY:
557*0Sstevel@tonic-gate 			break;
558*0Sstevel@tonic-gate 	}
559*0Sstevel@tonic-gate 
560*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
561*0Sstevel@tonic-gate 
562*0Sstevel@tonic-gate 	*regTblEndRow = 1;
563*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
564*0Sstevel@tonic-gate }
565*0Sstevel@tonic-gate 
set_regTblEndRow(int pass,IndexType index,Integer * regTblEndRow)566*0Sstevel@tonic-gate int set_regTblEndRow(int pass, IndexType index, Integer *regTblEndRow)
567*0Sstevel@tonic-gate {
568*0Sstevel@tonic-gate 	switch(pass)
569*0Sstevel@tonic-gate 	{
570*0Sstevel@tonic-gate 		case FIRST_PASS:
571*0Sstevel@tonic-gate 
572*0Sstevel@tonic-gate 			/* check the existence of the element which */
573*0Sstevel@tonic-gate 			/* corresponding to the given index and */
574*0Sstevel@tonic-gate 			/* check the validity fo the input value */
575*0Sstevel@tonic-gate 			/* if not valid or not exist, */
576*0Sstevel@tonic-gate 
577*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
578*0Sstevel@tonic-gate 
579*0Sstevel@tonic-gate 		case SECOND_PASS:
580*0Sstevel@tonic-gate 
581*0Sstevel@tonic-gate 			/* change the following coding, such that */
582*0Sstevel@tonic-gate 			/* the input value will be stored in the */
583*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
584*0Sstevel@tonic-gate 			/* index */
585*0Sstevel@tonic-gate 			printf("The new value is %d\n",regTblEndRow);
586*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
587*0Sstevel@tonic-gate 	}
588*0Sstevel@tonic-gate }
589*0Sstevel@tonic-gate 
590*0Sstevel@tonic-gate 
get_regTblStatus(int search_type,Integer * regTblStatus,IndexType * index)591*0Sstevel@tonic-gate int get_regTblStatus(int search_type, Integer *regTblStatus, IndexType *index)
592*0Sstevel@tonic-gate {
593*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
594*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
595*0Sstevel@tonic-gate 	/* appropriate value */
596*0Sstevel@tonic-gate 	switch(search_type)
597*0Sstevel@tonic-gate 	{
598*0Sstevel@tonic-gate 		case FIRST_ENTRY:
599*0Sstevel@tonic-gate 			if(index->type == INTEGER){
600*0Sstevel@tonic-gate 
601*0Sstevel@tonic-gate 				/* assume 1 is the first index */
602*0Sstevel@tonic-gate 
603*0Sstevel@tonic-gate 				index->value[0] = 1;
604*0Sstevel@tonic-gate 				index->len = 1;
605*0Sstevel@tonic-gate 			}else{
606*0Sstevel@tonic-gate 
607*0Sstevel@tonic-gate 				/* index type will be array of integer */
608*0Sstevel@tonic-gate 				/* assume that there are two index */
609*0Sstevel@tonic-gate 
610*0Sstevel@tonic-gate 				index->value[0] = 1;
611*0Sstevel@tonic-gate 				index->value[1]= 1;
612*0Sstevel@tonic-gate 				index->len = 2;
613*0Sstevel@tonic-gate 			}
614*0Sstevel@tonic-gate 			break;
615*0Sstevel@tonic-gate 
616*0Sstevel@tonic-gate 		case NEXT_ENTRY:
617*0Sstevel@tonic-gate 			if(index->type == INTEGER){
618*0Sstevel@tonic-gate 				index->value[0]++;
619*0Sstevel@tonic-gate 			}else{
620*0Sstevel@tonic-gate 
621*0Sstevel@tonic-gate 				/* index type will be array of integer */
622*0Sstevel@tonic-gate 				/* assume that there are two index */
623*0Sstevel@tonic-gate 
624*0Sstevel@tonic-gate 				index->value[index->len-1]++;
625*0Sstevel@tonic-gate 			}
626*0Sstevel@tonic-gate 			break;
627*0Sstevel@tonic-gate 
628*0Sstevel@tonic-gate 		case EXACT_ENTRY:
629*0Sstevel@tonic-gate 			break;
630*0Sstevel@tonic-gate 	}
631*0Sstevel@tonic-gate 
632*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
633*0Sstevel@tonic-gate 
634*0Sstevel@tonic-gate 	*regTblStatus = 1;
635*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
636*0Sstevel@tonic-gate }
637*0Sstevel@tonic-gate 
set_regTblStatus(int pass,IndexType index,Integer * regTblStatus)638*0Sstevel@tonic-gate int set_regTblStatus(int pass, IndexType index, Integer *regTblStatus)
639*0Sstevel@tonic-gate {
640*0Sstevel@tonic-gate 	switch(pass)
641*0Sstevel@tonic-gate 	{
642*0Sstevel@tonic-gate 		case FIRST_PASS:
643*0Sstevel@tonic-gate 
644*0Sstevel@tonic-gate 			/* check the existence of the element which */
645*0Sstevel@tonic-gate 			/* corresponding to the given index and */
646*0Sstevel@tonic-gate 			/* check the validity fo the input value */
647*0Sstevel@tonic-gate 			/* if not valid or not exist, */
648*0Sstevel@tonic-gate 
649*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
650*0Sstevel@tonic-gate 
651*0Sstevel@tonic-gate 		case SECOND_PASS:
652*0Sstevel@tonic-gate 
653*0Sstevel@tonic-gate 			/* change the following coding, such that */
654*0Sstevel@tonic-gate 			/* the input value will be stored in the */
655*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
656*0Sstevel@tonic-gate 			/* index */
657*0Sstevel@tonic-gate 			printf("The new value is %d\n",regTblStatus);
658*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
659*0Sstevel@tonic-gate 	}
660*0Sstevel@tonic-gate }
661*0Sstevel@tonic-gate 
662