Exemplo n.º 1
0
    def test_unpacked_pack(self):
        """Pack and then unpack the result and check for equality.

        Use two TLVs to also test match-field list packing/unpacking.
        """
        unpacked = Match()
        unpacked.unpack(self.match.pack())
        self.assertEqual(self.match, unpacked)
Exemplo n.º 2
0
class TestMatch(TestCase):
    """Test Match class."""

    tlv1 = OxmTLV(oxm_class=OxmClass.OFPXMC_OPENFLOW_BASIC,
                  oxm_field=OxmOfbMatchField.OFPXMT_OFB_IN_PHY_PORT,
                  oxm_hasmask=True, oxm_value=b'abc')
    tlv2 = OxmTLV(oxm_class=OxmClass.OFPXMC_EXPERIMENTER,
                  oxm_field=OxmOfbMatchField.OFPXMT_OFB_METADATA,
                  oxm_hasmask=False, oxm_value=b'abcdef')
    match = Match(match_type=MatchType.OFPMT_OXM,
                  oxm_match_fields=[tlv1, tlv2])

    def test_unpacked_pack(self):
        """Pack and then unpack the result and check for equality.

        Use two TLVs to also test match-field list packing/unpacking.
        """
        unpacked = Match()
        unpacked.unpack(self.match.pack())
        self.assertEqual(self.match, unpacked)

    def test_pack_other_instance(self):
        """Test packing another Match instance by using the value argument."""
        expected = self.match.pack()
        valued_pack = Match().pack(self.match)
        self.assertEqual(expected, valued_pack)
Exemplo n.º 3
0
    def __init__(self, table_id=Table.OFPTT_ALL, out_port=PortNo.OFPP_ANY,
                 out_group=Group.OFPG_ANY, cookie=0, cookie_mask=0,
                 match=None):
        """Create a FlowStatsRequest with the optional parameters below.

        Args:
            table_id (int): ID of table to read (from pyof_table_stats)
                0xff for all tables or 0xfe for emergency.
            out_port (:class:`int`, :class:`~pyof.v0x05.common.port.PortNo`):
                Require matching entries to include this as an output port.
                A value of :attr:`.PortNo.OFPP_ANY` indicates no restriction.
            out_group: Require matching entries to include this as an output
                group. A value of :attr:`Group.OFPG_ANY` indicates no
                restriction.
            cookie: Requires matching entries to contain this cookie value
            cookie_mask: Mask used to restrict the cookie bits that must match.
                A value of 0 indicates no restriction.
            match (~pyof.v0x05.common.flow_match.Match): Fields to match.
        """
        super().__init__()
        self.table_id = table_id
        self.out_port = out_port
        self.out_group = out_group
        self.cookie = cookie
        self.cookie_mask = cookie_mask
        self.match = Match() if match is None else match
Exemplo n.º 4
0
    def __init__(self, monitor_id=None, out_port=PortNo.OFPP_ANY, out_group=Group.OFPG_ANY, flags=FlowMonitorFlags,
                 table_id=Table.OFPTT_ALL,
                 command=FlowMonitorCommand, match=None):
        """
        Create a FlowStatsRequest with the optional parameters below.

        Args:
            monitor_id (int): uniquely identifies a monitor for a specific controller connection within a switch
            (from pyof_table_stats)
                0xff for all tables or 0xfe for emergency.
            out_port (:class:`int`, :class:`~pyof.v0x05.common.port.PortNo`):
                Require matching entries to include this as an output port.
                A value of :attr:`.PortNo.OFPP_ANY` indicates no restriction.
            out_group: Require matching entries to include this as an output
                group. A value of :attr:`Group.OFPG_ANY` indicates no
                restriction.
            table_id (int): ID of table to read (from pyof_table_stats)
                0xff for all tables or 0xfe for emergency.
            command: defines what operation must be done on that monitor
            match (~pyof.v0x05.common.flow_match.Match): Fields to match.
        """
        super().__init__()
        self.monitor_id = monitor_id
        self.out_port = out_port
        self.out_group = out_group
        self.flags = flags
        self.table_id = table_id
        self.command = command
        self.match = Match() if match is None else match
