diff options
31 files changed, 44 insertions, 44 deletions
diff --git a/scripts/vyatta-tshark-interface-port.pl b/scripts/vyatta-tshark-interface-port.pl index aa750e5..b82441e 100755 --- a/scripts/vyatta-tshark-interface-port.pl +++ b/scripts/vyatta-tshark-interface-port.pl @@ -31,7 +31,7 @@ use warnings; sub check_if_interface_is_tsharkable { my $interface = shift; - my @grep_tshark_interfaces = `sudo /usr/bin/tshark -D | grep $interface`; + my @grep_tshark_interfaces = `/usr/bin/tshark -D | grep $interface`; my $any_interface; for my $count (0 .. $#grep_tshark_interfaces) { @@ -48,8 +48,7 @@ sub check_if_interface_is_tsharkable { } } if ($exact_match == 0 || $any_interface eq 'any') { - print "Unable to capture traffic on $interface\n"; - exit 1; + die "Unable to capture traffic on $interface\n"; } } @@ -62,31 +61,11 @@ my $intf = $ARGV[0]; check_if_interface_is_tsharkable($intf); if ($#ARGV > 0){ - my $port = $ARGV[1]; - my $not_port = $ARGV[2]; - if ($port =~ /[a-zA-Z]/){ - print "Port number has to be numeric. Allowed values: <1-65535>\n"; - exit 1; - } else { - if (($port > 0) and ($port < 65536)){ - if ($not_port == 0){ - print "Capturing traffic on $intf port $port ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf port $port 2> /dev/null"; - } else { - print "Capturing traffic on $intf excluding port $port ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf not port $port 2> /dev/null"; - } - } else { - print "Invalid port number. Allowed values: <1-65535>\n"; - exit 1; - } - - } + my $filter = $ARGV[1]; + print "Capturing traffic on $intf $filter ...\n"; + exec "/usr/bin/tshark -n -i $intf $filter"; } else { - print "Capturing traffic on $intf ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf 2> /dev/null"; + print "Capturing traffic on $intf ...\n"; + exec "/usr/bin/tshark -n -i $intf"; } -exit 0; - -#end of file diff --git a/templates/show/interfaces/bonding/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/bonding/node.tag/capture/not/port/node.tag/node.def index c8e76aa..a3e56f0 100644 --- a/templates/show/interfaces/bonding/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/bonding/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding the specified bonding interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "not port $8" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/bonding/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/bonding/node.tag/capture/port/node.tag/node.def index 296ba4c..ff5a746 100644 --- a/templates/show/interfaces/bonding/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/bonding/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified bonding interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "port $7" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/filter/node.def b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..3866075 --- /dev/null +++ b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "$9" diff --git a/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/not/port/node.tag/node.def index 496f21c..924318b 100644 --- a/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding the specified bonding interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "${10}" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "not port ${10}" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/port/node.tag/node.def index 304b4e3..51c0f52 100644 --- a/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/bonding/node.tag/vif/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified bonding virtual interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "$9" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "port $9" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/bridge/node.tag/capture/filter/node.def b/templates/show/interfaces/bridge/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/bridge/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/bridge/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/bridge/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..2bb99d7 --- /dev/null +++ b/templates/show/interfaces/bridge/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" diff --git a/templates/show/interfaces/bridge/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/bridge/node.tag/capture/not/port/node.tag/node.def index 271106c..9795223 100644 --- a/templates/show/interfaces/bridge/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/bridge/node.tag/capture/not/port/node.tag/node.def @@ -1,4 +1,4 @@ help: Show captured traffic excluding the specified bridge interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "not port $8" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/bridge/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/bridge/node.tag/capture/port/node.tag/node.def index 7ad54b7..32dbbaa 100644 --- a/templates/show/interfaces/bridge/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/bridge/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified bridge interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "port $7" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/ethernet/node.tag/capture/filter/node.def b/templates/show/interfaces/ethernet/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/ethernet/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..2bb99d7 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" diff --git a/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def index a350ac5..ed32087 100644 --- a/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding the specified ethernet interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "not port $8" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def index f1aedc4..a607426 100644 --- a/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified ethernet interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "port $7" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/filter/node.def b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..3866075 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "$9" diff --git a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/not/port/node.tag/node.def index 258c6dc..1824901 100644 --- a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding the specified ethernet interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "${10}" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "not port ${10}" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/port/node.tag/node.def index 4090508..c94b8d5 100644 --- a/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/ethernet/node.tag/vif/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified ethernet virtual interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "$9" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4.$6" "port $9" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/loopback/node.tag/capture/filter/node.def b/templates/show/interfaces/loopback/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/loopback/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/loopback/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/loopback/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..2bb99d7 --- /dev/null +++ b/templates/show/interfaces/loopback/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" diff --git a/templates/show/interfaces/loopback/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/loopback/node.tag/capture/not/port/node.tag/node.def index b8d8ff2..4114ffa 100644 --- a/templates/show/interfaces/loopback/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/loopback/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding loopback interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "not port $8" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/loopback/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/loopback/node.tag/capture/port/node.tag/node.def index f1aedc4..a607426 100644 --- a/templates/show/interfaces/loopback/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/loopback/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified ethernet interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "port $7" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/pseudo-ethernet/node.tag/capture/filter/node.def b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/pseudo-ethernet/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..2bb99d7 --- /dev/null +++ b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" diff --git a/templates/show/interfaces/pseudo-ethernet/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/not/port/node.tag/node.def index 3a2b44e..0378015 100644 --- a/templates/show/interfaces/pseudo-ethernet/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding the specified pseudo ethernet interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "not port $8" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/pseudo-ethernet/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/port/node.tag/node.def index d5e357e..3d491dd 100644 --- a/templates/show/interfaces/pseudo-ethernet/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/pseudo-ethernet/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified pseudo ethernet interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "port $7" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/tunnel/node.tag/capture/filter/node.def b/templates/show/interfaces/tunnel/node.tag/capture/filter/node.def new file mode 100644 index 0000000..f434614 --- /dev/null +++ b/templates/show/interfaces/tunnel/node.tag/capture/filter/node.def @@ -0,0 +1 @@ +help: Show captured traffic with filtering diff --git a/templates/show/interfaces/tunnel/node.tag/capture/filter/node.tag/node.def b/templates/show/interfaces/tunnel/node.tag/capture/filter/node.tag/node.def new file mode 100644 index 0000000..2bb99d7 --- /dev/null +++ b/templates/show/interfaces/tunnel/node.tag/capture/filter/node.tag/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic for interface with filtering +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" diff --git a/templates/show/interfaces/tunnel/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/tunnel/node.tag/capture/not/port/node.tag/node.def index b5c87c9..f6d794e 100644 --- a/templates/show/interfaces/tunnel/node.tag/capture/not/port/node.tag/node.def +++ b/templates/show/interfaces/tunnel/node.tag/capture/not/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic excluding the specified tunnel interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "not port $8" allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/tunnel/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/tunnel/node.tag/capture/port/node.tag/node.def index d1f01df..14a1158 100644 --- a/templates/show/interfaces/tunnel/node.tag/capture/port/node.tag/node.def +++ b/templates/show/interfaces/tunnel/node.tag/capture/port/node.tag/node.def @@ -1,3 +1,3 @@ help: Show captured traffic on specified tunnel interface port -run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "port $7" allowed: echo -n '<1-65535>' |