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