Exemplo n.º 5
0
    def __init__(self, table_id=Table.OFPTT_ALL, out_port=PortNo.OFPP_ANY,
                 out_group=Group.OFPG_ANY, cookie=0, cookie_mask=0,
                 match=None):
        """Create a AggregateStatsRequest with the optional parameters below.

        Args:
            table_id (int): ID of table to read (from ofp_table_stats)
                OFPTT_ALL for all tables.
            out_port (int): Require matching entries to include this as an
                output port. A value of OFPP_ANY indicates no restriction.
            out_group (int): Require matching entries to include this as an
                output group. A value of OFPG_ANY indicates no restriction.
            cookie (int): Require matching entries to contain this cookie value
            cookie_mask (int): Mask used to restrict the cookie bits that must
                match. A value of 0 indicates no restriction.
            match (~pyof.v0x05.common.flow_match.Match):
                Fields to match. Variable size
        """
        super().__init__()
        self.table_id = table_id
        self.out_port = out_port
        self.out_group = out_group
        self.cookie = cookie
        self.cookie_mask = cookie_mask
        self.match = Match() if match is None else match
Exemplo n.º 6
0
class FlowMonitorRequest(GenericStruct):
    """
    Body for ofp_multipart_request of type OFPMP_FLOW_MONITOR.

     The OFPMP_FLOW_MONITOR request’s body consists of an array of zero or more
     instances of this structure. The request arranges to monitor the flows
     that match the specified criteria, which are interpreted in the same way as
     for OFPMP_FLOW.

    ’id’ identifies a particular monitor for the purpose of allowing it to be
     canceled later with OFPFMC_DELETE. ’id’ must be unique among
     existing monitors that have not already been canceled.

    """
    #: Controller-assigned ID for this monitor
    monitor_id = UBInt32()
    #: Required output port, if not OFPP_ANY
    out_port = UBInt32(enum_ref=PortNo)
    #: Required group number, if not OFPG_ANY
    out_group = UBInt32(enum_ref=Group)
    #: OFPFMF_*
    flags = UBInt16(enum_ref=FlowMonitorFlags)
    #: One table’s ID or OFPTT_ALL (all tables)
    table_id = UBInt8(enum_ref=Table)
    #: One of OFPFMC_*
    command = UBInt8(enum_ref=FlowMonitorCommand)
    #: Fields to match. Variable size
    match = Match()

    def __init__(self, monitor_id=None, out_port=PortNo.OFPP_ANY, out_group=Group.OFPG_ANY, flags=FlowMonitorFlags,
                 table_id=Table.OFPTT_ALL,
                 command=FlowMonitorCommand, match=None):
        """
        Create a FlowStatsRequest with the optional parameters below.

        Args:
            monitor_id (int): uniquely identifies a monitor for a specific controller connection within a switch
            (from pyof_table_stats)
                0xff for all tables or 0xfe for emergency.
            out_port (:class:`int`, :class:`~pyof.v0x05.common.port.PortNo`):
                Require matching entries to include this as an output port.
                A value of :attr:`.PortNo.OFPP_ANY` indicates no restriction.
            out_group: Require matching entries to include this as an output
                group. A value of :attr:`Group.OFPG_ANY` indicates no
                restriction.
            table_id (int): ID of table to read (from pyof_table_stats)
                0xff for all tables or 0xfe for emergency.
            command: defines what operation must be done on that monitor
            match (~pyof.v0x05.common.flow_match.Match): Fields to match.
        """
        super().__init__()
        self.monitor_id = monitor_id
        self.out_port = out_port
        self.out_group = out_group
        self.flags = flags
        self.table_id = table_id
        self.command = command
        self.match = Match() if match is None else match
