Closed addictedanshul closed 11 years ago
Have a look at Mib.getSymbolByOid(String oid)
. Think it does what you want, albeit only within the context of a single MIB file.
Also check MibLoader.getRootOid()
and the accessor ObjectIdentifierValue.getChildByValue(int)
to enable walking through the OID tree of all MIBs currently loaded.
I'll keep this issue open in order to document this better.
BTW. The real issue here is that the OID keys contain "referencetovalue". This means that a MIB symbol wasn't properly resolved to a value (couldn't find the parent OID). Are you seeing any warnings or errors?
Thanks for prompt reply
But I dont think there was any issue with the MIB loading.
It could find the parent easily... but when i saw the place where it populates the map...
symbolValueMap.put(value.getValue().toString(), symbol);
it is just putting the "value" as the key, which will always be in format "referencetovalue.3"
What I did is... convert that value to "ObjectIdentifierValue" and use "todetailstring" method.....
ObjectIdentifierValue root = (ObjectIdentifierValue) value.getValue();
symbolValueMapCustom.put("."+root.toDetailStringCustom(), symbol);
I had to edit that "todetailstring" method as well by commenting out below lines
// buffer.append(name); // buffer.append("("); buffer.append(value); // buffer.append(")");
Are you sure that key of the "symbolValueMap" should be full oid if the mib loading happens properly...
Ok... Then the problem is rather in ObjectIdentifierValue.toString():
public String toString() {
StringBuffer buffer;
if (cachedNumericValue == null) {
buffer = new StringBuffer();
if (parent != null) {
buffer.append(parent.toString());
buffer.append(".");
}
buffer.append(value);
cachedNumericValue = buffer.toString();
}
return cachedNumericValue;
}
I guess that the cachedNumericValue
value is set too early, before the parent OID symbol has been resolved properly. Have to look into this.
Also, note that the correct functioning of Mibble would not include the leading .
in the OID search, so you might want to adjust for that.
Hi
If we purchase the commercial license, would you provide a new jar after incorporating the changes as required by us... Is the product supported for lifetime with commercial license, otherwise what is the duration...
We just need small tweaks as per our requirement...
Sure, no problem. Contact me directly on sales@percederberg.net to discuss further.
Hi
The technical team here has a concern that whether you would just make the changes and provide a new jar for us... Or would you GA (General Availability) it and include it in your stable releases, so that our purchased version doesn't conflict with your later updated release...
Our is a small requirement where we want
Bug fixes (like this seems to be) will always end up in the public version. Features that are useful for the library are also generally included, unless the customer would object to that.
The requirements you mention seem very reasonable. I'd might build #2 slightly differently, but the functionality would be the same.
Hi Cederberg
My bad, I checked again and found out that fulloid string is set as the key for the symbolvaluemap... The issue was wit the mib loading only...
I had one concern though, why symbolnamemap was not populated in "validate" method of Mib.java along with symbolvaluemap...
Also symbolvaluemap is private, there should be a getter for the same, so that using the same we can create our own maps...
I had to make a getter method for symbolvaluemap, and then using that map i had populated my own symbolnamemap
So basically we need two things...
Thanks Anshul
Uploaded development version 2.10.alpha1 which adds MibLoader.getMibs(), fixes potential ObjectIdentifierValue.toString() issues and moves the API to Java 6.
Hi Cederberg
One question...
If I have a mibvaluesymbol like below
XYZ OBJECT-TYPE SYNTAX ABC DESCRIPTION "Something"
now i want SYNTAX of "XYZ" output -> "ABC"
ABC itself is mibvaluesymbol like below
ABC ::= TEXTUAL-CONVENTION STATUS current DESCRIPTION "Something"
When I do
MibType mibType = mibValSym.getType();
SnmpObjectType snmpObjType = (SnmpObjectType)mibType;
MibType newMibType = snmpObjType.getSyntax();
System.out.println("Syntax: "+newMibType.getName());
It returns me INTEGER and not ABC....
Please tell me, how can I get syntax of mibvaluesymbol when the syntax itself is another mibvaluesymbol...
Thanks Anshul
Try mibType.getReferenceSymbol().getName()
instead.
I have done by using below:
MibTypeSymbol mibTypeSym = newMibType.getReferenceSymbol();
if(mibTypeSym != null)
{
type = mibTypeSym.getName();
}
else
{
type = newMibType.getName();
}
let me know, if there's an easy way out...
Yes I have also used the same... Just that I have to check if referencesymbol comes up as null... then it has to be taken from mibtypename.
Thanks
Hi Cederberg
While loading a MIB I get an error saying "unexpected token "-", expected "END""
Error is on below line in MIB, which is just a comment...
Some Mib value symbols .... .... .... ----------------------------- Entities for Disaster Recovery Module -------------------------------- (Error Line)
Can you please tell me the cause of this...
Thanks
Its probably not a valid comment in ASN.1 syntax. Here are two valid examples:
... -- comment to the end of line
... -- comment start and end -- ...
Will Mibble not work if the Mib file name and Mib name are different... Like "ABC.txt" has MIB name defined as "XYZ" inside
And will the Mibble load more than one MIB definitions in the MIB file... Rite now, it says MIB Loaded as null when it has different MIB name in the file or more than one MIB definitions...
I am not able to debug the issue, as PARSER source code which is part of Grammatica is not available...
Try the built-in MibblePrinter utility. It shows the data parsed by Mibble. Dig though the source code for MibWriter to find out how it works.
But basically, Mibble parses all MIBs in a MIB file but only returns the first one.
Cederberg
Is the Mibble source java 7 compatible... because I could see some runtime errors as shown below... If not, can you please release a version which is java 7 compatible...
Duplicate local variable state Type mismatch: cannot convert from boolean to TokenStringDFA.State Syntax error on tokens, they can be merged to form == Duplicate local variable state The constructor TokenStringDFA.TransitionTree(TokenStringDFA) is undefined The constructor TokenStringDFA.TransitionTree(TokenStringDFA) is undefined The constructor TokenStringDFA.TransitionTree(TokenStringDFA) is undefined
at net.percederberg.grammatica.parser.TokenStringDFA$State.<init>(TokenStringDFA.java:26)
at net.percederberg.grammatica.parser.TokenStringDFA.<init>(TokenStringDFA.java:14)
at net.percederberg.grammatica.parser.Tokenizer$StringDFAMatcher.<init>(Tokenizer.java:309)
at net.percederberg.grammatica.parser.Tokenizer.<init>(Tokenizer.java:14)
at net.percederberg.mibble.asn1.Asn1Tokenizer.<init>(Asn1Tokenizer.java:49)
at net.percederberg.mibble.asn1.Asn1Parser.newTokenizer(Asn1Parser.java:120)
at net.percederberg.grammatica.parser.Parser.<init>(Parser.java:32)
at net.percederberg.grammatica.parser.RecursiveDescentParser.<init>(RecursiveDescentParser.java:19)
at net.percederberg.mibble.asn1.Asn1Parser.<init>(Asn1Parser.java:102)
at net.percederberg.mibble.MibLoader$MibSource.parseMib(MibLoader.java:983)
at net.percederberg.mibble.MibLoader.loadQueue(MibLoader.java:726)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:552)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:481)
Please ignore... its working fine...
symbolvaluemap in Mib.java has keys in the format like "referencetovalue.2" instead of full oid string like ".1.3.6.1.2.3.4"
Full oid string is universal accepted key which should be used to search for mibvaluesymbol from the map.