Code Duplication    Length = 35-45 lines in 5 locations

pyof/v0x01/controller2switch/common.py 1 location

@@ 403-439 (lines=37) @@
400
                 All ports if :attr:`.Port.OFPP_ALL`.
401
            queue_id (int): All queues if OFPQ_ALL (``0xfffffff``).
402
        """
403
        super().__init__()
404
        self.port_no = port_no
405
        self.queue_id = queue_id
406
407
408
class TableStats(GenericStruct):
409
    """Body of reply to OFPST_TABLE request."""
410
411
    table_id = UBInt8()
412
    #: Align to 32-bits.
413
    pad = Pad(3)
414
    name = Char(length=OFP_MAX_TABLE_NAME_LEN)
415
    wildcards = UBInt32(enum_ref=FlowWildCards)
416
    max_entries = UBInt32()
417
    active_count = UBInt32()
418
    count_lookup = UBInt64()
419
    count_matched = UBInt64()
420
421
    def __init__(self, table_id=None, name=None, wildcards=None,
422
                 max_entries=None, active_count=None, count_lookup=None,
423
                 count_matched=None):
424
        """Create a TableStats with the optional parameters below.
425
426
        Args:
427
            table_id (int): Identifier of table.  Lower numbered tables are
428
                consulted first.
429
            name (str): Table name.
430
            wildcards (:class:`~pyof.v0x01.common.flow_match.FlowWildCards`):
431
                Bitmap of OFPFW_* wildcards that are supported by the table.
432
            max_entries (int): Max number of entries supported.
433
            active_count (int): Number of active entries.
434
            count_lookup (int): Number of packets looked up in table.
435
            count_matched (int): Number of packets that hit table.
436
        """
437
        super().__init__()
438
        self.table_id = table_id
439
        self.name = name
440
        self.wildcards = wildcards
441
        self.max_entries = max_entries
442
        self.active_count = active_count

pyof/v0x01/controller2switch/features_reply.py 1 location

@@ 36-76 (lines=41) @@
33
34
# Classes
35
36
class SwitchFeatures(GenericMessage):
37
    """Message sent by the switch device to the controller.
38
39
    This message is the response for a features_request message, sent by the
40
    controller to the switch device. The 'OFPT_FEATURES_REPLY' message inherits
41
    from this class, despite the strange name.
42
    """
43
44
    header = Header(message_type=Type.OFPT_FEATURES_REPLY)
45
    datapath_id = DPID()
46
    n_buffers = UBInt32()
47
    n_tables = UBInt8()
48
    #: Align to 64-bits.
49
    pad = Pad(3)
50
    # Features
51
    capabilities = UBInt32(enum_ref=Capabilities)
52
    actions = UBInt32(enum_ref=ActionType)
53
    ports = ListOfPhyPorts()
54
55
    def __init__(self, xid=None, datapath_id=None, n_buffers=None,
56
                 n_tables=None, capabilities=None, actions=None, ports=None):
57
        """Create a SwitchFeatures with the optional parameters below.
58
59
        Args:
60
            xid (int): xid to be used on the message header.
61
            datapath_id (:class:`str` or :class:`.DPID`): datapath unique ID.
62
                The lower 48-bits are for MAC address, while
63
                the upper 16-bits are implementer-defined.
64
            n_buffers (int): UBInt32 max packets buffered at once.
65
            n_tables (int): UBInt8 number of tables supported by datapath.
66
            capabilities (int): UBInt32 bitmap of supported capabilities.
67
            actions (int): UBInt32 Bitmap of supported "action_type"s.
68
            ports (int): Port definitions.
69
        """
70
        super().__init__(xid)
71
        self.datapath_id = datapath_id
72
        self.n_buffers = n_buffers
73
        self.n_tables = n_tables
74
        self.capabilities = capabilities
75
        self.actions = actions
76
        self.ports = [] if ports is None else ports
77
78
79
class FeaturesReply(SwitchFeatures):

pyof/v0x04/controller2switch/port_mod.py 1 location

@@ 18-55 (lines=38) @@
15
# Classes
16
17
18
class PortMod(GenericMessage):
19
    """Implement messages to modify the physical port behavior."""
20
21
    header = Header(message_type=Type.OFPT_PORT_MOD)
22
    port_no = UBInt32()
23
    pad = Pad(4)
24
    hw_addr = HWAddress()
25
    pad2 = Pad(2)
26
    config = UBInt32(enum_ref=PortConfig)
27
    mask = UBInt32(enum_ref=PortConfig)
28
    advertise = UBInt32(enum_ref=PortFeatures)
29
    #: Pad to 64-bits.
30
    pad3 = Pad(4)
31
32
    def __init__(self, xid=None, port_no=None, hw_addr=None, config=None,
33
                 mask=None, advertise=None):
34
        """Create a PortMod with the optional parameters below.
