EmbeddedRelated.com
Forums
Memfault Beyond the Launch

How to decode the OID from an SNMP callback

Started by Steve October 30, 2011
My basic question was a topic in this forum about a year ago, but the
parties went "off-list" and the thread apparently died.

I am starting with SNMP1.c in the Samples directory, and have it
working. I can Get, Set, set traps, etc. Now, taking the typical example
code for adding an object:

p = snmp_add_long(p, "1.2.0", &rw_long);

and then generalizing it to:

p = snmp_add_long(p, "a.b.0", &rw_longx);

What I want to do is to determine "a" and "b" from a callback function.
Why? I will have >50 objects, so making individual callbacks for each
one will be messy. My data structure is such that with a single
callback, I can process all transactions quite easily, but only if I can
determine a and b. This may be (or should be) easy, but I am spinning my
wheels trying to figure out the functions in mib.lib and snmp.lib. It
appears that the needed information is buried in the structure p, but I
can't figure out how to decode it. Any ideas?

Regards,

Steve

I found the solution in a post by tjd_ee back in 2004. If looking for "a" and "b" in:

p = snmp_add_long(p, "a.b.0", &rw_longx);

a = (p->stem).oid[(p->stem).len - 3];
b = (p->stem).oid[(p->stem).len - 2];

I verified that this works. Thanks tid_ee!

Regards,

Steve

--- In r..., "Steve" wrote:
>
> My basic question was a topic in this forum about a year ago, but the
> parties went "off-list" and the thread apparently died.
>
> I am starting with SNMP1.c in the Samples directory, and have it
> working. I can Get, Set, set traps, etc. Now, taking the typical example
> code for adding an object:
>
> p = snmp_add_long(p, "1.2.0", &rw_long);
>
> and then generalizing it to:
>
> p = snmp_add_long(p, "a.b.0", &rw_longx);
>
> What I want to do is to determine "a" and "b" from a callback function.
> Why? I will have >50 objects, so making individual callbacks for each
> one will be messy. My data structure is such that with a single
> callback, I can process all transactions quite easily, but only if I can
> determine a and b. This may be (or should be) easy, but I am spinning my
> wheels trying to figure out the functions in mib.lib and snmp.lib. It
> appears that the needed information is buried in the structure p, but I
> can't figure out how to decode it. Any ideas?
>
> Regards,
>
> Steve
>


Memfault Beyond the Launch