diff mbox series

[1/3] framework/packet.py:add interface for write raw pkt

Message ID 20201209015944.12586-2-junx.w.zhou@intel.com (mailing list archive)
State Superseded
Headers show
Series add new interface for write raw pkt and | expand

Commit Message

Zhou, JunX W Dec. 9, 2020, 1:59 a.m. UTC
Signed-off-by: Zhou Jun <junx.w.zhou@intel.com>
---
 framework/packet.py | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

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 = {