Merge into master from pull request #377:
recursive TLV fixes (https://github.com/floodlight/loxigen/pull/377)
diff --git a/c_gen/templates/of_object.c b/c_gen/templates/of_object.c
index 596d79a..574db27 100644
--- a/c_gen/templates/of_object.c
+++ b/c_gen/templates/of_object.c
@@ -521,7 +521,7 @@
obj->wbuf = NULL;
}
-#define _MAX_PARENT_ITERATIONS 4
+#define _MAX_PARENT_ITERATIONS 8
/**
* Iteratively update parent lengths thru hierarchy
* @param obj The object whose length is being updated
diff --git a/openflow_input/bsn_tlv b/openflow_input/bsn_tlv
index af0fb96..7e9b376 100644
--- a/openflow_input/bsn_tlv
+++ b/openflow_input/bsn_tlv
@@ -468,3 +468,9 @@
uint16_t length;
uint16_t value;
};
+
+struct of_bsn_tlv_rx_bytes : of_bsn_tlv {
+ uint16_t type == 71;
+ uint16_t length;
+ uint64_t value;
+};
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index f8a7211..9c741d2 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -109,5 +109,5 @@
for name, ofclasses in modules.items():
args = args_by_module.get(name, {})
render(os.path.join(subdir, name + '.py'), template_name='module.py',
- version=version, ofclasses=ofclasses, modules=modules.keys(),
+ version=version, ofclasses=ofclasses, subdir=subdir,
**args)
diff --git a/py_gen/oftype.py b/py_gen/oftype.py
index 3893865..76eebd0 100644
--- a/py_gen/oftype.py
+++ b/py_gen/oftype.py
@@ -110,7 +110,7 @@
'of_oxm_t': OFTypeData(
init='None',
pack='%s.pack()',
- unpack='oxm.oxm.unpack(%s)'),
+ unpack='ofp.oxm.oxm.unpack(%s)'),
'of_checksum_128_t': OFTypeData(
init='0',
@@ -144,11 +144,11 @@
# Map from class name to Python class name
embedded_structs = {
- 'of_match_t': 'common.match',
- 'of_port_desc_t': 'common.port_desc',
- 'of_meter_features_t': 'common.meter_features',
- 'of_bsn_vport_t': 'common.bsn_vport',
- 'of_table_desc_t': 'common.table_desc',
+ 'of_match_t': 'ofp.match',
+ 'of_port_desc_t': 'ofp.port_desc',
+ 'of_meter_features_t': 'ofp.meter_features',
+ 'of_bsn_vport_t': 'ofp.bsn_vport',
+ 'of_table_desc_t': 'ofp.table_desc',
}
for (cls, pyclass) in embedded_structs.items():
@@ -198,7 +198,7 @@
ofclass = ofproto.class_by_name(oftype_list_elem(oftype))
assert ofclass, "No class named %r" % oftype_list_elem(oftype)
module_name, class_name = py_gen.codegen.generate_pyname(ofclass)
- return 'loxi.generic_util.unpack_list(%s, %s.%s.unpack)' % \
+ return 'loxi.generic_util.unpack_list(%s, ofp.%s.%s.unpack)' % \
(reader_expr, module_name, class_name)
else:
return "loxi.unimplemented('unpack %s')" % oftype
diff --git a/py_gen/templates/_message_extra.py b/py_gen/templates/_message_extra.py
index 9fc2f5e..adfd0e7 100644
--- a/py_gen/templates/_message_extra.py
+++ b/py_gen/templates/_message_extra.py
@@ -32,8 +32,8 @@
def parse_message(buf):
msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
- if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO:
- raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
+ if msg_ver != ofp.OFP_VERSION and msg_type != ofp.OFPT_HELLO:
+ raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (ofp.OFP_VERSION, msg_ver))
if len(buf) != msg_len:
raise loxi.ProtocolError("incorrect message size")
return message.unpack(loxi.generic_util.OFReader(buf))
diff --git a/py_gen/templates/module.py b/py_gen/templates/module.py
index 331044d..32baac9 100644
--- a/py_gen/templates/module.py
+++ b/py_gen/templates/module.py
@@ -33,13 +33,12 @@
import struct
import loxi
-import const
-:: for module in modules:
-import ${module}
-:: #endfor
import util
import loxi.generic_util
+import sys
+ofp = sys.modules['loxi.${subdir}']
+
:: for ofclass in ofclasses:
:: include('_ofclass.py', ofclass=ofclass)