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