Hi Maurice,

SNMP4J-SMI 1.1 is ready for download now - if you have not recognized it yet. The examples below are not valid any more, because I had to change the format
a little bit. See the SmiManager JavaDoc for the details:
http://www.snmp4j.org/smi/doc/com/snmp4j/smi/SmiManager.html

Best regards,
Frank

Am 04.01.2014 02:56, schrieb Frank Fock:
Maurice,

You got it right. The decoded index format without quotes that is currently
implemented is not suitable for round-trip coding/decoding.
The new (additional) format uses double quotes for non-implied length
sub-indexes with variable length, DISPLAY-HINT, or enum label encoding.
It uses single quotes for implied length non-numeric sub-index values.

Some examples from the unit tests I wrote to verify the new format:

OID vacmAccessContextMatch = new OID("1.3.6.1.6.3.16.1.4.1.4.7.118.51.103.114.111.117.112.0.3.1"); assertEquals("vacmAccessContextMatch.'v3group'.''.3.'noAuthNoPriv(1)'", vacmAccessContextMatch.toString()); assertEquals(vacmAccessContextMatch, new OID("vacmAccessContextMatch.'v3group'.''.3.'noAuthNoPriv(1)'"));

OID vacmViewTreeFamilyMask = new OID("1.3.6.1.6.3.16.1.5.2.1.3.20.117.110.114.101.115.116.114.105.99.116.101.100.82.101.97.100.86.105.101.119.3.1.3.6"); assertEquals("vacmViewTreeFamilyMask.'unrestrictedReadView'.'dod'", vacmViewTreeFamilyMask.toString());

OID vacmViewTreeFamilyMask2 = new OID("1.3.6.1.6.3.16.1.5.2.1.3.20.117.110.114.101.115.116.114.105.99.116.101.100.82.101.97.100.86.105.101.119.4.1.3.6.4976"); assertEquals("vacmViewTreeFamilyMask.'unrestrictedReadView'.'dod.4976'", vacmViewTreeFamilyMask2.toString());

OID vacmViewTreeFamilyMask3 = new OID("1.3.6.1.6.3.16.1.5.2.1.3.20.117.110.114.101.115.116.114.105.99.116.101.100.82.101.97.100.86.105.101.119.4.9.3.6.4976"); assertEquals("vacmViewTreeFamilyMask.'unrestrictedReadView'.'9.3.6.4976'", vacmViewTreeFamilyMask3.toString());

Best regards,
Frank


Am 03.01.2014 16:28, schrieb Garcia, Maurice:

Frank,

Sorry for all the questions L

One more related to this email trail...

I implemented the change you suggested and now the OID is resolved:

Output -> *vacmSecurityToGroupStatus.1.readwritesec*

But when I reverse the process, it will not encode back to BER.

OID 'vacmGroupName.1.readwritesec' cannot be parsed

at org.snmp4j.smi.OID.parseDottedString(_OID.java:148_)

at org.snmp4j.smi.OID.<init>(_OID.java:83_)

at com.comcast.cpe.cfb.ber.BERService.setOIDEncoding(_BERService.java:152_)

I am not sure if this is related to the bug you found that will be fixed in 1.0.2, but it appear to be the round-trip index conversion that you were talking about?

Thanks,

Maurice

*From:*Frank Fock [mailto:f...@agentpp.com]
*Sent:* Thursday, January 02, 2014 12:15 PM
*To:* Garcia, Maurice; snmp4j@agentpp.org
*Subject:* Re: [SNMP4J] - BER -> OID resolution i.e : snmpCommunityName

Hi Maurice,

OK, I understand.
To get the index decoded too, two steps are ncessary:

1. Set the OID format to:
smiManager.setOidFormat(SmiManager.OIDFormat.ObjectNameAndDecodedIndex);

2. Call  oOID.format();

While investigating this, I found two issues with SNMP4JSMI 1.0.1:

1. When activating the OID format OIDFormat.ObjectNameAndDecodedIndex object names of non-instance OIDs (i.e. objects in the MIB tree path like "mib-2") will be decoded as numeric OIDs only. This bug will be fixed with version 1.0.2 coming very soon.

2. Currently "OID.toString()" will not return object names with decoded index, because such OIDs cannot be parsed and thus are not suitable for rountrip conversion. However, I think I have found a solution to be able to do round-trip index conversion
and will implement it for version 1.0.2 too.

Best regards,
Frank

Am 02.01.2014 04:40, schrieb Garcia, Maurice:

    Thanks for the quick reponse!!

    I am using the SNMP4J-SMI with the purchased license.

    I used both the OID.format() and OID.toString, but I am getting
    the same result.

    *if*(*true*) {

    System./out/.println("BEROIDConversion.getOidName() - BER: "+
    *new*HexString(bBER).toString());

    System./out/.println("BEROIDConversion.getOidName() -
    OID.toString(): "+ oOID.toString());

    System./out/.println("BEROIDConversion.getOidName() -
    OID.format(): "+ oOID.format());

    }

    BEROIDConversion.getOidName() - BER: 30 1C 06 11 2B 06 01 06 03 12
    01 01 01 02 6D 74 61 70 72 6F 76 04 07 6D 74 61 5F 70 77 64

    BEROIDConversion.getOidName() - OID.toString():
    snmpCommunityName.109.116.97.112.114.111.118

    BEROIDConversion.getOidName() - OID.format():
    snmpCommunityName.109.116.97.112.114.111.118

    Am I doing something wrong, or is there more to the setup of SMI?

    Thanks,

    Maurice

    *From:*Frank Fock [mailto:f...@agentpp.com]
    *Sent:* Wednesday, January 01, 2014 12:03 PM
*To:* Garcia, Maurice; snmp4j@agentpp.org <mailto:snmp4j@agentpp.org>
    *Subject:* Re: [SNMP4J] - BER -> OID resolution i.e :
    snmpCommunityName

    Hi Maurice,

    I think the BER (Basic Encoding Rules) isn't the problem here.
    The BER encodes/decodes a numeric object identifier (i.e., an
    array of usinged 32bit integer values) to/from a network encoding
    that is independent from the byte and word order of a system.

    What you are looking for is SNMP4J-SMI which provides
    OID to object (last) name conversion and index to string
    conversions.

    If you have SNMP4J-SMI in place, OID.toString() will provide
    you the value you are looking for.

    Best regards,
    Frank

    Am 31.12.2013 17:18, schrieb Garcia, Maurice:

        Hi,

        I am trying to fully resolve the *snmpCommunityName*OID from
        BER to OID

        I tried using all the methods in the OID Class and can't find
        anything in the SMI class that can help..

        Any suggestions???

        /_Example:_/

        I get this -> *snmpCommunityName.109.116.97.112.114.111.118*

        But I want this -> *snmpCommunityName.'mtaprov1'*

        *Thanks,*

        *Maurice*




    --
    ---

    AGENT++

    Maximilian-Kolbe-Str. 10

    73257 Koengen, Germany

    https://agentpp.com

    Phone: +49 7024 8688230

    Fax:   +49 7024 8688231



--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231


--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231

_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
https://s16675406.onlinehome-server.info/mailman/listinfo/snmp4j

Reply via email to