xref: /titanic_50/usr/src/uts/common/smbsrv/smb_xdr.h (revision 129ce2569122928967f6c4d23eebbc1489419d6b)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SMBSRV_SMB_XDR_H
27 #define	_SMBSRV_SMB_XDR_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <rpc/xdr.h>
34 #include <sys/param.h>
35 #include <smbsrv/smbinfo.h>
36 #include <smbsrv/smb_ioctl.h>
37 
38 typedef struct smb_dr_kshare {
39 	int32_t k_op;
40 	char *k_path;
41 	char *k_sharename;
42 } smb_dr_kshare_t;
43 
44 #ifdef _KERNEL
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
49 
50 smb_dr_kshare_t *smb_share_mkabsolute(uint8_t *buf, uint32_t len);
51 #else
52 uint8_t *smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len);
53 #endif /* _KERNEL */
54 
55 /* null-terminated string buffer */
56 typedef struct smb_dr_string {
57 	char *buf;
58 } smb_dr_string_t;
59 
60 /* byte buffer (non-null terminated) */
61 typedef struct smb_dr_bytes {
62 	uint32_t bytes_len;
63 	uint8_t *bytes_val;
64 } smb_dr_bytes_t;
65 
66 #define	SMB_OPIPE_HDR_MAGIC	0x4F484452	/* OHDR */
67 #define	SMB_OPIPE_DOOR_BUFSIZE	(30 * 1024)
68 
69 /*
70  * Door operations for opipes.
71  */
72 typedef enum {
73 	SMB_OPIPE_NULL = 0,
74 	SMB_OPIPE_LOOKUP,
75 	SMB_OPIPE_OPEN,
76 	SMB_OPIPE_CLOSE,
77 	SMB_OPIPE_READ,
78 	SMB_OPIPE_WRITE,
79 	SMB_OPIPE_STAT
80 } smb_opipe_op_t;
81 
82 typedef struct smb_opipe_hdr {
83 	uint32_t oh_magic;
84 	uint32_t oh_fid;
85 	uint32_t oh_op;
86 	uint32_t oh_datalen;
87 	uint32_t oh_resid;
88 	uint32_t oh_status;
89 } smb_opipe_hdr_t;
90 
91 typedef struct smb_netuserinfo {
92 	uint64_t	ui_session_id;
93 	uint16_t	ui_uid;
94 	uint16_t	ui_domain_len;
95 	char		*ui_domain;
96 	uint16_t	ui_account_len;
97 	char		*ui_account;
98 	uint16_t	ui_workstation_len;
99 	char		*ui_workstation;
100 	smb_inaddr_t	ui_ipaddr;
101 	int32_t		ui_native_os;
102 	int64_t		ui_logon_time;
103 	uint32_t	ui_numopens;
104 	uint32_t	ui_flags;
105 } smb_netuserinfo_t;
106 
107 typedef struct smb_opennum {
108 	uint32_t	open_users;
109 	uint32_t	open_trees;
110 	uint32_t	open_files;
111 	uint32_t	qualtype;
112 	char		qualifier[MAXNAMELEN];
113 } smb_opennum_t;
114 
115 typedef struct smb_netconnectinfo {
116 	uint32_t	ci_id;
117 	uint32_t	ci_type;
118 	uint32_t	ci_numopens;
119 	uint32_t	ci_numusers;
120 	uint32_t	ci_time;
121 	uint32_t	ci_namelen;
122 	uint32_t	ci_sharelen;
123 	char		*ci_username;
124 	char		*ci_share;
125 } smb_netconnectinfo_t;
126 
127 typedef struct smb_netfileinfo {
128 	uint16_t	fi_fid;
129 	uint32_t	fi_uniqid;
130 	uint32_t	fi_permissions;
131 	uint32_t	fi_numlocks;
132 	uint32_t	fi_pathlen;
133 	uint32_t	fi_namelen;
134 	char		*fi_path;
135 	char		*fi_username;
136 } smb_netfileinfo_t;
137 
138 typedef struct smb_netsvcitem {
139 	list_node_t	nsi_lnd;
140 	union {
141 		smb_netuserinfo_t	nsi_user;
142 		smb_netconnectinfo_t	nsi_tree;
143 		smb_netfileinfo_t	nsi_ofile;
144 	} nsi_un;
145 } smb_netsvcitem_t;
146 
147 typedef struct smb_netsvc {
148 	list_t			ns_list;
149 	smb_netsvcitem_t	*ns_items;
150 	smb_ioc_svcenum_t	*ns_ioc;
151 	uint32_t		ns_ioclen;
152 } smb_netsvc_t;
153 
154 /* xdr routines for common door arguments/results */
155 extern bool_t xdr_smb_dr_string_t(XDR *, smb_dr_string_t *);
156 extern bool_t xdr_smb_dr_bytes_t(XDR *, smb_dr_bytes_t *);
157 extern bool_t xdr_smb_dr_kshare_t(XDR *, smb_dr_kshare_t *);
158 extern bool_t xdr_smb_inaddr_t(XDR *, smb_inaddr_t *);
159 
160 int smb_opipe_hdr_encode(smb_opipe_hdr_t *, uint8_t *, uint32_t);
161 int smb_opipe_hdr_decode(smb_opipe_hdr_t *, uint8_t *, uint32_t);
162 bool_t smb_opipe_hdr_xdr(XDR *xdrs, smb_opipe_hdr_t *objp);
163 int smb_netuserinfo_encode(smb_netuserinfo_t *, uint8_t *, uint32_t, uint_t *);
164 int smb_netuserinfo_decode(smb_netuserinfo_t *, uint8_t *, uint32_t, uint_t *);
165 bool_t smb_netuserinfo_xdr(XDR *, smb_netuserinfo_t *);
166 int smb_netconnectinfo_encode(smb_netconnectinfo_t *, uint8_t *, uint32_t,
167     uint_t *);
168 int smb_netconnectinfo_decode(smb_netconnectinfo_t *, uint8_t *, uint32_t,
169     uint_t *);
170 bool_t smb_netconnectinfo_xdr(XDR *, smb_netconnectinfo_t *);
171 int smb_netfileinfo_encode(smb_netfileinfo_t *, uint8_t *, uint32_t, uint_t *);
172 int smb_netfileinfo_decode(smb_netfileinfo_t *, uint8_t *, uint32_t, uint_t *);
173 bool_t smb_netfileinfo_xdr(XDR *, smb_netfileinfo_t *);
174 
175 /*
176  * VSS Door Structures
177  */
178 #define	SMB_VSS_GMT_SIZE sizeof ("@GMT-yyyy.mm.dd-hh.mm.ss")
179 
180 typedef struct smb_dr_get_gmttokens {
181 	uint32_t gg_count;
182 	char *gg_path;
183 } smb_dr_get_gmttokens_t;
184 
185 typedef char *gmttoken;
186 
187 typedef struct smb_dr_return_gmttokens {
188 	uint32_t rg_count;
189 	struct {
190 		uint_t rg_gmttokens_len;
191 		gmttoken *rg_gmttokens_val;
192 	} rg_gmttokens;
193 } smb_dr_return_gmttokens_t;
194 
195 typedef struct smb_dr_map_gmttoken {
196 	char *mg_path;
197 	char *mg_gmttoken;
198 } smb_dr_map_gmttoken_t;
199 
200 extern bool_t xdr_smb_dr_get_gmttokens_t(XDR *, smb_dr_get_gmttokens_t *);
201 extern bool_t xdr_gmttoken(XDR *, gmttoken *);
202 extern bool_t xdr_smb_dr_return_gmttokens_t(XDR *xdrs,
203     smb_dr_return_gmttokens_t *);
204 extern bool_t xdr_smb_dr_map_gmttoken_t(XDR *, smb_dr_map_gmttoken_t *);
205 
206 #ifdef	__cplusplus
207 }
208 #endif
209 
210 #endif	/* _SMBSRV_SMB_XDR_H */
211