|
1
|
|
|
"""Defines Features Reply classes and related items.""" |
|
2
|
|
|
|
|
3
|
|
|
# System imports |
|
4
|
|
|
|
|
5
|
|
|
# Third-party imports |
|
6
|
|
|
|
|
7
|
|
|
# Local source tree imports |
|
8
|
1 |
|
from pyof.foundation.base import GenericBitMask, GenericMessage |
|
9
|
1 |
|
from pyof.foundation.basic_types import Pad, UBInt8, UBInt32, UBInt64 |
|
10
|
1 |
|
from pyof.v0x04.common.header import Header, Type |
|
11
|
|
|
|
|
12
|
1 |
|
__all__ = ('FeaturesReply', 'Capabilities', 'SwitchFeatures') |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
1 |
|
class Capabilities(GenericBitMask): |
|
16
|
|
|
"""Capabilities supported by the datapath.""" |
|
17
|
|
|
|
|
18
|
|
|
#: Flow statistics |
|
19
|
1 |
|
OFPC_FLOW_STATS = 1 << 0 |
|
20
|
|
|
#: Table statistics |
|
21
|
1 |
|
OFPC_TABLE_STATS = 1 << 1 |
|
22
|
|
|
#: Port statistics |
|
23
|
1 |
|
OFPC_PORT_STATS = 1 << 2 |
|
24
|
|
|
#: Group statistics. |
|
25
|
1 |
|
OFPC_GROUP_STATS = 1 << 3 |
|
26
|
|
|
#: Can reassembe IP fragments |
|
27
|
1 |
|
OFPC_IP_REASM = 1 << 5 |
|
28
|
|
|
#: Queue statistics |
|
29
|
1 |
|
OFPC_QUEUE_STATS = 1 << 6 |
|
30
|
|
|
#: Switch will block looping ports. |
|
31
|
1 |
|
OFPC_PORT_BLOCKED = 1 << 8 |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
# Classes |
|
35
|
|
|
|
|
36
|
1 |
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
|
1 |
|
header = Header(message_type=Type.OFPT_FEATURES_REPLY) |
|
45
|
1 |
|
datapath_id = UBInt64() |
|
46
|
|
|
|
|
47
|
1 |
|
n_buffers = UBInt32() |
|
48
|
|
|
|
|
49
|
1 |
|
n_tables = UBInt8() |
|
50
|
1 |
|
auxiliary_id = UBInt8() |
|
51
|
|
|
#: Align to 64-bits. |
|
52
|
1 |
|
pad = Pad(2) |
|
53
|
|
|
|
|
54
|
|
|
# Features |
|
55
|
1 |
|
capabilities = UBInt32(enum_ref=Capabilities) |
|
56
|
1 |
|
reserved = UBInt32() |
|
57
|
|
|
|
|
58
|
1 |
|
def __init__(self, xid=None, datapath_id=None, n_buffers=None, |
|
59
|
|
|
n_tables=None, auxiliary_id=None, capabilities=None, |
|
60
|
|
|
reserved=None): |
|
61
|
|
|
"""The constructor just assings parameters to object attributes. |
|
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
|
1 |
|
super().__init__(xid) |
|
75
|
1 |
|
self.datapath_id = datapath_id |
|
76
|
1 |
|
self.n_buffers = n_buffers |
|
77
|
1 |
|
self.n_tables = n_tables |
|
78
|
1 |
|
self.auxiliary_id = auxiliary_id |
|
79
|
1 |
|
self.capabilities = capabilities |
|
80
|
1 |
|
self.reserved = reserved |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
1 |
|
class FeaturesReply(SwitchFeatures): |
|
84
|
|
|
"""'OFPT_FEATURES_REPLY' message.""" |
|
85
|
|
|
|