Code Duplication    Length = 38-45 lines in 3 locations

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):

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