[dts] [PATCH V3 1/3] framework/packet:add new interface for write raw pkt

Zhou Jun junx.w.zhou at intel.com
Wed Dec 9 03:50:10 CET 2020


framework/packet:add new interface for write raw pkt

Signed-off-by: Zhou Jun <junx.w.zhou at intel.com>
---
 framework/packet.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/framework/packet.py b/framework/packet.py
index 7d974db0..e13e74f2 100644
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -119,6 +119,12 @@ PKTGEN_PIDS = {}
 # default filter for LLDP packet
 LLDP_FILTER = {'layer': 'ether', 'config': {'type': 'not lldp'}}
 
+def write_raw_pkt(pkt_str, file_name):
+    tmp = eval(pkt_str)
+    tmp = bytearray(bytes(tmp))
+    with open(file_name, 'wb') as w:
+        w.write(tmp)
+        w.close()
 
 class scapy(object):
     SCAPY_LAYERS = {
-- 
2.17.1



More information about the dts mailing list