[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

8720.0. "esnmp programming troubles..." by GRIFUN::BENVI () Wed Feb 05 1997 11:04

        Hi all,
                I've been contacted by a customer who's experiencing some problems
        with esnmp programming. Customer is using Digital Unix V4.0 and the
        esnmp supplied with the o.s.
        Here some examples of the problems he has.

        First problem:
                
        the fucntion o_integer returns an error if applied to data of type 

                        ESNMP_TYPE_UInteger32
                        ESNMP_TYPE_Counter64
                        
        Here is an example:

                        object->type = ESNMP_TYPE_UInteger32;
                        memcpy(&valint,ptr,sizeof(int));
                        ret=o_integer(vb, object, valint);
                        

                        object->type = ESNMP_TYPE_Counter64;
                        memcpy(&vallong,ptr,sizeof(long));
                        ret=o_integer(vb, object, vallong);

        -------------------------------------------------------------------------------

        Second problem:

        It seems that the function instance2oid fails when applied to an oid that has
        a table with more than 60 variable-dimension key fields.
        If in:

            if(instance2oid(oid,object,inst,level)==NULL){
                       printf("ERROR: The instance2oid has returned NULL \n");
                       free(inst);
            }

        the oid has a key of a table with more than 60 elements
        (1.2.3.4.5....59.60.61.62), the function instance2oid fails.

        -------------------------------------------------------------------------------

        Third problem:

        Customer  "tailored" the libesnmp supplied as example (that produced huge files
        and very big amount of code) in order to have a smaller and more manageable
        code.
        They developed dem_agent_esnmp_get and dem_agent_esnmp_set routines that can be
        applied to simple variables and not to an array containig all mib variables 
        (as happens in libesnmp)
        He defined a variable I_agent of type ESNMP_TYPE_Integer32 and all his stuff
        works. Is this correct or it works just by chance? Any possible problems with
        it?
                SUBTREE ansaldo_subtree = { "demagent","1.3.6.1.4.1.1262.1.1",
                                                { 9, &elems[0] }, objects, I_agent
                        };

                static unsigned int elems[] = {
                                1, 3, 6, 1, 4, 1, 1262, 1, 1,    /* agent */
                                1, 3, 6, 1, 4, 1, 1262, 1, 1,    /* agent */
                        };

                static OBJECT objects[] = {
                           {I_agent,{9, &elems[  9]}, ESNMP_TYPE_Integer32, 
                                dem_agent_esnmp_get, dem_agent_esnmp_set},
                        };

        -------------------------------------------------------------------------------
        And now a request....
        is it possible to find a detailed description od diagnostic variables defined
        in our Host Resource MIB? Where?



        Thank you very much in advance
        Angelo

T.RTitleUserPersonal
Name
DateLines
8720.1SMURF::DANIELEWed Feb 05 1997 18:38131
Hi,

My comments start w/ md>>.  Feel free to send me mail (daniele@zk3.dec.com)
if that's easier for you.

Regards,
Mike

                      <<< Note 8720.0 by GRIFUN::BENVI >>>
                       -< esnmp programming troubles... >-


        Hi all,
                I've been contacted by a customer who's experiencing some problems
        with esnmp programming. Customer is using Digital Unix V4.0 and the
        esnmp supplied with the o.s.
        Here some examples of the problems he has.

        First problem:
                
        the fucntion o_integer returns an error if applied to data of type 

                        ESNMP_TYPE_UInteger32
                        ESNMP_TYPE_Counter64
                        
        Here is an example:

                        object->type = ESNMP_TYPE_UInteger32;
                        memcpy(&valint,ptr,sizeof(int));
                        ret=o_integer(vb, object, valint);
                        

                        object->type = ESNMP_TYPE_Counter64;
                        memcpy(&vallong,ptr,sizeof(long));
                        ret=o_integer(vb, object, vallong);


md>> I suspect the issue isn't really with o_integer.  These 2 data types
md>> are new for SNMP version 2.  Although constants are defined in esmnp.h
md>> for them, the extensible agent does NOT support SNMPv2 in any shipping
md>> release (it's part of the next functional release, called Steel).

md>> so i think it's more likely the customer just can't get the agent to
md>> return values for these mib objects (since that would be illegal
md>> in SNMPv1.

md>> But I'll try and pursue this further if you can tell me exactly what
md>> OBJECT is pointed to, what the value is being loaded, etc.

md>> In fact, the dispatching code in esnmp_poll() ignores OBJECTs of v2-only
md>> syntax.  So I'm not sure how you even get to the point of loading a value.

        -------------------------------------------------------------------------------

        Second problem:

        It seems that the function instance2oid fails when applied to an oid that has
        a table with more than 60 variable-dimension key fields.
        If in:

            if(instance2oid(oid,object,inst,level)==NULL){
                       printf("ERROR: The instance2oid has returned NULL \n");
                       free(inst);
            }

        the oid has a key of a table with more than 60 elements
        (1.2.3.4.5....59.60.61.62), the function instance2oid fails.

md>> The function fails if the resulting oid would have > 128 elements (illegal)
md>> or if the `oid' or 'object' arguments are null, or if memory can't be 
md>> allocated.


        -------------------------------------------------------------------------------

        Third problem:

        Customer  "tailored" the libesnmp supplied as example (that produced huge files
        and very big amount of code) in order to have a smaller and more manageable
        code.

md>> Do you mean the example in /usr/examples/esnmp?

        They developed dem_agent_esnmp_get and dem_agent_esnmp_set routines that can be
        applied to simple variables and not to an array containig all mib variables 
        (as happens in libesnmp)

md>> Do you mean as a result of compiling his mibs, the emitted tables
md>> were large?  what do you mean "as happens in libesnmp"?


        He defined a variable I_agent of type ESNMP_TYPE_Integer32 and all his stuff
        works. Is this correct or it works just by chance? Any possible problems with
        it?
                SUBTREE ansaldo_subtree = { "demagent","1.3.6.1.4.1.1262.1.1",
                                                { 9, &elems[0] }, objects, I_agent
                        };

                static unsigned int elems[] = {
                                1, 3, 6, 1, 4, 1, 1262, 1, 1,    /* agent */
                                1, 3, 6, 1, 4, 1, 1262, 1, 1,    /* agent */
                        };

                static OBJECT objects[] = {
                           {I_agent,{9, &elems[  9]}, ESNMP_TYPE_Integer32, 
                                dem_agent_esnmp_get, dem_agent_esnmp_set},
                        };

md>> this won't work in general.  all calls to load variable values, 
md>> convert between instances and oids, etc are based on using a 
md>> correct OBJECT structure.

md>> for instance, you couldn't load an octet sting into any VARBIND 
md>> using this object.

md>> (Maybe this is why you're getting the error from o_integer...)

md>> it's fine to edit the emitted *_tbl.c file to alter the get/set method 
md>> routine names for each object, but that's about it.


        -------------------------------------------------------------------------------
        And now a request....
        is it possible to find a detailed description od diagnostic variables defined
        in our Host Resource MIB? Where?

md>> Host MIB is a standard (RFC 1514).  The variables are already defined.
md>> Are there specific ones you have questions about? 

        Thank you very much in advance
        Angelo