loxi-prep: move header fields into the message classes
diff --git a/tests/actions.py b/tests/actions.py
index 68b2e1b..6bb6a8a 100644
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -88,7 +88,7 @@
request = ofp.message.features_request()
(reply, pkt) = self.controller.transact(request)
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
+ self.assertEqual(reply.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
supported_actions =[]
if(reply.actions &1<<ofp.OFPAT_OUTPUT):
diff --git a/tests/basic.py b/tests/basic.py
index 83291fc..66e0355 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -41,9 +41,9 @@
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get echo reply")
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
'response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
self.assertEqual(len(response.data), 0, 'response data non-empty')
@@ -56,9 +56,9 @@
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get echo reply (with data)")
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
'response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
self.assertEqual(request.data, response.data,
'response data does not match request')
@@ -391,9 +391,11 @@
request = illegal_message.illegal_message_type()
reply, pkt = self.controller.transact(request)
+ logging.info(repr(pkt))
self.assertTrue(reply is not None, "Did not get response to bad req")
- self.assertTrue(reply.header.type == ofp.OFPT_ERROR,
+ self.assertTrue(reply.type == ofp.OFPT_ERROR,
"reply not an error message")
+ logging.info(reply.err_type)
self.assertTrue(reply.err_type == ofp.OFPET_BAD_REQUEST,
"reply error type is not bad request")
self.assertTrue(reply.code == ofp.OFPBRC_BAD_TYPE,
diff --git a/tests/flow_query.py b/tests/flow_query.py
index 9c53ab6..68d4e1f 100644
--- a/tests/flow_query.py
+++ b/tests/flow_query.py
@@ -1203,16 +1203,12 @@
def error_handler(self, controller, msg, rawmsg):
logging.info("Got an ERROR message, type=%d, code=%d" \
- % (msg.type, msg.code) \
+ % (msg.err_type, msg.code) \
)
- logging.info("Message header:")
- logging.info(msg.header.show())
self.error_msgs.append(msg)
def removed_handler(self, controller, msg, rawmsg):
logging.info("Got a REMOVED message")
- logging.info("Message header:")
- logging.info(msg.header.show())
self.removed_msgs.append(msg)
def controller_set(self, controller):
@@ -1360,9 +1356,9 @@
flow_mod_msg.flags = flow_mod_msg.flags | ofp.OFPFF_CHECK_OVERLAP
if flow_cfg.send_rem:
flow_mod_msg.flags = flow_mod_msg.flags | ofp.OFPFF_SEND_FLOW_REM
- flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
+ flow_mod_msg.xid = random.randrange(1,0xffffffff)
logging.info("Sending flow_mod(add), xid=%d"
- % (flow_mod_msg.header.xid)
+ % (flow_mod_msg.xid)
)
self.controller.message_send(flow_mod_msg)
return True
@@ -1373,9 +1369,9 @@
else ofp.OFPFC_MODIFY
flow_mod_msg.buffer_id = 0xffffffff
flow_cfg.to_flow_mod_msg(flow_mod_msg)
- flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
+ flow_mod_msg.xid = random.randrange(1,0xffffffff)
logging.info("Sending flow_mod(mod), xid=%d"
- % (flow_mod_msg.header.xid)
+ % (flow_mod_msg.xid)
)
self.controller.message_send(flow_mod_msg)
return True
@@ -1388,9 +1384,9 @@
# TBD - "out_port" filtering of deletes needs to be tested
flow_mod_msg.out_port = ofp.OFPP_NONE
flow_cfg.to_flow_mod_msg(flow_mod_msg)
- flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
+ flow_mod_msg.xid = random.randrange(1,0xffffffff)
logging.info("Sending flow_mod(del), xid=%d"
- % (flow_mod_msg.header.xid)
+ % (flow_mod_msg.xid)
)
self.controller.message_send(flow_mod_msg)
return True
@@ -1416,7 +1412,7 @@
)
f = False
for e in self.error_msgs:
- if e.type == type and e.code == code:
+ if e.err_type == type and e.code == code:
logging.info("Got it")
f = True
if not f:
diff --git a/tests/load.py b/tests/load.py
index 3b72f72..2f0c05f 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -195,7 +195,7 @@
self.assertNotEqual(msg, None, "Barrier failed")
while self.controller.packets:
msg = self.controller.packets.pop(0)[0]
- self.assertNotEqual(msg.header.type, ofp.message.OFPT_ERROR,
+ self.assertNotEqual(msg.type, ofp.message.OFPT_ERROR,
"Error received")
def runTest(self):
diff --git a/tests/message_types.py b/tests/message_types.py
index eacaee6..8e97b64 100644
--- a/tests/message_types.py
+++ b/tests/message_types.py
@@ -45,7 +45,7 @@
self.assertTrue(response is not None,
'Switch did not exchange hello message in return')
self.assertEqual(len(response.data), 0, 'Response data field non-empty')
- self.assertTrue(response.header.version == 0x01, 'Openflow-version field is not 1.0.0')
+ self.assertTrue(response.version == 0x01, 'Openflow-version field is not 1.0.0')
class EchoWithData(base_tests.SimpleProtocol):
@@ -69,9 +69,9 @@
timeout=1)
self.assertTrue(response is not None,
"Did not get echo reply (with data)")
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
'Response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(request.xid, response.xid,
'Response xid does not match the request Xid')
self.assertEqual(request.data, response.data,
'Response data does not match request data')
@@ -95,7 +95,7 @@
#Send Echo Request
logging.info("Sending a Echo request with a version which is not supported by the switch")
request=ofp.message.echo_request()
- request.header.version=0
+ request.version=0
self.controller.message_send(request)
logging.info("Waiting for a OFPT_ERROR msg on the control plane...")
@@ -126,8 +126,8 @@
request = ofp.message.features_request()
(reply, pkt) = self.controller.transact(request)
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
- self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match')
+ self.assertEqual(reply.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
+ self.assertEqual(reply.xid,request.xid,'Transaction id does not match')
supported_actions =[]
if(reply.actions &1<<ofp.OFPAT_OUTPUT):
@@ -211,8 +211,8 @@
#Verify get_config_reply is recieved
logging.info("Expecting GetConfigReply ")
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
- self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match')
+ self.assertEqual(reply.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
+ self.assertEqual(reply.xid,request.xid,'Transaction id does not match')
if reply.miss_send_len == 0 :
logging.info ("the switch must send zero-size packet_in message")
@@ -244,7 +244,7 @@
request = ofp.message.get_config_request()
(reply, pkt) = self.controller.transact(request)
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
+ self.assertEqual(reply.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
miss_send_len = 0
miss_send_len = reply.miss_send_len
@@ -277,7 +277,7 @@
(rep, pkt) = self.controller.transact(request)
self.assertTrue(rep is not None, "Failed to get any reply")
- self.assertEqual(rep.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
+ self.assertEqual(rep.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
self.assertEqual(rep.miss_send_len,new_miss_send_len, "miss_send_len configuration parameter could not be set")
self.assertEqual(rep.flags,new_flags, "frag flags could not be set")
@@ -717,10 +717,10 @@
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get reply ")
- self.assertTrue(response.header.type == ofp.OFPT_QUEUE_GET_CONFIG_REPLY, "Reply is not Queue Config Reply")
+ self.assertTrue(response.type == ofp.OFPT_QUEUE_GET_CONFIG_REPLY, "Reply is not Queue Config Reply")
#Verify Reply Body
- self.assertEqual(response.header.xid, request.header.xid , "Transaction Id in reply is not same as request")
+ self.assertEqual(response.xid, request.xid , "Transaction Id in reply is not same as request")
self.assertEqual(response.port,request.port , "Port queried does not match ")
queues = []
queues = response.queues
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index 7ab49a2..c961f2e 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -300,7 +300,7 @@
timeout=1)
self.assertTrue(response is not None,
'Switch did not exchange hello message in return')
- self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.0')
+ self.assertTrue(response.version == 0x01, 'switch openflow-version field is not 1.0.0')
@@ -320,10 +320,10 @@
# Send echo_request
request = ofp.message.echo_request()
(response, pkt) = self.controller.transact(request)
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,'response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,'response is not echo_reply')
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
- self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.1')
+ self.assertTrue(response.version == 0x01, 'switch openflow-version field is not 1.0.1')
self.assertEqual(len(response.data), 0, 'response data non-empty')
@@ -343,8 +343,8 @@
#Send Barrier Request
request = ofp.message.barrier_request()
(response,pkt) = self.controller.transact(request)
- self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(response.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply')
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
diff --git a/tests/pktact.py b/tests/pktact.py
index 457d652..ad98812 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -372,7 +372,7 @@
request.queue_id = ofp.OFPQ_ALL
(queue_stats, p) = self.controller.transact(request)
self.assertNotEqual(queue_stats, None, "Queue stats request failed")
- if queue_stats.header.type == ofp.OFPT_ERROR:
+ if queue_stats.type == ofp.OFPT_ERROR:
skip_message_emit(self, "Enqueue packet to controller")
return