Changed debug output
diff --git a/src/python/oftest/protocol/parse.py b/src/python/oftest/protocol/parse.py
index 546439b..af1faed 100644
--- a/src/python/oftest/protocol/parse.py
+++ b/src/python/oftest/protocol/parse.py
@@ -12,6 +12,7 @@
from scapy.all import *
except:
sys.exit("Need to install scapy for packet parsing")
+import oft_config
"""
of_message.py
@@ -20,6 +21,11 @@
function information into the of_message namespace
"""
+parse_debug_level = oft_config.DEBUG_VERBOSE
+
+def dbg(self, level, string):
+ debug_log("PARSE", parse_debug_level, level, string)
+
# These message types are subclassed
msg_type_subclassed = [
OFPT_STATS_REQUEST,
@@ -113,7 +119,7 @@
sub_hdr.unpack(binary_string[OFP_HEADER_BYTES:])
return error_to_class_map[sub_hdr.type]()
else:
- print "ERROR parsing packet to object"
+ dbg(oft_config.DEBUG_ERROR, "Cannot parse pkt to message")
return None
def of_message_parse(binary_string, raw=False):
@@ -127,12 +133,12 @@
@param raw If true, interpret the packet as an L2 packet. Not
yet supported.
@return An object of some message class or None if fails
+ Note that any data beyond that parsed is not returned
"""
- #@todo verify that object type is really a message
if raw:
- print "raw packet message parsing not supported"
+ dbg(oft_config.DEBUG_ERROR, "raw packet message parsing not supported")
return None
obj = _of_message_to_object(binary_string)
@@ -156,7 +162,7 @@
"""
if raw:
- print "raw packet message parsing not supported"
+ dbg(oft_config.DEBUG_ERROR, "raw packet message parsing not supported")
return None
hdr = ofp_header()
@@ -217,14 +223,17 @@
dot1q = ether[Dot1Q]
except:
dot1q = None
+
try:
ip = ether[IP]
except:
ip = None
+
try:
tcp = ether[TCP]
except:
tcp = None
+
try:
udp = ether[UDP]
except:
@@ -252,7 +261,7 @@
#@todo check min length of packet
if pkt_format.upper() != "L2":
- print "ERROR: Only L2 packet supported for packet_to_flow"
+ dbg(oft_config.DEBUG_ERROR, "Only L2 supported for packet_to_flow")
return None
ether = scapy.all.Ether(packet)