Exemplo n.º 7
0
    def __init__(self, xid=None, cookie=0, cookie_mask=0, table_id=0,
                 command=None, idle_timeout=0, hard_timeout=0,
                 priority=0, buffer_id=OFP_NO_BUFFER, out_port=PortNo.OFPP_ANY,
                 out_group=Group.OFPG_ANY,
                 flags=FlowModFlags.OFPFF_SEND_FLOW_REM, importance=None,
                 match=None):
        """Create a FlowMod with the optional parameters below.

        Args:
            xid (int): xid to be used on the message header.
            cookie (int): Opaque controller-issued identifier.
            cookie_mask (int): Mask used to restrict the cookie bits that must
                match when the command is OFPFC_MODIFY* or OFPFC_DELETE*. A
                value of 0 indicates no restriction.
            table_id (int): ID of the table to put the flow in. For
                OFPFC_DELETE_* commands, OFPTT_ALL can also be used to delete
                matching flows from all tables.
            command (~pyof.v0x05.controller2switch.flow_mod.FlowModCommand):
                One of OFPFC_*.
            idle_timeout (int): Idle time before discarding (seconds).
            hard_timeout (int): Max time before discarding (seconds).
            priority (int): Priority level of flow entry.
            buffer_id (int): Buffered packet to apply to, or OFP_NO_BUFFER. Not
                meaningful for OFPFC_DELETE*.
            out_port (int): For OFPFC_DELETE* commands, require matching
                entries to include this as an output port. A value of OFPP_ANY
                indicates no restriction.
            out_group (int): For OFPFC_DELETE* commands, require matching
                entries to include this as an output group. A value of OFPG_ANY
                indicates no restriction.
            flags (~pyof.v0x05.controller2switch.flow_mod.FlowModFlags):
                One of OFPFF_*.
            importance (int): Eviction precedence (optional)
            match (~pyof.v0x05.common.flow_match.Match):
                Fields to match. Variable size.
        """
        super().__init__(xid)
        self.cookie = cookie
        self.cookie_mask = cookie_mask
        self.table_id = table_id
        self.command = command
        self.idle_timeout = idle_timeout
        self.hard_timeout = hard_timeout
        self.priority = priority
        self.buffer_id = buffer_id
        self.out_port = out_port
        self.out_group = out_group
        self.flags = flags
        self.importance = importance
        self.match = Match() if match is None else match
Exemplo n.º 8
0
class AggregateStatsRequest(GenericStruct):
    """Body for ofp_stats_request of type OFPST_AGGREGATE."""

    #: ID of table to read (from ofp_table_stats) OFPTT_ALL for all tables.
    table_id = UBInt8()
    #: Align to 32 bits.
    pad = Pad(3)
    #: Require matching entries to include this as an output port. A value of
    #: OFPP_ANY indicates no restriction.
    out_port = UBInt32()
    #: Require matching entries to include this as an output group. A value of
    #: OFPG_ANY indicates no restriction.
    out_group = UBInt32()
    #: Align to 64 bits
    pad2 = Pad(4)
    #: Require matching entries to contain this cookie value
    cookie = UBInt64()
    #: Mask used to restrict the cookie bits that must match. A value of 0
    #: indicates no restriction.
    cookie_mask = UBInt64()
    #: Fields to match. Variable size.
    match = Match()

    def __init__(self, table_id=Table.OFPTT_ALL, out_port=PortNo.OFPP_ANY,
                 out_group=Group.OFPG_ANY, cookie=0, cookie_mask=0,
                 match=None):
        """Create a AggregateStatsRequest with the optional parameters below.

        Args:
            table_id (int): ID of table to read (from ofp_table_stats)
                OFPTT_ALL for all tables.
            out_port (int): Require matching entries to include this as an
                output port. A value of OFPP_ANY indicates no restriction.
            out_group (int): Require matching entries to include this as an
                output group. A value of OFPG_ANY indicates no restriction.
            cookie (int): Require matching entries to contain this cookie value
            cookie_mask (int): Mask used to restrict the cookie bits that must
                match. A value of 0 indicates no restriction.
            match (~pyof.v0x05.common.flow_match.Match):
                Fields to match. Variable size
        """
        super().__init__()
        self.table_id = table_id
        self.out_port = out_port
        self.out_group = out_group
        self.cookie = cookie
        self.cookie_mask = cookie_mask
        self.match = Match() if match is None else match
