blib/lib/SMB/v2/Header.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 18 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 52 SCAR 24.8
CC
3
Cov
0%
new
6.0
is_response
6.0
is_signed
2.0
CRAP 12.0
1 # SMB Perl library, Copyright (C) 2014 Mikhael Goikhman, migo@cpan.org
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15  
16 package SMB::v2::Header;
17  
18 use strict;
19 use warnings;
20  
21 use parent 'SMB::Header';
22  
23 use constant {
24 # the command is a response, otherwise a request
25 FLAGS_RESPONSE => 0x1,
26 # the command is asynchronous
27 FLAGS_ASYNC_COMMAND => 0x2,
28 # the command is continued, part of the chain
29 FLAGS_CHAINED => 0x4,
30 # the command is signed */
31 FLAGS_SIGNED => 0x8,
32 # DFS resolution is required
33 FLAGS_DFS => 0x10000000,
34 };
35  
36 sub new ($%) {
37 my $class = shift;
38 my %options = @_;
39  
40 return $class->SUPER::new(
41 aid => delete $options{aid} || 0,
42 credits => delete $options{credits} || 0,
43 credit_charge => delete $options{credit_charge} || ($options{code} ? 1 : 0),
44 struct_size => delete $options{struct_size} || 2,
45 %options,
46 );
47 }
48  
49 sub is_response ($) {
50 my $self = shift;
51  
52 return $self->flags & FLAGS_RESPONSE ? 1 : 0;
53 }
54  
55 sub is_signed ($) {
56 my $self = shift;
57 my $signature = $self->signature;
58  
59 return ref($signature) eq 'ARRAY' && @$signature == 16 &&
60 (join('', $signature) ne "\0" x 16) &&
61 ($self->flags & FLAGS_SIGNED) != 0;
62 }
63  
64 1;