[6/7] framework/packet: Fix tcpdump help parse

Message ID 20230414125255.67812-7-akihiko.odaki@daynix.com (mailing list archive)
State Accepted
Headers
Series Fix for Fedora 37 |

Commit Message

Akihiko Odaki April 14, 2023, 12:52 p.m. UTC
  tcpdump version 4.99.3 puts several options in one line as follows:
> $ tcpdump --help
> tcpdump version 4.99.3
> libpcap version 1.10.3 (with TPACKET_V3)
> OpenSSL 3.0.5 5 Jul 2022
> Usage: tcpdump [-AbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ] [--count]
>		[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
> 		[ -i interface ] [ --immediate-mode ] [ -j tstamptype ]
> 		[ -M secret ] [ --number ] [ --print ] [ -Q in|out|inout ]
> 		[ -r file ] [ -s snaplen ] [ -T type ] [ --version ]
> 		[ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ]
> 		[ --time-stamp-precision precision ] [ --micro ] [ --nano ]
> 		[ -z postrotate-command ] [ -Z user ] [ expression ]

This change allows to match a substring representing an option.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 framework/packet.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/framework/packet.py b/framework/packet.py
index f56bf178..9603ec7b 100644
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -1099,7 +1099,7 @@  def start_tcpdump(crb, intf, count=0, filters=None, lldp_forbid=True):
     tcpdump_help = tcpdump_session.send_command("tcpdump -h")
 
     for line in tcpdump_help.split("\n"):
-        m = re.match(direct_param, line)
+        m = re.search(direct_param, line)
         if m:
             opt = re.search("-Q", m.group(2))
             if opt: