* [dts] [PATCH] framework: enhance the tcpdump direction option parsing
@ 2017-11-06 7:57 Herbert Guan
2017-11-10 13:51 ` Liu, Yong
0 siblings, 1 reply; 2+ messages in thread
From: Herbert Guan @ 2017-11-06 7:57 UTC (permalink / raw)
To: dts; +Cc: Herbert Guan
Some tcpdump versions (such as 4.9.0-5.el7) is providing help message
about direction option with both '-P' and '-Q':
" [ -Q|-P in|out|inout ]".
This format cause option parse fail.
This patch can enhance the direction option parsing and fix it.
Jira: ENTNET-552
Change-Id: I5835912905311d90ce4ee9897fa9c83a0266aa01
Signed-off-by: Herbert Guan <herbert.guan@arm.com>
---
framework/packet.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/framework/packet.py b/framework/packet.py
index 1907612..4ee51dd 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -787,14 +787,20 @@ def sniff_packets(intf, count=0, timeout=5, filters=[]):
sniff all packets for certain port in certain seconds
"""
param = ""
- direct_param = r"(\s+)\[ -(\w) in\|out\|inout \]"
+ direct_param = r"(\s+)\[ (\S+) in\|out\|inout \]"
tcpdump_help = subprocess.check_output("tcpdump -h; echo 0",
stderr=subprocess.STDOUT,
shell=True)
for line in tcpdump_help.split('\n'):
m = re.match(direct_param, line)
if m:
- param = "-" + m.group(2) + " in"
+ opt = re.search("-Q", m.group(2));
+ if opt:
+ param = "-Q" + " in"
+ else:
+ opt = re.search("-P", m.group(2));
+ if opt:
+ param = "-P" + " in"
if len(param) == 0:
print "tcpdump not support direction chioce!!!"
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH] framework: enhance the tcpdump direction option parsing
2017-11-06 7:57 [dts] [PATCH] framework: enhance the tcpdump direction option parsing Herbert Guan
@ 2017-11-10 13:51 ` Liu, Yong
0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2017-11-10 13:51 UTC (permalink / raw)
To: Herbert Guan, dts
Thanks, Herbert. Applied.
On 11/06/2017 03:57 PM, Herbert Guan wrote:
> Some tcpdump versions (such as 4.9.0-5.el7) is providing help message
> about direction option with both '-P' and '-Q':
> " [ -Q|-P in|out|inout ]".
> This format cause option parse fail.
> This patch can enhance the direction option parsing and fix it.
>
> Jira: ENTNET-552
> Change-Id: I5835912905311d90ce4ee9897fa9c83a0266aa01
> Signed-off-by: Herbert Guan<herbert.guan@arm.com>
> ---
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-10 5:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 7:57 [dts] [PATCH] framework: enhance the tcpdump direction option parsing Herbert Guan
2017-11-10 13:51 ` Liu, Yong
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).