Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Fixed
=====
- Added missing ``ActionPopMPLS.length`` attribute to fix ``PackException`` when packing objects.
- Correct return value for ``get_size()`` when used with ``ActionHeader`` objects directly (useful for TableFeatures Properties).
- Fix ``NextTableProperty.next_table_ids`` to correctly export only the Table IDs

[2025.1.0] - 2025-04-14
***********************
Expand Down
34 changes: 28 additions & 6 deletions pyof/v0x04/controller2switch/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'MultipartType', 'Bucket', 'BucketCounter', 'ListOfBucketCounter',
'ExperimenterMultipartHeader', 'Property', 'InstructionsProperty',
'NextTablesProperty', 'ActionsProperty', 'OxmProperty',
'ListOfProperty', 'TableFeatures')
'ListOfTableId', 'ListOfProperty', 'TableFeatures')

# Enum

Expand Down Expand Up @@ -509,6 +509,25 @@ def __init__(self, property_type=TableFeaturePropType.OFPTFPT_INSTRUCTIONS,
self.update_length()


class ListOfTableId(FixedTypeList):
"""List of Table IDs.

Represented by instances of UBInt8.
"""

def __init__(self, items=None):
"""Create a ListOfTableId with the optional parameters below.

Args:
items (|UBInt8|): Instance or a list of instances.

"""
items = [
x if isinstance(x, UBInt8) else UBInt8(x) for x in items or []
]
super().__init__(pyof_class=UBInt8, items=items)


class NextTablesProperty(Property):
"""Next Tables Property.

Expand All @@ -517,7 +536,7 @@ class NextTablesProperty(Property):
OFPTFPT_NEXT_TABLES_MISS
"""

next_table_ids = ListOfInstruction()
next_table_ids = ListOfTableId()

def __init__(self, property_type=TableFeaturePropType.OFPTFPT_NEXT_TABLES,
next_table_ids=None):
Expand All @@ -526,13 +545,16 @@ def __init__(self, property_type=TableFeaturePropType.OFPTFPT_NEXT_TABLES,
Args:
type(|TableFeaturePropType_v0x04|):
Property Type value of this instance.
next_table_ids (|ListOfInstruction_v0x04|):
List of InstructionGotoTable instances.
next_table_ids (|ListOfTableId_v0x04|):
List of UBInt8 (Table IDs) instances.

"""
super().__init__(property_type)
self.next_table_ids = (ListOfInstruction() if next_table_ids is None
else next_table_ids)
self.next_table_ids = (
next_table_ids
if isinstance(next_table_ids, ListOfTableId)
else ListOfTableId(next_table_ids)
)
self.update_length()


Expand Down