@@ 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 |
@@ 49-101 (lines=53) @@ | ||
46 | ||
47 | ||
48 | # Classes |
|
49 | class FlowMod(GenericMessage): |
|
50 | """Modifies the flow table from the controller.""" |
|
51 | ||
52 | header = Header(message_type=Type.OFPT_FLOW_MOD) |
|
53 | match = Match() |
|
54 | cookie = UBInt64() |
|
55 | command = UBInt16(enum_ref=FlowModCommand) |
|
56 | idle_timeout = UBInt16() |
|
57 | hard_timeout = UBInt16() |
|
58 | priority = UBInt16() |
|
59 | buffer_id = UBInt32() |
|
60 | out_port = UBInt16(enum_ref=Port) |
|
61 | flags = UBInt16(enum_ref=FlowModFlags) |
|
62 | actions = ListOfActions() |
|
63 | ||
64 | def __init__(self, xid=None, match=None, cookie=0, command=None, |
|
65 | idle_timeout=0, hard_timeout=0, priority=0, |
|
66 | buffer_id=NO_BUFFER, out_port=Port.OFPP_NONE, |
|
67 | flags=FlowModFlags.OFPFF_SEND_FLOW_REM, actions=None): |
|
68 | """Create a FlowMod with the optional parameters below. |
|
69 | ||
70 | Args: |
|
71 | xid (int): xid to be used on the message header. |
|
72 | match (~pyof.v0x01.common.flow_match.Match): Fields to match. |
|
73 | cookie (int): Opaque controller-issued identifier. |
|
74 | command (~pyof.v0x01.controller2switch.flow_mod.FlowModCommand): |
|
75 | One of OFPFC_*. |
|
76 | idle_timeout (int): Idle time before discarding (seconds). |
|
77 | hard_timeout (int): Max time before discarding (seconds). |
|
78 | priority (int): Priority level of flow entry. |
|
79 | buffer_idle (int): Buffered packet to apply to (or -1). |
|
80 | Not meaningful for OFPFC_DELETE*. |
|
81 | out_port (~pyof.v0x01.common.phy_port.Port): |
|
82 | For OFPFC_DELETE* commands, require matching entries to include |
|
83 | this as an output port. A value of OFPP_NONE indicates no |
|
84 | restriction. |
|
85 | flags (~pyof.v0x01.controller2switch.flow_mod.FlowModFlags): |
|
86 | One of OFPFF_*. |
|
87 | actions (~pyof.v0x01.common.action.ListOfActions): |
|
88 | The action length is inferred from the length field in the |
|
89 | header. |
|
90 | """ |
|
91 | super().__init__(xid) |
|
92 | self.match = match or Match() |
|
93 | self.cookie = cookie |
|
94 | self.command = command |
|
95 | self.idle_timeout = idle_timeout |
|
96 | self.hard_timeout = hard_timeout |
|
97 | self.priority = priority |
|
98 | self.buffer_id = buffer_id |
|
99 | self.out_port = out_port |
|
100 | self.flags = flags |
|
101 | self.actions = actions or [] |
|
102 |
@@ 29-80 (lines=52) @@ | ||
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 |