|
1
|
|
|
"""Testing v0x04 FlowRemoved message.""" |
|
2
|
|
|
from pyof.v0x04.asynchronous.flow_removed import FlowRemoved, FlowRemovedReason |
|
3
|
|
|
from pyof.v0x04.common.flow_match import ( |
|
4
|
|
|
Match, MatchType, OxmClass, OxmOfbMatchField, OxmTLV) |
|
5
|
|
|
from tests.unit.test_struct import TestStruct |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class TestFlowRemovedMsg(TestStruct): |
|
9
|
|
|
"""FlowRemoved message tests (also those in :class:`.TestDump`).""" |
|
10
|
|
|
|
|
11
|
|
|
@classmethod |
|
12
|
|
|
def setUpClass(cls): |
|
13
|
|
|
"""Configure raw file and its object in parent class (TestDump).""" |
|
14
|
|
|
super().setUpClass() |
|
15
|
|
|
super().set_raw_dump_file('v0x04', 'ofpt_flow_removed') |
|
16
|
|
|
super().set_raw_dump_object(FlowRemoved, xid=0, |
|
17
|
|
|
cookie=0x0000000000000000, priority=1000, |
|
18
|
|
|
reason=FlowRemovedReason.OFPRR_DELETE, |
|
19
|
|
|
table_id=0, duration_sec=77, |
|
20
|
|
|
duration_nsec=559000000, idle_timeout=0, |
|
21
|
|
|
hard_timeout=0, packet_count=0, |
|
22
|
|
|
byte_count=0, match=_new_match()) |
|
23
|
|
|
super().set_minimum_size(56) |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
def _new_match(): |
|
27
|
|
|
"""Crate new Match instance.""" |
|
28
|
|
|
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
|
|
|
tlv2 = 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=[tlv1, tlv2]) |
|
36
|
|
|
|