File Coverage

lib/SMB/v2/Header.pm
Criterion Covered Total %
statement 12 20 60.0
branch 0 2 0.0
condition 0 12 0.0
subroutine 4 7 57.1
pod 1 3 33.3
total 17 44 38.6


line stmt bran cond sub pod time code
1             # SMB Perl library, Copyright (C) 2014-2018 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 .
15              
16             package SMB::v2::Header;
17              
18 1     1   5 use strict;
  1         1  
  1         20  
19 1     1   3 use warnings;
  1         2  
  1         17  
20              
21 1     1   3 use parent 'SMB::Header';
  1         1  
  1         4  
22              
23             use constant {
24             # the command is a response, otherwise a request
25 1         224 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 1     1   45 };
  1         1  
35              
36             sub new ($%) {
37 0     0 1   my $class = shift;
38 0           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 0   0       struct_size => delete $options{struct_size} || 2,
      0        
      0        
      0        
45             %options,
46             );
47             }
48              
49             sub is_response ($) {
50 0     0 0   my $self = shift;
51              
52 0 0         return $self->flags & FLAGS_RESPONSE ? 1 : 0;
53             }
54              
55             sub is_signed ($) {
56 0     0 0   my $self = shift;
57 0           my $signature = $self->signature;
58              
59 0   0       return ref($signature) eq 'ARRAY' && @$signature == 16 &&
60             (join('', $signature) ne "\0" x 16) &&
61             ($self->flags & FLAGS_SIGNED) != 0;
62             }
63              
64             1;