/src/samba/source4/libcli/smb2/tcon.c
Line | Count | Source |
1 | | /* |
2 | | Unix SMB/CIFS implementation. |
3 | | |
4 | | SMB2 client tree handling |
5 | | |
6 | | Copyright (C) Andrew Tridgell 2005 |
7 | | |
8 | | This program is free software; you can redistribute it and/or modify |
9 | | it under the terms of the GNU General Public License as published by |
10 | | the Free Software Foundation; either version 3 of the License, or |
11 | | (at your option) any later version. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #include "includes.h" |
23 | | #include "libcli/smb2/smb2.h" |
24 | | #include "libcli/smb2/smb2_calls.h" |
25 | | #include "../libcli/smb/smbXcli_base.h" |
26 | | |
27 | | /* |
28 | | initialise a smb2_session structure |
29 | | */ |
30 | | struct smb2_tree *smb2_tree_init(struct smb2_session *session, |
31 | | TALLOC_CTX *parent_ctx, bool primary) |
32 | 0 | { |
33 | 0 | struct smb2_tree *tree; |
34 | |
|
35 | 0 | tree = talloc_zero(parent_ctx, struct smb2_tree); |
36 | 0 | if (!session) { |
37 | 0 | return NULL; |
38 | 0 | } |
39 | 0 | if (primary) { |
40 | 0 | tree->session = talloc_steal(tree, session); |
41 | 0 | } else { |
42 | 0 | tree->session = talloc_reference(tree, session); |
43 | 0 | } |
44 | |
|
45 | 0 | tree->smbXcli = smbXcli_tcon_create(tree); |
46 | 0 | if (tree->smbXcli == NULL) { |
47 | 0 | talloc_free(tree); |
48 | 0 | return NULL; |
49 | 0 | } |
50 | | |
51 | 0 | return tree; |
52 | 0 | } |
53 | | |
54 | | struct smb2_tree *smb2_tree_channel(struct smb2_tree *base_tree, |
55 | | TALLOC_CTX *parent_ctx, bool primary, |
56 | | struct smb2_session *session) |
57 | 0 | { |
58 | 0 | struct smb2_tree *tree; |
59 | |
|
60 | 0 | tree = talloc_zero(parent_ctx, struct smb2_tree); |
61 | 0 | if (!session) { |
62 | 0 | return NULL; |
63 | 0 | } |
64 | 0 | if (primary) { |
65 | 0 | tree->session = talloc_steal(tree, session); |
66 | 0 | } else { |
67 | 0 | tree->session = talloc_reference(tree, session); |
68 | 0 | } |
69 | |
|
70 | 0 | tree->smbXcli = smbXcli_tcon_copy(tree, base_tree->smbXcli); |
71 | 0 | if (tree->smbXcli == NULL) { |
72 | 0 | talloc_free(tree); |
73 | 0 | return NULL; |
74 | 0 | } |
75 | | |
76 | 0 | return tree; |
77 | 0 | } |