From e470b4c9f236f7a883e5d65cc93aaabb5977c34f Mon Sep 17 00:00:00 2001 From: Italo Valcy Date: Fri, 21 Nov 2025 18:03:01 -0300 Subject: [PATCH] Create the ListOfTableId and use it on NextTableProperty --- CHANGELOG.rst | 1 + pyof/v0x04/controller2switch/common.py | 34 +++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1fd4396b..c669659c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 *********************** diff --git a/pyof/v0x04/controller2switch/common.py b/pyof/v0x04/controller2switch/common.py index 68de4926..0f13a77d 100644 --- a/pyof/v0x04/controller2switch/common.py +++ b/pyof/v0x04/controller2switch/common.py @@ -22,7 +22,7 @@ 'MultipartType', 'Bucket', 'BucketCounter', 'ListOfBucketCounter', 'ExperimenterMultipartHeader', 'Property', 'InstructionsProperty', 'NextTablesProperty', 'ActionsProperty', 'OxmProperty', - 'ListOfProperty', 'TableFeatures') + 'ListOfTableId', 'ListOfProperty', 'TableFeatures') # Enum @@ -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. @@ -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): @@ -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()