test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Tu, Lijuan" <lijuan.tu@intel.com>
To: "Xiao, QimaiX" <qimaix.xiao@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: "Xiao, QimaiX" <qimaix.xiao@intel.com>
Subject: Re: [dts] [PATCH V1] framework/packet: add function update_pkt
Date: Fri, 22 Nov 2019 06:38:07 +0000	[thread overview]
Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB67997@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1574320079-39675-1-git-send-email-qimaix.xiao@intel.com>

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xiao Qimai
> Sent: Thursday, November 21, 2019 3:08 PM
> To: dts@dpdk.org
> Cc: Xiao, QimaiX <qimaix.xiao@intel.com>
> Subject: [dts] [PATCH V1] framework/packet: add function update_pkt
> 
> *.function update_pkt is to update the input pkts to Packet Object,
>   the type of the input pkts could be str, dict and list.
> 
> Signed-off-by: Xiao Qimai <qimaix.xiao@intel.com>
> ---
>  framework/packet.py | 43 ++++++++++++++++++++++++++++++++++++++++--
> -
>  1 file changed, 40 insertions(+), 3 deletions(-)
> 
> diff --git a/framework/packet.py b/framework/packet.py index
> 05b2367..a742bd4 100755
> --- a/framework/packet.py
> +++ b/framework/packet.py
> @@ -371,9 +371,7 @@ class Packet(object):
> 
>          if pkt_str is not None and type(pkt_str) == str:
>              self._scapy_str_to_pkt(pkt_str)
> -        elif len(options) == 0:
> -            pass
> -        else:
> +        elif len(options) != 0:
>              self._add_pkt(self.pkt_opts)
>          if self.pktgen.pkt is not None:
>              self.pktgen.append_pkts()
> @@ -458,6 +456,45 @@ class Packet(object):
>              self._add_pkt(kwargs)
>          self.pktgen.append_pkts()
> 
> +    def update_pkt_str(self, pkt):
> +        self._scapy_str_to_pkt(pkt)
> +        self.pktgen.append_pkts()
> +
> +    def update_pkt_dict(self, pkt):
> +        self.pkt_opts = pkt
> +        if hasattr(self, 'configured_layer_raw'):
> +            delattr(self, 'configured_layer_raw')
> +        self._add_pkt(pkt)
> +        self.pktgen.append_pkts()
> +
> +    def update_pkt(self, pkts):
> +        """
> +        update pkts to packet object
> +        :param pkts: pkts to update
> +        :type str|dict|list
> +        :return: None
> +        """
> +        self.pktgen = scapy()
> +        self.pkt_layers = []
> +        if isinstance(pkts, str):
> +            self.update_pkt_str(pkts)
> +        elif isinstance(pkts, dict):
> +            self.update_pkt_dict(pkts)
> +        elif isinstance(pkts, list):
> +            for i in pkts:
> +                if isinstance(i, str):
> +                    try:
> +                        self.update_pkt_str(i)
> +                    except:
> +                        print("warning: packet %s update failed" % i)
> +                elif isinstance(i, dict):
> +                    try:
> +                        self.update_pkt_dict(i)
> +                    except:
> +                        print("warning: packet %s update failed" % i)
> +                else:
> +                    print("packet {} is not acceptable".format(i))
> +
>      def generate_random_pkts(self, dstmac=None, pktnum=100,
> random_type=None, ip_increase=True, random_payload=False,
>                               options=None):
>          """
> --
> 2.17.1


      reply	other threads:[~2019-11-22  6:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21  7:07 Xiao Qimai
2019-11-22  6:38 ` Tu, Lijuan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8CE3E05A3F976642AAB0F4675D0AD20E0BB67997@SHSMSX101.ccr.corp.intel.com \
    --to=lijuan.tu@intel.com \
    --cc=dts@dpdk.org \
    --cc=qimaix.xiao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).