xref: /titanic_51/usr/src/uts/common/smbsrv/smb_door.h (revision dd51520e127b452179a2ce4ea3bd8dee949f9afe)
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _SMBSRV_SMB_DOOR_H
26 #define	_SMBSRV_SMB_DOOR_H
27 
28 #include <sys/door.h>
29 #include <smbsrv/wintypes.h>
30 #include <smbsrv/smb_xdr.h>
31 #include <smbsrv/smb_token.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define	SMBD_DOOR_NAME			"/var/run/smbd_door"
38 
39 #define	SMB_DOOR_CALL_RETRIES		3
40 
41 /*
42  * Opcodes for smbd door.
43  *
44  * SMB_DR_NULL is the equivalent of the NULL RPC.  It ensures that an
45  * opcode of zero is not misinterpreted as an operational door call
46  * and it is available as a test interface.
47  *
48  * SMB_DR_ASYNC_RESPONSE delivers the response part of an asynchronous
49  * request and must be processed as a synchronous request.
50  */
51 typedef enum smb_dopcode {
52 	SMB_DR_NULL = 0,
53 	SMB_DR_ASYNC_RESPONSE,
54 	SMB_DR_USER_AUTH_LOGON,
55 	SMB_DR_USER_NONAUTH_LOGON,
56 	SMB_DR_USER_AUTH_LOGOFF,
57 	SMB_DR_LOOKUP_SID,
58 	SMB_DR_LOOKUP_NAME,
59 	SMB_DR_JOIN,
60 	SMB_DR_GET_DCINFO,
61 	SMB_DR_VSS_GET_COUNT,
62 	SMB_DR_VSS_GET_SNAPSHOTS,
63 	SMB_DR_VSS_MAP_GMTTOKEN,
64 	SMB_DR_ADS_FIND_HOST,
65 	SMB_DR_QUOTA_QUERY,
66 	SMB_DR_QUOTA_SET,
67 	SMB_DR_DFS_GET_REFERRALS,
68 	SMB_DR_SHR_HOSTACCESS,
69 	SMB_DR_SHR_EXEC
70 } smb_dopcode_t;
71 
72 struct smb_event;
73 
74 typedef struct smb_doorarg {
75 	smb_doorhdr_t		da_hdr;
76 	door_arg_t		da_arg;
77 	xdrproc_t		da_req_xdr;
78 	xdrproc_t		da_rsp_xdr;
79 	void			*da_req_data;
80 	void			*da_rsp_data;
81 	smb_dopcode_t		da_opcode;
82 	const char		*da_opname;
83 	struct smb_event	*da_event;
84 	uint32_t		da_flags;
85 } smb_doorarg_t;
86 
87 /*
88  * Door call return codes.
89  */
90 #define	SMB_DOP_SUCCESS			0
91 #define	SMB_DOP_NOT_CALLED		1
92 #define	SMB_DOP_DECODE_ERROR		2
93 #define	SMB_DOP_ENCODE_ERROR		3
94 #define	SMB_DOP_EMPTYBUF		4
95 
96 #ifndef _KERNEL
97 char *smb_common_encode(void *, xdrproc_t, size_t *);
98 int smb_common_decode(char *, size_t, xdrproc_t, void *);
99 char *smb_string_encode(char *, size_t *);
100 int smb_string_decode(smb_string_t *, char *, size_t);
101 #endif /* _KERNEL */
102 
103 /*
104  * Legacy door interface
105  */
106 #define	SMB_SHARE_DNAME		"/var/run/smb_share_door"
107 #define	SMB_SHARE_DSIZE		(65 * 1024)
108 
109 /*
110  * door operations
111  */
112 #define	SMB_SHROP_NUM_SHARES		1
113 #define	SMB_SHROP_DELETE		2
114 #define	SMB_SHROP_RENAME		3
115 #define	SMB_SHROP_ADD			4
116 #define	SMB_SHROP_MODIFY		5
117 #define	SMB_SHROP_LIST			6
118 
119 /*
120  * Door server status
121  *
122  * SMB_SHARE_DERROR is returned by the door server if there is problem
123  * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is
124  * returned.
125  *
126  */
127 #define	SMB_SHARE_DSUCCESS		0
128 #define	SMB_SHARE_DERROR		-1
129 
130 typedef struct smb_dr_ctx {
131 	char *ptr;
132 	char *start_ptr;
133 	char *end_ptr;
134 	int status;
135 } smb_dr_ctx_t;
136 
137 smb_dr_ctx_t *smb_dr_decode_start(char *, int);
138 int smb_dr_decode_finish(smb_dr_ctx_t *);
139 
140 smb_dr_ctx_t *smb_dr_encode_start(char *, int);
141 int smb_dr_encode_finish(smb_dr_ctx_t *, unsigned int *);
142 
143 int32_t smb_dr_get_int32(smb_dr_ctx_t *);
144 DWORD smb_dr_get_dword(smb_dr_ctx_t *);
145 uint32_t smb_dr_get_uint32(smb_dr_ctx_t *);
146 int64_t smb_dr_get_int64(smb_dr_ctx_t *);
147 uint64_t smb_dr_get_uint64(smb_dr_ctx_t *);
148 unsigned short smb_dr_get_ushort(smb_dr_ctx_t *);
149 
150 void smb_dr_put_int32(smb_dr_ctx_t *, int32_t);
151 void smb_dr_put_dword(smb_dr_ctx_t *, DWORD);
152 void smb_dr_put_uint32(smb_dr_ctx_t *, uint32_t);
153 void smb_dr_put_int64(smb_dr_ctx_t *, int64_t);
154 void smb_dr_put_uint64(smb_dr_ctx_t *, uint64_t);
155 void smb_dr_put_ushort(smb_dr_ctx_t *, unsigned short);
156 
157 char *smb_dr_get_string(smb_dr_ctx_t *);
158 void smb_dr_put_string(smb_dr_ctx_t *, const char *);
159 void smb_dr_free_string(char *);
160 
161 void smb_dr_put_word(smb_dr_ctx_t *, WORD);
162 WORD smb_dr_get_word(smb_dr_ctx_t *);
163 
164 void smb_dr_put_BYTE(smb_dr_ctx_t *, BYTE);
165 BYTE smb_dr_get_BYTE(smb_dr_ctx_t *);
166 
167 void smb_dr_put_buf(smb_dr_ctx_t *, unsigned char *, int);
168 int smb_dr_get_buf(smb_dr_ctx_t *, unsigned char *, int);
169 
170 void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *);
171 void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *);
172 
173 void smb_share_door_clnt_init(void);
174 void smb_share_door_clnt_fini(void);
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif	/* _SMBSRV_SMB_DOOR_H */
181