|
15 | 15 | 'FlowModFailedCode', 'GroupModFailedCode', 'HelloFailedCode', |
16 | 16 | 'MeterModFailedCode', 'PortModFailedCode', 'QueueOpFailedCode', |
17 | 17 | 'RoleRequestFailedCode', 'SwitchConfigFailedCode', |
18 | | - 'TableFeaturesFailedCode', 'TableModFailedCode') |
| 18 | + 'TableFeaturesFailedCode', 'TableModFailedCode', |
| 19 | + 'GenericFailedCode') |
19 | 20 |
|
20 | 21 | # Enums |
21 | 22 |
|
22 | 23 |
|
| 24 | +class GenericFailedCode(IntEnum): |
| 25 | + """Error_msg 'code' values for OFPET_BAD_ACTION. |
| 26 | +
|
| 27 | + 'data' contains at least the first 64 bytes of the failed request. |
| 28 | + """ |
| 29 | + |
| 30 | + #: Unknown error |
| 31 | + GENERIC_ERROR = 0 |
| 32 | + |
| 33 | + |
23 | 34 | class BadActionCode(IntEnum): |
24 | 35 | """Error_msg 'code' values for OFPET_BAD_ACTION. |
25 | 36 |
|
@@ -197,6 +208,29 @@ class ErrorType(IntEnum): |
197 | 208 | #: Experimenter error messages. |
198 | 209 | OFPET_EXPERIMENTER = 0xffff |
199 | 210 |
|
| 211 | + def get_class(self): |
| 212 | + """Return a Code class based on current ErrorType value. |
| 213 | +
|
| 214 | + Returns: |
| 215 | + enum.IntEnum: class referenced by current error type. |
| 216 | +
|
| 217 | + """ |
| 218 | + classes = {'OFPET_HELLO_FAILED': HelloFailedCode, |
| 219 | + 'OFPET_BAD_REQUEST': BadRequestCode, |
| 220 | + 'OFPET_BAD_ACTION': BadActionCode, |
| 221 | + 'OFPET_BAD_INSTRUCTION': BadInstructionCode, |
| 222 | + 'OFPET_BAD_MATCH': BadMatchCode, |
| 223 | + 'OFPET_FLOW_MOD_FAILED': FlowModFailedCode, |
| 224 | + 'OFPET_GROUP_MOD_FAILED': GroupModFailedCode, |
| 225 | + 'OFPET_PORT_MOD_FAILED': PortModFailedCode, |
| 226 | + 'OFPET_QUEUE_OP_FAILED': QueueOpFailedCode, |
| 227 | + 'OFPET_SWITCH_CONFIG_FAILED': SwitchConfigFailedCode, |
| 228 | + 'OFPET_ROLE_REQUEST_FAILED': RoleRequestFailedCode, |
| 229 | + 'OFPET_METER_MOD_FAILED': MeterModFailedCode, |
| 230 | + 'OFPET_TABLE_MOD_FAILED': TableModFailedCode, |
| 231 | + 'OFPET_TABLE_FEATURES_FAILED': TableFeaturesFailedCode} |
| 232 | + return classes.get(self.name, GenericFailedCode) |
| 233 | + |
200 | 234 |
|
201 | 235 | class FlowModFailedCode(IntEnum): |
202 | 236 | """Error_msg 'code' values for OFPET_FLOW_MOD_FAILED. |
|
0 commit comments