Exemplo n.º 9
0
 def setUpClass(cls):
     """Configure raw file and its object in parent class (TestDump)."""
     super().setUpClass()
     super().set_raw_dump_file('v0x05', 'ofpt_flow_removed')
     super().set_raw_dump_object(FlowRemoved,
                                 xid=1,
                                 cookie=1,
                                 priority=1,
                                 reason=1,
                                 table_id=1,
                                 duration_sec=1,
                                 duration_nsec=2,
                                 idle_timeout=3,
                                 hard_timeout=4,
                                 packet_count=1,
                                 byte_count=1,
                                 match=Match())
     super().set_minimum_size(56)
Exemplo n.º 10
0
 def test_pack_other_instance(self):
     """Test packing another Match instance by using the value argument."""
     expected = self.match.pack()
     valued_pack = Match().pack(self.match)
     self.assertEqual(expected, valued_pack)
Exemplo n.º 11
0
class FlowMod(GenericMessage):
    """Flow setup and teardown (controller -> datapath)."""

    header = Header(message_type=Type.OFPT_FLOW_MOD)

    #: Opaque controller-issued identifier.
    cookie = UBInt64()

    #: Mask used to restrict the cookie bits that must match when the command is
    #: OFPFC_MODIFY* or OFPFC_DELETE*. A value of 0 indicates no restriction.
    cookie_mask = UBInt64()

    #: ID of the table to put the flow in. For OFPFC_DELETE_* commands, OFPTT_ALL
    #: can also be used to delete matching flows from all tables.
    table_id = UBInt8()

    #: One of OFPFC_*.
    command = UBInt8(enum_ref=FlowModCommand)

    #: Idle time before discarding (seconds).
    idle_timeout = UBInt16()

    #: Max time before discarding (seconds).
    hard_timeout = UBInt16()

    #: Priority level of flow entry
    priority = UBInt16()

    #: Buffered packet to apply to, or OFP_NO_BUFFER.
    #: Not meaningful for OFPFC_DELETE*.
    buffer_id = UBInt32()

    #: For OFPFC_DELETE* commands, require matching entries to include this as an output port.
    #: A value of OFPP_ANY indicates no restrictions.
    out_port = UBInt32()

    #: For OFPFC_DELETE* commands, require matching entries to include this as an output group.
    #: A value of OFPP_ANY indicates no restrictions.
    out_group = UBInt32()

    #: Bitmap of OFPFF_* flags.
    flags = UBInt16(enum_ref=FlowModFlags)

    #: Eviction precedence (optional).
    importance = UBInt16()

    #: Fields to match. Variable size.
    match = Match()

    #: The variable size and padded match is always followed by instructions.
    #: Instruction set - 0 or more. The length of the instruction set is inferred from the length field in the header.
    #: instructions = ListOfInstruction()

    def __init__(self, xid=None, cookie=0, cookie_mask=0, table_id=0,
                 command=None, idle_timeout=0, hard_timeout=0,
                 priority=0, buffer_id=OFP_NO_BUFFER, out_port=PortNo.OFPP_ANY,
                 out_group=Group.OFPG_ANY,
                 flags=FlowModFlags.OFPFF_SEND_FLOW_REM, importance=None,
                 match=None):
        """Create a FlowMod with the optional parameters below.

        Args:
            xid (int): xid to be used on the message header.
            cookie (int): Opaque controller-issued identifier.
            cookie_mask (int): Mask used to restrict the cookie bits that must
                match when the command is OFPFC_MODIFY* or OFPFC_DELETE*. A
                value of 0 indicates no restriction.
            table_id (int): ID of the table to put the flow in. For
                OFPFC_DELETE_* commands, OFPTT_ALL can also be used to delete
                matching flows from all tables.
            command (~pyof.v0x05.controller2switch.flow_mod.FlowModCommand):
                One of OFPFC_*.
            idle_timeout (int): Idle time before discarding (seconds).
            hard_timeout (int): Max time before discarding (seconds).
            priority (int): Priority level of flow entry.
            buffer_id (int): Buffered packet to apply to, or OFP_NO_BUFFER. Not
                meaningful for OFPFC_DELETE*.
            out_port (int): For OFPFC_DELETE* commands, require matching
                entries to include this as an output port. A value of OFPP_ANY
                indicates no restriction.
            out_group (int): For OFPFC_DELETE* commands, require matching
                entries to include this as an output group. A value of OFPG_ANY
                indicates no restriction.
            flags (~pyof.v0x05.controller2switch.flow_mod.FlowModFlags):
                One of OFPFF_*.
            importance (int): Eviction precedence (optional)
            match (~pyof.v0x05.common.flow_match.Match):
                Fields to match. Variable size.
        """
        super().__init__(xid)
        self.cookie = cookie
        self.cookie_mask = cookie_mask
        self.table_id = table_id
        self.command = command
        self.idle_timeout = idle_timeout
        self.hard_timeout = hard_timeout
        self.priority = priority
        self.buffer_id = buffer_id
        self.out_port = out_port
        self.out_group = out_group
        self.flags = flags
        self.importance = importance
        self.match = Match() if match is None else match
