pyloxi: generate OXM classes
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index b8e014f..19bdbaf 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -68,6 +68,13 @@
type_values['subtype'] = type_maps.extension_action_to_subtype(cls, version)
elif utils.class_is_queue_prop(cls):
type_values['type'] = util.constant_for_value(version, "ofp_queue_properties", util.primary_wire_type(cls, version))
+ elif utils.class_is_oxm(cls):
+ 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)]
+ type_values['type_len'] = '%#x' % (oxm_class << 16 | oxm_type << 8 | \
+ oxm_masked << 8 | oxm_len)
return type_values
@@ -75,7 +82,7 @@
def build_ofclasses(version):
blacklist = ["of_action", "of_action_header", "of_header", "of_queue_prop",
"of_queue_prop_header", "of_experimenter", "of_action_experimenter",
- "of_oxm"]
+ "of_oxm", "of_oxm_header", "of_oxm_experimenter_header"]
ofclasses = []
for cls in of_g.standard_class_order:
if version not in of_g.unified[cls] or cls in blacklist:
@@ -85,6 +92,8 @@
# Name for the generated Python class
if utils.class_is_action(cls):
pyname = cls[10:]
+ elif utils.class_is_oxm(cls):
+ pyname = cls[7:]
else:
pyname = cls[3:]
@@ -131,17 +140,23 @@
return ofclasses
def generate_init(out, name, version):
- util.render_template(out, 'init.py')
+ util.render_template(out, 'init.py', version=version)
def generate_action(out, name, version):
ofclasses = [x for x in build_ofclasses(version)
if utils.class_is_action(x.name)]
util.render_template(out, 'action.py', ofclasses=ofclasses, version=version)
+def generate_oxm(out, name, version):
+ ofclasses = [x for x in build_ofclasses(version)
+ if utils.class_is_oxm(x.name)]
+ util.render_template(out, 'oxm.py', ofclasses=ofclasses, version=version)
+
def generate_common(out, name, version):
ofclasses = [x for x in build_ofclasses(version)
if not utils.class_is_message(x.name)
and not utils.class_is_action(x.name)
+ and not utils.class_is_oxm(x.name)
and not utils.class_is_list(x.name)]
util.render_template(out, 'common.py', ofclasses=ofclasses, version=version)