35
36
        Args:
37
            xid (int): OpenFlow xid to the header.
38
            port_no (int): Physical port number.
39
            hw_addr (HWAddress): The hardware address is not configurable.
40
                This is used to sanity-check the request,
41
                so it must be the same as returned in an ofp_phy_port struct.
42
            config (~pyof.v0x04.common.port.PortConfig):
43
                Bitmap of OFPPC_* flags
44
            mask (~pyof.v0x04.common.port.PortConfig):
45
                Bitmap of OFPPC_* flags to be changed
46
            advertise (~pyof.v0x04.common.port.PortFeatures):
47
                Bitmap of OFPPF_*. Zero all bits to prevent any action taking
48
                place.
49
        """
50
        super().__init__(xid)
51
        self.port_no = port_no
52
        self.hw_addr = hw_addr
53
        self.config = config
54
        self.mask = mask
55
        self.advertise = advertise
56

pyof/v0x01/controller2switch/port_mod.py 1 location

@@ 18-52 (lines=35) @@
15
# Classes
16
17
18
class PortMod(GenericMessage):
19
    """Implement messages to modify the physical port behavior."""
20
21
    header = Header(message_type=Type.OFPT_PORT_MOD)
22
    port_no = UBInt16()
23
    hw_addr = HWAddress()
24
    config = UBInt32(enum_ref=PortConfig)
25
    mask = UBInt32(enum_ref=PortConfig)
26
    advertise = UBInt32(enum_ref=PortFeatures)
27
    #: Pad to 64-bits.
28
    pad = Pad(4)
29
30
    def __init__(self, xid=None, port_no=None, hw_addr=None, config=None,
31
                 mask=None, advertise=None):
32
        """Create a PortMod with the optional parameters below.
33
34
        Args:
35
            xid (int): OpenFlow xid to the header.
36
            port_no (int): Physical port number.
37
            hw_addr (HWAddress): The hardware address is not configurable.
38
                This is used to sanity-check the request,
39
                so it must be the same as returned in an ofp_phy_port struct.
40
            config (~pyof.v0x01.common.phy_port.PortConfig):
41
                Bitmap of OFPPC_* flags
42
            mask (~pyof.v0x01.common.phy_port.PortConfig):
43
                Bitmap of OFPPC_* flags to be changed
44
            advertise (~pyof.v0x01.common.phy_port.PortFeatures):
45
                Bitmap of "ofp_port_features"s
46
        """
47
        super().__init__(xid)
48
        self.port_no = port_no
49
        self.hw_addr = hw_addr
50
        self.config = config
51
        self.mask = mask
52
        self.advertise = advertise
53

pyof/v0x04/controller2switch/features_reply.py 1 location

@@ 36-80 (lines=45) @@
33
34
# Classes
35
36
class SwitchFeatures(GenericMessage):
37
    """Message sent by the switch device to the controller.
38
39
    This message is the response for a features_request message, sent by the
40
    controller to the switch device. The 'OFPT_FEATURES_REPLY' message inherits
41
    from this class, despite the strange name.
42
    """
43
44
    header = Header(message_type=Type.OFPT_FEATURES_REPLY)
45
    datapath_id = DPID()
46
47
    n_buffers = UBInt32()
48
49
    n_tables = UBInt8()
50
    auxiliary_id = UBInt8()
51
    #: Align to 64-bits.
52
    pad = Pad(2)
53
54
    # Features
55
    capabilities = UBInt32(enum_ref=Capabilities)
56
    reserved = UBInt32()
57
58
    def __init__(self, xid=None, datapath_id=None, n_buffers=None,
59
                 n_tables=None, auxiliary_id=None, capabilities=None,
60
                 reserved=None):
61
        """Create a SwitchFeatures with the optional parameters below.
62
63
        Args:
64
            xid (int): xid to be used on the message header.
65
            datapath_id (int): Datapath unique ID.
66
                The lower 48-bits are for MAC address, while
67
                the upper 16-bits are implementer-defined.
68
            n_buffers (int): Max packets buffered at once.
69
            n_tables (int): Number of tables supported by datapath.
70
            auxiliary_id (int): Identify auxiliary connections.
71
            capabilities (int): bitmap of supported capabilities.
72
            reserved (int): Reserved.
73
        """
74
        super().__init__(xid)
75
        self.datapath_id = datapath_id
76
        self.n_buffers = n_buffers
77
        self.n_tables = n_tables
78
        self.auxiliary_id = auxiliary_id
79
        self.capabilities = capabilities
80
        self.reserved = reserved
81
82
83
class FeaturesReply(SwitchFeatures):