libcli/smb/smbXcli: maintain smb2 channel_signing_key separate from the signing_key
[Samba.git] / libcli / smb / smbXcli_base.h
blobc919f88b1281adaa069983b6e461e99ec0fd6f56
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 struct tevent_req *smbXcli_conn_samba_suicide_send(TALLOC_CTX *mem_ctx,
55 struct tevent_context *ev,
56 struct smbXcli_conn *conn,
57 uint8_t exitcode);
58 NTSTATUS smbXcli_conn_samba_suicide_recv(struct tevent_req *req);
59 NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
60 uint8_t exitcode);
62 void smbXcli_req_unset_pending(struct tevent_req *req);
63 bool smbXcli_req_set_pending(struct tevent_req *req);
65 uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn);
66 uint32_t smb1cli_conn_max_xmit(struct smbXcli_conn *conn);
67 uint32_t smb1cli_conn_server_session_key(struct smbXcli_conn *conn);
68 const uint8_t *smb1cli_conn_server_challenge(struct smbXcli_conn *conn);
69 uint16_t smb1cli_conn_server_security_mode(struct smbXcli_conn *conn);
70 bool smb1cli_conn_server_readbraw(struct smbXcli_conn *conn);
71 bool smb1cli_conn_server_writebraw(struct smbXcli_conn *conn);
72 bool smb1cli_conn_server_lockread(struct smbXcli_conn *conn);
73 bool smb1cli_conn_server_writeunlock(struct smbXcli_conn *conn);
74 int smb1cli_conn_server_time_zone(struct smbXcli_conn *conn);
76 bool smb1cli_conn_activate_signing(struct smbXcli_conn *conn,
77 const DATA_BLOB user_session_key,
78 const DATA_BLOB response);
79 bool smb1cli_conn_check_signing(struct smbXcli_conn *conn,
80 const uint8_t *buf, uint32_t seqnum);
81 bool smb1cli_conn_signing_is_active(struct smbXcli_conn *conn);
83 void smb1cli_conn_set_encryption(struct smbXcli_conn *conn,
84 struct smb_trans_enc_state *es);
85 bool smb1cli_conn_encryption_on(struct smbXcli_conn *conn);
87 bool smb1cli_is_andx_req(uint8_t cmd);
88 size_t smb1cli_req_wct_ofs(struct tevent_req **reqs, int num_reqs);
90 uint16_t smb1cli_req_mid(struct tevent_req *req);
91 void smb1cli_req_set_mid(struct tevent_req *req, uint16_t mid);
93 uint32_t smb1cli_req_seqnum(struct tevent_req *req);
94 void smb1cli_req_set_seqnum(struct tevent_req *req, uint32_t seqnum);
96 struct smb1cli_req_expected_response {
97 NTSTATUS status;
98 uint8_t wct;
101 struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx,
102 struct tevent_context *ev,
103 struct smbXcli_conn *conn,
104 uint8_t smb_command,
105 uint8_t additional_flags,
106 uint8_t clear_flags,
107 uint16_t additional_flags2,
108 uint16_t clear_flags2,
109 uint32_t timeout_msec,
110 uint32_t pid,
111 uint16_t tid,
112 uint16_t uid,
113 uint8_t wct, uint16_t *vwv,
114 int iov_count,
115 struct iovec *bytes_iov);
116 NTSTATUS smb1cli_req_chain_submit(struct tevent_req **reqs, int num_reqs);
118 struct tevent_req *smb1cli_req_send(TALLOC_CTX *mem_ctx,
119 struct tevent_context *ev,
120 struct smbXcli_conn *conn,
121 uint8_t smb_command,
122 uint8_t additional_flags,
123 uint8_t clear_flags,
124 uint16_t additional_flags2,
125 uint16_t clear_flags2,
126 uint32_t timeout_msec,
127 uint32_t pid,
128 uint16_t tid,
129 uint16_t uid,
130 uint8_t wct, uint16_t *vwv,
131 uint32_t num_bytes,
132 const uint8_t *bytes);
133 NTSTATUS smb1cli_req_recv(struct tevent_req *req,
134 TALLOC_CTX *mem_ctx,
135 struct iovec **piov,
136 uint8_t **phdr,
137 uint8_t *pwct,
138 uint16_t **pvwv,
139 uint32_t *pvwv_offset,
140 uint32_t *pnum_bytes,
141 uint8_t **pbytes,
142 uint32_t *pbytes_offset,
143 uint8_t **pinbuf,
144 const struct smb1cli_req_expected_response *expected,
145 size_t num_expected);
147 struct tevent_req *smb1cli_trans_send(
148 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
149 struct smbXcli_conn *conn, uint8_t cmd,
150 uint8_t additional_flags, uint8_t clear_flags,
151 uint16_t additional_flags2, uint16_t clear_flags2,
152 uint32_t timeout_msec,
153 uint32_t pid, uint16_t tid, uint16_t uid,
154 const char *pipe_name, uint16_t fid, uint16_t function, int flags,
155 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
156 uint8_t *param, uint32_t num_param, uint32_t max_param,
157 uint8_t *data, uint32_t num_data, uint32_t max_data);
158 NTSTATUS smb1cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
159 uint16_t *recv_flags2,
160 uint16_t **setup, uint8_t min_setup,
161 uint8_t *num_setup,
162 uint8_t **param, uint32_t min_param,
163 uint32_t *num_param,
164 uint8_t **data, uint32_t min_data,
165 uint32_t *num_data);
166 NTSTATUS smb1cli_trans(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn,
167 uint8_t trans_cmd,
168 uint8_t additional_flags, uint8_t clear_flags,
169 uint16_t additional_flags2, uint16_t clear_flags2,
170 uint32_t timeout_msec,
171 uint32_t pid, uint16_t tid, uint16_t uid,
172 const char *pipe_name, uint16_t fid, uint16_t function,
173 int flags,
174 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
175 uint8_t *param, uint32_t num_param, uint32_t max_param,
176 uint8_t *data, uint32_t num_data, uint32_t max_data,
177 uint16_t *recv_flags2,
178 uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
179 uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
180 uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
182 uint32_t smb2cli_conn_server_capabilities(struct smbXcli_conn *conn);
183 uint16_t smb2cli_conn_server_security_mode(struct smbXcli_conn *conn);
184 uint32_t smb2cli_conn_max_trans_size(struct smbXcli_conn *conn);
185 uint32_t smb2cli_conn_max_read_size(struct smbXcli_conn *conn);
186 uint32_t smb2cli_conn_max_write_size(struct smbXcli_conn *conn);
187 void smb2cli_conn_set_max_credits(struct smbXcli_conn *conn,
188 uint16_t max_credits);
190 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
191 struct tevent_context *ev,
192 struct smbXcli_conn *conn,
193 uint16_t cmd,
194 uint32_t additional_flags,
195 uint32_t clear_flags,
196 uint32_t timeout_msec,
197 uint32_t pid,
198 uint32_t tid,
199 struct smbXcli_session *session,
200 const uint8_t *fixed,
201 uint16_t fixed_len,
202 const uint8_t *dyn,
203 uint32_t dyn_len);
204 void smb2cli_req_set_notify_async(struct tevent_req *req);
205 NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
206 int num_reqs);
207 void smb2cli_req_set_credit_charge(struct tevent_req *req, uint16_t charge);
209 struct smb2cli_req_expected_response {
210 NTSTATUS status;
211 uint16_t body_size;
214 struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
215 struct tevent_context *ev,
216 struct smbXcli_conn *conn,
217 uint16_t cmd,
218 uint32_t additional_flags,
219 uint32_t clear_flags,
220 uint32_t timeout_msec,
221 uint32_t pid,
222 uint32_t tid,
223 struct smbXcli_session *session,
224 const uint8_t *fixed,
225 uint16_t fixed_len,
226 const uint8_t *dyn,
227 uint32_t dyn_len);
228 NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
229 struct iovec **piov,
230 const struct smb2cli_req_expected_response *expected,
231 size_t num_expected);
233 struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
234 struct tevent_context *ev,
235 struct smbXcli_conn *conn,
236 uint32_t timeout_msec,
237 enum protocol_types min_protocol,
238 enum protocol_types max_protocol);
239 NTSTATUS smbXcli_negprot_recv(struct tevent_req *req);
240 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
241 uint32_t timeout_msec,
242 enum protocol_types min_protocol,
243 enum protocol_types max_protocol);
245 struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx,
246 struct smbXcli_conn *conn);
247 uint8_t smb2cli_session_security_mode(struct smbXcli_session *session);
248 uint64_t smb2cli_session_current_id(struct smbXcli_session *session);
249 void smb2cli_session_set_id_and_flags(struct smbXcli_session *session,
250 uint64_t session_id,
251 uint16_t session_flags);
252 NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
253 const DATA_BLOB session_key,
254 const struct iovec *recv_iov);
255 NTSTATUS smb2cli_session_create_channel(TALLOC_CTX *mem_ctx,
256 struct smbXcli_session *session1,
257 struct smbXcli_conn *conn,
258 struct smbXcli_session **_session2);
259 NTSTATUS smb2cli_session_set_channel_key(struct smbXcli_session *session,
260 const DATA_BLOB channel_key,
261 const struct iovec *recv_iov);
263 #endif /* _SMBXCLI_BASE_H_ */