xref: /illumos-gate/usr/src/uts/common/fs/smbsrv/smb_trans2_dfs.c (revision 6e375c8351497b82ffa4f33cbf61d712999b4605)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <smbsrv/smb_incl.h>
29 
30 
31 /*
32  * trans2_get_dfs_referral
33  *
34  * The client sends this request to ask the server to convert
35  * RequestFilename into an alternate name for this file.  This request can
36  * be sent to the server if the server response to the NEGOTIATE SMB
37  * included the CAP_DFS capability.  The TID of the request must be IPC$.
38  * Bit15 of Flags2 in the SMB header must be set, indicating this is a
39  * UNICODE request.
40  *
41  * Client Request              Description
42  * ==========================  =========================================
43  * WordCount                   15
44  * TotalDataCount              0
45  * SetupCount                  1
46  * Setup[0]                    TRANS2_GET_DFS_REFERRAL
47  *
48  * Parameter Block Encoding    Description
49  * ==========================  =========================================
50  * USHORT MaxReferralLevel     Latest referral version number understood
51  * WCHAR RequestFileName;      DFS name of file for which referral is
52  *                             sought
53  *
54  * Response Data Block         Description
55  * ==========================  =========================================
56  * USHORT PathConsumed;        Number of RequestFilename bytes client
57  * USHORT NumberOfReferrals;   Number of referrals contained in this
58  *                             response
59  * USHORT Flags;               bit0 - The servers in Referrals are
60  *                             capable of fielding
61  *                             TRANS2_GET_DFS_REFERRAL.
62  *                             bit1 - The servers in Referrals should
63  *                             hold the storage for the requested file.
64  * REFERRAL_LIST Referrals[]   Set of referrals for this file
65  * UNICODESTRINGE Strings      Used to hold the strings pointed to by
66  *                             Version 2 Referrals in REFERRALS.
67  *
68  * The server response is a list of Referrals which inform the client where
69  * it should resubmit the request to obtain access to the file.
70  * PathConsumed in the response indicates to the client how many characters
71  * of  RequestFilename have been consumed by the server.  When the client
72  * chooses one of the referrals to use for file access, the client may need
73  * to strip the leading PathConsumed characters from the front of
74  * RequestFileName before submitting the name to the target server.
75  * Whether or not the pathname should be trimmed is indicated by the
76  * individual referral as detailed below.
77  *
78  * Flags indicates how this referral should be treated.  If bit0 is clear,
79  * any entity in the Referrals list holds the storage for RequestFileName.
80  * If bit0 is set, any entity in the Referrals list has further referral
81  * information for RequestFilename � a TRANS2_GET_DFS_REFERRAL request
82  * should be sent to an entity in the Referrals list for further
83  * resolution.
84  *
85  * The format of an individual referral contains version and  length
86  * information allowing the client to skip referrals it does not
87  * understand.  MaxReferralLevel indicates to the server the latest version
88  * of referral which the client can digest.  Since each referral has a
89  * uniform element, MaxReferralLevel is advisory only. Each element in
90  * Referrals has this envelope:
91  *
92  * REFERRAL_LIST element
93  * ======================================================================
94  *
95  * USHORT VersionNumber        Version of this referral element
96  *
97  * USHORT ReferralSize         Size of this referral element
98  *
99  * The following referral element versions are defined:
100  *
101  * Version 1 Referral Element Format
102  * ======================================================================
103  *
104  * USHORT ServerType           Type of Node handling referral:
105  *                             0 - Don't know
106  *                             1 - SMB Server
107  *                             2 - Netware Server
108  *                             3 - Domain
109  *
110  * USHORT ReferralFlags        Flags which describe this referral:
111  *                             01 - Strip off PathConsumed characters
112  *                             before submitting RequestFileName to Node
113  *
114  * UNICODESTRING Node          Name of entity to visit next
115  *
116  * Version 2 Referral Element Format
117  * ======================================================================
118  *
119  * USHORT ServerType              Type of Node handling referral:
120  *                                 0 - Don't know
121  *                                 1 - SMB Server
122  *                                 2 - Netware Server
123  *                                 3 - Domain
124  *
125  * USHORT ReferralFlags           Flags which describe this referral:
126  *                                 01 - Strip off PathConsumed characters
127  *                                 before submitting RequestFileName to
128  *                                 Node
129  *
130  * ULONG Proximity                A hint describing the proximity of this
131  *                                 server to the client. 0 indicates the
132  *                                 closest, higher numbers indicate
133  *                                 increasingly "distant" servers. The
134  *                                 number is only relevant within the
135  *                                 context of the servers listed in this
136  *                                 particular SMB.
137  *
138  * ULONG TimeToLive               Number of seconds for which the client
139  *                                 can cache this referral.
140  *
141  * USHORT DfsPathOffset           Offset, in bytes from the beginning of
142  *                                 this referral, of  the DFS Path that
143  *                                 matched PathConsumed bytes of the
144  *                                 RequestFileName.
145  *
146  * USHORT DfsAlternatePathOffset  Offset, in bytes from the beginning of
147  *                                 this referral, of an alternate name
148  *                                 (8.3 format) of the DFS Path that
149  *                                 matched PathConsumed bytes of the
150  *                                 RequestFileName.
151  *
152  * USHORT NetworkAddressOffset    Offset, in bytes from the beginning of
153  *                                 this referral, of the entity to visit
154  *                                 next.
155  *
156  * The CIFS protocol imposes no referral selection policy.
157  */
158 int /*ARGSUSED*/
159 smb_com_trans2_get_dfs_referral(struct smb_request *sr)
160 {
161 	return (SDRC_NOT_IMPLEMENTED);
162 }
163 
164 
165 /*
166  * SMB: trans2_report_dfs_inconsistency
167  *
168  * As part of the Distributed Name Resolution algorithm, a DFS client may
169  * discover a  knowledge inconsistency between the referral server (i.e.,
170  * the server that handed out a referral), and the storage server (i.e.,
171  * the server to which the client was redirected to by the referral
172  * server). When such an inconsistency is discovered, the DFS client
173  * optionally sends this SMB to the referral server, allowing the referral
174  * server to take corrective action.
175  *
176  * Client Request                     Description
177  * ================================== ==================================
178  * WordCount                          15
179  * MaxParameterCount                  0
180  * SetupCount                         1
181  * Setup[0]                           TRANS2_REPORT_DFS_INCONSISTENCY
182  *
183  * Parameter Block Encoding           Description
184  * ================================== ==================================
185  *
186  * UNICODESTRING RequestFileName;     DFS Name of file for which
187  *                                     referral was sought
188  *
189  * The data part of this request contains the referral element (Version 1
190  * format only) believed to be in error.  These are encoded as described in
191  * the TRANS2_GET_DFS_REFERRAL response.  If the server returns success,
192  * the client can resubmit the TRANS2_GET_DFS_REFERRAL request to this
193  * server to get a new referral.  It is not mandatory for the DFS knowledge
194  * to be automatically repaired � the client must be prepared to receive
195  * further errant referrals and must not wind up looping between this
196  * request and the TRANS2_GET_DFS_REFERRAL request.
197  *
198  * Bit15 of Flags2 in the SMB header must be set, indicating this is a
199  * UNICODE request.
200  */
201 int /*ARGSUSED*/
202 smb_com_trans2_report_dfs_inconsistency(struct smb_request *sr)
203 {
204 	return (SDRC_NOT_IMPLEMENTED);
205 }
206