diff --git a/src/www/diag_packet_capture.php b/src/www/diag_packet_capture.php index 82485d1ec..91e6d6a6b 100644 --- a/src/www/diag_packet_capture.php +++ b/src/www/diag_packet_capture.php @@ -48,8 +48,10 @@ function start_capture($options) { $cmd_opts = array(); $filter_opts = array(); - $intf = get_real_interface($options['interface']); - $cmd_opts[] = '-i ' . $intf; + if (!empty($options['interface'])) { + $intf = get_real_interface($options['interface']); + $cmd_opts[] = '-i ' . $intf; + } if (empty($options['promiscuous'])) { // disable promiscuous mode @@ -104,15 +106,13 @@ function start_capture($options) $filter_opts[] = "port " . str_replace("!", "not ", $options['port']); } - if (!empty($intf)) { - $cmd = '/usr/sbin/tcpdump '; - $cmd .= implode(' ', $cmd_opts); - $cmd .= ' -w /tmp/packetcapture.cap '; - $cmd .= " ".escapeshellarg(implode(' and ', $filter_opts)); - //delete previous packet capture if it exists - @unlink('/tmp/packetcapture.cap'); - mwexec_bg($cmd); - } + $cmd = '/usr/sbin/tcpdump '; + $cmd .= implode(' ', $cmd_opts); + $cmd .= ' -w /tmp/packetcapture.cap '; + $cmd .= " ".escapeshellarg(implode(' and ', $filter_opts)); + //delete previous packet capture if it exists + @unlink('/tmp/packetcapture.cap'); + mwexec_bg($cmd); } /** @@ -201,7 +201,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } else { // set form defaults $pconfig = array(); - $pconfig['interface'] = "WAN"; + $pconfig['interface'] = "wan"; $pconfig['promiscuous'] = null; $pconfig['fam'] = null; $pconfig['proto'] = null; @@ -215,7 +215,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = $_POST; if (!empty($_POST['start'])) { - if (!array_key_exists($pconfig['interface'], $interfaces)) { + if (!empty($pconfig['interface']) && !array_key_exists($pconfig['interface'], $interfaces)) { $input_errors[] = gettext("Invalid interface."); } if ($pconfig['fam'] !== "" && $pconfig['fam'] !== "ip" && $pconfig['fam'] !== "ip6") { @@ -312,6 +312,9 @@ include("fbegin.inc");