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 /***** agentEntry           ********************************/
44*0Sstevel@tonic-gate 
get_agentEntry(int search_type,AgentEntry_t ** agentEntry_data,IndexType * index)45*0Sstevel@tonic-gate extern int get_agentEntry(int search_type, AgentEntry_t **agentEntry_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 	*agentEntry_data = (AgentEntry_t*)calloc(1,sizeof(AgentEntry_t));
51*0Sstevel@tonic-gate 	if(agentEntry_data == NULL) return SNMP_ERR_GENERR;
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate 	res = get_agentID(
54*0Sstevel@tonic-gate 	        search_type,
55*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentID),
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_agentStatus(
60*0Sstevel@tonic-gate 	        search_type,
61*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentStatus),
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_agentTimeOut(
66*0Sstevel@tonic-gate 	        search_type,
67*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentTimeOut),
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_agentPortNumber(
72*0Sstevel@tonic-gate 	        search_type,
73*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentPortNumber),
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_agentPersonalFile(
78*0Sstevel@tonic-gate 	        search_type,
79*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentPersonalFile),
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_agentConfigFile(
84*0Sstevel@tonic-gate 	        search_type,
85*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentConfigFile),
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_agentExecutable(
90*0Sstevel@tonic-gate 	        search_type,
91*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentExecutable),
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_agentVersionNum(
96*0Sstevel@tonic-gate 	        search_type,
97*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentVersionNum),
98*0Sstevel@tonic-gate 	        index);
99*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate 	res = get_agentProcessID(
102*0Sstevel@tonic-gate 	        search_type,
103*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentProcessID),
104*0Sstevel@tonic-gate 	        index);
105*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 	res = get_agentName(
108*0Sstevel@tonic-gate 	        search_type,
109*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentName),
110*0Sstevel@tonic-gate 	        index);
111*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate 	res = get_agentSystemUpTime(
114*0Sstevel@tonic-gate 	        search_type,
115*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentSystemUpTime),
116*0Sstevel@tonic-gate 	        index);
117*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate 	res = get_agentWatchDogTime(
120*0Sstevel@tonic-gate 	        search_type,
121*0Sstevel@tonic-gate 	        &((*agentEntry_data)->agentWatchDogTime),
122*0Sstevel@tonic-gate 	        index);
123*0Sstevel@tonic-gate 	if(res != SNMP_ERR_NOERROR) return res;
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate 	 return res;
126*0Sstevel@tonic-gate }
127*0Sstevel@tonic-gate 
128*0Sstevel@tonic-gate 
free_agentEntry(AgentEntry_t * agentEntry)129*0Sstevel@tonic-gate void free_agentEntry(AgentEntry_t *agentEntry)
130*0Sstevel@tonic-gate {
131*0Sstevel@tonic-gate 	free_agentPersonalFile(&(agentEntry->agentPersonalFile));
132*0Sstevel@tonic-gate 	free_agentConfigFile(&(agentEntry->agentConfigFile));
133*0Sstevel@tonic-gate 	free_agentExecutable(&(agentEntry->agentExecutable));
134*0Sstevel@tonic-gate 	free_agentVersionNum(&(agentEntry->agentVersionNum));
135*0Sstevel@tonic-gate 	free_agentName(&(agentEntry->agentName));
136*0Sstevel@tonic-gate }
137*0Sstevel@tonic-gate 
get_agentID(int search_type,Integer * agentID,IndexType * index)138*0Sstevel@tonic-gate int get_agentID(int search_type, Integer *agentID, IndexType *index)
139*0Sstevel@tonic-gate {
140*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
141*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
142*0Sstevel@tonic-gate 	/* appropriate value */
143*0Sstevel@tonic-gate 	switch(search_type)
144*0Sstevel@tonic-gate 	{
145*0Sstevel@tonic-gate 		case FIRST_ENTRY:
146*0Sstevel@tonic-gate 			if(index->type == INTEGER){
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate 				/* assume 1 is the first index */
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate 				index->value[0] = 1;
151*0Sstevel@tonic-gate 				index->len = 1;
152*0Sstevel@tonic-gate 			}else{
153*0Sstevel@tonic-gate 
154*0Sstevel@tonic-gate 				/* index type will be array of integer */
155*0Sstevel@tonic-gate 				/* assume that there are two index */
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate 				index->value[0] = 1;
158*0Sstevel@tonic-gate 				index->value[1]= 1;
159*0Sstevel@tonic-gate 				index->len = 2;
160*0Sstevel@tonic-gate 			}
161*0Sstevel@tonic-gate 			break;
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate 		case NEXT_ENTRY:
164*0Sstevel@tonic-gate 			if(index->type == INTEGER){
165*0Sstevel@tonic-gate 				index->value[0]++;
166*0Sstevel@tonic-gate 			}else{
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate 				/* index type will be array of integer */
169*0Sstevel@tonic-gate 				/* assume that there are two index */
170*0Sstevel@tonic-gate 
171*0Sstevel@tonic-gate 				index->value[index->len-1]++;
172*0Sstevel@tonic-gate 			}
173*0Sstevel@tonic-gate 			break;
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate 		case EXACT_ENTRY:
176*0Sstevel@tonic-gate 			break;
177*0Sstevel@tonic-gate 	}
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
180*0Sstevel@tonic-gate 
181*0Sstevel@tonic-gate 	*agentID = 1;
182*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
183*0Sstevel@tonic-gate }
184*0Sstevel@tonic-gate 
get_agentStatus(int search_type,Integer * agentStatus,IndexType * index)185*0Sstevel@tonic-gate int get_agentStatus(int search_type, Integer *agentStatus, IndexType *index)
186*0Sstevel@tonic-gate {
187*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
188*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
189*0Sstevel@tonic-gate 	/* appropriate value */
190*0Sstevel@tonic-gate 	switch(search_type)
191*0Sstevel@tonic-gate 	{
192*0Sstevel@tonic-gate 		case FIRST_ENTRY:
193*0Sstevel@tonic-gate 			if(index->type == INTEGER){
194*0Sstevel@tonic-gate 
195*0Sstevel@tonic-gate 				/* assume 1 is the first index */
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate 				index->value[0] = 1;
198*0Sstevel@tonic-gate 				index->len = 1;
199*0Sstevel@tonic-gate 			}else{
200*0Sstevel@tonic-gate 
201*0Sstevel@tonic-gate 				/* index type will be array of integer */
202*0Sstevel@tonic-gate 				/* assume that there are two index */
203*0Sstevel@tonic-gate 
204*0Sstevel@tonic-gate 				index->value[0] = 1;
205*0Sstevel@tonic-gate 				index->value[1]= 1;
206*0Sstevel@tonic-gate 				index->len = 2;
207*0Sstevel@tonic-gate 			}
208*0Sstevel@tonic-gate 			break;
209*0Sstevel@tonic-gate 
210*0Sstevel@tonic-gate 		case NEXT_ENTRY:
211*0Sstevel@tonic-gate 			if(index->type == INTEGER){
212*0Sstevel@tonic-gate 				index->value[0]++;
213*0Sstevel@tonic-gate 			}else{
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate 				/* index type will be array of integer */
216*0Sstevel@tonic-gate 				/* assume that there are two index */
217*0Sstevel@tonic-gate 
218*0Sstevel@tonic-gate 				index->value[index->len-1]++;
219*0Sstevel@tonic-gate 			}
220*0Sstevel@tonic-gate 			break;
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate 		case EXACT_ENTRY:
223*0Sstevel@tonic-gate 			break;
224*0Sstevel@tonic-gate 	}
225*0Sstevel@tonic-gate 
226*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
227*0Sstevel@tonic-gate 
228*0Sstevel@tonic-gate 	*agentStatus = 1;
229*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
230*0Sstevel@tonic-gate }
231*0Sstevel@tonic-gate 
set_agentStatus(int pass,IndexType index,Integer * agentStatus)232*0Sstevel@tonic-gate int set_agentStatus(int pass, IndexType index, Integer *agentStatus)
233*0Sstevel@tonic-gate {
234*0Sstevel@tonic-gate 	switch(pass)
235*0Sstevel@tonic-gate 	{
236*0Sstevel@tonic-gate 		case FIRST_PASS:
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate 			/* check the existence of the element which */
239*0Sstevel@tonic-gate 			/* corresponding to the given index and */
240*0Sstevel@tonic-gate 			/* check the validity fo the input value */
241*0Sstevel@tonic-gate 			/* if not valid or not exist, */
242*0Sstevel@tonic-gate 
243*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate 		case SECOND_PASS:
246*0Sstevel@tonic-gate 
247*0Sstevel@tonic-gate 			/* change the following coding, such that */
248*0Sstevel@tonic-gate 			/* the input value will be stored in the */
249*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
250*0Sstevel@tonic-gate 			/* index */
251*0Sstevel@tonic-gate 			printf("The new value is %d\n",agentStatus);
252*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
253*0Sstevel@tonic-gate 	}
254*0Sstevel@tonic-gate }
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate 
get_agentTimeOut(int search_type,Integer * agentTimeOut,IndexType * index)257*0Sstevel@tonic-gate int get_agentTimeOut(int search_type, Integer *agentTimeOut, IndexType *index)
258*0Sstevel@tonic-gate {
259*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
260*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
261*0Sstevel@tonic-gate 	/* appropriate value */
262*0Sstevel@tonic-gate 	switch(search_type)
263*0Sstevel@tonic-gate 	{
264*0Sstevel@tonic-gate 		case FIRST_ENTRY:
265*0Sstevel@tonic-gate 			if(index->type == INTEGER){
266*0Sstevel@tonic-gate 
267*0Sstevel@tonic-gate 				/* assume 1 is the first index */
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate 				index->value[0] = 1;
270*0Sstevel@tonic-gate 				index->len = 1;
271*0Sstevel@tonic-gate 			}else{
272*0Sstevel@tonic-gate 
273*0Sstevel@tonic-gate 				/* index type will be array of integer */
274*0Sstevel@tonic-gate 				/* assume that there are two index */
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate 				index->value[0] = 1;
277*0Sstevel@tonic-gate 				index->value[1]= 1;
278*0Sstevel@tonic-gate 				index->len = 2;
279*0Sstevel@tonic-gate 			}
280*0Sstevel@tonic-gate 			break;
281*0Sstevel@tonic-gate 
282*0Sstevel@tonic-gate 		case NEXT_ENTRY:
283*0Sstevel@tonic-gate 			if(index->type == INTEGER){
284*0Sstevel@tonic-gate 				index->value[0]++;
285*0Sstevel@tonic-gate 			}else{
286*0Sstevel@tonic-gate 
287*0Sstevel@tonic-gate 				/* index type will be array of integer */
288*0Sstevel@tonic-gate 				/* assume that there are two index */
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate 				index->value[index->len-1]++;
291*0Sstevel@tonic-gate 			}
292*0Sstevel@tonic-gate 			break;
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate 		case EXACT_ENTRY:
295*0Sstevel@tonic-gate 			break;
296*0Sstevel@tonic-gate 	}
297*0Sstevel@tonic-gate 
298*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
299*0Sstevel@tonic-gate 
300*0Sstevel@tonic-gate 	*agentTimeOut = 1;
301*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
302*0Sstevel@tonic-gate }
303*0Sstevel@tonic-gate 
set_agentTimeOut(int pass,IndexType index,Integer * agentTimeOut)304*0Sstevel@tonic-gate int set_agentTimeOut(int pass, IndexType index, Integer *agentTimeOut)
305*0Sstevel@tonic-gate {
306*0Sstevel@tonic-gate 	switch(pass)
307*0Sstevel@tonic-gate 	{
308*0Sstevel@tonic-gate 		case FIRST_PASS:
309*0Sstevel@tonic-gate 
310*0Sstevel@tonic-gate 			/* check the existence of the element which */
311*0Sstevel@tonic-gate 			/* corresponding to the given index and */
312*0Sstevel@tonic-gate 			/* check the validity fo the input value */
313*0Sstevel@tonic-gate 			/* if not valid or not exist, */
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
316*0Sstevel@tonic-gate 
317*0Sstevel@tonic-gate 		case SECOND_PASS:
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate 			/* change the following coding, such that */
320*0Sstevel@tonic-gate 			/* the input value will be stored in the */
321*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
322*0Sstevel@tonic-gate 			/* index */
323*0Sstevel@tonic-gate 			printf("The new value is %d\n",agentTimeOut);
324*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
325*0Sstevel@tonic-gate 	}
326*0Sstevel@tonic-gate }
327*0Sstevel@tonic-gate 
328*0Sstevel@tonic-gate 
get_agentPortNumber(int search_type,Integer * agentPortNumber,IndexType * index)329*0Sstevel@tonic-gate int get_agentPortNumber(int search_type, Integer *agentPortNumber, IndexType *index)
330*0Sstevel@tonic-gate {
331*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
332*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
333*0Sstevel@tonic-gate 	/* appropriate value */
334*0Sstevel@tonic-gate 	switch(search_type)
335*0Sstevel@tonic-gate 	{
336*0Sstevel@tonic-gate 		case FIRST_ENTRY:
337*0Sstevel@tonic-gate 			if(index->type == INTEGER){
338*0Sstevel@tonic-gate 
339*0Sstevel@tonic-gate 				/* assume 1 is the first index */
340*0Sstevel@tonic-gate 
341*0Sstevel@tonic-gate 				index->value[0] = 1;
342*0Sstevel@tonic-gate 				index->len = 1;
343*0Sstevel@tonic-gate 			}else{
344*0Sstevel@tonic-gate 
345*0Sstevel@tonic-gate 				/* index type will be array of integer */
346*0Sstevel@tonic-gate 				/* assume that there are two index */
347*0Sstevel@tonic-gate 
348*0Sstevel@tonic-gate 				index->value[0] = 1;
349*0Sstevel@tonic-gate 				index->value[1]= 1;
350*0Sstevel@tonic-gate 				index->len = 2;
351*0Sstevel@tonic-gate 			}
352*0Sstevel@tonic-gate 			break;
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate 		case NEXT_ENTRY:
355*0Sstevel@tonic-gate 			if(index->type == INTEGER){
356*0Sstevel@tonic-gate 				index->value[0]++;
357*0Sstevel@tonic-gate 			}else{
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate 				/* index type will be array of integer */
360*0Sstevel@tonic-gate 				/* assume that there are two index */
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate 				index->value[index->len-1]++;
363*0Sstevel@tonic-gate 			}
364*0Sstevel@tonic-gate 			break;
365*0Sstevel@tonic-gate 
366*0Sstevel@tonic-gate 		case EXACT_ENTRY:
367*0Sstevel@tonic-gate 			break;
368*0Sstevel@tonic-gate 	}
369*0Sstevel@tonic-gate 
370*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
371*0Sstevel@tonic-gate 
372*0Sstevel@tonic-gate 	*agentPortNumber = 1;
373*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
374*0Sstevel@tonic-gate }
375*0Sstevel@tonic-gate 
set_agentPortNumber(int pass,IndexType index,Integer * agentPortNumber)376*0Sstevel@tonic-gate int set_agentPortNumber(int pass, IndexType index, Integer *agentPortNumber)
377*0Sstevel@tonic-gate {
378*0Sstevel@tonic-gate 	switch(pass)
379*0Sstevel@tonic-gate 	{
380*0Sstevel@tonic-gate 		case FIRST_PASS:
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate 			/* check the existence of the element which */
383*0Sstevel@tonic-gate 			/* corresponding to the given index and */
384*0Sstevel@tonic-gate 			/* check the validity fo the input value */
385*0Sstevel@tonic-gate 			/* if not valid or not exist, */
386*0Sstevel@tonic-gate 
387*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
388*0Sstevel@tonic-gate 
389*0Sstevel@tonic-gate 		case SECOND_PASS:
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate 			/* change the following coding, such that */
392*0Sstevel@tonic-gate 			/* the input value will be stored in the */
393*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
394*0Sstevel@tonic-gate 			/* index */
395*0Sstevel@tonic-gate 			printf("The new value is %d\n",agentPortNumber);
396*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
397*0Sstevel@tonic-gate 	}
398*0Sstevel@tonic-gate }
399*0Sstevel@tonic-gate 
400*0Sstevel@tonic-gate 
get_agentPersonalFile(int search_type,String * agentPersonalFile,IndexType * index)401*0Sstevel@tonic-gate int get_agentPersonalFile(int search_type, String *agentPersonalFile, IndexType *index)
402*0Sstevel@tonic-gate {
403*0Sstevel@tonic-gate 	u_char *str;
404*0Sstevel@tonic-gate 	int len;
405*0Sstevel@tonic-gate 
406*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
407*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
408*0Sstevel@tonic-gate 	/* appropriate value */
409*0Sstevel@tonic-gate 	switch(search_type)
410*0Sstevel@tonic-gate 	{
411*0Sstevel@tonic-gate 		case FIRST_ENTRY:
412*0Sstevel@tonic-gate 			if(index->type == INTEGER){
413*0Sstevel@tonic-gate 
414*0Sstevel@tonic-gate 				/* assume 1 is the first index */
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate 				index->value[0] = 1;
417*0Sstevel@tonic-gate 				index->len = 1;
418*0Sstevel@tonic-gate 			}else{
419*0Sstevel@tonic-gate 
420*0Sstevel@tonic-gate 				/* index type will be array of integer */
421*0Sstevel@tonic-gate 				/* assume that there are two index */
422*0Sstevel@tonic-gate 
423*0Sstevel@tonic-gate 				index->value[0] = 1;
424*0Sstevel@tonic-gate 				index->value[1]= 1;
425*0Sstevel@tonic-gate 				index->len = 2;
426*0Sstevel@tonic-gate 			}
427*0Sstevel@tonic-gate 			break;
428*0Sstevel@tonic-gate 
429*0Sstevel@tonic-gate 		case NEXT_ENTRY:
430*0Sstevel@tonic-gate 			if(index->type == INTEGER){
431*0Sstevel@tonic-gate 				index->value[0]++;
432*0Sstevel@tonic-gate 			}else{
433*0Sstevel@tonic-gate 
434*0Sstevel@tonic-gate 				/* index type will be array of integer */
435*0Sstevel@tonic-gate 				/* assume that there are two index */
436*0Sstevel@tonic-gate 
437*0Sstevel@tonic-gate 				index->value[index->len-1]++;
438*0Sstevel@tonic-gate 			}
439*0Sstevel@tonic-gate 			break;
440*0Sstevel@tonic-gate 
441*0Sstevel@tonic-gate 		case EXACT_ENTRY:
442*0Sstevel@tonic-gate 			break;
443*0Sstevel@tonic-gate 	}
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate 	/* It is required to allocate memory to the pointers */
446*0Sstevel@tonic-gate 	/* inside the input argument */
447*0Sstevel@tonic-gate 	/* Here, we assume that "hello" is the value of the mib variable */
448*0Sstevel@tonic-gate 	/* please change it to the real one */
449*0Sstevel@tonic-gate 
450*0Sstevel@tonic-gate 	len = strlen("hello");
451*0Sstevel@tonic-gate 	str = (u_char*)calloc(len,sizeof(char));
452*0Sstevel@tonic-gate 	if(str==NULL){
453*0Sstevel@tonic-gate 		return SNMP_ERR_GENERR;
454*0Sstevel@tonic-gate 	}
455*0Sstevel@tonic-gate 	memcpy(str,"hello",len);
456*0Sstevel@tonic-gate 
457*0Sstevel@tonic-gate 	/*fill in the contents of the argument */
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate 	agentPersonalFile->chars = str;
460*0Sstevel@tonic-gate 	agentPersonalFile->len = len;
461*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
462*0Sstevel@tonic-gate }
463*0Sstevel@tonic-gate 
set_agentPersonalFile(int pass,IndexType index,String * agentPersonalFile)464*0Sstevel@tonic-gate int set_agentPersonalFile(int pass, IndexType index, String *agentPersonalFile)
465*0Sstevel@tonic-gate {
466*0Sstevel@tonic-gate 	char buf[100];
467*0Sstevel@tonic-gate 
468*0Sstevel@tonic-gate 	switch(pass)
469*0Sstevel@tonic-gate 	{
470*0Sstevel@tonic-gate 		case FIRST_PASS:
471*0Sstevel@tonic-gate 
472*0Sstevel@tonic-gate 			/* check the existence of the element which */
473*0Sstevel@tonic-gate 			/* corresponding to the given index and */
474*0Sstevel@tonic-gate 			/* check the validity fo the input value */
475*0Sstevel@tonic-gate 			/* if not valid or not exist, */
476*0Sstevel@tonic-gate 
477*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
478*0Sstevel@tonic-gate 
479*0Sstevel@tonic-gate 		case SECOND_PASS:
480*0Sstevel@tonic-gate 
481*0Sstevel@tonic-gate 			/* change the following coding, such that */
482*0Sstevel@tonic-gate 			/* the input value will be stored in the */
483*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
484*0Sstevel@tonic-gate 			/* index */
485*0Sstevel@tonic-gate 			memcpy(buf,agentPersonalFile->chars,agentPersonalFile->len);
486*0Sstevel@tonic-gate 			buf[agentPersonalFile->len+1] = '\0';
487*0Sstevel@tonic-gate 			printf("The new value is %s\n",buf);
488*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
489*0Sstevel@tonic-gate 	}
490*0Sstevel@tonic-gate }
491*0Sstevel@tonic-gate 
492*0Sstevel@tonic-gate 
free_agentPersonalFile(String * agentPersonalFile)493*0Sstevel@tonic-gate void free_agentPersonalFile(String *agentPersonalFile)
494*0Sstevel@tonic-gate {
495*0Sstevel@tonic-gate 	 if(agentPersonalFile->chars!=NULL && agentPersonalFile->len !=0)
496*0Sstevel@tonic-gate 	{
497*0Sstevel@tonic-gate 		free(agentPersonalFile->chars);
498*0Sstevel@tonic-gate 		agentPersonalFile->len = 0;
499*0Sstevel@tonic-gate 	}
500*0Sstevel@tonic-gate }
501*0Sstevel@tonic-gate 
get_agentConfigFile(int search_type,String * agentConfigFile,IndexType * index)502*0Sstevel@tonic-gate int get_agentConfigFile(int search_type, String *agentConfigFile, IndexType *index)
503*0Sstevel@tonic-gate {
504*0Sstevel@tonic-gate 	u_char *str;
505*0Sstevel@tonic-gate 	int len;
506*0Sstevel@tonic-gate 
507*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
508*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
509*0Sstevel@tonic-gate 	/* appropriate value */
510*0Sstevel@tonic-gate 	switch(search_type)
511*0Sstevel@tonic-gate 	{
512*0Sstevel@tonic-gate 		case FIRST_ENTRY:
513*0Sstevel@tonic-gate 			if(index->type == INTEGER){
514*0Sstevel@tonic-gate 
515*0Sstevel@tonic-gate 				/* assume 1 is the first index */
516*0Sstevel@tonic-gate 
517*0Sstevel@tonic-gate 				index->value[0] = 1;
518*0Sstevel@tonic-gate 				index->len = 1;
519*0Sstevel@tonic-gate 			}else{
520*0Sstevel@tonic-gate 
521*0Sstevel@tonic-gate 				/* index type will be array of integer */
522*0Sstevel@tonic-gate 				/* assume that there are two index */
523*0Sstevel@tonic-gate 
524*0Sstevel@tonic-gate 				index->value[0] = 1;
525*0Sstevel@tonic-gate 				index->value[1]= 1;
526*0Sstevel@tonic-gate 				index->len = 2;
527*0Sstevel@tonic-gate 			}
528*0Sstevel@tonic-gate 			break;
529*0Sstevel@tonic-gate 
530*0Sstevel@tonic-gate 		case NEXT_ENTRY:
531*0Sstevel@tonic-gate 			if(index->type == INTEGER){
532*0Sstevel@tonic-gate 				index->value[0]++;
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[index->len-1]++;
539*0Sstevel@tonic-gate 			}
540*0Sstevel@tonic-gate 			break;
541*0Sstevel@tonic-gate 
542*0Sstevel@tonic-gate 		case EXACT_ENTRY:
543*0Sstevel@tonic-gate 			break;
544*0Sstevel@tonic-gate 	}
545*0Sstevel@tonic-gate 
546*0Sstevel@tonic-gate 	/* It is required to allocate memory to the pointers */
547*0Sstevel@tonic-gate 	/* inside the input argument */
548*0Sstevel@tonic-gate 	/* Here, we assume that "hello" is the value of the mib variable */
549*0Sstevel@tonic-gate 	/* please change it to the real one */
550*0Sstevel@tonic-gate 
551*0Sstevel@tonic-gate 	len = strlen("hello");
552*0Sstevel@tonic-gate 	str = (u_char*)calloc(len,sizeof(char));
553*0Sstevel@tonic-gate 	if(str==NULL){
554*0Sstevel@tonic-gate 		return SNMP_ERR_GENERR;
555*0Sstevel@tonic-gate 	}
556*0Sstevel@tonic-gate 	memcpy(str,"hello",len);
557*0Sstevel@tonic-gate 
558*0Sstevel@tonic-gate 	/*fill in the contents of the argument */
559*0Sstevel@tonic-gate 
560*0Sstevel@tonic-gate 	agentConfigFile->chars = str;
561*0Sstevel@tonic-gate 	agentConfigFile->len = len;
562*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
563*0Sstevel@tonic-gate }
564*0Sstevel@tonic-gate 
set_agentConfigFile(int pass,IndexType index,String * agentConfigFile)565*0Sstevel@tonic-gate int set_agentConfigFile(int pass, IndexType index, String *agentConfigFile)
566*0Sstevel@tonic-gate {
567*0Sstevel@tonic-gate 	char buf[100];
568*0Sstevel@tonic-gate 
569*0Sstevel@tonic-gate 	switch(pass)
570*0Sstevel@tonic-gate 	{
571*0Sstevel@tonic-gate 		case FIRST_PASS:
572*0Sstevel@tonic-gate 
573*0Sstevel@tonic-gate 			/* check the existence of the element which */
574*0Sstevel@tonic-gate 			/* corresponding to the given index and */
575*0Sstevel@tonic-gate 			/* check the validity fo the input value */
576*0Sstevel@tonic-gate 			/* if not valid or not exist, */
577*0Sstevel@tonic-gate 
578*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
579*0Sstevel@tonic-gate 
580*0Sstevel@tonic-gate 		case SECOND_PASS:
581*0Sstevel@tonic-gate 
582*0Sstevel@tonic-gate 			/* change the following coding, such that */
583*0Sstevel@tonic-gate 			/* the input value will be stored in the */
584*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
585*0Sstevel@tonic-gate 			/* index */
586*0Sstevel@tonic-gate 			memcpy(buf,agentConfigFile->chars,agentConfigFile->len);
587*0Sstevel@tonic-gate 			buf[agentConfigFile->len+1] = '\0';
588*0Sstevel@tonic-gate 			printf("The new value is %s\n",buf);
589*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
590*0Sstevel@tonic-gate 	}
591*0Sstevel@tonic-gate }
592*0Sstevel@tonic-gate 
593*0Sstevel@tonic-gate 
free_agentConfigFile(String * agentConfigFile)594*0Sstevel@tonic-gate void free_agentConfigFile(String *agentConfigFile)
595*0Sstevel@tonic-gate {
596*0Sstevel@tonic-gate 	 if(agentConfigFile->chars!=NULL && agentConfigFile->len !=0)
597*0Sstevel@tonic-gate 	{
598*0Sstevel@tonic-gate 		free(agentConfigFile->chars);
599*0Sstevel@tonic-gate 		agentConfigFile->len = 0;
600*0Sstevel@tonic-gate 	}
601*0Sstevel@tonic-gate }
602*0Sstevel@tonic-gate 
get_agentExecutable(int search_type,String * agentExecutable,IndexType * index)603*0Sstevel@tonic-gate int get_agentExecutable(int search_type, String *agentExecutable, IndexType *index)
604*0Sstevel@tonic-gate {
605*0Sstevel@tonic-gate 	u_char *str;
606*0Sstevel@tonic-gate 	int len;
607*0Sstevel@tonic-gate 
608*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
609*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
610*0Sstevel@tonic-gate 	/* appropriate value */
611*0Sstevel@tonic-gate 	switch(search_type)
612*0Sstevel@tonic-gate 	{
613*0Sstevel@tonic-gate 		case FIRST_ENTRY:
614*0Sstevel@tonic-gate 			if(index->type == INTEGER){
615*0Sstevel@tonic-gate 
616*0Sstevel@tonic-gate 				/* assume 1 is the first index */
617*0Sstevel@tonic-gate 
618*0Sstevel@tonic-gate 				index->value[0] = 1;
619*0Sstevel@tonic-gate 				index->len = 1;
620*0Sstevel@tonic-gate 			}else{
621*0Sstevel@tonic-gate 
622*0Sstevel@tonic-gate 				/* index type will be array of integer */
623*0Sstevel@tonic-gate 				/* assume that there are two index */
624*0Sstevel@tonic-gate 
625*0Sstevel@tonic-gate 				index->value[0] = 1;
626*0Sstevel@tonic-gate 				index->value[1]= 1;
627*0Sstevel@tonic-gate 				index->len = 2;
628*0Sstevel@tonic-gate 			}
629*0Sstevel@tonic-gate 			break;
630*0Sstevel@tonic-gate 
631*0Sstevel@tonic-gate 		case NEXT_ENTRY:
632*0Sstevel@tonic-gate 			if(index->type == INTEGER){
633*0Sstevel@tonic-gate 				index->value[0]++;
634*0Sstevel@tonic-gate 			}else{
635*0Sstevel@tonic-gate 
636*0Sstevel@tonic-gate 				/* index type will be array of integer */
637*0Sstevel@tonic-gate 				/* assume that there are two index */
638*0Sstevel@tonic-gate 
639*0Sstevel@tonic-gate 				index->value[index->len-1]++;
640*0Sstevel@tonic-gate 			}
641*0Sstevel@tonic-gate 			break;
642*0Sstevel@tonic-gate 
643*0Sstevel@tonic-gate 		case EXACT_ENTRY:
644*0Sstevel@tonic-gate 			break;
645*0Sstevel@tonic-gate 	}
646*0Sstevel@tonic-gate 
647*0Sstevel@tonic-gate 	/* It is required to allocate memory to the pointers */
648*0Sstevel@tonic-gate 	/* inside the input argument */
649*0Sstevel@tonic-gate 	/* Here, we assume that "hello" is the value of the mib variable */
650*0Sstevel@tonic-gate 	/* please change it to the real one */
651*0Sstevel@tonic-gate 
652*0Sstevel@tonic-gate 	len = strlen("hello");
653*0Sstevel@tonic-gate 	str = (u_char*)calloc(len,sizeof(char));
654*0Sstevel@tonic-gate 	if(str==NULL){
655*0Sstevel@tonic-gate 		return SNMP_ERR_GENERR;
656*0Sstevel@tonic-gate 	}
657*0Sstevel@tonic-gate 	memcpy(str,"hello",len);
658*0Sstevel@tonic-gate 
659*0Sstevel@tonic-gate 	/*fill in the contents of the argument */
660*0Sstevel@tonic-gate 
661*0Sstevel@tonic-gate 	agentExecutable->chars = str;
662*0Sstevel@tonic-gate 	agentExecutable->len = len;
663*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
664*0Sstevel@tonic-gate }
665*0Sstevel@tonic-gate 
set_agentExecutable(int pass,IndexType index,String * agentExecutable)666*0Sstevel@tonic-gate int set_agentExecutable(int pass, IndexType index, String *agentExecutable)
667*0Sstevel@tonic-gate {
668*0Sstevel@tonic-gate 	char buf[100];
669*0Sstevel@tonic-gate 
670*0Sstevel@tonic-gate 	switch(pass)
671*0Sstevel@tonic-gate 	{
672*0Sstevel@tonic-gate 		case FIRST_PASS:
673*0Sstevel@tonic-gate 
674*0Sstevel@tonic-gate 			/* check the existence of the element which */
675*0Sstevel@tonic-gate 			/* corresponding to the given index and */
676*0Sstevel@tonic-gate 			/* check the validity fo the input value */
677*0Sstevel@tonic-gate 			/* if not valid or not exist, */
678*0Sstevel@tonic-gate 
679*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
680*0Sstevel@tonic-gate 
681*0Sstevel@tonic-gate 		case SECOND_PASS:
682*0Sstevel@tonic-gate 
683*0Sstevel@tonic-gate 			/* change the following coding, such that */
684*0Sstevel@tonic-gate 			/* the input value will be stored in the */
685*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
686*0Sstevel@tonic-gate 			/* index */
687*0Sstevel@tonic-gate 			memcpy(buf,agentExecutable->chars,agentExecutable->len);
688*0Sstevel@tonic-gate 			buf[agentExecutable->len+1] = '\0';
689*0Sstevel@tonic-gate 			printf("The new value is %s\n",buf);
690*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
691*0Sstevel@tonic-gate 	}
692*0Sstevel@tonic-gate }
693*0Sstevel@tonic-gate 
694*0Sstevel@tonic-gate 
free_agentExecutable(String * agentExecutable)695*0Sstevel@tonic-gate void free_agentExecutable(String *agentExecutable)
696*0Sstevel@tonic-gate {
697*0Sstevel@tonic-gate 	 if(agentExecutable->chars!=NULL && agentExecutable->len !=0)
698*0Sstevel@tonic-gate 	{
699*0Sstevel@tonic-gate 		free(agentExecutable->chars);
700*0Sstevel@tonic-gate 		agentExecutable->len = 0;
701*0Sstevel@tonic-gate 	}
702*0Sstevel@tonic-gate }
703*0Sstevel@tonic-gate 
get_agentVersionNum(int search_type,String * agentVersionNum,IndexType * index)704*0Sstevel@tonic-gate int get_agentVersionNum(int search_type, String *agentVersionNum, IndexType *index)
705*0Sstevel@tonic-gate {
706*0Sstevel@tonic-gate 	u_char *str;
707*0Sstevel@tonic-gate 	int len;
708*0Sstevel@tonic-gate 
709*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
710*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
711*0Sstevel@tonic-gate 	/* appropriate value */
712*0Sstevel@tonic-gate 	switch(search_type)
713*0Sstevel@tonic-gate 	{
714*0Sstevel@tonic-gate 		case FIRST_ENTRY:
715*0Sstevel@tonic-gate 			if(index->type == INTEGER){
716*0Sstevel@tonic-gate 
717*0Sstevel@tonic-gate 				/* assume 1 is the first index */
718*0Sstevel@tonic-gate 
719*0Sstevel@tonic-gate 				index->value[0] = 1;
720*0Sstevel@tonic-gate 				index->len = 1;
721*0Sstevel@tonic-gate 			}else{
722*0Sstevel@tonic-gate 
723*0Sstevel@tonic-gate 				/* index type will be array of integer */
724*0Sstevel@tonic-gate 				/* assume that there are two index */
725*0Sstevel@tonic-gate 
726*0Sstevel@tonic-gate 				index->value[0] = 1;
727*0Sstevel@tonic-gate 				index->value[1]= 1;
728*0Sstevel@tonic-gate 				index->len = 2;
729*0Sstevel@tonic-gate 			}
730*0Sstevel@tonic-gate 			break;
731*0Sstevel@tonic-gate 
732*0Sstevel@tonic-gate 		case NEXT_ENTRY:
733*0Sstevel@tonic-gate 			if(index->type == INTEGER){
734*0Sstevel@tonic-gate 				index->value[0]++;
735*0Sstevel@tonic-gate 			}else{
736*0Sstevel@tonic-gate 
737*0Sstevel@tonic-gate 				/* index type will be array of integer */
738*0Sstevel@tonic-gate 				/* assume that there are two index */
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate 				index->value[index->len-1]++;
741*0Sstevel@tonic-gate 			}
742*0Sstevel@tonic-gate 			break;
743*0Sstevel@tonic-gate 
744*0Sstevel@tonic-gate 		case EXACT_ENTRY:
745*0Sstevel@tonic-gate 			break;
746*0Sstevel@tonic-gate 	}
747*0Sstevel@tonic-gate 
748*0Sstevel@tonic-gate 	/* It is required to allocate memory to the pointers */
749*0Sstevel@tonic-gate 	/* inside the input argument */
750*0Sstevel@tonic-gate 	/* Here, we assume that "hello" is the value of the mib variable */
751*0Sstevel@tonic-gate 	/* please change it to the real one */
752*0Sstevel@tonic-gate 
753*0Sstevel@tonic-gate 	len = strlen("hello");
754*0Sstevel@tonic-gate 	str = (u_char*)calloc(len,sizeof(char));
755*0Sstevel@tonic-gate 	if(str==NULL){
756*0Sstevel@tonic-gate 		return SNMP_ERR_GENERR;
757*0Sstevel@tonic-gate 	}
758*0Sstevel@tonic-gate 	memcpy(str,"hello",len);
759*0Sstevel@tonic-gate 
760*0Sstevel@tonic-gate 	/*fill in the contents of the argument */
761*0Sstevel@tonic-gate 
762*0Sstevel@tonic-gate 	agentVersionNum->chars = str;
763*0Sstevel@tonic-gate 	agentVersionNum->len = len;
764*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
765*0Sstevel@tonic-gate }
766*0Sstevel@tonic-gate 
set_agentVersionNum(int pass,IndexType index,String * agentVersionNum)767*0Sstevel@tonic-gate int set_agentVersionNum(int pass, IndexType index, String *agentVersionNum)
768*0Sstevel@tonic-gate {
769*0Sstevel@tonic-gate 	char buf[100];
770*0Sstevel@tonic-gate 
771*0Sstevel@tonic-gate 	switch(pass)
772*0Sstevel@tonic-gate 	{
773*0Sstevel@tonic-gate 		case FIRST_PASS:
774*0Sstevel@tonic-gate 
775*0Sstevel@tonic-gate 			/* check the existence of the element which */
776*0Sstevel@tonic-gate 			/* corresponding to the given index and */
777*0Sstevel@tonic-gate 			/* check the validity fo the input value */
778*0Sstevel@tonic-gate 			/* if not valid or not exist, */
779*0Sstevel@tonic-gate 
780*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
781*0Sstevel@tonic-gate 
782*0Sstevel@tonic-gate 		case SECOND_PASS:
783*0Sstevel@tonic-gate 
784*0Sstevel@tonic-gate 			/* change the following coding, such that */
785*0Sstevel@tonic-gate 			/* the input value will be stored in the */
786*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
787*0Sstevel@tonic-gate 			/* index */
788*0Sstevel@tonic-gate 			memcpy(buf,agentVersionNum->chars,agentVersionNum->len);
789*0Sstevel@tonic-gate 			buf[agentVersionNum->len+1] = '\0';
790*0Sstevel@tonic-gate 			printf("The new value is %s\n",buf);
791*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
792*0Sstevel@tonic-gate 	}
793*0Sstevel@tonic-gate }
794*0Sstevel@tonic-gate 
795*0Sstevel@tonic-gate 
free_agentVersionNum(String * agentVersionNum)796*0Sstevel@tonic-gate void free_agentVersionNum(String *agentVersionNum)
797*0Sstevel@tonic-gate {
798*0Sstevel@tonic-gate 	 if(agentVersionNum->chars!=NULL && agentVersionNum->len !=0)
799*0Sstevel@tonic-gate 	{
800*0Sstevel@tonic-gate 		free(agentVersionNum->chars);
801*0Sstevel@tonic-gate 		agentVersionNum->len = 0;
802*0Sstevel@tonic-gate 	}
803*0Sstevel@tonic-gate }
804*0Sstevel@tonic-gate 
get_agentProcessID(int search_type,Integer * agentProcessID,IndexType * index)805*0Sstevel@tonic-gate int get_agentProcessID(int search_type, Integer *agentProcessID, IndexType *index)
806*0Sstevel@tonic-gate {
807*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
808*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
809*0Sstevel@tonic-gate 	/* appropriate value */
810*0Sstevel@tonic-gate 	switch(search_type)
811*0Sstevel@tonic-gate 	{
812*0Sstevel@tonic-gate 		case FIRST_ENTRY:
813*0Sstevel@tonic-gate 			if(index->type == INTEGER){
814*0Sstevel@tonic-gate 
815*0Sstevel@tonic-gate 				/* assume 1 is the first index */
816*0Sstevel@tonic-gate 
817*0Sstevel@tonic-gate 				index->value[0] = 1;
818*0Sstevel@tonic-gate 				index->len = 1;
819*0Sstevel@tonic-gate 			}else{
820*0Sstevel@tonic-gate 
821*0Sstevel@tonic-gate 				/* index type will be array of integer */
822*0Sstevel@tonic-gate 				/* assume that there are two index */
823*0Sstevel@tonic-gate 
824*0Sstevel@tonic-gate 				index->value[0] = 1;
825*0Sstevel@tonic-gate 				index->value[1]= 1;
826*0Sstevel@tonic-gate 				index->len = 2;
827*0Sstevel@tonic-gate 			}
828*0Sstevel@tonic-gate 			break;
829*0Sstevel@tonic-gate 
830*0Sstevel@tonic-gate 		case NEXT_ENTRY:
831*0Sstevel@tonic-gate 			if(index->type == INTEGER){
832*0Sstevel@tonic-gate 				index->value[0]++;
833*0Sstevel@tonic-gate 			}else{
834*0Sstevel@tonic-gate 
835*0Sstevel@tonic-gate 				/* index type will be array of integer */
836*0Sstevel@tonic-gate 				/* assume that there are two index */
837*0Sstevel@tonic-gate 
838*0Sstevel@tonic-gate 				index->value[index->len-1]++;
839*0Sstevel@tonic-gate 			}
840*0Sstevel@tonic-gate 			break;
841*0Sstevel@tonic-gate 
842*0Sstevel@tonic-gate 		case EXACT_ENTRY:
843*0Sstevel@tonic-gate 			break;
844*0Sstevel@tonic-gate 	}
845*0Sstevel@tonic-gate 
846*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
847*0Sstevel@tonic-gate 
848*0Sstevel@tonic-gate 	*agentProcessID = 1;
849*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
850*0Sstevel@tonic-gate }
851*0Sstevel@tonic-gate 
set_agentProcessID(int pass,IndexType index,Integer * agentProcessID)852*0Sstevel@tonic-gate int set_agentProcessID(int pass, IndexType index, Integer *agentProcessID)
853*0Sstevel@tonic-gate {
854*0Sstevel@tonic-gate 	switch(pass)
855*0Sstevel@tonic-gate 	{
856*0Sstevel@tonic-gate 		case FIRST_PASS:
857*0Sstevel@tonic-gate 
858*0Sstevel@tonic-gate 			/* check the existence of the element which */
859*0Sstevel@tonic-gate 			/* corresponding to the given index and */
860*0Sstevel@tonic-gate 			/* check the validity fo the input value */
861*0Sstevel@tonic-gate 			/* if not valid or not exist, */
862*0Sstevel@tonic-gate 
863*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
864*0Sstevel@tonic-gate 
865*0Sstevel@tonic-gate 		case SECOND_PASS:
866*0Sstevel@tonic-gate 
867*0Sstevel@tonic-gate 			/* change the following coding, such that */
868*0Sstevel@tonic-gate 			/* the input value will be stored in the */
869*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
870*0Sstevel@tonic-gate 			/* index */
871*0Sstevel@tonic-gate 			printf("The new value is %d\n",agentProcessID);
872*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
873*0Sstevel@tonic-gate 	}
874*0Sstevel@tonic-gate }
875*0Sstevel@tonic-gate 
876*0Sstevel@tonic-gate 
get_agentName(int search_type,String * agentName,IndexType * index)877*0Sstevel@tonic-gate int get_agentName(int search_type, String *agentName, IndexType *index)
878*0Sstevel@tonic-gate {
879*0Sstevel@tonic-gate 	u_char *str;
880*0Sstevel@tonic-gate 	int len;
881*0Sstevel@tonic-gate 
882*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
883*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
884*0Sstevel@tonic-gate 	/* appropriate value */
885*0Sstevel@tonic-gate 	switch(search_type)
886*0Sstevel@tonic-gate 	{
887*0Sstevel@tonic-gate 		case FIRST_ENTRY:
888*0Sstevel@tonic-gate 			if(index->type == INTEGER){
889*0Sstevel@tonic-gate 
890*0Sstevel@tonic-gate 				/* assume 1 is the first index */
891*0Sstevel@tonic-gate 
892*0Sstevel@tonic-gate 				index->value[0] = 1;
893*0Sstevel@tonic-gate 				index->len = 1;
894*0Sstevel@tonic-gate 			}else{
895*0Sstevel@tonic-gate 
896*0Sstevel@tonic-gate 				/* index type will be array of integer */
897*0Sstevel@tonic-gate 				/* assume that there are two index */
898*0Sstevel@tonic-gate 
899*0Sstevel@tonic-gate 				index->value[0] = 1;
900*0Sstevel@tonic-gate 				index->value[1]= 1;
901*0Sstevel@tonic-gate 				index->len = 2;
902*0Sstevel@tonic-gate 			}
903*0Sstevel@tonic-gate 			break;
904*0Sstevel@tonic-gate 
905*0Sstevel@tonic-gate 		case NEXT_ENTRY:
906*0Sstevel@tonic-gate 			if(index->type == INTEGER){
907*0Sstevel@tonic-gate 				index->value[0]++;
908*0Sstevel@tonic-gate 			}else{
909*0Sstevel@tonic-gate 
910*0Sstevel@tonic-gate 				/* index type will be array of integer */
911*0Sstevel@tonic-gate 				/* assume that there are two index */
912*0Sstevel@tonic-gate 
913*0Sstevel@tonic-gate 				index->value[index->len-1]++;
914*0Sstevel@tonic-gate 			}
915*0Sstevel@tonic-gate 			break;
916*0Sstevel@tonic-gate 
917*0Sstevel@tonic-gate 		case EXACT_ENTRY:
918*0Sstevel@tonic-gate 			break;
919*0Sstevel@tonic-gate 	}
920*0Sstevel@tonic-gate 
921*0Sstevel@tonic-gate 	/* It is required to allocate memory to the pointers */
922*0Sstevel@tonic-gate 	/* inside the input argument */
923*0Sstevel@tonic-gate 	/* Here, we assume that "hello" is the value of the mib variable */
924*0Sstevel@tonic-gate 	/* please change it to the real one */
925*0Sstevel@tonic-gate 
926*0Sstevel@tonic-gate 	len = strlen("hello");
927*0Sstevel@tonic-gate 	str = (u_char*)calloc(len,sizeof(char));
928*0Sstevel@tonic-gate 	if(str==NULL){
929*0Sstevel@tonic-gate 		return SNMP_ERR_GENERR;
930*0Sstevel@tonic-gate 	}
931*0Sstevel@tonic-gate 	memcpy(str,"hello",len);
932*0Sstevel@tonic-gate 
933*0Sstevel@tonic-gate 	/*fill in the contents of the argument */
934*0Sstevel@tonic-gate 
935*0Sstevel@tonic-gate 	agentName->chars = str;
936*0Sstevel@tonic-gate 	agentName->len = len;
937*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
938*0Sstevel@tonic-gate }
939*0Sstevel@tonic-gate 
set_agentName(int pass,IndexType index,String * agentName)940*0Sstevel@tonic-gate int set_agentName(int pass, IndexType index, String *agentName)
941*0Sstevel@tonic-gate {
942*0Sstevel@tonic-gate 	char buf[100];
943*0Sstevel@tonic-gate 
944*0Sstevel@tonic-gate 	switch(pass)
945*0Sstevel@tonic-gate 	{
946*0Sstevel@tonic-gate 		case FIRST_PASS:
947*0Sstevel@tonic-gate 
948*0Sstevel@tonic-gate 			/* check the existence of the element which */
949*0Sstevel@tonic-gate 			/* corresponding to the given index and */
950*0Sstevel@tonic-gate 			/* check the validity fo the input value */
951*0Sstevel@tonic-gate 			/* if not valid or not exist, */
952*0Sstevel@tonic-gate 
953*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
954*0Sstevel@tonic-gate 
955*0Sstevel@tonic-gate 		case SECOND_PASS:
956*0Sstevel@tonic-gate 
957*0Sstevel@tonic-gate 			/* change the following coding, such that */
958*0Sstevel@tonic-gate 			/* the input value will be stored in the */
959*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
960*0Sstevel@tonic-gate 			/* index */
961*0Sstevel@tonic-gate 			memcpy(buf,agentName->chars,agentName->len);
962*0Sstevel@tonic-gate 			buf[agentName->len+1] = '\0';
963*0Sstevel@tonic-gate 			printf("The new value is %s\n",buf);
964*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
965*0Sstevel@tonic-gate 	}
966*0Sstevel@tonic-gate }
967*0Sstevel@tonic-gate 
968*0Sstevel@tonic-gate 
free_agentName(String * agentName)969*0Sstevel@tonic-gate void free_agentName(String *agentName)
970*0Sstevel@tonic-gate {
971*0Sstevel@tonic-gate 	 if(agentName->chars!=NULL && agentName->len !=0)
972*0Sstevel@tonic-gate 	{
973*0Sstevel@tonic-gate 		free(agentName->chars);
974*0Sstevel@tonic-gate 		agentName->len = 0;
975*0Sstevel@tonic-gate 	}
976*0Sstevel@tonic-gate }
977*0Sstevel@tonic-gate 
get_agentSystemUpTime(int search_type,Integer * agentSystemUpTime,IndexType * index)978*0Sstevel@tonic-gate int get_agentSystemUpTime(int search_type, Integer *agentSystemUpTime, IndexType *index)
979*0Sstevel@tonic-gate {
980*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
981*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
982*0Sstevel@tonic-gate 	/* appropriate value */
983*0Sstevel@tonic-gate 	switch(search_type)
984*0Sstevel@tonic-gate 	{
985*0Sstevel@tonic-gate 		case FIRST_ENTRY:
986*0Sstevel@tonic-gate 			if(index->type == INTEGER){
987*0Sstevel@tonic-gate 
988*0Sstevel@tonic-gate 				/* assume 1 is the first index */
989*0Sstevel@tonic-gate 
990*0Sstevel@tonic-gate 				index->value[0] = 1;
991*0Sstevel@tonic-gate 				index->len = 1;
992*0Sstevel@tonic-gate 			}else{
993*0Sstevel@tonic-gate 
994*0Sstevel@tonic-gate 				/* index type will be array of integer */
995*0Sstevel@tonic-gate 				/* assume that there are two index */
996*0Sstevel@tonic-gate 
997*0Sstevel@tonic-gate 				index->value[0] = 1;
998*0Sstevel@tonic-gate 				index->value[1]= 1;
999*0Sstevel@tonic-gate 				index->len = 2;
1000*0Sstevel@tonic-gate 			}
1001*0Sstevel@tonic-gate 			break;
1002*0Sstevel@tonic-gate 
1003*0Sstevel@tonic-gate 		case NEXT_ENTRY:
1004*0Sstevel@tonic-gate 			if(index->type == INTEGER){
1005*0Sstevel@tonic-gate 				index->value[0]++;
1006*0Sstevel@tonic-gate 			}else{
1007*0Sstevel@tonic-gate 
1008*0Sstevel@tonic-gate 				/* index type will be array of integer */
1009*0Sstevel@tonic-gate 				/* assume that there are two index */
1010*0Sstevel@tonic-gate 
1011*0Sstevel@tonic-gate 				index->value[index->len-1]++;
1012*0Sstevel@tonic-gate 			}
1013*0Sstevel@tonic-gate 			break;
1014*0Sstevel@tonic-gate 
1015*0Sstevel@tonic-gate 		case EXACT_ENTRY:
1016*0Sstevel@tonic-gate 			break;
1017*0Sstevel@tonic-gate 	}
1018*0Sstevel@tonic-gate 
1019*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
1020*0Sstevel@tonic-gate 
1021*0Sstevel@tonic-gate 	*agentSystemUpTime = 1;
1022*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
1023*0Sstevel@tonic-gate }
1024*0Sstevel@tonic-gate 
set_agentSystemUpTime(int pass,IndexType index,Integer * agentSystemUpTime)1025*0Sstevel@tonic-gate int set_agentSystemUpTime(int pass, IndexType index, Integer *agentSystemUpTime)
1026*0Sstevel@tonic-gate {
1027*0Sstevel@tonic-gate 	switch(pass)
1028*0Sstevel@tonic-gate 	{
1029*0Sstevel@tonic-gate 		case FIRST_PASS:
1030*0Sstevel@tonic-gate 
1031*0Sstevel@tonic-gate 			/* check the existence of the element which */
1032*0Sstevel@tonic-gate 			/* corresponding to the given index and */
1033*0Sstevel@tonic-gate 			/* check the validity fo the input value */
1034*0Sstevel@tonic-gate 			/* if not valid or not exist, */
1035*0Sstevel@tonic-gate 
1036*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
1037*0Sstevel@tonic-gate 
1038*0Sstevel@tonic-gate 		case SECOND_PASS:
1039*0Sstevel@tonic-gate 
1040*0Sstevel@tonic-gate 			/* change the following coding, such that */
1041*0Sstevel@tonic-gate 			/* the input value will be stored in the */
1042*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
1043*0Sstevel@tonic-gate 			/* index */
1044*0Sstevel@tonic-gate 			printf("The new value is %d\n",agentSystemUpTime);
1045*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
1046*0Sstevel@tonic-gate 	}
1047*0Sstevel@tonic-gate }
1048*0Sstevel@tonic-gate 
1049*0Sstevel@tonic-gate 
get_agentWatchDogTime(int search_type,Integer * agentWatchDogTime,IndexType * index)1050*0Sstevel@tonic-gate int get_agentWatchDogTime(int search_type, Integer *agentWatchDogTime, IndexType *index)
1051*0Sstevel@tonic-gate {
1052*0Sstevel@tonic-gate 	/* In the case, the search_type is FIRST_ENTRY or NEXT_ENTRY */
1053*0Sstevel@tonic-gate 	/* this function should modify the index argument to the */
1054*0Sstevel@tonic-gate 	/* appropriate value */
1055*0Sstevel@tonic-gate 	switch(search_type)
1056*0Sstevel@tonic-gate 	{
1057*0Sstevel@tonic-gate 		case FIRST_ENTRY:
1058*0Sstevel@tonic-gate 			if(index->type == INTEGER){
1059*0Sstevel@tonic-gate 
1060*0Sstevel@tonic-gate 				/* assume 1 is the first index */
1061*0Sstevel@tonic-gate 
1062*0Sstevel@tonic-gate 				index->value[0] = 1;
1063*0Sstevel@tonic-gate 				index->len = 1;
1064*0Sstevel@tonic-gate 			}else{
1065*0Sstevel@tonic-gate 
1066*0Sstevel@tonic-gate 				/* index type will be array of integer */
1067*0Sstevel@tonic-gate 				/* assume that there are two index */
1068*0Sstevel@tonic-gate 
1069*0Sstevel@tonic-gate 				index->value[0] = 1;
1070*0Sstevel@tonic-gate 				index->value[1]= 1;
1071*0Sstevel@tonic-gate 				index->len = 2;
1072*0Sstevel@tonic-gate 			}
1073*0Sstevel@tonic-gate 			break;
1074*0Sstevel@tonic-gate 
1075*0Sstevel@tonic-gate 		case NEXT_ENTRY:
1076*0Sstevel@tonic-gate 			if(index->type == INTEGER){
1077*0Sstevel@tonic-gate 				index->value[0]++;
1078*0Sstevel@tonic-gate 			}else{
1079*0Sstevel@tonic-gate 
1080*0Sstevel@tonic-gate 				/* index type will be array of integer */
1081*0Sstevel@tonic-gate 				/* assume that there are two index */
1082*0Sstevel@tonic-gate 
1083*0Sstevel@tonic-gate 				index->value[index->len-1]++;
1084*0Sstevel@tonic-gate 			}
1085*0Sstevel@tonic-gate 			break;
1086*0Sstevel@tonic-gate 
1087*0Sstevel@tonic-gate 		case EXACT_ENTRY:
1088*0Sstevel@tonic-gate 			break;
1089*0Sstevel@tonic-gate 	}
1090*0Sstevel@tonic-gate 
1091*0Sstevel@tonic-gate 	/*assume that the mib variable has a value of 1 */
1092*0Sstevel@tonic-gate 
1093*0Sstevel@tonic-gate 	*agentWatchDogTime = 1;
1094*0Sstevel@tonic-gate 	return SNMP_ERR_NOERROR;
1095*0Sstevel@tonic-gate }
1096*0Sstevel@tonic-gate 
set_agentWatchDogTime(int pass,IndexType index,Integer * agentWatchDogTime)1097*0Sstevel@tonic-gate int set_agentWatchDogTime(int pass, IndexType index, Integer *agentWatchDogTime)
1098*0Sstevel@tonic-gate {
1099*0Sstevel@tonic-gate 	switch(pass)
1100*0Sstevel@tonic-gate 	{
1101*0Sstevel@tonic-gate 		case FIRST_PASS:
1102*0Sstevel@tonic-gate 
1103*0Sstevel@tonic-gate 			/* check the existence of the element which */
1104*0Sstevel@tonic-gate 			/* corresponding to the given index and */
1105*0Sstevel@tonic-gate 			/* check the validity fo the input value */
1106*0Sstevel@tonic-gate 			/* if not valid or not exist, */
1107*0Sstevel@tonic-gate 
1108*0Sstevel@tonic-gate 			return SNMP_ERR_GENERR;
1109*0Sstevel@tonic-gate 
1110*0Sstevel@tonic-gate 		case SECOND_PASS:
1111*0Sstevel@tonic-gate 
1112*0Sstevel@tonic-gate 			/* change the following coding, such that */
1113*0Sstevel@tonic-gate 			/* the input value will be stored in the */
1114*0Sstevel@tonic-gate 			/* corresponding mib variable of the given */
1115*0Sstevel@tonic-gate 			/* index */
1116*0Sstevel@tonic-gate 			printf("The new value is %d\n",agentWatchDogTime);
1117*0Sstevel@tonic-gate 			return SNMP_ERR_NOERROR;
1118*0Sstevel@tonic-gate 	}
1119*0Sstevel@tonic-gate }
1120*0Sstevel@tonic-gate 
1121