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 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <unistd.h>
30*0Sstevel@tonic-gate #include <sys/types.h>
31*0Sstevel@tonic-gate #include <sys/times.h>
32*0Sstevel@tonic-gate #include <netinet/in.h>
33*0Sstevel@tonic-gate #include <stdio.h>
34*0Sstevel@tonic-gate #include <sys/socket.h>
35*0Sstevel@tonic-gate #include <errno.h>
36*0Sstevel@tonic-gate #include <syslog.h>
37*0Sstevel@tonic-gate #include <string.h>
38*0Sstevel@tonic-gate #include <arpa/inet.h>
39*0Sstevel@tonic-gate #include <netdb.h>
40*0Sstevel@tonic-gate #include <nlist.h>
41*0Sstevel@tonic-gate
42*0Sstevel@tonic-gate #include "snmp_msg.h"
43*0Sstevel@tonic-gate #include "impl.h"
44*0Sstevel@tonic-gate #include "trace.h"
45*0Sstevel@tonic-gate #include "snmp.h"
46*0Sstevel@tonic-gate #include "pdu.h"
47*0Sstevel@tonic-gate #include "request.h"
48*0Sstevel@tonic-gate #include "error.h"
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate /***** GLOBAL VARIABLES *****/
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate static Subid sysUptime_subids[] = { 1, 3, 6, 1, 2, 1, 1, 3, 0 };
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate Oid sysUptime_name = { sysUptime_subids, 8 };
57*0Sstevel@tonic-gate Oid sysUptime_instance = { sysUptime_subids, 9 };
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate /***** LOCAL VARIABLES *****/
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate static uint32_t request_id = 0;
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate static Subid snmpEnableAuthTraps_subids[] = { 1, 3, 6, 1, 2, 1, 11, 30, 0 };
65*0Sstevel@tonic-gate static Oid snmpEnableAuthTraps_name = { snmpEnableAuthTraps_subids, 9 };
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate
68*0Sstevel@tonic-gate /********************************************************************/
69*0Sstevel@tonic-gate
request_create(char * community,int type,char * error_label)70*0Sstevel@tonic-gate /* static */ SNMP_pdu *request_create(char *community, int type, char *error_label)
71*0Sstevel@tonic-gate {
72*0Sstevel@tonic-gate SNMP_pdu *request;
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gate error_label[0] = '\0';
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate switch(type)
78*0Sstevel@tonic-gate {
79*0Sstevel@tonic-gate case GET_REQ_MSG:
80*0Sstevel@tonic-gate case GETNEXT_REQ_MSG:
81*0Sstevel@tonic-gate case SET_REQ_MSG:
82*0Sstevel@tonic-gate break;
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate default:
85*0Sstevel@tonic-gate sprintf(error_label, "BUG: request_create(): bad type (0x%x)",
86*0Sstevel@tonic-gate type);
87*0Sstevel@tonic-gate return NULL;
88*0Sstevel@tonic-gate }
89*0Sstevel@tonic-gate
90*0Sstevel@tonic-gate request = snmp_pdu_new(error_label);
91*0Sstevel@tonic-gate if(request == NULL)
92*0Sstevel@tonic-gate {
93*0Sstevel@tonic-gate return NULL;
94*0Sstevel@tonic-gate }
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gate request->version = SNMP_VERSION_1;
97*0Sstevel@tonic-gate request->community = strdup(community);
98*0Sstevel@tonic-gate if(request->community == NULL)
99*0Sstevel@tonic-gate {
100*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_ALLOC);
101*0Sstevel@tonic-gate snmp_pdu_free(request);
102*0Sstevel@tonic-gate return NULL;
103*0Sstevel@tonic-gate }
104*0Sstevel@tonic-gate request->type = type;
105*0Sstevel@tonic-gate request->request_id = request_id++;
106*0Sstevel@tonic-gate
107*0Sstevel@tonic-gate
108*0Sstevel@tonic-gate return request;
109*0Sstevel@tonic-gate }
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate
112*0Sstevel@tonic-gate /********************************************************************/
113*0Sstevel@tonic-gate
request_send_to_port_time_out_blocking(IPAddress * ip_address,int port,struct timeval * timeout,SNMP_pdu * request,char * error_label)114*0Sstevel@tonic-gate SNMP_pdu *request_send_to_port_time_out_blocking(IPAddress *ip_address, int port,struct timeval *timeout,SNMP_pdu *request, char *error_label)
115*0Sstevel@tonic-gate {
116*0Sstevel@tonic-gate int sd;
117*0Sstevel@tonic-gate Address address;
118*0Sstevel@tonic-gate SNMP_pdu *response;
119*0Sstevel@tonic-gate Address me;
120*0Sstevel@tonic-gate int numfds;
121*0Sstevel@tonic-gate fd_set fdset;
122*0Sstevel@tonic-gate int count;
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate
125*0Sstevel@tonic-gate error_label[0] = '\0';
126*0Sstevel@tonic-gate
127*0Sstevel@tonic-gate if(request == NULL)
128*0Sstevel@tonic-gate {
129*0Sstevel@tonic-gate sprintf(error_label, "BUG: request_send_blocking(): request is NULL");
130*0Sstevel@tonic-gate return NULL;
131*0Sstevel@tonic-gate }
132*0Sstevel@tonic-gate
133*0Sstevel@tonic-gate switch(request->type)
134*0Sstevel@tonic-gate {
135*0Sstevel@tonic-gate case GET_REQ_MSG:
136*0Sstevel@tonic-gate case GETNEXT_REQ_MSG:
137*0Sstevel@tonic-gate case SET_REQ_MSG:
138*0Sstevel@tonic-gate break;
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gate default:
141*0Sstevel@tonic-gate sprintf(error_label, "BUG: request_send_blocking(): bad type (0x%x)",
142*0Sstevel@tonic-gate request->type);
143*0Sstevel@tonic-gate return NULL;
144*0Sstevel@tonic-gate }
145*0Sstevel@tonic-gate
146*0Sstevel@tonic-gate /* sd */
147*0Sstevel@tonic-gate sd = socket(AF_INET, SOCK_DGRAM, 0);
148*0Sstevel@tonic-gate if(sd < 0)
149*0Sstevel@tonic-gate {
150*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_SOCKET,
151*0Sstevel@tonic-gate errno_string());
152*0Sstevel@tonic-gate return (NULL);
153*0Sstevel@tonic-gate }
154*0Sstevel@tonic-gate
155*0Sstevel@tonic-gate memset(&me, 0, sizeof (Address));
156*0Sstevel@tonic-gate me.sin_family = AF_INET;
157*0Sstevel@tonic-gate if ((request->type) == SET_REQ_MSG)
158*0Sstevel@tonic-gate me.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
159*0Sstevel@tonic-gate else
160*0Sstevel@tonic-gate me.sin_addr.s_addr = htonl(INADDR_ANY);
161*0Sstevel@tonic-gate me.sin_port = htons(0);
162*0Sstevel@tonic-gate if(bind(sd, (struct sockaddr *)&me, sizeof(me)) != 0)
163*0Sstevel@tonic-gate {
164*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_BIND,
165*0Sstevel@tonic-gate errno_string());
166*0Sstevel@tonic-gate (void)close(sd);
167*0Sstevel@tonic-gate return NULL;
168*0Sstevel@tonic-gate }
169*0Sstevel@tonic-gate
170*0Sstevel@tonic-gate /* address */
171*0Sstevel@tonic-gate memset(&address, 0, sizeof(Address));
172*0Sstevel@tonic-gate address.sin_family = AF_INET;
173*0Sstevel@tonic-gate /* LINTED */
174*0Sstevel@tonic-gate address.sin_port = (short)port;
175*0Sstevel@tonic-gate address.sin_addr.s_addr = ip_address->s_addr;
176*0Sstevel@tonic-gate
177*0Sstevel@tonic-gate if(snmp_pdu_send(sd, &address, request, error_label))
178*0Sstevel@tonic-gate {
179*0Sstevel@tonic-gate (void)close(sd);
180*0Sstevel@tonic-gate return NULL;
181*0Sstevel@tonic-gate }
182*0Sstevel@tonic-gate
183*0Sstevel@tonic-gate
184*0Sstevel@tonic-gate for (;;)
185*0Sstevel@tonic-gate {
186*0Sstevel@tonic-gate numfds = 0;
187*0Sstevel@tonic-gate FD_ZERO(&fdset);
188*0Sstevel@tonic-gate
189*0Sstevel@tonic-gate numfds = sd + 1;
190*0Sstevel@tonic-gate FD_SET(sd, &fdset);
191*0Sstevel@tonic-gate
192*0Sstevel@tonic-gate count = select(numfds, &fdset, 0, 0, timeout);
193*0Sstevel@tonic-gate if(count > 0)
194*0Sstevel@tonic-gate {
195*0Sstevel@tonic-gate if(FD_ISSET(sd, &fdset))
196*0Sstevel@tonic-gate {
197*0Sstevel@tonic-gate response = snmp_pdu_receive(sd, &address, error_label);
198*0Sstevel@tonic-gate if(response == NULL)
199*0Sstevel@tonic-gate {
200*0Sstevel@tonic-gate (void)close(sd);
201*0Sstevel@tonic-gate return NULL;
202*0Sstevel@tonic-gate }
203*0Sstevel@tonic-gate (void)close(sd);
204*0Sstevel@tonic-gate
205*0Sstevel@tonic-gate return response;
206*0Sstevel@tonic-gate }
207*0Sstevel@tonic-gate }
208*0Sstevel@tonic-gate else
209*0Sstevel@tonic-gate {
210*0Sstevel@tonic-gate switch(count)
211*0Sstevel@tonic-gate {
212*0Sstevel@tonic-gate case 0:
213*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_TIMEOUT);
214*0Sstevel@tonic-gate (void)close(sd);
215*0Sstevel@tonic-gate return NULL;
216*0Sstevel@tonic-gate
217*0Sstevel@tonic-gate case -1:
218*0Sstevel@tonic-gate if(errno == EINTR)
219*0Sstevel@tonic-gate {
220*0Sstevel@tonic-gate continue;
221*0Sstevel@tonic-gate }
222*0Sstevel@tonic-gate else
223*0Sstevel@tonic-gate {
224*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_SELECT,
225*0Sstevel@tonic-gate errno_string());
226*0Sstevel@tonic-gate (void)close(sd);
227*0Sstevel@tonic-gate return NULL;
228*0Sstevel@tonic-gate }
229*0Sstevel@tonic-gate }
230*0Sstevel@tonic-gate }
231*0Sstevel@tonic-gate }
232*0Sstevel@tonic-gate /* NOTREACHED */
233*0Sstevel@tonic-gate }
234*0Sstevel@tonic-gate
235*0Sstevel@tonic-gate
request_send_to_port_blocking(IPAddress * ip_address,int port,SNMP_pdu * request,char * error_label)236*0Sstevel@tonic-gate SNMP_pdu *request_send_to_port_blocking(IPAddress *ip_address, int port,SNMP_pdu *request, char *error_label)
237*0Sstevel@tonic-gate {
238*0Sstevel@tonic-gate struct timeval timeout;
239*0Sstevel@tonic-gate
240*0Sstevel@tonic-gate timeout.tv_sec = 100;
241*0Sstevel@tonic-gate timeout.tv_usec = 0;
242*0Sstevel@tonic-gate return(request_send_to_port_time_out_blocking
243*0Sstevel@tonic-gate (ip_address,port,&timeout,request,error_label));
244*0Sstevel@tonic-gate }
245*0Sstevel@tonic-gate
246*0Sstevel@tonic-gate
request_send_blocking(IPAddress * ip_address,SNMP_pdu * request,char * error_label)247*0Sstevel@tonic-gate /*static*/ SNMP_pdu *request_send_blocking(IPAddress *ip_address, SNMP_pdu *request, char *error_label)
248*0Sstevel@tonic-gate {
249*0Sstevel@tonic-gate return(request_send_to_port_blocking(ip_address,SNMP_PORT,request,error_label));
250*0Sstevel@tonic-gate }
251*0Sstevel@tonic-gate
252*0Sstevel@tonic-gate /********************************************************************/
253*0Sstevel@tonic-gate
254*0Sstevel@tonic-gate /*
255*0Sstevel@tonic-gate * if the request failed, this function returns 0
256*0Sstevel@tonic-gate * otherwise it returns sysUpTime
257*0Sstevel@tonic-gate */
258*0Sstevel@tonic-gate
request_sysUpTime(char * error_label,char * community_name)259*0Sstevel@tonic-gate int32_t request_sysUpTime(char *error_label, char *community_name)
260*0Sstevel@tonic-gate {
261*0Sstevel@tonic-gate static int my_ip_address_initialized = False;
262*0Sstevel@tonic-gate static IPAddress my_ip_address;
263*0Sstevel@tonic-gate SNMP_pdu *request;
264*0Sstevel@tonic-gate SNMP_pdu *response;
265*0Sstevel@tonic-gate SNMP_variable *variable;
266*0Sstevel@tonic-gate static int32_t sysUpTime = 0;
267*0Sstevel@tonic-gate static clock_t last = 0;
268*0Sstevel@tonic-gate clock_t now;
269*0Sstevel@tonic-gate struct tms buffer;
270*0Sstevel@tonic-gate
271*0Sstevel@tonic-gate
272*0Sstevel@tonic-gate error_label[0] = '\0';
273*0Sstevel@tonic-gate
274*0Sstevel@tonic-gate now = times(&buffer);
275*0Sstevel@tonic-gate if( (last == 0) || ((now - last) > 360000) ) /* 1 hour */
276*0Sstevel@tonic-gate {
277*0Sstevel@tonic-gate if(my_ip_address_initialized == False)
278*0Sstevel@tonic-gate {
279*0Sstevel@tonic-gate if(get_my_ip_address(&my_ip_address, error_label))
280*0Sstevel@tonic-gate {
281*0Sstevel@tonic-gate return 0;
282*0Sstevel@tonic-gate }
283*0Sstevel@tonic-gate
284*0Sstevel@tonic-gate my_ip_address_initialized = True;
285*0Sstevel@tonic-gate }
286*0Sstevel@tonic-gate
287*0Sstevel@tonic-gate if(community_name == NULL)
288*0Sstevel@tonic-gate request = request_create("public", GET_REQ_MSG, error_label);
289*0Sstevel@tonic-gate else
290*0Sstevel@tonic-gate request = request_create(community_name, GET_REQ_MSG, error_label);
291*0Sstevel@tonic-gate
292*0Sstevel@tonic-gate if(request == NULL)
293*0Sstevel@tonic-gate {
294*0Sstevel@tonic-gate return 0;
295*0Sstevel@tonic-gate }
296*0Sstevel@tonic-gate
297*0Sstevel@tonic-gate if(snmp_pdu_append_null_variable(request, &sysUptime_instance, error_label) == NULL)
298*0Sstevel@tonic-gate {
299*0Sstevel@tonic-gate snmp_pdu_free(request);
300*0Sstevel@tonic-gate return 0;
301*0Sstevel@tonic-gate }
302*0Sstevel@tonic-gate
303*0Sstevel@tonic-gate response = request_send_blocking(&my_ip_address, request, error_label);
304*0Sstevel@tonic-gate if(response == NULL)
305*0Sstevel@tonic-gate {
306*0Sstevel@tonic-gate snmp_pdu_free(request);
307*0Sstevel@tonic-gate return 0;
308*0Sstevel@tonic-gate }
309*0Sstevel@tonic-gate snmp_pdu_free(request);
310*0Sstevel@tonic-gate
311*0Sstevel@tonic-gate if(response->error_status)
312*0Sstevel@tonic-gate {
313*0Sstevel@tonic-gate sprintf(error_label, "%s",
314*0Sstevel@tonic-gate error_status_string(response->error_status));
315*0Sstevel@tonic-gate snmp_pdu_free(response);
316*0Sstevel@tonic-gate return 0;
317*0Sstevel@tonic-gate }
318*0Sstevel@tonic-gate
319*0Sstevel@tonic-gate variable = response->first_variable;
320*0Sstevel@tonic-gate if(variable->next_variable
321*0Sstevel@tonic-gate || SSAOidCmp(&(variable->name), &sysUptime_instance)
322*0Sstevel@tonic-gate || (variable->type != TIMETICKS)
323*0Sstevel@tonic-gate || (variable->val.integer == NULL)
324*0Sstevel@tonic-gate || (variable->val_len != sizeof(int32_t)) )
325*0Sstevel@tonic-gate {
326*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_BAD_RESPONSE);
327*0Sstevel@tonic-gate snmp_pdu_free(response);
328*0Sstevel@tonic-gate return 0;
329*0Sstevel@tonic-gate }
330*0Sstevel@tonic-gate sysUpTime = *(variable->val.integer);
331*0Sstevel@tonic-gate last = now;
332*0Sstevel@tonic-gate snmp_pdu_free(response);
333*0Sstevel@tonic-gate
334*0Sstevel@tonic-gate if(trace_level > 0)
335*0Sstevel@tonic-gate {
336*0Sstevel@tonic-gate trace("sysUpTime: %d\n\n", sysUpTime);
337*0Sstevel@tonic-gate }
338*0Sstevel@tonic-gate
339*0Sstevel@tonic-gate return sysUpTime;
340*0Sstevel@tonic-gate }
341*0Sstevel@tonic-gate
342*0Sstevel@tonic-gate /* LINTED */
343*0Sstevel@tonic-gate return (sysUpTime + (int32_t)(now - last));
344*0Sstevel@tonic-gate }
345*0Sstevel@tonic-gate
346*0Sstevel@tonic-gate
347*0Sstevel@tonic-gate /********************************************************************/
348*0Sstevel@tonic-gate
349*0Sstevel@tonic-gate /*
350*0Sstevel@tonic-gate * if the request failed, this function returns -1
351*0Sstevel@tonic-gate * otherwise it returns True or False accordind to the
352*0Sstevel@tonic-gate * value of snmpEnableAuthTraps
353*0Sstevel@tonic-gate */
354*0Sstevel@tonic-gate
request_snmpEnableAuthTraps(char * error_label)355*0Sstevel@tonic-gate int request_snmpEnableAuthTraps(char *error_label)
356*0Sstevel@tonic-gate {
357*0Sstevel@tonic-gate static int my_ip_address_initialized = False;
358*0Sstevel@tonic-gate static IPAddress my_ip_address;
359*0Sstevel@tonic-gate SNMP_pdu *request;
360*0Sstevel@tonic-gate SNMP_pdu *response;
361*0Sstevel@tonic-gate SNMP_variable *variable;
362*0Sstevel@tonic-gate int snmpEnableAuthTraps;
363*0Sstevel@tonic-gate struct timeval timeout;
364*0Sstevel@tonic-gate
365*0Sstevel@tonic-gate timeout.tv_sec = 5;
366*0Sstevel@tonic-gate timeout.tv_usec = 0;
367*0Sstevel@tonic-gate
368*0Sstevel@tonic-gate
369*0Sstevel@tonic-gate error_label[0] = '\0';
370*0Sstevel@tonic-gate
371*0Sstevel@tonic-gate if(my_ip_address_initialized == False)
372*0Sstevel@tonic-gate {
373*0Sstevel@tonic-gate if(get_my_ip_address(&my_ip_address, error_label))
374*0Sstevel@tonic-gate {
375*0Sstevel@tonic-gate return -1;
376*0Sstevel@tonic-gate }
377*0Sstevel@tonic-gate
378*0Sstevel@tonic-gate my_ip_address_initialized = True;
379*0Sstevel@tonic-gate }
380*0Sstevel@tonic-gate
381*0Sstevel@tonic-gate request = request_create("public", GET_REQ_MSG, error_label);
382*0Sstevel@tonic-gate if(request == NULL)
383*0Sstevel@tonic-gate {
384*0Sstevel@tonic-gate return -1;
385*0Sstevel@tonic-gate }
386*0Sstevel@tonic-gate
387*0Sstevel@tonic-gate if(snmp_pdu_append_null_variable(request, &snmpEnableAuthTraps_name, error_label) == NULL)
388*0Sstevel@tonic-gate {
389*0Sstevel@tonic-gate snmp_pdu_free(request);
390*0Sstevel@tonic-gate return -1;
391*0Sstevel@tonic-gate }
392*0Sstevel@tonic-gate
393*0Sstevel@tonic-gate response = request_send_to_port_time_out_blocking(&my_ip_address, \
394*0Sstevel@tonic-gate SNMP_PORT, &timeout, request, error_label);
395*0Sstevel@tonic-gate if(response == NULL)
396*0Sstevel@tonic-gate {
397*0Sstevel@tonic-gate snmp_pdu_free(request);
398*0Sstevel@tonic-gate return -1;
399*0Sstevel@tonic-gate }
400*0Sstevel@tonic-gate snmp_pdu_free(request);
401*0Sstevel@tonic-gate
402*0Sstevel@tonic-gate if(response->error_status)
403*0Sstevel@tonic-gate {
404*0Sstevel@tonic-gate sprintf(error_label, "%s",
405*0Sstevel@tonic-gate error_status_string(response->error_status));
406*0Sstevel@tonic-gate snmp_pdu_free(response);
407*0Sstevel@tonic-gate return -1;
408*0Sstevel@tonic-gate }
409*0Sstevel@tonic-gate
410*0Sstevel@tonic-gate variable = response->first_variable;
411*0Sstevel@tonic-gate if(variable->next_variable
412*0Sstevel@tonic-gate || SSAOidCmp(&(variable->name), &snmpEnableAuthTraps_name)
413*0Sstevel@tonic-gate || (variable->type != INTEGER)
414*0Sstevel@tonic-gate || (variable->val.integer == NULL)
415*0Sstevel@tonic-gate || (variable->val_len != sizeof(int32_t)) )
416*0Sstevel@tonic-gate {
417*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_BAD_RESPONSE);
418*0Sstevel@tonic-gate snmp_pdu_free(response);
419*0Sstevel@tonic-gate return -1;
420*0Sstevel@tonic-gate }
421*0Sstevel@tonic-gate snmpEnableAuthTraps = *(variable->val.integer);
422*0Sstevel@tonic-gate snmp_pdu_free(response);
423*0Sstevel@tonic-gate
424*0Sstevel@tonic-gate if(trace_level > 0)
425*0Sstevel@tonic-gate {
426*0Sstevel@tonic-gate trace("snmpAuthTraps: %s\n\n",
427*0Sstevel@tonic-gate (snmpEnableAuthTraps == 1)? "enabled(1)": "disabled(2)");
428*0Sstevel@tonic-gate }
429*0Sstevel@tonic-gate
430*0Sstevel@tonic-gate switch(snmpEnableAuthTraps)
431*0Sstevel@tonic-gate {
432*0Sstevel@tonic-gate case 1: /* enabled(1) */
433*0Sstevel@tonic-gate return TRUE;
434*0Sstevel@tonic-gate case 2: /* disable(2) */
435*0Sstevel@tonic-gate return FALSE;
436*0Sstevel@tonic-gate default:
437*0Sstevel@tonic-gate sprintf(error_label, ERR_MSG_BAD_VALUE);
438*0Sstevel@tonic-gate return -1;
439*0Sstevel@tonic-gate }
440*0Sstevel@tonic-gate }
441*0Sstevel@tonic-gate
442*0Sstevel@tonic-gate
443*0Sstevel@tonic-gate /********************************************************************/
444*0Sstevel@tonic-gate
445