I'm using java Mibble library to process MIB files and create MIB implementation for my snmp agent. And have a little problem with that:
There is a DisplayString type that is the representation of OCTET_STRING but can contains only 7bit ASCII chars. There is also type like AdminString that is another represetnation of OCTET_STRING but can contains all ASCII chars.
So my question is: how to distinguish DisplayString (so I can check for chars that are greater then 126 in my implementation) from Admin String? i tried to use MibTypeTag[1] but apparently I don't know HOW to use it (any hints?) and it says that "it is possible to distinguish between types using the same or a similar primitive ASN.1 type representation (such as DisplayString and IpAddress)"
My written english isn't perfect so here's what I would like to do:
if (MibTypeTag == DisplayString) {
check for chars greater than 126
}
else if (MibTypeTag == AdminString) {
awesome! nothing to do!
}
Thanks in advance!
[1] http://www.mibble.org/doc/release/api/net/percederberg/mibble/MibType.html
Ok, I resolved this problem.
I decided not to use getTag() at all - instead I tried this algorithm:
get the type of the object (getType()) and check if it is an instance of StringType
if it is I get reference symbol from it:
MibTypeSymbol mts = (StringType)myObj.getReferenceSymbol()
Then I convert this MibTypeSymbol to String and compare to "DisplayString"
mts.toString.equals("DisplayString");
And - as for now - it is working.
Mayby this help for someone in the future.
But mayby someone have better idea?