| 269 | |
| 270 | |
| 271 | class OpenFlow(_ofp_header): |
| 272 | name = "OpenFlow dissector" |
| 273 | |
| 274 | @classmethod |
| 275 | def dispatch_hook(cls, _pkt=None, *args, **kargs): |
| 276 | if _pkt and len(_pkt) >= 2: |
| 277 | version = orb(_pkt[0]) |
| 278 | if version == 0x04: # OpenFlow 1.3 |
| 279 | from scapy.contrib.openflow3 import OpenFlow3 |
| 280 | return OpenFlow3.dispatch_hook(_pkt, *args, **kargs) |
| 281 | elif version == 0x01: # OpenFlow 1.0 |
| 282 | # port 6653 has been allocated by IANA, port 6633 should no |
| 283 | # longer be used |
| 284 | # OpenFlow function may be called with a None |
| 285 | # self in OFPPacketField |
| 286 | of_type = orb(_pkt[1]) |
| 287 | if of_type == 1: |
| 288 | err_type = orb(_pkt[9]) |
| 289 | # err_type is a short int, but last byte is enough |
| 290 | if err_type == 255: |
| 291 | err_type = 65535 |
| 292 | return ofp_error_cls[err_type] |
| 293 | elif of_type == 16: |
| 294 | mp_type = orb(_pkt[9]) |
| 295 | if mp_type == 255: |
| 296 | mp_type = 65535 |
| 297 | return ofp_stats_request_cls[mp_type] |
| 298 | elif of_type == 17: |
| 299 | mp_type = orb(_pkt[9]) |
| 300 | if mp_type == 255: |
| 301 | mp_type = 65535 |
| 302 | return ofp_stats_reply_cls[mp_type] |
| 303 | else: |
| 304 | return ofpt_cls[of_type] |
| 305 | else: |
| 306 | warning("Unknown OpenFlow packet") |
| 307 | return _UnknownOpenFlow |
| 308 | |
| 309 | |
| 310 | ofp_action_types = {0: "OFPAT_OUTPUT", |
no outgoing calls
no test coverage detected
searching dependent graphs…