pyloxi: fix OXM lengths
The length field only includes the payload, not the header.
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index f55610b..90ddf23 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -84,7 +84,7 @@
oxm_class = 0x8000
oxm_type = util.primary_wire_type(cls, version)
oxm_masked = cls.find('masked') != -1 and 1 or 0
- oxm_len = of_g.base_length[(cls, version)]
+ oxm_len = of_g.base_length[(cls, version)] - 4
type_values['type_len'] = '%#x' % (oxm_class << 16 | oxm_type << 8 | \
oxm_masked << 8 | oxm_len)
elif cls == "of_match_v3":
diff --git a/py_gen/tests/of12.py b/py_gen/tests/of12.py
index 3b0aefb..b0dec92 100644
--- a/py_gen/tests/of12.py
+++ b/py_gen/tests/of12.py
@@ -78,7 +78,7 @@
expected = ''.join([
'\x80\x00', # class
'\x02', # type/masked
- '\x08', # length
+ '\x04', # length
'\x00\x00\x00\x2a' # value
])
self.assertEquals(expected, obj.pack())
@@ -89,7 +89,7 @@
expected = ''.join([
'\x80\x00', # class
'\x03', # type/masked
- '\x0c', # length
+ '\x08', # length
'\x00\x00\x00\x2a', # value
'\xaa\xbb\xcc\xdd' # mask
])
@@ -101,7 +101,7 @@
expected = ''.join([
'\x80\x00', # class
'\x36', # type/masked
- '\x14', # length
+ '\x10', # length
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0d\x0f', # value
])
self.assertEquals(expected, obj.pack())
diff --git a/py_gen/tests/of13.py b/py_gen/tests/of13.py
index 915bbe8..09ec013 100644
--- a/py_gen/tests/of13.py
+++ b/py_gen/tests/of13.py
@@ -93,7 +93,7 @@
expected = ''.join([
'\x80\x00', # class
'\x02', # type/masked
- '\x08', # length
+ '\x04', # length
'\x00\x00\x00\x2a' # value
])
self.assertEquals(expected, obj.pack())
@@ -104,7 +104,7 @@
expected = ''.join([
'\x80\x00', # class
'\x03', # type/masked
- '\x0c', # length
+ '\x08', # length
'\x00\x00\x00\x2a', # value
'\xaa\xbb\xcc\xdd' # mask
])
@@ -116,7 +116,7 @@
expected = ''.join([
'\x80\x00', # class
'\x36', # type/masked
- '\x14', # length
+ '\x10', # length
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0d\x0f', # value
])
self.assertEquals(expected, obj.pack())