Wondering if anyone has faced a similar problem and/or 
knows the reason:

I've implemented code to integrate a custom MIB with the 
SNMP agent, and everything in general works fine. The code 
reads/writes objects from/to an external database.
All SNMP commands generally work correctly.

The problem arises when one of two specific objects are 
included and I try to do a snmpwalk on the MIB. snmpwalk 
works correctly the first time. However, attempting to do 
a snmpwalk a second time invariably causes the agent to 
crash.

Would very much appreciate any opinions/suggestions on 
this.
I am appending relevant sections of code/MIB below.

Thanks in advance,
Ayan

1. MIB file header:

           IPCompanion-MIB DEFINITIONS ::= BEGIN

           IMPORTS
                   mgmt, internet
                       FROM RFC1155-SMI
                   OBJECT-TYPE
                           FROM RFC-1212;

           --  This MIB module uses the extended 
OBJECT-TYPE macro as
           --  defined in [14];


           --  MIB-II (same prefix as MIB-I)

           mib-2      OBJECT IDENTIFIER ::= { mgmt 1 }

           -- textual conventions

           DisplayString ::=
               OCTET STRING
           -- This data type is used to model textual 
information taken
           -- from the NVT ASCII character set.  By 
convention, objects
           -- with this syntax are declared as having
           --
           --      SIZE (0..255)

--          PhysAddress ::=
--              OCTET STRING
           -- This data type is used to model media 
addresses.  For many
           -- types of media, this will be in a binary 
representation.
           -- For example, an ethernet address would be 
represented as

           -- a string of 6 octets.


               -- groups in MIB-II

           system       OBJECT IDENTIFIER
             --DEFAULT test-function-async 
    null_test_async
                ::= { mib-2 1 }

           -- the System group

           -- Implementation of the System group is 
mandatory for all
           -- systems.  If an agent is not configured to 
have a value
           -- for any of these variables, a string of 
length 0 is
           -- returned.
           interfaces   OBJECT IDENTIFIER ::= { mib-2 2 }

           at           OBJECT IDENTIFIER ::= { mib-2 3 }

           ip           OBJECT IDENTIFIER ::= { mib-2 4 }

           icmp         OBJECT IDENTIFIER ::= { mib-2 5 }

           tcp          OBJECT IDENTIFIER ::= { mib-2 6 }

           udp          OBJECT IDENTIFIER ::= { mib-2 7 }

           egp          OBJECT IDENTIFIER ::= { mib-2 8 }

           -- historical (some say hysterical)
           -- cmot      OBJECT IDENTIFIER ::= { mib-2 9 }

           transmission OBJECT IDENTIFIER ::= { mib-2 10 }

           snmp         OBJECT IDENTIFIER ::= { mib-2 11 }

           experimental OBJECT IDENTIFIER ::= { internet 3 
}
           private      OBJECT IDENTIFIER ::= { internet 4 
}
           enterprises  OBJECT IDENTIFIER ::= { private 1 
}
           viacast      OBJECT IDENTIFIER
             --DEFAULT test-function-async 
    null_test_async
                  ::= { enterprises 5014 }

           viacastLband OBJECT IDENTIFIER ::= { viacast 1 
}
           viacastTsd   OBJECT IDENTIFIER ::= { viacast 2 
}
           viacastStats OBJECT IDENTIFIER ::= { viacast 3 
}
           viacastLan   OBJECT IDENTIFIER ::= { viacast 4 
}
           viacastMisc  OBJECT IDENTIFIER ::= { viacast 5 
}
           viacastUnit  OBJECT IDENTIFIER ::= { viacast 6 
}
           viacastLicn  OBJECT IDENTIFIER ::= { viacast 7 
}
           -- the viacast group

2. Offending MIB object:

          pmibLbandDVBSPilot OBJECT-TYPE
               SYNTAX  DisplayString
               ACCESS  read-write
               STATUS  mandatory
               DESCRIPTION "Enable DVBS Pilot"
               ::= { viacastLband 7 }

3. Handler code for the object:

void
init_viacastLband(void)
{
/***other init code***/

netsnmp_register_scalar(netsnmp_create_handler_registration
                             ("pmibLbandDVBSPilot",
                              handle_pmibLbandDVBSPilot,
                              pmibLbandDVBSPilot_oid,
OID_LENGTH(pmibLbandDVBSPilot_oid),
                              HANDLER_CAN_RWRITE));
}


int
handle_pmibLbandDVBSPilot(netsnmp_mib_handler *handler,
                      netsnmp_handler_registration 
*reginfo,
                      netsnmp_agent_request_info *reqinfo,
                      netsnmp_request_info *requests)
{
     int             ret;
     static char     szbuf_tmp_decode[128];
     int             nbytes_decoded;
     static char     szbuf_tmp[128];
     char            mybuf[SPRINT_MAX_LEN];

     switch (reqinfo->mode) {

     case MODE_GET:
       dboper_decode( szbuf_tmp_decode, sizeof( 
szbuf_tmp_decode ),
                      &nbytes_decoded,
                      DBPARAM_LBAND_DVBS2_PILOT,
                      &gst_db_engine, 0 );
       snmp_set_var_typed_value(requests->requestvb, 
ASN_OCTET_STR,
                                (u_char 
*)szbuf_tmp_decode,
                                nbytes_decoded);
       break;

     case MODE_SET_RESERVE1:
         ret = netsnmp_check_vb_type(requests->requestvb, 
ASN_OCTET_STR);
         if (ret != SNMP_ERR_NOERROR)
           netsnmp_set_request_error(reqinfo, requests, 
ret);
         break;

     case MODE_SET_RESERVE2:
         break;

     case MODE_SET_FREE:
         break;

     case MODE_SET_ACTION:
       strncpy(mybuf, requests->requestvb->val.string, 
requests->requestvb->val_len);
       mybuf[SNMP_MIN(requests->requestvb->val_len, 
SPRINT_MAX_LEN-1)] = '\0';

       snmp_log(LOG_INFO, "pmibLbandDVBSPilot: 
string_value: %s\n", mybuf);

       ret = dboper_proc_usr_input( szbuf_tmp, 
sizeof(szbuf_tmp),
                                    DBPARAM_LBAND_DVBS2_PILOT,
                                    &gst_db_engine, 0,
                                    mybuf );
       save_params(&gst_db_engine);
       if ( ret < 0 )
         netsnmp_set_request_error(reqinfo, requests, 
SNMP_ERR_WRONGVALUE);
       break;

     case MODE_SET_COMMIT:
       break;

     case MODE_SET_UNDO:
       break;

     default:
       snmp_log(LOG_ERR, "unknown mode (%d) in 
handle_pmibLbandDVBSPilot\n", reqinfo->mode);
       return SNMP_ERR_GENERR;
     }
     return SNMP_ERR_NOERROR;
}



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to