2
* File...........: ibmOSAMib.c
3
* Author(s)......: Thomas Weber <tweber@de.ibm.com>
4
* (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2002
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"
34
/* ptr to OSA Express MIB information stored in linked lists */
35
TABLE_OID* oid_list_head;
37
/* ptr to interface information on this system */
43
/**********************************************************************
45
* Initialization routine. This function is called when the agent
48
* IN uses global MIB data
51
*********************************************************************/
52
void init_ibmOSAMib(void) {
55
sd, /* socket descriptor */
56
error_code, /* holds errno value */
57
osaexp_num, /* number of OSA Express devices */
58
retc; /* return code from register_tables */
60
struct ifreq ifr; /* request structure for ioctl */
61
IPA_CMD_REG* ipa_reg_mib; /* structure for IPA REGISTER MIB command header */
62
char* buffer; /* a data buffer */
63
char time_buf[TIME_BUF_SIZE]; /* date/time buffer */
65
/* init head for Toplevel OID linked list */
66
oid_list_head = init_oid_list();
67
if ( oid_list_head == NULL )
69
fprintf( stderr, "init_ibmOSAMib(): "
70
"malloc() for OID list head failed\n"
71
"Cannot start subagent...exiting...\n");
75
/* GET ucd-snmp ifNumber/ifIndex/ifDescr from IF-MIB for all interfaces */
77
ifNumber = query_IF_MIB( &if_list );
80
fprintf( stderr, "init_ibmOSAMib(): "
81
"could not obtain interface info from IF-MIB\n"
82
"check if: snmpd daemon is started and subagent "
83
"access control is correct\n"
84
"see agent log file for more details\n"
85
"Cannot start subagent...exiting...\n");
88
else if ( ifNumber == 0 )
91
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
92
"SNMP reports no devices within IF-MIB"
93
" - starting subagent anyway\n", time_buf );
97
/* query OSA-E device driver for OSA-E devices and mark them in IF-MIB interface list */
98
osaexp_num = query_OSA_EXP ( &if_list, ifNumber );
101
fprintf( stderr, "init_ibmOSAMib(): "
102
"OSA-E device driver query interface ioctl() failed\n"
103
"check agent log file for more details\n"
104
"Cannot start subagent...exiting...\n");
107
else if ( osaexp_num == 0 )
109
fprintf( stderr, "init_ibmOSAMib(): bad or no OSA-E devices reported\n"
110
"check agent log file for more details\n"
111
"Cannot start subagent...exiting...\n");
116
/* allocate area, that should contain retrieved MIB data for a single interface */
117
buffer = (char*) malloc ( MIB_AREA_LEN );
118
if ( buffer == NULL )
120
fprintf( stderr, "init_ibmOSAMib(): "
121
"malloc() for REGISTER MIB data buffer "
122
"failed\ninit_ibmOSAMib(): requested %d bytes\n"
123
"Cannot start subagent...exiting...\n",
128
/* open socket for ioctl */
129
sd = socket( AF_INET, SOCK_STREAM, 0 );
133
fprintf( stderr, "init_ibmOSAMIB(): "
134
"error opening socket() - reason %s\n"
135
"Cannot start subagent...exiting...\n",
136
strerror( error_code ) );
140
/* walk through interface list and query MIB data for all OSA-E devices */
141
/* register MIB data with subagent driving code afterwards */
142
for ( i=0; i < ifNumber; i++ )
144
if ( if_list[i].is_OSAEXP == TRUE )
147
memset( buffer, 0, MIB_AREA_LEN );
149
/* setup ioctl buffer with request and input parameters */
150
ipa_reg_mib = (IPA_CMD_REG*) buffer; /* map command structure */
151
ipa_reg_mib->ioctl_cmd.data_len = /* length of IPA data area */
152
MIB_AREA_LEN - offsetof( IOCTL_CMD_HDR, ipa_cmd_hdr );
153
ipa_reg_mib->ioctl_cmd.req_len = /* length of IPA subcommand */
154
sizeof( ipa_reg_mib->ioctl_cmd );
156
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.request = IPA_REG_MIB; /* IPA subcommand code */
157
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ifIndex = if_list[i].ifIndex; /* assign IF-MIB ifIndex */
158
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ret_code = 0;
159
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.seq_num = 0; /* sequence number not used */
162
strcpy( ifr.ifr_name, if_list[i].if_Name ); /* add interface name */
163
ifr.ifr_ifru.ifru_data = (char*) buffer; /* add data buffer */
165
if ( ioctl( sd, SIOC_QETH_ADP_SET_SNMP_CONTROL, &ifr ) < 0 )
169
/* see if we got a common I/O error */
170
if ( error_code == -EIO )
172
get_time( time_buf );
173
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
174
"ioctl() failed - reason %s for interface %s\n"
175
"init_ibmOSAMib(): start subagent anyway\n",
176
time_buf, strerror( error_code ), if_list[i].if_Name );
183
/* let's see, if we got a return code from IPAssists */
184
/* or if MIB buffer is exhausted */
185
switch ( ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ret_code ) {
187
fprintf( stderr, "init_ibmOSAMib(): "
188
"ioctl() failed - IPA command failed "
190
"Can't get MIB information for network interface %s\n"
191
"Cannot start subagent...exiting...\n", if_list[i].if_Name );
195
fprintf( stderr, "init_ibmOSAMib(): "
196
"ioctl() failed - IPA command not supported "
198
"Can't get MIB information for network interface %s\n"
199
"Cannot start subagent...exiting...\n", if_list[i].if_Name );
203
get_time( time_buf );
204
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
205
"ioctl() failed - valid IPA command, but no"
206
" SNMP data is available for interface %s\n"
207
"init_ibmOSAMib(): start subagent anyway\n",
208
time_buf, if_list[i].if_Name );
214
case -ENOMEM: /* should not happen in the near future ;-) */
215
fprintf( stderr, "init_ibmOSAMib(): "
216
"ioctl() failed - MIB data size > "
217
"constant MIB_AREA_LEN\n"
219
"Enlarge constant for MIB_AREA_LEN within "
220
"ibmOSAMibDefs.h and recompile the subagent\n"
222
"Can't get MIB information for network interfaces\n"
223
"Cannot start subagent...exiting...\n" );
226
fprintf( stderr, "init_ibmOSAMib(): "
227
"ioctl() failed - reason %s\n"
229
"Can't get MIB information for network interface %s\n"
230
"Cannot start subagent...exiting...\n",
231
strerror( error_code ), if_list[i].if_Name );
237
else if( ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ret_code != 0 )
239
/* now check IPA SNMP subcommand return code */
240
switch ( ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ret_code ) {
242
case IPA_SNMP_INV_TOPOID:
243
case IPA_SNMP_INV_GROUP:
244
case IPA_SNMP_INV_SUFFIX:
245
case IPA_SNMP_INV_INST:
246
case IPA_SNMP_OID_NREAD:
247
case IPA_SNMP_OID_NWRIT:
248
get_time( time_buf );
249
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
250
"IPA SNMP subcommand failed\n"
252
"IPA SNMP subcommand return code 0x%x\n"
254
"Can't get MIB information for network interface %s\n"
255
"Cannot start subagent...exiting...\n", time_buf,
256
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ret_code,
257
if_list[i].if_Name );
260
case IPA_SNMP_NOT_SUPP:
261
get_time( time_buf );
262
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
263
"IPA SNMP subcommand failed - subcommand 0x%x "
264
"not supported\ninit_ibmOSAMib(): "
265
"Can't get MIB information for network interface %s\n"
266
"Cannot start subagent...exiting...\n", time_buf,
267
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.request,
268
if_list[i].if_Name );
271
case IPA_SNMP_NO_DATA:
272
get_time( time_buf );
273
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
274
"IPA SNMP subcommand failed - no data available\n"
276
"Can't get MIB information for network interface %s\n"
277
"Cannot start subagent...exiting...\n", time_buf,
278
if_list[i].if_Name );
282
get_time( time_buf );
283
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): "
284
"IPA SNMP subcommand failed - undefined return code"
285
" 0x%x\ninit_ibmOSAMib(): "
286
"Can't get MIB information for network interface %s\n"
287
"Cannot start subagent...exiting...\n", time_buf,
288
ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ret_code,
289
if_list[i].if_Name );
298
/* save microcode level */
299
if_list[i].ipa_ver = ipa_reg_mib->ioctl_cmd.ipa_cmd_hdr.ipa_ver;
302
/* register initial table information, that we got from IPAssists */
303
retc = register_tables ( buffer, oid_list_head );
306
fprintf( stderr, "init_ibmOSAMib(): "
307
"register MIB data with subagent driving "
308
"code failed\ninit_ibmOSAMib(): for ifIndex %d ifDescr %s\n"
309
"check agent log file for more details\n"
310
"Cannot start subagent...exiting...\n",
311
if_list[i].ifIndex, if_list[i].if_Name );
318
/* log IPA microcode level per interface */
319
for ( i=0; i < ifNumber; i++ )
321
if ( if_list[i].is_OSAEXP == TRUE )
322
snmp_log( LOG_INFO, "OSA-E microcode level is %x for interface %s\n",
324
if_list[i].if_Name );
331
} /* end init_ibmOSAMib */
334
/**********************************************************************
336
* This function is called every time the agent gets a request for
337
* any MIB data for the IBM OSA express MIB. It's up to this function
338
* to return the appropriate data back to the subagent driving code.
339
* This function supports all standard SNMIv2 data types.
341
* IN variable vp - entry in variableN array
342
* INOUT oid *name - OID from original request/OID being returned
343
* INOUT size_t *length - length of orig. OID/length of ret. OID
344
* IN int exact - exact/inexact request
345
* OUT size_t *var_len - length of answer being returned
346
* OUT WriteMethod **write_method - unused
347
* returns: NULL - vp entry does not match or instance wrong
348
* - something within ioctl handling failed
349
* else data returned as answer
350
*********************************************************************/
351
unsigned char* var_ibmOSAMib( struct variable *vp,
356
WriteMethod **write_method)
358
/* variables for returning data back to the subagent driving code */
359
static long long_ret;
360
static unsigned char octetstr_buf[MAX_GET_DATA];
361
static oid objid[MAX_OID_LEN];
362
static struct counter64 osa_counter64;
365
unsigned char *ptr_uchar;
367
int ifIndex; /* IF-MIB ifIndex of the OSA device that is queried for data */
368
int offset; /* offset to returned data portion within GET command area */
369
char time_buf[TIME_BUF_SIZE]; /* date/time buffer */
371
IPA_CMD_GET *get_cmd; /* area for GET command */
372
IPA_GET_DATA *get_res; /* pointer to offset where data portion starts */
376
* This function compares the full OID that is passed in to the registered
377
* OIDs from this subagent.
378
* It is the IBM OSA Express specific version of the default
379
* header_simple_table() function, that is normally used in case of a simple
380
* table. Place a mutual exlusion lock around this operation to avoid
381
* interfering threads, when updating the internal MIB table thru thread
385
ifIndex = header_osa_table( vp, name, length, exact, var_len, write_method,
388
if ( ifIndex == MATCH_FAILED )
392
/* issue ioctl to query Get/Getnext request data */
393
offset = do_GET_ioctl ( ifIndex, name, *length, &get_cmd );
400
* return the result to subagent driving code
403
/* map data portion returned by IPAssists */
404
/* # ptr GET command area + offset returned data portion */
405
/* # align PTR to 4 byte bdy where data portion starts */
406
tmp_ptr = (char*) get_cmd;
408
get_res = (IPA_GET_DATA*) (PTR_ALIGN4( tmp_ptr ));
412
case ASN_INTEGER: case ASN_COUNTER: case ASN_GAUGE: case ASN_TIMETICKS:
413
/* ASN_UNSIGNED is same as ASN_GAUGE (RFC1902) */
415
if ( get_res->len == sizeof(int) )
417
ptr_int = (int*) get_res->data;
418
long_ret = (long) *ptr_int;
422
ptr_long = (long*) get_res->data;
423
long_ret = (long) *ptr_long;
428
return (unsigned char *) &long_ret;
433
if ( get_res->len > 8 )
435
get_time( time_buf );
436
snmp_log( LOG_ERR, "%s var_ibmOSAMib(): "
437
"IPA data length for ASN_COUNTER64 > 8 bytes\n"
438
"var_ibmOSAMib(): rejected Get/Getnext request\n", time_buf );
443
/* IPA returns 8 bytes for COUNTER64 */
444
ptr_int = (int*) get_res->data;
445
osa_counter64.high = (int) *ptr_int;
447
osa_counter64.low = (int) *ptr_int;
449
*var_len = sizeof( osa_counter64 );
452
return (unsigned char *) &osa_counter64;
455
case ASN_OPAQUE: /* old v1 type/included for compability */
456
case ASN_OCTET_STR: /* used for Binary data */
457
/* case Display String is handled within var_DisplayStr() */
459
if ( get_res->len > MAX_GET_DATA )
461
get_time( time_buf );
462
snmp_log( LOG_ERR, "%s var_ibmOSAMib(): "
463
"IPA data length %d for ASN_OCTET_STR > "
464
"MAX_GET_DATA (%d bytes)\n"
465
"var_ibmOSAMib(): rejected Get/Getnext request\n",
466
time_buf, get_res->len, MAX_GET_DATA );
471
*var_len = get_res->len;
472
ptr_uchar = (unsigned char*) get_res->data;
473
memcpy( octetstr_buf, ptr_uchar, *var_len );
476
return (unsigned char *) octetstr_buf;
481
/* IPA IpAddress within 4 bytes hex data */
482
ptr_int = (int*) get_res->data;
483
long_ret = (long) *ptr_int;
486
return (unsigned char *) &long_ret;
491
/* IPA returned ObjectId as character string, have to convert... */
492
*var_len = str_to_oid_conv ( get_res->data, objid );
495
get_time( time_buf );
496
snmp_log( LOG_ERR, "%s var_ibmOSAMib(): IPA returned bad ObjectId - "
497
"cannot convert ucd-snmp oid type\n"
498
"var_ibmOSAMib(): rejected Get/Getnext request\n", time_buf );
503
*var_len = (*var_len) * sizeof( oid );
506
return (unsigned char *) &objid;
510
get_time( time_buf );
511
snmp_log( LOG_ERR, "%s var_ibmOSAMib(): "
512
"got a not known ASN data type %x\n"
514
"rejected Get/Getnext request\n", time_buf, vp->type );
522
} /* end var_ibmOSAMib */
525
/**********************************************************************
527
* This function handles the special case for Display Strings, which are
528
* a textual convention to Octet Strings. The binary data case for
529
* Octet Strings is handled within var_ibmOSAMib().
530
* It's up to this function to return the appropriate data back to the
531
* subagent driving code.
533
* IN variable vp - entry in variableN array
534
* INOUT oid *name - OID from original request/OID being returned
535
* INOUT size_t *length - length of orig. OID/length of ret. OID
536
* IN int exact - exact/inexact request
537
* OUT size_t *var_len - length of answer being returned
538
* OUT WriteMethod **write_method - unused
539
* returns: NULL - vp entry does not match or instance wrong
540
* - something within ioctl handling failed
541
* else data returned as answer
542
*********************************************************************/
543
unsigned char* var_DisplayStr( struct variable *vp,
548
WriteMethod **write_method)
550
/* variables for returning a display string to the subagent driving code */
551
static unsigned char string[SPRINT_MAX_LEN];
552
char time_buf[TIME_BUF_SIZE]; /* date/time buffer */
554
int ifIndex; /* IF-MIB ifIndex of the OSA device that is queried for data */
555
int offset; /* offset to returned data portion within GET command area */
557
IPA_CMD_GET *get_cmd; /* area for GET command */
558
IPA_GET_DATA *get_res; /* pointer to offset where data portion starts */
562
* This function compares the full OID that is passed in to the registered
563
* OIDs from this subagent.
564
* It is the IBM OSA Express specific version of the default
565
* header_simple_table() function, that is normally used in case of a simple
566
* table. Place a mutual exlusion lock around this operation to avoid
567
* interfering threads, when updating the internal MIB table thru thread
571
ifIndex = header_osa_table( vp, name, length, exact, var_len, write_method,
574
if ( ifIndex == MATCH_FAILED )
578
/* issue ioctl to query Get/Getnext request data */
579
offset = do_GET_ioctl ( ifIndex, name, *length, &get_cmd );
586
* return the result to subagent driving code
589
/* map data portion returned by IPAssists */
590
/* # ptr GET command area + offset returned data portion */
591
/* # align PTR to 4 byte bdy where data portion starts */
592
tmp_ptr = (char*) get_cmd;
594
get_res = (IPA_GET_DATA*) (PTR_ALIGN4( tmp_ptr ));
596
if ( vp->type == ASN_OCTET_STR)
598
if ( get_res->len > SPRINT_MAX_LEN )
600
get_time( time_buf );
601
snmp_log( LOG_ERR, "%s var_DisplayStr(): "
602
"IPA data length %d for Display "
603
"String > SPRINT_MAX_LEN (%d bytes)\n"
604
"var_ibmOSAMib(): rejected Get/Getnext request\n"
605
,time_buf, get_res->len, SPRINT_MAX_LEN );
610
strncpy( string, get_res->data, get_res->len );
611
string[ get_res->len ] = '\0';
612
*var_len = strlen( string );
615
return (unsigned char *) string;
619
get_time( time_buf );
620
snmp_log( LOG_ERR, "%s var_DisplayStr(): "
621
"expected a Display String here, "
622
"but got a different ASN data type: %x\n"
624
"rejected Get/Getnext request\n", time_buf, vp->type );
631
} /* end var_DisplayStr */
634
/**********************************************************************
636
* This function handles the communication with an OSA Express Card
637
* to query the appropriate MIB information from IPAssists.
638
* An ioctl is used in order to qet the appropriate information.
640
* IN int ifIndex - IF-MIB interface index
641
* IN oid *name - OID being returned
642
* IN size_t len - length of ret. OID
643
* INOUT IPA_CMD_GET** cmd - GET command area
644
* returns: cmd_len - return offset to returned data
645
* -1 - ioctl() was not successful
646
*********************************************************************/
647
int do_GET_ioctl ( int ifIndex, oid *name, size_t len, IPA_CMD_GET **cmd )
649
int sd; /* socket descriptor */
651
char oid_str[MAX_OID_STR_LEN]; /* may hold an OID as string */
652
char time_buf[TIME_BUF_SIZE]; /* date/time buffer */
653
char device[IFNAME_MAXLEN] = "not_found"; /* device name for ioctl */
654
struct ifreq ifr; /* request structure for ioctl */
657
/* search device name in in global interface list for ifIndex */
658
for ( i=0; i < ifNumber; i++ )
660
if ( if_list[i].ifIndex == ifIndex )
662
strcpy( device, if_list[i].if_Name );
667
if ( strcmp( device, "not_found" ) == 0 )
669
get_time( time_buf );
670
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
671
"ifIndex %d is not recorded in "
673
"OSA Subagent MIB information may be incomplete!\n"
674
,time_buf, ifIndex );
679
* query IPAssists for data appropriate to the OID that we just validated
682
/* convert Get/GetNext OID to a string used by IPA */
683
if( oid_to_str_conv ( name, len, oid_str ) == FALSE )
685
get_time( time_buf );
686
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
687
"cannot convert OID to string object\n"
688
"do_GET_ioctl(): rejected request\n", time_buf );
692
/* allocate memory for Get/GetNext command area */
693
*cmd = ( IPA_CMD_GET* ) malloc( GET_AREA_LEN );
696
get_time( time_buf );
698
"%s do_GET_ioctl(): "
699
"malloc() for GET command area failed\n"
700
"do_GET_ioctl(): rejected request for .%s\n",
705
/* set up input parameters in Get/GetNext command area */
706
/* size of IPA data area */
707
(*cmd)->ioctl_cmd.data_len =
708
GET_AREA_LEN - offsetof( IOCTL_CMD_HDR, ipa_cmd_hdr );
710
/* size of IPA GET subcommand padded to 4-byte bdy */
711
(*cmd)->ioctl_cmd.req_len =
712
(sizeof((*cmd)->ioctl_cmd) + strlen( oid_str ) + 1 + 3)&(~3);
714
/* set up input parameters in Get/GetNext command area */
715
(*cmd)->ioctl_cmd.ipa_cmd_hdr.request = IPA_GET_OID; /* IPA subcommand code */
716
(*cmd)->ioctl_cmd.ipa_cmd_hdr.ifIndex = ifIndex; /* assign IF-MIB ifIndex */
717
(*cmd)->ioctl_cmd.ipa_cmd_hdr.ret_code = 0;
718
(*cmd)->ioctl_cmd.ipa_cmd_hdr.seq_num = 0; /* sequence# is not used */
719
strcpy( (*cmd)->full_oid, oid_str ); /* requested OID */
720
/* (fully qualified) */
723
* issue Get/GetNext command against IPAssists
726
/* create socket for ioctl */
727
sd = socket( AF_INET, SOCK_STREAM, 0 );
731
get_time( time_buf );
732
snmp_log(LOG_ERR, "%s do_GET_ioctl(): "
733
"error opening socket() - reason %s\n"
734
"do_GET_ioctl(): rejected request for .%s\n",
735
time_buf, strerror( error_code ), oid_str );
741
strcpy( ifr.ifr_name, device );
742
ifr.ifr_ifru.ifru_data = (char*) (*cmd);
743
if ( ioctl( sd, SIOC_QETH_ADP_SET_SNMP_CONTROL, &ifr ) < 0 )
746
get_time( time_buf );
748
/* see if we got a common I/O error */
749
if ( error_code == -EIO )
751
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
752
"ioctl() failed - reason %s\n"
753
"do_GET_ioctl(): rejected request for .%s\n",
754
time_buf, strerror( error_code ), oid_str );
760
/* let's see, if we got a return code from IPAssists */
761
/* or if MIB buffer is exhausted */
762
switch ( (*cmd)->ioctl_cmd.ipa_cmd_hdr.ret_code ) {
765
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
766
"ioctl() failed - IPA command failed\n"
767
"do_GET_ioctl(): rejected request for .%s\n",
772
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
773
"ioctl() failed - IPA command not supported\n"
774
"do_GET_ioctl(): rejected request for .%s\n",
779
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
780
"ioctl() failed - valid IPA command, but no "
781
"SNMP data is available\n"
782
"do_GET_ioctl(): rejected request for .%s\n",
787
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
788
"ioctl() failed - response data > "
789
"constant MAX_GET_DATA %d\n"
790
"do_GET_ioctl(): rejected request for .%s\n",
791
time_buf, MAX_GET_DATA, oid_str );
795
snmp_log(LOG_ERR, "%s do_GET_ioctl(): "
796
"ioctl() failed - reason %s\n"
797
"do_GET_ioctl(): rejected request for .%s\n",
798
time_buf, strerror( error_code ), oid_str );
811
/* now check IPA SNMP subcommand return code */
812
switch ( (*cmd)->ioctl_cmd.ipa_cmd_hdr.ret_code ) {
814
case IPA_SNMP_SUCCESS:
815
/* return offset to data portion */
816
return ( sizeof( IPA_CMD_GET ) + strlen( oid_str ) + 1 );
819
case IPA_SNMP_INV_TOPOID:
820
case IPA_SNMP_INV_GROUP:
821
case IPA_SNMP_INV_SUFFIX:
822
case IPA_SNMP_INV_INST:
823
case IPA_SNMP_OID_NREAD:
824
case IPA_SNMP_OID_NWRIT:
825
get_time( time_buf );
826
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
827
"IPA SNMP subcommand failed - cannot handle OID\n"
828
"do_GET_ioctl(): IPA SNMP subcommand return code 0x%x\n"
829
"do_GET_ioctl(): rejected request for .%s\n",
830
time_buf, (*cmd)->ioctl_cmd.ipa_cmd_hdr.ret_code, oid_str );
833
case IPA_SNMP_NOT_SUPP:
834
get_time( time_buf );
835
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
836
"IPA SNMP subcommand failed - subcommand 0x%x not supported\n"
837
"do_GET_ioctl(): rejected request for .%s\n",
838
time_buf, (*cmd)->ioctl_cmd.ipa_cmd_hdr.request, oid_str );
841
case IPA_SNMP_NO_DATA:
842
get_time( time_buf );
843
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
844
"IPA SNMP subcommand failed - no data available\n"
845
"do_GET_ioctl(): rejected request for .%s\n",
850
get_time( time_buf );
851
snmp_log( LOG_ERR, "%s do_GET_ioctl(): "
852
"IPA SNMP subcommand failed - undefined return code 0x%x\n"
853
"do_GET_ioctl(): rejected request for .%s\n",
854
time_buf, (*cmd)->ioctl_cmd.ipa_cmd_hdr.ret_code, oid_str );
863
} /* end do_GET_ioctl */
866
/**********************************************************************
868
* !!! Set processing is not supported in version 1.0.0 !!!
869
* !!! Function is defind as a skeleton for later use !!!
870
* This function handles any SET requests raised against the
872
* The flow of actions is to preserve proper transaction handling
873
* with other transactions in the same set request.
875
* IN int action - current action state
876
* IN u_char *var_val - new variable value
877
* IN u_char var_val_type - data type of above variable
878
* IN size_t var_val_len - length of variable value
879
* IN u_char *statP - value that a GET request would return
881
* IN oid *name - OID to be set
882
* IN size_t name_len - len of OID to be set
883
* returns: SNMP_ERR_WRONGTYPE - wrong data type passed in
884
* SNMP_ERR_GENERR - general error occured
885
* SNMP_ERR_UNDOFAILED - undo operation failed
886
* SNMP_ERR_NOERROR - variable set sucessful
887
*********************************************************************/
888
int write_ibmOSAMib( int action,
896
/* static unsigned char string[SPRINT_MAX_LEN]; */
901
/* check to see that everything is possible */
906
/* allocate needed memory here */
911
/* Release any resources that have been allocated */
916
/* Actually make the change requested. Note that anything done
917
here must be reversable in the UNDO case */
922
/* Back out any changes made in the ACTION case */
927
/* Things are working well, so it's now safe to make the change
928
permanently. Make sure that anything done here can't fail! */
931
return SNMP_ERR_NOERROR;
932
} /* end write_ibmOSAMib */