Renamed files
oft_config ==> config
ofmsg ==> protocol
ofmsg/of_message ==> protocol/parse
ofmsg/ofp ==> protocol/cstruct
ofmsg/ofp_aux ==> protocol/class_maps
diff --git a/src/python/oftest/oft_config.py b/src/python/oftest/config.py
similarity index 100%
rename from src/python/oftest/oft_config.py
rename to src/python/oftest/config.py
diff --git a/src/python/oftest/ofmsg/action_list.py b/src/python/oftest/protocol/action_list.py
similarity index 99%
rename from src/python/oftest/ofmsg/action_list.py
rename to src/python/oftest/protocol/action_list.py
index 5327eee..884b933 100644
--- a/src/python/oftest/ofmsg/action_list.py
+++ b/src/python/oftest/protocol/action_list.py
@@ -3,7 +3,7 @@
"""
from action import *
-from ofp import ofp_header
+from cstruct import ofp_header
# # Map OFP action identifiers to the actual structures used on the wire
# action_object_map = {
diff --git a/src/python/oftest/ofmsg/of_message.py b/src/python/oftest/protocol/parse.py
similarity index 73%
rename from src/python/oftest/ofmsg/of_message.py
rename to src/python/oftest/protocol/parse.py
index bd6d639..49b5df1 100644
--- a/src/python/oftest/ofmsg/of_message.py
+++ b/src/python/oftest/protocol/parse.py
@@ -1,4 +1,4 @@
-
+o
from message import *
from error import *
from action import *
@@ -85,17 +85,17 @@
if not hdr.type in msg_type_subclassed:
return msg_type_to_class_map[hdr.type]()
if hdr.type == OFPT_STATS_REQUEST:
- st_hdr = ofp_stats_request()
- st_hdr.unpack(binary_string)
- return stats_request_to_class_map[st_hdr.type]()
+ sub_hdr = ofp_stats_request()
+ sub_hdr.unpack(binary_string)
+ return stats_request_to_class_map[sub_hdr.type]()
elif hdr.type == OFPT_STATS_REPLY:
- st_hdr = ofp_stats_reply()
- st_hdr.unpack(binary_string)
- return stats_reply_to_class_map[st_hdr.type]()
- elif hdr.type == OFPT_STATS_REPLY:
- st_hdr = ofp_error_msg()
- st_hdr.unpack(binary_string)
- return error_to_class_map[st_hdr.type]()
+ sub_hdr = ofp_stats_reply()
+ sub_hdr.unpack(binary_string)
+ return stats_reply_to_class_map[sub_hdr.type]()
+ elif hdr.type == OFPT_ERROR:
+ sub_hdr = ofp_error_msg()
+ sub_hdr.unpack(binary_string)
+ return error_to_class_map[sub_hdr.type]()
else:
print "ERROR parsing packet to object"
return None
@@ -108,10 +108,8 @@
members fully populated.
@param binary_string The packet (string) to be parsed
-
@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
"""
@@ -125,3 +123,39 @@
obj.unpack(binary_string)
return obj
+
+def of_header_parse(binary_string, raw=False):
+ """
+ Parse only the header from an OpenFlow packet
+
+ Parses the header from a raw OpenFlow packet into a
+ an ofp_header Python class.
+
+ @param binary_string The packet (string) to be parsed
+ @param raw If true, interpret the packet as an L2 packet. Not
+ yet supported.
+ @return An ofp_header object
+
+ """
+
+ if raw:
+ print "raw packet message parsing not supported"
+ return None
+
+ hdr = ofp_header()
+ hdr.unpack(binary_string)
+
+ return hdr
+
+def packet_to_flow(packet, wildcards=None, pkt_format="L2"):
+ """
+ Create a flow that matches packet with the given wildcards
+
+ @param packet The packet to use as a flow template
+ @param wildcards Wildcards to place in the flow (ignore those
+ fields from the packet)
+ @param pkt_format May be one string from: L2, L3, ?
+ Fields from unspecified layers are forced to be wildcards
+
+ """
+