smbXcli: rework smb1cli_trans.c to use smbXcli_conn/smbXcli_req
[Samba/gebeck_regimport.git] / libcli / smb / smbXcli_base.h
blob8cb3b8eee71b3089a4dbc2ebbbd6422e374910ed
1 /*
2 Unix SMB/CIFS implementation.
3 Infrastructure for async SMB client requests
4 Copyright (C) Volker Lendecke 2008
5 Copyright (C) Stefan Metzmacher 2011
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _SMBXCLI_BASE_H_
22 #define _SMBXCLI_BASE_H_
24 struct smbXcli_conn;
25 struct smbXcli_session;
26 struct smb_trans_enc_state;
27 struct GUID;
29 struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
30 int fd,
31 const char *remote_name,
32 enum smb_signing_setting signing_state,
33 uint32_t smb1_capabilities,
34 struct GUID *client_guid);
36 bool smbXcli_conn_is_connected(struct smbXcli_conn *conn);
37 void smbXcli_conn_disconnect(struct smbXcli_conn *conn, NTSTATUS status);
39 bool smbXcli_conn_has_async_calls(struct smbXcli_conn *conn);
41 enum protocol_types smbXcli_conn_protocol(struct smbXcli_conn *conn);
42 bool smbXcli_conn_use_unicode(struct smbXcli_conn *conn);
44 void smbXcli_conn_set_sockopt(struct smbXcli_conn *conn, const char *options);
45 const struct sockaddr_storage *smbXcli_conn_local_sockaddr(struct smbXcli_conn *conn);
46 const struct sockaddr_storage *smbXcli_conn_remote_sockaddr(struct smbXcli_conn *conn);
47 const char *smbXcli_conn_remote_name(struct smbXcli_conn *conn);
49 uint16_t smbXcli_conn_max_requests(struct smbXcli_conn *conn);
50 NTTIME smbXcli_conn_server_system_time(struct smbXcli_conn *conn);
51 const DATA_BLOB *smbXcli_conn_server_gss_blob(struct smbXcli_conn *conn);
52 const struct GUID *smbXcli_conn_server_guid(struct smbXcli_conn *conn);
54 void smbXcli_req_unset_pending(struct tevent_req *req);
55 bool smbXcli_req_set_pending(struct tevent_req *req);
57 uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn);
58 uint32_t smb1cli_conn_max_xmit(struct smbXcli_conn *conn);
59 uint32_t smb1cli_conn_server_session_key(struct smbXcli_conn *conn);
60 const uint8_t *smb1cli_conn_server_challenge(struct smbXcli_conn *conn);
61 uint16_t smb1cli_conn_server_security_mode(struct smbXcli_conn *conn);
62 int smb1cli_conn_server_time_zone(struct smbXcli_conn *conn);
64 bool smb1cli_conn_activate_signing(struct smbXcli_conn *conn,
65 const DATA_BLOB user_session_key,
66 const DATA_BLOB response);
67 bool smb1cli_conn_check_signing(struct smbXcli_conn *conn,
68 const uint8_t *buf, uint32_t seqnum);
69 bool smb1cli_conn_signing_is_active(struct smbXcli_conn *conn);
71 void smb1cli_conn_set_encryption(struct smbXcli_conn *conn,
72 struct smb_trans_enc_state *es);
73 bool smb1cli_conn_encryption_on(struct smbXcli_conn *conn);
75 bool smb1cli_is_andx_req(uint8_t cmd);
76 size_t smb1cli_req_wct_ofs(struct tevent_req **reqs, int num_reqs);
78 uint16_t smb1cli_req_mid(struct tevent_req *req);
79 void smb1cli_req_set_mid(struct tevent_req *req, uint16_t mid);
81 uint32_t smb1cli_req_seqnum(struct tevent_req *req);
82 void smb1cli_req_set_seqnum(struct tevent_req *req, uint32_t seqnum);
84 struct smb1cli_req_expected_response {
85 NTSTATUS status;
86 uint8_t wct;
89 struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx,
90 struct tevent_context *ev,
91 struct smbXcli_conn *conn,
92 uint8_t smb_command,
93 uint8_t additional_flags,
94 uint8_t clear_flags,
95 uint16_t additional_flags2,
96 uint16_t clear_flags2,
97 uint32_t timeout_msec,
98 uint32_t pid,
99 uint16_t tid,
100 uint16_t uid,
101 uint8_t wct, uint16_t *vwv,
102 int iov_count,
103 struct iovec *bytes_iov);
104 NTSTATUS smb1cli_req_chain_submit(struct tevent_req **reqs, int num_reqs);
106 struct tevent_req *smb1cli_req_send(TALLOC_CTX *mem_ctx,
107 struct tevent_context *ev,
108 struct smbXcli_conn *conn,
109 uint8_t smb_command,
110 uint8_t additional_flags,
111 uint8_t clear_flags,
112 uint16_t additional_flags2,
113 uint16_t clear_flags2,
114 uint32_t timeout_msec,
115 uint32_t pid,
116 uint16_t tid,
117 uint16_t uid,
118 uint8_t wct, uint16_t *vwv,
119 uint32_t num_bytes,
120 const uint8_t *bytes);
121 NTSTATUS smb1cli_req_recv(struct tevent_req *req,
122 TALLOC_CTX *mem_ctx,
123 struct iovec **piov,
124 uint8_t **phdr,
125 uint8_t *pwct,
126 uint16_t **pvwv,
127 uint32_t *pvwv_offset,
128 uint32_t *pnum_bytes,
129 uint8_t **pbytes,
130 uint32_t *pbytes_offset,
131 uint8_t **pinbuf,
132 const struct smb1cli_req_expected_response *expected,
133 size_t num_expected);
135 struct tevent_req *smb1cli_trans_send(
136 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
137 struct smbXcli_conn *conn, uint8_t cmd,
138 uint8_t additional_flags, uint8_t clear_flags,
139 uint16_t additional_flags2, uint16_t clear_flags2,
140 uint32_t timeout_msec,
141 uint32_t pid, uint16_t tid, uint16_t uid,
142 const char *pipe_name, uint16_t fid, uint16_t function, int flags,
143 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
144 uint8_t *param, uint32_t num_param, uint32_t max_param,
145 uint8_t *data, uint32_t num_data, uint32_t max_data);
146 NTSTATUS smb1cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
147 uint16_t *recv_flags2,
148 uint16_t **setup, uint8_t min_setup,
149 uint8_t *num_setup,
150 uint8_t **param, uint32_t min_param,
151 uint32_t *num_param,
152 uint8_t **data, uint32_t min_data,
153 uint32_t *num_data);
154 NTSTATUS smb1cli_trans(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn,
155 uint8_t trans_cmd,
156 uint8_t additional_flags, uint8_t clear_flags,
157 uint16_t additional_flags2, uint16_t clear_flags2,
158 uint32_t timeout_msec,
159 uint32_t pid, uint16_t tid, uint16_t uid,
160 const char *pipe_name, uint16_t fid, uint16_t function,
161 int flags,
162 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
163 uint8_t *param, uint32_t num_param, uint32_t max_param,
164 uint8_t *data, uint32_t num_data, uint32_t max_data,
165 uint16_t *recv_flags2,
166 uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
167 uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
168 uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
170 uint32_t smb2cli_conn_server_capabilities(struct smbXcli_conn *conn);
171 uint16_t smb2cli_conn_server_security_mode(struct smbXcli_conn *conn);
172 uint32_t smb2cli_conn_max_trans_size(struct smbXcli_conn *conn);
173 uint32_t smb2cli_conn_max_read_size(struct smbXcli_conn *conn);
174 uint32_t smb2cli_conn_max_write_size(struct smbXcli_conn *conn);
175 void smb2cli_conn_set_max_credits(struct smbXcli_conn *conn,
176 uint16_t max_credits);
178 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
179 struct tevent_context *ev,
180 struct smbXcli_conn *conn,
181 uint16_t cmd,
182 uint32_t additional_flags,
183 uint32_t clear_flags,
184 uint32_t timeout_msec,
185 uint32_t pid,
186 uint32_t tid,
187 struct smbXcli_session *session,
188 const uint8_t *fixed,
189 uint16_t fixed_len,
190 const uint8_t *dyn,
191 uint32_t dyn_len);
192 void smb2cli_req_set_notify_async(struct tevent_req *req);
193 NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
194 int num_reqs);
195 void smb2cli_req_set_credit_charge(struct tevent_req *req, uint16_t charge);
197 struct smb2cli_req_expected_response {
198 NTSTATUS status;
199 uint16_t body_size;
202 struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
203 struct tevent_context *ev,
204 struct smbXcli_conn *conn,
205 uint16_t cmd,
206 uint32_t additional_flags,
207 uint32_t clear_flags,
208 uint32_t timeout_msec,
209 uint32_t pid,
210 uint32_t tid,
211 struct smbXcli_session *session,
212 const uint8_t *fixed,
213 uint16_t fixed_len,
214 const uint8_t *dyn,
215 uint32_t dyn_len);
216 NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
217 struct iovec **piov,
218 const struct smb2cli_req_expected_response *expected,
219 size_t num_expected);
221 struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
222 struct tevent_context *ev,
223 struct smbXcli_conn *conn,
224 uint32_t timeout_msec,
225 enum protocol_types min_protocol,
226 enum protocol_types max_protocol);
227 NTSTATUS smbXcli_negprot_recv(struct tevent_req *req);
228 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
229 uint32_t timeout_msec,
230 enum protocol_types min_protocol,
231 enum protocol_types max_protocol);
233 struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx,
234 struct smbXcli_conn *conn);
235 uint8_t smb2cli_session_security_mode(struct smbXcli_session *session);
236 uint64_t smb2cli_session_current_id(struct smbXcli_session *session);
237 void smb2cli_session_set_id_and_flags(struct smbXcli_session *session,
238 uint64_t session_id,
239 uint16_t session_flags);
240 NTSTATUS smb2cli_session_update_session_key(struct smbXcli_session *session,
241 const DATA_BLOB session_key,
242 const struct iovec *recv_iov);
243 NTSTATUS smb2cli_session_create_channel(TALLOC_CTX *mem_ctx,
244 struct smbXcli_session *session1,
245 struct smbXcli_conn *conn,
246 struct smbXcli_session **_session2);
248 #endif /* _SMBXCLI_BASE_H_ */