Exemplo n.º 12
0
class FlowUpdateFull(GenericStruct):
    """ OFPMP_FLOW_MONITOR reply for OFPFME_INITIAL, OFPFME_ADDED, OFPFME_REMOVED,
    and OFPFME_MODIFIED."""

    #: Length is 32 + match + instructions.
    length = UBInt16()
    #: One of OFPFME_*
    event = UBInt16(enum_ref=FlowUpdateEvent)
    #: ID of flow’s table
    table_id = UBInt8()
    #: OFPRR_* for OFPFME_REMOVED, else zero
    reason = UBInt8(enum_ref=FlowUpdateEvent)
    #: Number of seconds idle before expiration
    idle_timeout = UBInt16()
    #: Number of seconds before expiration
    hard_timeout = UBInt16()
    #: Priority of the entry
    priority = UBInt16()
    #: uint8_t zeros[4]; Reserved, currently zeroed
    zeros = UBInt32(0)
    #: Opaque controller-issued identifier.
    cookie = UBInt16()
    #: Fields to match. Variable size
    match = Match()
    """
    Instruction set.
        If OFPFMF_INSTRUCTIONS was not specified, or ’event’ is
        OFPFME_REMOVED, no instructions are included. """

    # instructions = ListOfInstruction() or []

    def __init__(self,
                 event=FlowUpdateEvent,
                 table_id=None,
                 reason=None,
                 idle_timeout=None,
                 hard_timeout=None,
                 priority=None,
                 zeros=None,
                 cookie=None,
                 match=None):
        """Create a FlowUpdateFull with the optional parameters below.

        Args:
            length (int): Length of this entry.
            event (int):  One of OFPFME_*
            table_id (int): ID of table flow came from.
            idle_timeout (int): Number of seconds idle before expiration.
            hard_timeout (int): Number of seconds before expiration.
            priority (int): Priority of the entry. Only meaningful when this
                is not an exact-match entry.
            cookie (int): Opaque controller-issued identifier.
            match (~pyof.v0x05.common.flow_match.Match): Description of fields.
        """
        super().__init__()
        self.event = event
        self.table_id = table_id
        self.reason = reason
        self.idle_timeout = idle_timeout
        self.hard_timeout = hard_timeout
        self.priority = priority
        self.zeros = zeros
        self.cookie = cookie
        self.match = match
        self.length = self.__sizeof__()
