-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fixed Length Strings As Index to Table Includes Length in OID #141
Comments
Hello! You have done everything correctly, but you have run into a few problems that all need to be fixed. Originally, it has been pysmi's job to assign a value to the pysnmp/pysnmp/smi/mibs/SNMPv2-TC.py Line 432 in d6b9e91
As a result, no part of this functionality works anymore now :) and the lack of related unit tests have unfortunately let all that happen, at least until now. FWIW, just this week I skipped over point 2 above in the context of lextudio/pysmi#8, because I could not find any uses of the As such, I think the path forward to resolve this issue as follows:
|
Just shipped pysnmp release 7.1.9 and pysmi 1.5.8 that contains more recent changes on MIB parsing. @WakkaTrout Initial testing shows there is no issue with the latest pysnmp and pysmi. We can close this issue once you confirm on your side. |
@lextm This issue is not fixed, I am still getting an "'int' object is not subscriptable" error from this line of code: pysnmp/pysnmp/smi/mibs/SNMPv2-SMI.py Line 1233 in eb68a47
Additionally, as dcvmoole mentioned, with the PEPT-8 changes in pysnmp, the octet string class has methods named is_fixed_length() and get_fixed_length() but everywhere else in the code still uses the pre-PEPT-8 changes with the name isFixedLength() and getFixedLength(). This will have to be rectified to get this to all work. I did a little digging for the exact RFC this behavior is defined in. It is RFC 2578 Section 7.7 Bullet 2 |
@WakkaTrout The PEP 8 renaming doesn't block anything right now, as rfc1902.py has already contained the compatibility API to remap the methods/properties. You will have to provide more code to reproduce the remaining issues, as the code above was tested on our side and no longer shows any errors. "'int' object is not subscriptable" should be caused by something else. We recommend you open a new issue, so that we can start from scratch. The changes in latest pysnmp and pysmi packages already changed the landscape. |
Context:
I received an older proprietary MIB that has a fixed length OCTET string as the index for a table. The MIB does not have the IMPLIED keyword in it, but the length of the OCTET string is fixed. A snippet of the MIB with the names changed is shown below (forgive my inability to format the below in a nice way):
ExampleTextualConv ::= TEXTUAL-CONVENTION
STATUS current
SYNTAX OCTET STRING (SIZE(8))
exampleTable OBJECT-TYPE
SYNTAX SEQUENCE OF exampleTableEntry
MAX-ACCESS not-accessible
STATUS current
::= { exampleOID 1 }
exampleTableEntry OBJECT-TYPE
SYNTAX ExampleTableEntry
MAX-ACCESS not-accessible
STATUS current
INDEX {exampleIndex}
::= { exampleTable 1 }
ExampleTableEntry ::= SEQUENCE
{
exampleIndex ExampleTextualConv
exampleRowStatus RowStatus
}
exampleIndex OBJECT-TYPE
SYNTAX ExampleTextualConv
MAX-ACCESS not-accessible
STATUS current
::= { exampleTableEntry 1 }
exampleRowStatus OBJECT-TYPE
SYNTAX RowStatus
MAX-ACCESS read-create
STATUS current
::= { exampleTableEntry 2 }
From my understanding of how SNMPv2 and later works, if there is a string in an OID that is fixed length, then the length of the string is not included in the SNMP message OID. In the above example, exampleIndex is a fixed length string and therefore, the length of the string is not included in the OID when requesting table rows.
What I am seeing:
In the newest release of pysnmp, 7.1.8, I am seeing the lengths of the string be included in the OID's on wireshark. I ran mibdump on the above mib and used the generated python files.
My Fix
To get it to work, I had to add the isFixedLength() function and the getFixedLength() function to the generated textual convention.
After that, I ran into a bug where there was a name clash as seen below.
pysnmp/pysnmp/smi/mibs/SNMPv2-SMI.py
Line 1251 in d6b9e91
I fixed the above by just renaming the return 'value' to 'value2'.
return obj.clone(tuple(value[:value2])), value[value2:]
Please correct me if I am doing something incorrectly with mibdump that led me to have to do the above
The text was updated successfully, but these errors were encountered: