xref: /illumos-gate/usr/src/uts/common/smbsrv/smb_xdr.h (revision 499fd601)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <rpc/xdr.h>
36 #include <sys/param.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 extern bool_t xdr_u_char(XDR *xdrs, uchar_t *cp);
51 extern bool_t xdr_vector(XDR *xdrs, char *basep, uint_t nelem,
52     uint_t elemsize, xdrproc_t xdr_elem);
53 
54 smb_dr_kshare_t *smb_share_mkabsolute(uint8_t *buf, uint32_t len);
55 #else
56 uint8_t *smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len);
57 #endif /* _KERNEL */
58 
59 /* null-terminated string buffer */
60 typedef struct smb_dr_string {
61 	char *buf;
62 } smb_dr_string_t;
63 
64 /* byte buffer (non-null terminated) */
65 typedef struct smb_dr_bytes {
66 	uint32_t bytes_len;
67 	uint8_t *bytes_val;
68 } smb_dr_bytes_t;
69 
70 /*
71  * smb_dr_user_ctx/smb_dr_ulist data structures are defined to transfer
72  * the necessary information for all connected users via door to
73  * mlsvc. The smb_dr_user_ctx provides user context that will be part
74  * of the MLSVC rpc context.
75  *
76  * Both SMB session ID and SMB UID of smb_dr_user_ctx_t are used to
77  * uniquely identified the corresponding in-kernel SMB user object.
78  */
79 #define	SMB_DR_MAX_USERS	50
80 typedef struct smb_dr_user_ctx {
81 	uint64_t du_session_id;
82 	uint16_t du_uid;
83 	uint16_t du_domain_len;
84 	char *du_domain;
85 	uint16_t du_account_len;
86 	char *du_account;
87 	uint16_t du_workstation_len;
88 	char *du_workstation;
89 	uint32_t du_ipaddr;
90 	int32_t du_native_os;
91 	int64_t du_logon_time;
92 	uint32_t du_flags;
93 } smb_dr_user_ctx_t;
94 
95 typedef struct smb_dr_ulist {
96 	uint32_t dul_cnt;
97 	smb_dr_user_ctx_t dul_users[SMB_DR_MAX_USERS];
98 } smb_dr_ulist_t;
99 
100 /* xdr routines for common door arguments/results */
101 extern bool_t xdr_smb_dr_string_t(XDR *, smb_dr_string_t *);
102 extern bool_t xdr_smb_dr_bytes_t(XDR *, smb_dr_bytes_t *);
103 extern bool_t xdr_smb_dr_user_ctx_t(XDR *, smb_dr_user_ctx_t *);
104 extern bool_t xdr_smb_dr_ulist_t(XDR *, smb_dr_ulist_t *);
105 extern bool_t xdr_smb_dr_kshare_t(XDR *, smb_dr_kshare_t *);
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif	/* _SMBSRV_SMB_XDR_H */
112