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.
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.
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]
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
26 #ifndef _SMBSRV_SMB_XDR_H
27 #define _SMBSRV_SMB_XDR_H
34 #include <sys/param.h>
37 #include <smbsrv/wintypes.h>
38 #include <smbsrv/smb_sid.h>
39 #include <smbsrv/smbinfo.h>
40 #include <smbsrv/smb_ioctl.h>
41 #include <smbsrv/smb_sid.h>
42 #include <smbsrv/smb_share.h>
43 #include <smbsrv/smb_dfs.h>
44 #include <smbsrv/wintypes.h>
46 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
47 #include <sys/sysmacros.h>
48 #define xdr_int8_t xdr_char
49 #define xdr_uint8_t xdr_u_char
50 #define xdr_int16_t xdr_short
51 #define xdr_uint16_t xdr_u_short
53 #include <stddef.h> /* offsetof */
57 * null-terminated string
58 * See also: smb_string_xdr()
60 typedef struct smb_string
{
67 * Initial message on server named pipes.
68 * Followed by smb_netuserinfo
70 typedef struct smb_pipehdr
{
75 #define SMB_PIPE_HDR_MAGIC 0x50495045 /* PIPE */
78 * Maximum message size for SMB named pipes.
79 * Should be less than PIPE_BUF (5120).
80 * Use the same value Windows does.
82 #define SMB_PIPE_MAX_MSGSIZE 4280
85 * Door up-call stuff shared with smbd
88 #define SMB_DOOR_HDR_MAGIC 0x444F4F52 /* DOOR */
93 #define SMB_DF_ASYNC 0x00000001 /* Asynchronous call */
94 #define SMB_DF_SYSSPACE 0x00000002 /* Called from the kernel */
95 #define SMB_DF_USERSPACE 0x00000004 /* Called from user space */
96 #define SMB_DF_FAKE_KERNEL 0x00000008 /* Called from fake kernel */
99 * Header for door calls. The op codes and return codes are defined
100 * in smb_door.h. The header is here to make it available to XDR.
102 * fid For opipe: the pipe identifier.
103 * op The door operation being invoked.
104 * txid Unique transaction id for the current door call.
105 * datalen Bytes of data following the header (excludes the header).
106 * resid For opipe: the number of bytes remaining in the server.
107 * door_rc Return code provided by the door server.
108 * status A pass-through status provided by the door operation.
110 * See also: smb_doorhdr_xdr()
112 typedef struct smb_doorhdr
{
125 * Information about the client of a named pipe, provided by smbsrv
126 * to the server side of the named pipe (the RPC service).
127 * See also: smb_netuserinfo_xdr()
129 typedef struct smb_netuserinfo
{
130 uint64_t ui_session_id
;
132 uint16_t ui_domain_len
;
134 uint16_t ui_account_len
;
137 uint16_t ui_workstation_len
;
138 char *ui_workstation
;
139 smb_inaddr_t ui_ipaddr
;
140 int32_t ui_native_os
;
141 int64_t ui_logon_time
;
142 uint32_t ui_numopens
;
146 typedef struct smb_opennum
{
151 char qualifier
[MAXNAMELEN
];
155 * SMB (internal) representation of a tree connection (etc.)
156 * See also: smb_netconnectinfo_xdr()
158 typedef struct smb_netconnectinfo
{
161 uint32_t ci_numopens
;
162 uint32_t ci_numusers
;
165 uint32_t ci_sharelen
;
168 } smb_netconnectinfo_t
;
171 * SMB (internal) representation of an open file.
172 * See also: smb_netfileinfo_xdr()
174 typedef struct smb_netfileinfo
{
177 uint32_t fi_permissions
;
178 uint32_t fi_numlocks
;
185 typedef struct smb_netsvcitem
{
188 smb_netuserinfo_t nsi_user
;
189 smb_netconnectinfo_t nsi_tree
;
190 smb_netfileinfo_t nsi_ofile
;
194 typedef struct smb_netsvc
{
196 smb_netsvcitem_t
*ns_items
;
197 smb_ioc_svcenum_t
*ns_ioc
;
202 bool_t
smb_buf32_xdr(XDR
*, struct smb_buf32
*);
203 bool_t
smb_string_xdr(XDR
*, smb_string_t
*);
204 bool_t
smb_inaddr_xdr(XDR
*, smb_inaddr_t
*);
206 const char *smb_doorhdr_opname(uint32_t);
207 int smb_doorhdr_encode(smb_doorhdr_t
*, uint8_t *, uint32_t);
208 int smb_doorhdr_decode(smb_doorhdr_t
*, uint8_t *, uint32_t);
209 bool_t
smb_doorhdr_xdr(XDR
*xdrs
, smb_doorhdr_t
*objp
);
210 int smb_netuserinfo_encode(smb_netuserinfo_t
*, uint8_t *, uint32_t, uint_t
*);
211 int smb_netuserinfo_decode(smb_netuserinfo_t
*, uint8_t *, uint32_t, uint_t
*);
212 bool_t
smb_netuserinfo_xdr(XDR
*, smb_netuserinfo_t
*);
213 int smb_netconnectinfo_encode(smb_netconnectinfo_t
*, uint8_t *, uint32_t,
215 int smb_netconnectinfo_decode(smb_netconnectinfo_t
*, uint8_t *, uint32_t,
217 bool_t
smb_netconnectinfo_xdr(XDR
*, smb_netconnectinfo_t
*);
218 int smb_netfileinfo_encode(smb_netfileinfo_t
*, uint8_t *, uint32_t, uint_t
*);
219 int smb_netfileinfo_decode(smb_netfileinfo_t
*, uint8_t *, uint32_t, uint_t
*);
220 bool_t
smb_netfileinfo_xdr(XDR
*, smb_netfileinfo_t
*);
222 typedef uint16_t sid_type_t
;
224 typedef struct lsa_account
{
226 sid_type_t a_sidtype
;
227 char a_domain
[MAXNAMELEN
];
228 char a_name
[MAXNAMELEN
];
229 char a_sid
[SMB_SID_STRSZ
];
232 int lsa_account_encode(lsa_account_t
*, uint8_t *, uint32_t);
233 int lsa_account_decode(lsa_account_t
*, uint8_t *, uint32_t);
234 bool_t
lsa_account_xdr(XDR
*, lsa_account_t
*);
237 * VSS Door Structures
239 #define SMB_VSS_GMT_SIZE sizeof ("@GMT-yyyy.mm.dd-hh.mm.ss")
242 * Args for enumerating "previous versions".
243 * See also: smb_gmttoken_query_xdr()
245 typedef struct smb_gmttoken_query
{
248 } smb_gmttoken_query_t
;
251 * Part of response for enumerating "previous versions".
252 * See also: smb_gmttoken_xdr()
254 typedef char *smb_gmttoken_t
;
257 * Response for enumerating "previous versions".
258 * See also: smb_gmttoken_response_xdr()
260 typedef struct smb_gmttoken_response
{
263 uint_t gtr_gmttokens_len
;
264 smb_gmttoken_t
*gtr_gmttokens_val
;
266 } smb_gmttoken_response_t
;
269 * Args to lookup "previous versions" during open.
270 * See also: smb_gmttoken_snapname_xdr()
272 typedef struct smb_gmttoken_snapname
{
275 uint64_t gts_toktime
; /* seconds */
276 } smb_gmttoken_snapname_t
;
278 bool_t
smb_gmttoken_query_xdr(XDR
*, smb_gmttoken_query_t
*);
279 bool_t
smb_gmttoken_response_xdr(XDR
*, smb_gmttoken_response_t
*);
280 bool_t
smb_gmttoken_snapname_xdr(XDR
*, smb_gmttoken_snapname_t
*);
283 * User and Group Quotas
285 * SMB User and Group quota values of SMB_QUOTA_UNLIMITED mean
286 * No Limit. This maps to 0 (none) on ZFS.
288 #define SMB_QUOTA_UNLIMITED 0xFFFFFFFFFFFFFFFF
291 * SMB (internal) representation of a quota response
292 * See also: smb_quota_xdr()
294 typedef struct smb_quota
{
295 list_node_t q_list_node
;
296 char q_sidstr
[SMB_SID_STRSZ
];
301 avl_node_t q_avl_node
;
305 * Part of a quota response
306 * See also: smb_quota_sid_xdr()
308 typedef struct smb_quota_sid
{
309 list_node_t qs_list_node
;
310 char qs_sidstr
[SMB_SID_STRSZ
];
314 SMB_QUOTA_QUERY_INVALID_OP
,
315 SMB_QUOTA_QUERY_SIDLIST
,
316 SMB_QUOTA_QUERY_STARTSID
,
318 } smb_quota_query_op_t
;
321 * SMB (internal) form of a quota lookup
322 * See also: smb_quota_query_xdr()
324 typedef struct smb_quota_query
{
326 uint32_t qq_query_op
; /* smb_quota_query_op_t */
329 uint32_t qq_max_quota
;
330 list_t qq_sid_list
; /* list of smb_quota_sid_t */
334 * The get quota response (list of quota records)
335 * See also: smb_quota_response_xdr()
337 typedef struct smb_quota_response
{
339 list_t qr_quota_list
; /* list of smb_quota_t */
340 } smb_quota_response_t
;
343 * The set quota request (list of quota records)
344 * See also: smb_quota_set_xdr()
346 typedef struct smb_quota_set
{
348 list_t qs_quota_list
; /* list of smb_quota_t */
351 bool_t
smb_quota_query_xdr(XDR
*, smb_quota_query_t
*);
352 bool_t
smb_quota_response_xdr(XDR
*, smb_quota_response_t
*);
353 bool_t
smb_quota_set_xdr(XDR
*, smb_quota_set_t
*);
355 typedef struct dfs_referral_query
{
356 dfs_reftype_t rq_type
;
358 } dfs_referral_query_t
;
360 typedef struct dfs_referral_response
{
361 dfs_info_t rp_referrals
;
363 } dfs_referral_response_t
;
365 bool_t
dfs_referral_query_xdr(XDR
*, dfs_referral_query_t
*);
366 bool_t
dfs_referral_response_xdr(XDR
*, dfs_referral_response_t
*);
368 typedef struct smb_shr_hostaccess_query
{
373 smb_inaddr_t shq_ipaddr
;
374 } smb_shr_hostaccess_query_t
;
376 bool_t
smb_shr_hostaccess_query_xdr(XDR
*, smb_shr_hostaccess_query_t
*);
377 bool_t
smb_shr_execinfo_xdr(XDR
*, smb_shr_execinfo_t
*);
383 #endif /* _SMBSRV_SMB_XDR_H */