pyloxi: support (only) empty 1.2/1.3 matches
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index 82bf772..f55610b 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -87,6 +87,8 @@
oxm_len = of_g.base_length[(cls, version)]
type_values['type_len'] = '%#x' % (oxm_class << 16 | oxm_type << 8 | \
oxm_masked << 8 | oxm_len)
+ elif cls == "of_match_v3":
+ type_values['type'] = 1
return type_values
diff --git a/py_gen/oftype.py b/py_gen/oftype.py
index 3beb8e3..44356e2 100644
--- a/py_gen/oftype.py
+++ b/py_gen/oftype.py
@@ -125,8 +125,8 @@
elif self.base == 'of_list_hello_elem_t':
return 'common.unpack_list_hello_elem(%s)' % (reader_expr)
elif self.base == 'of_list_oxm_t':
- # XXX need the match_v3 length field
- return 'oxm.unpack_list(%s)' % (reader_expr)
+ # TODO
+ return '[]'
elif self.base == 'of_port_name_t':
return self._gen_string_unpack_expr(reader_expr, 16)
elif self.base == 'of_table_name_t' or self.base == 'of_serial_num_t':
diff --git a/py_gen/templates/_pack.py b/py_gen/templates/_pack.py
index e853833..0c208f7 100644
--- a/py_gen/templates/_pack.py
+++ b/py_gen/templates/_pack.py
@@ -57,3 +57,6 @@
length = sum([len(x) for x in packed])
packed[${length_member_index}] = ${length_member.oftype.gen_pack_expr('length')}
:: #endif
+:: if ofclass.name == 'of_match_v3':
+ packed.append('\x00' * ((length + 7)/8*8 - length))
+:: #endif
diff --git a/py_gen/templates/common.py b/py_gen/templates/common.py
index 5245a26..75c6f4c 100644
--- a/py_gen/templates/common.py
+++ b/py_gen/templates/common.py
@@ -64,6 +64,10 @@
return None
return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None]
+def unpack_list_oxm(buf):
+ # TODO
+ return []
+
:: for ofclass in ofclasses:
:: include('_ofclass.py', ofclass=ofclass, superclass="object")
diff --git a/py_gen/tests/of11.py b/py_gen/tests/of11.py
index c36e0f5..51514ce 100644
--- a/py_gen/tests/of11.py
+++ b/py_gen/tests/of11.py
@@ -108,15 +108,6 @@
def test_show(self):
expected_failures = [
- ofp.common.flow_stats_entry,
- ofp.message.aggregate_stats_request,
- ofp.message.flow_add,
- ofp.message.flow_delete,
- ofp.message.flow_delete_strict,
- ofp.message.flow_modify,
- ofp.message.flow_modify_strict,
- ofp.message.flow_removed,
- ofp.message.flow_stats_request,
]
for klass in self.klasses:
def fn():
diff --git a/py_gen/tests/of12.py b/py_gen/tests/of12.py
index 2f144b5..3b0aefb 100644
--- a/py_gen/tests/of12.py
+++ b/py_gen/tests/of12.py
@@ -56,6 +56,21 @@
self.assertTrue(hasattr(loxi.of12, "message"))
self.assertTrue(hasattr(loxi.of12, "oxm"))
+class TestCommon(unittest.TestCase):
+ sample_empty_match_buf = ''.join([
+ '\x00\x01', # type
+ '\x00\x04', # length
+ '\x00\x00\x00\x00', # padding
+ ])
+
+ def test_empty_match_pack(self):
+ obj = ofp.match()
+ self.assertEquals(self.sample_empty_match_buf, obj.pack())
+
+ def test_empty_match_unpack(self):
+ obj = ofp.match.unpack(self.sample_empty_match_buf)
+ self.assertEquals(len(obj.oxm_list), 0)
+
class TestOXM(unittest.TestCase):
def test_oxm_in_phy_port_pack(self):
import loxi.of12 as ofp
@@ -117,16 +132,12 @@
ofp.common.instruction_header,
ofp.common.instruction_write_actions,
ofp.common.instruction_write_metadata,
- ofp.common.match_v3,
ofp.common.table_stats_entry,
- ofp.message.aggregate_stats_request,
ofp.message.flow_add,
ofp.message.flow_delete,
ofp.message.flow_delete_strict,
ofp.message.flow_modify,
ofp.message.flow_modify_strict,
- ofp.message.flow_removed,
- ofp.message.flow_stats_request,
ofp.message.group_desc_stats_reply,
ofp.message.group_mod,
ofp.message.group_stats_reply,
@@ -146,17 +157,7 @@
def test_show(self):
expected_failures = [
- ofp.common.flow_stats_entry,
ofp.common.table_stats_entry,
- ofp.message.aggregate_stats_request,
- ofp.message.flow_add,
- ofp.message.flow_delete,
- ofp.message.flow_delete_strict,
- ofp.message.flow_modify,
- ofp.message.flow_modify_strict,
- ofp.message.flow_removed,
- ofp.message.flow_stats_request,
- ofp.message.packet_in,
]
for klass in self.klasses:
def fn():
diff --git a/py_gen/tests/of13.py b/py_gen/tests/of13.py
index 6be63a4..915bbe8 100644
--- a/py_gen/tests/of13.py
+++ b/py_gen/tests/of13.py
@@ -170,7 +170,6 @@
ofp.common.instruction_meter,
ofp.common.instruction_write_actions,
ofp.common.instruction_write_metadata,
- ofp.common.match_v3,
ofp.common.meter_band,
ofp.common.meter_band_drop,
ofp.common.meter_band_dscp_remark,
@@ -193,14 +192,11 @@
ofp.common.table_feature_prop_write_actions_miss,
ofp.common.table_feature_prop_write_setfield,
ofp.common.table_feature_prop_write_setfield_miss,
- ofp.message.aggregate_stats_request,
ofp.message.flow_add,
ofp.message.flow_delete,
ofp.message.flow_delete_strict,
ofp.message.flow_modify,
ofp.message.flow_modify_strict,
- ofp.message.flow_removed,
- ofp.message.flow_stats_request,
ofp.message.group_desc_stats_reply,
ofp.message.group_mod,
ofp.message.group_stats_reply,