| 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::Command::TreeConnect; | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | use parent 'SMB::v2::Command'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | sub init ($) { | ||||||||||
| 24 | 0 | ▶ | $_[0]->set( | ||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 25 | share_type => 1, | ||||||||||
| 26 | share_flags => 0x800, | ||||||||||
| 27 | capabilities => 0, | ||||||||||
| 28 | access_mask => 0x1f01ff, | ||||||||||
| 29 | uri => undef, | ||||||||||
| 30 | ) | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | sub verify_uri ($) { | ||||||||||
| 34 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
verify_uri: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | die "Tree connect $self misses share uri\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | unless $self->parse_share_uri($self->uri); | ||||||||||
| 38 | |||||||||||
| 39 | 0 | return $self->uri; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub parse ($$) { | ||||||||||
| 43 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 44 | 0 | my $parser = shift; | |||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | if ($self->is_response) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | $self->share_type($parser->uint8); | |||||||||
| 48 | 0 | $parser->uint8; # reserved | |||||||||
| 49 | 0 | $self->share_flags($parser->uint32); | |||||||||
| 50 | 0 | $self->capabilities($parser->uint32); | |||||||||
| 51 | 0 | $self->access_mask($parser->uint32); | |||||||||
| 52 | } else { | ||||||||||
| 53 | 0 | $parser->uint16; # reserved | |||||||||
| 54 | 0 | $parser->uint16; | |||||||||
| 55 | 0 | my $uri_len = $parser->uint16; | |||||||||
| 56 | 0 | $self->uri($parser->utf16($uri_len)); | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 0 | return $self; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | sub pack ($$) { | ||||||||||
| 63 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
pack: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 64 | 0 | my $packer = shift; | |||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | if ($self->is_response) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | $packer | |||||||||
| 68 | ->uint8($self->share_type) | ||||||||||
| 69 | ->uint8(0) # reserved | ||||||||||
| 70 | ->uint32($self->share_flags) | ||||||||||
| 71 | ->uint32($self->capabilities) | ||||||||||
| 72 | ->uint32($self->access_mask) | ||||||||||
| 73 | ; | ||||||||||
| 74 | } else { | ||||||||||
| 75 | 0 | $packer | |||||||||
| 76 | ->uint16(0) # reserved | ||||||||||
| 77 | ->uint16($packer->diff('smb-header') + 4) | ||||||||||
| 78 | ->stub('uri-len', 'uint16') | ||||||||||
| 79 | ->mark('uri') | ||||||||||
| 80 | ->utf16($self->verify_uri) | ||||||||||
| 81 | ->fill('uri-len', $packer->diff('uri')) | ||||||||||
| 82 | ; | ||||||||||
| 83 | } | ||||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 1 | 1; | |||||||||