New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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" #9

Closed
addictedanshul opened this Issue May 23, 2013 · 21 comments

Comments

Projects
None yet
2 participants
@addictedanshul
Copy link

addictedanshul commented May 23, 2013

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.

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 23, 2013

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.

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 23, 2013

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?

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 23, 2013

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...

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 23, 2013

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.

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 23, 2013

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...

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 23, 2013

Sure, no problem. Contact me directly on sales@percederberg.net to discuss further.

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 23, 2013

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

  1. fulloid string as key in the symbolvaluemap in Mib.java...
  2. and another map inside MibLoader.java which has mib name as key and mib object as value.
@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 23, 2013

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.

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 24, 2013

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...

  1. symbolNameMap should alsobe populated in the validate method
  2. and another map inside MibLoader.java which has mib name as key and mib object as value

Thanks
Anshul

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 26, 2013

Uploaded development version 2.10.alpha1 which adds MibLoader.getMibs(), fixes potential ObjectIdentifierValue.toString() issues and moves the API to Java 6.

http://www.mibble.org/download/development/index.html

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 27, 2013

Hi Cederberg

One question...

If I have a mibvaluesymbol like below


XYZ OBJECT-TYPE
SYNTAX ABC
DESCRIPTION
"Something"

::= { XYZ 2 }

now i want SYNTAX of "XYZ"
output -> "ABC"

ABC itself is mibvaluesymbol like below


ABC ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Something"

SYNTAX Integer32 (0..2147483647)

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

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 27, 2013

Try mibType.getReferenceSymbol().getName() instead.

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 27, 2013

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...

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 27, 2013

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

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 30, 2013

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

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 30, 2013

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 -- ...
@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 30, 2013

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...

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented May 30, 2013

I am not able to debug the issue, as PARSER source code which is part of Grammatica is not available...

@cederberg

This comment has been minimized.

Copy link
Owner

cederberg commented May 30, 2013

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.

@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented Jun 3, 2013

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)
@addictedanshul

This comment has been minimized.

Copy link

addictedanshul commented Jun 3, 2013

Please ignore... its working fine...

@cederberg cederberg closed this Jun 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment