Code Duplication    Length = 39-48 lines in 2 locations

pyof/v0x04/controller2switch/multipart_request.py 2 locations

@@ 159-206 (lines=48) @@
156
        return BinaryData(b'')
157
158
159
class AggregateStatsRequest(GenericStruct):
160
    """Body for ofp_stats_request of type OFPST_AGGREGATE."""
161
162
    #: ID of table to read (from ofp_table_stats) OFPTT_ALL for all tables.
163
    table_id = UBInt8()
164
    #: Align to 32 bits.
165
    pad = Pad(3)
166
    #: Require matching entries to include this as an output port. A value of
167
    #: OFPP_ANY indicates no restriction.
168
    out_port = UBInt32()
169
    #: Require matching entries to include this as an output group. A value of
170
    #: OFPG_ANY indicates no restriction.
171
    out_group = UBInt32()
172
    #: Align to 64 bits
173
    pad2 = Pad(4)
174
    #: Require matching entries to contain this cookie value
175
    cookie = UBInt64()
176
    #: Mask used to restrict the cookie bits that must match. A value of 0
177
    #: indicates no restriction.
178
    cookie_mask = UBInt64()
179
    #: Fields to match. Variable size.
180
    match = Match()
181
182
    def __init__(self, table_id=Table.OFPTT_ALL, out_port=PortNo.OFPP_ANY,
183
                 out_group=Group.OFPG_ANY, cookie=0, cookie_mask=0,
184
                 match=None):
185
        """Create a AggregateStatsRequest with the optional parameters below.
186
187
        Args:
188
            table_id (int): ID of table to read (from ofp_table_stats)
189
                OFPTT_ALL for all tables.
190
            out_port (int): Require matching entries to include this as an
191
                output port. A value of OFPP_ANY indicates no restriction.
192
            out_group (int): Require matching entries to include this as an
193
                output group. A value of OFPG_ANY indicates no restriction.
194
            cookie (int): Require matching entries to contain this cookie value
195
            cookie_mask (int): Mask used to restrict the cookie bits that must
196
                match. A value of 0 indicates no restriction.
197
            match (~pyof.v0x04.common.flow_match.Match):
198
                Fields to match. Variable size
199
        """
200
        super().__init__()
201
        self.table_id = table_id
202
        self.out_port = out_port
203
        self.out_group = out_group
204
        self.cookie = cookie
205
        self.cookie_mask = cookie_mask
206
        self.match = Match() if match is None else match
207
208
209
class FlowStatsRequest(GenericStruct):
@@ 209-247 (lines=39) @@
206
        self.match = Match() if match is None else match
207
208
209
class FlowStatsRequest(GenericStruct):
210
    """Body for ofp_stats_request of type OFPST_FLOW."""
211
212
    table_id = UBInt8()
213
    #: Align to 32 bits.
214
    pad = Pad(3)
215
    out_port = UBInt32()
216
    out_group = UBInt32()
217
    pad2 = Pad(4)
218
    cookie = UBInt64()
219
    cookie_mask = UBInt64()
220
    match = Match()
221
222
    def __init__(self, table_id=Table.OFPTT_ALL, out_port=PortNo.OFPP_ANY,
223
                 out_group=Group.OFPG_ANY, cookie=0, cookie_mask=0,
224
                 match=None):
225
        """Create a FlowStatsRequest with the optional parameters below.
226
227
        Args:
228
            table_id (int): ID of table to read (from pyof_table_stats)
229
                0xff for all tables or 0xfe for emergency.
230
            out_port (:class:`int`, :class:`~pyof.v0x04.common.port.PortNo`):
231
                Require matching entries to include this as an output port.
232
                A value of :attr:`.PortNo.OFPP_ANY` indicates no restriction.
233
            out_group: Require matching entries to include this as an output
234
                group. A value of :attr:`Group.OFPG_ANY` indicates no
235
                restriction.
236
            cookie: Requires matching entries to contain this cookie value
237
            cookie_mask: Mask used to restrict the cookie bits that must match.
238
                A value of 0 indicates no restriction.
239
            match (~pyof.v0x04.common.flow_match.Match): Fields to match.
240
        """
241
        super().__init__()
242
        self.table_id = table_id
243
        self.out_port = out_port
244
        self.out_group = out_group
245
        self.cookie = cookie
246
        self.cookie_mask = cookie_mask
247
        self.match = Match() if match is None else match
248
249
250
class PortStatsRequest(GenericStruct):