krb5samba: Add compat code to initialize keyblock contents
[Samba/bjacke.git] / libcli / smb / smbXcli_base.h
blob91dc2448351800e94e860970ef021bf54cd4c4e6
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,
35 uint32_t smb2_capabilities);
37 bool smbXcli_conn_is_connected(struct smbXcli_conn *conn);
38 void smbXcli_conn_disconnect(struct smbXcli_conn *conn, NTSTATUS status);
40 bool smbXcli_conn_has_async_calls(struct smbXcli_conn *conn);
42 enum protocol_types smbXcli_conn_protocol(struct smbXcli_conn *conn);
43 bool smbXcli_conn_use_unicode(struct smbXcli_conn *conn);
45 void smbXcli_conn_set_sockopt(struct smbXcli_conn *conn, const char *options);
46 const struct sockaddr_storage *smbXcli_conn_local_sockaddr(struct smbXcli_conn *conn);
47 const struct sockaddr_storage *smbXcli_conn_remote_sockaddr(struct smbXcli_conn *conn);
48 const char *smbXcli_conn_remote_name(struct smbXcli_conn *conn);
50 uint16_t smbXcli_conn_max_requests(struct smbXcli_conn *conn);
51 NTTIME smbXcli_conn_server_system_time(struct smbXcli_conn *conn);
52 const DATA_BLOB *smbXcli_conn_server_gss_blob(struct smbXcli_conn *conn);
53 const struct GUID *smbXcli_conn_server_guid(struct smbXcli_conn *conn);
55 struct tevent_req *smbXcli_conn_samba_suicide_send(TALLOC_CTX *mem_ctx,
56 struct tevent_context *ev,
57 struct smbXcli_conn *conn,
58 uint8_t exitcode);
59 NTSTATUS smbXcli_conn_samba_suicide_recv(struct tevent_req *req);
60 NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
61 uint8_t exitcode);
63 void smbXcli_req_unset_pending(struct tevent_req *req);
64 bool smbXcli_req_set_pending(struct tevent_req *req);
66 uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn);
67 uint32_t smb1cli_conn_max_xmit(struct smbXcli_conn *conn);
68 uint32_t smb1cli_conn_server_session_key(struct smbXcli_conn *conn);
69 const uint8_t *smb1cli_conn_server_challenge(struct smbXcli_conn *conn);
70 uint16_t smb1cli_conn_server_security_mode(struct smbXcli_conn *conn);
71 bool smb1cli_conn_server_readbraw(struct smbXcli_conn *conn);
72 bool smb1cli_conn_server_writebraw(struct smbXcli_conn *conn);
73 bool smb1cli_conn_server_lockread(struct smbXcli_conn *conn);
74 bool smb1cli_conn_server_writeunlock(struct smbXcli_conn *conn);
75 int smb1cli_conn_server_time_zone(struct smbXcli_conn *conn);
77 bool smb1cli_conn_activate_signing(struct smbXcli_conn *conn,
78 const DATA_BLOB user_session_key,
79 const DATA_BLOB response);
80 bool smb1cli_conn_check_signing(struct smbXcli_conn *conn,
81 const uint8_t *buf, uint32_t seqnum);
82 bool smb1cli_conn_signing_is_active(struct smbXcli_conn *conn);
84 void smb1cli_conn_set_encryption(struct smbXcli_conn *conn,
85 struct smb_trans_enc_state *es);
86 bool smb1cli_conn_encryption_on(struct smbXcli_conn *conn);
88 bool smb1cli_is_andx_req(uint8_t cmd);
89 size_t smb1cli_req_wct_ofs(struct tevent_req **reqs, int num_reqs);
91 uint16_t smb1cli_req_mid(struct tevent_req *req);
92 void smb1cli_req_set_mid(struct tevent_req *req, uint16_t mid);
94 uint32_t smb1cli_req_seqnum(struct tevent_req *req);
95 void smb1cli_req_set_seqnum(struct tevent_req *req, uint32_t seqnum);
97 struct smb1cli_req_expected_response {
98 NTSTATUS status;
99 uint8_t wct;
102 struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx,
103 struct tevent_context *ev,
104 struct smbXcli_conn *conn,
105 uint8_t smb_command,
106 uint8_t additional_flags,
107 uint8_t clear_flags,
108 uint16_t additional_flags2,
109 uint16_t clear_flags2,
110 uint32_t timeout_msec,
111 uint32_t pid,
112 uint16_t tid,
113 uint16_t uid,
114 uint8_t wct, uint16_t *vwv,
115 int iov_count,
116 struct iovec *bytes_iov);
117 NTSTATUS smb1cli_req_chain_submit(struct tevent_req **reqs, int num_reqs);
119 struct tevent_req *smb1cli_req_send(TALLOC_CTX *mem_ctx,
120 struct tevent_context *ev,
121 struct smbXcli_conn *conn,
122 uint8_t smb_command,
123 uint8_t additional_flags,
124 uint8_t clear_flags,
125 uint16_t additional_flags2,
126 uint16_t clear_flags2,
127 uint32_t timeout_msec,
128 uint32_t pid,
129 uint16_t tid,
130 uint16_t uid,
131 uint8_t wct, uint16_t *vwv,
132 uint32_t num_bytes,
133 const uint8_t *bytes);
134 NTSTATUS smb1cli_req_recv(struct tevent_req *req,
135 TALLOC_CTX *mem_ctx,
136 struct iovec **piov,
137 uint8_t **phdr,
138 uint8_t *pwct,
139 uint16_t **pvwv,
140 uint32_t *pvwv_offset,
141 uint32_t *pnum_bytes,
142 uint8_t **pbytes,
143 uint32_t *pbytes_offset,
144 uint8_t **pinbuf,
145 const struct smb1cli_req_expected_response *expected,
146 size_t num_expected);
148 struct tevent_req *smb1cli_trans_send(
149 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
150 struct smbXcli_conn *conn, uint8_t cmd,
151 uint8_t additional_flags, uint8_t clear_flags,
152 uint16_t additional_flags2, uint16_t clear_flags2,
153 uint32_t timeout_msec,
154 uint32_t pid, uint16_t tid, uint16_t uid,
155 const char *pipe_name, uint16_t fid, uint16_t function, int flags,
156 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
157 uint8_t *param, uint32_t num_param, uint32_t max_param,
158 uint8_t *data, uint32_t num_data, uint32_t max_data);
159 NTSTATUS smb1cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
160 uint16_t *recv_flags2,
161 uint16_t **setup, uint8_t min_setup,
162 uint8_t *num_setup,
163 uint8_t **param, uint32_t min_param,
164 uint32_t *num_param,
165 uint8_t **data, uint32_t min_data,
166 uint32_t *num_data);
167 NTSTATUS smb1cli_trans(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn,
168 uint8_t trans_cmd,
169 uint8_t additional_flags, uint8_t clear_flags,
170 uint16_t additional_flags2, uint16_t clear_flags2,
171 uint32_t timeout_msec,
172 uint32_t pid, uint16_t tid, uint16_t uid,
173 const char *pipe_name, uint16_t fid, uint16_t function,
174 int flags,
175 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
176 uint8_t *param, uint32_t num_param, uint32_t max_param,
177 uint8_t *data, uint32_t num_data, uint32_t max_data,
178 uint16_t *recv_flags2,
179 uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
180 uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
181 uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
183 uint32_t smb2cli_conn_server_capabilities(struct smbXcli_conn *conn);
184 uint16_t smb2cli_conn_server_security_mode(struct smbXcli_conn *conn);
185 uint32_t smb2cli_conn_max_trans_size(struct smbXcli_conn *conn);
186 uint32_t smb2cli_conn_max_read_size(struct smbXcli_conn *conn);
187 uint32_t smb2cli_conn_max_write_size(struct smbXcli_conn *conn);
188 void smb2cli_conn_set_max_credits(struct smbXcli_conn *conn,
189 uint16_t max_credits);
191 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
192 struct tevent_context *ev,
193 struct smbXcli_conn *conn,
194 uint16_t cmd,
195 uint32_t additional_flags,
196 uint32_t clear_flags,
197 uint32_t timeout_msec,
198 uint32_t pid,
199 uint32_t tid,
200 struct smbXcli_session *session,
201 const uint8_t *fixed,
202 uint16_t fixed_len,
203 const uint8_t *dyn,
204 uint32_t dyn_len);
205 void smb2cli_req_set_notify_async(struct tevent_req *req);
206 NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
207 int num_reqs);
208 void smb2cli_req_set_credit_charge(struct tevent_req *req, uint16_t charge);
210 struct smb2cli_req_expected_response {
211 NTSTATUS status;
212 uint16_t body_size;
215 struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
216 struct tevent_context *ev,
217 struct smbXcli_conn *conn,
218 uint16_t cmd,
219 uint32_t additional_flags,
220 uint32_t clear_flags,
221 uint32_t timeout_msec,
222 uint32_t pid,
223 uint32_t tid,
224 struct smbXcli_session *session,
225 const uint8_t *fixed,
226 uint16_t fixed_len,
227 const uint8_t *dyn,
228 uint32_t dyn_len);
229 NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
230 struct iovec **piov,
231 const struct smb2cli_req_expected_response *expected,
232 size_t num_expected);
234 struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
235 struct tevent_context *ev,
236 struct smbXcli_conn *conn,
237 uint32_t timeout_msec,
238 enum protocol_types min_protocol,
239 enum protocol_types max_protocol);
240 NTSTATUS smbXcli_negprot_recv(struct tevent_req *req);
241 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
242 uint32_t timeout_msec,
243 enum protocol_types min_protocol,
244 enum protocol_types max_protocol);
246 struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx,
247 struct smbXcli_conn *conn);
248 uint8_t smb2cli_session_security_mode(struct smbXcli_session *session);
249 uint64_t smb2cli_session_current_id(struct smbXcli_session *session);
250 uint16_t smb2cli_session_get_flags(struct smbXcli_session *session);
251 NTSTATUS smb2cli_session_application_key(struct smbXcli_session *session,
252 TALLOC_CTX *mem_ctx,
253 DATA_BLOB *key);
254 void smb2cli_session_set_id_and_flags(struct smbXcli_session *session,
255 uint64_t session_id,
256 uint16_t session_flags);
257 NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
258 const DATA_BLOB session_key,
259 const struct iovec *recv_iov);
260 NTSTATUS smb2cli_session_create_channel(TALLOC_CTX *mem_ctx,
261 struct smbXcli_session *session1,
262 struct smbXcli_conn *conn,
263 struct smbXcli_session **_session2);
264 NTSTATUS smb2cli_session_set_channel_key(struct smbXcli_session *session,
265 const DATA_BLOB channel_key,
266 const struct iovec *recv_iov);
268 struct tevent_req *smb2cli_session_setup_send(TALLOC_CTX *mem_ctx,
269 struct tevent_context *ev,
270 struct smbXcli_conn *conn,
271 uint32_t timeout_msec,
272 struct smbXcli_session *session,
273 uint8_t in_flags,
274 uint32_t in_capabilities,
275 uint32_t in_channel,
276 uint64_t in_previous_session_id,
277 const DATA_BLOB *in_security_buffer);
278 NTSTATUS smb2cli_session_setup_recv(struct tevent_req *req,
279 TALLOC_CTX *mem_ctx,
280 struct iovec **recv_iov,
281 DATA_BLOB *out_security_buffer);
283 #endif /* _SMBXCLI_BASE_H_ */