summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py b/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
index c0a753c..35bcf1f 100755
--- a/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
+++ b/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
@@ -644,8 +644,11 @@ class Scapy_service(Scapy_service_api):
for field_desc in pkt.fields_desc:
field_id = field_desc.name
ignored = field_id not in layer_full.fields
- offset = field_desc._offset
- protocol_offset = pkt._offset
+ # scapy offset/length calculation doesn't support dynamic size structures
+ # since PktClass.fields_desc is a singletone,
+ # _offset/size can be missing, uninitialized or contain values from the previous runs
+ offset = getattr(field_desc, '_offset', None)
+ protocol_offset = getattr(pkt, '_offset', None)
field_sz = field_desc.get_size_bytes()
# some values are unavailable in pkt(original model)
# at the same time,
@@ -708,7 +711,7 @@ class Scapy_service(Scapy_service_api):
fields.append(field_data)
layer_data = {
"id": layer_id,
- "offset": pkt._offset,
+ "offset": protocol_offset,
"fields": fields,
"real_id": real_layer_id,
"valid_structure": valid_struct,