sniff: Make sure monitor port is not phantom before we start the sniff.

And fix portmod showing Current flags.
This commit is contained in:
Ben Greear
2020-03-17 12:48:41 -07:00
parent 5b548941a3
commit e34f509d9c
2 changed files with 26 additions and 3 deletions

View File

@@ -716,11 +716,9 @@ sub group_items {
# Generic disassembly of lines created by show # Generic disassembly of lines created by show
our @starting_exceptions = ( our @starting_exceptions = (
# please keep these sorted # please keep these sorted
"Advertising:",
"Command:", "Command:",
"Conn Established:", "Conn Established:",
"Conn Timeouts:", "Conn Timeouts:",
"Current:",
"Cx Detected:", "Cx Detected:",
"DNS Servers:", "DNS Servers:",
"Endpoint [", "Endpoint [",
@@ -737,7 +735,6 @@ our @starting_exceptions = (
"Rx Pkts (On Wire):", "Rx Pkts (On Wire):",
"RX-Silence:", "RX-Silence:",
"Shelf: 1,", "Shelf: 1,",
"Supported:",
"TCP Retransmits:", "TCP Retransmits:",
"Tx Bytes:", "Tx Bytes:",
"Tx Bytes (On Wire):", "Tx Bytes (On Wire):",
@@ -751,7 +748,11 @@ our @starting_exceptions = (
# Generic disassembly of lines created by show # Generic disassembly of lines created by show
our @port_starting_exceptions = ( our @port_starting_exceptions = (
# please keep these sorted # please keep these sorted
"Advertising:",
"Current:",
"Missed-Beacons:", "Missed-Beacons:",
"Partner:",
"Supported:",
"Tx-Excessive-Retry:", "Tx-Excessive-Retry:",
"Rx-Invalid-CRYPT:", "Rx-Invalid-CRYPT:",
"Rx-Invalid-MISC:", "Rx-Invalid-MISC:",

View File

@@ -228,6 +228,28 @@ def main():
sflags = "0x02" # dumpcap, no terminal sflags = "0x02" # dumpcap, no terminal
for m in monis_n: for m in monis_n:
r = monis_r[idx] r = monis_r[idx]
# Wait for monitor to be non-phantom
isph = True
while isph:
port_stats = subprocess.run(["./lf_portmod.pl", "--manager", lfmgr, "--card", r, "--port_name", m,
"--show_port", "Current"], stdout=PIPE, stderr=PIPE);
pss = port_stats.stdout.decode('utf-8', 'ignore');
for line in pss.splitlines():
#print("line: %s\n"%line)
ma = re.search('Current:\s+(.*)', line)
if (ma != None):
cf = ma.group(1);
isph = False
for f in cf.split():
if (f == "PHANTOM"):
isph = True
break
if isph:
print("Waiting for monitor port %s.%s to become non-phantom\n"%(r, m));
sleep(1)
print("Starting sniffer on port %s.%s for %s seconds, saving to file %s.pcap on resource %s\n"%(r, m, dur, m, r)) print("Starting sniffer on port %s.%s for %s seconds, saving to file %s.pcap on resource %s\n"%(r, m, dur, m, r))
subprocess.run(["./lf_portmod.pl", "--manager", lfmgr, subprocess.run(["./lf_portmod.pl", "--manager", lfmgr,
"--cli_cmd", "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur))]); "--cli_cmd", "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur))]);