mibble-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mibble-users] MibNode -> SnmpTextualConvention


From: Per Cederberg
Subject: Re: [Mibble-users] MibNode -> SnmpTextualConvention
Date: Mon, 24 Jan 2005 17:01:22 +0100

Hi Birgit,

On mon, 2005-01-24 at 12:33 +0000, Birgit Arkesteijn wrote:
> We are trying to use Mibble (v2.5) for this purpose. I'm extending 
> the Mibble Browser example into a Stub Browser;
> The user can select OIDs via the JTree, generate stub files and save
> them to disk.

Interesting! Please let me know how far you've progressed, as
I've been thinking about adding this type of MIB compiler
functionality into Mibble myself. I have some code from a
similar effort that I'm planning to rinse and integrate into
Mibble, so some of it might be quite handy here.

> The JTree gives me MibNode(s). I manage to get my hands on a lot of MIB
> information. However, I do not seem to get hold of any 
> SnmpTextualConvention objects.
> 
> As example I'm trying to generate a stub for sysDescr. sysDescr is a
> DisplayString, so I assume that somewhere a SnmpTextualConvention object
> is associated with the MibNode for sysDescr.

This is a frequent problem for people using Mibble, so I guess
it should be added to some kind of FAQ on the web site. Being
too lazy for that right now, I'll explain it here instead... :-)

It is a bit tricky, and mostly unnecessary, to get hold of the 
SnmpTextualConvention object via the Mibble API. The textual
conventions are "resolved" to their base ASN.1 types during the
analysis phase of the loading and are thereafter tucked away
into the MibType.getReferenceSymbol() API.

Now this may seem unpractical, but most of the time it isn't.
Most of the relevant information from the textual description
are instead available by other means:

* Want to know what type the INTEGER or OCTET STRING *really*
  is? Use the type tags defined in the SNMPv2-SMI. For IpAddress
  it would look like this:

     if (type.hasTag(MibTypeTag.APPLICATION_CATEGORY, 0)) {
         // type is an IpAddress (or subtype thereof)
     }

  In general type tags should always be used to distinguish
  between the SNMP types (see the SnmpManager.createAsnValue()
  for example).

* Want to know if a type was defined via some textual
  convention? Use the simplified type reference API, like
  this:

     if (type.hasReferenceTo("DisplayString")) {
         // type is a DisplayString (or subtype thereof)
     }

* Finally, one can always traverse the referenced symbols
  to get the full textual convention information via the
  complete reference API, like this:

     while (type != null) {
         symbol = type.getReferenceSymbol();
         if (symbol == null) {
             type = null;
         } else {
             System.out.println("Referenced " + symbol.getName());
             type = symbol.getType();
         }
     }

Hope this helps!

/Per
-- 
Per Cederberg
System Architect & Process Mentor
Phone: +46-73-664 69 13
Email: address@hidden
Web:   http://www.percederberg.net/software/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]