summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2017-02-22 13:48:14 +0200
committerimarom <imarom@cisco.com>2017-02-22 13:49:23 +0200
commit97144e5554fdd9f5ca71e8086154031f6d2435eb (patch)
tree7de5893d333c3e91a4787452d8847224052f1e33 /scripts
parent74a55c270b465ae6e0ec36d58a1f2f4b0e132e00 (diff)
fix for https://trex-tgn.cisco.com/youtrack/issue/trex-358
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py7
-rw-r--r--scripts/external_libs/scapy-2.3.1/python2/scapy/packet.py24
-rw-r--r--scripts/external_libs/scapy-2.3.1/python3/scapy/packet.py24
3 files changed, 27 insertions, 28 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
index 679068ac..edd3d91e 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
@@ -485,7 +485,7 @@ class CTRexScapyPktUtl(object):
for pkt in self.pkt_iter ():
if pkt.name == name:
if cnt==0:
- return (pkt, pkt.offset)
+ return (pkt, pkt._offset)
else:
cnt=cnt -1
@@ -500,7 +500,7 @@ class CTRexScapyPktUtl(object):
for pkt in self.pkt_iter ():
if pkt.name == name:
if cnt==0:
- return pkt.offset
+ return pkt._offset
else:
cnt=cnt -1
@@ -513,12 +513,11 @@ class CTRexScapyPktUtl(object):
t=self._layer_offset(layer,layer_cnt);
l_offset=t[1];
layer_pkt=t[0]
-
#layer_pkt.dump_fields_offsets ()
for f in layer_pkt.fields_desc:
if f.name == field_name:
- return (l_offset+f.offset,f.get_size_bytes ());
+ return (l_offset+f._offset,f.get_size_bytes ());
raise CTRexPacketBuildException(-11, "No layer %s-%d." % (field_name, layer_cnt))
diff --git a/scripts/external_libs/scapy-2.3.1/python2/scapy/packet.py b/scripts/external_libs/scapy-2.3.1/python2/scapy/packet.py
index 711d7032..5bd2e693 100644
--- a/scripts/external_libs/scapy-2.3.1/python2/scapy/packet.py
+++ b/scripts/external_libs/scapy-2.3.1/python2/scapy/packet.py
@@ -77,7 +77,7 @@ class Packet(BasePacket):
self.name = self.__class__.__name__
self.aliastypes = [ self.__class__ ] + self.aliastypes
self.default_fields = {}
- self.offset=0; # offset of the object
+ self._offset=0; # offset of the object
self.offset_fields = {} # ofsset of each field
self.overloaded_fields = {}
self.fields={}
@@ -159,7 +159,7 @@ class Packet(BasePacket):
clone.default_fields = self.default_fields.copy()
clone.overloaded_fields = self.overloaded_fields.copy()
clone.overload_fields = self.overload_fields.copy()
- clone.offset=self.offset
+ clone._offset=self._offset
clone.underlayer = self.underlayer
clone.explicit = self.explicit
clone.raw_packet_cache = self.raw_packet_cache
@@ -170,7 +170,7 @@ class Packet(BasePacket):
def dump_offsets (self):
print "obj-id ",id(self),
- print self.name ,self.offset
+ print self.name ,self._offset
if self.payload:
self.payload.dump_offsets()
@@ -316,7 +316,7 @@ class Packet(BasePacket):
def dump_fields_offsets (self):
for f in self.fields_desc:
- print "field %-40s %02d %02d" % (f.name, f.offset,f.get_size_bytes ());
+ print "field %-40s %02d %02d" % (f.name, f._offset,f.get_size_bytes ());
def self_build(self, field_pos_list=None):
@@ -325,10 +325,10 @@ class Packet(BasePacket):
p=""
for f in self.fields_desc:
if type(p) is tuple :
- f.offset=len(p[0])
+ f._offset=len(p[0])
else:
assert(type(p)==str)
- f.offset=len(p)
+ f._offset=len(p)
val = self.getfieldval(f.name)
if isinstance(val, RawVal):
@@ -336,7 +336,7 @@ class Packet(BasePacket):
p += sval
if field_pos_list is not None:
field_pos_list.append( (f.name, sval.encode("string_escape"), len(p), len(sval) ) )
- f.offset= val
+ f._offset= val
else:
p = f.addfield(self, p, val)
@@ -347,14 +347,14 @@ class Packet(BasePacket):
def do_update_payload_offset(self,pkt):
#print "obj-id ",id(self)
- #print "current offset ",self.name," ",self.offset
+ #print "current offset ",self.name," ",self._offset
#print "current header size ",len(pkt)
- self.payload.offset = self.offset + len(pkt)
+ self.payload._offset = self._offset + len(pkt)
def dump_layers_offset (self):
p=self;
while True:
- print p.name, "offset :",p.offset
+ print p.name, "offset :",p._offset
p=p.payload
if p ==None or isinstance(p,NoPayload):
break;
@@ -387,7 +387,7 @@ class Packet(BasePacket):
assert(type(p) == type(o) )
#copy
- p.offset=o.offset
+ p._offset=o._offset
#next
p=p.payload
@@ -705,7 +705,7 @@ Creates an EPS file describing a packet. If filename is not provided a temporary
pkt = self.__class__()
pkt.explicit = 1
pkt.fields = kargs
- pkt.offset=self.offset
+ pkt._offset=self._offset
pkt.time = self.time
pkt.underlayer = self.underlayer
pkt.overload_fields = self.overload_fields.copy()
diff --git a/scripts/external_libs/scapy-2.3.1/python3/scapy/packet.py b/scripts/external_libs/scapy-2.3.1/python3/scapy/packet.py
index c92a27b1..5fcf57c6 100644
--- a/scripts/external_libs/scapy-2.3.1/python3/scapy/packet.py
+++ b/scripts/external_libs/scapy-2.3.1/python3/scapy/packet.py
@@ -81,7 +81,7 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
self.name = self.__class__.__name__
self.aliastypes = [ self.__class__ ] + self.aliastypes
self.default_fields = {}
- self.offset=0; # offset of the object
+ self._offset=0; # offset of the object
self.offset_fields = {} # ofsset of each field
self.overloaded_fields = {}
self.fields={}
@@ -163,7 +163,7 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
clone.default_fields = self.default_fields.copy()
clone.overloaded_fields = self.overloaded_fields.copy()
clone.overload_fields = self.overload_fields.copy()
- clone.offset=self.offset
+ clone._offset=self._offset
clone.underlayer = self.underlayer
clone.explicit = self.explicit
clone.raw_packet_cache = self.raw_packet_cache
@@ -173,7 +173,7 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
return clone
def dump_offsets (self):
- print ("obj-id {0} {1} {2}".format(id(self),self.name ,self.offset))
+ print ("obj-id {0} {1} {2}".format(id(self),self.name ,self._offset))
if self.payload:
self.payload.dump_offsets()
@@ -335,7 +335,7 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
def dump_fields_offsets (self):
for f in self.fields_desc:
- print ("field %-40s %02d %02d" % (f.name, f.offset,f.get_size_bytes () ) );
+ print ("field %-40s %02d %02d" % (f.name, f._offset,f.get_size_bytes () ) );
def self_build(self, field_pos_list=None):
if self.raw_packet_cache is not None:
@@ -344,10 +344,10 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
for f in self.fields_desc:
#print(f.name)
if type(p) is tuple :
- f.offset=len(p[0])
+ f._offset=len(p[0])
else:
assert(type(p)==bytes)
- f.offset=len(p)
+ f._offset=len(p)
val = self.getfieldval(f.name)
if isinstance(val, RawVal):
@@ -356,7 +356,7 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
p += sval
if field_pos_list is not None:
field_pos_list.append( (f.name, sval.encode("string_escape"), len(p), len(sval) ) )
- f.offset= val
+ f._offset= val
else:
p = f.addfield(self, p, val)
return p
@@ -366,14 +366,14 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
def do_update_payload_offset(self,pkt):
#print "obj-id ",id(self)
- #print "current offset ",self.name," ",self.offset
+ #print "current offset ",self.name," ",self._offset
#print "current header size ",len(pkt)
- self.payload.offset = self.offset + len(pkt)
+ self.payload._offset = self._offset + len(pkt)
def dump_layers_offset (self):
p=self;
while True:
- print (p.name, "offset :",p.offset)
+ print (p.name, "offset :",p._offset)
p=p.payload
if p ==None or isinstance(p,NoPayload):
break;
@@ -403,7 +403,7 @@ class Packet(BasePacket, metaclass = Packet_metaclass):
assert(type(p) == type(o) )
#copy
- p.offset=o.offset
+ p._offset=o._offset
#next
p=p.payload
@@ -719,7 +719,7 @@ Creates an EPS file describing a packet. If filename is not provided a temporary
pkt = self.__class__()
pkt.explicit = 1
pkt.fields = kargs
- pkt.offset=self.offset
+ pkt._offset=self._offset
pkt.time = self.time
pkt.underlayer = self.underlayer
pkt.overload_fields = self.overload_fields.copy()