Code Duplication    Length = 51-66 lines in 2 locations

pyof/v0x01/asynchronous/flow_removed.py 1 location

@@ 29-79 (lines=51) @@
26
27
28
# Classes
29
class FlowRemoved(GenericMessage):
30
    """Flow removed (datapath -> controller)."""
31
32
    #: :class:`~pyof.v0x01.common.header.Header`: OpenFlow Header
33
    header = Header(message_type=Type.OFPT_FLOW_REMOVED)
34
    #: :class:`~pyof.v0x01.common.flow_match.Match`: OpenFlow Header
35
    match = Match()
36
    cookie = UBInt64()
37
38
    priority = UBInt16()
39
    reason = UBInt8(enum_ref=FlowRemovedReason)
40
    #: Align to 32-bits.
41
    pad = Pad(1)
42
43
    duration_sec = UBInt32()
44
    duration_nsec = UBInt32()
45
46
    idle_timeout = UBInt16()
47
    #: Align to 64-bits.
48
    pad2 = Pad(2)
49
    packet_count = UBInt64()
50
    byte_count = UBInt64()
51
52
    def __init__(self, xid=None, match=None, cookie=None, priority=None,
53
                 reason=None, duration_sec=None, duration_nsec=None,
54
                 idle_timeout=None, packet_count=None, byte_count=None):
55
        """Assign parameters to object attributes.
56
57
        Args:
58
            xid (int): OpenFlow Header's xid.
59
            match (~pyof.v0x01.common.flow_match.Match): Fields' description.
60
            cookie (int): Opaque controller-issued identifier.
61
            priority (int): Priority level of flow entry.
62
            reason (~pyof.v0x01.asynchronous.flow_removed.FlowRemovedReason):
63
                Why the flow was removed.
64
            duration_sec (int): Time the flow was alive in seconds.
65
            duration_nsec (int): Time the flow was alive in nanoseconds in
66
                addition to duration_sec.
67
            idle_timeout (int): Idle timeout from original flow mod.
68
            packet_count (int): Number of packets.
69
            byte_count (int): Byte count.
70
        """
71
        super().__init__(xid)
72
        self.match = match
73
        self.cookie = cookie
74
        self.priority = priority
75
        self.reason = reason
76
        self.duration_sec = duration_sec
77
        self.duration_nsec = duration_nsec
78
        self.idle_timeout = idle_timeout
79
        self.packet_count = packet_count
80
        self.byte_count = byte_count
81

pyof/v0x04/asynchronous/flow_removed.py 1 location

@@ 30-95 (lines=66) @@
27
28
29
# Classes
30
class FlowRemoved(GenericMessage):
31
    """Flow removed (datapath -> controller).
32
33
    If the controller has requested to be notified when flow entries time out
34
    or are deleted from tables, the datapath does this with the
35
    OFPT_FLOW_REMOVED message.
36
    """
37
38
    #: :class:`~pyof.v0x04.common.header.Header`: OpenFlow Header
39
    header = Header(message_type=Type.OFPT_FLOW_REMOVED)
40
    #: Opaque controller-issued identifier.
41
    cookie = UBInt64()
42
    #: Priority level of flow entry.
43
    priority = UBInt16()
44
    #: One of OFPRR_*.
45
    reason = UBInt8(enum_ref=FlowRemovedReason)
46
    #: ID of the table
47
    table_id = UBInt8()
48
    #: Time flow was alive in seconds.
49
    duration_sec = UBInt32()
50
    #: Time flow was alive in nanoseconds beyond duration_sec.
51
    duration_nsec = UBInt32()
52
    #: Idle timeout from original flow mod.
53
    idle_timeout = UBInt16()
54
    #: Hard timeout from original flow mod.
55
    hard_timeout = UBInt16()
56
    packet_count = UBInt64()
57
    byte_count = UBInt64()
58
    #: Description of fields. Variable size.
59
    #: :class:`~pyof.v0x04.common.flow_match.Match`
60
    match = Match()
61
62
    def __init__(self, xid=None, cookie=None, priority=None, reason=None,
63
                 table_id=None, duration_sec=None, duration_nsec=None,
64
                 idle_timeout=None, hard_timeout=None, packet_count=None,
65
                 byte_count=None, match=None):
66
        """Assign parameters to object attributes.
67
68
        Args:
69
            xid (int): OpenFlow Header's xid.
70
            cookie (int): Opaque controller-issued identifier.
71
            priority (int): Priority level of flow entry.
72
            reason (~pyof.v0x04.asynchronous.flow_removed.FlowRemovedReason):
73
                Why the flow was removed.
74
            table_id (int): ID of the table.
75
            duration_sec (int): Time the flow was alive in seconds.
76
            duration_nsec (int): Time the flow was alive in nanoseconds in
77
                addition to duration_sec.
78
            idle_timeout (int): Idle timeout from original flow mod.
79
            hard_timeout (int): Hard timeout from original flow mod.
80
            packet_count (int): Number of packets.
81
            byte_count (int): Byte count.
82
            match (~pyof.v0x04.common.flow_match.Match): Fields' description.
83
        """
84
        super().__init__(xid)
85
        self.cookie = cookie
86
        self.priority = priority
87
        self.reason = reason
88
        self.table_id = table_id
89
        self.duration_sec = duration_sec
90
        self.duration_nsec = duration_nsec
91
        self.idle_timeout = idle_timeout
92
        self.hard_timeout = hard_timeout
93
        self.packet_count = packet_count
94
        self.byte_count = byte_count
95
        self.match = match
96