xref: /illumos-gate/usr/src/uts/common/fs/smbsrv/smb_trans2_dfs.c (revision d8849d7dee03b84a3fa281ec65eb9e3d86d3756b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
26  */
27 
28 #include <smbsrv/smb_kproto.h>
29 #include <smb/winioctl.h>
30 
31 /*
32  * [MS-CIFS]
33  *
34  * 2.2.6.17    TRANS2_REPORT_DFS_INCONSISTENCY (0x0011)
35  *
36  *  This Transaction2 subcommand was introduced in the NT LAN Manager dialect.
37  *  This subcommand is reserved but not implemented.
38  *
39  *  Clients SHOULD NOT send requests using this command code. Servers receiving
40  *  requests with this command code SHOULD return STATUS_NOT_IMPLEMENTED
41  *  (ERRDOS/ERRbadfunc).
42  */
43 smb_sdrc_t /*ARGSUSED*/
44 smb_com_trans2_report_dfs_inconsistency(smb_request_t *sr)
45 {
46 	return (SDRC_NOT_IMPLEMENTED);
47 }
48 
49 /*
50  * See [MS-DFSC] for details about this command
51  */
52 smb_sdrc_t
53 smb_com_trans2_get_dfs_referral(smb_request_t *sr, smb_xa_t *xa)
54 {
55 	smb_fsctl_t fsctl;
56 	uint32_t status;
57 	uint16_t doserr;
58 
59 	/* This request is only valid over IPC connections */
60 	if (!STYPE_ISIPC(sr->tid_tree->t_res_type)) {
61 		smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRDOS,
62 		    ERROR_ACCESS_DENIED);
63 		return (SDRC_ERROR);
64 	}
65 
66 	fsctl.CtlCode = FSCTL_DFS_GET_REFERRALS;
67 	fsctl.InputCount = xa->smb_tpscnt;
68 	fsctl.OutputCount = 0;
69 	fsctl.MaxOutputResp = xa->smb_mdrcnt;
70 	fsctl.in_mbc = &xa->req_param_mb;
71 	fsctl.out_mbc = &xa->rep_data_mb;
72 
73 	status = smb_dfs_get_referrals(sr, &fsctl);
74 
75 	/*
76 	 * Out param is the API-level return code.
77 	 * Out data (rep_data_mb) is the referral.
78 	 */
79 	doserr = smb_status2doserr(status);
80 	(void) smb_mbc_encodef(&xa->rep_param_mb, "w", doserr);
81 	if (status != 0) {
82 		smbsr_error(sr, status, ERRDOS, doserr);
83 		return (SDRC_ERROR);
84 	}
85 
86 	return (SDRC_SUCCESS);
87 }
88