On Wed, 2008-08-27 at 14:14 +0200, Hanig, Michael wrote:
> Hello there,
> 
> I stumbled upon some problems using net-snmp for creating a sub-agent.
> I was able to figure out most of the stuff, but there are still some
> questions left.
> 
> I) What is the difference between
> 
> netsnmp_register_watched_scalar()
> 
> and
> 
> netsnmp_register_watched_instance()
> 
> ?

Assume that you are calling the registration code with <theOid> as the
OID, then _instance registers a variable at <theOid> while _scalar
registers a variable at <theOid>.0, this is useful for simple scalar
variables that are declared outside of any table in the MIB.

> Besides *_instance mostly seems to work as I want it to and *_scalar
> doesn’t. ;)

Sounds like _the_ argument for using _instance.

> II) Why does net-snmp behave different with the following code:
> 
> 1) netsnmp_register_watched_instance(
>         netsnmp_create_handler_registration(
>                 “one”,
>                 NULL,
>                 my_oid1,
>                 OID_LENGTH(my_oid1),
>                 HANDLER_CAN_RWRITE),
>         netsnmp_create_watcher_info(
>                 (void *)&string,
>                 sizeof(string),
>                 ASN_OCTET_STR,
>                 WATCHER_MAX_SIZE));
> 
> snmpget/-set works fine
> 
> 2) netsnmp_register_watched_instance(
>         netsnmp_create_handler_registration(
>                 “two”,
>                 NULL,
>                 my_oid2,
>                 OID_LENGTH(my_oid2),
>                 HANDLER_CAN_RWRITE),
>         netsnmp_create_watcher_info(
>                 (void *)&integer,
>                 sizeof(integer),
>                 ASN_INTEGER,
>                 WATCHER_FIXED_SIZE));
> 
> snmpget works fine / snmpset doesn’t work (wrong type or length)

What exact commad are you issuing?

> 3) netsnmp_register_int_instance(
>         “two”,
>         my_oid2,
>         OID_LENGTH(my_oid2),
>         &integer,
>         NULL);
> 
> snmpget/-set works fine

In 5.5 (trunk) this is equivalent to 2) and the _watched code is
rewritten.
In all previous versions this calls a different handling routine.

Could you pleease check if your problem is present in the trunk version
as well? f there is a bug I would rather know about it now than later.

> Is it safe to use the netsnmp_register_int_instance rather than the
> netsnmp_register_watched_instance?

They should be functionally equivalent.

> III) How do I correctly add an OID in a table?
> 
> I tried
> 
> netsnmp_set_row_column(netsnmp_row, 2, ASN_OBJECT_ID, “\0”,
> sizeof(“\0”)); /* OID 0.0 */
> 
> which should be fine to my understanding of OID-encoding. But the
> agent refuses to generate a paket because of a bad sub-identifier, so
> the request times out. I also tried to add a more complex OID (i.e.
> 2.100.3) accordingly to the above example with “\x81\x34\x03” but I
> may be totally wrong with that.
> 
> Perhaps I only need a point to the right direction.

I failed to understand question III

/MF


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to