|
1
|
|
|
"""Modifications to the port from the controller.""" |
|
2
|
|
|
|
|
3
|
|
|
# System imports |
|
4
|
|
|
|
|
5
|
|
|
# Third-party imports |
|
6
|
|
|
|
|
7
|
1 |
|
from pyof.foundation.base import GenericMessage |
|
8
|
1 |
|
from pyof.foundation.basic_types import HWAddress, Pad, UBInt16, UBInt32 |
|
9
|
|
|
# Local source tree imports |
|
10
|
1 |
|
from pyof.v0x01.common.header import Header, Type |
|
11
|
1 |
|
from pyof.v0x01.common.phy_port import PortConfig, PortFeatures |
|
12
|
|
|
|
|
13
|
1 |
|
__all__ = ('PortMod',) |
|
14
|
|
|
|
|
15
|
|
|
# Classes |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
1 |
View Code Duplication |
class PortMod(GenericMessage): |
|
|
|
|
|
|
19
|
|
|
"""Implement messages to modify the physical port behavior.""" |
|
20
|
|
|
|
|
21
|
1 |
|
header = Header(message_type=Type.OFPT_PORT_MOD) |
|
22
|
1 |
|
port_no = UBInt16() |
|
23
|
1 |
|
hw_addr = HWAddress() |
|
24
|
1 |
|
config = UBInt32(enum_ref=PortConfig) |
|
25
|
1 |
|
mask = UBInt32(enum_ref=PortConfig) |
|
26
|
1 |
|
advertise = UBInt32(enum_ref=PortFeatures) |
|
27
|
|
|
#: Pad to 64-bits. |
|
28
|
1 |
|
pad = Pad(4) |
|
29
|
|
|
|
|
30
|
1 |
|
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
|
1 |
|
super().__init__(xid) |
|
48
|
1 |
|
self.port_no = port_no |
|
49
|
1 |
|
self.hw_addr = hw_addr |
|
50
|
1 |
|
self.config = config |
|
51
|
1 |
|
self.mask = mask |
|
52
|
|
|
self.advertise = advertise |
|
53
|
|
|
|