loxi-prep: move header fields into the message classes
diff --git a/src/python/of10/class_maps.py b/src/python/of10/class_maps.py
index 89226b4..b638eec 100644
--- a/src/python/of10/class_maps.py
+++ b/src/python/of10/class_maps.py
@@ -27,6 +27,10 @@
'matched_count'
],
'ofp_flow_removed' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'match',
'cookie',
'priority',
@@ -68,15 +72,29 @@
'port_no'
],
'ofp_stats_request' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'stats_type',
'flags'
],
+ 'ofp_hello' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid'
+ ],
'ofp_aggregate_stats_request' : [
'match',
'table_id',
'out_port'
],
'ofp_port_status' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'reason',
'desc'
],
@@ -85,6 +103,10 @@
'len'
],
'ofp_port_mod' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'port_no',
'hw_addr',
'config',
@@ -103,6 +125,10 @@
'max_len'
],
'ofp_switch_config' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'flags',
'miss_send_len'
],
@@ -112,9 +138,17 @@
'nw_tos'
],
'ofp_queue_get_config_reply' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'port'
],
'ofp_packet_in' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'buffer_id',
'total_len',
'in_port',
@@ -144,6 +178,10 @@
'vendor'
],
'ofp_stats_reply' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'stats_type',
'flags'
],
@@ -159,6 +197,10 @@
'dp_desc'
],
'ofp_queue_get_config_request' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'port'
],
'ofp_packet_queue' : [
@@ -185,6 +227,10 @@
'queue_id'
],
'ofp_switch_features' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'datapath_id',
'n_buffers',
'n_tables',
@@ -213,9 +259,17 @@
'xid'
],
'ofp_vendor_header' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'vendor'
],
'ofp_packet_out' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'buffer_id',
'in_port',
'actions_len'
@@ -231,6 +285,10 @@
'vlan_pcp'
],
'ofp_flow_mod' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'match',
'cookie',
'command',
@@ -242,6 +300,10 @@
'flags'
],
'ofp_error_msg' : [
+ 'version',
+ 'type',
+ 'length',
+ 'xid',
'err_type',
'code'
],
diff --git a/src/python/of10/cstruct.py b/src/python/of10/cstruct.py
index 3d2c638..ede9b31 100644
--- a/src/python/of10/cstruct.py
+++ b/src/python/of10/cstruct.py
@@ -312,6 +312,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.match = ofp_match()
self.cookie = 0
self.priority = 0
@@ -343,6 +347,7 @@
if(not self.__assert()[0]):
return None
packed = ""
+ packed += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
packed += self.match.pack()
packed += struct.pack("!QHBBLLH", self.cookie, self.priority, self.reason, self.pad, self.duration_sec, self.duration_nsec, self.idle_timeout)
packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
@@ -354,33 +359,41 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 80):
+ if (len(binaryString) < 88):
return binaryString
- self.match.unpack(binaryString[0:])
+ fmt = '!BBHL'
+ start = 0
+ end = start + struct.calcsize(fmt)
+ (self.version, self.type, self.length, self.xid) = struct.unpack(fmt, binaryString[start:end])
+ self.match.unpack(binaryString[8:])
fmt = '!QHBBLLH'
- start = 40
+ start = 48
end = start + struct.calcsize(fmt)
(self.cookie, self.priority, self.reason, self.pad, self.duration_sec, self.duration_nsec, self.idle_timeout) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BB'
- start = 62
+ start = 70
end = start + struct.calcsize(fmt)
(self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
fmt = '!QQ'
- start = 64
+ start = 72
end = start + struct.calcsize(fmt)
(self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[80:]
+ return binaryString[88:]
def __len__(self):
"""Return length of message
"""
- l = 80
+ l = 88
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.match != other.match: return False
if self.cookie != other.cookie: return False
if self.priority != other.priority: return False
@@ -400,6 +413,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'match: \n'
outstr += self.match.show(prefix + ' ')
outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
@@ -797,6 +814,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.stats_type = 0
self.flags = 0
@@ -813,7 +834,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!HH", self.stats_type, self.flags)
+ packed += struct.pack("!BBHLHH", self.version, self.type, self.length, self.xid, self.stats_type, self.flags)
return packed
def unpack(self, binaryString):
@@ -821,24 +842,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 4):
+ if (len(binaryString) < 12):
return binaryString
- fmt = '!HH'
+ fmt = '!BBHLHH'
start = 0
end = start + struct.calcsize(fmt)
- (self.stats_type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
+ (self.version, self.type, self.length, self.xid, self.stats_type, self.flags) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[12:]
def __len__(self):
"""Return length of message
"""
- l = 4
+ l = 12
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.stats_type != other.stats_type: return False
if self.flags != other.flags: return False
return True
@@ -849,6 +874,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'stats_type: ' + str(self.stats_type) + '\n'
outstr += prefix + 'flags: ' + str(self.flags) + '\n'
return outstr
@@ -866,6 +895,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
def __assert(self):
"""Sanity check
@@ -880,6 +913,7 @@
if(not self.__assert()[0]):
return None
packed = ""
+ packed += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
return packed
def unpack(self, binaryString):
@@ -887,20 +921,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 0):
+ if (len(binaryString) < 8):
return binaryString
- return binaryString[0:]
+ fmt = '!BBHL'
+ start = 0
+ end = start + struct.calcsize(fmt)
+ (self.version, self.type, self.length, self.xid) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[8:]
def __len__(self):
"""Return length of message
"""
- l = 0
+ l = 8
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
return True
def __ne__(self, other): return not self.__eq__(other)
@@ -909,6 +951,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
return outstr
@@ -1003,6 +1049,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.reason = 0
self.pad= [0,0,0,0,0,0,0]
self.desc = ofp_phy_port()
@@ -1026,7 +1076,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!B", self.reason)
+ packed += struct.pack("!BBHLB", self.version, self.type, self.length, self.xid, self.reason)
packed += struct.pack("!BBBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6])
packed += self.desc.pack()
return packed
@@ -1036,29 +1086,33 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 56):
+ if (len(binaryString) < 64):
return binaryString
- fmt = '!B'
+ fmt = '!BBHLB'
start = 0
end = start + struct.calcsize(fmt)
- (self.reason,) = struct.unpack(fmt, binaryString[start:end])
+ (self.version, self.type, self.length, self.xid, self.reason) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BBBBBBB'
- start = 1
+ start = 9
end = start + struct.calcsize(fmt)
(self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6]) = struct.unpack(fmt, binaryString[start:end])
- self.desc.unpack(binaryString[8:])
- return binaryString[56:]
+ self.desc.unpack(binaryString[16:])
+ return binaryString[64:]
def __len__(self):
"""Return length of message
"""
- l = 56
+ l = 64
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.reason != other.reason: return False
if self.pad != other.pad: return False
if self.desc != other.desc: return False
@@ -1070,6 +1124,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'reason: ' + str(self.reason) + '\n'
outstr += prefix + 'desc: \n'
outstr += self.desc.show(prefix + ' ')
@@ -1168,6 +1226,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.port_no = 0
self.hw_addr= [0,0,0,0,0,0]
self.config = 0
@@ -1196,7 +1258,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!H", self.port_no)
+ packed += struct.pack("!BBHLH", self.version, self.type, self.length, self.xid, self.port_no)
packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
packed += struct.pack("!LLL", self.config, self.mask, self.advertise)
packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
@@ -1207,36 +1269,40 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 24):
+ if (len(binaryString) < 32):
return binaryString
- fmt = '!H'
+ fmt = '!BBHLH'
start = 0
end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
+ (self.version, self.type, self.length, self.xid, self.port_no) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BBBBBB'
- start = 2
+ start = 10
end = start + struct.calcsize(fmt)
(self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
fmt = '!LLL'
- start = 8
+ start = 16
end = start + struct.calcsize(fmt)
(self.config, self.mask, self.advertise) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BBBB'
- start = 20
+ start = 28
end = start + struct.calcsize(fmt)
(self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
+ return binaryString[32:]
def __len__(self):
"""Return length of message
"""
- l = 24
+ l = 32
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.port_no != other.port_no: return False
if self.hw_addr != other.hw_addr: return False
if self.config != other.config: return False
@@ -1251,6 +1317,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
outstr += prefix + 'config: ' + str(self.config) + '\n'
@@ -1429,6 +1499,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.flags = 0
self.miss_send_len = 128
@@ -1445,7 +1519,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!HH", self.flags, self.miss_send_len)
+ packed += struct.pack("!BBHLHH", self.version, self.type, self.length, self.xid, self.flags, self.miss_send_len)
return packed
def unpack(self, binaryString):
@@ -1453,24 +1527,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 4):
+ if (len(binaryString) < 12):
return binaryString
- fmt = '!HH'
+ fmt = '!BBHLHH'
start = 0
end = start + struct.calcsize(fmt)
- (self.flags, self.miss_send_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
+ (self.version, self.type, self.length, self.xid, self.flags, self.miss_send_len) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[12:]
def __len__(self):
"""Return length of message
"""
- l = 4
+ l = 12
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.miss_send_len != other.miss_send_len: return False
return True
@@ -1481,6 +1559,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'flags: ' + str(self.flags) + '\n'
outstr += prefix + 'miss_send_len: ' + str(self.miss_send_len) + '\n'
return outstr
@@ -1581,6 +1663,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.port = 0
self.pad= [0,0,0,0,0,0]
@@ -1601,7 +1687,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!H", self.port)
+ packed += struct.pack("!BBHLH", self.version, self.type, self.length, self.xid, self.port)
packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
return packed
@@ -1610,28 +1696,32 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 8):
+ if (len(binaryString) < 16):
return binaryString
- fmt = '!H'
+ fmt = '!BBHLH'
start = 0
end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
+ (self.version, self.type, self.length, self.xid, self.port) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BBBBBB'
- start = 2
+ start = 10
end = start + struct.calcsize(fmt)
(self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
+ return binaryString[16:]
def __len__(self):
"""Return length of message
"""
- l = 8
+ l = 16
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.port != other.port: return False
if self.pad != other.pad: return False
return True
@@ -1642,6 +1732,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'port: ' + str(self.port) + '\n'
return outstr
@@ -1658,6 +1752,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.buffer_id = 0
self.total_len = 0
self.in_port = 0
@@ -1677,7 +1775,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!LHHBB", self.buffer_id, self.total_len, self.in_port, self.reason, self.pad)
+ packed += struct.pack("!BBHLLHHBB", self.version, self.type, self.length, self.xid, self.buffer_id, self.total_len, self.in_port, self.reason, self.pad)
return packed
def unpack(self, binaryString):
@@ -1685,24 +1783,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 10):
+ if (len(binaryString) < 18):
return binaryString
- fmt = '!LHHBB'
+ fmt = '!BBHLLHHBB'
start = 0
end = start + struct.calcsize(fmt)
- (self.buffer_id, self.total_len, self.in_port, self.reason, self.pad) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[10:]
+ (self.version, self.type, self.length, self.xid, self.buffer_id, self.total_len, self.in_port, self.reason, self.pad) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[18:]
def __len__(self):
"""Return length of message
"""
- l = 10
+ l = 18
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.buffer_id != other.buffer_id: return False
if self.total_len != other.total_len: return False
if self.in_port != other.in_port: return False
@@ -1716,6 +1818,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
outstr += prefix + 'total_len: ' + str(self.total_len) + '\n'
outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
@@ -2010,6 +2116,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.stats_type = 0
self.flags = 0
@@ -2026,7 +2136,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!HH", self.stats_type, self.flags)
+ packed += struct.pack("!BBHLHH", self.version, self.type, self.length, self.xid, self.stats_type, self.flags)
return packed
def unpack(self, binaryString):
@@ -2034,24 +2144,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 4):
+ if (len(binaryString) < 12):
return binaryString
- fmt = '!HH'
+ fmt = '!BBHLHH'
start = 0
end = start + struct.calcsize(fmt)
- (self.stats_type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
+ (self.version, self.type, self.length, self.xid, self.stats_type, self.flags) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[12:]
def __len__(self):
"""Return length of message
"""
- l = 4
+ l = 12
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.stats_type != other.stats_type: return False
if self.flags != other.flags: return False
return True
@@ -2062,6 +2176,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'stats_type: ' + str(self.stats_type) + '\n'
outstr += prefix + 'flags: ' + str(self.flags) + '\n'
return outstr
@@ -2267,6 +2385,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.port = 0
self.pad= [0,0]
@@ -2287,7 +2409,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!H", self.port)
+ packed += struct.pack("!BBHLH", self.version, self.type, self.length, self.xid, self.port)
packed += struct.pack("!BB", self.pad[0], self.pad[1])
return packed
@@ -2296,28 +2418,32 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 4):
+ if (len(binaryString) < 12):
return binaryString
- fmt = '!H'
+ fmt = '!BBHLH'
start = 0
end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
+ (self.version, self.type, self.length, self.xid, self.port) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BB'
- start = 2
+ start = 10
end = start + struct.calcsize(fmt)
(self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
+ return binaryString[12:]
def __len__(self):
"""Return length of message
"""
- l = 4
+ l = 12
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.port != other.port: return False
if self.pad != other.pad: return False
return True
@@ -2328,6 +2454,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'port: ' + str(self.port) + '\n'
return outstr
@@ -2772,6 +2902,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.datapath_id = 0
self.n_buffers = 0
self.n_tables = 0
@@ -2796,7 +2930,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!QLB", self.datapath_id, self.n_buffers, self.n_tables)
+ packed += struct.pack("!BBHLQLB", self.version, self.type, self.length, self.xid, self.datapath_id, self.n_buffers, self.n_tables)
packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
packed += struct.pack("!LL", self.capabilities, self.actions)
return packed
@@ -2806,32 +2940,36 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 24):
+ if (len(binaryString) < 32):
return binaryString
- fmt = '!QLB'
+ fmt = '!BBHLQLB'
start = 0
end = start + struct.calcsize(fmt)
- (self.datapath_id, self.n_buffers, self.n_tables) = struct.unpack(fmt, binaryString[start:end])
+ (self.version, self.type, self.length, self.xid, self.datapath_id, self.n_buffers, self.n_tables) = struct.unpack(fmt, binaryString[start:end])
fmt = '!BBB'
- start = 13
+ start = 21
end = start + struct.calcsize(fmt)
(self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
fmt = '!LL'
- start = 16
+ start = 24
end = start + struct.calcsize(fmt)
(self.capabilities, self.actions) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
+ return binaryString[32:]
def __len__(self):
"""Return length of message
"""
- l = 24
+ l = 32
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.datapath_id != other.datapath_id: return False
if self.n_buffers != other.n_buffers: return False
if self.n_tables != other.n_tables: return False
@@ -2846,6 +2984,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'datapath_id: ' + str(self.datapath_id) + '\n'
outstr += prefix + 'n_buffers: ' + str(self.n_buffers) + '\n'
outstr += prefix + 'n_tables: ' + str(self.n_tables) + '\n'
@@ -3086,6 +3228,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.vendor = 0
def __assert(self):
@@ -3101,7 +3247,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!L", self.vendor)
+ packed += struct.pack("!BBHLL", self.version, self.type, self.length, self.xid, self.vendor)
return packed
def unpack(self, binaryString):
@@ -3109,24 +3255,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 4):
+ if (len(binaryString) < 12):
return binaryString
- fmt = '!L'
+ fmt = '!BBHLL'
start = 0
end = start + struct.calcsize(fmt)
- (self.vendor,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
+ (self.version, self.type, self.length, self.xid, self.vendor) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[12:]
def __len__(self):
"""Return length of message
"""
- l = 4
+ l = 12
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.vendor != other.vendor: return False
return True
@@ -3136,6 +3286,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'vendor: ' + str(self.vendor) + '\n'
return outstr
@@ -3152,6 +3306,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.buffer_id = 4294967295
self.in_port = 0
self.actions_len = 0
@@ -3169,7 +3327,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!LHH", self.buffer_id, self.in_port, self.actions_len)
+ packed += struct.pack("!BBHLLHH", self.version, self.type, self.length, self.xid, self.buffer_id, self.in_port, self.actions_len)
return packed
def unpack(self, binaryString):
@@ -3177,24 +3335,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 8):
+ if (len(binaryString) < 16):
return binaryString
- fmt = '!LHH'
+ fmt = '!BBHLLHH'
start = 0
end = start + struct.calcsize(fmt)
- (self.buffer_id, self.in_port, self.actions_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
+ (self.version, self.type, self.length, self.xid, self.buffer_id, self.in_port, self.actions_len) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[16:]
def __len__(self):
"""Return length of message
"""
- l = 8
+ l = 16
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.buffer_id != other.buffer_id: return False
if self.in_port != other.in_port: return False
if self.actions_len != other.actions_len: return False
@@ -3206,6 +3368,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
outstr += prefix + 'actions_len: ' + str(self.actions_len) + '\n'
@@ -3379,6 +3545,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.match = ofp_match()
self.cookie = 0
self.command = 0
@@ -3404,6 +3574,7 @@
if(not self.__assert()[0]):
return None
packed = ""
+ packed += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
packed += self.match.pack()
packed += struct.pack("!QHHHHLHH", self.cookie, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.flags)
return packed
@@ -3413,25 +3584,33 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 64):
+ if (len(binaryString) < 72):
return binaryString
- self.match.unpack(binaryString[0:])
+ fmt = '!BBHL'
+ start = 0
+ end = start + struct.calcsize(fmt)
+ (self.version, self.type, self.length, self.xid) = struct.unpack(fmt, binaryString[start:end])
+ self.match.unpack(binaryString[8:])
fmt = '!QHHHHLHH'
- start = 40
+ start = 48
end = start + struct.calcsize(fmt)
(self.cookie, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[64:]
+ return binaryString[72:]
def __len__(self):
"""Return length of message
"""
- l = 64
+ l = 72
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.match != other.match: return False
if self.cookie != other.cookie: return False
if self.command != other.command: return False
@@ -3449,6 +3628,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'match: \n'
outstr += self.match.show(prefix + ' ')
outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
@@ -3474,6 +3657,10 @@
"""Initialize
Declare members and default values
"""
+ self.version = 0
+ self.type = 0
+ self.length = 0
+ self.xid = 0
self.err_type = 0
self.code = 0
@@ -3490,7 +3677,7 @@
if(not self.__assert()[0]):
return None
packed = ""
- packed += struct.pack("!HH", self.err_type, self.code)
+ packed += struct.pack("!BBHLHH", self.version, self.type, self.length, self.xid, self.err_type, self.code)
return packed
def unpack(self, binaryString):
@@ -3498,24 +3685,28 @@
Do not unpack empty array used as placeholder
since they can contain heterogeneous type
"""
- if (len(binaryString) < 4):
+ if (len(binaryString) < 12):
return binaryString
- fmt = '!HH'
+ fmt = '!BBHLHH'
start = 0
end = start + struct.calcsize(fmt)
- (self.err_type, self.code) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
+ (self.version, self.type, self.length, self.xid, self.err_type, self.code) = struct.unpack(fmt, binaryString[start:end])
+ return binaryString[12:]
def __len__(self):
"""Return length of message
"""
- l = 4
+ l = 12
return l
def __eq__(self, other):
"""Return True if self and other have same values
"""
if type(self) != type(other): return False
+ if self.version != other.version: return False
+ if self.type != other.type: return False
+ if self.length != other.length: return False
+ if self.xid != other.xid: return False
if self.err_type != other.err_type: return False
if self.code != other.code: return False
return True
@@ -3526,6 +3717,10 @@
"""Generate string showing basic members of structure
"""
outstr = ''
+ outstr += prefix + 'version: ' + str(self.version) + '\n'
+ outstr += prefix + 'type: ' + str(self.type) + '\n'
+ outstr += prefix + 'length: ' + str(self.length) + '\n'
+ outstr += prefix + 'xid: ' + str(self.xid) + '\n'
outstr += prefix + 'err_type: ' + str(self.err_type) + '\n'
outstr += prefix + 'code: ' + str(self.code) + '\n'
return outstr
@@ -3990,32 +4185,32 @@
OFP_AGGREGATE_STATS_REPLY_BYTES = 24
OFP_AGGREGATE_STATS_REQUEST_BYTES = 44
OFP_DESC_STATS_BYTES = 1056
-OFP_ERROR_MSG_BYTES = 4
-OFP_FLOW_MOD_BYTES = 64
-OFP_FLOW_REMOVED_BYTES = 80
+OFP_ERROR_MSG_BYTES = 12
+OFP_FLOW_MOD_BYTES = 72
+OFP_FLOW_REMOVED_BYTES = 88
OFP_FLOW_STATS_BYTES = 88
OFP_FLOW_STATS_REQUEST_BYTES = 44
OFP_HEADER_BYTES = 8
-OFP_HELLO_BYTES = 0
+OFP_HELLO_BYTES = 8
OFP_MATCH_BYTES = 40
-OFP_PACKET_IN_BYTES = 10
-OFP_PACKET_OUT_BYTES = 8
+OFP_PACKET_IN_BYTES = 18
+OFP_PACKET_OUT_BYTES = 16
OFP_PACKET_QUEUE_BYTES = 8
OFP_PHY_PORT_BYTES = 48
-OFP_PORT_MOD_BYTES = 24
+OFP_PORT_MOD_BYTES = 32
OFP_PORT_STATS_BYTES = 104
OFP_PORT_STATS_REQUEST_BYTES = 8
-OFP_PORT_STATUS_BYTES = 56
-OFP_QUEUE_GET_CONFIG_REPLY_BYTES = 8
-OFP_QUEUE_GET_CONFIG_REQUEST_BYTES = 4
+OFP_PORT_STATUS_BYTES = 64
+OFP_QUEUE_GET_CONFIG_REPLY_BYTES = 16
+OFP_QUEUE_GET_CONFIG_REQUEST_BYTES = 12
OFP_QUEUE_PROP_HEADER_BYTES = 8
OFP_QUEUE_PROP_MIN_RATE_BYTES = 16
OFP_QUEUE_STATS_BYTES = 32
OFP_QUEUE_STATS_REQUEST_BYTES = 8
-OFP_STATS_REPLY_BYTES = 4
-OFP_STATS_REQUEST_BYTES = 4
-OFP_SWITCH_CONFIG_BYTES = 4
-OFP_SWITCH_FEATURES_BYTES = 24
+OFP_STATS_REPLY_BYTES = 12
+OFP_STATS_REQUEST_BYTES = 12
+OFP_SWITCH_CONFIG_BYTES = 12
+OFP_SWITCH_FEATURES_BYTES = 32
OFP_TABLE_STATS_BYTES = 64
-OFP_VENDOR_HEADER_BYTES = 4
+OFP_VENDOR_HEADER_BYTES = 12
diff --git a/src/python/of10/error.py b/src/python/of10/error.py
index c69b70d..700338b 100644
--- a/src/python/of10/error.py
+++ b/src/python/of10/error.py
@@ -17,30 +17,28 @@
"""
def __init__(self):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_HELLO_FAILED
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
+ self.err_type = OFPET_HELLO_FAILED
self.data = ""
def pack(self, assertstruct=True):
self.header.length = self.__len__()
- packed = self.header.pack()
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
return ""
def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+ return OFP_ERROR_MSG_BYTES + len(self.data)
def show(self, prefix=''):
outstr = prefix + "hello_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix + ' ')
outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
##@todo Consider trying to parse the string
@@ -48,8 +46,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
+ return (ofp_error_msg.__eq__(self, other) and
self.data == other.data)
def __ne__(self, other): return not self.__eq__(other)
@@ -67,30 +64,28 @@
"""
def __init__(self):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
+ self.err_type = OFPET_BAD_REQUEST
self.data = ""
def pack(self, assertstruct=True):
self.header.length = self.__len__()
- packed = self.header.pack()
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
return ""
def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+ return OFP_ERROR_MSG_BYTES + len(self.data)
def show(self, prefix=''):
outstr = prefix + "bad_request_error_msg\m"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix + ' ')
outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
##@todo Consider trying to parse the string
@@ -98,8 +93,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
+ return (ofp_error_msg.__eq__(self, other) and
self.data == other.data)
def __ne__(self, other): return not self.__eq__(other)
@@ -117,30 +111,28 @@
"""
def __init__(self):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_ACTION
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
+ self.err_type = OFPET_BAD_ACTION
self.data = ""
def pack(self, assertstruct=True):
self.header.length = self.__len__()
- packed = self.header.pack()
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
return ""
def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+ return OFP_ERROR_MSG_BYTES + len(self.data)
def show(self, prefix=''):
outstr = prefix + "bad_action_error_msg\m"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix + ' ')
outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
##@todo Consider trying to parse the string
@@ -148,8 +140,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
+ return (ofp_error_msg.__eq__(self, other) and
self.data == other.data)
def __ne__(self, other): return not self.__eq__(other)
@@ -167,30 +158,28 @@
"""
def __init__(self):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_FLOW_MOD_FAILED
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
+ self.err_type = OFPET_FLOW_MOD_FAILED
self.data = ""
def pack(self, assertstruct=True):
self.header.length = self.__len__()
- packed = self.header.pack()
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
return ""
def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+ return OFP_ERROR_MSG_BYTES + len(self.data)
def show(self, prefix=''):
outstr = prefix + "flow_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix + ' ')
outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
##@todo Consider trying to parse the string
@@ -198,8 +187,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
+ return (ofp_error_msg.__eq__(self, other) and
self.data == other.data)
def __ne__(self, other): return not self.__eq__(other)
@@ -217,30 +205,28 @@
"""
def __init__(self):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_PORT_MOD_FAILED
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
+ self.err_type = OFPET_PORT_MOD_FAILED
self.data = ""
def pack(self, assertstruct=True):
self.header.length = self.__len__()
- packed = self.header.pack()
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
return ""
def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+ return OFP_ERROR_MSG_BYTES + len(self.data)
def show(self, prefix=''):
outstr = prefix + "port_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix + ' ')
outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
##@todo Consider trying to parse the string
@@ -248,8 +234,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
+ return (ofp_error_msg.__eq__(self, other) and
self.data == other.data)
def __ne__(self, other): return not self.__eq__(other)
@@ -267,30 +252,28 @@
"""
def __init__(self):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_QUEUE_OP_FAILED
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
+ self.err_type = OFPET_QUEUE_OP_FAILED
self.data = ""
def pack(self, assertstruct=True):
self.header.length = self.__len__()
- packed = self.header.pack()
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
return ""
def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
+ return OFP_ERROR_MSG_BYTES + len(self.data)
def show(self, prefix=''):
outstr = prefix + "queue_op_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix + ' ')
outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
##@todo Consider trying to parse the string
@@ -298,8 +281,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
+ return (ofp_error_msg.__eq__(self, other) and
self.data == other.data)
def __ne__(self, other): return not self.__eq__(other)
diff --git a/src/python/of10/message.py b/src/python/of10/message.py
index d614110..5b4ce02 100644
--- a/src/python/of10/message.py
+++ b/src/python/of10/message.py
@@ -19,7 +19,6 @@
Constructor for base class
"""
- self.header = ofp_header()
# Additional base data members declared here
# Normally will define pack, unpack, __len__ functions
@@ -42,9 +41,8 @@
##@var header
# OpenFlow message header: length, version, xid, type
ofp_template_msg.__init__(self)
- self.header = ofp_header()
# For a real message, will be set to an integer
- self.header.type = "TEMPLATE_MSG_VALUE"
+ self.type = "TEMPLATE_MSG_VALUE"
def pack(self):
"""
Pack object into string
@@ -107,7 +105,7 @@
#
################################################################
-class barrier_reply:
+class barrier_reply(ofp_header):
"""
Wrapper class for barrier_reply
@@ -117,12 +115,18 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_BARRIER_REPLY=19)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REPLY
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_BARRIER_REPLY
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -137,9 +141,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
return packed
def unpack(self, binary_string):
@@ -151,8 +156,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
return binary_string
@@ -164,8 +169,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
return length
def show(self, prefix=''):
@@ -180,7 +186,7 @@
outstr = prefix + 'barrier_reply (OFPT_BARRIER_REPLY)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
return outstr
def __eq__(self, other):
@@ -191,8 +197,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
return True
def __ne__(self, other):
@@ -205,7 +211,7 @@
return not self.__eq__(other)
-class barrier_request:
+class barrier_request(ofp_header):
"""
Wrapper class for barrier_request
@@ -215,12 +221,18 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_BARRIER_REQUEST=18)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REQUEST
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_BARRIER_REQUEST
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -235,9 +247,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
return packed
def unpack(self, binary_string):
@@ -249,8 +262,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
return binary_string
@@ -262,8 +275,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
return length
def show(self, prefix=''):
@@ -278,7 +292,7 @@
outstr = prefix + 'barrier_request (OFPT_BARRIER_REQUEST)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
return outstr
def __eq__(self, other):
@@ -289,8 +303,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
return True
def __ne__(self, other):
@@ -303,7 +317,7 @@
return not self.__eq__(other)
-class echo_reply:
+class echo_reply(ofp_header):
"""
Wrapper class for echo_reply
@@ -313,13 +327,19 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_ECHO_REPLY=3)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg data: Binary string following message members
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REPLY
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_ECHO_REPLY
self.data = ""
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -335,9 +355,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
packed += self.data
return packed
@@ -350,8 +371,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
self.data = binary_string
binary_string = ''
return binary_string
@@ -364,8 +385,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
length += len(self.data)
return length
@@ -381,7 +403,7 @@
outstr = prefix + 'echo_reply (OFPT_ECHO_REPLY)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
# if len(self.data) > 0:
@@ -400,8 +422,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
if self.data != other.data: return False
return True
@@ -415,7 +437,7 @@
return not self.__eq__(other)
-class echo_request:
+class echo_request(ofp_header):
"""
Wrapper class for echo_request
@@ -425,13 +447,19 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_ECHO_REQUEST=2)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg data: Binary string following message members
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REQUEST
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_ECHO_REQUEST
self.data = ""
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -447,9 +475,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
packed += self.data
return packed
@@ -462,8 +491,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
self.data = binary_string
binary_string = ''
return binary_string
@@ -476,8 +505,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
length += len(self.data)
return length
@@ -493,7 +523,7 @@
outstr = prefix + 'echo_request (OFPT_ECHO_REQUEST)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
# if len(self.data) > 0:
@@ -512,8 +542,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
if self.data != other.data: return False
return True
@@ -538,6 +568,10 @@
@arg type: The message type (OFPT_ERROR=1)
Data members inherited from ofp_error_msg:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg err_type
@arg code
@arg data: Binary string following message members
@@ -546,8 +580,8 @@
def __init__(self, **kwargs):
ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
+ self.version = OFP_VERSION
+ self.type = OFPT_ERROR
self.data = ""
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -563,8 +597,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_error_msg.pack(self)
packed += self.data
@@ -579,7 +613,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_error_msg.unpack(self, binary_string)
self.data = binary_string
@@ -594,7 +627,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_error_msg.__len__(self)
length += len(self.data)
@@ -612,7 +645,6 @@
outstr = prefix + 'error (OFPT_ERROR)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_error_msg.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
@@ -632,7 +664,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_error_msg.__eq__(self, other): return False
if self.data != other.data: return False
@@ -659,6 +690,10 @@
@arg type: The message type (OFPT_FEATURES_REPLY=6)
Data members inherited from ofp_switch_features:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg datapath_id
@arg n_buffers
@arg n_tables
@@ -670,8 +705,8 @@
def __init__(self, **kwargs):
ofp_switch_features.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REPLY
+ self.version = OFP_VERSION
+ self.type = OFPT_FEATURES_REPLY
self.ports = []
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -687,8 +722,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_switch_features.pack(self)
for obj in self.ports:
@@ -704,7 +739,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_switch_features.unpack(self, binary_string)
while len(binary_string) >= OFP_PHY_PORT_BYTES:
@@ -722,7 +756,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_switch_features.__len__(self)
for obj in self.ports:
@@ -741,7 +775,6 @@
outstr = prefix + 'features_reply (OFPT_FEATURES_REPLY)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_switch_features.show(self, prefix)
outstr += prefix + "Array ports\n"
for obj in self.ports:
@@ -756,7 +789,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_switch_features.__eq__(self, other): return False
if self.ports != other.ports: return False
@@ -772,7 +804,7 @@
return not self.__eq__(other)
-class features_request:
+class features_request(ofp_header):
"""
Wrapper class for features_request
@@ -782,12 +814,18 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_FEATURES_REQUEST=5)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REQUEST
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_FEATURES_REQUEST
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -802,9 +840,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
return packed
def unpack(self, binary_string):
@@ -816,8 +855,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
return binary_string
@@ -829,8 +868,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
return length
def show(self, prefix=''):
@@ -845,7 +885,7 @@
outstr = prefix + 'features_request (OFPT_FEATURES_REQUEST)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
return outstr
def __eq__(self, other):
@@ -856,8 +896,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
return True
def __ne__(self, other):
@@ -881,6 +921,10 @@
@arg type: The message type (OFPT_FLOW_MOD=14)
Data members inherited from ofp_flow_mod:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg match
@arg cookie
@arg command
@@ -896,8 +940,8 @@
def __init__(self, **kwargs):
ofp_flow_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_MOD
+ self.version = OFP_VERSION
+ self.type = OFPT_FLOW_MOD
self.actions = []
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -913,8 +957,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_flow_mod.pack(self)
packed += action_list(self.actions).pack()
@@ -929,10 +973,9 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_flow_mod.unpack(self, binary_string)
- ai_len = self.header.length - (OFP_FLOW_MOD_BYTES + OFP_HEADER_BYTES)
+ ai_len = self.length - (OFP_FLOW_MOD_BYTES + OFP_HEADER_BYTES)
obj = action_list()
binary_string = obj.unpack(binary_string, bytes=ai_len)
self.actions = list(obj)
@@ -947,7 +990,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_flow_mod.__len__(self)
for obj in self.actions:
@@ -966,7 +1009,6 @@
outstr = prefix + 'flow_mod (OFPT_FLOW_MOD)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_flow_mod.show(self, prefix)
outstr += prefix + "List actions\n"
for obj in self.actions:
@@ -981,7 +1023,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_flow_mod.__eq__(self, other): return False
if self.actions != other.actions: return False
@@ -1008,6 +1049,10 @@
@arg type: The message type (OFPT_FLOW_REMOVED=11)
Data members inherited from ofp_flow_removed:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg match
@arg cookie
@arg priority
@@ -1022,8 +1067,8 @@
def __init__(self, **kwargs):
ofp_flow_removed.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_REMOVED
+ self.version = OFP_VERSION
+ self.type = OFPT_FLOW_REMOVED
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -1038,8 +1083,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_flow_removed.pack(self)
return packed
@@ -1053,7 +1098,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_flow_removed.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -1067,7 +1111,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_flow_removed.__len__(self)
return length
@@ -1084,7 +1128,6 @@
outstr = prefix + 'flow_removed (OFPT_FLOW_REMOVED)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_flow_removed.show(self, prefix)
return outstr
@@ -1096,7 +1139,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_flow_removed.__eq__(self, other): return False
return True
@@ -1122,6 +1164,10 @@
@arg type: The message type (OFPT_GET_CONFIG_REPLY=8)
Data members inherited from ofp_switch_config:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg flags
@arg miss_send_len
@@ -1129,8 +1175,8 @@
def __init__(self, **kwargs):
ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REPLY
+ self.version = OFP_VERSION
+ self.type = OFPT_GET_CONFIG_REPLY
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -1145,8 +1191,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_switch_config.pack(self)
return packed
@@ -1160,7 +1206,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_switch_config.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -1174,7 +1219,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_switch_config.__len__(self)
return length
@@ -1191,7 +1236,6 @@
outstr = prefix + 'get_config_reply (OFPT_GET_CONFIG_REPLY)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_switch_config.show(self, prefix)
return outstr
@@ -1203,7 +1247,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_switch_config.__eq__(self, other): return False
return True
@@ -1218,7 +1261,7 @@
return not self.__eq__(other)
-class get_config_request:
+class get_config_request(ofp_header):
"""
Wrapper class for get_config_request
@@ -1228,12 +1271,18 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_GET_CONFIG_REQUEST=7)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REQUEST
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_GET_CONFIG_REQUEST
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -1248,9 +1297,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
return packed
def unpack(self, binary_string):
@@ -1262,8 +1312,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
return binary_string
@@ -1275,8 +1325,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
return length
def show(self, prefix=''):
@@ -1291,7 +1342,7 @@
outstr = prefix + 'get_config_request (OFPT_GET_CONFIG_REQUEST)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
return outstr
def __eq__(self, other):
@@ -1302,8 +1353,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
return True
def __ne__(self, other):
@@ -1316,7 +1367,7 @@
return not self.__eq__(other)
-class hello:
+class hello(ofp_header):
"""
Wrapper class for hello
@@ -1326,13 +1377,19 @@
@arg xid: The transaction ID
@arg type: The message type (OFPT_HELLO=0)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg data: Binary string following message members
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_HELLO
+ ofp_header.__init__(self)
+ self.version = OFP_VERSION
+ self.type = OFPT_HELLO
self.data = ""
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -1348,9 +1405,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
+ packed += ofp_header.pack(self)
packed += self.data
return packed
@@ -1363,8 +1421,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = ofp_header.unpack(self, binary_string)
self.data = binary_string
binary_string = ''
return binary_string
@@ -1377,8 +1435,9 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
+ length += ofp_header.__len__(self)
length += len(self.data)
return length
@@ -1394,7 +1453,7 @@
outstr = prefix + 'hello (OFPT_HELLO)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += ofp_header.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
# if len(self.data) > 0:
@@ -1413,8 +1472,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not ofp_header.__eq__(self, other): return False
if self.data != other.data: return False
return True
@@ -1439,6 +1498,10 @@
@arg type: The message type (OFPT_PACKET_IN=10)
Data members inherited from ofp_packet_in:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg buffer_id
@arg total_len
@arg in_port
@@ -1449,8 +1512,8 @@
def __init__(self, **kwargs):
ofp_packet_in.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_IN
+ self.version = OFP_VERSION
+ self.type = OFPT_PACKET_IN
self.data = ""
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -1466,8 +1529,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_packet_in.pack(self)
packed += self.data
@@ -1482,7 +1545,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_packet_in.unpack(self, binary_string)
self.data = binary_string
@@ -1497,7 +1559,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_packet_in.__len__(self)
length += len(self.data)
@@ -1515,7 +1577,6 @@
outstr = prefix + 'packet_in (OFPT_PACKET_IN)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_packet_in.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
@@ -1535,7 +1596,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_packet_in.__eq__(self, other): return False
if self.data != other.data: return False
@@ -1562,6 +1622,10 @@
@arg type: The message type (OFPT_PACKET_OUT=13)
Data members inherited from ofp_packet_out:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg buffer_id
@arg in_port
@arg actions_len
@@ -1572,8 +1636,8 @@
def __init__(self, **kwargs):
ofp_packet_out.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_OUT
+ self.version = OFP_VERSION
+ self.type = OFPT_PACKET_OUT
self.actions = []
self.data = ""
for (k, v) in kwargs.items():
@@ -1590,8 +1654,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
self.actions_len = 0
for obj in self.actions:
@@ -1610,7 +1674,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_packet_out.unpack(self, binary_string)
obj = action_list()
@@ -1628,7 +1691,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_packet_out.__len__(self)
for obj in self.actions:
@@ -1648,7 +1711,6 @@
outstr = prefix + 'packet_out (OFPT_PACKET_OUT)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_packet_out.show(self, prefix)
outstr += prefix + "List actions\n"
for obj in self.actions:
@@ -1671,7 +1733,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_packet_out.__eq__(self, other): return False
if self.data != other.data: return False
@@ -1699,6 +1760,10 @@
@arg type: The message type (OFPT_PORT_MOD=15)
Data members inherited from ofp_port_mod:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg port_no
@arg hw_addr
@arg config
@@ -1709,8 +1774,8 @@
def __init__(self, **kwargs):
ofp_port_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_MOD
+ self.version = OFP_VERSION
+ self.type = OFPT_PORT_MOD
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -1725,8 +1790,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_port_mod.pack(self)
return packed
@@ -1740,7 +1805,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_port_mod.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -1754,7 +1818,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_port_mod.__len__(self)
return length
@@ -1771,7 +1835,6 @@
outstr = prefix + 'port_mod (OFPT_PORT_MOD)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_port_mod.show(self, prefix)
return outstr
@@ -1783,7 +1846,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_port_mod.__eq__(self, other): return False
return True
@@ -1809,6 +1871,10 @@
@arg type: The message type (OFPT_PORT_STATUS=12)
Data members inherited from ofp_port_status:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg reason
@arg desc
@@ -1816,8 +1882,8 @@
def __init__(self, **kwargs):
ofp_port_status.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_STATUS
+ self.version = OFP_VERSION
+ self.type = OFPT_PORT_STATUS
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -1832,8 +1898,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_port_status.pack(self)
return packed
@@ -1847,7 +1913,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_port_status.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -1861,7 +1926,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_port_status.__len__(self)
return length
@@ -1878,7 +1943,6 @@
outstr = prefix + 'port_status (OFPT_PORT_STATUS)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_port_status.show(self, prefix)
return outstr
@@ -1890,7 +1954,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_port_status.__eq__(self, other): return False
return True
@@ -1916,6 +1979,10 @@
@arg type: The message type (OFPT_QUEUE_GET_CONFIG_REPLY=21)
Data members inherited from ofp_queue_get_config_reply:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg port
@arg queues: Variable length array of TBD
@@ -1923,8 +1990,8 @@
def __init__(self, **kwargs):
ofp_queue_get_config_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REPLY
+ self.version = OFP_VERSION
+ self.type = OFPT_QUEUE_GET_CONFIG_REPLY
self.queues = []
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -1940,8 +2007,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_queue_get_config_reply.pack(self)
for obj in self.queues:
@@ -1957,7 +2024,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_queue_get_config_reply.unpack(self, binary_string)
for obj in self.queues:
@@ -1973,7 +2039,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_queue_get_config_reply.__len__(self)
for obj in self.queues:
@@ -1992,7 +2058,6 @@
outstr = prefix + 'queue_get_config_reply (OFPT_QUEUE_GET_CONFIG_REPLY)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_queue_get_config_reply.show(self, prefix)
outstr += prefix + "Array queues\n"
for obj in self.queues:
@@ -2007,7 +2072,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_queue_get_config_reply.__eq__(self, other): return False
if self.queues != other.queues: return False
@@ -2034,14 +2098,18 @@
@arg type: The message type (OFPT_QUEUE_GET_CONFIG_REQUEST=20)
Data members inherited from ofp_queue_get_config_request:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg port
"""
def __init__(self, **kwargs):
ofp_queue_get_config_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_QUEUE_GET_CONFIG_REQUEST
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -2056,8 +2124,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_queue_get_config_request.pack(self)
return packed
@@ -2071,7 +2139,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_queue_get_config_request.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -2085,7 +2152,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_queue_get_config_request.__len__(self)
return length
@@ -2102,7 +2169,6 @@
outstr = prefix + 'queue_get_config_request (OFPT_QUEUE_GET_CONFIG_REQUEST)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_queue_get_config_request.show(self, prefix)
return outstr
@@ -2114,7 +2180,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_queue_get_config_request.__eq__(self, other): return False
return True
@@ -2140,6 +2205,10 @@
@arg type: The message type (OFPT_SET_CONFIG=9)
Data members inherited from ofp_switch_config:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg flags
@arg miss_send_len
@@ -2147,8 +2216,8 @@
def __init__(self, **kwargs):
ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_SET_CONFIG
+ self.version = OFP_VERSION
+ self.type = OFPT_SET_CONFIG
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -2163,8 +2232,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_switch_config.pack(self)
return packed
@@ -2178,7 +2247,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_switch_config.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -2192,7 +2260,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_switch_config.__len__(self)
return length
@@ -2209,7 +2277,6 @@
outstr = prefix + 'set_config (OFPT_SET_CONFIG)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_switch_config.show(self, prefix)
return outstr
@@ -2221,7 +2288,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_switch_config.__eq__(self, other): return False
return True
@@ -2247,6 +2313,10 @@
@arg type: The message type (OFPT_STATS_REPLY=17)
Data members inherited from ofp_stats_reply:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg stats_type
@arg flags
@@ -2254,8 +2324,8 @@
def __init__(self, **kwargs):
ofp_stats_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REPLY
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -2270,8 +2340,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
return packed
@@ -2285,7 +2355,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -2299,7 +2368,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_stats_reply.__len__(self)
return length
@@ -2316,7 +2385,6 @@
outstr = prefix + 'stats_reply (OFPT_STATS_REPLY)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self, prefix)
return outstr
@@ -2328,7 +2396,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_stats_reply.__eq__(self, other): return False
return True
@@ -2354,6 +2421,10 @@
@arg type: The message type (OFPT_STATS_REQUEST=16)
Data members inherited from ofp_stats_request:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg stats_type
@arg flags
@@ -2361,8 +2432,8 @@
def __init__(self, **kwargs):
ofp_stats_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
for (k, v) in kwargs.items():
if hasattr(self, k):
setattr(self, k, v)
@@ -2377,8 +2448,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
return packed
@@ -2392,7 +2463,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
# Fixme: If no self.data, add check for data remaining
@@ -2406,7 +2476,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_stats_request.__len__(self)
return length
@@ -2423,7 +2493,6 @@
outstr = prefix + 'stats_request (OFPT_STATS_REQUEST)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self, prefix)
return outstr
@@ -2435,7 +2504,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_stats_request.__eq__(self, other): return False
return True
@@ -2461,6 +2529,10 @@
@arg type: The message type (OFPT_VENDOR=4)
Data members inherited from ofp_vendor_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg vendor
@arg data: Binary string following message members
@@ -2468,8 +2540,8 @@
def __init__(self, **kwargs):
ofp_vendor_header.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_VENDOR
+ self.version = OFP_VERSION
+ self.type = OFPT_VENDOR
self.data = ""
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -2485,8 +2557,8 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_vendor_header.pack(self)
packed += self.data
@@ -2501,7 +2573,6 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_vendor_header.unpack(self, binary_string)
self.data = binary_string
@@ -2516,7 +2587,7 @@
string.
"""
- length = OFP_HEADER_BYTES
+ length = 0
length += ofp_vendor_header.__len__(self)
length += len(self.data)
@@ -2534,7 +2605,6 @@
outstr = prefix + 'vendor (OFPT_VENDOR)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
outstr += ofp_vendor_header.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
@@ -2554,7 +2624,6 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
if not ofp_vendor_header.__eq__(self, other): return False
if self.data != other.data: return False
@@ -2692,10 +2761,10 @@
Wrapper class for aggregate stats request message
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_aggregate_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
self.stats_type = OFPST_AGGREGATE
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -2704,14 +2773,13 @@
raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
packed += ofp_aggregate_stats_request.pack(self)
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
binary_string = ofp_aggregate_stats_request.unpack(self, binary_string)
if len(binary_string) != 0:
@@ -2719,21 +2787,19 @@
return binary_string
def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
+ return OFP_STATS_REQUEST_BYTES + \
OFP_AGGREGATE_STATS_REQUEST_BYTES
def show(self, prefix=''):
outstr = prefix + "aggregate_stats_request\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self)
outstr += ofp_aggregate_stats_request.show(self)
return outstr
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
+ return (ofp_stats_request.__eq__(self, other) and
ofp_aggregate_stats_request.__eq__(self, other))
def __ne__(self, other): return not self.__eq__(other)
@@ -2744,23 +2810,22 @@
Wrapper class for aggregate stats reply
"""
def __init__(self):
- self.header = ofp_header()
ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_AGGREGATE
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
+ self.stats_type = OFPST_AGGREGATE
# stats: Array of type aggregate_stats_entry
self.entries = []
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
for obj in self.entries:
packed += obj.pack()
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
dummy = aggregate_stats_entry()
while len(binary_string) >= len(dummy):
@@ -2772,7 +2837,7 @@
return binary_string
def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
+ length = OFP_STATS_REPLY_BYTES
for obj in self.entries:
length += len(obj)
return length
@@ -2780,7 +2845,6 @@
def show(self, prefix=''):
outstr = prefix + "aggregate_stats_reply\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self)
outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
for obj in self.entries:
@@ -2789,8 +2853,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
+ return (ofp_stats_reply.__eq__(self, other) and
self.entries == other.entries)
def __ne__(self, other): return not self.__eq__(other)
@@ -2801,10 +2864,10 @@
Wrapper class for desc stats request message
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_desc_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
self.stats_type = OFPST_DESC
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -2813,14 +2876,13 @@
raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
packed += ofp_desc_stats_request.pack(self)
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
binary_string = ofp_desc_stats_request.unpack(self, binary_string)
if len(binary_string) != 0:
@@ -2828,21 +2890,19 @@
return binary_string
def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
+ return OFP_STATS_REQUEST_BYTES + \
OFP_DESC_STATS_REQUEST_BYTES
def show(self, prefix=''):
outstr = prefix + "desc_stats_request\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self)
outstr += ofp_desc_stats_request.show(self)
return outstr
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
+ return (ofp_stats_request.__eq__(self, other) and
ofp_desc_stats_request.__eq__(self, other))
def __ne__(self, other): return not self.__eq__(other)
@@ -2853,23 +2913,22 @@
Wrapper class for desc stats reply
"""
def __init__(self):
- self.header = ofp_header()
ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_DESC
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
+ self.stats_type = OFPST_DESC
# stats: Array of type desc_stats_entry
self.entries = []
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
for obj in self.entries:
packed += obj.pack()
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
dummy = desc_stats_entry()
while len(binary_string) >= len(dummy):
@@ -2881,7 +2940,7 @@
return binary_string
def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
+ length = OFP_STATS_REPLY_BYTES
for obj in self.entries:
length += len(obj)
return length
@@ -2889,7 +2948,6 @@
def show(self, prefix=''):
outstr = prefix + "desc_stats_reply\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self)
outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
for obj in self.entries:
@@ -2898,8 +2956,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
+ return (ofp_stats_reply.__eq__(self, other) and
self.entries == other.entries)
def __ne__(self, other): return not self.__eq__(other)
@@ -2910,10 +2967,10 @@
Wrapper class for flow stats request message
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_flow_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
self.stats_type = OFPST_FLOW
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -2922,14 +2979,13 @@
raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
packed += ofp_flow_stats_request.pack(self)
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
binary_string = ofp_flow_stats_request.unpack(self, binary_string)
if len(binary_string) != 0:
@@ -2937,21 +2993,19 @@
return binary_string
def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
+ return OFP_STATS_REQUEST_BYTES + \
OFP_FLOW_STATS_REQUEST_BYTES
def show(self, prefix=''):
outstr = prefix + "flow_stats_request\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self)
outstr += ofp_flow_stats_request.show(self)
return outstr
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
+ return (ofp_stats_request.__eq__(self, other) and
ofp_flow_stats_request.__eq__(self, other))
def __ne__(self, other): return not self.__eq__(other)
@@ -2962,23 +3016,22 @@
Wrapper class for flow stats reply
"""
def __init__(self):
- self.header = ofp_header()
ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_FLOW
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
+ self.stats_type = OFPST_FLOW
# stats: Array of type flow_stats_entry
self.entries = []
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
for obj in self.entries:
packed += obj.pack()
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
dummy = flow_stats_entry()
while len(binary_string) >= len(dummy):
@@ -2990,7 +3043,7 @@
return binary_string
def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
+ length = OFP_STATS_REPLY_BYTES
for obj in self.entries:
length += len(obj)
return length
@@ -2998,7 +3051,6 @@
def show(self, prefix=''):
outstr = prefix + "flow_stats_reply\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self)
outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
for obj in self.entries:
@@ -3007,8 +3059,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
+ return (ofp_stats_reply.__eq__(self, other) and
self.entries == other.entries)
def __ne__(self, other): return not self.__eq__(other)
@@ -3019,10 +3070,10 @@
Wrapper class for port stats request message
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_port_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
self.stats_type = OFPST_PORT
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -3031,14 +3082,13 @@
raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
packed += ofp_port_stats_request.pack(self)
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
binary_string = ofp_port_stats_request.unpack(self, binary_string)
if len(binary_string) != 0:
@@ -3046,21 +3096,19 @@
return binary_string
def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
+ return OFP_STATS_REQUEST_BYTES + \
OFP_PORT_STATS_REQUEST_BYTES
def show(self, prefix=''):
outstr = prefix + "port_stats_request\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self)
outstr += ofp_port_stats_request.show(self)
return outstr
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
+ return (ofp_stats_request.__eq__(self, other) and
ofp_port_stats_request.__eq__(self, other))
def __ne__(self, other): return not self.__eq__(other)
@@ -3071,23 +3119,22 @@
Wrapper class for port stats reply
"""
def __init__(self):
- self.header = ofp_header()
ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_PORT
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
+ self.stats_type = OFPST_PORT
# stats: Array of type port_stats_entry
self.entries = []
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
for obj in self.entries:
packed += obj.pack()
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
dummy = port_stats_entry()
while len(binary_string) >= len(dummy):
@@ -3099,7 +3146,7 @@
return binary_string
def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
+ length = OFP_STATS_REPLY_BYTES
for obj in self.entries:
length += len(obj)
return length
@@ -3107,7 +3154,6 @@
def show(self, prefix=''):
outstr = prefix + "port_stats_reply\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self)
outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
for obj in self.entries:
@@ -3116,8 +3162,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
+ return (ofp_stats_reply.__eq__(self, other) and
self.entries == other.entries)
def __ne__(self, other): return not self.__eq__(other)
@@ -3128,10 +3173,10 @@
Wrapper class for queue stats request message
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_queue_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
self.stats_type = OFPST_QUEUE
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -3140,14 +3185,13 @@
raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
packed += ofp_queue_stats_request.pack(self)
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
binary_string = ofp_queue_stats_request.unpack(self, binary_string)
if len(binary_string) != 0:
@@ -3155,21 +3199,19 @@
return binary_string
def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
+ return OFP_STATS_REQUEST_BYTES + \
OFP_QUEUE_STATS_REQUEST_BYTES
def show(self, prefix=''):
outstr = prefix + "queue_stats_request\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self)
outstr += ofp_queue_stats_request.show(self)
return outstr
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
+ return (ofp_stats_request.__eq__(self, other) and
ofp_queue_stats_request.__eq__(self, other))
def __ne__(self, other): return not self.__eq__(other)
@@ -3180,23 +3222,22 @@
Wrapper class for queue stats reply
"""
def __init__(self):
- self.header = ofp_header()
ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_QUEUE
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
+ self.stats_type = OFPST_QUEUE
# stats: Array of type queue_stats_entry
self.entries = []
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
for obj in self.entries:
packed += obj.pack()
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
dummy = queue_stats_entry()
while len(binary_string) >= len(dummy):
@@ -3208,7 +3249,7 @@
return binary_string
def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
+ length = OFP_STATS_REPLY_BYTES
for obj in self.entries:
length += len(obj)
return length
@@ -3216,7 +3257,6 @@
def show(self, prefix=''):
outstr = prefix + "queue_stats_reply\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self)
outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
for obj in self.entries:
@@ -3225,8 +3265,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
+ return (ofp_stats_reply.__eq__(self, other) and
self.entries == other.entries)
def __ne__(self, other): return not self.__eq__(other)
@@ -3237,10 +3276,10 @@
Wrapper class for table stats request message
"""
def __init__(self, **kwargs):
- self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_table_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REQUEST
self.stats_type = OFPST_TABLE
for (k, v) in kwargs.items():
if hasattr(self, k):
@@ -3249,14 +3288,13 @@
raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_request.pack(self)
packed += ofp_table_stats_request.pack(self)
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_request.unpack(self, binary_string)
binary_string = ofp_table_stats_request.unpack(self, binary_string)
if len(binary_string) != 0:
@@ -3264,21 +3302,19 @@
return binary_string
def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
+ return OFP_STATS_REQUEST_BYTES + \
OFP_TABLE_STATS_REQUEST_BYTES
def show(self, prefix=''):
outstr = prefix + "table_stats_request\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_request.show(self)
outstr += ofp_table_stats_request.show(self)
return outstr
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
+ return (ofp_stats_request.__eq__(self, other) and
ofp_table_stats_request.__eq__(self, other))
def __ne__(self, other): return not self.__eq__(other)
@@ -3289,23 +3325,22 @@
Wrapper class for table stats reply
"""
def __init__(self):
- self.header = ofp_header()
ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_TABLE
+ self.version = OFP_VERSION
+ self.type = OFPT_STATS_REPLY
+ self.stats_type = OFPST_TABLE
# stats: Array of type table_stats_entry
self.entries = []
def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
+ self.length = len(self)
+ packed = ""
packed += ofp_stats_reply.pack(self)
for obj in self.entries:
packed += obj.pack()
return packed
def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
binary_string = ofp_stats_reply.unpack(self, binary_string)
dummy = table_stats_entry()
while len(binary_string) >= len(dummy):
@@ -3317,7 +3352,7 @@
return binary_string
def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
+ length = OFP_STATS_REPLY_BYTES
for obj in self.entries:
length += len(obj)
return length
@@ -3325,7 +3360,6 @@
def show(self, prefix=''):
outstr = prefix + "table_stats_reply\n"
outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
outstr += ofp_stats_reply.show(self)
outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
for obj in self.entries:
@@ -3334,8 +3368,7 @@
def __eq__(self, other):
if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
+ return (ofp_stats_reply.__eq__(self, other) and
self.entries == other.entries)
def __ne__(self, other): return not self.__eq__(other)
diff --git a/src/python/of10/parse.py b/src/python/of10/parse.py
index 63d17c9..ac76a16 100644
--- a/src/python/of10/parse.py
+++ b/src/python/of10/parse.py
@@ -96,12 +96,13 @@
"""
hdr = message.ofp_header()
hdr.unpack(binary_string)
+ logging.info(hdr.show())
# FIXME: Add error detection
if not hdr.type in msg_type_subclassed:
return msg_type_to_class_map[hdr.type]()
if hdr.type == cstruct.OFPT_STATS_REQUEST:
sub_hdr = message.ofp_stats_request()
- sub_hdr.unpack(binary_string[cstruct.OFP_HEADER_BYTES:])
+ sub_hdr.unpack(binary_string)
try:
obj = stats_request_to_class_map[sub_hdr.stats_type]()
except KeyError:
@@ -109,7 +110,7 @@
return obj
elif hdr.type == cstruct.OFPT_STATS_REPLY:
sub_hdr = message.ofp_stats_reply()
- sub_hdr.unpack(binary_string[cstruct.OFP_HEADER_BYTES:])
+ sub_hdr.unpack(binary_string)
try:
obj = stats_reply_to_class_map[sub_hdr.stats_type]()
except KeyError:
@@ -117,7 +118,7 @@
return obj
elif hdr.type == cstruct.OFPT_ERROR:
sub_hdr = message.ofp_error_msg()
- sub_hdr.unpack(binary_string[cstruct.OFP_HEADER_BYTES:])
+ sub_hdr.unpack(binary_string)
return error_to_class_map[sub_hdr.err_type]()
else:
parse_logger.error("Cannot parse pkt to message")
diff --git a/src/python/oftest/base_tests.py b/src/python/oftest/base_tests.py
index 5c6c9cf..9d905f9 100644
--- a/src/python/oftest/base_tests.py
+++ b/src/python/oftest/base_tests.py
@@ -44,7 +44,7 @@
reply, pkt = self.controller.transact(request)
self.assertTrue(reply is not None,
"Did not complete features_request for handshake")
- if reply.header.version == 1:
+ if reply.version == 1:
self.supported_actions = reply.actions
logging.info("Supported actions: " + hex(self.supported_actions))
except:
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
diff --git a/src/python/oftest/illegal_message.py b/src/python/oftest/illegal_message.py
index eeb5022..2d0ce7b 100644
--- a/src/python/oftest/illegal_message.py
+++ b/src/python/oftest/illegal_message.py
@@ -6,26 +6,36 @@
ILLEGAL_MESSAGE_TYPE=217
-class illegal_message_type:
+class illegal_message_type(of10.ofp_header):
"""
- Wrapper class for illegal message
+ Wrapper class for illegal_message_type
OpenFlow message header: length, version, xid, type
@arg length: The total length of the message
@arg version: The OpenFlow version (1)
@arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REQUEST=2)
+ @arg type: The message type (ILLEGAL_MESSAGE_TYPE=217)
+ Data members inherited from ofp_header:
+ @arg version
+ @arg type
+ @arg length
+ @arg xid
@arg data: Binary string following message members
- The message type is set to "illegal" and the pack assert
- check for the OF header is disabled
"""
- def __init__(self):
- self.header = of10.ofp_header()
- self.header.type = ILLEGAL_MESSAGE_TYPE
+ def __init__(self, **kwargs):
+ of10.ofp_header.__init__(self)
+ self.version = of10.OFP_VERSION
+ self.type = ILLEGAL_MESSAGE_TYPE
self.data = ""
+ for (k, v) in kwargs.items():
+ if hasattr(self, k):
+ setattr(self, k, v)
+ else:
+ raise NameError("field %s does not exist in %s" % (k, self.__class__))
+
def pack(self):
"""
@@ -34,9 +44,10 @@
@return The packed string which can go on the wire
"""
- self.header.length = len(self)
- packed = self.header.pack(assertstruct=False)
+ self.length = len(self)
+ packed = ""
+ packed += of10.ofp_header.pack(self, assertstruct=False)
packed += self.data
return packed
@@ -49,8 +60,8 @@
@return The remainder of binary_string that was not parsed.
"""
- binary_string = self.header.unpack(binary_string)
+ binary_string = of10.ofp_header.unpack(self, binary_string)
self.data = binary_string
binary_string = ''
return binary_string
@@ -63,8 +74,9 @@
string.
"""
- length = of10.OFP_HEADER_BYTES
+ length = 0
+ length += of10.ofp_header.__len__(self)
length += len(self.data)
return length
@@ -77,12 +89,18 @@
"""
- outstr = prefix + 'illegal_message (' + \
- str(ILLEGAL_MESSAGE_TYPE) + ')\n'
+ outstr = prefix + 'illegal_message (217)\n'
prefix += ' '
outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
+ outstr += of10.ofp_header.show(self, prefix)
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
+ ##@todo Fix this circular reference
+ # if len(self.data) > 0:
+ # obj = of_message_parse(self.data)
+ # if obj != None:
+ # outstr += obj.show(prefix)
+ # else:
+ # outstr += prefix + "Unable to parse data\n"
return outstr
def __eq__(self, other):
@@ -93,8 +111,8 @@
"""
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
+ if not of10.ofp_header.__eq__(self, other): return False
if self.data != other.data: return False
return True