xref: /titanic_51/usr/src/uts/common/fs/smbsrv/smb_trans2_dfs.c (revision a90cf9f29973990687fa61de9f1f6ea22e924e40)
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 2013 Nexenta Systems, Inc.  All rights reserved.
26  */
27 
28 #include <smbsrv/smb_kproto.h>
29 #include <smbsrv/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 	/* Out param is the API-level return code. */
76 	doserr = smb_status2doserr(status);
77 	(void) smb_mbc_encodef(&xa->rep_param_mb, "w", doserr);
78 
79 #if 0	/* XXX - Is API-level return code enough? */
80 	if (status) {
81 		smbsr_error(sr, NT_STATUS_NO_SUCH_DEVICE, 0, 0);
82 		return (SDRC_ERROR);
83 	}
84 #endif
85 
86 	return (SDRC_SUCCESS);
87 }
88