blib/lib/POE/Component/Client/NRPE.pm

filter: Statementstmt 91.3% 159 / 174 Branchbran 71.4% 40 / 56 Conditioncond 54.8% 17 / 31 MC/DCmcdc 22.2% 4 / 18 Subroutinesub 100% 19 / 19 Podpod 100% 1 / 1 totaltotal 80.2% 240 / 299 CC 42 SCAR 21.7
CC
42
Cov
83%
check_nrpe
15.4
_sock_in
14.7
_send_response
7.0
CRAP 8.8
↑ Summary
1 package POE::Component::Client::NRPE;
2 {
3 10 $POE::Component::Client::NRPE::VERSION = '0.20';
4 }
5  
6 #ABSTRACT: A POE Component that implements check_nrpe functionality
7  
8 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use POE qw(Wheel::SocketFactory Filter::Stream Wheel::ReadWrite);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Net::SSLeay;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use POE::Component::SSLify qw( Client_SSLify );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 10 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 10 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 9 ▶sub check_nrpe {
Subroutine check_nrpe: called CC=14 SCAR=27.3
Pod documented
18 9 my $package = shift;
19 9 my %params = @_;
20 9 $params{lc $_} = delete $params{$_} for keys %params;
21 croak "$package requires a 'host' argument\n"
22 9 ▶ unless $params{host};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"host"} 0 9 9
23 croak "$package requires an 'event' argument\n"
24 9 ▶ unless $params{event};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"event"} 0 9 9
25 9 ▶ $params{port} = 5666 unless defined $params{port};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params{"port"} 1 8 9
26 9 ▶ $params{command} = '_NRPE_CHECK' unless $params{command};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"command"} 9 0 9
27 9 ▶ $params{command} = join( '!', $params{command}, $params{args} ) if defined $params{args};
Branch: 1 branch
BranchTrueFalseTotal
if defined $params{"args"} 0 9 9
28 9 ▶ $params{version} = 2 unless $params{version} and $params{version} eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"version"} and $params{"version"} eq 1 8 1 9
Condition66%2/3
$params{"version"} and $params{"version"} eq 1
!ll&&!rl&&r
801
MC/DC50%1/2
$params{"version"} and $params{"version"} eq 1
$params{"version"} $params{"version"} eq 1
Truth table66%2/3
A and B
A= $params{"version"}B= $params{"version"} eq 1
ABresult
0X0
100
111
29 9 ▶ $params{usessl} = 1 unless defined $params{usessl} and $params{usessl} eq '0';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params{"usessl"} and $params{"usessl"} eq 0 1 8 9
Condition66%2/3
defined $params{"usessl"} and $params{"usessl"} eq 0
!ll&&!rl&&r
108
MC/DC50%1/2
defined $params{"usessl"} and $params{"usessl"} eq 0
defined $params{"usessl"} $params{"usessl"} eq 0
Truth table66%2/3
A and B
A= defined $params{"usessl"}B= $params{"usessl"} eq 0
ABresult
0X0
100
111
30 9 ▶ $params{timeout} = 10 unless defined $params{timeout} and $params{timeout} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params{"timeout"} and $params{"timeout"} =~ /^\d+$/ 4 5 9
Condition66%2/3
defined $params{"timeout"} and $params{"timeout"} =~ /^\d+$/
!ll&&!rl&&r
405
MC/DC50%1/2
defined $params{"timeout"} and $params{"timeout"} =~ /^\d+$/
defined $params{"timeout"} $params{"timeout"} =~ /^\d+$/
Truth table66%2/3
A and B
A= defined $params{"timeout"}B= $params{"timeout"} =~ /^\d+$/
ABresult
0X0
100
111
31 9 my $options = delete $params{options};
32 9 my $self = bless \%params, $package;
33 9 ▶ $self->{session_id} = POE::Session->create(
Branch: 1 branch
BranchTrueFalseTotal
ref $options eq 'HASH' ? : 0 9 9
34 object_states => [
35 $self => [ qw(_start _connect _sock_up _sock_err _sock_in _sock_down _send_response _timeout) ],
36 ],
37 heap => $self,
38 ( ref($options) eq 'HASH' ? ( options => $options ) : () ),
39 )->ID();
40 9 return $self;
41 }
42  
43 9 ▶sub _start {
Subroutine _start: called CC=5 SCAR=19.2
44 9 my ($kernel,$sender,$self) = @_[KERNEL,SENDER,OBJECT];
45 9 $self->{session_id} = $_[SESSION]->ID();
46 9 $self->{filter} = POE::Filter::Stream->new();
47 9 ▶ if ( $kernel == $sender and !$self->{session} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kernel == $sender and not $self->{"session"}) 0 9 9
Condition33%1/3
$kernel == $sender and not $self->{"session"}
!ll&&!rl&&r
900
MC/DC0%0/2
$kernel == $sender and not $self->{"session"}
$kernel == $sender not $self->{"session"}
Truth table33%1/3
A and not(B)
A= $kernel == $senderB= not $self->{"session"}
ABresult
0X0
100
111
48 0 croak "Not called from another POE session and 'session' wasn't set\n";
49 }
50 9 my $sender_id;
51 9 ▶ if ( $self->{session} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'session'}) { } 0 9 9
52 0 ▶ if ( my $ref = $kernel->alias_resolve( $self->{session} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ref = $kernel->alias_resolve($self->{'session'})) { } 0 0 0
53 0 $sender_id = $ref->ID();
54 }
55 else {
56 0 croak "Could not resolve 'session' to a valid POE session\n";
57 }
58 }
59 else {
60 9 $sender_id = $sender->ID();
61 }
62 9 $kernel->refcount_increment( $sender_id, __PACKAGE__ );
63 9 $self->{sender_id} = $sender_id;
64 9 $kernel->yield( '_connect' );
65 9 return;
66 }
67  
68 9 ▶sub _connect {
Subroutine _connect: called CC=1 SCAR=0.0
69 9 my ($kernel,$self) = @_[KERNEL,OBJECT];
70 $self->{sockfactory} = POE::Wheel::SocketFactory->new(
71 SocketProtocol => 'tcp',
72 RemoteAddress => $self->{host},
73 RemotePort => $self->{port},
74 9 SuccessEvent => '_sock_up',
75 FailureEvent => '_sock_err',
76 );
77 9 $kernel->delay( '_timeout', $self->{timeout} );
78 9 return;
79 }
80  
81 2 ▶sub _timeout {
Subroutine _timeout: called CC=1 SCAR=0.0
82 2 my ($kernel,$self) = @_[KERNEL,OBJECT];
83 2 delete $self->{sockfactory};
84 2 delete $self->{socket};
85 2 $kernel->yield( '_send_response', 'timeout' );
86 2 return;
87 }
88  
89 2 ▶sub _sock_err {
Subroutine _sock_err: called CC=1 SCAR=0.0
90 2 my ($kernel,$self) = @_[KERNEL,OBJECT];
91 2 $kernel->delay( '_timeout' );
92 2 delete $self->{sockfactory};
93 2 $kernel->yield( '_send_response', 'sockerr', @_[ARG0..ARG2] );
94 2 return;
95 }
96  
97 7 ▶sub _sock_up {
Subroutine _sock_up: called CC=5 SCAR=18.0
98 7 my ($kernel,$self,$socket) = @_[KERNEL,OBJECT,ARG0];
99 7 $kernel->delay( '_timeout' );
100 7 delete $self->{sockfactory};
101 # Only version 2 supports SSL
102 7 ▶ if ( $self->{version} == 2 and $self->{usessl} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"version"} == 2 and $self->{"usessl"}) 0 7 7
Condition66%2/3
$self->{"version"} == 2 and $self->{"usessl"}
!ll&&!rl&&r
160
MC/DC0%0/2
$self->{"version"} == 2 and $self->{"usessl"}
$self->{"version"} == 2 $self->{"usessl"}
Truth table66%2/3
A and B
A= $self->{"version"} == 2B= $self->{"usessl"}
ABresult
0X0
100
111
103 0 my $ctx = Net::SSLeay::CTX_tlsv1_new();
104 0 Net::SSLeay::CTX_set_cipher_list( $ctx, 'ADH');
105 0 eval { $socket = Client_SSLify( $socket, undef, undef, $ctx ); };
106 0 ▶ warn "Failed to SSLify the socket: $@\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
107 }
108 $self->{socket} = new POE::Wheel::ReadWrite
109 ( Handle => $socket,
110 Filter => $self->{filter},
111 7 InputEvent => '_sock_in',
112 ErrorEvent => '_sock_down',
113 );
114 7 my $packet;
115 7 ▶ if ( $self->{version} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'version'} == 1) { } 1 6 7
116 1 $packet = pack "NNNNa[1024]", 1, 1, 0, length( $self->{command} ), $self->{command};
117 }
118 else {
119 6 $packet = _gen_packet_ver2( $self->{command} );
120 }
121 7 $self->{socket}->put( $packet );
122 7 $kernel->delay( '_timeout', $self->{timeout} );
123 7 return;
124 }
125  
126 1 ▶sub _sock_down {
Subroutine _sock_down: called CC=2 SCAR=7.0
127 1 my ($kernel,$self) = @_[KERNEL,OBJECT];
128 1 delete $self->{socket};
129 1 $kernel->delay( '_timeout' );
130 1 ▶ $kernel->yield( '_send_response', 'nodata' ) unless $self->{_data_returned};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_data_returned"} 1 0 1
131 1 return;
132 }
133  
134 4 ▶sub _sock_in {
Subroutine _sock_in: called CC=12 SCAR=26.9
135 4 my ($kernel,$self,$input) = @_[KERNEL,OBJECT,ARG0];
136 4 my ($result,$data);
137 SWITCH: {
138 4 ▶ if ( $self->{version} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'version'} == 1) { } 1 3 4
139 1 my $length = length $input;
140 1 ▶ if ( $length != 1040 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length != 1040) 0 1 1
141 0 $result = 3;
142 0 $data = sprintf "CHECK_NRPE: Received %d bytes (%d expected)", $length, 1040;
143 0 last SWITCH;
144 }
145 1 my @args = unpack "NNNNa*", $input;
146 1 ▶ if ( $args[0] ne '2' or $args[1] ne '1' or $args[2] !~ /^[0123]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[0] ne 2 or $args[1] ne 1 or not $args[2] =~ /^[0123]$/) 0 1 1
Condition33%2/6
$args[0] ne 2 or $args[1] ne 1 or not $args[2] =~ /^[0123]$/
l!l&&r!l&&!r
001
$args[0] ne 2 or $args[1] ne 1
l!l&&r!l&&!r
001
MC/DC0%0/3
$args[0] ne 2 or $args[1] ne 1 or not $args[2] =~ /^[0123]$/
$args[0] ne 2 $args[1] ne 1 not $args[2] =~ /^[0123]$/
Truth table25%1/4
A or B or not(C)
A= $args[0] ne 2B= $args[1] ne 1C= not $args[2] =~ /^[0123]$/
ABCresult
1XX1
01X1
0011
0000
147 0 $result = 3;
148 0 $data = 'CHECK_NRPE: Packet failed sanity checking';
149 0 last SWITCH;
150 }
151 1 $args[4] =~ s/\x00*$//g;
152 1 $result = $args[2];
153 1 ▶ $data = $args[4] || 'CHECK_NRPE: No output returned from NRPE daemon.';
Condition50%1/2
$args[4] || 'CHECK_NRPE: No output returned from NRPE daemon.'
l!l
10
MC/DC0%0/1
$args[4] || 'CHECK_NRPE: No output returned from NRPE daemon.'
$args[4]
Truth table50%1/2
A
A= $args[4]
Aresult
11
00
154 }
155 else {
156 3 my $length = length $input;
157 3 ▶ if ( $length != 1036 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length != 1036) 1 2 3
158 1 $result = 3;
159 1 $data = sprintf "CHECK_NRPE: Received %d bytes (%d expected)", $length, 1036;
160 1 last SWITCH;
161 }
162 2 my @args = unpack "nnNnZ*", $input;
163 2 ▶ if ( $args[0] ne '2' or $args[1] ne '2' or $args[3] !~ /^[0123]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[0] ne 2 or $args[1] ne 2 or not $args[3] =~ /^[0123]$/) 1 1 2
Condition66%4/6
$args[0] ne 2 or $args[1] ne 2 or not $args[3] =~ /^[0123]$/
l!l&&r!l&&!r
101
$args[0] ne 2 or $args[1] ne 2
l!l&&r!l&&!r
101
MC/DC33%1/3
$args[0] ne 2 or $args[1] ne 2 or not $args[3] =~ /^[0123]$/
$args[0] ne 2 $args[1] ne 2 not $args[3] =~ /^[0123]$/
Truth table50%2/4
A or B or not(C)
A= $args[0] ne 2B= $args[1] ne 2C= not $args[3] =~ /^[0123]$/
ABCresult
1XX1
01X1
0011
0000
164 1 $result = 3;
165 1 $data = 'CHECK_NRPE: Packet failed sanity checking';
166 1 last SWITCH;
167 }
168 1 $args[4] =~ s/\x00*$//g;
169 1 $result = $args[3];
170 1 ▶ $data = $args[4] || 'CHECK_NRPE: No output returned from NRPE daemon.';
Condition50%1/2
$args[4] || 'CHECK_NRPE: No output returned from NRPE daemon.'
l!l
10
MC/DC0%0/1
$args[4] || 'CHECK_NRPE: No output returned from NRPE daemon.'
$args[4]
Truth table50%1/2
A
A= $args[4]
Aresult
11
00
171 }
172 }
173 4 $self->{_data_returned} = [ $result, $data ];
174 4 delete $self->{socket};
175 4 $kernel->yield( '_send_response', 'gotdata', $result, $data );
176 4 return;
177 }
178  
179 9 ▶sub _send_response {
Subroutine _send_response: called CC=7 SCAR=19.5
180 9 my ($kernel,$self,$type) = @_[KERNEL,OBJECT,ARG0];
181 9 my $response = { };
182 9 $response->{$_} = $self->{$_} for qw(version host command context);
183 SWITCH: {
184 9 ▶ if ( $type eq 'gotdata' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "gotdata") 4 5 9
185 4 $response->{result} = $_[ARG1];
186 4 $response->{data} = $_[ARG2];
187 4 last SWITCH;
188 }
189 5 ▶ if ( $type eq 'nodata' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "nodata") 1 4 5
190 1 $response->{result} = 3;
191 1 $response->{data} = 'CHECK NRPE: Error receiving data from daemon.';
192 1 last SWITCH;
193 }
194 4 ▶ if ( $type eq 'sockerr' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "sockerr") 2 2 4
195 2 $response->{result} = 3;
196 2 $response->{data} = 'CHECK NRPE: socket error: ' . join(' ', @_[ARG1..$#_]);
197 2 last SWITCH;
198 }
199 2 ▶ if ( $type eq 'timeout' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "timeout") 2 0 2
200 2 ▶ $response->{result} = ( $self->{unknown} ? 3 : 2 );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'unknown'} ? : 1 1 2
201 2 $response->{data} = sprintf("CHECK_NRPE: Socket timeout after %d seconds.", $self->{timeout} );
202 2 last SWITCH;
203 }
204 }
205 9 $kernel->post( $self->{sender_id}, $self->{event}, $response );
206 9 $kernel->refcount_decrement( $self->{sender_id}, __PACKAGE__ );
207 9 $kernel->alarm_remove_all();
208 9 return;
209 }
210  
211 # These functions are derived from http://www.stic-online.de/stic/html/nrpe-generic.html
212 # Copyright (C) 2006, 2007 STIC GmbH, http://www.stic-online.de
213 # Licensed under GPLv2
214  
215 6 ▶sub _gen_packet_ver2 {
Subroutine _gen_packet_ver2: called CC=2 SCAR=6.9
216 6 my $data = shift;
217 6 ▶ for ( my $i = length ( $data ); $i < 1024; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 1024) 6078 6 6084
218 6078 $data .= "\x00";
219 }
220 6 $data .= "SR";
221 6 my $res = pack "n", 2324;
222 6 my $packet = "\x00\x02\x00\x01";
223 6 my $tail = $res . $data;
224 6 my $crc = ~_crc32( $packet . "\x00\x00\x00\x00" . $tail );
225 6 $packet .= pack ( "N", $crc ) . $tail;
226 6 return $packet;
227 }
228  
229 8 ▶sub _crc32 {
Subroutine _crc32: called CC=2 SCAR=6.9
230 8 my $crc;
231 my $len;
232 8 my $i;
233 8 my $index;
234 8 my @args;
235 8 my ($arg) = @_;
236 8 my @crc_table =(
237 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
238 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
239 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
240 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
241 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
242 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
243 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
244 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
245 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
246 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
247 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
248 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
249 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
250 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
251 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
252 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
253 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
254 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
255 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
256 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
257 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
258 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
259 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
260 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
261 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
262 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
263 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
264 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
265 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
266 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
267 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
268 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
269 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
270 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
271 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
272 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
273 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
274 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
275 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
276 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
277 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
278 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
279 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
280 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
281 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
282 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
283 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
284 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
285 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
286 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
287 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
288 0x2d02ef8d
289 );
290  
291 8 $crc = 0xffffffff;
292 8 $len = length($arg);
293 8 @args = unpack "c*", $arg;
294 8 ▶ for ($i = 0; $i < $len; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 8288 8 8296
295 8288 $index = ($crc ^ $args[$i]) & 0xff;
296 8288 $crc = $crc_table[$index] ^ (($crc >> 8) & 0x00ffffff);
297 }
298 8 return $crc;
299 }
300  
301 10 'POE it';
302  
303 __END__
↑ Summary