2 Unix SMB/CIFS implementation.
5 Copyright (C) Stefan Metzmacher 2009
6 Copyright (C) David Disseldorp 2012
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.
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.
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/>.
23 #include "smbd/smbd.h"
24 #include "smbd/globals.h"
25 #include "../libcli/smb/smb_common.h"
26 #include "../libcli/security/security.h"
27 #include "../lib/util/tevent_ntstatus.h"
28 #include "include/ntioctl.h"
29 #include "../librpc/ndr/libndr.h"
30 #include "librpc/gen_ndr/ndr_ioctl.h"
31 #include "smb2_ioctl_private.h"
32 #include "../lib/tsocket/tsocket.h"
33 #include "lib/messages_ctdb.h"
34 #include "ctdbd_conn.h"
37 #define DBGC_CLASS DBGC_SMB2
39 static void copychunk_pack_limits(struct srv_copychunk_rsp
*cc_rsp
)
41 cc_rsp
->chunks_written
= COPYCHUNK_MAX_CHUNKS
;
42 cc_rsp
->chunk_bytes_written
= COPYCHUNK_MAX_CHUNK_LEN
;
43 cc_rsp
->total_bytes_written
= COPYCHUNK_MAX_TOTAL_LEN
;
46 static NTSTATUS
copychunk_check_limits(struct srv_copychunk_copy
*cc_copy
)
49 uint32_t total_len
= 0;
52 * [MS-SMB2] 3.3.5.15.6 Handling a Server-Side Data Copy Request
53 * Send and invalid parameter response if:
54 * - The ChunkCount value is greater than
55 * ServerSideCopyMaxNumberofChunks
57 if (cc_copy
->chunk_count
> COPYCHUNK_MAX_CHUNKS
) {
58 return NT_STATUS_INVALID_PARAMETER
;
61 for (i
= 0; i
< cc_copy
->chunk_count
; i
++) {
63 * - The Length value in a single chunk is greater than
64 * ServerSideCopyMaxChunkSize or equal to zero.
66 if ((cc_copy
->chunks
[i
].length
== 0)
67 || (cc_copy
->chunks
[i
].length
> COPYCHUNK_MAX_CHUNK_LEN
)) {
68 return NT_STATUS_INVALID_PARAMETER
;
70 total_len
+= cc_copy
->chunks
[i
].length
;
73 * - Sum of Lengths in all chunks is greater than
74 * ServerSideCopyMaxDataSize
76 if (total_len
> COPYCHUNK_MAX_TOTAL_LEN
) {
77 return NT_STATUS_INVALID_PARAMETER
;
83 struct fsctl_srv_copychunk_state
{
84 struct tevent_context
*ev
;
85 struct connection_struct
*conn
;
86 struct srv_copychunk_copy cc_copy
;
87 uint32_t current_chunk
;
92 struct files_struct
*src_fsp
;
93 struct files_struct
*dst_fsp
;
95 COPYCHUNK_OUT_EMPTY
= 0,
100 static void fsctl_srv_copychunk_vfs_done(struct tevent_req
*subreq
);
102 static NTSTATUS
fsctl_srv_copychunk_loop(struct tevent_req
*req
);
104 static struct tevent_req
*fsctl_srv_copychunk_send(TALLOC_CTX
*mem_ctx
,
105 struct tevent_context
*ev
,
107 struct files_struct
*dst_fsp
,
109 size_t in_max_output
,
110 struct smbd_smb2_request
*smb2req
)
112 struct tevent_req
*req
= NULL
;
113 struct fsctl_srv_copychunk_state
*state
= NULL
;
114 enum ndr_err_code ndr_ret
;
117 /* handler for both copy-chunk variants */
118 SMB_ASSERT((ctl_code
== FSCTL_SRV_COPYCHUNK
)
119 || (ctl_code
== FSCTL_SRV_COPYCHUNK_WRITE
));
121 req
= tevent_req_create(mem_ctx
, &state
,
122 struct fsctl_srv_copychunk_state
);
126 *state
= (struct fsctl_srv_copychunk_state
) {
127 .conn
= dst_fsp
->conn
,
129 .ctl_code
= ctl_code
,
133 if (in_max_output
< sizeof(struct srv_copychunk_rsp
)) {
134 DEBUG(3, ("max output %d not large enough to hold copy chunk "
135 "response %lu\n", (int)in_max_output
,
136 (unsigned long)sizeof(struct srv_copychunk_rsp
)));
137 state
->status
= NT_STATUS_INVALID_PARAMETER
;
138 tevent_req_nterror(req
, state
->status
);
139 return tevent_req_post(req
, ev
);
142 ndr_ret
= ndr_pull_struct_blob(in_input
, mem_ctx
, &state
->cc_copy
,
143 (ndr_pull_flags_fn_t
)ndr_pull_srv_copychunk_copy
);
144 if (ndr_ret
!= NDR_ERR_SUCCESS
) {
145 DEBUG(0, ("failed to unmarshall copy chunk req\n"));
146 state
->status
= NT_STATUS_INVALID_PARAMETER
;
147 tevent_req_nterror(req
, state
->status
);
148 return tevent_req_post(req
, ev
);
151 state
->token
= data_blob_const(state
->cc_copy
.source_key
,
152 sizeof(state
->cc_copy
.source_key
));
154 state
->status
= copychunk_check_limits(&state
->cc_copy
);
155 if (!NT_STATUS_IS_OK(state
->status
)) {
156 DEBUG(3, ("copy chunk req exceeds limits\n"));
157 state
->out_data
= COPYCHUNK_OUT_LIMITS
;
158 tevent_req_nterror(req
, state
->status
);
159 return tevent_req_post(req
, ev
);
162 /* any errors from here onwards should carry copychunk response data */
163 state
->out_data
= COPYCHUNK_OUT_RSP
;
165 status
= fsctl_srv_copychunk_loop(req
);
166 if (tevent_req_nterror(req
, status
)) {
167 return tevent_req_post(req
, ev
);
173 static NTSTATUS
fsctl_srv_copychunk_loop(struct tevent_req
*req
)
175 struct fsctl_srv_copychunk_state
*state
= tevent_req_data(
176 req
, struct fsctl_srv_copychunk_state
);
177 struct tevent_req
*subreq
= NULL
;
179 off_t source_off
= 0;
180 off_t target_off
= 0;
183 * chunk_count can be 0 which must either just do nothing returning
184 * success saying number of copied chunks is 0 (verified against
187 * Or it can be a special macOS copyfile request, so we send this into
188 * the VFS, vfs_fruit if loaded implements the macOS copyfile semantics.
190 if (state
->cc_copy
.chunk_count
> 0) {
191 struct srv_copychunk
*chunk
= NULL
;
193 chunk
= &state
->cc_copy
.chunks
[state
->current_chunk
];
194 length
= chunk
->length
;
195 source_off
= chunk
->source_off
;
196 target_off
= chunk
->target_off
;
199 subreq
= SMB_VFS_OFFLOAD_WRITE_SEND(state
->dst_fsp
->conn
,
208 if (tevent_req_nomem(subreq
, req
)) {
209 return NT_STATUS_NO_MEMORY
;
211 tevent_req_set_callback(subreq
, fsctl_srv_copychunk_vfs_done
, req
);
216 static void fsctl_srv_copychunk_vfs_done(struct tevent_req
*subreq
)
218 struct tevent_req
*req
= tevent_req_callback_data(
219 subreq
, struct tevent_req
);
220 struct fsctl_srv_copychunk_state
*state
= tevent_req_data(
221 req
, struct fsctl_srv_copychunk_state
);
222 off_t chunk_nwritten
;
225 status
= SMB_VFS_OFFLOAD_WRITE_RECV(state
->conn
, subreq
,
228 if (!NT_STATUS_IS_OK(status
)) {
229 DBG_ERR("copy chunk failed [%s] chunk [%u] of [%u]\n",
231 (unsigned int)state
->current_chunk
,
232 (unsigned int)state
->cc_copy
.chunk_count
);
233 tevent_req_nterror(req
, status
);
237 DBG_DEBUG("good copy chunk [%u] of [%u]\n",
238 (unsigned int)state
->current_chunk
,
239 (unsigned int)state
->cc_copy
.chunk_count
);
240 state
->total_written
+= chunk_nwritten
;
242 if (state
->cc_copy
.chunk_count
== 0) {
244 * This must not produce an error but just return a chunk count
245 * of 0 in the response.
247 tevent_req_done(req
);
251 state
->current_chunk
++;
252 if (state
->current_chunk
== state
->cc_copy
.chunk_count
) {
253 tevent_req_done(req
);
257 status
= fsctl_srv_copychunk_loop(req
);
258 if (tevent_req_nterror(req
, status
)) {
263 static NTSTATUS
fsctl_srv_copychunk_recv(struct tevent_req
*req
,
264 struct srv_copychunk_rsp
*cc_rsp
,
267 struct fsctl_srv_copychunk_state
*state
= tevent_req_data(req
,
268 struct fsctl_srv_copychunk_state
);
271 switch (state
->out_data
) {
272 case COPYCHUNK_OUT_EMPTY
:
275 case COPYCHUNK_OUT_LIMITS
:
276 /* 2.2.32.1 - send back our maximum transfer size limits */
277 copychunk_pack_limits(cc_rsp
);
280 case COPYCHUNK_OUT_RSP
:
281 cc_rsp
->chunks_written
= state
->current_chunk
;
282 cc_rsp
->chunk_bytes_written
= 0;
283 cc_rsp
->total_bytes_written
= state
->total_written
;
286 default: /* not reached */
290 status
= tevent_req_simple_recv_ntstatus(req
);
294 struct cluster_movable_ips
{
296 uint32_t array_index
;
297 struct sockaddr_storage
*ips
;
300 static int stash_cluster_movable_ips(uint32_t total_ip_count
,
301 const struct sockaddr_storage
*ip
,
305 struct cluster_movable_ips
*cluster_movable_ips
306 = talloc_get_type_abort(private_data
,
307 struct cluster_movable_ips
);
309 if (!is_movable_ip
) {
313 if (cluster_movable_ips
->array_len
== 0) {
314 SMB_ASSERT(total_ip_count
< INT_MAX
);
315 cluster_movable_ips
->ips
316 = talloc_zero_array(cluster_movable_ips
,
317 struct sockaddr_storage
,
319 if (cluster_movable_ips
->ips
== NULL
) {
322 cluster_movable_ips
->array_len
= total_ip_count
;
325 SMB_ASSERT(cluster_movable_ips
->array_index
326 < cluster_movable_ips
->array_len
);
328 cluster_movable_ips
->ips
[cluster_movable_ips
->array_index
] = *ip
;
329 cluster_movable_ips
->array_index
++;
334 static bool find_in_cluster_movable_ips(
335 struct cluster_movable_ips
*cluster_movable_ips
,
336 const struct sockaddr_storage
*ifss
)
338 struct samba_sockaddr srv_ip
= {
345 for (i
= 0; i
< cluster_movable_ips
->array_index
; i
++) {
346 struct samba_sockaddr pub_ip
= {
348 .ss
= cluster_movable_ips
->ips
[i
],
351 if (sockaddr_equal(&pub_ip
.u
.sa
, &srv_ip
.u
.sa
)) {
358 static NTSTATUS
fsctl_network_iface_info(TALLOC_CTX
*mem_ctx
,
359 struct tevent_context
*ev
,
360 struct smbXsrv_connection
*xconn
,
362 uint32_t in_max_output
,
363 DATA_BLOB
*out_output
)
365 struct samba_sockaddr xconn_srv_addr
= { .sa_socklen
= 0, };
366 struct fsctl_net_iface_info
*array
= NULL
;
367 struct fsctl_net_iface_info
*first
= NULL
;
368 struct fsctl_net_iface_info
*last
= NULL
;
371 enum ndr_err_code ndr_err
;
372 struct cluster_movable_ips
*cluster_movable_ips
= NULL
;
376 if (in_input
->length
!= 0) {
377 return NT_STATUS_INVALID_PARAMETER
;
381 * The list of probed interfaces might have changed, we might need to
382 * refresh local_interfaces to get up-to-date network information, and
383 * respond to clients which sent FSCTL_QUERY_NETWORK_INTERFACE_INFO.
384 * For example, network speed is changed, interfaces count is changed
385 * (some link down or link up), and etc.
388 num_ifaces
= iface_count();
390 *out_output
= data_blob_null
;
392 array
= talloc_zero_array(mem_ctx
,
393 struct fsctl_net_iface_info
,
396 return NT_STATUS_NO_MEMORY
;
399 if (lp_clustering()) {
400 cluster_movable_ips
= talloc_zero(array
,
401 struct cluster_movable_ips
);
402 if (cluster_movable_ips
== NULL
) {
404 return NT_STATUS_NO_MEMORY
;
406 ret
= ctdbd_public_ip_foreach(messaging_ctdb_connection(),
407 stash_cluster_movable_ips
,
408 cluster_movable_ips
);
411 return NT_STATUS_INTERNAL_ERROR
;
415 sret
= tsocket_address_bsd_sockaddr(xconn
->local_address
,
416 &xconn_srv_addr
.u
.sa
,
417 sizeof(xconn_srv_addr
.u
.ss
));
419 return NT_STATUS_INTERNAL_ERROR
;
421 xconn_srv_addr
.sa_socklen
= sret
;
423 for (i
=0; i
< num_ifaces
; i
++) {
424 struct fsctl_net_iface_info
*cur
= &array
[i
];
425 const struct interface
*iface
= get_interface(i
);
426 const struct sockaddr_storage
*ifss
= &iface
->ip
;
427 const void *ifptr
= ifss
;
428 const struct sockaddr
*ifsa
= (const struct sockaddr
*)ifptr
;
429 struct tsocket_address
*a
= NULL
;
433 ret
= tsocket_address_bsd_from_sockaddr(array
,
434 ifsa
, sizeof(struct sockaddr_storage
),
437 NTSTATUS status
= map_nt_error_from_unix_common(errno
);
442 ok
= tsocket_address_is_inet(a
, "ip");
447 addr
= tsocket_address_inet_addr_string(a
, array
);
450 return NT_STATUS_NO_MEMORY
;
453 if (sockaddr_equal(ifsa
, &xconn_srv_addr
.u
.sa
)) {
455 * We can announce the ip of the current connection even
456 * if it is a moveable cluster address... as the client
457 * is already connected to it.
459 * It means in a typical ctdb cluster, where we
460 * only have public addresses, the client can at least
461 * have more than one multichannel'ed connection to the
464 } else if (cluster_movable_ips
!= NULL
) {
465 bool is_movable_ip
= find_in_cluster_movable_ips(
469 DBG_DEBUG("Interface [%s] - "
470 "has movable public ip - "
471 "skipping address [%s].\n",
477 cur
->ifindex
= iface
->if_index
;
478 if (cur
->ifindex
== 0) {
480 * Did not get interface index from kernel,
481 * nor from the config. ==> Apply a common
482 * default value for these cases.
484 cur
->ifindex
= UINT32_MAX
;
486 cur
->capability
= iface
->capability
;
487 cur
->linkspeed
= iface
->linkspeed
;
488 if (cur
->linkspeed
== 0) {
489 DBG_DEBUG("Link speed 0 on interface [%s] - skipping "
490 "address [%s].\n", iface
->name
, addr
);
494 ok
= tsocket_address_is_inet(a
, "ipv4");
496 cur
->sockaddr
.family
= FSCTL_NET_IFACE_AF_INET
;
497 cur
->sockaddr
.saddr
.saddr_in
.ipv4
= addr
;
499 ok
= tsocket_address_is_inet(a
, "ipv6");
501 cur
->sockaddr
.family
= FSCTL_NET_IFACE_AF_INET6
;
502 cur
->sockaddr
.saddr
.saddr_in6
.ipv6
= addr
;
519 if (DEBUGLEVEL
>= 10) {
520 NDR_PRINT_DEBUG(fsctl_net_iface_info
, first
);
523 ndr_err
= ndr_push_struct_blob(out_output
, mem_ctx
, first
,
524 (ndr_push_flags_fn_t
)ndr_push_fsctl_net_iface_info
);
526 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
527 return ndr_map_error2ntstatus(ndr_err
);
533 static NTSTATUS
fsctl_validate_neg_info(TALLOC_CTX
*mem_ctx
,
534 struct tevent_context
*ev
,
535 struct smbXsrv_connection
*conn
,
537 uint32_t in_max_output
,
538 DATA_BLOB
*out_output
,
541 uint32_t in_capabilities
;
542 DATA_BLOB in_guid_blob
;
544 uint16_t in_security_mode
;
545 uint16_t in_num_dialects
;
547 struct GUID_ndr_buf out_guid_buf
= { .buf
= {0}, };
549 enum protocol_types protocol
= PROTOCOL_NONE
;
551 if (lp_server_max_protocol() <= PROTOCOL_SMB2_02
) {
553 * With SMB 2.02 we didn't get the
554 * capabilities, client guid, security mode
555 * and dialects the client would have offered.
557 * So we behave compatible with a true
558 * SMB 2.02 server and return NT_STATUS_FILE_CLOSED.
560 * As SMB >= 2.10 offers the two phase SMB2 Negotiate
561 * we keep supporting FSCTL_VALIDATE_NEGOTIATE_INFO
562 * starting with SMB 2.10, while Windows only supports
563 * it starting with SMB > 2.10.
565 return NT_STATUS_FILE_CLOSED
;
568 if (in_input
->length
< 0x18) {
569 return NT_STATUS_INVALID_PARAMETER
;
572 in_capabilities
= IVAL(in_input
->data
, 0x00);
573 in_guid_blob
= data_blob_const(in_input
->data
+ 0x04, 16);
574 in_security_mode
= SVAL(in_input
->data
, 0x14);
575 in_num_dialects
= SVAL(in_input
->data
, 0x16);
577 if (in_input
->length
< (0x18 + in_num_dialects
*2)) {
578 return NT_STATUS_INVALID_PARAMETER
;
581 if (in_max_output
< 0x18) {
582 return NT_STATUS_BUFFER_TOO_SMALL
;
585 status
= GUID_from_ndr_blob(&in_guid_blob
, &in_guid
);
586 if (!NT_STATUS_IS_OK(status
)) {
592 * 3.3.5.15.12 Handling a Validate Negotiate Info Request
594 * The server MUST determine the greatest common dialect
595 * between the dialects it implements and the Dialects array
596 * of the VALIDATE_NEGOTIATE_INFO request. If no dialect is
597 * matched, or if the value is not equal to Connection.Dialect,
598 * the server MUST terminate the transport connection
599 * and free the Connection object.
601 protocol
= smbd_smb2_protocol_dialect_match(in_input
->data
+ 0x18,
604 if (conn
->protocol
!= protocol
) {
606 return NT_STATUS_ACCESS_DENIED
;
609 if (!GUID_equal(&in_guid
, &conn
->smb2
.client
.guid
)) {
611 return NT_STATUS_ACCESS_DENIED
;
614 if (in_security_mode
!= conn
->smb2
.client
.security_mode
) {
616 return NT_STATUS_ACCESS_DENIED
;
619 if (in_capabilities
!= conn
->smb2
.client
.capabilities
) {
621 return NT_STATUS_ACCESS_DENIED
;
624 GUID_to_ndr_buf(&conn
->smb2
.server
.guid
, &out_guid_buf
);
626 *out_output
= data_blob_talloc(mem_ctx
, NULL
, 0x18);
627 if (out_output
->data
== NULL
) {
628 return NT_STATUS_NO_MEMORY
;
631 SIVAL(out_output
->data
, 0x00, conn
->smb2
.server
.capabilities
);
632 memcpy(out_output
->data
+0x04, out_guid_buf
.buf
, 16);
633 SSVAL(out_output
->data
, 0x14, conn
->smb2
.server
.security_mode
);
634 SSVAL(out_output
->data
, 0x16, conn
->smb2
.server
.dialect
);
639 static void smb2_ioctl_network_fs_copychunk_done(struct tevent_req
*subreq
);
640 static void smb2_ioctl_network_fs_offload_read_done(struct tevent_req
*subreq
);
642 struct tevent_req
*smb2_ioctl_network_fs(uint32_t ctl_code
,
643 struct tevent_context
*ev
,
644 struct tevent_req
*req
,
645 struct smbd_smb2_ioctl_state
*state
)
647 struct tevent_req
*subreq
;
653 * FSCTL_SRV_COPYCHUNK is issued when a handle has
654 * FILE_READ_DATA and FILE_WRITE_DATA access to the file;
655 * FSCTL_SRV_COPYCHUNK_WRITE is issued when a handle only has
656 * FILE_WRITE_DATA access.
658 case FSCTL_SRV_COPYCHUNK_WRITE
: /* FALL THROUGH */
659 case FSCTL_SRV_COPYCHUNK
:
660 subreq
= fsctl_srv_copychunk_send(state
, ev
,
664 state
->in_max_output
,
666 if (tevent_req_nomem(subreq
, req
)) {
667 return tevent_req_post(req
, ev
);
669 tevent_req_set_callback(subreq
,
670 smb2_ioctl_network_fs_copychunk_done
,
674 case FSCTL_QUERY_NETWORK_INTERFACE_INFO
:
675 if (!state
->smbreq
->xconn
->client
->server_multi_channel_enabled
)
677 if (IS_IPC(state
->smbreq
->conn
)) {
678 status
= NT_STATUS_FS_DRIVER_REQUIRED
;
680 status
= NT_STATUS_INVALID_DEVICE_REQUEST
;
683 tevent_req_nterror(req
, status
);
684 return tevent_req_post(req
, ev
);
687 status
= fsctl_network_iface_info(state
, ev
,
688 state
->smbreq
->xconn
,
690 state
->in_max_output
,
692 if (!tevent_req_nterror(req
, status
)) {
693 tevent_req_done(req
);
695 return tevent_req_post(req
, ev
);
697 case FSCTL_VALIDATE_NEGOTIATE_INFO
:
698 status
= fsctl_validate_neg_info(state
, ev
,
699 state
->smbreq
->xconn
,
701 state
->in_max_output
,
704 if (!tevent_req_nterror(req
, status
)) {
705 tevent_req_done(req
);
707 return tevent_req_post(req
, ev
);
709 case FSCTL_SRV_REQUEST_RESUME_KEY
:
710 subreq
= SMB_VFS_OFFLOAD_READ_SEND(state
,
713 FSCTL_SRV_REQUEST_RESUME_KEY
,
715 if (tevent_req_nomem(subreq
, req
)) {
716 return tevent_req_post(req
, ev
);
718 tevent_req_set_callback(
719 subreq
, smb2_ioctl_network_fs_offload_read_done
, req
);
723 uint8_t *out_data
= NULL
;
724 uint32_t out_data_len
= 0;
726 if (state
->fsp
== NULL
) {
727 status
= NT_STATUS_NOT_SUPPORTED
;
729 status
= SMB_VFS_FSCTL(state
->fsp
,
732 state
->smbreq
->flags2
,
733 state
->in_input
.data
,
734 state
->in_input
.length
,
736 state
->in_max_output
,
738 state
->out_output
= data_blob_const(out_data
, out_data_len
);
739 if (NT_STATUS_IS_OK(status
)) {
740 tevent_req_done(req
);
741 return tevent_req_post(req
, ev
);
745 if (NT_STATUS_EQUAL(status
, NT_STATUS_NOT_SUPPORTED
)) {
746 if (IS_IPC(state
->smbreq
->conn
)) {
747 status
= NT_STATUS_FS_DRIVER_REQUIRED
;
749 status
= NT_STATUS_INVALID_DEVICE_REQUEST
;
753 tevent_req_nterror(req
, status
);
754 return tevent_req_post(req
, ev
);
759 tevent_req_nterror(req
, NT_STATUS_INTERNAL_ERROR
);
760 return tevent_req_post(req
, ev
);
763 static void smb2_ioctl_network_fs_copychunk_done(struct tevent_req
*subreq
)
765 struct tevent_req
*req
= tevent_req_callback_data(subreq
,
767 struct smbd_smb2_ioctl_state
*ioctl_state
= tevent_req_data(req
,
768 struct smbd_smb2_ioctl_state
);
769 struct srv_copychunk_rsp cc_rsp
;
771 bool pack_rsp
= false;
774 status
= fsctl_srv_copychunk_recv(subreq
, &cc_rsp
, &pack_rsp
);
776 if (pack_rsp
== true) {
777 enum ndr_err_code ndr_ret
;
778 ndr_ret
= ndr_push_struct_blob(&ioctl_state
->out_output
,
781 (ndr_push_flags_fn_t
)ndr_push_srv_copychunk_rsp
);
782 if (ndr_ret
!= NDR_ERR_SUCCESS
) {
783 status
= NT_STATUS_INTERNAL_ERROR
;
787 if (!tevent_req_nterror(req
, status
)) {
788 tevent_req_done(req
);
792 static void smb2_ioctl_network_fs_offload_read_done(struct tevent_req
*subreq
)
794 struct tevent_req
*req
= tevent_req_callback_data(
795 subreq
, struct tevent_req
);
796 struct smbd_smb2_ioctl_state
*state
= tevent_req_data(
797 req
, struct smbd_smb2_ioctl_state
);
798 struct req_resume_key_rsp rkey_rsp
;
799 enum ndr_err_code ndr_ret
;
806 * Note that both flags and xferlen are not used with copy-chunk.
808 status
= SMB_VFS_OFFLOAD_READ_RECV(subreq
,
815 if (tevent_req_nterror(req
, status
)) {
819 if (token
.length
!= sizeof(rkey_rsp
.resume_key
)) {
820 tevent_req_nterror(req
, NT_STATUS_INTERNAL_ERROR
);
824 ZERO_STRUCT(rkey_rsp
);
825 memcpy(rkey_rsp
.resume_key
, token
.data
, token
.length
);
827 ndr_ret
= ndr_push_struct_blob(&state
->out_output
, state
, &rkey_rsp
,
828 (ndr_push_flags_fn_t
)ndr_push_req_resume_key_rsp
);
829 if (ndr_ret
!= NDR_ERR_SUCCESS
) {
830 tevent_req_nterror(req
, NT_STATUS_INTERNAL_ERROR
);
834 tevent_req_done(req
);