Total Complexity | 1 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | """Flow Table Modification message.""" |
||
2 | 1 | from enum import IntEnum |
|
3 | |||
4 | 1 | from pyof.foundation.base import GenericMessage |
|
5 | 1 | from pyof.foundation.basic_types import Pad, UBInt8, UBInt32 |
|
6 | 1 | from pyof.v0x04.common.header import Header, Type |
|
7 | |||
8 | 1 | __all__ = ('Table', 'TableMod') |
|
9 | |||
10 | |||
11 | 1 | class Table(IntEnum): |
|
12 | """Table numbering. Tables can use any number up to OFPT_MAX.""" |
||
13 | |||
14 | #: Last usable table number. |
||
15 | 1 | OFPTT_MAX = 0xfe |
|
16 | # Fake tables. |
||
17 | #: Wildcard table used for table config, flow stats and flow deletes. |
||
18 | 1 | OFPTT_ALL = 0xff |
|
19 | |||
20 | |||
21 | 1 | class TableMod(GenericMessage): |
|
22 | """Configure/Modify behavior of a flow table.""" |
||
23 | |||
24 | 1 | header = Header(message_type=Type.OFPT_TABLE_MOD) |
|
25 | 1 | table_id = UBInt8() |
|
26 | #: Pad to 32 bits |
||
27 | 1 | pad = Pad(3) |
|
28 | 1 | config = UBInt32() |
|
29 | |||
30 | 1 | def __init__(self, xid=None, table_id=Table.OFPTT_ALL, config=3): |
|
31 | """Assing parameters to object attributes. |
||
32 | |||
33 | Args: |
||
34 | xid (int): :class:`~pyof.v0x04.common.header.Header`'s xid. |
||
35 | Defaults to random. |
||
36 | table_id (int): ID of the table, OFPTT_ALL indicates all tables. |
||
37 | config (int): Bitmap of OFPTC_* flags |
||
38 | """ |
||
39 | 1 | super().__init__(xid) |
|
40 | 1 | self.table_id = table_id |
|
41 | # This is reserved for future used. The default value is the only valid |
||
42 | # one from the Enum. |
||
43 | self.config = config |
||
44 |