Skip to content

Commit

Permalink
Merge pull request #12 from cesbit/dev
Browse files Browse the repository at this point in the history
Handle wrong use of OBJECT-IDENTITY
  • Loading branch information
joente authored Oct 10, 2024
2 parents 44ffb0c + 75c0781 commit e6ae323
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions asyncsnmplib/mib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ def on_result(
base_name = result_name = base['name']
prefixlen = len(base_oid) + 1

if base['tp'] == 'OBJECT IDENTIFIER':
# check if the type of the base oid is table or scalar object.
# scalar objects have (0, ) as index (oid suffix)
# in some mibs (i.e. SW-MIB) the assignments are done with the
# OBJECT-IDENTITY macro
if base['tp'] in ('OBJECT IDENTIFIER', 'OBJECT-IDENTITY'):
# filter out recursive "SEQUENCE" types
result = [res for res in result if res[0][prefixlen] == 0]
elif base_name.endswith('XEntry'):
Expand Down Expand Up @@ -123,7 +127,11 @@ def on_result_base(
result_name = base['name']
prefixlen = len(base_oid) + 1

if base['tp'] == 'OBJECT IDENTIFIER':
# check if the type of the base oid is table or scalar object.
# scalar objects have (0, ) as index (oid suffix)
# in some mibs (i.e. SW-MIB) the assignments are done with the
# OBJECT-IDENTITY macro
if base['tp'] in ('OBJECT IDENTIFIER', 'OBJECT-IDENTITY'):
# filter out recursive "SEQUENCE" types
result = [res for res in result if res[0][prefixlen] == 0]

Expand Down

0 comments on commit e6ae323

Please sign in to comment.