summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2014-01-28 11:31:10 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-01-28 11:04:15 +0900
commite08ac471d44db84666c0b0f2fd1b270db5dde025 (patch)
treed4a09722125eb756d01c478cf657130cace9d2ed
parent053c9851b6db984c1a6e566f30679db29384d708 (diff)
ofproto_v1_3_parser: put some assertions
Put some assertions to catch usage mistakes earlier. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_3_parser.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py
index ec8bcc49..a18eccc8 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -2379,7 +2379,10 @@ class OFPFlowMod(MsgBase):
self.flags = flags
if match is None:
match = OFPMatch()
+ assert isinstance(match, OFPMatch)
self.match = match
+ for i in instructions:
+ assert isinstance(i, OFPInstruction)
self.instructions = instructions
def _serialize_body(self):
@@ -2401,7 +2404,7 @@ class OFPFlowMod(MsgBase):
offset += inst.len
-class OFPInstruction(object):
+class OFPInstruction(StringifyMixin):
_INSTRUCTION_TYPES = {}
@staticmethod
@@ -2420,7 +2423,7 @@ class OFPInstruction(object):
@OFPInstruction.register_instruction_type([ofproto_v1_3.OFPIT_GOTO_TABLE])
-class OFPInstructionGotoTable(StringifyMixin):
+class OFPInstructionGotoTable(OFPInstruction):
"""
Goto table instruction
@@ -2451,7 +2454,7 @@ class OFPInstructionGotoTable(StringifyMixin):
@OFPInstruction.register_instruction_type([ofproto_v1_3.OFPIT_WRITE_METADATA])
-class OFPInstructionWriteMetadata(StringifyMixin):
+class OFPInstructionWriteMetadata(OFPInstruction):
"""
Write metadata instruction
@@ -2487,7 +2490,7 @@ class OFPInstructionWriteMetadata(StringifyMixin):
@OFPInstruction.register_instruction_type([ofproto_v1_3.OFPIT_WRITE_ACTIONS,
ofproto_v1_3.OFPIT_APPLY_ACTIONS,
ofproto_v1_3.OFPIT_CLEAR_ACTIONS])
-class OFPInstructionActions(StringifyMixin):
+class OFPInstructionActions(OFPInstruction):
"""
Actions instruction
@@ -2508,6 +2511,8 @@ class OFPInstructionActions(StringifyMixin):
def __init__(self, type_, actions=None, len_=None):
super(OFPInstructionActions, self).__init__()
self.type = type_
+ for a in actions:
+ assert isinstance(a, OFPAction)
self.actions = actions
@classmethod
@@ -2546,7 +2551,7 @@ class OFPInstructionActions(StringifyMixin):
@OFPInstruction.register_instruction_type([ofproto_v1_3.OFPIT_METER])
-class OFPInstructionMeter(StringifyMixin):
+class OFPInstructionMeter(OFPInstruction):
"""
Meter instruction