1
|
|
|
"""FlowMod test.""" |
2
|
|
|
from pyof.v0x04.common.action import ActionOutput, ListOfActions |
3
|
|
|
from pyof.v0x04.common.flow_instructions import ( |
4
|
|
|
InstructionApplyAction, ListOfInstruction) |
5
|
|
|
from pyof.v0x04.common.flow_match import ( |
6
|
|
|
Match, MatchType, OxmClass, OxmOfbMatchField, OxmTLV) |
7
|
|
|
from pyof.v0x04.common.port import PortNo |
8
|
|
|
from pyof.v0x04.controller2switch.flow_mod import FlowMod, FlowModCommand |
9
|
|
|
from tests.unit.test_struct import TestStruct |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class TestFlowMod(TestStruct): |
13
|
|
|
"""FlowMod test.""" |
14
|
|
|
|
15
|
|
|
def test_min_size(self): |
16
|
|
|
"""Test struct minimum size.""" |
17
|
|
|
super().set_raw_dump_file('v0x04', 'ofpt_flow_mod') |
18
|
|
|
super().set_raw_dump_object(FlowMod, xid=2219910763, |
19
|
|
|
command=FlowModCommand.OFPFC_ADD, |
20
|
|
|
priority=1000, |
21
|
|
|
match=_new_match(), |
22
|
|
|
instructions=_new_list_of_instructions()) |
23
|
|
|
super().set_minimum_size(56) |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
def _new_match(): |
27
|
|
|
"""Crate new Match instance.""" |
28
|
|
|
oxm_tlv1 = OxmTLV(oxm_class=OxmClass.OFPXMC_OPENFLOW_BASIC, |
29
|
|
|
oxm_field=OxmOfbMatchField.OFPXMT_OFB_ETH_TYPE, |
30
|
|
|
oxm_hasmask=False, oxm_value=b'\x88\xcc') |
31
|
|
|
oxmt_lv2 = OxmTLV(oxm_class=OxmClass.OFPXMC_OPENFLOW_BASIC, |
32
|
|
|
oxm_field=OxmOfbMatchField.OFPXMT_OFB_VLAN_VID, |
33
|
|
|
oxm_hasmask=False, oxm_value=b'\x1e\xd7') |
34
|
|
|
return Match(match_type=MatchType.OFPMT_OXM, |
35
|
|
|
oxm_match_fields=[oxm_tlv1, oxmt_lv2]) |
36
|
|
|
|
37
|
|
|
def _new_list_of_instructions(): |
38
|
|
|
"""Crate new ListOfInstruction.""" |
39
|
|
|
output = ActionOutput(port=PortNo.OFPP_CONTROLLER) |
40
|
|
|
loa = ListOfActions([output]) |
41
|
|
|
instruction = InstructionApplyAction(loa) |
42
|
|
|
return ListOfInstruction([instruction]) |
43
|
|
|
|