loxi-prep: move header fields into the message classes
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index 6fd88f5..cd7bbcf 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -254,26 +254,26 @@
if hdr.type == ofp.OFPT_ECHO_REQUEST:
self.logger.debug("Responding to echo request")
rep = ofp.message.echo_reply()
- rep.header.xid = hdr.xid
+ rep.xid = hdr.xid
# Ignoring additional data
self.message_send(rep.pack(), zero_xid=True)
continue
# Log error messages
if hdr.type == ofp.OFPT_ERROR:
- if msg.type in ofp.ofp_error_type_map:
- type_str = ofp.ofp_error_type_map[msg.type]
- if msg.type == ofp.OFPET_HELLO_FAILED:
+ if msg.err_type in ofp.ofp_error_type_map:
+ type_str = ofp.ofp_error_type_map[msg.err_type]
+ if msg.err_type == ofp.OFPET_HELLO_FAILED:
code_map = ofp.ofp_hello_failed_code_map
- elif msg.type == ofp.OFPET_BAD_REQUEST:
+ elif msg.err_type == ofp.OFPET_BAD_REQUEST:
code_map = ofp.ofp_bad_request_code_map
- elif msg.type == ofp.OFPET_BAD_ACTION:
+ elif msg.err_type == ofp.OFPET_BAD_ACTION:
code_map = ofp.ofp_bad_action_code_map
- elif msg.type == ofp.OFPET_FLOW_MOD_FAILED:
+ elif msg.err_type == ofp.OFPET_FLOW_MOD_FAILED:
code_map = ofp.ofp_flow_mod_failed_code_map
- elif msg.type == ofp.OFPET_PORT_MOD_FAILED:
+ elif msg.err_type == ofp.OFPET_PORT_MOD_FAILED:
code_map = ofp.ofp_port_mod_failed_code_map
- elif msg.type == ofp.OFPET_QUEUE_OP_FAILED:
+ elif msg.err_type == ofp.OFPET_QUEUE_OP_FAILED:
code_map = ofp.ofp_queue_op_failed_code_map
else:
code_map = None
@@ -285,7 +285,7 @@
else:
type_str = "unknown"
self.logger.warn("Received error message: xid=%d type=%s (%d) code=%s (%d)",
- hdr.xid, type_str, msg.type, code_str, msg.code)
+ hdr.xid, type_str, msg.err_type, code_str, msg.code)
# Now check for message handlers; preference is given to
# handlers for a specific packet
@@ -592,8 +592,8 @@
self.logger.debug("Looking for %s" % ofp.ofp_type_map[exp_msg])
for i in range(len(self.packets)):
msg = self.packets[i][0]
- self.logger.debug("Checking packets[%d] (%s)" % (i, ofp.ofp_type_map[msg.header.type]))
- if msg.header.type == exp_msg:
+ self.logger.debug("Checking packets[%d] (%s)" % (i, ofp.ofp_type_map[msg.type]))
+ if msg.type == exp_msg:
(msg, pkt) = self.packets.pop(i)
return (msg, pkt)
# Not found
@@ -626,21 +626,21 @@
"""
- if not zero_xid and msg.header.xid == 0:
- msg.header.xid = ofutils.gen_xid()
+ if not zero_xid and msg.xid == 0:
+ msg.xid = ofutils.gen_xid()
- self.logger.debug("Running transaction %d" % msg.header.xid)
+ self.logger.debug("Running transaction %d" % msg.xid)
with self.xid_cv:
if self.xid:
self.logger.error("Can only run one transaction at a time")
return (None, None)
- self.xid = msg.header.xid
+ self.xid = msg.xid
self.xid_response = None
self.message_send(msg.pack())
- self.logger.debug("Waiting for transaction %d" % msg.header.xid)
+ self.logger.debug("Waiting for transaction %d" % msg.xid)
ofutils.timed_wait(self.xid_cv, lambda: self.xid_response, timeout=timeout)
if self.xid_response:
@@ -670,8 +670,8 @@
raise Exception("no socket")
#@todo If not string, try to pack
if type(msg) != type(""):
- if msg.header.xid == 0 and not zero_xid:
- msg.header.xid = ofutils.gen_xid()
+ if msg.xid == 0 and not zero_xid:
+ msg.xid = ofutils.gen_xid()
outpkt = msg.pack()
else:
outpkt = msg