IMP/Filter.pm

filter: Statementstmt 57.8% 99 / 171 Branchbran 44.1% 53 / 120 Conditioncond 25.0% 11 / 44 MC/DCmcdc 14.2% 4 / 28 Subroutinesub 66.6% 10 / 15 Podpod 100% 7 / 7 totaltotal 47.7% 184 / 385 CC 79 SCAR 50.8
CC
79
Cov
49%
in
246.2
_imp_cb
181.7
deny
12.0
CRAP 160.6
« IMP/ProtocolPinning.pm ↑ Summary IMP/Debug.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶no if $] >= 5.017011, warnings => 'experimental::smartmatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Net::IMP::Filter;
6 3 ▶use Net::IMP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Net::IMP::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Hash::Util 'lock_ref_keys';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 ############################################################################
13 # these need to be redefined in subclass
14 ############################################################################
15 # analyzed data output
16 sub out {
17 0 ▶ my ($self,$dir,$data) = @_;
Subroutine out: not called CC=1 SCAR=6.9
Pod documented
18 0 return;
19 }
20  
21 sub deny {
22 0 ▶ my ($self,$msg,$dir,@extmsg) = @_;
Subroutine deny: not called CC=3 SCAR=24.8
Pod documented
23 0 ▶ while (@extmsg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@extmsg) 0 0 0
24 0 my ($k,$v) = splice(@extmsg,0,2);
25 0 $msg .= " $k:$v";
26 }
27 0 ▶ $DEBUG && debug("deny $msg");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("deny $msg") 0 0 0
28 0 return;
29 }
30  
31 sub fatal {
32 0 ▶ my ($self,$msg) = @_;
Subroutine fatal: not called CC=2 SCAR=17.9
Pod documented
33 0 ▶ $DEBUG && debug("fatal $msg");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("fatal $msg") 0 0 0
34 0 return;
35 }
36  
37 sub log {
38 0 ▶ my ($self,$level,$msg,$dir,$offset,$len,@extmsg) = @_;
Subroutine log: not called CC=3 SCAR=24.8
Pod documented
39 0 ▶ while (@extmsg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@extmsg) 0 0 0
40 0 my ($k,$v) = splice(@extmsg,0,2);
41 0 $msg .= " $k:$v";
42 }
43 0 ▶ $DEBUG && debug("log [$level] $msg");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("log [$level] $msg") 0 0 0
44 0 return;
45 }
46  
47 sub acctfld {
48 0 ▶ my ($self,$key,$value) = @_;
Subroutine acctfld: not called CC=2 SCAR=17.9
Pod documented
49 0 ▶ $DEBUG && debug("acctfld $key=$value");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("acctfld $key=$value") 0 0 0
50 0 return;
51 }
52  
53 ############################################################################
54 # Implementation
55 ############################################################################
56 sub new {
57 10 ▶ my ($class,$imp,%args) = @_;
Subroutine new: called CC=3 SCAR=11.6
Pod documented
58 10 ▶ my $self = lock_ref_keys( bless {
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0100
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
59 %args,
60 imp => $imp, # analyzer object
61 buf => [
62 # list of buffered data [ offset,buf,type ] per dir
63 # buffers for same streaming type will be concatenated
64 [ [0,'',0] ],
65 [ [0,'',0] ],
66 ],
67 pass => [0,0], # may pass up to this offset
68 prepass => [0,0], # may prepass up to this offset
69 skipped => [0,0], # flag if last data got not send to analyzer
70 # because of pass into future
71 eof => [0,0], # flag if eof received
72 dead => 0, # set if deny|fatal received
73 },(ref $class || $class) );
74  
75 10 ▶ if ($imp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($imp) 10 0 10
76 10 weaken( my $weak = $self );
77 10 $imp->set_callback(\&_imp_cb,$weak);
78 }
79 10 return $self;
80 }
81  
82 # data into analyzer
83 sub in {
84 25 ▶ my ($self,$dir,$data,$type) = @_;
Subroutine in: called CC=27 SCAR=55.1
Pod documented
85 25 ▶ $self->{dead} and return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"dead"} and return 0 25 25
86  
87 25 ▶ $type ||= IMP_DATA_STREAM;
Condition100%2/2
$type ||= "imp.data.stream"
l!l
520
MC/DC100%1/1
$type ||= "imp.data.stream"
$type
Truth table100%2/2
A
A= $type
Aresult
11
00
88 25 ▶ $DEBUG && debug("in($dir,$type) %d bytes",length($data));
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("in($dir,$type) %d bytes", length $data) 0 25 25
89  
90 25 ▶ $self->{eof}[$dir] = 1 if $data eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $data eq "" 9 16 25
91 25 ▶ return $self->out($dir,$data,$type) if ! $self->{imp};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"imp"} 0 25 25
92  
93 25 my $buf = $self->{buf}[$dir];
94  
95 # (pre)pass as much as possible
96 25 for my $w (qw(pass prepass)) {
97 50 ▶ my $maxoff = $self->{$w}[$dir] or next;
Branch: 1 branch
BranchTrueFalseTotal
my $maxoff = $self->{$w}[$dir] or next 50 0 50
98 0 ▶ @$buf == 1 and ! $buf->[0][2] or die "buf should be empty";
Branch: 1 branch
BranchTrueFalseTotal
@$buf == 1 and not $buf->[0][2] or die "buf should be empty" 0 0 0
Condition0%0/3
@$buf == 1 and not $buf->[0][2]
!ll&&!rl&&r
000
MC/DC0%0/2
@$buf == 1 and not $buf->[0][2]
@$buf == 1 not $buf->[0][2]
Truth table0%0/3
A and not(B)
A= @$buf == 1B= not $buf->[0][2]
ABresult
0X0
100
111
99 0 ▶ if ( $maxoff == IMP_MAXOFFSET
Branch: 1 branch
BranchTrueFalseTotal
if ($maxoff == -1 or $maxoff > $buf->[-1][0] + length($data)) 0 0 0
Condition0%0/3
$maxoff == -1 or $maxoff > $buf->[-1][0] + length($data)
l!l&&r!l&&!r
000
MC/DC0%0/2
$maxoff == -1 or $maxoff > $buf->[-1][0] + length($data)
$maxoff == -1 $maxoff > $buf->[-1][0] + length($data)
Truth table0%0/3
A or B
A= $maxoff == -1B= $maxoff > $buf->[-1][0] + length($data)
ABresult
1X1
011
000
100 or $maxoff > $buf->[-1][0] + length($data) ) {
101 0 ▶ $DEBUG && debug("can $w everything");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("can $w everything") 0 0 0
102 0 ▶ my $lastoff = $self->{skipped}[$dir] && $buf->[0][0];
Condition0%0/3
$self->{'skipped'}[$dir] && $buf->[0][0]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{'skipped'}[$dir] && $buf->[0][0]
$self->{'skipped'}[$dir] $buf->[0][0]
Truth table0%0/3
A && B
A= $self->{'skipped'}[$dir]B= $buf->[0][0]
ABresult
0X0
100
111
103 0 $buf->[0][0] += length($data);
104 0 $self->out($dir,$data,$type);
105 0 ▶ if ($w eq 'prepass') {
Branch: 2 branches
BranchTrueFalseTotal
if ($w eq 'prepass') { } 0 0 0
elsif ($data eq '' and $maxoff != -1) { } 0 0 0
106 0 $self->{imp}->data($dir,$data,$lastoff,$type);
107 0 $self->{skipped}[$dir] = 0;
108 ▶ } elsif ( $data eq '' and $maxoff != IMP_MAXOFFSET ) {
Condition0%0/3
$data eq "" and $maxoff != -1
!ll&&!rl&&r
000
MC/DC0%0/2
$data eq "" and $maxoff != -1
$data eq "" $maxoff != -1
Truth table0%0/3
A and B
A= $data eq ""B= $maxoff != -1
ABresult
0X0
100
111
109 0 $self->{imp}->data($dir,$data,$lastoff,$type);
110 0 $self->{skipped}[$dir] = 0;
111 } else {
112 0 $self->{skipped}[$dir] = 1;
113 }
114 0 return;
115 }
116  
117 0 my $canfw = $maxoff - $buf->[-1][0];
118 0 ▶ if ( $type > 0 and $canfw != length($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type > 0 and $canfw != length $data) 0 0 0
Condition0%0/3
$type > 0 and $canfw != length $data
!ll&&!rl&&r
000
MC/DC0%0/2
$type > 0 and $canfw != length $data
$type > 0 $canfw != length $data
Truth table0%0/3
A and B
A= $type > 0B= $canfw != length $data
ABresult
0X0
100
111
119 # packet types need to be handled as a single piece
120 0 debug("partial $w for $type ignored");
121 0 next;
122 }
123  
124 0 ▶ $DEBUG && debug("can $w %d bytes of %d", $canfw, length($data));
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("can $w %d bytes of %d", $canfw, length $data) 0 0 0
125 0 my $fwd = substr($data,0,$canfw,'');
126 0 ▶ my $lastoff = $self->{skipped}[$dir] && $buf->[0][0];
Condition0%0/3
$self->{'skipped'}[$dir] && $buf->[0][0]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{'skipped'}[$dir] && $buf->[0][0]
$self->{'skipped'}[$dir] $buf->[0][0]
Truth table0%0/3
A && B
A= $self->{'skipped'}[$dir]B= $buf->[0][0]
ABresult
0X0
100
111
127 0 $buf->[0][0] += length($fwd);
128 0 $self->{$w}[$dir] = 0; # no more (pre)pass
129 0 $self->out($dir,$fwd,$type);
130 0 ▶ if ($w eq 'prepass') {
Branch: 1 branch
BranchTrueFalseTotal
if ($w eq 'prepass') { } 0 0 0
131 0 $self->{imp}->data($dir,$fwd,$lastoff,$type);
132 0 $self->{skipped}[$dir] = 0;
133 } else {
134 0 $self->{skipped}[$dir] = 1;
135 }
136 }
137  
138 # data left which need to be forwarded to analyzer
139 25 ▶ if ( ! $buf->[-1][2] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $buf->[-1][2]) { } 12 13 25
elsif ($type < 0 and $buf->[-1][2] == $type) { } 12 1 13
140 # replace empty (untyped) buffer with new data
141 12 $buf->[-1][1] = $data;
142 12 $buf->[-1][2] = $type;
143 ▶ } elsif ( $type < 0 and $buf->[-1][2] == $type ) {
Condition66%2/3
$type < 0 and $buf->[-1][2] == $type
!ll&&!rl&&r
1012
MC/DC50%1/2
$type < 0 and $buf->[-1][2] == $type
$type < 0 $buf->[-1][2] == $type
Truth table66%2/3
A and B
A= $type < 0B= $buf->[-1][2] == $type
ABresult
0X0
100
111
144 # streaming data of same type can be added to current buffer
145 12 $buf->[-1][1] .= $data;
146 } else {
147 # need new buffer
148 1 push @$buf,[
149 $buf->[-1][0] + length($buf->[-1][1]), # base = end of last
150 $data,
151 $type
152 ];
153 }
154  
155 25 ▶ $DEBUG && debug("buffer and analyze %d bytes of data", length($data));
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("buffer and analyze %d bytes of data", length $data) 0 25 25
156 25 ▶ my $lastoff = $self->{skipped}[$dir] && $buf->[0][0];
Condition33%1/3
$self->{'skipped'}[$dir] && $buf->[0][0]
!ll&&!rl&&r
2500
MC/DC0%0/2
$self->{'skipped'}[$dir] && $buf->[0][0]
$self->{'skipped'}[$dir] $buf->[0][0]
Truth table33%1/3
A && B
A= $self->{'skipped'}[$dir]B= $buf->[0][0]
ABresult
0X0
100
111
157 25 $self->{imp}->data($dir,$data,$lastoff,$type);
158 25 $self->{skipped}[$dir] = 0;
159 }
160  
161 # callback from analyzer
162 sub _imp_cb {
163 68 ▶ my $self = shift;
Subroutine _imp_cb: called CC=45 SCAR=52.0
164 68 ▶ $self->{dead} and return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"dead"} and return 0 68 68
165  
166 68 my @fwd;
167 68 for my $rv (@_) {
168 71 my $rtype = shift(@$rv);
169 71 ▶ $DEBUG && debug("$rtype ".join(" ",map { "'$_'" } @$rv));
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("$rtype " . join(" ", map({"'${_}'";} @$rv))) 0 71 71
170  
171 71 ▶ if ( $rtype == IMP_DENY ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($rtype == 4352) { } 0 71 71
elsif ($rtype == 4354) { } 0 71 71
elsif ($rtype == 1) { } 0 71 71
elsif ($rtype == 4) { } 0 71 71
elsif ($rtype ~~ [4097, 4099]) { } 40 31 71
elsif ($rtype == 4113) { } 31 0 31
elsif ($rtype ~~ [16, 17]) { } 0 0 0
172 0 my ($dir,$msg,@extmsg) = @$rv;
173 0 $self->deny($msg,$dir,@extmsg);
174 0 $self->{dead} = 1;
175 0 return;
176 } elsif ( $rtype == IMP_FATAL ) {
177 0 my $reason = shift;
178 0 $self->fatal($reason);
179 0 $self->{dead} = 1;
180 0 return;
181  
182 } elsif ( $rtype == IMP_LOG ) {
183 0 my ($dir,$offset,$len,$level,$msg,@extmsg) = @$rv;
184 0 $self->log($level,$msg,$dir,$offset,$len,@extmsg);
185  
186 } elsif ( $rtype == IMP_ACCTFIELD ) {
187 0 my ($key,$value) = @$rv;
188 0 $self->acctfld($key,$value);
189  
190 } elsif ( $rtype ~~ [ IMP_PASS, IMP_PREPASS ] ) {
191 40 my ($dir,$offset) = @$rv;
192 40 ▶ $DEBUG && debug("got %s %d|%d", $rtype,$dir,$offset);
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("got %s %d|%d", $rtype, $dir, $offset) 0 40 40
193  
194 40 ▶ if ( $self->{pass}[$dir] == IMP_MAXOFFSET ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'pass'}[$dir] == -1) { } 0 40 40
elsif ($rtype == 4097) { } 40 0 40
elsif ($offset == -1 or $offset > $self->{'pass'}[$dir] and $offset > $self->{'prepass'}[$dir]) { } 0 0 0
195 0 next; # cannot get better than previous pass
196 } elsif ( $rtype == IMP_PASS ) {
197 40 ▶ if ( $offset == IMP_MAXOFFSET ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($offset == -1) { } 9 31 40
elsif ($offset > $self->{'pass'}[$dir]) { } 31 0 31
198 9 $self->{pass}[$dir] = $offset;
199 9 $self->{prepass}[$dir] = 0;
200 } elsif ( $offset > $self->{pass}[$dir] ) {
201 31 $self->{pass}[$dir] = $offset;
202 $self->{prepass}[$dir] = 0
203 31 ▶ if $offset >= $self->{prepass}[$dir];
Branch: 1 branch
BranchTrueFalseTotal
if $offset >= $self->{"prepass"}[$dir] 31 0 31
204 } else {
205 0 next; # not better than previous pass
206 }
207  
208 # IMP_PREPASS
209 ▶ } elsif ( $offset == IMP_MAXOFFSET or (
Condition0%0/6
$offset == -1 or $offset > $self->{"pass"}[$dir] and $offset > $self->{"prepass"}[$dir]
l!l&&r!l&&!r
000
$offset > $self->{"pass"}[$dir] and $offset > $self->{"prepass"}[$dir]
!ll&&!rl&&r
000
MC/DC0%0/3
$offset == -1 or $offset > $self->{"pass"}[$dir] and $offset > $self->{"prepass"}[$dir]
$offset == -1 $offset > $self->{"pass"}[$dir] $offset > $self->{"prepass"}[$dir]
Truth table0%0/4
A or B and C
A= $offset == -1B= $offset > $self->{"pass"}[$dir]C= $offset > $self->{"prepass"}[$dir]
ABCresult
1XX1
0111
00X0
0100
210 $offset > $self->{pass}[$dir] and
211 $offset > $self->{prepass}[$dir] )) {
212 # update for prepass
213 0 $self->{prepass}[$dir] = $offset
214 } else {
215 # next; # no better than previous prepass
216 }
217  
218 40 my $buf = $self->{buf}[$dir];
219 40 my $end;
220  
221 40 ▶ while ($buf->[0][2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf->[0][2]) 32 9 41
222 32 my $buf0 = shift(@$buf);
223 32 $end = $buf0->[0] + length($buf0->[1]);
224 32 ▶ if ( $offset == IMP_MAXOFFSET
Branch: 4 branches
BranchTrueFalseTotal
if ($offset == -1 or $offset >= $end) { } 10 22 32
elsif ($offset < $buf0->[0]) { } 0 22 22
elsif ($offset == $buf0->[0]) { } 1 21 22
elsif ($buf0->[2] < 0) { } 21 0 21
Condition66%2/3
$offset == -1 or $offset >= $end
l!l&&r!l&&!r
01022
MC/DC50%1/2
$offset == -1 or $offset >= $end
$offset == -1 $offset >= $end
Truth table66%2/3
A or B
A= $offset == -1B= $offset >= $end
ABresult
1X1
011
000
225 or $offset >= $end ) {
226 10 ▶ $DEBUG && debug("pass complete buf");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("pass complete buf") 0 10 10
227 10 push @fwd, [ $dir, $buf0->[1] ];
228 # keep dummy in buf
229 10 ▶ if ( ! @$buf ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$buf) 9 1 10
230 9 unshift @$buf,[ $buf0->[0] + length($buf0->[1]),'',0 ];
231 9 ▶ push @fwd,[$dir,''] if $self->{eof}[$dir]; # fwd eof
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"eof"}[$dir] 9 0 9
232 9 last;
233 }
234 } elsif ( $offset < $buf0->[0] ) {
235 0 ▶ $DEBUG && debug("duplicate $rtype $offset ($buf0->[0])");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("duplicate $rtype $offset ($buf0->[0])") 0 0 0
236 0 unshift @$buf,$buf0;
237 0 last;
238 } elsif ( $offset == $buf0->[0] ) {
239 # at border, e.g. forward 0 bytes
240 1 unshift @$buf,$buf0;
241 1 last;
242 } elsif ( $buf0->[2] < 0 ) {
243 # streaming type, can pass part of buf
244 21 ▶ $DEBUG && debug("pass part of buf");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("pass part of buf") 0 21 21
245 21 push @fwd, [
246 $dir,
247 substr($buf0->[1],0,$offset - $end,'')
248 ];
249 # put back with adjusted offset
250 21 $buf0->[0] = $offset;
251 21 unshift @$buf, $buf0;
252 21 last;
253 } else {
254 0 ▶ $DEBUG && debug(
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("ignore partial $rtype for $buf0->[2] (offset=$offset,pos=$buf0->[0])") 0 0 0
255 "ignore partial $rtype for $buf0->[2] (offset=$offset,pos=$buf0->[0])");
256 0 unshift @$buf, $buf0; # put back
257 0 last;
258 }
259 }
260  
261 40 ▶ if ( $offset != IMP_MAXOFFSET and $offset <= $end ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset != -1 and $offset <= $end) 31 9 40
Condition66%2/3
$offset != -1 and $offset <= $end
!ll&&!rl&&r
9031
MC/DC50%1/2
$offset != -1 and $offset <= $end
$offset != -1 $offset <= $end
Truth table66%2/3
A and B
A= $offset != -1B= $offset <= $end
ABresult
0X0
100
111
262 # limit reached, reset (pre)pass
263 31 ▶ $self->{ $rtype == IMP_PASS ? 'pass':'prepass' }[$dir] = 0;
Branch: 1 branch
BranchTrueFalseTotal
$rtype == 4097 ? : 31 0 31
264 }
265  
266 } elsif ( $rtype == IMP_REPLACE ) {
267 31 my ($dir,$offset,$newdata) = @$rv;
268 31 ▶ $DEBUG && debug("got %s %d|%d", $rtype,$dir,$offset);
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("got %s %d|%d", $rtype, $dir, $offset) 0 31 31
269  
270 31 ▶ if ( $self->{pass}[$dir] or $self->{prepass}[$dir] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pass"}[$dir] or $self->{"prepass"}[$dir]) 0 31 31
Condition33%1/3
$self->{"pass"}[$dir] or $self->{"prepass"}[$dir]
l!l&&r!l&&!r
0031
MC/DC0%0/2
$self->{"pass"}[$dir] or $self->{"prepass"}[$dir]
$self->{"pass"}[$dir] $self->{"prepass"}[$dir]
Truth table33%1/3
A or B
A= $self->{"pass"}[$dir]B= $self->{"prepass"}[$dir]
ABresult
1X1
011
000
271 # we are allowed to (pre)pass in future, so we cannot replace
272 0 die "cannot replace already passed data";
273 }
274  
275 31 my $buf = $self->{buf}[$dir];
276 31 my $buf0 = $buf->[0];
277 31 my $eob = $buf0->[0] + length($buf0->[1]);
278 31 ▶ if ( $eob < $offset ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($eob < $offset) { } 0 31 31
elsif ($eob == $offset) { } 3 28 31
279 0 die "replacement cannot span different types or packets";
280 } elsif ( $eob == $offset ) {
281 # full replace
282 3 ▶ $DEBUG && debug("full replace");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("full replace") 0 3 3
283 3 push @fwd,[ $dir,$newdata ];
284 3 shift(@$buf);
285 3 ▶ push @$buf, [ $eob,'',0 ] if ! @$buf;
Branch: 1 branch
BranchTrueFalseTotal
unless @$buf 3 0 3
286 } else {
287 28 ▶ die "no partial replacement for packet types allowed"
Branch: 1 branch
BranchTrueFalseTotal
if $buf0->[2] > 0 0 28 28
288 if $buf0->[2]>0;
289 28 ▶ $DEBUG && debug("partial replace");
Branch: 1 branch
BranchTrueFalseTotal
$Net::IMP::Filter::DEBUG and debug("partial replace") 0 28 28
290 28 push @fwd,[ $dir,$newdata ];
291 28 substr( $buf0->[1],0,$offset - $buf0->[0],'');
292 28 $buf0->[0] = $offset;
293 }
294  
295 } elsif ( $rtype ~~ [ IMP_PAUSE, IMP_CONTINUE ] ) {
296 # ignore
297 } else {
298 0 die "cannot handle Net::IMP rtype $rtype";
299 }
300 }
301 68 $self->out(@$_) for (@fwd);
302 }
303  
304  
305 3 1;
306 __END__
« IMP/ProtocolPinning.pm ↑ Summary IMP/Debug.pm »