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.
25 #ifndef _SMBSRV_SMB_XDR_H
26 #define _SMBSRV_SMB_XDR_H
33 #include <sys/param.h>
35 #include <smbsrv/wintypes.h>
36 #include <smbsrv/smb_sid.h>
37 #include <smbsrv/smbinfo.h>
38 #include <smbsrv/smb_ioctl.h>
39 #include <smbsrv/smb_sid.h>
40 #include <smbsrv/smb_share.h>
41 #include <smbsrv/smb_dfs.h>
42 #include <smbsrv/wintypes.h>
45 #define xdr_int8_t xdr_char
46 #define xdr_uint8_t xdr_u_char
47 #define xdr_int16_t xdr_short
48 #define xdr_uint16_t xdr_u_short
51 /* null-terminated string */
52 typedef struct smb_string
{
56 /* 32-bit opaque buffer (non-null terminated strings) */
57 typedef struct smb_buf32
{
62 #define SMB_OPIPE_HDR_MAGIC 0x4F484452 /* OHDR */
63 #define SMB_OPIPE_DOOR_BUFSIZE (30 * 1024)
66 * Door operations for opipes.
78 #define SMB_DOOR_HDR_MAGIC 0x444F4F52 /* DOOR */
83 #define SMB_DF_ASYNC 0x00000001 /* Asynchronous call */
84 #define SMB_DF_SYSSPACE 0x00000002 /* Called from the kernel */
85 #define SMB_DF_USERSPACE 0x00000004 /* Called from user space */
88 * Header for door calls. The op codes and return codes are defined
89 * in smb_door.h. The header is here to make it available to XDR.
91 * fid For opipe: the pipe identifier.
92 * op The door operation being invoked.
93 * txid Unique transaction id for the current door call.
94 * datalen Bytes of data following the header (excludes the header).
95 * resid For opipe: the number of bytes remaining in the server.
96 * door_rc Return code provided by the door server.
97 * status A pass-through status provided by the door operation.
99 typedef struct smb_doorhdr
{
111 typedef struct smb_netuserinfo
{
112 uint64_t ui_session_id
;
114 uint16_t ui_domain_len
;
116 uint16_t ui_account_len
;
119 uint16_t ui_workstation_len
;
120 char *ui_workstation
;
121 smb_inaddr_t ui_ipaddr
;
122 int32_t ui_native_os
;
123 int64_t ui_logon_time
;
124 uint32_t ui_numopens
;
128 typedef struct smb_opennum
{
133 char qualifier
[MAXNAMELEN
];
136 typedef struct smb_netconnectinfo
{
139 uint32_t ci_numopens
;
140 uint32_t ci_numusers
;
143 uint32_t ci_sharelen
;
146 } smb_netconnectinfo_t
;
148 typedef struct smb_netfileinfo
{
151 uint32_t fi_permissions
;
152 uint32_t fi_numlocks
;
159 typedef struct smb_netsvcitem
{
162 smb_netuserinfo_t nsi_user
;
163 smb_netconnectinfo_t nsi_tree
;
164 smb_netfileinfo_t nsi_ofile
;
168 typedef struct smb_netsvc
{
170 smb_netsvcitem_t
*ns_items
;
171 smb_ioc_svcenum_t
*ns_ioc
;
176 bool_t
smb_buf32_xdr(XDR
*, smb_buf32_t
*);
177 bool_t
smb_string_xdr(XDR
*, smb_string_t
*);
178 bool_t
smb_inaddr_xdr(XDR
*, smb_inaddr_t
*);
180 const char *smb_doorhdr_opname(uint32_t);
181 int smb_doorhdr_encode(smb_doorhdr_t
*, uint8_t *, uint32_t);
182 int smb_doorhdr_decode(smb_doorhdr_t
*, uint8_t *, uint32_t);
183 bool_t
smb_doorhdr_xdr(XDR
*xdrs
, smb_doorhdr_t
*objp
);
184 int smb_netuserinfo_encode(smb_netuserinfo_t
*, uint8_t *, uint32_t, uint_t
*);
185 int smb_netuserinfo_decode(smb_netuserinfo_t
*, uint8_t *, uint32_t, uint_t
*);
186 bool_t
smb_netuserinfo_xdr(XDR
*, smb_netuserinfo_t
*);
187 int smb_netconnectinfo_encode(smb_netconnectinfo_t
*, uint8_t *, uint32_t,
189 int smb_netconnectinfo_decode(smb_netconnectinfo_t
*, uint8_t *, uint32_t,
191 bool_t
smb_netconnectinfo_xdr(XDR
*, smb_netconnectinfo_t
*);
192 int smb_netfileinfo_encode(smb_netfileinfo_t
*, uint8_t *, uint32_t, uint_t
*);
193 int smb_netfileinfo_decode(smb_netfileinfo_t
*, uint8_t *, uint32_t, uint_t
*);
194 bool_t
smb_netfileinfo_xdr(XDR
*, smb_netfileinfo_t
*);
196 typedef uint16_t sid_type_t
;
198 typedef struct lsa_account
{
200 sid_type_t a_sidtype
;
201 char a_domain
[MAXNAMELEN
];
202 char a_name
[MAXNAMELEN
];
203 char a_sid
[SMB_SID_STRSZ
];
206 int lsa_account_encode(lsa_account_t
*, uint8_t *, uint32_t);
207 int lsa_account_decode(lsa_account_t
*, uint8_t *, uint32_t);
208 bool_t
lsa_account_xdr(XDR
*, lsa_account_t
*);
211 * VSS Door Structures
213 #define SMB_VSS_GMT_SIZE sizeof ("@GMT-yyyy.mm.dd-hh.mm.ss")
215 typedef struct smb_gmttoken_query
{
218 } smb_gmttoken_query_t
;
220 typedef char *smb_gmttoken_t
;
222 typedef struct smb_gmttoken_response
{
225 uint_t gtr_gmttokens_len
;
226 smb_gmttoken_t
*gtr_gmttokens_val
;
228 } smb_gmttoken_response_t
;
230 typedef struct smb_gmttoken_snapname
{
233 } smb_gmttoken_snapname_t
;
235 bool_t
smb_gmttoken_query_xdr(XDR
*, smb_gmttoken_query_t
*);
236 bool_t
smb_gmttoken_response_xdr(XDR
*, smb_gmttoken_response_t
*);
237 bool_t
smb_gmttoken_snapname_xdr(XDR
*, smb_gmttoken_snapname_t
*);
240 * User and Group Quotas
242 * SMB User and Group quota values of SMB_QUOTA_UNLIMITED mean
243 * No Limit. This maps to 0 (none) on ZFS.
245 #define SMB_QUOTA_UNLIMITED 0xFFFFFFFFFFFFFFFF
247 typedef struct smb_quota
{
248 list_node_t q_list_node
;
249 char q_sidstr
[SMB_SID_STRSZ
];
254 avl_node_t q_avl_node
;
257 typedef struct smb_quota_sid
{
258 list_node_t qs_list_node
;
259 char qs_sidstr
[SMB_SID_STRSZ
];
263 SMB_QUOTA_QUERY_INVALID_OP
,
264 SMB_QUOTA_QUERY_SIDLIST
,
265 SMB_QUOTA_QUERY_STARTSID
,
267 } smb_quota_query_op_t
;
269 typedef struct smb_quota_query
{
271 uint32_t qq_query_op
; /* smb_quota_query_op_t */
274 uint32_t qq_max_quota
;
275 list_t qq_sid_list
; /* list of smb_quota_sid_t */
278 typedef struct smb_quota_response
{
280 list_t qr_quota_list
; /* list of smb_quota_t */
281 } smb_quota_response_t
;
283 typedef struct smb_quota_set
{
285 list_t qs_quota_list
; /* list of smb_quota_t */
288 bool_t
smb_quota_query_xdr(XDR
*, smb_quota_query_t
*);
289 bool_t
smb_quota_response_xdr(XDR
*, smb_quota_response_t
*);
290 bool_t
smb_quota_set_xdr(XDR
*, smb_quota_set_t
*);
292 typedef struct dfs_referral_query
{
293 dfs_reftype_t rq_type
;
295 } dfs_referral_query_t
;
297 typedef struct dfs_referral_response
{
298 dfs_info_t rp_referrals
;
300 } dfs_referral_response_t
;
302 bool_t
dfs_referral_query_xdr(XDR
*, dfs_referral_query_t
*);
303 bool_t
dfs_referral_response_xdr(XDR
*, dfs_referral_response_t
*);
305 typedef struct smb_shr_hostaccess_query
{
310 smb_inaddr_t shq_ipaddr
;
311 } smb_shr_hostaccess_query_t
;
313 bool_t
smb_shr_hostaccess_query_xdr(XDR
*, smb_shr_hostaccess_query_t
*);
314 bool_t
smb_shr_execinfo_xdr(XDR
*, smb_shr_execinfo_t
*);
320 #endif /* _SMBSRV_SMB_XDR_H */