pyloxi: unpack of_list_instruction
diff --git a/py_gen/oftype.py b/py_gen/oftype.py
index 7719432..3717036 100644
--- a/py_gen/oftype.py
+++ b/py_gen/oftype.py
@@ -148,6 +148,8 @@
return self._gen_string_unpack_expr(reader_expr, 256)
elif self.base == 'of_meter_features_t':
return 'common.meter_features.unpack(%s)' % (reader_expr)
+ elif self.base == 'of_list_instruction_t':
+ return 'instruction.unpack_list(%s)' % (reader_expr)
elif utils.class_is_list(self.base):
element_cls = utils.list_to_entry_type(self.base)[:-2]
if ((element_cls, self.version) in of_g.is_fixed_length) \
diff --git a/py_gen/templates/common.py b/py_gen/templates/common.py
index 1ab91cf..1ab2f68 100644
--- a/py_gen/templates/common.py
+++ b/py_gen/templates/common.py
@@ -32,6 +32,9 @@
import sys
import struct
import action
+:: if version >= 2:
+import instruction # for unpack_list
+:: #endif
:: if version >= 4:
import meter_band # for unpack_list
:: #endif
diff --git a/py_gen/templates/message.py b/py_gen/templates/message.py
index 228d2d0..196cd6c 100644
--- a/py_gen/templates/message.py
+++ b/py_gen/templates/message.py
@@ -36,6 +36,9 @@
import const
import common
import action # for unpack_list
+:: if version >= 2:
+import instruction # for unpack_list
+:: #endif
:: if version >= 4:
import meter_band # for unpack_list
:: #endif
diff --git a/py_gen/tests/of11.py b/py_gen/tests/of11.py
index 3b1b584..2fdec9e 100644
--- a/py_gen/tests/of11.py
+++ b/py_gen/tests/of11.py
@@ -70,13 +70,7 @@
def test_serialization(self):
expected_failures = [
- ofp.common.flow_stats_entry,
ofp.common.table_stats_entry,
- ofp.message.flow_add,
- ofp.message.flow_modify,
- ofp.message.flow_modify_strict,
- ofp.message.flow_delete,
- ofp.message.flow_delete_strict,
]
for klass in self.klasses:
def fn():
diff --git a/py_gen/tests/of12.py b/py_gen/tests/of12.py
index 92dbe70..a176253 100644
--- a/py_gen/tests/of12.py
+++ b/py_gen/tests/of12.py
@@ -158,13 +158,7 @@
def test_serialization(self):
expected_failures = [
- ofp.common.flow_stats_entry,
ofp.common.table_stats_entry,
- ofp.message.flow_add,
- ofp.message.flow_modify,
- ofp.message.flow_modify_strict,
- ofp.message.flow_delete,
- ofp.message.flow_delete_strict,
]
for klass in self.klasses:
def fn():
diff --git a/py_gen/tests/of13.py b/py_gen/tests/of13.py
index 6ec9897..3c9772f 100644
--- a/py_gen/tests/of13.py
+++ b/py_gen/tests/of13.py
@@ -395,8 +395,59 @@
## Flow-mods
def test_flow_add(self):
- # TODO
- pass
+ obj = ofp.message.flow_add(
+ xid=0x12345678,
+ cookie=0xFEDCBA9876543210,
+ cookie_mask=0xFF00FF00FF00FF00,
+ table_id=3,
+ idle_timeout=5,
+ hard_timeout=10,
+ priority=6000,
+ buffer_id=50,
+ out_port=6,
+ out_group=8,
+ flags=0,
+ match=ofp.match(oxm_list=[]),
+ instructions=[
+ ofp.instruction.goto_table(table_id=4),
+ ofp.instruction.goto_table(table_id=7)])
+ buf = ''.join([
+ '\x04', '\x0e', # version, type
+ '\x00\x48', # length
+ '\x12\x34\x56\x78', # xid
+
+ '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
+
+ '\xff\x00\xff\x00\xff\x00\xff\x00', # cookie_mask
+
+ '\x03', # table_id
+ '\x00', # _command
+ '\x00\x05', # idle_timeout
+ '\x00\x0a', # hard_timeout
+ '\x17\x70', # priority
+
+ '\x00\x00\x00\x32', # buffer_id
+ '\x00\x00\x00\x06', # out_port
+
+ '\x00\x00\x00\x08', # out_group
+ '\x00\x00', # flags
+ '\x00' * 2, # pad
+
+ '\x00\x01', # match.type
+ '\x00\x04', # match.length
+ '\x00' * 4, # pad
+
+ '\x00\x01', # instructions[0].type
+ '\x00\x08', # instructions[0].length
+ '\x04', # instructions[0].table_id
+ '\x00' * 3, # pad
+
+ '\x00\x01', # instructions[1].type
+ '\x00\x08', # instructions[1].length
+ '\x07', # instructions[1].table_id
+ '\x00' * 3, # pad
+ ])
+ test_serialization(obj, buf)
def test_flow_modify(self):
# TODO
@@ -934,19 +985,11 @@
def test_serialization(self):
expected_failures = [
- ofp.common.flow_stats_entry,
ofp.common.table_feature_prop_apply_actions,
ofp.common.table_feature_prop_apply_actions_miss,
- ofp.common.table_feature_prop_instructions,
- ofp.common.table_feature_prop_instructions_miss,
ofp.common.table_feature_prop_write_actions,
ofp.common.table_feature_prop_write_actions_miss,
ofp.common.table_features,
- ofp.message.flow_add,
- ofp.message.flow_delete,
- ofp.message.flow_delete_strict,
- ofp.message.flow_modify,
- ofp.message.flow_modify_strict,
ofp.message.table_features_stats_reply,
ofp.message.table_features_stats_request,
]