xref: /titanic_41/usr/src/uts/common/smbsrv/smb_door.h (revision 3fb517f786391b507780c78aabb8d98bfea9efe9)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_SMB_DOOR_H
27 #define	_SMBSRV_SMB_DOOR_H
28 
29 #include <sys/door.h>
30 #include <smbsrv/wintypes.h>
31 #include <smbsrv/smb_xdr.h>
32 #include <smbsrv/smb_token.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define	SMBD_DOOR_NAME			"/var/run/smbd_door"
39 
40 #define	SMB_DOOR_CALL_RETRIES		3
41 
42 /*
43  * Opcodes for smbd door.
44  *
45  * SMB_DR_NULL is the equivalent of the NULL RPC.  It ensures that an
46  * opcode of zero is not misinterpreted as an operational door call
47  * and it is available as a test interface.
48  *
49  * SMB_DR_ASYNC_RESPONSE delivers the response part of an asynchronous
50  * request and must be processed as a synchronous request.
51  */
52 typedef enum smb_dopcode {
53 	SMB_DR_NULL = 0,
54 	SMB_DR_ASYNC_RESPONSE,
55 	SMB_DR_USER_AUTH_LOGON,
56 	SMB_DR_USER_NONAUTH_LOGON,
57 	SMB_DR_USER_AUTH_LOGOFF,
58 	SMB_DR_LOOKUP_SID,
59 	SMB_DR_LOOKUP_NAME,
60 	SMB_DR_JOIN,
61 	SMB_DR_GET_DCINFO,
62 	SMB_DR_VSS_GET_COUNT,
63 	SMB_DR_VSS_GET_SNAPSHOTS,
64 	SMB_DR_VSS_MAP_GMTTOKEN,
65 	SMB_DR_ADS_FIND_HOST,
66 	SMB_DR_QUOTA_QUERY,
67 	SMB_DR_QUOTA_SET,
68 	SMB_DR_DFS_GET_REFERRALS
69 } smb_dopcode_t;
70 
71 struct smb_event;
72 
73 typedef struct smb_doorarg {
74 	smb_doorhdr_t		da_hdr;
75 	door_arg_t		da_arg;
76 	xdrproc_t		da_req_xdr;
77 	xdrproc_t		da_rsp_xdr;
78 	void			*da_req_data;
79 	void			*da_rsp_data;
80 	smb_dopcode_t		da_opcode;
81 	const char		*da_opname;
82 	struct smb_event	*da_event;
83 	uint32_t		da_flags;
84 } smb_doorarg_t;
85 
86 /*
87  * Door call return codes.
88  */
89 #define	SMB_DOP_SUCCESS			0
90 #define	SMB_DOP_NOT_CALLED		1
91 #define	SMB_DOP_DECODE_ERROR		2
92 #define	SMB_DOP_ENCODE_ERROR		3
93 #define	SMB_DOP_EMPTYBUF		4
94 
95 #ifndef _KERNEL
96 char *smb_common_encode(void *, xdrproc_t, size_t *);
97 int smb_common_decode(char *, size_t, xdrproc_t, void *);
98 char *smb_string_encode(char *, size_t *);
99 int smb_string_decode(smb_string_t *, char *, size_t);
100 #endif /* _KERNEL */
101 
102 typedef struct smb_dr_ctx {
103 	char *ptr;
104 	char *start_ptr;
105 	char *end_ptr;
106 	int status;
107 } smb_dr_ctx_t;
108 
109 smb_dr_ctx_t *smb_dr_decode_start(char *, int);
110 int smb_dr_decode_finish(smb_dr_ctx_t *);
111 
112 smb_dr_ctx_t *smb_dr_encode_start(char *, int);
113 int smb_dr_encode_finish(smb_dr_ctx_t *, unsigned int *);
114 
115 int32_t smb_dr_get_int32(smb_dr_ctx_t *);
116 DWORD smb_dr_get_dword(smb_dr_ctx_t *);
117 uint32_t smb_dr_get_uint32(smb_dr_ctx_t *);
118 int64_t smb_dr_get_int64(smb_dr_ctx_t *);
119 uint64_t smb_dr_get_uint64(smb_dr_ctx_t *);
120 unsigned short smb_dr_get_ushort(smb_dr_ctx_t *);
121 
122 void smb_dr_put_int32(smb_dr_ctx_t *, int32_t);
123 void smb_dr_put_dword(smb_dr_ctx_t *, DWORD);
124 void smb_dr_put_uint32(smb_dr_ctx_t *, uint32_t);
125 void smb_dr_put_int64(smb_dr_ctx_t *, int64_t);
126 void smb_dr_put_uint64(smb_dr_ctx_t *, uint64_t);
127 void smb_dr_put_ushort(smb_dr_ctx_t *, unsigned short);
128 
129 char *smb_dr_get_string(smb_dr_ctx_t *);
130 void smb_dr_put_string(smb_dr_ctx_t *, const char *);
131 void smb_dr_free_string(char *);
132 
133 void smb_dr_put_word(smb_dr_ctx_t *, WORD);
134 WORD smb_dr_get_word(smb_dr_ctx_t *);
135 
136 void smb_dr_put_BYTE(smb_dr_ctx_t *, BYTE);
137 BYTE smb_dr_get_BYTE(smb_dr_ctx_t *);
138 
139 void smb_dr_put_buf(smb_dr_ctx_t *, unsigned char *, int);
140 int smb_dr_get_buf(smb_dr_ctx_t *, unsigned char *, int);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif	/* _SMBSRV_SMB_DOOR_H */
147