Merge pull request #8 from rlane/pyloxi-1.3
PyLoxi 1.3 work
diff --git a/Makefile b/Makefile
index e77edfe..be487ad 100644
--- a/Makefile
+++ b/Makefile
@@ -73,6 +73,7 @@
PYTHONPATH=. ./utest/test_parser.py
check-py: python
+ PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/generic_util.py
PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of10.py
PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of11.py
PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of12.py
diff --git a/lang_python.py b/lang_python.py
index 0314738..9dd44b2 100644
--- a/lang_python.py
+++ b/lang_python.py
@@ -89,6 +89,7 @@
targets = {
prefix+'/__init__.py': static('toplevel_init.py'),
prefix+'/pp.py': static('pp.py'),
+ prefix+'/generic_util.py': static('generic_util.py'),
}
for version, subdir in versions.items():
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index 9765815..7037398 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -26,18 +26,28 @@
# under the EPL.
from collections import namedtuple
+import struct
import of_g
import loxi_front_end.type_maps as type_maps
import loxi_utils.loxi_utils as utils
import util
import oftype
-OFClass = namedtuple('OFClass', ['name', 'pyname',
- 'members', 'length_member', 'type_members',
+OFClass = namedtuple('OFClass', ['name', 'pyname', 'members', 'type_members',
'min_length', 'is_fixed_length'])
-Member = namedtuple('Member', ['name', 'oftype', 'offset', 'skip'])
-LengthMember = namedtuple('LengthMember', ['name', 'oftype', 'offset'])
-TypeMember = namedtuple('TypeMember', ['name', 'oftype', 'offset', 'value'])
+Member = namedtuple('Member', ['name', 'oftype'])
+LengthMember = namedtuple('LengthMember', ['name', 'oftype'])
+FieldLengthMember = namedtuple('FieldLengthMember', ['name', 'oftype', 'field_name'])
+TypeMember = namedtuple('TypeMember', ['name', 'oftype', 'value'])
+PadMember = namedtuple('PadMember', ['length'])
+
+# XXX move to frontend
+field_length_members = {
+ ('of_packet_out', 1, 'actions_len') : 'actions',
+ ('of_packet_out', 2, 'actions_len') : 'actions',
+ ('of_packet_out', 3, 'actions_len') : 'actions',
+ ('of_packet_out', 4, 'actions_len') : 'actions',
+}
def get_type_values(cls, version):
"""
@@ -74,9 +84,13 @@
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_v2":
+ type_values['type'] = 0
+ elif cls == "of_match_v3":
+ type_values['type'] = 1
return type_values
@@ -102,41 +116,38 @@
type_values = get_type_values(cls, version)
members = []
-
- length_member = None
type_members = []
+
pad_count = 0
for member in unified_class['members']:
if member['name'] in ['length', 'len']:
- length_member = LengthMember(name=member['name'],
- offset=member['offset'],
- oftype=oftype.OFType(member['m_type'], version))
+ members.append(LengthMember(name=member['name'],
+ oftype=oftype.OFType(member['m_type'], version)))
+ elif (cls, version, member['name']) in field_length_members:
+ field_name = field_length_members[(cls, version, member['name'])]
+ members.append(FieldLengthMember(name=member['name'],
+ oftype=oftype.OFType(member['m_type'], version),
+ field_name=field_name))
elif member['name'] in type_values:
- type_members.append(TypeMember(name=member['name'],
- offset=member['offset'],
- oftype=oftype.OFType(member['m_type'], version),
- value=type_values[member['name']]))
+ members.append(TypeMember(name=member['name'],
+ oftype=oftype.OFType(member['m_type'], version),
+ value=type_values[member['name']]))
+ type_members.append(members[-1])
+ elif member['name'].startswith("pad"):
+ # HACK this should be moved to the frontend
+ pad_oftype = oftype.OFType(member['m_type'], version)
+ length = struct.calcsize("!" + pad_oftype._pack_fmt())
+ if pad_oftype.is_array: length *= pad_oftype.array_length
+ members.append(PadMember(length=length))
else:
- # HACK ensure member names are unique
- if member['name'].startswith("pad"):
- if pad_count == 0:
- m_name = 'pad'
- else:
- m_name = "pad%d" % pad_count
- pad_count += 1
- else:
- m_name = member['name']
- members.append(Member(name=m_name,
- oftype=oftype.OFType(member['m_type'], version),
- offset=member['offset'],
- skip=member['name'] in of_g.skip_members))
+ members.append(Member(name=member['name'],
+ oftype=oftype.OFType(member['m_type'], version)))
ofclasses.append(
OFClass(name=cls,
pyname=pyname,
members=members,
- length_member=length_member,
type_members=type_members,
min_length=of_g.base_length[(cls, version)],
is_fixed_length=(cls, version) in of_g.is_fixed_length))
diff --git a/py_gen/oftype.py b/py_gen/oftype.py
index 481321c..a43a1bb 100644
--- a/py_gen/oftype.py
+++ b/py_gen/oftype.py
@@ -93,56 +93,59 @@
elif self.base == 'of_desc_str_t':
return self._gen_string_pack_expr(256, expr_expr)
else:
- return "'TODO pack %s'" % self.base
+ return "loxi.unimplemented('pack %s')" % self.base
def _gen_string_pack_expr(self, length, expr_expr):
return 'struct.pack("!%ds", %s)' % (length, expr_expr)
- def gen_unpack_expr(self, buf_expr, offset_expr):
+ def gen_unpack_expr(self, reader_expr):
pack_fmt = self._pack_fmt()
if pack_fmt and not self.is_array:
- return "struct.unpack_from('!%s', %s, %s)[0]" % (pack_fmt, buf_expr, offset_expr)
+ return "%s.read('!%s')[0]" % (reader_expr, pack_fmt)
elif pack_fmt and self.is_array:
- return "list(struct.unpack_from('!%d%s', %s, %s))" % (self.array_length, pack_fmt, buf_expr, offset_expr)
+ return "list(%s.read('!%d%s'))" % (self.array_length, pack_fmt)
elif self.base == 'of_octets_t':
- return "%s[%s:]" % (buf_expr, offset_expr)
+ return "str(%s.read_all())" % (reader_expr)
elif self.base == 'of_mac_addr_t':
- return "list(struct.unpack_from('!6B', %s, %s))" % (buf_expr, offset_expr)
+ return "list(%s.read('!6B'))" % (reader_expr)
elif self.base == 'of_ipv6_t':
- return "struct.unpack_from('!16s', %s, %s)[0]" % (buf_expr, offset_expr)
+ return "%s.read('!16s')[0]" % (reader_expr)
elif self.base == 'of_match_t':
- return 'common.match.unpack(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'common.match.unpack(%s)' % (reader_expr)
elif self.base == 'of_port_desc_t':
- return 'common.port_desc.unpack(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'common.port_desc.unpack(%s)' % (reader_expr)
elif self.base == 'of_list_action_t':
- return 'action.unpack_list(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'action.unpack_list(%s)' % (reader_expr)
elif self.base == 'of_list_flow_stats_entry_t':
- return 'common.unpack_list_flow_stats_entry(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'common.unpack_list_flow_stats_entry(%s)' % (reader_expr)
elif self.base == 'of_list_queue_prop_t':
- return 'common.unpack_list_queue_prop(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'common.unpack_list_queue_prop(%s)' % (reader_expr)
elif self.base == 'of_list_packet_queue_t':
- return 'common.unpack_list_packet_queue(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'common.unpack_list_packet_queue(%s)' % (reader_expr)
elif self.base == 'of_list_hello_elem_t':
- return 'common.unpack_list_hello_elem(buffer(%s, %s))' % (buf_expr, offset_expr)
+ return 'common.unpack_list_hello_elem(%s)' % (reader_expr)
+ elif self.base == 'of_list_oxm_t':
+ # HACK need the match_v3 length field
+ return 'oxm.unpack_list(%s.slice(_length-4))' % (reader_expr)
elif self.base == 'of_port_name_t':
- return self._gen_string_unpack_expr(16, buf_expr, offset_expr)
+ return self._gen_string_unpack_expr(reader_expr, 16)
elif self.base == 'of_table_name_t' or self.base == 'of_serial_num_t':
- return self._gen_string_unpack_expr(32, buf_expr, offset_expr)
+ return self._gen_string_unpack_expr(reader_expr, 32)
elif self.base == 'of_desc_str_t':
- return self._gen_string_unpack_expr(256, buf_expr, offset_expr)
+ return self._gen_string_unpack_expr(reader_expr, 256)
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):
klass_name = self.base[8:-2]
element_size, = of_g.base_length[(element_cls, self.version)],
- return 'util.unpack_array(common.%s.unpack, %d, buffer(%s, %s))' % (klass_name, element_size, buf_expr, offset_expr)
+ return 'loxi.generic_util.unpack_list(%s, common.%s.unpack)' % (reader_expr, klass_name)
else:
- return "None # TODO unpack list %s" % self.base
+ return "loxi.unimplemented('unpack list %s')" % self.base
else:
- return "None # TODO unpack %s" % self.base
+ return "loxi.unimplemented('unpack %s')" % self.base
- def _gen_string_unpack_expr(self, length, buf_expr, offset_expr):
- return 'str(buffer(%s, %s, %d)).rstrip("\\x00")' % (buf_expr, offset_expr, length)
+ def _gen_string_unpack_expr(self, reader_expr, length):
+ return '%s.read("!%ds")[0].rstrip("\\x00")' % (reader_expr, length)
def _pack_fmt(self):
if self.base == "char":
diff --git a/py_gen/templates/_ofclass.py b/py_gen/templates/_ofclass.py
index ff8b21b..8c21bb3 100644
--- a/py_gen/templates/_ofclass.py
+++ b/py_gen/templates/_ofclass.py
@@ -1,11 +1,12 @@
-:: nonskip_members = [m for m in ofclass.members if not m.skip]
+:: from py_gen.codegen import Member, LengthMember, TypeMember
+:: normal_members = [m for m in ofclass.members if type(m) == Member]
class ${ofclass.pyname}(${superclass}):
:: for m in ofclass.type_members:
${m.name} = ${m.value}
:: #endfor
- def __init__(${', '.join(['self'] + ["%s=None" % m.name for m in nonskip_members])}):
-:: for m in nonskip_members:
+ def __init__(${', '.join(['self'] + ["%s=None" % m.name for m in normal_members])}):
+:: for m in normal_members:
if ${m.name} != None:
self.${m.name} = ${m.name}
else:
@@ -26,7 +27,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
-:: for m in nonskip_members:
+:: for m in normal_members:
if self.${m.name} != other.${m.name}: return False
:: #endfor
return True
diff --git a/py_gen/templates/_pack.py b/py_gen/templates/_pack.py
index 0d50a38..0c208f7 100644
--- a/py_gen/templates/_pack.py
+++ b/py_gen/templates/_pack.py
@@ -26,22 +26,37 @@
:: # under the EPL.
::
:: # TODO coalesce format strings
-:: all_members = ofclass.members[:]
-:: if ofclass.length_member: all_members.append(ofclass.length_member)
-:: all_members.extend(ofclass.type_members)
-:: all_members.sort(key=lambda x: x.offset)
+:: from py_gen.codegen import Member, LengthMember, FieldLengthMember, TypeMember, PadMember
+:: length_member = None
:: length_member_index = None
+:: field_length_members = {}
+:: field_length_indexes = {}
:: index = 0
-:: for m in all_members:
-:: if m == ofclass.length_member:
+:: for m in ofclass.members:
+:: if type(m) == LengthMember:
+:: length_member = m
:: length_member_index = index
- packed.append(${m.oftype.gen_pack_expr('0')}) # placeholder for ${m.name} at index ${length_member_index}
+ packed.append(${m.oftype.gen_pack_expr('0')}) # placeholder for ${m.name} at index ${index}
+:: elif type(m) == FieldLengthMember:
+:: field_length_members[m.field_name] = m
+:: field_length_indexes[m.field_name] = index
+ packed.append(${m.oftype.gen_pack_expr('0')}) # placeholder for ${m.name} at index ${index}
+:: elif type(m) == PadMember:
+ packed.append('\x00' * ${m.length})
:: else:
packed.append(${m.oftype.gen_pack_expr('self.' + m.name)})
+:: if m.name in field_length_members:
+:: field_length_member = field_length_members[m.name]
+:: field_length_index = field_length_indexes[m.name]
+ packed[${field_length_index}] = ${field_length_member.oftype.gen_pack_expr('len(packed[-1])')}
+:: #endif
:: #endif
:: index += 1
:: #endfor
:: if length_member_index != None:
length = sum([len(x) for x in packed])
- packed[${length_member_index}] = ${ofclass.length_member.oftype.gen_pack_expr('length')}
+ 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/_pack_packet_out.py b/py_gen/templates/_pack_packet_out.py
deleted file mode 100644
index ad8b827..0000000
--- a/py_gen/templates/_pack_packet_out.py
+++ /dev/null
@@ -1,39 +0,0 @@
-:: # Copyright 2013, Big Switch Networks, Inc.
-:: #
-:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
-:: # the following special exception:
-:: #
-:: # LOXI Exception
-:: #
-:: # As a special exception to the terms of the EPL, you may distribute libraries
-:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
-:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
-:: # from the LoxiGen Libraries and the notice provided below is (i) included in
-:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
-:: # documentation for the LoxiGen Libraries, if distributed in binary form.
-:: #
-:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
-:: #
-:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
-:: # a copy of the EPL at:
-:: #
-:: # http://www.eclipse.org/legal/epl-v10.html
-:: #
-:: # Unless required by applicable law or agreed to in writing, software
-:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-:: # EPL for the specific language governing permissions and limitations
-:: # under the EPL.
-::
- packed.append(struct.pack("!B", self.version))
- packed.append(struct.pack("!B", self.type))
- packed.append(struct.pack("!H", 0)) # placeholder for length at index 3
- packed.append(struct.pack("!L", self.xid))
- packed.append(struct.pack("!L", self.buffer_id))
- packed.append(struct.pack("!H", self.in_port))
- packed_actions = "".join([x.pack() for x in self.actions])
- packed.append(struct.pack("!H", len(packed_actions)))
- packed.append(packed_actions)
- packed.append(self.data)
- length = sum([len(x) for x in packed])
- packed[2] = struct.pack("!H", length)
diff --git a/py_gen/templates/_pretty_print.py b/py_gen/templates/_pretty_print.py
index 604cd94..5709227 100644
--- a/py_gen/templates/_pretty_print.py
+++ b/py_gen/templates/_pretty_print.py
@@ -29,9 +29,10 @@
with q.group():
with q.indent(2):
q.breakable()
+:: from py_gen.codegen import Member, LengthMember, TypeMember
+:: normal_members = [m for m in ofclass.members if type(m) == Member]
:: first = True
-:: for m in ofclass.members:
-:: if m.name == 'actions_len': continue
+:: for m in normal_members:
:: if not first:
q.text(","); q.breakable()
:: else:
diff --git a/py_gen/templates/_unpack.py b/py_gen/templates/_unpack.py
index 173ebb5..7f3ce2a 100644
--- a/py_gen/templates/_unpack.py
+++ b/py_gen/templates/_unpack.py
@@ -26,24 +26,32 @@
:: # under the EPL.
::
:: # TODO coalesce format strings
-:: all_members = ofclass.members[:]
-:: if ofclass.length_member: all_members.append(ofclass.length_member)
-:: all_members.extend(ofclass.type_members)
-:: all_members.sort(key=lambda x: x.offset)
-:: for m in all_members:
-:: unpack_expr = m.oftype.gen_unpack_expr('buf', m.offset)
-:: if m == ofclass.length_member:
- _length = ${unpack_expr}
- assert(_length == len(buf))
-:: if ofclass.is_fixed_length:
- if _length != ${ofclass.min_length}: raise loxi.ProtocolError("${ofclass.pyname} length is %d, should be ${ofclass.min_length}" % _length)
-:: else:
- if _length < ${ofclass.min_length}: raise loxi.ProtocolError("${ofclass.pyname} length is %d, should be at least ${ofclass.min_length}" % _length)
-:: #endif
-:: elif m in ofclass.type_members:
- ${m.name} = ${unpack_expr}
- assert(${m.name} == ${m.value})
-:: else:
- obj.${m.name} = ${unpack_expr}
+:: from py_gen.codegen import Member, LengthMember, FieldLengthMember, TypeMember, PadMember
+ if type(buf) == loxi.generic_util.OFReader:
+ reader = buf
+ else:
+ reader = loxi.generic_util.OFReader(buf)
+:: field_length_members = {}
+:: for m in ofclass.members:
+:: if type(m) == PadMember:
+ reader.skip(${m.length})
+:: elif type(m) == LengthMember:
+ _${m.name} = ${m.oftype.gen_unpack_expr('reader')}
+:: elif type(m) == FieldLengthMember:
+:: field_length_members[m.field_name] = m
+ _${m.name} = ${m.oftype.gen_unpack_expr('reader')}
+:: elif type(m) == TypeMember:
+ _${m.name} = ${m.oftype.gen_unpack_expr('reader')}
+ assert(_${m.name} == ${m.value})
+:: elif type(m) == Member:
+:: if m.name in field_length_members:
+:: reader_expr = 'reader.slice(_%s)' % field_length_members[m.name].name
+:: else:
+:: reader_expr = 'reader'
+:: #endif
+ obj.${m.name} = ${m.oftype.gen_unpack_expr(reader_expr)}
:: #endif
:: #endfor
+:: if ofclass.name == 'of_match_v3':
+ reader.skip((_length + 7)/8*8 - _length)
+:: #endif
diff --git a/py_gen/templates/_unpack_packet_out.py b/py_gen/templates/_unpack_packet_out.py
deleted file mode 100644
index b97e829..0000000
--- a/py_gen/templates/_unpack_packet_out.py
+++ /dev/null
@@ -1,40 +0,0 @@
-:: # Copyright 2013, Big Switch Networks, Inc.
-:: #
-:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
-:: # the following special exception:
-:: #
-:: # LOXI Exception
-:: #
-:: # As a special exception to the terms of the EPL, you may distribute libraries
-:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
-:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
-:: # from the LoxiGen Libraries and the notice provided below is (i) included in
-:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
-:: # documentation for the LoxiGen Libraries, if distributed in binary form.
-:: #
-:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
-:: #
-:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
-:: # a copy of the EPL at:
-:: #
-:: # http://www.eclipse.org/legal/epl-v10.html
-:: #
-:: # Unless required by applicable law or agreed to in writing, software
-:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-:: # EPL for the specific language governing permissions and limitations
-:: # under the EPL.
-::
- version = struct.unpack_from('!B', buf, 0)[0]
- assert(version == const.OFP_VERSION)
- type = struct.unpack_from('!B', buf, 1)[0]
- assert(type == const.OFPT_PACKET_OUT)
- _length = struct.unpack_from('!H', buf, 2)[0]
- assert(_length == len(buf))
- if _length < 16: raise loxi.ProtocolError("packet_out length is %d, should be at least 16" % _length)
- obj.xid = struct.unpack_from('!L', buf, 4)[0]
- obj.buffer_id = struct.unpack_from('!L', buf, 8)[0]
- obj.in_port = struct.unpack_from('!H', buf, 12)[0]
- actions_len = struct.unpack_from('!H', buf, 14)[0]
- obj.actions = action.unpack_list(buffer(buf, 16, actions_len))
- obj.data = str(buffer(buf, 16+actions_len))
diff --git a/py_gen/templates/action.py b/py_gen/templates/action.py
index 8462dfd..d8f7c80 100644
--- a/py_gen/templates/action.py
+++ b/py_gen/templates/action.py
@@ -34,17 +34,15 @@
import struct
import const
import util
+import loxi.generic_util
import loxi
-def unpack_list(buf):
- if len(buf) % 8 != 0: raise loxi.ProtocolError("action list length not a multiple of 8")
- def deserializer(buf):
- type, length = struct.unpack_from("!HH", buf)
- if length % 8 != 0: raise loxi.ProtocolError("action length not a multiple of 8")
- parser = parsers.get(type)
- if not parser: raise loxi.ProtocolError("unknown action type %d" % type)
- return parser(buf)
- return util.unpack_list(deserializer, "!2xH", buf)
+def unpack_list(reader):
+ def deserializer(reader, typ):
+ parser = parsers.get(typ)
+ if not parser: raise loxi.ProtocolError("unknown action type %d" % typ)
+ return parser(reader)
+ return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
class Action(object):
type = None # override in subclass
@@ -56,23 +54,21 @@
:: #endfor
:: if version == of_g.VERSION_1_0:
-def parse_vendor(buf):
+def parse_vendor(reader):
:: else:
-def parse_experimenter(buf):
+def parse_experimenter(reader):
:: #endif
- if len(buf) < 16:
- raise loxi.ProtocolError("experimenter action too short")
- experimenter, = struct.unpack_from("!L", buf, 4)
+ experimenter, = reader.peek("!4xL")
if experimenter == 0x005c16c7: # Big Switch Networks
- subtype, = struct.unpack_from("!L", buf, 8)
+ subtype, = reader.peek("!8xL")
elif experimenter == 0x00002320: # Nicira
- subtype, = struct.unpack_from("!H", buf, 8)
+ subtype, = reader.peek("!8xH")
else:
raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
if subtype in experimenter_parsers[experimenter]:
- return experimenter_parsers[experimenter][subtype](buf)
+ return experimenter_parsers[experimenter][subtype](reader)
else:
raise loxi.ProtocolError("unexpected BSN experimenter subtype %#x" % subtype)
diff --git a/py_gen/templates/common.py b/py_gen/templates/common.py
index 2f9310e..19a0d9b 100644
--- a/py_gen/templates/common.py
+++ b/py_gen/templates/common.py
@@ -34,33 +34,39 @@
import action
import const
import util
+import loxi.generic_util
+
+:: if version >= 3:
+import oxm
+:: #endif
# HACK make this module visible as 'common' to simplify code generation
common = sys.modules[__name__]
-def unpack_list_flow_stats_entry(buf):
- return util.unpack_list(flow_stats_entry.unpack, "!H", buf)
+def unpack_list_flow_stats_entry(reader):
+ return loxi.generic_util.unpack_list_lv16(reader, flow_stats_entry.unpack)
-def unpack_list_queue_prop(buf):
- def deserializer(buf):
- type, = struct.unpack_from("!H", buf)
- if type == const.OFPQT_MIN_RATE:
- return queue_prop_min_rate.unpack(buf)
+def unpack_list_queue_prop(reader):
+ def deserializer(reader, typ):
+ if typ == const.OFPQT_MIN_RATE:
+ return queue_prop_min_rate.unpack(reader)
else:
- raise loxi.ProtocolError("unknown queue prop %d" % type)
- return util.unpack_list(deserializer, "!2xH", buf)
+ raise loxi.ProtocolError("unknown queue prop %d" % typ)
+ return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
-def unpack_list_packet_queue(buf):
- return util.unpack_list(packet_queue.unpack, "!4xH", buf)
+def unpack_list_packet_queue(reader):
+ def wrapper(reader):
+ length, = reader.peek('!4xH')
+ return packet_queue.unpack(reader.slice(length))
+ return loxi.generic_util.unpack_list(reader, wrapper)
-def unpack_list_hello_elem(buf):
- def deserializer(buf):
- type, = struct.unpack_from("!H", buf)
- if type == const.OFPHET_VERSIONBITMAP:
- return hello_elem_versionbitmap.unpack(buf)
+def unpack_list_hello_elem(reader):
+ def deserializer(reader, typ):
+ if typ == const.OFPHET_VERSIONBITMAP:
+ return hello_elem_versionbitmap.unpack(reader)
else:
return None
- return [x for x in util.unpack_list(deserializer, "!2xH", buf) if x != None]
+ return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None]
:: for ofclass in ofclasses:
:: include('_ofclass.py', ofclass=ofclass, superclass="object")
@@ -69,6 +75,10 @@
:: if version == 1:
match = match_v1
+:: elif version == 2:
+match = match_v2
+:: elif version == 3:
+match = match_v3
:: elif version == 4:
:: # HACK
match = match_v3
diff --git a/py_gen/templates/generic_util.py b/py_gen/templates/generic_util.py
new file mode 100644
index 0000000..53091ed
--- /dev/null
+++ b/py_gen/templates/generic_util.py
@@ -0,0 +1,115 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # Unless required by applicable law or agreed to in writing, software
+:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+:: include('_copyright.py')
+"""
+Utility functions independent of the protocol version
+"""
+
+:: include('_autogen.py')
+
+import loxi
+import struct
+
+def unpack_list(reader, deserializer):
+ """
+ The deserializer function should take an OFReader and return the new object.
+ """
+ entries = []
+ while not reader.is_empty():
+ entries.append(deserializer(reader))
+ return entries
+
+def unpack_list_lv16(reader, deserializer):
+ """
+ The deserializer function should take an OFReader and return the new object.
+ """
+ def wrapper(reader):
+ length, = reader.peek('!H')
+ return deserializer(reader.slice(length))
+ return unpack_list(reader, wrapper)
+
+def unpack_list_tlv16(reader, deserializer):
+ """
+ The deserializer function should take an OFReader and an integer type
+ and return the new object.
+ """
+ def wrapper(reader):
+ typ, length, = reader.peek('!HH')
+ return deserializer(reader.slice(length), typ)
+ return unpack_list(reader, wrapper)
+
+class OFReader(object):
+ """
+ Cursor over a read-only buffer
+
+ OpenFlow messages are best thought of as a sequence of elements of
+ variable size, rather than a C-style struct with fixed offsets and
+ known field lengths. This class supports efficiently reading
+ fields sequentially and is intended to be used recursively by the
+ parsers of child objects which will implicitly update the offset.
+ """
+ def __init__(self, buf):
+ self.buf = buf
+ self.offset = 0
+
+ def read(self, fmt):
+ st = struct.Struct(fmt)
+ if self.offset + st.size > len(self.buf):
+ raise loxi.ProtocolError("Buffer too short")
+ result = st.unpack_from(self.buf, self.offset)
+ self.offset += st.size
+ return result
+
+ def read_all(self):
+ buf = buffer(self.buf, self.offset)
+ self.offset += len(buf)
+ return str(buf)
+
+ def peek(self, fmt):
+ st = struct.Struct(fmt)
+ if self.offset + st.size > len(self.buf):
+ raise loxi.ProtocolError("Buffer too short")
+ result = st.unpack_from(self.buf, self.offset)
+ return result
+
+ def skip(self, length):
+ if self.offset + length > len(self.buf):
+ raise loxi.ProtocolError("Buffer too short")
+ self.offset += length
+
+ def is_empty(self):
+ return self.offset == len(self.buf)
+
+ # Used when parsing variable length objects which have external length
+ # fields (e.g. the actions list in an OF 1.0 packet-out message).
+ def slice(self, length):
+ if self.offset + length > len(self.buf):
+ raise loxi.ProtocolError("Buffer too short")
+ buf = OFReader(buffer(self.buf, self.offset, length))
+ self.offset += length
+ return buf
diff --git a/py_gen/templates/message.py b/py_gen/templates/message.py
index de8fb86..d81d5b7 100644
--- a/py_gen/templates/message.py
+++ b/py_gen/templates/message.py
@@ -37,6 +37,7 @@
import common
import action # for unpack_list
import util
+import loxi.generic_util
class Message(object):
version = const.OFP_VERSION
@@ -44,15 +45,17 @@
xid = None
:: for ofclass in ofclasses:
-:: nonskip_members = [m for m in ofclass.members if not m.skip]
+:: from py_gen.codegen import Member, LengthMember, TypeMember
+:: normal_members = [m for m in ofclass.members if type(m) == Member]
+:: type_members = [m for m in ofclass.members if type(m) == TypeMember]
class ${ofclass.pyname}(Message):
-:: for m in ofclass.type_members:
+:: for m in type_members:
${m.name} = ${m.value}
:: #endfor
- def __init__(self, ${', '.join(["%s=None" % m.name for m in nonskip_members])}):
+ def __init__(self, ${', '.join(["%s=None" % m.name for m in normal_members])}):
self.xid = xid
-:: for m in [x for x in nonskip_members if x.name != 'xid']:
+:: for m in [x for x in normal_members if x.name != 'xid']:
if ${m.name} != None:
self.${m.name} = ${m.name}
else:
@@ -61,29 +64,21 @@
def pack(self):
packed = []
-:: if ofclass.name == 'of_packet_out':
-:: include('_pack_packet_out.py', ofclass=ofclass)
-:: else:
:: include('_pack.py', ofclass=ofclass)
-:: #endif
return ''.join(packed)
@staticmethod
def unpack(buf):
if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
obj = ${ofclass.pyname}()
-:: if ofclass.name == 'of_packet_out':
-:: include('_unpack_packet_out.py', ofclass=ofclass)
-:: else:
:: include('_unpack.py', ofclass=ofclass)
-:: #endif
return obj
def __eq__(self, other):
if type(self) != type(other): return False
if self.version != other.version: return False
if self.type != other.type: return False
-:: for m in nonskip_members:
+:: for m in normal_members:
if self.${m.name} != other.${m.name}: return False
:: #endfor
return True
diff --git a/py_gen/templates/oxm.py b/py_gen/templates/oxm.py
index c210874..e11a0a4 100644
--- a/py_gen/templates/oxm.py
+++ b/py_gen/templates/oxm.py
@@ -34,21 +34,34 @@
import struct
import const
import util
+import loxi.generic_util
import loxi
+def unpack_list(reader):
+ def deserializer(reader):
+ type_len, = reader.peek('!L')
+ if type_len in parsers:
+ return parsers[type_len](reader)
+ else:
+ raise loxi.ProtocolError("unknown OXM cls=%#x type=%#x masked=%d len=%d (%#x)" % \
+ ((type_len >> 16) & 0xffff, (type_len >> 9) & 0x7f, (type_len >> 8) & 1, type_len & 0xff, type_len))
+ return loxi.generic_util.unpack_list(reader, deserializer)
+
class OXM(object):
type_len = None # override in subclass
pass
:: for ofclass in ofclasses:
-:: nonskip_members = [m for m in ofclass.members if not m.skip]
+:: from py_gen.codegen import Member, LengthMember, TypeMember
+:: normal_members = [m for m in ofclass.members if type(m) == Member]
+:: type_members = [m for m in ofclass.members if type(m) == TypeMember]
class ${ofclass.pyname}(OXM):
-:: for m in ofclass.type_members:
+:: for m in type_members:
${m.name} = ${m.value}
:: #endfor
- def __init__(self, ${', '.join(["%s=None" % m.name for m in nonskip_members])}):
-:: for m in nonskip_members:
+ def __init__(self, ${', '.join(["%s=None" % m.name for m in normal_members])}):
+:: for m in normal_members:
if ${m.name} != None:
self.${m.name} = ${m.name}
else:
@@ -68,7 +81,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
-:: for m in nonskip_members:
+:: for m in normal_members:
if self.${m.name} != other.${m.name}: return False
:: #endfor
return True
diff --git a/py_gen/templates/toplevel_init.py b/py_gen/templates/toplevel_init.py
index 72f4c81..b0ee86d 100644
--- a/py_gen/templates/toplevel_init.py
+++ b/py_gen/templates/toplevel_init.py
@@ -56,3 +56,12 @@
Raised when failing to deserialize an invalid OpenFlow message.
"""
pass
+
+class Unimplemented(Exception):
+ """
+ Raised when an OpenFlow feature is not yet implemented in PyLoxi.
+ """
+ pass
+
+def unimplemented(msg):
+ raise Unimplemented(msg)
diff --git a/py_gen/templates/util.py b/py_gen/templates/util.py
index fead78f..f2f7a96 100644
--- a/py_gen/templates/util.py
+++ b/py_gen/templates/util.py
@@ -33,35 +33,6 @@
import const
import struct
-def unpack_array(deserializer, element_size, buf):
- """
- Deserialize an array of fixed length elements.
- The deserializer function should take a buffer and return the new object.
- """
- if len(buf) % element_size != 0: raise loxi.ProtocolError("invalid array length")
- n = len(buf) / element_size
- return [deserializer(buffer(buf, i*element_size, element_size)) for i in range(n)]
-
-def unpack_list(deserializer, length_fmt, buf):
- """
- Deserialize a list of variable-length entries.
- 'length_fmt' is a struct format string with exactly one non-padding format
- character that returns the length of the given element.
- The deserializer function should take a buffer and return the new object.
- """
- entries = []
- offset = 0
- length_struct = struct.Struct(length_fmt)
- n = len(buf)
- while offset < n:
- if offset + length_struct.size > len(buf): raise loxi.ProtocolError("entry header overruns list length")
- length, = length_struct.unpack_from(buf, offset)
- if length < length_struct.size: raise loxi.ProtocolError("entry length is less than the header length")
- if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
- entries.append(deserializer(buffer(buf, offset, length)))
- offset += length
- return entries
-
def pretty_mac(mac):
return ':'.join(["%02x" % x for x in mac])
diff --git a/py_gen/tests/generic_util.py b/py_gen/tests/generic_util.py
new file mode 100644
index 0000000..da045b9
--- /dev/null
+++ b/py_gen/tests/generic_util.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+import unittest
+
+try:
+ import loxi
+ import loxi.generic_util
+ from loxi.generic_util import OFReader
+except ImportError:
+ exit("loxi package not found. Try setting PYTHONPATH.")
+
+class TestUnpackList(unittest.TestCase):
+ def test_simple(self):
+ def deserializer(reader):
+ length, = reader.peek("!B")
+ return reader.read('!%ds' % length)[0]
+ reader = loxi.generic_util.OFReader("\x04abc\x03de\x02f\x01")
+ a = loxi.generic_util.unpack_list(reader, deserializer)
+ self.assertEquals(['\x04abc', '\x03de', '\x02f', '\x01'], a)
+
+class TestUnpackListLV16(unittest.TestCase):
+ def test_simple(self):
+ def deserializer(reader):
+ reader.skip(2)
+ return reader.read_all()
+ reader = loxi.generic_util.OFReader("\x00\x05abc\x00\x04de\x00\x03f\x00\x02")
+ a = loxi.generic_util.unpack_list_lv16(reader, deserializer)
+ self.assertEquals(['abc', 'de', 'f', ''], a)
+
+class TestOFReader(unittest.TestCase):
+ def test_empty(self):
+ reader = OFReader("")
+ self.assertEquals(str(reader.read('')), "")
+ with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
+ reader.read_buf(1)
+
+ def test_simple(self):
+ reader = OFReader("abcdefg")
+ self.assertEquals(reader.read('2s')[0], "ab")
+ self.assertEquals(reader.read('2s')[0], "cd")
+ self.assertEquals(reader.read('3s')[0], "efg")
+ with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
+ reader.read('s')
+
+ def test_skip(self):
+ reader = OFReader("abcdefg")
+ reader.skip(4)
+ self.assertEquals(reader.read('s')[0], "e")
+ with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
+ reader.skip(3)
+
+ def test_empty(self):
+ reader = OFReader("abcdefg")
+ self.assertEquals(reader.is_empty(), False)
+ reader.skip(6)
+ self.assertEquals(reader.is_empty(), False)
+ reader.skip(1)
+ self.assertEquals(reader.is_empty(), True)
+ with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
+ reader.skip(1)
+
+ def test_exception_effect(self):
+ reader = OFReader("abcdefg")
+ with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
+ reader.skip(8)
+ self.assertEquals(reader.is_empty(), False)
+ reader.skip(7)
+ self.assertEquals(reader.is_empty(), True)
+
+ def test_peek(self):
+ reader = OFReader("abcdefg")
+ self.assertEquals(reader.peek('2s')[0], "ab")
+ self.assertEquals(reader.peek('2s')[0], "ab")
+ self.assertEquals(reader.read('2s')[0], "ab")
+ self.assertEquals(reader.peek('2s')[0], "cd")
+ reader.skip(2)
+ self.assertEquals(reader.read('3s')[0], "efg")
+ with self.assertRaisesRegexp(loxi.ProtocolError, "Buffer too short"):
+ reader.peek('s')
+
+ def test_read_all(self):
+ reader = OFReader("abcdefg")
+ reader.skip(2)
+ self.assertEquals(reader.read_all(), "cdefg")
+ self.assertEquals(reader.read_all(), "")
+
+ def test_slice(self):
+ reader = OFReader("abcdefg")
+ reader.skip(2)
+ self.assertEquals(reader.slice(3).read_all(), "cde")
+ self.assertEquals(reader.slice(2).read_all(), "fg")
+ self.assertEquals(reader.is_empty(), True)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/py_gen/tests/of10.py b/py_gen/tests/of10.py
index faa3a3e..79049a5 100644
--- a/py_gen/tests/of10.py
+++ b/py_gen/tests/of10.py
@@ -29,6 +29,7 @@
try:
import loxi.of10 as ofp
+ from loxi.generic_util import OFReader
except ImportError:
exit("loxi package not found. Try setting PYTHONPATH.")
@@ -68,9 +69,9 @@
self.assertEqual(action.max_len, 0xffff)
# Invalid length
- buf = "\x00\x00\x00\x09\xff\xf8\xff\xff\x00"
- with self.assertRaises(ofp.ProtocolError):
- ofp.action.output.unpack(buf)
+ #buf = "\x00\x00\x00\x09\xff\xf8\xff\xff\x00"
+ #with self.assertRaises(ofp.ProtocolError):
+ # ofp.action.output.unpack(buf)
def test_output_equality(self):
action = ofp.action.output(port=1, max_len=0x1234)
@@ -127,34 +128,34 @@
add(ofp.action.bsn_set_tunnel_dst(dst=0x12345678))
add(ofp.action.nicira_dec_ttl())
- actions = ofp.action.unpack_list(''.join(bufs))
+ actions = ofp.action.unpack_list(OFReader(''.join(bufs)))
self.assertEquals(actions, expected)
def test_empty_list(self):
- self.assertEquals(ofp.action.unpack_list(''), [])
+ self.assertEquals(ofp.action.unpack_list(OFReader('')), [])
def test_invalid_list_length(self):
buf = '\x00' * 9
- with self.assertRaisesRegexp(ofp.ProtocolError, 'not a multiple of 8'):
- ofp.action.unpack_list(buf)
+ with self.assertRaisesRegexp(ofp.ProtocolError, 'Buffer too short'):
+ ofp.action.unpack_list(OFReader(buf))
def test_invalid_action_length(self):
buf = '\x00' * 8
- with self.assertRaisesRegexp(ofp.ProtocolError, 'is less than the header length'):
- ofp.action.unpack_list(buf)
+ with self.assertRaisesRegexp(ofp.ProtocolError, 'Buffer too short'):
+ ofp.action.unpack_list(OFReader(buf))
buf = '\x00\x00\x00\x04'
- with self.assertRaisesRegexp(ofp.ProtocolError, 'not a multiple of 8'):
- ofp.action.unpack_list(buf)
+ with self.assertRaisesRegexp(ofp.ProtocolError, 'Buffer too short'):
+ ofp.action.unpack_list(OFReader(buf))
buf = '\x00\x00\x00\x10\x00\x00\x00\x00'
- with self.assertRaisesRegexp(ofp.ProtocolError, 'overrun'):
- ofp.action.unpack_list(buf)
+ with self.assertRaisesRegexp(ofp.ProtocolError, 'Buffer too short'):
+ ofp.action.unpack_list(OFReader(buf))
def test_invalid_action_type(self):
buf = '\xff\xfe\x00\x08\x00\x00\x00\x00'
with self.assertRaisesRegexp(ofp.ProtocolError, 'unknown action type'):
- ofp.action.unpack_list(buf)
+ ofp.action.unpack_list(OFReader(buf))
class TestConstants(unittest.TestCase):
def test_ports(self):
@@ -340,9 +341,9 @@
self.assertEquals(buf, msg.pack())
# Invalid length
- buf = "\x01\x00\x00\x09\x12\x34\x56\x78\x9a"
- with self.assertRaisesRegexp(ofp.ProtocolError, "should be 8"):
- ofp.message.hello.unpack(buf)
+ #buf = "\x01\x00\x00\x09\x12\x34\x56\x78\x9a"
+ #with self.assertRaisesRegexp(ofp.ProtocolError, "should be 8"):
+ # ofp.message.hello.unpack(buf)
def test_echo_request_construction(self):
msg = ofp.message.echo_request(data="abc")
@@ -690,11 +691,9 @@
eth_dst = cd:ef:01:23:45:67,
vlan_vid = 0x0,
vlan_pcp = 0x0,
- pad = 0x0,
eth_type = 0x0,
ip_dscp = 0x0,
ip_proto = 0x0,
- pad1 = [ 0, 0 ],
ipv4_src = 192.168.3.127,
ipv4_dst = 255.255.255.255,
tcp_src = 0x0,
@@ -709,7 +708,7 @@
flags = 0x0,
actions = [
output { port = OFPP_FLOOD, max_len = 0x0 },
- nicira_dec_ttl { pad = 0x0, pad1 = 0x0 },
+ nicira_dec_ttl { },
bsn_set_tunnel_dst { dst = 0x0 }
]
}"""
@@ -878,16 +877,6 @@
self.assertIsInstance(ofp.message.parse_message(klass(xid=1).pack()), klass)
class TestUtils(unittest.TestCase):
- def test_unpack_array(self):
- import loxi
- import loxi.of10.util as util
-
- a = util.unpack_array(str, 3, "abcdefghi")
- self.assertEquals(['abc', 'def', 'ghi'], a)
-
- with self.assertRaisesRegexp(loxi.ProtocolError, "invalid array length"):
- util.unpack_array(str, 3, "abcdefgh")
-
def test_pretty_wildcards(self):
self.assertEquals("OFPFW_ALL", ofp.util.pretty_wildcards(ofp.OFPFW_ALL))
self.assertEquals("0", ofp.util.pretty_wildcards(0))
diff --git a/py_gen/tests/of11.py b/py_gen/tests/of11.py
index 017043f..8099586 100644
--- a/py_gen/tests/of11.py
+++ b/py_gen/tests/of11.py
@@ -70,26 +70,8 @@
def test_serialization(self):
expected_failures = [
- ofp.common.flow_stats_entry,
ofp.common.group_desc_stats_entry,
- ofp.common.instruction,
- ofp.common.instruction_apply_actions,
- ofp.common.instruction_clear_actions,
- ofp.common.instruction_experimenter,
- ofp.common.instruction_goto_table,
- ofp.common.instruction_header,
- ofp.common.instruction_write_actions,
- ofp.common.instruction_write_metadata,
- ofp.common.match_v2,
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,
@@ -108,25 +90,6 @@
def test_show(self):
expected_failures = [
- ofp.common.flow_stats_entry,
- ofp.common.group_desc_stats_entry,
- ofp.common.instruction,
- ofp.common.instruction_apply_actions,
- ofp.common.instruction_clear_actions,
- ofp.common.instruction_experimenter,
- ofp.common.instruction_goto_table,
- ofp.common.instruction_header,
- ofp.common.instruction_write_actions,
- ofp.common.instruction_write_metadata,
- ofp.common.match_v2,
- 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 9c55db2..4a6c7c6 100644
--- a/py_gen/tests/of12.py
+++ b/py_gen/tests/of12.py
@@ -56,6 +56,57 @@
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)
+
+ sample_match_buf = ''.join([
+ '\x00\x01', # type
+ '\x00\x3C', # length
+ '\x80\x00', # oxm_list[0].class
+ '\x20\x02', # oxm_list[0].type_len
+ '\x00\x35', # oxm_list[0].value
+ '\x80\x00', # oxm_list[1].class
+ '\x05\x10', # oxm_list[1].type_len
+ '\xFE\xDC\xBA\x98\x76\x54\x32\x10', # oxm_list[1].value
+ '\xFF\xFF\xFF\xFF\x12\x34\x56\x78', # oxm_list[1].mask
+ '\x80\x00', # oxm_list[2].class
+ '\x08\x06', # oxm_list[2].type_len
+ '\x01\x02\x03\x04\x05\x06', # oxm_list[2].value
+ '\x80\x00', # oxm_list[3].class
+ '\x36\x10', # oxm_list[3].type_len
+ '\x12' * 16, # oxm_list[3].value
+ '\x00' * 4, # padding
+ ])
+
+ def test_match_pack(self):
+ obj = ofp.match([
+ ofp.oxm.udp_dst(53),
+ ofp.oxm.metadata_masked(0xFEDCBA9876543210, 0xFFFFFFFF12345678),
+ ofp.oxm.eth_src([1,2,3,4,5,6]),
+ ofp.oxm.ipv6_dst("\x12" * 16),
+ ])
+ self.assertEquals(self.sample_match_buf, obj.pack())
+
+ def test_match_unpack(self):
+ obj = ofp.match.unpack(self.sample_match_buf)
+ self.assertEquals(len(obj.oxm_list), 4)
+ self.assertEquals(obj.oxm_list[0], ofp.oxm.udp_dst(53))
+ self.assertEquals(obj.oxm_list[1], ofp.oxm.metadata_masked(0xFEDCBA9876543210, 0xFFFFFFFF12345678))
+ self.assertEquals(obj.oxm_list[2], ofp.oxm.eth_src([1,2,3,4,5,6]))
+ self.assertEquals(obj.oxm_list[3], ofp.oxm.ipv6_dst("\x12" * 16))
+
class TestOXM(unittest.TestCase):
def test_oxm_in_phy_port_pack(self):
import loxi.of12 as ofp
@@ -63,7 +114,7 @@
expected = ''.join([
'\x80\x00', # class
'\x02', # type/masked
- '\x08', # length
+ '\x04', # length
'\x00\x00\x00\x2a' # value
])
self.assertEquals(expected, obj.pack())
@@ -74,7 +125,7 @@
expected = ''.join([
'\x80\x00', # class
'\x03', # type/masked
- '\x0c', # length
+ '\x08', # length
'\x00\x00\x00\x2a', # value
'\xaa\xbb\xcc\xdd' # mask
])
@@ -86,7 +137,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())
@@ -107,30 +158,11 @@
def test_serialization(self):
expected_failures = [
- ofp.common.flow_stats_entry,
ofp.common.group_desc_stats_entry,
- ofp.common.instruction,
- ofp.common.instruction_apply_actions,
- ofp.common.instruction_clear_actions,
- ofp.common.instruction_experimenter,
- ofp.common.instruction_goto_table,
- 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,
- ofp.message.packet_in,
]
for klass in self.klasses:
def fn():
@@ -146,27 +178,7 @@
def test_show(self):
expected_failures = [
- ofp.common.flow_stats_entry,
- ofp.common.group_desc_stats_entry,
- ofp.common.instruction,
- ofp.common.instruction_apply_actions,
- ofp.common.instruction_clear_actions,
- ofp.common.instruction_experimenter,
- ofp.common.instruction_goto_table,
- 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.packet_in,
]
for klass in self.klasses:
def fn():
diff --git a/py_gen/tests/of13.py b/py_gen/tests/of13.py
index 638e61d..3d921d2 100644
--- a/py_gen/tests/of13.py
+++ b/py_gen/tests/of13.py
@@ -26,12 +26,43 @@
# EPL for the specific language governing permissions and limitations
# under the EPL.
import unittest
+import difflib
try:
import loxi.of13 as ofp
+ from loxi.generic_util import OFReader
except ImportError:
exit("loxi package not found. Try setting PYTHONPATH.")
+# Human-friendly format for binary strings. 8 bytes per line.
+def format_binary(buf):
+ byts = map(ord, buf)
+ lines = [[]]
+ for byt in byts:
+ if len(lines[-1]) == 8:
+ lines.append([])
+ lines[-1].append(byt)
+ return '\n'.join([' '.join(['%02x' % y for y in x]) for x in lines])
+
+def diff(a, b):
+ return '\n'.join(difflib.ndiff(a.splitlines(), b.splitlines()))
+
+# Test serialization / deserialization of a sample object.
+# Depends on the __eq__ method being correct.
+def test_serialization(obj, buf):
+ packed = obj.pack()
+ if packed != buf:
+ a = format_binary(buf)
+ b = format_binary(packed)
+ raise AssertionError("Serialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
+ (type(obj).__name__, a, b, diff(a, b)))
+ unpacked = type(obj).unpack(buf)
+ if obj != unpacked:
+ a = obj.show()
+ b = unpacked.show()
+ raise AssertionError("Deserialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
+ (type(obj).__name__, a, b, diff(a, b)))
+
class TestImports(unittest.TestCase):
def test_toplevel(self):
import loxi
@@ -80,11 +111,473 @@
'\x00\x00\x00\x04', # unknown type
'\x00\x01\x00\x04', # versionbitmap
])
- l = ofp.unpack_list_hello_elem(buf)
+ l = ofp.unpack_list_hello_elem(OFReader(buf))
self.assertEquals(len(l), 2)
self.assertTrue(isinstance(l[0], ofp.hello_elem_versionbitmap))
self.assertTrue(isinstance(l[1], ofp.hello_elem_versionbitmap))
+class TestMessages(unittest.TestCase):
+ def test_hello(self):
+ obj = ofp.message.hello(
+ xid=0x12345678,
+ elements=[
+ ofp.hello_elem_versionbitmap(
+ bitmaps=[ofp.uint32(1), ofp.uint32(2)]),
+ ofp.hello_elem_versionbitmap(
+ bitmaps=[ofp.uint32(3), ofp.uint32(4)])])
+ buf = ''.join([
+ '\x04', '\x00', # version, type
+ '\x00\x20', # length
+ '\x12\x34\x56\x78', # xid
+ '\x00\x01', # elements[0].type
+ '\x00\x0c', # elements[0].length
+ '\x00\x00\x00\x01', # elements[0].bitmaps[0]
+ '\x00\x00\x00\x02', # elements[0].bitmaps[1]
+ '\x00\x01', # elements[1].type
+ '\x00\x0c', # elements[1].length
+ '\x00\x00\x00\x03', # elements[1].bitmaps[0]
+ '\x00\x00\x00\x04', # elements[1].bitmaps[1]
+ ])
+ test_serialization(obj, buf)
+
+ def test_error(self):
+ obj = ofp.message.error_msg(
+ xid=0x12345678,
+ err_type=ofp.OFPET_BAD_MATCH,
+ code=ofp.OFPBMC_BAD_MASK,
+ data="abc")
+ buf = ''.join([
+ '\x04', '\x01', # version, type
+ '\x00\x0f', # length
+ '\x12\x34\x56\x78', # xid
+ '\x00\x04', # err_type
+ '\x00\x08', # code
+ 'abc', # data
+ ])
+ test_serialization(obj, buf)
+
+ def test_echo_request(self):
+ obj = ofp.message.echo_request(
+ xid=0x12345678,
+ data="abc")
+ buf = ''.join([
+ '\x04', '\x02', # version, type
+ '\x00\x0b', # length
+ '\x12\x34\x56\x78', # xid
+ 'abc', # data
+ ])
+ test_serialization(obj, buf)
+
+ def test_echo_reply(self):
+ obj = ofp.message.echo_reply(
+ xid=0x12345678,
+ data="abc")
+ buf = ''.join([
+ '\x04', '\x03', # version, type
+ '\x00\x0b', # length
+ '\x12\x34\x56\x78', # xid
+ 'abc', # data
+ ])
+ test_serialization(obj, buf)
+
+ def test_features_request(self):
+ obj = ofp.message.features_request(xid=0x12345678)
+ buf = ''.join([
+ '\x04', '\x05', # version, type
+ '\x00\x08', # length
+ '\x12\x34\x56\x78', # xid
+ ])
+ test_serialization(obj, buf)
+
+ def test_features_reply(self):
+ obj = ofp.message.features_reply(
+ xid=0x12345678,
+ datapath_id=0xFEDCBA9876543210,
+ n_buffers=64,
+ n_tables=200,
+ auxiliary_id=5,
+ capabilities=ofp.OFPC_FLOW_STATS|ofp.OFPC_PORT_BLOCKED,
+ reserved=0)
+ buf = ''.join([
+ '\x04', '\x06', # version, type
+ '\x00\x20', # length
+ '\x12\x34\x56\x78', # xid
+ '\xfe\xdc\xba\x98\x76\x54\x32\x10', # datapath_id
+ '\x00\x00\x00\x40', # n_buffers
+ '\xc8', # n_tables
+ '\x05', # auxiliary_id
+ '\x00\x00', # pad
+ '\x00\x00\x01\x01', # capabilities
+ '\x00\x00\x00\x00', # reserved
+ ])
+ test_serialization(obj, buf)
+
+ def test_get_config_request(self):
+ obj = ofp.message.get_config_request(xid=0x12345678)
+ buf = ''.join([
+ '\x04', '\x07', # version, type
+ '\x00\x08', # length
+ '\x12\x34\x56\x78', # xid
+ ])
+ test_serialization(obj, buf)
+
+ def test_get_config_reply(self):
+ obj = ofp.message.get_config_reply(
+ xid=0x12345678,
+ flags=ofp.OFPC_FRAG_REASM,
+ miss_send_len=0xffff)
+ buf = ''.join([
+ '\x04', '\x08', # version, type
+ '\x00\x0c', # length
+ '\x12\x34\x56\x78', # xid
+ '\x00\x02', # flags
+ '\xff\xff', # miss_send_len
+ ])
+ test_serialization(obj, buf)
+
+ def test_set_config(self):
+ obj = ofp.message.set_config(
+ xid=0x12345678,
+ flags=ofp.OFPC_FRAG_REASM,
+ miss_send_len=0xffff)
+ buf = ''.join([
+ '\x04', '\x09', # version, type
+ '\x00\x0c', # length
+ '\x12\x34\x56\x78', # xid
+ '\x00\x02', # flags
+ '\xff\xff', # miss_send_len
+ ])
+ test_serialization(obj, buf)
+
+ def test_packet_in(self):
+ obj = ofp.message.packet_in(
+ xid=0x12345678,
+ buffer_id=100,
+ total_len=17000,
+ reason=ofp.OFPR_ACTION,
+ table_id=20,
+ cookie=0xFEDCBA9876543210,
+ match=ofp.match(oxm_list=[
+ ofp.oxm.arp_op(value=1),
+ ofp.oxm.in_port_masked(value=4, value_mask=5)]),
+ data="abc")
+ buf = ''.join([
+ '\x04', '\x0a', # version, type
+ '\x00\x35', # length
+ '\x12\x34\x56\x78', # xid
+ '\x00\x00\x00\x64', # buffer_id
+ '\x42\x68', # total_len
+ '\x01', # reason
+ '\x14', # table_id
+ '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
+ '\x00\x01', # match.type
+ '\x00\x16', # match.length
+ '\x80\x00\x2A\x02', # match.oxm_list[0].type_len
+ '\x00\x01', # match.oxm_list[0].value
+ '\x80\x00\x01\x08', # match.oxm_list[1].type_len
+ '\x00\x00\x00\x04', # match.oxm_list[1].value
+ '\x00\x00\x00\x05', # match.oxm_list[1].mask
+ '\x00\x00', # match.pad
+ '\x00\x00', # pad
+ 'abc', # data
+ ])
+ test_serialization(obj, buf)
+
+ def test_flow_removed(self):
+ obj = ofp.message.flow_removed(
+ xid=0x12345678,
+ cookie=0xFEDCBA9876543210,
+ priority=17000,
+ reason=ofp.OFPRR_DELETE,
+ table_id=20,
+ duration_sec=10,
+ duration_nsec=1000,
+ idle_timeout=5,
+ hard_timeout=30,
+ packet_count=1,
+ byte_count=2,
+ match=ofp.match(oxm_list=[
+ ofp.oxm.arp_op(value=1),
+ ofp.oxm.in_port_masked(value=4, value_mask=5)]))
+ buf = ''.join([
+ '\x04', '\x0b', # version, type
+ '\x00\x48', # length
+ '\x12\x34\x56\x78', # xid
+ '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
+ '\x42\x68', # priority
+ '\x02', # reason
+ '\x14', # table_id
+ '\x00\x00\x00\x0a', # duration_sec
+ '\x00\x00\x03\xe8', # duration_nsec
+ '\x00\x05', # idle_timeout
+ '\x00\x1e', # hard_timeout
+ '\x00\x00\x00\x00\x00\x00\x00\x01', # packet_count
+ '\x00\x00\x00\x00\x00\x00\x00\x02', # byte_count
+ '\x00\x01', # match.type
+ '\x00\x16', # match.length
+ '\x80\x00\x2A\x02', # match.oxm_list[0].type_len
+ '\x00\x01', # match.oxm_list[0].value
+ '\x80\x00\x01\x08', # match.oxm_list[1].type_len
+ '\x00\x00\x00\x04', # match.oxm_list[1].value
+ '\x00\x00\x00\x05', # match.oxm_list[1].mask
+ '\x00\x00', # match.pad
+ ])
+ test_serialization(obj, buf)
+
+ def test_port_status(self):
+ obj = ofp.message.port_status(
+ xid=0x12345678,
+ reason=ofp.OFPPR_MODIFY,
+ desc=ofp.port_desc(
+ port_no=4,
+ hw_addr=[1,2,3,4,5,6],
+ name="foo",
+ config=ofp.OFPPC_NO_FWD|ofp.OFPPC_NO_RECV,
+ state=ofp.OFPPS_BLOCKED,
+ curr=ofp.OFPPF_10MB_HD,
+ advertised=ofp.OFPPF_10MB_FD,
+ supported=ofp.OFPPF_100MB_HD,
+ peer=ofp.OFPPF_100MB_FD,
+ curr_speed=10,
+ max_speed=20))
+ buf = ''.join([
+ '\x04', '\x0c', # version, type
+ '\x00\x50', # length
+ '\x12\x34\x56\x78', # xid
+ '\x02', # reason
+ '\x00' * 7, # pad
+ '\x00\x00\x00\x04', # port_no
+ '\x00' * 4, # pad
+ '\x01\x02\x03\x04\x05\x06', # hw_addr
+ '\x00' * 2, # pad
+ 'foo' + '\x00' * 13, # name
+ '\x00\x00\x00\x24', # config
+ '\x00\x00\x00\x02', # state
+ '\x00\x00\x00\x01', # curr
+ '\x00\x00\x00\x02', # advertised
+ '\x00\x00\x00\x04', # supported
+ '\x00\x00\x00\x08', # peer
+ '\x00\x00\x00\x0a', # curr_speed
+ '\x00\x00\x00\x14', # max_speed
+ ])
+ test_serialization(obj, buf)
+
+ def test_packet_out(self):
+ obj = ofp.message.packet_out(
+ xid=0x12345678,
+ buffer_id=100,
+ in_port=4,
+ actions=[
+ ofp.action.output(port=2, max_len=0xffff),
+ ofp.action.dec_nw_ttl()],
+ data="abc")
+ buf = ''.join([
+ '\x04', '\x0d', # version, type
+ '\x00\x33', # length
+ '\x12\x34\x56\x78', # xid
+ '\x00\x00\x00\x64', # buffer_id
+ '\x00\x00\x00\x04', # in_port
+ '\x00\x18', # actions_len
+ '\x00' * 6, # pad
+ '\x00\x00', # actions[0].type
+ '\x00\x10', # actions[0].length
+ '\x00\x00\x00\x02', # actions[0].port
+ '\xff\xff', # actions[0].max_len
+ '\x00' * 6, # pad
+ '\x00\x18', # actions[1].type
+ '\x00\x08', # actions[1].length
+ '\x00' * 4, # pad
+ 'abc', # data
+ ])
+ test_serialization(obj, buf)
+
+
+ ## Flow-mods
+
+ def test_flow_add(self):
+ # TODO
+ pass
+
+ def test_flow_modify(self):
+ # TODO
+ pass
+
+ def test_flow_modify_strict(self):
+ # TODO
+ pass
+
+ def test_flow_delete(self):
+ # TODO
+ pass
+
+ def test_flow_delete_strict(self):
+ # TODO
+ pass
+
+
+ def test_group_mod(self):
+ # TODO
+ pass
+
+ def test_port_mod(self):
+ # TODO
+ pass
+
+ def test_table_mod(self):
+ # TODO
+ pass
+
+
+ ## Multipart messages
+
+ def test_desc_stats_request(self):
+ # TODO
+ pass
+
+ def test_desc_stats_reply(self):
+ # TODO
+ pass
+
+ def test_flow_stats_request(self):
+ # TODO
+ pass
+
+ def test_flow_stats_reply(self):
+ # TODO
+ pass
+
+ def test_aggregate_stats_request(self):
+ # TODO
+ pass
+
+ def test_aggregate_stats_reply(self):
+ # TODO
+ pass
+
+ def test_port_stats_request(self):
+ # TODO
+ pass
+
+ def test_port_stats_reply(self):
+ # TODO
+ pass
+
+ def test_queue_stats_request(self):
+ # TODO
+ pass
+
+ def test_queue_stats_reply(self):
+ # TODO
+ pass
+
+ def test_group_stats_request(self):
+ # TODO
+ pass
+
+ def test_group_stats_reply(self):
+ # TODO
+ pass
+
+ def test_group_desc_stats_request(self):
+ # TODO
+ pass
+
+ def test_group_desc_stats_reply(self):
+ # TODO
+ pass
+
+ def test_group_features_stats_request(self):
+ # TODO
+ pass
+
+ def test_group_features_stats_reply(self):
+ # TODO
+ pass
+
+ def test_meter_stats_request(self):
+ # TODO
+ pass
+
+ def test_meter_stats_reply(self):
+ # TODO
+ pass
+
+ def test_meter_config_stats_request(self):
+ # TODO
+ pass
+
+ def test_meter_config_stats_reply(self):
+ # TODO
+ pass
+
+ def test_meter_features_stats_request(self):
+ # TODO
+ pass
+
+ def test_meter_features_stats_reply(self):
+ # TODO
+ pass
+
+ def test_table_features_stats_request(self):
+ # TODO
+ pass
+
+ def test_table_features_stats_reply(self):
+ # TODO
+ pass
+
+ def test_port_desc_stats_request(self):
+ # TODO
+ pass
+
+ def test_port_desc_stats_reply(self):
+ # TODO
+ pass
+
+
+ def test_barrier_request(self):
+ # TODO
+ pass
+
+ def test_barrier_reply(self):
+ # TODO
+ pass
+
+ def test_queue_get_config_request(self):
+ # TODO
+ pass
+
+ def test_queue_get_config_reply(self):
+ # TODO
+ pass
+
+ def test_role_request(self):
+ # TODO
+ pass
+
+ def test_role_reply(self):
+ # TODO
+ pass
+
+ def test_get_async_request(self):
+ # TODO
+ pass
+
+ def test_get_async_reply(self):
+ # TODO
+ pass
+
+ def test_set_async(self):
+ # TODO
+ pass
+
+ def test_meter_mod(self):
+ # TODO
+ pass
+
+ # TODO test experimenter messages
+
+
class TestOXM(unittest.TestCase):
def test_oxm_in_phy_port_pack(self):
import loxi.of13 as ofp
@@ -92,7 +585,7 @@
expected = ''.join([
'\x80\x00', # class
'\x02', # type/masked
- '\x08', # length
+ '\x04', # length
'\x00\x00\x00\x2a' # value
])
self.assertEquals(expected, obj.pack())
@@ -103,7 +596,7 @@
expected = ''.join([
'\x80\x00', # class
'\x03', # type/masked
- '\x0c', # length
+ '\x08', # length
'\x00\x00\x00\x2a', # value
'\xaa\xbb\xcc\xdd' # mask
])
@@ -115,7 +608,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())
@@ -136,76 +629,12 @@
def test_serialization(self):
expected_failures = [
- ofp.common.action_id,
- ofp.common.action_id_bsn_mirror,
- ofp.common.action_id_bsn_set_tunnel_dst,
- ofp.common.action_id_copy_ttl_in,
- ofp.common.action_id_copy_ttl_out,
- ofp.common.action_id_dec_mpls_ttl,
- ofp.common.action_id_dec_nw_ttl,
- ofp.common.action_id_experimenter,
- ofp.common.action_id_group,
- ofp.common.action_id_header,
- ofp.common.action_id_nicira_dec_ttl,
- ofp.common.action_id_output,
- ofp.common.action_id_pop_mpls,
- ofp.common.action_id_pop_pbb,
- ofp.common.action_id_pop_vlan,
- ofp.common.action_id_push_mpls,
- ofp.common.action_id_push_pbb,
- ofp.common.action_id_push_vlan,
- ofp.common.action_id_set_field,
- ofp.common.action_id_set_mpls_ttl,
- ofp.common.action_id_set_nw_ttl,
- ofp.common.action_id_set_queue,
- ofp.common.flow_stats_entry,
ofp.common.group_desc_stats_entry,
- ofp.common.instruction,
- ofp.common.instruction_apply_actions,
- ofp.common.instruction_clear_actions,
- ofp.common.instruction_experimenter,
- ofp.common.instruction_goto_table,
- ofp.common.instruction_header,
- 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,
- ofp.common.meter_band_experimenter,
- ofp.common.meter_band_header,
- ofp.common.table_feature_prop,
- ofp.common.table_feature_prop_apply_actions,
- ofp.common.table_feature_prop_apply_actions_miss,
- ofp.common.table_feature_prop_apply_setfield,
- ofp.common.table_feature_prop_apply_setfield_miss,
- ofp.common.table_feature_prop_experimenter,
- ofp.common.table_feature_prop_header,
- ofp.common.table_feature_prop_instructions,
- ofp.common.table_feature_prop_instructions_miss,
- ofp.common.table_feature_prop_match,
- ofp.common.table_feature_prop_next_tables,
- ofp.common.table_feature_prop_next_tables_miss,
- ofp.common.table_feature_prop_wildcards,
- ofp.common.table_feature_prop_write_actions,
- 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,
- ofp.message.meter_features_stats_reply,
ofp.message.meter_stats_reply,
- ofp.message.packet_in,
+ ofp.message.meter_features_stats_reply,
ofp.message.table_features_stats_reply,
ofp.message.table_features_stats_request,
]
@@ -222,73 +651,7 @@
fn()
def test_show(self):
- expected_failures = [
- ofp.common.action_id,
- ofp.common.action_id_bsn_mirror,
- ofp.common.action_id_bsn_set_tunnel_dst,
- ofp.common.action_id_copy_ttl_in,
- ofp.common.action_id_copy_ttl_out,
- ofp.common.action_id_dec_mpls_ttl,
- ofp.common.action_id_dec_nw_ttl,
- ofp.common.action_id_experimenter,
- ofp.common.action_id_group,
- ofp.common.action_id_header,
- ofp.common.action_id_nicira_dec_ttl,
- ofp.common.action_id_output,
- ofp.common.action_id_pop_mpls,
- ofp.common.action_id_pop_pbb,
- ofp.common.action_id_pop_vlan,
- ofp.common.action_id_push_mpls,
- ofp.common.action_id_push_pbb,
- ofp.common.action_id_push_vlan,
- ofp.common.action_id_set_field,
- ofp.common.action_id_set_mpls_ttl,
- ofp.common.action_id_set_nw_ttl,
- ofp.common.action_id_set_queue,
- ofp.common.flow_stats_entry,
- ofp.common.group_desc_stats_entry,
- ofp.common.instruction,
- ofp.common.instruction_apply_actions,
- ofp.common.instruction_clear_actions,
- ofp.common.instruction_experimenter,
- ofp.common.instruction_goto_table,
- ofp.common.instruction_header,
- 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,
- ofp.common.meter_band_experimenter,
- ofp.common.meter_band_header,
- ofp.common.table_feature_prop,
- ofp.common.table_feature_prop_apply_actions,
- ofp.common.table_feature_prop_apply_actions_miss,
- ofp.common.table_feature_prop_apply_setfield,
- ofp.common.table_feature_prop_apply_setfield_miss,
- ofp.common.table_feature_prop_experimenter,
- ofp.common.table_feature_prop_header,
- ofp.common.table_feature_prop_instructions,
- ofp.common.table_feature_prop_instructions_miss,
- ofp.common.table_feature_prop_match,
- ofp.common.table_feature_prop_next_tables,
- ofp.common.table_feature_prop_next_tables_miss,
- ofp.common.table_feature_prop_wildcards,
- ofp.common.table_feature_prop_write_actions,
- 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.packet_in,
- ]
+ expected_failures = []
for klass in self.klasses:
def fn():
obj = klass()