xref: /titanic_52/usr/src/uts/common/smbsrv/smb_xdr.h (revision 16dd44c265271a75647fb0bb41109bb7c585a526)
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 
37 typedef struct smb_dr_kshare {
38 	int32_t k_op;
39 	char *k_path;
40 	char *k_sharename;
41 } smb_dr_kshare_t;
42 
43 #ifdef _KERNEL
44 #define	xdr_int8_t	xdr_char
45 #define	xdr_uint8_t	xdr_u_char
46 #define	xdr_int16_t	xdr_short
47 #define	xdr_uint16_t	xdr_u_short
48 
49 extern bool_t xdr_u_char(XDR *xdrs, uchar_t *cp);
50 extern bool_t xdr_vector(XDR *xdrs, char *basep, uint_t nelem,
51     uint_t elemsize, xdrproc_t xdr_elem);
52 
53 smb_dr_kshare_t *smb_share_mkabsolute(uint8_t *buf, uint32_t len);
54 #else
55 uint8_t *smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len);
56 #endif /* _KERNEL */
57 
58 /* null-terminated string buffer */
59 typedef struct smb_dr_string {
60 	char *buf;
61 } smb_dr_string_t;
62 
63 /* byte buffer (non-null terminated) */
64 typedef struct smb_dr_bytes {
65 	uint32_t bytes_len;
66 	uint8_t *bytes_val;
67 } smb_dr_bytes_t;
68 
69 #define	SMB_DR_MAX_USERS	50
70 
71 #define	SMB_OPIPE_HDR_MAGIC	0x4F484452	/* OHDR */
72 #define	SMB_OPIPE_DOOR_BUFSIZE	(30 * 1024)
73 
74 /*
75  * Door operations for opipes.
76  */
77 typedef enum {
78 	SMB_OPIPE_NULL = 0,
79 	SMB_OPIPE_LOOKUP,
80 	SMB_OPIPE_OPEN,
81 	SMB_OPIPE_CLOSE,
82 	SMB_OPIPE_READ,
83 	SMB_OPIPE_WRITE,
84 	SMB_OPIPE_STAT
85 } smb_opipe_op_t;
86 
87 typedef struct smb_opipe_hdr {
88 	uint32_t oh_magic;
89 	uint32_t oh_fid;
90 	uint32_t oh_op;
91 	uint32_t oh_datalen;
92 	uint32_t oh_resid;
93 	uint32_t oh_status;
94 } smb_opipe_hdr_t;
95 
96 typedef struct smb_opipe_context {
97 	uint64_t oc_session_id;
98 	uint16_t oc_uid;
99 	uint16_t oc_domain_len;
100 	char *oc_domain;
101 	uint16_t oc_account_len;
102 	char *oc_account;
103 	uint16_t oc_workstation_len;
104 	char *oc_workstation;
105 	smb_inaddr_t oc_ipaddr;
106 	int32_t oc_native_os;
107 	int64_t oc_logon_time;
108 	uint32_t oc_flags;
109 } smb_opipe_context_t;
110 
111 typedef struct smb_dr_ulist {
112 	uint32_t dul_cnt;
113 	smb_opipe_context_t dul_users[SMB_DR_MAX_USERS];
114 } smb_dr_ulist_t;
115 
116 /* xdr routines for common door arguments/results */
117 extern bool_t xdr_smb_dr_string_t(XDR *, smb_dr_string_t *);
118 extern bool_t xdr_smb_dr_bytes_t(XDR *, smb_dr_bytes_t *);
119 extern bool_t xdr_smb_dr_ulist_t(XDR *, smb_dr_ulist_t *);
120 extern bool_t xdr_smb_dr_kshare_t(XDR *, smb_dr_kshare_t *);
121 extern bool_t xdr_smb_inaddr_t(XDR *, smb_inaddr_t *);
122 
123 int smb_opipe_hdr_encode(smb_opipe_hdr_t *, uint8_t *, uint32_t);
124 int smb_opipe_hdr_decode(smb_opipe_hdr_t *, uint8_t *, uint32_t);
125 bool_t smb_opipe_hdr_xdr(XDR *xdrs, smb_opipe_hdr_t *objp);
126 int smb_opipe_context_encode(smb_opipe_context_t *, uint8_t *, uint32_t);
127 int smb_opipe_context_decode(smb_opipe_context_t *, uint8_t *, uint32_t);
128 bool_t smb_opipe_context_xdr(XDR *, smb_opipe_context_t *);
129 /*
130  * VSS Door Structures
131  */
132 #define	SMB_VSS_GMT_SIZE sizeof ("@GMT-yyyy.mm.dd-hh.mm.ss")
133 
134 typedef struct smb_dr_get_gmttokens {
135 	uint32_t gg_count;
136 	char *gg_path;
137 } smb_dr_get_gmttokens_t;
138 
139 typedef char *gmttoken;
140 
141 typedef struct smb_dr_return_gmttokens {
142 	uint32_t rg_count;
143 	struct {
144 		uint_t rg_gmttokens_len;
145 		gmttoken *rg_gmttokens_val;
146 	} rg_gmttokens;
147 } smb_dr_return_gmttokens_t;
148 
149 typedef struct smb_dr_map_gmttoken {
150 	char *mg_path;
151 	char *mg_gmttoken;
152 } smb_dr_map_gmttoken_t;
153 
154 extern bool_t xdr_smb_dr_get_gmttokens_t(XDR *, smb_dr_get_gmttokens_t *);
155 extern bool_t xdr_gmttoken(XDR *, gmttoken *);
156 extern bool_t xdr_smb_dr_return_gmttokens_t(XDR *xdrs,
157     smb_dr_return_gmttokens_t *);
158 extern bool_t xdr_smb_dr_map_gmttoken_t(XDR *, smb_dr_map_gmttoken_t *);
159 
160 #ifdef	__cplusplus
161 }
162 #endif
163 
164 #endif	/* _SMBSRV_SMB_XDR_H */
165