2 * File...........: ibmOSAMib.c
3 * Author(s)......: Thomas Weber <tweber@de.ibm.com>
4 * Copyright IBM Corp. 2002,2007
9 * Basic MIB implementation module for the OSA-E subagent.
10 * The code in this module is typical for a ucd-snmp MIB implementation
11 * information on how this works.
12 * Because the MIB layout is retrieved during startup of the subagent,
13 * the magic indentifier is not used within this implementation.
14 * The var_ function uses the vp->type instead to distinct the OIDs.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option)
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include "ibmOSAMibUtil.h"
32 #include "ibmOSAMib.h"
33 #include "zt_common.h"
35 /* ptr to OSA Express MIB information stored in linked lists */
36 TABLE_OID
* oid_list_head
;
38 /* ptr to interface information on this system */
44 /**********************************************************************
46 * Initialization routine. This function is called when the agent
49 * IN uses global MIB data
52 *********************************************************************/
53 void init_ibmOSAMib(void) {
56 sd
, /* socket descriptor */
57 error_code
, /* holds errno value */
58 osaexp_num
, /* number of OSA Express devices */
59 retc
; /* return code from register_tables */
61 struct ifreq ifr
; /* request structure for ioctl */
62 IPA_CMD_REG
* ipa_reg_mib
; /* structure for IPA REGISTER MIB command header */
63 char* buffer
; /* a data buffer */
64 char time_buf
[TIME_BUF_SIZE
]; /* date/time buffer */
66 /* init head for Toplevel OID linked list */
67 oid_list_head
= init_oid_list();
68 if ( oid_list_head
== NULL
)
70 fprintf( stderr
, "init_ibmOSAMib(): "
71 "malloc() for OID list head failed\n"
72 "Cannot start subagent...exiting...\n");
76 /* GET ucd-snmp ifNumber/ifIndex/ifDescr from IF-MIB for all interfaces */
78 ifNumber
= query_IF_MIB( &if_list
);
81 fprintf( stderr
, "init_ibmOSAMib(): "
82 "could not obtain interface info from IF-MIB\n"
83 "check if: snmpd daemon is started and subagent "
84 "access control is correct\n"
85 "see agent log file for more details\n"
86 "Cannot start subagent...exiting...\n");
89 else if ( ifNumber
== 0 )
92 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
93 "SNMP reports no devices within IF-MIB"
94 " - starting subagent anyway\n", time_buf
);
98 /* query OSA-E device driver for OSA-E devices and mark them in IF-MIB interface list */
99 osaexp_num
= query_OSA_EXP ( &if_list
, ifNumber
);
100 if ( osaexp_num
< 0 )
102 fprintf( stderr
, "init_ibmOSAMib(): "
103 "OSA-E device driver query interface ioctl() failed\n"
104 "check agent log file for more details\n"
105 "Cannot start subagent...exiting...\n");
108 else if ( osaexp_num
== 0 )
110 fprintf( stderr
, "init_ibmOSAMib(): bad or no OSA-E devices reported\n"
111 "check agent log file for more details\n"
112 "Cannot start subagent...exiting...\n");
117 /* allocate area, that should contain retrieved MIB data for a single interface */
118 buffer
= (char*) malloc ( MIB_AREA_LEN
);
119 if ( buffer
== NULL
)
121 fprintf( stderr
, "init_ibmOSAMib(): "
122 "malloc() for REGISTER MIB data buffer "
123 "failed\ninit_ibmOSAMib(): requested %d bytes\n"
124 "Cannot start subagent...exiting...\n",
129 /* open socket for ioctl */
130 sd
= socket( AF_INET
, SOCK_STREAM
, 0 );
134 fprintf( stderr
, "init_ibmOSAMIB(): "
135 "error opening socket() - reason %s\n"
136 "Cannot start subagent...exiting...\n",
137 strerror( error_code
) );
141 /* walk through interface list and query MIB data for all OSA-E devices */
142 /* register MIB data with subagent driving code afterwards */
143 for ( i
=0; i
< ifNumber
; i
++ )
145 if ( if_list
[i
].is_OSAEXP
== TRUE
)
148 memset( buffer
, 0, MIB_AREA_LEN
);
150 /* setup ioctl buffer with request and input parameters */
151 ipa_reg_mib
= (IPA_CMD_REG
*) buffer
; /* map command structure */
152 ipa_reg_mib
->ioctl_cmd
.data_len
= /* length of IPA data area */
153 MIB_AREA_LEN
- offsetof( IOCTL_CMD_HDR
, ipa_cmd_hdr
);
154 ipa_reg_mib
->ioctl_cmd
.req_len
= /* length of IPA subcommand */
155 sizeof( ipa_reg_mib
->ioctl_cmd
);
157 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.request
= IPA_REG_MIB
; /* IPA subcommand code */
158 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ifIndex
= if_list
[i
].ifIndex
; /* assign IF-MIB ifIndex */
159 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ret_code
= 0;
160 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.seq_num
= 0; /* sequence number not used */
163 strcpy( ifr
.ifr_name
, if_list
[i
].if_Name
); /* add interface name */
164 ifr
.ifr_ifru
.ifru_data
= (char*) buffer
; /* add data buffer */
166 if ( ioctl( sd
, SIOC_QETH_ADP_SET_SNMP_CONTROL
, &ifr
) < 0 )
170 /* see if we got a common I/O error */
171 if ( error_code
== -EIO
)
173 get_time( time_buf
);
174 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
175 "ioctl() failed - reason %s for interface %s\n"
176 "init_ibmOSAMib(): start subagent anyway\n",
177 time_buf
, strerror( error_code
), if_list
[i
].if_Name
);
184 /* let's see, if we got a return code from IPAssists */
185 /* or if MIB buffer is exhausted */
186 switch ( ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ret_code
) {
188 fprintf( stderr
, "init_ibmOSAMib(): "
189 "ioctl() failed - IPA command failed "
191 "Can't get MIB information for network interface %s\n"
192 "Cannot start subagent...exiting...\n", if_list
[i
].if_Name
);
196 fprintf( stderr
, "init_ibmOSAMib(): "
197 "ioctl() failed - IPA command not supported "
199 "Can't get MIB information for network interface %s\n"
200 "Cannot start subagent...exiting...\n", if_list
[i
].if_Name
);
204 get_time( time_buf
);
205 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
206 "ioctl() failed - valid IPA command, but no"
207 " SNMP data is available for interface %s\n"
208 "init_ibmOSAMib(): start subagent anyway\n",
209 time_buf
, if_list
[i
].if_Name
);
215 case -ENOMEM
: /* should not happen in the near future ;-) */
216 fprintf( stderr
, "init_ibmOSAMib(): "
217 "ioctl() failed - MIB data size > "
218 "constant MIB_AREA_LEN\n"
220 "Enlarge constant for MIB_AREA_LEN within "
221 "ibmOSAMibDefs.h and recompile the subagent\n"
223 "Can't get MIB information for network interfaces\n"
224 "Cannot start subagent...exiting...\n" );
227 fprintf( stderr
, "init_ibmOSAMib(): "
228 "ioctl() failed - reason %s\n"
230 "Can't get MIB information for network interface %s\n"
231 "Cannot start subagent...exiting...\n",
232 strerror( error_code
), if_list
[i
].if_Name
);
238 else if( ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ret_code
!= 0 )
240 /* now check IPA SNMP subcommand return code */
241 switch ( ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ret_code
) {
243 case IPA_SNMP_INV_TOPOID
:
244 case IPA_SNMP_INV_GROUP
:
245 case IPA_SNMP_INV_SUFFIX
:
246 case IPA_SNMP_INV_INST
:
247 case IPA_SNMP_OID_NREAD
:
248 case IPA_SNMP_OID_NWRIT
:
249 get_time( time_buf
);
250 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
251 "IPA SNMP subcommand failed\n"
253 "IPA SNMP subcommand return code 0x%x\n"
255 "Can't get MIB information for network interface %s\n"
256 "Cannot start subagent...exiting...\n", time_buf
,
257 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ret_code
,
258 if_list
[i
].if_Name
);
261 case IPA_SNMP_NOT_SUPP
:
262 get_time( time_buf
);
263 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
264 "IPA SNMP subcommand failed - subcommand 0x%x "
265 "not supported\ninit_ibmOSAMib(): "
266 "Can't get MIB information for network interface %s\n"
267 "Cannot start subagent...exiting...\n", time_buf
,
268 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.request
,
269 if_list
[i
].if_Name
);
272 case IPA_SNMP_NO_DATA
:
273 get_time( time_buf
);
274 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
275 "IPA SNMP subcommand failed - no data available\n"
277 "Can't get MIB information for network interface %s\n"
278 "Cannot start subagent...exiting...\n", time_buf
,
279 if_list
[i
].if_Name
);
283 get_time( time_buf
);
284 snmp_log( LOG_ERR
, "%s init_ibmOSAMib(): "
285 "IPA SNMP subcommand failed - undefined return code"
286 " 0x%x\ninit_ibmOSAMib(): "
287 "Can't get MIB information for network interface %s\n"
288 "Cannot start subagent...exiting...\n", time_buf
,
289 ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ret_code
,
290 if_list
[i
].if_Name
);
299 /* save microcode level */
300 if_list
[i
].ipa_ver
= ipa_reg_mib
->ioctl_cmd
.ipa_cmd_hdr
.ipa_ver
;
303 /* register initial table information, that we got from IPAssists */
304 retc
= register_tables ( buffer
, oid_list_head
);
307 fprintf( stderr
, "init_ibmOSAMib(): "
308 "register MIB data with subagent driving "
309 "code failed\ninit_ibmOSAMib(): for ifIndex %d ifDescr %s\n"
310 "check agent log file for more details\n"
311 "Cannot start subagent...exiting...\n",
312 if_list
[i
].ifIndex
, if_list
[i
].if_Name
);
319 /* log IPA microcode level per interface */
320 for ( i
=0; i
< ifNumber
; i
++ )
322 if ( if_list
[i
].is_OSAEXP
== TRUE
)
323 snmp_log( LOG_INFO
, "OSA-E microcode level is %x for interface %s\n",
325 if_list
[i
].if_Name
);
332 } /* end init_ibmOSAMib */
335 /**********************************************************************
337 * This function is called every time the agent gets a request for
338 * any MIB data for the IBM OSA express MIB. It's up to this function
339 * to return the appropriate data back to the subagent driving code.
340 * This function supports all standard SNMIv2 data types.
342 * IN variable vp - entry in variableN array
343 * INOUT oid *name - OID from original request/OID being returned
344 * INOUT size_t *length - length of orig. OID/length of ret. OID
345 * IN int exact - exact/inexact request
346 * OUT size_t *var_len - length of answer being returned
347 * OUT WriteMethod **write_method - unused
348 * returns: NULL - vp entry does not match or instance wrong
349 * - something within ioctl handling failed
350 * else data returned as answer
351 *********************************************************************/
352 unsigned char* var_ibmOSAMib( struct variable
*vp
,
357 WriteMethod
**write_method
)
359 /* variables for returning data back to the subagent driving code */
360 static long long_ret
;
361 static unsigned char octetstr_buf
[MAX_GET_DATA
];
362 static oid objid
[MAX_OID_LEN
];
363 static struct counter64 osa_counter64
;
366 unsigned char *ptr_uchar
;
368 int ifIndex
; /* IF-MIB ifIndex of the OSA device that is queried for data */
369 int offset
; /* offset to returned data portion within GET command area */
370 char time_buf
[TIME_BUF_SIZE
]; /* date/time buffer */
372 IPA_CMD_GET
*get_cmd
; /* area for GET command */
373 IPA_GET_DATA
*get_res
; /* pointer to offset where data portion starts */
377 * This function compares the full OID that is passed in to the registered
378 * OIDs from this subagent.
379 * It is the IBM OSA Express specific version of the default
380 * header_simple_table() function, that is normally used in case of a simple
381 * table. Place a mutual exlusion lock around this operation to avoid
382 * interfering threads, when updating the internal MIB table thru thread
386 ifIndex
= header_osa_table( vp
, name
, length
, exact
, var_len
, write_method
,
389 if ( ifIndex
== MATCH_FAILED
)
393 /* issue ioctl to query Get/Getnext request data */
394 offset
= do_GET_ioctl ( ifIndex
, name
, *length
, &get_cmd
);
401 * return the result to subagent driving code
404 /* map data portion returned by IPAssists */
405 /* # ptr GET command area + offset returned data portion */
406 /* # align PTR to 4 byte bdy where data portion starts */
407 tmp_ptr
= (char*) get_cmd
;
409 get_res
= (IPA_GET_DATA
*) (PTR_ALIGN4( tmp_ptr
));
413 case ASN_INTEGER
: case ASN_COUNTER
: case ASN_GAUGE
: case ASN_TIMETICKS
:
414 /* ASN_UNSIGNED is same as ASN_GAUGE (RFC1902) */
416 if ( get_res
->len
== sizeof(int) )
418 ptr_int
= (int*) get_res
->data
;
419 long_ret
= (long) *ptr_int
;
423 ptr_long
= (long*) get_res
->data
;
424 long_ret
= (long) *ptr_long
;
429 return (unsigned char *) &long_ret
;
434 if ( get_res
->len
> 8 )
436 get_time( time_buf
);
437 snmp_log( LOG_ERR
, "%s var_ibmOSAMib(): "
438 "IPA data length for ASN_COUNTER64 > 8 bytes\n"
439 "var_ibmOSAMib(): rejected Get/Getnext request\n", time_buf
);
444 /* IPA returns 8 bytes for COUNTER64 */
445 ptr_int
= (int*) get_res
->data
;
446 osa_counter64
.high
= (int) *ptr_int
;
448 osa_counter64
.low
= (int) *ptr_int
;
450 *var_len
= sizeof( osa_counter64
);
453 return (unsigned char *) &osa_counter64
;
456 case ASN_OPAQUE
: /* old v1 type/included for compability */
457 case ASN_OCTET_STR
: /* used for Binary data */
458 /* case Display String is handled within var_DisplayStr() */
460 if ( get_res
->len
> MAX_GET_DATA
)
462 get_time( time_buf
);
463 snmp_log( LOG_ERR
, "%s var_ibmOSAMib(): "
464 "IPA data length %d for ASN_OCTET_STR > "
465 "MAX_GET_DATA (%d bytes)\n"
466 "var_ibmOSAMib(): rejected Get/Getnext request\n",
467 time_buf
, get_res
->len
, MAX_GET_DATA
);
472 *var_len
= get_res
->len
;
473 ptr_uchar
= (unsigned char*) get_res
->data
;
474 memcpy( octetstr_buf
, ptr_uchar
, *var_len
);
477 return (unsigned char *) octetstr_buf
;
482 /* IPA IpAddress within 4 bytes hex data */
483 ptr_int
= (int*) get_res
->data
;
484 long_ret
= (long) *ptr_int
;
487 return (unsigned char *) &long_ret
;
492 /* IPA returned ObjectId as character string, have to convert... */
493 *var_len
= str_to_oid_conv ( get_res
->data
, objid
);
496 get_time( time_buf
);
497 snmp_log( LOG_ERR
, "%s var_ibmOSAMib(): IPA returned bad ObjectId - "
498 "cannot convert ucd-snmp oid type\n"
499 "var_ibmOSAMib(): rejected Get/Getnext request\n", time_buf
);
504 *var_len
= (*var_len
) * sizeof( oid
);
507 return (unsigned char *) &objid
;
511 get_time( time_buf
);
512 snmp_log( LOG_ERR
, "%s var_ibmOSAMib(): "
513 "got a not known ASN data type %x\n"
515 "rejected Get/Getnext request\n", time_buf
, vp
->type
);
523 } /* end var_ibmOSAMib */
526 /**********************************************************************
528 * This function handles the special case for Display Strings, which are
529 * a textual convention to Octet Strings. The binary data case for
530 * Octet Strings is handled within var_ibmOSAMib().
531 * It's up to this function to return the appropriate data back to the
532 * subagent driving code.
534 * IN variable vp - entry in variableN array
535 * INOUT oid *name - OID from original request/OID being returned
536 * INOUT size_t *length - length of orig. OID/length of ret. OID
537 * IN int exact - exact/inexact request
538 * OUT size_t *var_len - length of answer being returned
539 * OUT WriteMethod **write_method - unused
540 * returns: NULL - vp entry does not match or instance wrong
541 * - something within ioctl handling failed
542 * else data returned as answer
543 *********************************************************************/
544 unsigned char* var_DisplayStr( struct variable
*vp
,
549 WriteMethod
**write_method
)
551 /* variables for returning a display string to the subagent driving code */
552 static char string
[SPRINT_MAX_LEN
];
553 char time_buf
[TIME_BUF_SIZE
]; /* date/time buffer */
555 int ifIndex
; /* IF-MIB ifIndex of the OSA device that is queried for data */
556 int offset
; /* offset to returned data portion within GET command area */
558 IPA_CMD_GET
*get_cmd
; /* area for GET command */
559 IPA_GET_DATA
*get_res
; /* pointer to offset where data portion starts */
563 * This function compares the full OID that is passed in to the registered
564 * OIDs from this subagent.
565 * It is the IBM OSA Express specific version of the default
566 * header_simple_table() function, that is normally used in case of a simple
567 * table. Place a mutual exlusion lock around this operation to avoid
568 * interfering threads, when updating the internal MIB table thru thread
572 ifIndex
= header_osa_table( vp
, name
, length
, exact
, var_len
, write_method
,
575 if ( ifIndex
== MATCH_FAILED
)
579 /* issue ioctl to query Get/Getnext request data */
580 offset
= do_GET_ioctl ( ifIndex
, name
, *length
, &get_cmd
);
587 * return the result to subagent driving code
590 /* map data portion returned by IPAssists */
591 /* # ptr GET command area + offset returned data portion */
592 /* # align PTR to 4 byte bdy where data portion starts */
593 tmp_ptr
= (char*) get_cmd
;
595 get_res
= (IPA_GET_DATA
*) (PTR_ALIGN4( tmp_ptr
));
597 if ( vp
->type
== ASN_OCTET_STR
)
599 if ( get_res
->len
>= SPRINT_MAX_LEN
)
601 get_time( time_buf
);
602 snmp_log( LOG_ERR
, "%s var_DisplayStr(): "
603 "IPA data length %d for Display "
604 "String >= SPRINT_MAX_LEN (%d bytes)\n"
605 "var_ibmOSAMib(): rejected Get/Getnext request\n"
606 ,time_buf
, get_res
->len
, SPRINT_MAX_LEN
);
611 strncpy( string
, get_res
->data
, get_res
->len
);
612 string
[ get_res
->len
] = '\0';
613 *var_len
= strlen( string
);
616 return (unsigned char *) string
;
620 get_time( time_buf
);
621 snmp_log( LOG_ERR
, "%s var_DisplayStr(): "
622 "expected a Display String here, "
623 "but got a different ASN data type: %x\n"
625 "rejected Get/Getnext request\n", time_buf
, vp
->type
);
632 } /* end var_DisplayStr */
635 /**********************************************************************
637 * This function handles the communication with an OSA Express Card
638 * to query the appropriate MIB information from IPAssists.
639 * An ioctl is used in order to qet the appropriate information.
641 * IN int ifIndex - IF-MIB interface index
642 * IN oid *name - OID being returned
643 * IN size_t len - length of ret. OID
644 * INOUT IPA_CMD_GET** cmd - GET command area
645 * returns: cmd_len - return offset to returned data
646 * -1 - ioctl() was not successful
647 *********************************************************************/
648 int do_GET_ioctl ( int ifIndex
, oid
*name
, size_t len
, IPA_CMD_GET
**cmd
)
650 int sd
; /* socket descriptor */
652 char oid_str
[MAX_OID_STR_LEN
]; /* may hold an OID as string */
653 char time_buf
[TIME_BUF_SIZE
]; /* date/time buffer */
654 char device
[IFNAME_MAXLEN
] = "not_found"; /* device name for ioctl */
655 struct ifreq ifr
; /* request structure for ioctl */
658 /* search device name in in global interface list for ifIndex */
659 for ( i
=0; i
< ifNumber
; i
++ )
661 if ( if_list
[i
].ifIndex
== ifIndex
)
663 strcpy( device
, if_list
[i
].if_Name
);
668 if ( strcmp( device
, "not_found" ) == 0 )
670 get_time( time_buf
);
671 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
672 "ifIndex %d is not recorded in "
674 "OSA Subagent MIB information may be incomplete!\n"
675 ,time_buf
, ifIndex
);
680 * query IPAssists for data appropriate to the OID that we just validated
683 /* convert Get/GetNext OID to a string used by IPA */
684 if( oid_to_str_conv ( name
, len
, oid_str
) == FALSE
)
686 get_time( time_buf
);
687 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
688 "cannot convert OID to string object\n"
689 "do_GET_ioctl(): rejected request\n", time_buf
);
693 /* allocate memory for Get/GetNext command area */
694 *cmd
= ( IPA_CMD_GET
* ) malloc( GET_AREA_LEN
);
697 get_time( time_buf
);
699 "%s do_GET_ioctl(): "
700 "malloc() for GET command area failed\n"
701 "do_GET_ioctl(): rejected request for .%s\n",
706 /* set up input parameters in Get/GetNext command area */
707 /* size of IPA data area */
708 (*cmd
)->ioctl_cmd
.data_len
=
709 GET_AREA_LEN
- offsetof( IOCTL_CMD_HDR
, ipa_cmd_hdr
);
711 /* size of IPA GET subcommand padded to 4-byte bdy */
712 (*cmd
)->ioctl_cmd
.req_len
=
713 (sizeof((*cmd
)->ioctl_cmd
) + strlen( oid_str
) + 1 + 3)&(~3);
715 /* set up input parameters in Get/GetNext command area */
716 (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.request
= IPA_GET_OID
; /* IPA subcommand code */
717 (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.ifIndex
= ifIndex
; /* assign IF-MIB ifIndex */
718 (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.ret_code
= 0;
719 (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.seq_num
= 0; /* sequence# is not used */
720 strcpy( (*cmd
)->full_oid
, oid_str
); /* requested OID */
721 /* (fully qualified) */
724 * issue Get/GetNext command against IPAssists
727 /* create socket for ioctl */
728 sd
= socket( AF_INET
, SOCK_STREAM
, 0 );
732 get_time( time_buf
);
733 snmp_log(LOG_ERR
, "%s do_GET_ioctl(): "
734 "error opening socket() - reason %s\n"
735 "do_GET_ioctl(): rejected request for .%s\n",
736 time_buf
, strerror( error_code
), oid_str
);
742 strcpy( ifr
.ifr_name
, device
);
743 ifr
.ifr_ifru
.ifru_data
= (char*) (*cmd
);
744 if ( ioctl( sd
, SIOC_QETH_ADP_SET_SNMP_CONTROL
, &ifr
) < 0 )
747 get_time( time_buf
);
749 /* see if we got a common I/O error */
750 if ( error_code
== -EIO
)
752 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
753 "ioctl() failed - reason %s\n"
754 "do_GET_ioctl(): rejected request for .%s\n",
755 time_buf
, strerror( error_code
), oid_str
);
761 /* let's see, if we got a return code from IPAssists */
762 /* or if MIB buffer is exhausted */
763 switch ( (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.ret_code
) {
766 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
767 "ioctl() failed - IPA command failed\n"
768 "do_GET_ioctl(): rejected request for .%s\n",
773 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
774 "ioctl() failed - IPA command not supported\n"
775 "do_GET_ioctl(): rejected request for .%s\n",
780 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
781 "ioctl() failed - valid IPA command, but no "
782 "SNMP data is available\n"
783 "do_GET_ioctl(): rejected request for .%s\n",
788 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
789 "ioctl() failed - response data > "
790 "constant MAX_GET_DATA %d\n"
791 "do_GET_ioctl(): rejected request for .%s\n",
792 time_buf
, MAX_GET_DATA
, oid_str
);
796 snmp_log(LOG_ERR
, "%s do_GET_ioctl(): "
797 "ioctl() failed - reason %s\n"
798 "do_GET_ioctl(): rejected request for .%s\n",
799 time_buf
, strerror( error_code
), oid_str
);
812 /* now check IPA SNMP subcommand return code */
813 switch ( (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.ret_code
) {
815 case IPA_SNMP_SUCCESS
:
816 /* return offset to data portion */
817 return ( sizeof( IPA_CMD_GET
) + strlen( oid_str
) + 1 );
820 case IPA_SNMP_INV_TOPOID
:
821 case IPA_SNMP_INV_GROUP
:
822 case IPA_SNMP_INV_SUFFIX
:
823 case IPA_SNMP_INV_INST
:
824 case IPA_SNMP_OID_NREAD
:
825 case IPA_SNMP_OID_NWRIT
:
826 get_time( time_buf
);
827 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
828 "IPA SNMP subcommand failed - cannot handle OID\n"
829 "do_GET_ioctl(): IPA SNMP subcommand return code 0x%x\n"
830 "do_GET_ioctl(): rejected request for .%s\n",
831 time_buf
, (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.ret_code
, oid_str
);
834 case IPA_SNMP_NOT_SUPP
:
835 get_time( time_buf
);
836 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
837 "IPA SNMP subcommand failed - subcommand 0x%x not supported\n"
838 "do_GET_ioctl(): rejected request for .%s\n",
839 time_buf
, (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.request
, oid_str
);
842 case IPA_SNMP_NO_DATA
:
843 get_time( time_buf
);
844 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
845 "IPA SNMP subcommand failed - no data available\n"
846 "do_GET_ioctl(): rejected request for .%s\n",
851 get_time( time_buf
);
852 snmp_log( LOG_ERR
, "%s do_GET_ioctl(): "
853 "IPA SNMP subcommand failed - undefined return code 0x%x\n"
854 "do_GET_ioctl(): rejected request for .%s\n",
855 time_buf
, (*cmd
)->ioctl_cmd
.ipa_cmd_hdr
.ret_code
, oid_str
);
864 } /* end do_GET_ioctl */
867 /**********************************************************************
869 * !!! Set processing is not supported in version 1.0.0 !!!
870 * !!! Function is defind as a skeleton for later use !!!
871 * This function handles any SET requests raised against the
873 * The flow of actions is to preserve proper transaction handling
874 * with other transactions in the same set request.
876 * IN int action - current action state
877 * IN u_char *var_val - new variable value
878 * IN u_char var_val_type - data type of above variable
879 * IN size_t var_val_len - length of variable value
880 * IN u_char *statP - value that a GET request would return
882 * IN oid *name - OID to be set
883 * IN size_t name_len - len of OID to be set
884 * returns: SNMP_ERR_WRONGTYPE - wrong data type passed in
885 * SNMP_ERR_GENERR - general error occured
886 * SNMP_ERR_UNDOFAILED - undo operation failed
887 * SNMP_ERR_NOERROR - variable set sucessful
888 *********************************************************************/
889 int write_ibmOSAMib( int action
,
890 u_char
*UNUSED(var_val
),
891 u_char
UNUSED(var_val_type
),
892 size_t UNUSED(var_val_len
),
893 u_char
*UNUSED(statP
),
895 size_t UNUSED(name_len
) )
897 /* static unsigned char string[SPRINT_MAX_LEN]; */
902 /* check to see that everything is possible */
907 /* allocate needed memory here */
912 /* Release any resources that have been allocated */
917 /* Actually make the change requested. Note that anything done
918 here must be reversable in the UNDO case */
923 /* Back out any changes made in the ACTION case */
928 /* Things are working well, so it's now safe to make the change
929 permanently. Make sure that anything done here can't fail! */
932 return SNMP_ERR_NOERROR
;
933 } /* end write_ibmOSAMib */