From 7829fea4a2c8936513fa95215b7d84997f814a69 Mon Sep 17 00:00:00 2001 From: pmikus Date: Thu, 10 Jun 2021 08:02:29 +0000 Subject: FIX: Pylint reduce Signed-off-by: pmikus Change-Id: I909942dbb920df7f0fe15c0c92cda92c3cd8d8ad --- GPL/tools/trex/trex_astf_assert.py | 2 +- GPL/tools/trex/trex_astf_profile.py | 2 +- GPL/tools/trex/trex_astf_stop.py | 4 +-- GPL/tools/trex/trex_stl_assert.py | 2 +- GPL/tools/trex/trex_stl_profile.py | 4 +-- GPL/tools/trex/trex_stl_stop.py | 4 +-- .../trex/profile_trex_astf_base_class.py | 2 +- .../trex/trex-stl-2n-dot1qip4asym-ip4src254.py | 30 ++++++++--------- .../trex/trex-stl-2n-ethip4-macsrc500kdst500k.py | 18 +++++----- .../trex/trex-stl-2n-ethip4-macsrc50kdst50k.py | 8 ++--- .../trex/trex-stl-2n-ethip4-macsrc5kdst5k.py | 8 ++--- .../trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py | 3 +- .../trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py | 1 - .../trex/trex-stl-3n-ethip4-ip4dst60000.py | 2 +- .../trex/trex-stl-3n-ethip4-macsrc500kdst500k.py | 8 ++--- .../trex/trex-stl-3n-ethip4-macsrc5kdst5k.py | 8 ++--- .../trex/trex-stl-3n-ethip4udp-10u15p.py | 4 +-- .../trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py | 3 +- GPL/traffic_scripts/PacketVerifier.py | 1 + GPL/traffic_scripts/geneve_tunnel.py | 6 ++-- GPL/traffic_scripts/ipsec_interface.py | 12 +++---- GPL/traffic_scripts/ipsec_policy.py | 6 ++-- GPL/traffic_scripts/lisp/lisp_check.py | 27 ++++++++++++--- GPL/traffic_scripts/lisp/lispgpe_check.py | 24 +++++++++++--- GPL/traffic_scripts/nat.py | 24 +++++++++++--- GPL/traffic_scripts/policer.py | 7 ++-- GPL/traffic_scripts/send_icmp_wait_for_reply.py | 34 +++++++++---------- GPL/traffic_scripts/send_ip_check_headers.py | 26 ++++++++++++--- GPL/traffic_scripts/srv6_encap.py | 38 +++++++++++----------- GPL/traffic_scripts/vxlan.py | 4 +++ 62 files changed, 192 insertions(+), 162 deletions(-) (limited to 'GPL') diff --git a/GPL/tools/trex/trex_astf_assert.py b/GPL/tools/trex/trex_astf_assert.py index e983f598b9..494f3832bd 100644 --- a/GPL/tools/trex/trex_astf_assert.py +++ b/GPL/tools/trex/trex_astf_assert.py @@ -40,7 +40,7 @@ import sys sys.path.insert( 0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/" ) -from trex.astf.api import * +from trex.astf.api import ASTFClient, TRexError def main(): diff --git a/GPL/tools/trex/trex_astf_profile.py b/GPL/tools/trex/trex_astf_profile.py index d08fb61778..193ff21185 100644 --- a/GPL/tools/trex/trex_astf_profile.py +++ b/GPL/tools/trex/trex_astf_profile.py @@ -36,7 +36,7 @@ import time sys.path.insert( 0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/" ) -from trex.astf.api import * +from trex.astf.api import ASTFClient, ASTFProfile, TRexError def fmt_latency(lat_min, lat_avg, lat_max, hdrh): diff --git a/GPL/tools/trex/trex_astf_stop.py b/GPL/tools/trex/trex_astf_stop.py index 1db122ba0f..871b252328 100644 --- a/GPL/tools/trex/trex_astf_stop.py +++ b/GPL/tools/trex/trex_astf_stop.py @@ -41,12 +41,10 @@ import argparse import json import sys -from collections import OrderedDict # Needed to parse xstats representation. - sys.path.insert( 0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/" ) -from trex.astf.api import * +from trex.astf.api import ASTFClient def main(): diff --git a/GPL/tools/trex/trex_stl_assert.py b/GPL/tools/trex/trex_stl_assert.py index eef06be49f..f4f6d16603 100644 --- a/GPL/tools/trex/trex_stl_assert.py +++ b/GPL/tools/trex/trex_stl_assert.py @@ -40,7 +40,7 @@ import sys sys.path.insert( 0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/" ) -from trex.stl.api import * +from trex.stl.api import STLClient, STLError def main(): diff --git a/GPL/tools/trex/trex_stl_profile.py b/GPL/tools/trex/trex_stl_profile.py index 4eedc80899..cef985870c 100644 --- a/GPL/tools/trex/trex_stl_profile.py +++ b/GPL/tools/trex/trex_stl_profile.py @@ -36,7 +36,7 @@ import time sys.path.insert( 0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/" ) -from trex.stl.api import * +from trex.stl.api import STLClient, STLProfile, STLError def fmt_latency(lat_min, lat_avg, lat_max, hdrh): @@ -155,7 +155,7 @@ def simple_burst( if u"macsrc" in profile_file: client.set_port_attr(ports=[port_0, port_1], promiscuous=True) if isinstance(framesize, int): - last_stream_a = int((len(streams) - 2 ) / 2) + last_stream_a = int((len(streams) - 2) / 2) last_stream_b = (last_stream_a * 2) client.add_streams(streams[0:last_stream_a], ports=[port_0]) if traffic_directions > 1: diff --git a/GPL/tools/trex/trex_stl_stop.py b/GPL/tools/trex/trex_stl_stop.py index 1704a89220..14ec817f70 100644 --- a/GPL/tools/trex/trex_stl_stop.py +++ b/GPL/tools/trex/trex_stl_stop.py @@ -41,12 +41,10 @@ import argparse import json import sys -from collections import OrderedDict # Needed to parse xstats representation. - sys.path.insert( 0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/" ) -from trex.stl.api import * +from trex.stl.api import STLClient def main(): diff --git a/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py b/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py index 80ae78fc5a..e36e52c2c1 100644 --- a/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py +++ b/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py @@ -133,7 +133,7 @@ class TrafficProfileBaseClass: """ self.framesize = kwargs[u"framesize"] self._pcap_dir = kwargs.get( - u"pcap_dir",u"/opt/trex-core-2.88/scripts/avl" + u"pcap_dir", u"/opt/trex-core-2.88/scripts/avl" ) return self.create_profile() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py b/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py index f5da9d95b7..91df41eba7 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py +++ b/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py @@ -70,24 +70,24 @@ class TrafficStreams(TrafficStreamsBaseClass): # Direction 0 --> 1 base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) ) # Direction 1 --> 0 base_pkt_b = ( - Ether() / - Dot1Q( - vlan=self.vlan_id - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) + Ether() / + Dot1Q( + vlan=self.vlan_id + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) ) # Direction 0 --> 1 diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py index 7792236269..73c36ef2a1 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py +++ b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py @@ -95,15 +95,15 @@ class TrafficStreams(TrafficStreamsBaseClass): ) # Direction 1 --> 0 base_pkt_b = ( - Ether( - src=self.p2_src_start_mac, - dst=self.p2_dst_start_mac - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) ) # Direction 0 --> 1 diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc50kdst50k.py b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc50kdst50k.py index 49d1032abb..535aa73e4f 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc50kdst50k.py +++ b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc50kdst50k.py @@ -124,11 +124,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", @@ -176,11 +176,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc5kdst5k.py b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc5kdst5k.py index d71c2d6eab..a9039fa49f 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc5kdst5k.py +++ b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc5kdst5k.py @@ -125,11 +125,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", @@ -177,11 +177,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py index 9d15e9ea28..615ca88bb4 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py index 7fefc279db..5f9a9d6b68 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py @@ -163,4 +163,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py index e8fc20f488..04cfa5f2fb 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py index ab2aaae36a..2b43760b05 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py index 90c741d7dc..a997d8f5bc 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py index 34a089abf1..db49cb73bc 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py index 24611f1ec6..749258b8c5 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py index 8217450185..a5ae2e2b55 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py index 76a8299904..10e6a50d95 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py index dff6e0209e..65f9d18ee0 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py index c28e214995..ff02a2b811 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py index 664e341b07..ce85e17c5e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py index 858ff84652..b34518f4b9 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py index 42698bf7dc..3e941b98bd 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py index a52c3d91e8..0acbfb701d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py index 78be186d91..e58d437753 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py @@ -145,7 +145,7 @@ class TrafficStreams(TrafficStreamsBaseClass): STLVmWrFlowVar( fv_name=u"dst", pkt_offset=u"IP.dst" - ), + ), STLVmFixIpv4( offset=u"IP" ) @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py index e49ffeeacd..6fce1ed791 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py index b09b024a16..7a65d7ccad 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py index 1af2c4c841..8b0df91ba5 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py index 4acd1faf40..a40792ad0c 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py index 302bd20f3c..0553e6faeb 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py index e92efb927e..9ee65eb354 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py index 14e258552b..7da9933da0 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py index ac0c503f67..518e4b0d2d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py index 2c301efed2..d9dade68d0 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py index 96bc3fbb26..7dc9410fd7 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py index 02620e00e9..367624ea07 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py index 03662d514e..c528be7a31 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py index d8f8e69a6d..9df1f4da36 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py index 1c793b98a1..4d062b4573 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py index 43ef04ffbe..76cb46592b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py index 5a8c9f7f3d..f8d84c7696 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py index 5fc755b2d1..c97f1ca176 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py index f655046bea..3d225f8ce3 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000.py index d00fb76e78..53cef6b1ab 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000.py @@ -96,7 +96,7 @@ class TrafficStreams(TrafficStreamsBaseClass): STLVmWrFlowVar( fv_name=u"dst", pkt_offset=u"IP.dst" - ), + ), STLVmFixIpv4( offset=u"IP" ) diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc500kdst500k.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc500kdst500k.py index c2e37fd3cd..1cbbffdb2a 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc500kdst500k.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc500kdst500k.py @@ -125,11 +125,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", @@ -177,11 +177,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py index d71c2d6eab..a9039fa49f 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py @@ -125,11 +125,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", @@ -177,11 +177,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u15p.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u15p.py index 9b85dd529d..c84838d2f9 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u15p.py @@ -92,7 +92,7 @@ class TrafficStreams(TrafficStreamsBaseClass): ) # Direction 1 --> 0 base_pkt_b = ( - Ether() / + Ether() / IP( src=self.p2_src_start_ip, dst=self.p2_dst_start_ip, @@ -130,7 +130,7 @@ class TrafficStreams(TrafficStreamsBaseClass): # Direction 0 --> 1 vm2 = STLScVmRaw( [ - STLVmFlowVar( + STLVmFlowVar( name=u"dport", min_value=self.p2_dst_start_udp_port, max_value=self.p2_dst_end_udp_port, diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py index a1cf195bfa..0e2ac5ecaf 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py @@ -60,7 +60,7 @@ _VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") class VXLAN(Packet): - name=u"VXLAN" + name = u"VXLAN" fields_desc = [ FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), ThreeBytesField(u"vni", 0), @@ -295,4 +295,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_scripts/PacketVerifier.py b/GPL/traffic_scripts/PacketVerifier.py index 89b8c3c206..974906e439 100644 --- a/GPL/traffic_scripts/PacketVerifier.py +++ b/GPL/traffic_scripts/PacketVerifier.py @@ -76,6 +76,7 @@ import os import select +import time from scapy.all import ETH_P_IP, ETH_P_IPV6, ETH_P_ALL, ETH_P_ARP from scapy.config import conf diff --git a/GPL/traffic_scripts/geneve_tunnel.py b/GPL/traffic_scripts/geneve_tunnel.py index 1270aa6663..19dae6d5c9 100644 --- a/GPL/traffic_scripts/geneve_tunnel.py +++ b/GPL/traffic_scripts/geneve_tunnel.py @@ -284,9 +284,9 @@ def main(): # read another packet in the queue if the current one is # ICMPv6MLReport2 continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break check_geneve( rx_pkt_recv, ip_layer, rx_src_mac, rx_dst_mac, geneve_tunnel_mac, diff --git a/GPL/traffic_scripts/ipsec_interface.py b/GPL/traffic_scripts/ipsec_interface.py index ee157260fa..d49e8bc57e 100644 --- a/GPL/traffic_scripts/ipsec_interface.py +++ b/GPL/traffic_scripts/ipsec_interface.py @@ -243,9 +243,9 @@ def main(): if rx_pkt_recv.haslayer(ICMPv6ND_NS): # read another packet in the queue if the current one is ICMPv6ND_NS continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break check_ipsec( rx_pkt_recv, ip_layer, rx_src_mac, rx_dst_mac, src_tun, dst_tun, src_ip, @@ -275,9 +275,9 @@ def main(): # read another packet in the queue if the current one is # ICMPv6MLReport2 continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break check_ip(tx_pkt_recv, ip_layer, tx_dst_mac, tx_src_mac, dst_ip, src_ip) diff --git a/GPL/traffic_scripts/ipsec_policy.py b/GPL/traffic_scripts/ipsec_policy.py index 4acf0a144b..b0d4545114 100644 --- a/GPL/traffic_scripts/ipsec_policy.py +++ b/GPL/traffic_scripts/ipsec_policy.py @@ -209,9 +209,9 @@ def main(): # read another packet in the queue if the current one is # ICMPv6MLReport2 continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break check_ip(rx_pkt_recv, ip_layer, src_ip, dst_ip) diff --git a/GPL/traffic_scripts/lisp/lisp_check.py b/GPL/traffic_scripts/lisp/lisp_check.py index 88d4ad5619..f7b4c6a797 100644 --- a/GPL/traffic_scripts/lisp/lisp_check.py +++ b/GPL/traffic_scripts/lisp/lisp_check.py @@ -66,17 +66,33 @@ class LispInnerIPv6(IPv6): name = u"Lisp Inner Layer - IPv6" -def valid_ipv4(ip): +def valid_ipv4(ip_address): + """Check IPv4 address. + + :param ip_address: IPv4 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv4Address(ip) + ipaddress.IPv4Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False -def valid_ipv6(ip): +def valid_ipv6(ip_address): + """Check IPv6 address. + + :param ip_address: IPv6 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv6Address(ip) + ipaddress.IPv6Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False @@ -85,7 +101,8 @@ def valid_ipv6(ip): def main(): """Send IP ICMP packet from one traffic generator interface to the other. - :raises RuntimeError: If the received packet is not correct.""" + :raises RuntimeError: If the received packet is not correct. + """ args = TrafficScriptArg( [ diff --git a/GPL/traffic_scripts/lisp/lispgpe_check.py b/GPL/traffic_scripts/lisp/lispgpe_check.py index 79d2ccfab6..f8fa595867 100644 --- a/GPL/traffic_scripts/lisp/lispgpe_check.py +++ b/GPL/traffic_scripts/lisp/lispgpe_check.py @@ -92,17 +92,33 @@ class LispGPEInnerNSH(Packet): """ -def valid_ipv4(ip): +def valid_ipv4(ip_address): + """Check IPv4 address. + + :param ip_address: IPv4 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv4Address(ip) + ipaddress.IPv4Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False -def valid_ipv6(ip): +def valid_ipv6(ip_address): + """Check IPv6 address. + + :param ip_address: IPv6 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv6Address(ip) + ipaddress.IPv6Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False diff --git a/GPL/traffic_scripts/nat.py b/GPL/traffic_scripts/nat.py index 319d617f7c..43715fb383 100644 --- a/GPL/traffic_scripts/nat.py +++ b/GPL/traffic_scripts/nat.py @@ -38,17 +38,33 @@ from .PacketVerifier import RxQueue, TxQueue from .TrafficScriptArg import TrafficScriptArg -def valid_ipv4(ip): +def valid_ipv4(ip_address): + """Check IPv4 address. + + :param ip_address: IPv4 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv4Address(ip) + ipaddress.IPv4Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False -def valid_ipv6(ip): +def valid_ipv6(ip_address): + """Check IPv6 address. + + :param ip_address: IPv6 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv6Address(ip) + ipaddress.IPv6Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False diff --git a/GPL/traffic_scripts/policer.py b/GPL/traffic_scripts/policer.py index ef78f279ad..46131da2a0 100644 --- a/GPL/traffic_scripts/policer.py +++ b/GPL/traffic_scripts/policer.py @@ -26,7 +26,6 @@ """Traffic script for IPsec verification.""" import sys -import logging from ipaddress import ip_address from scapy.layers.l2 import Ether @@ -117,9 +116,9 @@ def main(): # read another packet in the queue if the current one is # ICMPv6MLReport2 continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break if pkt_recv is None: raise RuntimeError(u"Rx timeout") diff --git a/GPL/traffic_scripts/send_icmp_wait_for_reply.py b/GPL/traffic_scripts/send_icmp_wait_for_reply.py index 966fa60a9c..fefa60f44e 100644 --- a/GPL/traffic_scripts/send_icmp_wait_for_reply.py +++ b/GPL/traffic_scripts/send_icmp_wait_for_reply.py @@ -38,33 +38,33 @@ from .PacketVerifier import RxQueue, TxQueue from .TrafficScriptArg import TrafficScriptArg -def valid_ipv4(ip): - """Check if IP address has the correct IPv4 address format. +def valid_ipv4(ip_address): + """Check IPv4 address. - :param ip: IP address. - :type ip: str - :return: True in case of correct IPv4 address format, - otherwise return False. + :param ip_address: IPv4 address to check. + :type ip_address: str + :returns: True if IP address is correct. :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. """ try: - ipaddress.IPv4Address(ip) + ipaddress.IPv4Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False -def valid_ipv6(ip): - """Check if IP address has the correct IPv6 address format. +def valid_ipv6(ip_address): + """Check IPv6 address. - :param ip: IP address. - :type ip: str - :return: True in case of correct IPv6 address format, - otherwise return False. + :param ip_address: IPv6 address to check. + :type ip_address: str + :returns: True if IP address is correct. :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. """ try: - ipaddress.IPv6Address(ip) + ipaddress.IPv6Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False @@ -105,9 +105,9 @@ def main(): raise ValueError(u"IP not in correct format") icmp_request = ( - Ether(src=src_mac, dst=dst_mac) / - ip_layer(src=src_ip, dst=dst_ip) / - icmp_req() + Ether(src=src_mac, dst=dst_mac) / + ip_layer(src=src_ip, dst=dst_ip) / + icmp_req() ) # Send created packet on the interface diff --git a/GPL/traffic_scripts/send_ip_check_headers.py b/GPL/traffic_scripts/send_ip_check_headers.py index 40268d99c2..e052b12190 100644 --- a/GPL/traffic_scripts/send_ip_check_headers.py +++ b/GPL/traffic_scripts/send_ip_check_headers.py @@ -42,17 +42,33 @@ from .PacketVerifier import RxQueue, TxQueue from .TrafficScriptArg import TrafficScriptArg -def valid_ipv4(ip): +def valid_ipv4(ip_address): + """Check IPv4 address. + + :param ip_address: IPv4 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv4Address(ip) + ipaddress.IPv4Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False -def valid_ipv6(ip): +def valid_ipv6(ip_address): + """Check IPv6 address. + + :param ip_address: IPv6 address to check. + :type ip_address: str + :returns: True if IP address is correct. + :rtype: bool + :raises AttributeError, AddressValueError: If IP address is not valid. + """ try: - ipaddress.IPv6Address(ip) + ipaddress.IPv6Address(ip_address) return True except (AttributeError, ipaddress.AddressValueError): return False @@ -90,7 +106,7 @@ def main(): rxq = RxQueue(rx_if) txq = TxQueue(tx_if) - sent_packets =list() + sent_packets = list() pkt_raw = Ether(src=tx_src_mac, dst=tx_dst_mac) if encaps_tx == u"Dot1q": diff --git a/GPL/traffic_scripts/srv6_encap.py b/GPL/traffic_scripts/srv6_encap.py index 9cdfccf432..ce62d79974 100644 --- a/GPL/traffic_scripts/srv6_encap.py +++ b/GPL/traffic_scripts/srv6_encap.py @@ -255,9 +255,9 @@ def main(): if rx_pkt_recv.haslayer(ICMPv6ND_NS): # read another packet in the queue if the current one is ICMPv6ND_NS continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break check_srv6( rx_pkt_recv, rx_src_mac, rx_dst_mac, src_ip, dst_ip, dir0_srcsid, @@ -270,20 +270,20 @@ def main(): ip_pkt[Raw].load += (b"\0" * (size_limit - 14 - len(ip_pkt))) rx_pkt_send = ( - Ether(src=rx_dst_mac, dst=rx_src_mac) / - IPv6(src=dir1_srcsid, dst=dir1_dstsid1) / - IPv6ExtHdrSegmentRouting( - segleft=1 if dir1_dstsid3 == u"None" else 2, - lastentry=1 if dir1_dstsid3 == u"None" else 2, - addresses=[dir1_dstsid2, dir1_dstsid1] - if dir1_dstsid3 == u"None" - else [dir1_dstsid3, dir1_dstsid2, dir1_dstsid1] - ) / - ip_pkt + Ether(src=rx_dst_mac, dst=rx_src_mac) / + IPv6(src=dir1_srcsid, dst=dir1_dstsid1) / + IPv6ExtHdrSegmentRouting( + segleft=1 if dir1_dstsid3 == u"None" else 2, + lastentry=1 if dir1_dstsid3 == u"None" else 2, + addresses=[dir1_dstsid2, dir1_dstsid1] + if dir1_dstsid3 == u"None" + else [dir1_dstsid3, dir1_dstsid2, dir1_dstsid1] + ) / + ip_pkt ) if dir1_dstsid2 != u"None" else ( - Ether(src=rx_dst_mac, dst=rx_src_mac) / - IPv6(src=dir1_srcsid, dst=dir1_dstsid1) / - ip_pkt + Ether(src=rx_dst_mac, dst=rx_src_mac) / + IPv6(src=dir1_srcsid, dst=dir1_dstsid1) / + ip_pkt ) rx_txq.send(rx_pkt_send) @@ -300,9 +300,9 @@ def main(): # read another packet in the queue if the current one is # ICMPv6MLReport2 continue - else: - # otherwise process the current packet - break + + # otherwise process the current packet + break if decap == u"True": check_ip(tx_pkt_recv, tx_dst_mac, tx_src_mac, dst_ip, src_ip) diff --git a/GPL/traffic_scripts/vxlan.py b/GPL/traffic_scripts/vxlan.py index 2acd2a2c93..25d2d60ed8 100644 --- a/GPL/traffic_scripts/vxlan.py +++ b/GPL/traffic_scripts/vxlan.py @@ -21,6 +21,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Traffic script for vxlan verification.""" + from scapy.fields import BitField, XByteField, X3BytesField from scapy.layers.inet import UDP from scapy.layers.l2 import Ether @@ -28,6 +30,8 @@ from scapy.packet import Packet, bind_layers class VXLAN(Packet): + """Custom scapy layer override for VXLAN.""" + name = u"VXLAN" fields_desc = [ BitField(u"flags", 0x08000000, 32), -- cgit 1.2.3-korg