Exemplo n.º 13
0
class FlowStats(GenericStruct):
    """Body of reply to OFPST_FLOW request."""

    length = UBInt16()
    table_id = UBInt8()
    #: Align to 32 bits.
    pad = Pad(1)
    duration_sec = UBInt32()
    duration_nsec = UBInt32()
    priority = UBInt16()
    idle_timeout = UBInt16()
    hard_timeout = UBInt16()
    flags = UBInt16()
    importance = UBInt16()
    #: Align to 64-bits
    pad2 = Pad(2)
    cookie = UBInt64()
    packet_count = UBInt64()
    byte_count = UBInt64()
    match = Match()

    #: instructions = ListOfInstruction()

    def __init__(self,
                 length=None,
                 table_id=None,
                 duration_sec=None,
                 duration_nsec=None,
                 priority=None,
                 idle_timeout=None,
                 hard_timeout=None,
                 flags=None,
                 importance=None,
                 cookie=None,
                 packet_count=None,
                 byte_count=None,
                 match=None):
        """Create a FlowStats with the optional parameters below.

        Args:
            length (int): Length of this entry.
            table_id (int): ID of table flow came from.
            duration_sec (int): Time flow has been alive in seconds.
            duration_nsec (int): Time flow has been alive in nanoseconds in
                addition to duration_sec.
            priority (int): Priority of the entry. Only meaningful when this
                is not an exact-match entry.
            idle_timeout (int): Number of seconds idle before expiration.
            hard_timeout (int): Number of seconds before expiration.
            flags (int): Bitmap of OFPFF_* flags.
            importance (int): Eviction precedence.
            cookie (int): Opaque controller-issued identifier.
            packet_count (int): Number of packets in flow.
            byte_count (int): Number of bytes in flow.
            match (~pyof.v0x05.common.flow_match.Match): Description of fields.
        """
        super().__init__()
        self.length = length
        self.table_id = table_id
        self.duration_sec = duration_sec
        self.duration_nsec = duration_nsec
        self.priority = priority
        self.idle_timeout = idle_timeout
        self.hard_timeout = hard_timeout
        self.flags = flags
        self.importance = importance
        self.cookie = cookie
        self.packet_count = packet_count
        self.byte_count = byte_count
        self.match = match

        #: self.instructions = instructions or []

    def unpack(self, buff, offset=0):
        """Unpack a binary message into this object's attributes.

        Pass the correct length for list unpacking.

        Args:
            buff (bytes): Binary data package to be unpacked.
            offset (int): Where to begin unpacking.
        """
        unpack_length = UBInt16()
        unpack_length.unpack(buff, offset)
        super().unpack(buff[:offset + unpack_length], offset)
Exemplo n.º 14
0
class PacketIn(GenericMessage):
    """Packet received on port (datapath -> controller)."""

    #: :class:`~pyof.v0x05.common.header.Header`: OpenFlow Header
    header = Header(message_type=Type.OFPT_PACKET_IN)
    #: ID assigned by datapath.
    buffer_id = UBInt32()
    #: Full length of frame.
    total_len = UBInt16()
    #: Reason packet is being sent (one of OFPR_*),
    reason = UBInt8(enum_ref=PacketInReason)
    #: ID of the table that was looked up.
    table_id = UBInt8()
    #: Cookie of the flow entry that was looked up.
    cookie = UBInt64()
    #: Packet metadata. Variable size.
    match = Match()

    #: Align to 64 bit + 16 bit
    #: pad = Pad(2)
    #: Ethernet frame whose length is inferred from header.length.
    #: The padding bytes preceding the Ethernet frame ensure that the IP
    #: header (if any) following the Ethernet header is 32-bit aligned.
    data = BinaryData()

    def __init__(self,
                 xid=None,
                 buffer_id=None,
                 total_len=None,
                 reason=None,
                 table_id=None,
                 cookie=None,
                 match=None,
                 data=b''):
        """Assign parameters to object attributes.

        Args:
            xid (int): Header's xid.
            buffer_id (int): ID assigned by datapath.
            total_len (int): Full length of frame.
            reason (~pyof.v0x05.asynchronous.packet_in.PacketInReason):
                The reason why the packet is being sent
            table_id (int): ID of the table that was looked up
            cookie (int): Cookie of the flow entry that was looked up
            match (:class:`~pyof.v0x05.common.flow_match.Match`):
                Packet metadata with variable size.
            data (bytes): Ethernet frame, halfway through 32-bit word, so the
                IP header is 32-bit aligned. The amount of data is inferred
                from the length field in the header. Because of padding,
                offsetof(struct ofp_packet_in, data) ==
                sizeof(struct ofp_packet_in) - 2.
        """
        super().__init__(xid)
        self.buffer_id = buffer_id
        self.total_len = total_len
        self.reason = reason
        self.table_id = table_id
        self.cookie = cookie
        self.match = match
        self.data = data

    @property
    def in_port(self):
        """Retrieve the 'in_port' that generated the PacketIn.

        This method will look for the OXM_TLV with type OFPXMT_OFB_IN_PORT on
        the `oxm_match_fields` field from `match` field and return its value,
        if the OXM exists.

        Returns:
            The integer number of the 'in_port' that generated the PacketIn if
            it exists. Otherwise return None.

        """
        in_port = self.match.get_field(OxmOfbMatchField.OFPXMT_OFB_IN_PORT)
        return int.from_bytes(in_port, 'big')
