1
|
|
|
"""Defines Features Reply classes and related items.""" |
2
|
|
|
|
3
|
|
|
# System imports |
4
|
|
|
|
5
|
|
|
# Third-party imports |
6
|
|
|
|
7
|
|
|
# Local source tree imports |
8
|
|
|
from pyof.foundation.base import GenericBitMask, GenericMessage |
9
|
|
|
from pyof.foundation.basic_types import DPID, Pad, UBInt8, UBInt32 |
10
|
|
|
from pyof.v0x04.common.header import Header, Type |
11
|
|
|
|
12
|
|
|
__all__ = ('FeaturesReply', 'Capabilities', 'SwitchFeatures') |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class Capabilities(GenericBitMask): |
16
|
|
|
"""Capabilities supported by the datapath.""" |
17
|
|
|
|
18
|
|
|
#: Flow statistics |
19
|
|
|
OFPC_FLOW_STATS = 1 << 0 |
20
|
|
|
#: Table statistics |
21
|
|
|
OFPC_TABLE_STATS = 1 << 1 |
22
|
|
|
#: Port statistics |
23
|
|
|
OFPC_PORT_STATS = 1 << 2 |
24
|
|
|
#: Group statistics. |
25
|
|
|
OFPC_GROUP_STATS = 1 << 3 |
26
|
|
|
#: Can reassembe IP fragments |
27
|
|
|
OFPC_IP_REASM = 1 << 5 |
28
|
|
|
#: Queue statistics |
29
|
|
|
OFPC_QUEUE_STATS = 1 << 6 |
30
|
|
|
#: Switch will block looping ports. |
31
|
|
|
OFPC_PORT_BLOCKED = 1 << 8 |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
# Classes |
35
|
|
|
|
36
|
|
View Code Duplication |
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): |
84
|
|
|
"""'OFPT_FEATURES_REPLY' message.""" |
85
|
|
|
|