diff options
-rw-r--r-- | lib/Vyatta/Conntrack/ConntrackUtil.pm | 18 | ||||
-rwxr-xr-x | scripts/vyatta-show-conntrack.pl | 9 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/Vyatta/Conntrack/ConntrackUtil.pm b/lib/Vyatta/Conntrack/ConntrackUtil.pm index 8f529c2..104f237 100644 --- a/lib/Vyatta/Conntrack/ConntrackUtil.pm +++ b/lib/Vyatta/Conntrack/ConntrackUtil.pm @@ -25,7 +25,23 @@ package Vyatta::Conntrack::ConntrackUtil; use base qw(Exporter); -our @EXPORT = qw(check_for_conntrack_hooks); +our @EXPORT = qw(check_for_conntrack_hooks, + process_protocols); + +sub process_protocols { + my $proto = undef; + my %proto_hash = (); + my $PROTO_FILE = '/etc/protocols'; + # do nothing if can't open + return if (!open($proto, $PROTO_FILE)); + while (<$proto>) { + next if (/^\s*#/); + next if (!/^\S+\s+(\d+)\s+(\S+)\s/); + $proto_hash{$1} = $2; + } + close $proto; + return \%proto_hash; +} #function to find if connection tracking is enabled. #looks in the iptables to see if any of the features introduced diff --git a/scripts/vyatta-show-conntrack.pl b/scripts/vyatta-show-conntrack.pl index 57a9799..e5b2629 100755 --- a/scripts/vyatta-show-conntrack.pl +++ b/scripts/vyatta-show-conntrack.pl @@ -36,8 +36,9 @@ use strict; use Switch; use Vyatta::TypeChecker; -my $format = "%-10s %-22s %-22s %-12s %-20s\n"; -my $format_IPv6 = "%-10s %-40s %-40s %-12s %-20s\n"; +my $format = "%-10s %-22s %-22s %-16s %-20s\n"; +my $format_IPv6 = "%-10s %-40s %-40s %-16s %-20s\n"; +my $href; #reference to hash containing protocol-num to name key-value pairs sub print_xml { my ($data, $cache, $family) = @_; @@ -45,6 +46,7 @@ sub print_xml { my %flowh; my $tcount = 0; + $href = process_protocols(); while (1) { my $meta = 0; last if ! defined $data->{flow}[$flow]; @@ -67,6 +69,9 @@ sub print_xml { $dport{$dir} = $l4_ref->{dport}[0]; $proto{$dir} = $l4_ref->{protoname}; $protonum{$dir} = $l4_ref->{protonum}; + if (($proto{$dir} eq 'unknown') and (defined($protonum{$dir}))) { + $proto{$dir} = lc(${$href}{$protonum{$dir}}); + } } } } elsif ($dir eq 'independent') { |