Exemplo n.º 15
0
class FlowRemoved(GenericMessage):
    """Flow removed (datapath -> controller).

    If the controller has requested to be notified when flow entries time out
    or are deleted from tables, the datapath does this with the
    OFPT_FLOW_REMOVED message.
    """

    #: :class:`~pyof.v0x05.common.header.Header`: OpenFlow Header
    header = Header(message_type=Type.OFPT_FLOW_REMOVED)
    #: Opaque controller-issued identifier.
    cookie = UBInt64()
    #: Priority level of flow entry.
    priority = UBInt16()
    #: One of OFPRR_*.
    reason = UBInt8(enum_ref=FlowRemovedReason)
    #: ID of the table
    table_id = UBInt8()
    #: Time flow was alive in seconds.
    duration_sec = UBInt32()
    #: Time flow was alive in nanoseconds beyond duration_sec.
    duration_nsec = UBInt32()
    #: Idle timeout from original flow mod.
    idle_timeout = UBInt16()
    #: Hard timeout from original flow mod.
    hard_timeout = UBInt16()
    packet_count = UBInt64()
    byte_count = UBInt64()
    #: Description of fields. Variable size.
    #: :class:`~pyof.v0x05.common.flow_match.Match`
    match = Match()

    def __init__(self,
                 xid=None,
                 cookie=None,
                 priority=None,
                 reason=None,
                 table_id=None,
                 duration_sec=None,
                 duration_nsec=None,
                 idle_timeout=None,
                 hard_timeout=None,
                 packet_count=None,
                 byte_count=None,
                 match=None):
        """Assign parameters to object attributes.

        Args:
            xid (int): OpenFlow Header's xid.
            cookie (int): Opaque controller-issued identifier.
            priority (int): Priority level of flow entry.
            reason (~pyof.v0x05.asynchronous.flow_removed.FlowRemovedReason):
                Why the flow was removed.
            table_id (int): ID of the table.
            duration_sec (int): Time the flow was alive in seconds.
            duration_nsec (int): Time the flow was alive in nanoseconds in
                addition to duration_sec.
            idle_timeout (int): Idle timeout from original flow mod.
            hard_timeout (int): Hard timeout from original flow mod.
            packet_count (int): Number of packets.
            byte_count (int): Byte count.
            match (~pyof.v0x05.common.flow_match.Match): Fields' description.
        """
        super().__init__(xid)
        self.cookie = cookie
        self.priority = priority
        self.reason = reason
        self.table_id = table_id
        self.duration_sec = duration_sec
        self.duration_nsec = duration_nsec
        self.idle_timeout = idle_timeout
        self.hard_timeout = hard_timeout
        self.packet_count = packet_count
        self.byte_count = byte_count
        self.match = match