diff --git a/scapy/contrib/openflow.py b/scapy/contrib/openflow.py index 954fd4a3a..f04ce3e0c 100755 --- a/scapy/contrib/openflow.py +++ b/scapy/contrib/openflow.py @@ -16,7 +16,7 @@ import struct from scapy.fields import * from scapy.layers.l2 import * from scapy.layers.inet import * -from scapy.compat import orb +from scapy.compat import orb, raw ### If prereq_autocomplete is True then match prerequisites will be ### automatically handled. See OFPMatch class. @@ -95,7 +95,7 @@ class OFPPhyPort(Packet): FlagsField("peer", 0, 32, ofp_port_features) ] def extract_padding(self, s): - return "", s + return b"", s class OFPMatch(Packet): name = "OFP_MATCH" @@ -127,7 +127,7 @@ class OFPMatch(Packet): ShortField("tp_dst", None) ] def extract_padding(self, s): - return "", s + return b"", s ### with post_build we create the wildcards field bit by bit def post_build(self, p, pay): @@ -398,7 +398,7 @@ class QueuePropertyPacketListField(PacketListField): def getfield(self, pkt, s): lst = [] l = 0 - ret = "" + ret = b"" remain = s while remain: @@ -413,11 +413,11 @@ class QueuePropertyPacketListField(PacketListField): class OFPPacketQueue(Packet): def extract_padding(self, s): - return "", s + return b"", s def post_build(self, p, pay): if self.properties == []: - p += str(OFPQTNone()) + p += raw(OFPQTNone()) if self.len is None: l = len(p)+len(pay) p = p[:4] + struct.pack("!H", l) + p[6:] @@ -439,7 +439,7 @@ class QueuePacketListField(PacketListField): def getfield(self, pkt, s): lst = [] l = 0 - ret = "" + ret = b"" remain = s while remain: @@ -969,7 +969,7 @@ class OFPTStatsRequestTable(_ofp_header): class OFPTableStats(Packet): def extract_padding(self, s): - return "", s + return b"", s name = "OFP_TABLE_STATS" fields_desc = [ ByteField("table_id", 0), @@ -1019,7 +1019,7 @@ class OFPTStatsRequestPort(_ofp_header): class OFPPortStats(Packet): def extract_padding(self, s): - return "", s + return b"", s name = "OFP_PORT_STATS" fields_desc = [ ShortEnumField("port_no", 0, ofp_port_no), diff --git a/scapy/contrib/openflow.uts b/scapy/contrib/openflow.uts index 168fc5a97..d228b13f3 100755 --- a/scapy/contrib/openflow.uts +++ b/scapy/contrib/openflow.uts @@ -14,7 +14,7 @@ raw(ofm) == b'\x01\x02\x00\x08\x00\x00\x00\x00' ofm = OFPMatch(in_port=1, nw_tos=8) ofm = OFPMatch(raw(ofm)) assert(ofm.wildcards1 == 0x1) -ofm.wildcards2 == 0xfe +ofm.wildcards2 == 0xee = OpenFlow(), generic method test with OFPTEchoRequest() ofm = OFPTEchoRequest() @@ -37,7 +37,7 @@ act2 = OFPATOutput(port='CONTROLLER') act3 = OFPATSetDlSrc(dl_addr='1a:d5:cb:4e:3c:64') ofm = OFPTFlowMod(priority=1000, match=mtc, flags='CHECK_OVERLAP', actions=[act1,act2,act3]) raw(ofm) -s = b'\x01\x0e\x00h\x00\x00\x00\x00\x00?\xc8\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa8*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xe8\xff\xff\xff\xff\xff\xff\x00\x02\x00\x06\x00\x08\xc0\xa8*\x01\x00\x00\x00\x08\xff\xfd\xff\xff\x00\x04\x00\x10\x1a\xd5\xcbN