MCPcopy Create free account
hub / github.com/secdev/scapy / OpenFlow

Class OpenFlow

scapy/contrib/openflow.py:271–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269
270
271class 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
310ofp_action_types = {0: "OFPAT_OUTPUT",

Callers 1

getfieldMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…