Merge commit '7d815089a43a963b49eaddf97e514194ec29805b'
[unleashed.git] / usr / src / uts / common / smbsrv / smb_door.h
blob84b33746f0c0de0ab65033aeafa1e32e3163bedc
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
26 #ifndef _SMBSRV_SMB_DOOR_H
27 #define _SMBSRV_SMB_DOOR_H
29 #include <sys/door.h>
30 #include <smb/wintypes.h>
31 #include <smbsrv/smb_xdr.h>
32 #include <smbsrv/smb_token.h>
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 #define SMBD_DOOR_NAME "/var/run/smbd_door"
40 #define SMB_DOOR_CALL_RETRIES 3
43 * Opcodes for smbd door.
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.
49 * SMB_DR_ASYNC_RESPONSE delivers the response part of an asynchronous
50 * request and must be processed as a synchronous request.
52 * See also: smb_doorhdr_opname()
54 typedef enum smb_dopcode {
55 SMB_DR_NULL = 0,
56 SMB_DR_ASYNC_RESPONSE,
57 SMB_DR_USER_AUTH_LOGON,
58 SMB_DR_USER_NONAUTH_LOGON,
59 SMB_DR_USER_AUTH_LOGOFF,
60 SMB_DR_LOOKUP_SID,
61 SMB_DR_LOOKUP_NAME,
62 SMB_DR_JOIN,
63 SMB_DR_GET_DCINFO,
64 SMB_DR_VSS_GET_COUNT,
65 SMB_DR_VSS_GET_SNAPSHOTS,
66 SMB_DR_VSS_MAP_GMTTOKEN,
67 SMB_DR_ADS_FIND_HOST,
68 SMB_DR_QUOTA_QUERY,
69 SMB_DR_QUOTA_SET,
70 SMB_DR_DFS_GET_REFERRALS,
71 SMB_DR_SHR_HOSTACCESS,
72 SMB_DR_SHR_EXEC,
73 SMB_DR_NOTIFY_DC_CHANGED
74 } smb_dopcode_t;
76 struct smb_event;
78 typedef struct smb_doorarg {
79 smb_doorhdr_t da_hdr;
80 door_arg_t da_arg;
81 xdrproc_t da_req_xdr;
82 xdrproc_t da_rsp_xdr;
83 void *da_req_data;
84 void *da_rsp_data;
85 smb_dopcode_t da_opcode;
86 const char *da_opname;
87 struct smb_event *da_event;
88 uint32_t da_flags;
89 } smb_doorarg_t;
92 * Door call return codes.
94 #define SMB_DOP_SUCCESS 0
95 #define SMB_DOP_NOT_CALLED 1
96 #define SMB_DOP_DECODE_ERROR 2
97 #define SMB_DOP_ENCODE_ERROR 3
98 #define SMB_DOP_EMPTYBUF 4
100 #if !defined(_KERNEL)
101 char *smb_common_encode(void *, xdrproc_t, size_t *);
102 int smb_common_decode(char *, size_t, xdrproc_t, void *);
103 char *smb_string_encode(char *, size_t *);
104 int smb_string_decode(smb_string_t *, char *, size_t);
105 #endif /* !_KERNEL */
108 * Legacy door interface
110 #define SMB_SHARE_DNAME "/var/run/smb_share_door"
111 #define SMB_SHARE_DSIZE (65 * 1024)
114 * door operations
116 #define SMB_SHROP_NUM_SHARES 1
117 #define SMB_SHROP_DELETE 2
118 #define SMB_SHROP_RENAME 3
119 #define SMB_SHROP_ADD 4
120 #define SMB_SHROP_MODIFY 5
121 #define SMB_SHROP_LIST 6
124 * Door server status
126 * SMB_SHARE_DERROR is returned by the door server if there is problem
127 * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is
128 * returned.
131 #define SMB_SHARE_DSUCCESS 0
132 #define SMB_SHARE_DERROR -1
134 typedef struct smb_dr_ctx {
135 char *ptr;
136 char *start_ptr;
137 char *end_ptr;
138 int status;
139 } smb_dr_ctx_t;
141 smb_dr_ctx_t *smb_dr_decode_start(char *, int);
142 int smb_dr_decode_finish(smb_dr_ctx_t *);
144 smb_dr_ctx_t *smb_dr_encode_start(char *, int);
145 int smb_dr_encode_finish(smb_dr_ctx_t *, unsigned int *);
147 int32_t smb_dr_get_int32(smb_dr_ctx_t *);
148 DWORD smb_dr_get_dword(smb_dr_ctx_t *);
149 uint32_t smb_dr_get_uint32(smb_dr_ctx_t *);
150 int64_t smb_dr_get_int64(smb_dr_ctx_t *);
151 uint64_t smb_dr_get_uint64(smb_dr_ctx_t *);
152 unsigned short smb_dr_get_ushort(smb_dr_ctx_t *);
154 void smb_dr_put_int32(smb_dr_ctx_t *, int32_t);
155 void smb_dr_put_dword(smb_dr_ctx_t *, DWORD);
156 void smb_dr_put_uint32(smb_dr_ctx_t *, uint32_t);
157 void smb_dr_put_int64(smb_dr_ctx_t *, int64_t);
158 void smb_dr_put_uint64(smb_dr_ctx_t *, uint64_t);
159 void smb_dr_put_ushort(smb_dr_ctx_t *, unsigned short);
161 char *smb_dr_get_string(smb_dr_ctx_t *);
162 void smb_dr_put_string(smb_dr_ctx_t *, const char *);
163 void smb_dr_free_string(char *);
165 void smb_dr_put_word(smb_dr_ctx_t *, WORD);
166 WORD smb_dr_get_word(smb_dr_ctx_t *);
168 void smb_dr_put_BYTE(smb_dr_ctx_t *, BYTE);
169 BYTE smb_dr_get_BYTE(smb_dr_ctx_t *);
171 void smb_dr_put_buf(smb_dr_ctx_t *, unsigned char *, int);
172 int smb_dr_get_buf(smb_dr_ctx_t *, unsigned char *, int);
174 void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *);
175 void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *);
177 void smb_share_door_clnt_init(void);
178 void smb_share_door_clnt_fini(void);
180 #ifdef __cplusplus
182 #endif
184 #endif /* _SMBSRV_SMB_DOOR_H */