Code Duplication    Length = 35-38 lines in 2 locations

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