diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-02-16 00:23:40 +0200 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-02-16 00:23:40 +0200 |
commit | 229618c0663517e8e03ee0a34e0f53584381fd69 (patch) | |
tree | decb33aa5342a43be4f324e44484bd4e4881afb9 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py | |
parent | aebe518a0f109f25928cf82eb998e7b7602a2c03 (diff) |
ws_main - add exp folder, scapy - add ipv6 verify/conversion to str buffer, hltapi - add ipv6, vlan.
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py | 15 |
1 files changed, 13 insertions, 2 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 1e2286c5..88efe265 100644 --- 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 @@ -12,8 +12,6 @@ from trex_stl_packet_builder_interface import CTrexPktBuilderInterface from scapy.all import * - - class CTRexPacketBuildException(Exception): """ This is the general Packet Building error exception class. @@ -61,6 +59,19 @@ def is_valid_ipv4(ip_addr): raise CTRexPacketBuildException(-10,"not valid ipv4 format"); +def is_valid_ipv6(ipv6_addr): + """ + return buffer in network order + """ + if type(ipv6_addr)==str and len(ipv6_addr) == 16: + return ipv6_addr + try: + return socket.inet_pton(socket.AF_INET6, ipv6_addr) + except AttributeError: # no inet_pton here, sorry + raise CTRexPacketBuildException(-10, 'No inet_pton function available') + except: + raise CTRexPacketBuildException(-10, 'Not valid ipv6 format') + class CTRexScriptsBase(object): """ VM Script base class |