Inspect/L5/Unknown.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 61 CC 4 SCAR 13.9
CC
4
Cov
0%
guess_protocol
6.0
new_connection
6.0
in
6.0
CRAP 4.0
1 ############################################################################
2 # Net::Inspect::L5::Unknown
3 # guessing handler for connections which are not handled by anything else
4 ############################################################################
5 use warnings;
6 use strict;
7 package Net::Inspect::L5::Unknown;
8 use base 'Net::Inspect::Connection';
9 use fields qw(replay);
10 use Net::Inspect::Debug;
11  
12 sub guess_protocol {
13 my ($self,$guess,$dir,$data,$eof,$time,$meta) = @_;
14  
15 # keep all calls for replaying later
16 push @{ $self->{replay} ||=[] },[$dir,$data,$eof,$time];
17  
18 $guess->attached == 1 or return; # let others try first
19  
20 # it's just me left
21 my $obj = $self->new_connection($meta);
22 if ( ! $obj ) {
23 $guess->detach($self);
24 return;
25 }
26  
27 # replay all
28 $obj->in(@$_) for @{ $self->{replay} };
29 undef $self->{replay};
30 return ($obj,length($data));
31 }
32  
33 sub new_connection {
34 my ($self,$meta) = @_;
35 return $self->{upper_flow}->new_connection($meta) if $self->{upper_flow};
36 return $self->new;
37 }
38  
39 sub in {
40 my ($self,$dir,$data,$eof,$time) = @_;
41 $self->{expire} = $time + 500;
42 return $self->{upper_flow}->in($dir,$data,$eof,$time) if $self->{upper_flow};
43 return length($data); # ignores
44 }
45  
46 sub fatal {
47 my ($self,$reason,$dir,$time) = @_;
48 trace($reason);
49 }
50  
51 1;
52  
53 __END__