loxi-prep: use plain lists to hold OF actions
Some callsites needed to be changed because they depended on action_list.append
taking a shallow copy.
diff --git a/src/python/of10/message.py b/src/python/of10/message.py
index 4f5a43f..849c15a 100644
--- a/src/python/of10/message.py
+++ b/src/python/of10/message.py
@@ -904,8 +904,6 @@
setattr(self, k, v)
else:
raise NameError("field %s does not exist in %s" % (k, self.__class__))
- # Coerce keyword arg into list type
- self.actions = action_list(self.actions)
def pack(self):
@@ -919,7 +917,7 @@
packed = self.header.pack()
packed += ofp_flow_mod.pack(self)
- packed += self.actions.pack()
+ packed += action_list(self.actions).pack()
return packed
def unpack(self, binary_string):
@@ -935,7 +933,9 @@
binary_string = ofp_flow_mod.unpack(self, binary_string)
ai_len = self.header.length - (OFP_FLOW_MOD_BYTES + OFP_HEADER_BYTES)
- binary_string = self.actions.unpack(binary_string, bytes=ai_len)
+ obj = action_list()
+ binary_string = obj.unpack(binary_string, bytes=ai_len)
+ self.actions = list(obj)
# Fixme: If no self.data, add check for data remaining
return binary_string
@@ -950,7 +950,8 @@
length = OFP_HEADER_BYTES
length += ofp_flow_mod.__len__(self)
- length += len(self.actions)
+ for obj in self.actions:
+ length += len(obj)
return length
def show(self, prefix=''):
@@ -1580,8 +1581,6 @@
setattr(self, k, v)
else:
raise NameError("field %s does not exist in %s" % (k, self.__class__))
- # Coerce keyword arg into list type
- self.actions = action_list(self.actions)
def pack(self):
@@ -1594,9 +1593,11 @@
self.header.length = len(self)
packed = self.header.pack()
- self.actions_len = len(self.actions)
+ self.actions_len = 0
+ for obj in self.actions:
+ self.actions_len += len(obj)
packed += ofp_packet_out.pack(self)
- packed += self.actions.pack()
+ packed += action_list(self.actions).pack()
packed += self.data
return packed
@@ -1612,7 +1613,9 @@
binary_string = self.header.unpack(binary_string)
binary_string = ofp_packet_out.unpack(self, binary_string)
- binary_string = self.actions.unpack(binary_string, bytes=self.actions_len)
+ obj = action_list()
+ binary_string = obj.unpack(binary_string, bytes=self.actions_len)
+ self.actions = list(obj)
self.data = binary_string
binary_string = ''
return binary_string
@@ -1628,7 +1631,8 @@
length = OFP_HEADER_BYTES
length += ofp_packet_out.__len__(self)
- length += len(self.actions)
+ for obj in self.actions:
+ length += len(obj)
length += len(self.data)
return length
@@ -2642,12 +2646,12 @@
"""
def __init__(self):
ofp_flow_stats.__init__(self)
- self.actions = action_list()
+ self.actions = []
def pack(self, assertstruct=True):
self.length = len(self)
packed = ofp_flow_stats.pack(self, assertstruct)
- packed += self.actions.pack()
+ packed += action_list(self.actions).pack()
if len(packed) != self.length:
print("ERROR: flow_stats_entry pack length not equal",
self.length, len(packed))
@@ -2659,7 +2663,9 @@
if ai_len < 0:
print("ERROR: flow_stats_entry unpack length too small",
self.length)
- binary_string = self.actions.unpack(binary_string, bytes=ai_len)
+ obj = action_list()
+ binary_string = obj.unpack(binary_string, bytes=ai_len)
+ self.actions = list(obj)
return binary_string
def __len__(self):