loxi-prep: remove uses of cstruct module
This module does not exist in PyLoxi.
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index 4d44c14..6fd88f5 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -224,12 +224,12 @@
continue
self.logger.debug("Msg in: buf len %d. hdr.type %s. hdr.len %d hdr.version %d hdr.xid %d" %
- (len(pkt), ofp.cstruct.ofp_type_map[hdr.type], hdr.length, hdr.version, hdr.xid))
- if hdr.version < ofp.cstruct.OFP_VERSION:
+ (len(pkt), ofp.ofp_type_map[hdr.type], hdr.length, hdr.version, hdr.xid))
+ if hdr.version < ofp.OFP_VERSION:
self.logger.error("Switch only supports up to OpenFlow version %d (OFTest version is %d)",
- hdr.version, ofp.cstruct.OFP_VERSION)
+ hdr.version, ofp.OFP_VERSION)
print "Switch only supports up to OpenFlow version %d (OFTest version is %d)" % \
- (hdr.version, ofp.cstruct.OFP_VERSION)
+ (hdr.version, ofp.OFP_VERSION)
self.disconnect()
return
@@ -251,7 +251,7 @@
# Check if keep alive is set; if so, respond to echo requests
if self.keep_alive:
- if hdr.type == ofp.cstruct.OFPT_ECHO_REQUEST:
+ if hdr.type == ofp.OFPT_ECHO_REQUEST:
self.logger.debug("Responding to echo request")
rep = ofp.message.echo_reply()
rep.header.xid = hdr.xid
@@ -296,7 +296,7 @@
handled = self.handlers["all"](self, msg, rawmsg)
if not handled: # Not handled, enqueue
- self.logger.debug("Enqueuing pkt type " + ofp.cstruct.ofp_type_map[hdr.type])
+ self.logger.debug("Enqueuing pkt type " + ofp.ofp_type_map[hdr.type])
with self.packets_cv:
if len(self.packets) >= self.max_pkts:
self.packets.pop(0)
@@ -577,7 +577,7 @@
"""
if exp_msg is not None:
- self.logger.debug("Poll for %s" % ofp.cstruct.ofp_type_map[exp_msg])
+ self.logger.debug("Poll for %s" % ofp.ofp_type_map[exp_msg])
else:
self.logger.debug("Poll for any OF message")
@@ -589,10 +589,10 @@
(msg, pkt) = self.packets.pop(0)
return (msg, pkt)
else:
- self.logger.debug("Looking for %s" % ofp.cstruct.ofp_type_map[exp_msg])
+ 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.cstruct.ofp_type_map[msg.header.type]))
+ self.logger.debug("Checking packets[%d] (%s)" % (i, ofp.ofp_type_map[msg.header.type]))
if msg.header.type == exp_msg:
(msg, pkt) = self.packets.pop(i)
return (msg, pkt)
@@ -679,7 +679,7 @@
msg_version, msg_type, msg_len, msg_xid = struct.unpack_from("!BBHL", outpkt)
self.logger.debug("Msg out: buf len %d. hdr.type %s. hdr.len %d hdr.version %d hdr.xid %d",
len(outpkt),
- ofp.cstruct.ofp_type_map.get(msg_type, "unknown (%d)" % msg_type),
+ ofp.ofp_type_map.get(msg_type, "unknown (%d)" % msg_type),
msg_len,
msg_version,
msg_xid)
diff --git a/src/python/oftest/illegal_message.py b/src/python/oftest/illegal_message.py
index 0c6a878..eeb5022 100644
--- a/src/python/oftest/illegal_message.py
+++ b/src/python/oftest/illegal_message.py
@@ -2,7 +2,7 @@
Support an illegal message
"""
-from cstruct import *
+import of10
ILLEGAL_MESSAGE_TYPE=217
@@ -23,7 +23,7 @@
"""
def __init__(self):
- self.header = ofp_header()
+ self.header = of10.ofp_header()
self.header.type = ILLEGAL_MESSAGE_TYPE
self.data = ""
@@ -63,7 +63,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = of10.OFP_HEADER_BYTES
length += len(self.data)
return length
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index fcd8f21..fd7d4b2 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -16,7 +16,7 @@
import oftest
import oftest.controller
import oftest.dataplane
-import of10.cstruct
+import of10
import of10.message
import of10.action
import of10.parse
@@ -41,9 +41,9 @@
logging.info("Deleting all flows")
msg = of10.message.flow_mod()
- msg.match.wildcards = of10.cstruct.OFPFW_ALL
- msg.out_port = of10.cstruct.OFPP_NONE
- msg.command = of10.cstruct.OFPFC_DELETE
+ msg.match.wildcards = of10.OFPFW_ALL
+ msg.out_port = of10.OFPP_NONE
+ msg.command = of10.OFPFC_DELETE
msg.buffer_id = 0xffffffff
ctrl.message_send(msg)
return 0 # for backwards compatibility
@@ -51,8 +51,8 @@
def required_wildcards(parent):
w = test_param_get('required_wildcards', default='default')
if w == 'l3-l4':
- return (of10.cstruct.OFPFW_NW_SRC_ALL | of10.cstruct.OFPFW_NW_DST_ALL | of10.cstruct.OFPFW_NW_TOS
- | of10.cstruct.OFPFW_NW_PROTO | of10.cstruct.OFPFW_TP_SRC | of10.cstruct.OFPFW_TP_DST)
+ return (of10.OFPFW_NW_SRC_ALL | of10.OFPFW_NW_DST_ALL | of10.OFPFW_NW_TOS
+ | of10.OFPFW_NW_PROTO | of10.OFPFW_TP_SRC | of10.OFPFW_TP_DST)
else:
return 0
@@ -461,7 +461,7 @@
# Expect a packet from each port on egr port list
for egr_port in egr_port_list:
check_port = egr_port
- if egr_port == of10.cstruct.OFPP_IN_PORT:
+ if egr_port == of10.OFPP_IN_PORT:
check_port = ing_port
(rcv_port, rcv_pkt, pkt_time) = parent.dataplane.poll(
port_number=check_port, exp_pkt=exp_pkt_arg)
@@ -517,7 +517,7 @@
'Match failed: dl_type: ' + str(req_match.dl_type) +
" != " + str(res_match.dl_type))
- if (not(req_match.wildcards & of10.cstruct.OFPFW_DL_TYPE)
+ if (not(req_match.wildcards & of10.OFPFW_DL_TYPE)
and (req_match.dl_type == IP_ETHERTYPE)):
parent.assertEqual(req_match.nw_tos, res_match.nw_tos,
'Match failed: nw_tos: ' + str(req_match.nw_tos) +
@@ -532,7 +532,7 @@
'Match failed: nw_dst: ' + str(req_match.nw_dst) +
" != " + str(res_match.nw_dst))
- if (not(req_match.wildcards & of10.cstruct.OFPFW_NW_PROTO)
+ if (not(req_match.wildcards & of10.OFPFW_NW_PROTO)
and ((req_match.nw_proto == TCP_PROTOCOL)
or (req_match.nw_proto == UDP_PROTOCOL))):
parent.assertEqual(req_match.tp_src, res_match.tp_src,
@@ -565,7 +565,7 @@
if wildcards is None:
wildcards = required_wildcards(parent)
if in_band:
- wildcards &= ~of10.cstruct.OFPFW_IN_PORT
+ wildcards &= ~of10.OFPFW_IN_PORT
match.wildcards = wildcards
match.in_port = ing_port
@@ -578,7 +578,7 @@
request.match = match
request.buffer_id = 0xffffffff
if check_expire:
- request.flags |= of10.cstruct.OFPFF_SEND_FLOW_REM
+ request.flags |= of10.OFPFF_SEND_FLOW_REM
request.hard_timeout = 1
if action_list is not None:
@@ -750,7 +750,7 @@
egr_ports = get_egr_list(parent, of_ports, egr_count,
exclude_list=[ingress_port])
if ing_port:
- egr_ports.append(of10.cstruct.OFPP_IN_PORT)
+ egr_ports.append(of10.OFPP_IN_PORT)
if len(egr_ports) == 0:
parent.assertTrue(0, "Failed to generate egress port list")
@@ -770,7 +770,7 @@
egr_ports = get_egr_list(parent, of_ports, egr_count,
exclude_list=[ingress_port])
if ing_port:
- egr_ports.append(of10.cstruct.OFPP_IN_PORT)
+ egr_ports.append(of10.OFPP_IN_PORT)
flow_match_test_pktout(parent, ingress_port, egr_ports,
dl_vlan=dl_vlan,
pkt=pkt, exp_pkt=exp_pkt,
@@ -970,9 +970,9 @@
# If in_band is true, then only drop from first test port
def flow_mod_gen(port_map, in_band):
request = of10.message.flow_mod()
- request.match.wildcards = of10.cstruct.OFPFW_ALL
+ request.match.wildcards = of10.OFPFW_ALL
if in_band:
- request.match.wildcards = of10.cstruct.OFPFW_ALL - of10.cstruct.OFPFW_IN_PORT
+ request.match.wildcards = of10.OFPFW_ALL - of10.OFPFW_IN_PORT
for of_port, ifname in port_map.items(): # Grab first port
break
request.match.in_port = of_port
@@ -1003,10 +1003,10 @@
lookups, matched
"""
stat_req = of10.message.aggregate_stats_request()
- stat_req.match = of10.cstruct.ofp_match()
- stat_req.match.wildcards = of10.cstruct.OFPFW_ALL
+ stat_req.match = of10.ofp_match()
+ stat_req.match.wildcards = of10.OFPFW_ALL
stat_req.table_id = 0xff
- stat_req.out_port = of10.cstruct.OFPP_NONE
+ stat_req.out_port = of10.OFPP_NONE
rv = {}
@@ -1154,7 +1154,7 @@
stats.extend(reply.stats)
return stats
-def get_flow_stats(test, match, table_id=0xff, out_port=of10.cstruct.OFPP_NONE):
+def get_flow_stats(test, match, table_id=0xff, out_port=of10.OFPP_NONE):
"""
Retrieve a list of flow stats entries.
"""
@@ -1178,7 +1178,7 @@
return get_stats(test, req)
def verify_flow_stats(test, match, table_id=0xff,
- out_port=of10.cstruct.OFPP_NONE,
+ out_port=of10.OFPP_NONE,
initial=[],
pkts=None, bytes=None):
"""