[SNMP-12] MibTable assumes Enum values start from 0 Created: 04/Apr/16  Updated: 19/Oct/17

Status: In Review
Project: snmp
Component/s: General
Affects Version/s: unspecified
Fix Version/s: None

Type: Bug
Reporter: Romanos Skiadas Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 5650

 Description   

The MibTable class assumes that Enums start from 0 which is is not always true and causes problems.
For example, in this leaf, the first value is 1:

> leaf ifAdminStatus {
> type enumeration {
> enum up

{ value 1; }

> enum down

{ value 2; }

> enum testing

{ value 3; }

> }
> [etc]

This is the relevant snippet from the MibTable class:

> } else if (Enum.class.isAssignableFrom(objectType)) {
> setObject = objectType.getEnumConstants()[variable.toInt()];

getEnumConstants returns an array like [up, down, testing], however variable.toInt() ranges from 1 to 3.
If ifAdminStatus is up, variable.toInt()=1 so:

[up, down, testing][1] => down

If ifAdminStatus is testing, you get [up, down, testing][3] which causes an exception:

>2016-04-04 12:17:47,386 | WARN | tp1045961511-266 | MibTable | 242 - org.opendaylight.snmp - 1.1.0.Beryllium | Populate Exception
>java.lang.ArrayIndexOutOfBoundsException: 3
> at org.opendaylight.snmp.plugin.internal.MibTable.parse(MibTable.java:179)
> at org.opendaylight.snmp.plugin.internal.MibTable.populate(MibTable.java:88)

The correct code should shift variable.toInt() accordingly to account for this. Right now I am working on fixing this.



 Comments   
Comment by Abbas P Pareedkunju [ 31/May/16 ]

Hi,

Is it ok if I start working on this?

Thanks,
Abbas

Comment by Romanos Skiadas [ 31/May/16 ]

(In reply to Abbas P Pareedkunju from comment #1)
> Hi,
>
> Is it ok if I start working on this?
>
> Thanks,
> Abbas

I've already submitted a pull request to fix it
https://git.opendaylight.org/gerrit/#/c/37249/

Comment by Abbas P Pareedkunju [ 31/May/16 ]

Thanks to confirm Romanos.
I have assigned it back to the default.

Generated at Wed Feb 07 20:39:12 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.