19fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States/*
29fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * CDDL HEADER START
39fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States *
49fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * The contents of this file are subject to the terms of the
59fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * Common Development and Distribution License (the "License").
69fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * You may not use this file except in compliance with the License.
79fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States *
89fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * or http://www.opensolaris.org/os/licensing.
109fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * See the License for the specific language governing permissions
119fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * and limitations under the License.
129fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States *
139fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * When distributing Covered Code, include this CDDL HEADER in each
149fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * If applicable, add the following below this CDDL HEADER, with the
169fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * fields enclosed by brackets "[]" replaced with your own identifying
179fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * information: Portions Copyright [yyyy] [name of copyright owner]
189fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States *
199fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * CDDL HEADER END
209fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States */
219fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States/*
22148c5f4Alan Wright * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23dafb549Gordon Ross * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
249fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States */
259fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
269fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#ifndef _SMBSRV_SMB_DOOR_H
279fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	_SMBSRV_SMB_DOOR_H
289fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
299fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#include <sys/door.h>
303299f39Gordon Ross#include <smb/wintypes.h>
319fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#include <smbsrv/smb_xdr.h>
329fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#include <smbsrv/smb_token.h>
339fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
349fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#ifdef __cplusplus
359fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesextern "C" {
369fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#endif
379fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
389fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMBD_DOOR_NAME			"/var/run/smbd_door"
399fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
409fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMB_DOOR_CALL_RETRIES		3
419fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
429fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States/*
439fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * Opcodes for smbd door.
449fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States *
459fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * SMB_DR_NULL is the equivalent of the NULL RPC.  It ensures that an
469fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * opcode of zero is not misinterpreted as an operational door call
479fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * and it is available as a test interface.
489fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States *
499fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * SMB_DR_ASYNC_RESPONSE delivers the response part of an asynchronous
509fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * request and must be processed as a synchronous request.
51a90cf9fGordon Ross *
52a90cf9fGordon Ross * See also: smb_doorhdr_opname()
539fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States */
549fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statestypedef enum smb_dopcode {
559fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_NULL = 0,
569fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_ASYNC_RESPONSE,
579fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_USER_AUTH_LOGON,
589fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_USER_NONAUTH_LOGON,
599fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_USER_AUTH_LOGOFF,
609fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_LOOKUP_SID,
619fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_LOOKUP_NAME,
629fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_JOIN,
639fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_GET_DCINFO,
649fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_VSS_GET_COUNT,
659fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_VSS_GET_SNAPSHOTS,
669fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_VSS_MAP_GMTTOKEN,
679fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_ADS_FIND_HOST,
689fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_QUOTA_QUERY,
699fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	SMB_DR_QUOTA_SET,
70148c5f4Alan Wright	SMB_DR_DFS_GET_REFERRALS,
71148c5f4Alan Wright	SMB_DR_SHR_HOSTACCESS,
72b3700b0Gordon Ross	SMB_DR_SHR_EXEC,
73dafb549Gordon Ross	SMB_DR_NOTIFY_DC_CHANGED,
74dafb549Gordon Ross	SMB_DR_LOOKUP_LSID,
75dafb549Gordon Ross	SMB_DR_LOOKUP_LNAME
769fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States} smb_dopcode_t;
779fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
789fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesstruct smb_event;
799fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
809fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statestypedef struct smb_doorarg {
819fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	smb_doorhdr_t		da_hdr;
829fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	door_arg_t		da_arg;
839fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	xdrproc_t		da_req_xdr;
849fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	xdrproc_t		da_rsp_xdr;
859fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	void			*da_req_data;
869fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	void			*da_rsp_data;
879fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	smb_dopcode_t		da_opcode;
889fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	const char		*da_opname;
899fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	struct smb_event	*da_event;
909fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	uint32_t		da_flags;
919fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States} smb_doorarg_t;
929fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
939fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States/*
949fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States * Door call return codes.
959fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States */
969fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMB_DOP_SUCCESS			0
979fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMB_DOP_NOT_CALLED		1
989fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMB_DOP_DECODE_ERROR		2
999fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMB_DOP_ENCODE_ERROR		3
1009fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#define	SMB_DOP_EMPTYBUF		4
1019fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
102b819ceaGordon Ross#if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
1039fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Stateschar *smb_common_encode(void *, xdrproc_t, size_t *);
1049fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint smb_common_decode(char *, size_t, xdrproc_t, void *);
1059fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Stateschar *smb_string_encode(char *, size_t *);
1069fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint smb_string_decode(smb_string_t *, char *, size_t);
107b819ceaGordon Ross#endif /* !_KERNEL */
108b819ceaGordon Ross
109b819ceaGordon Ross/* libfksmbsrv "kdoor" callback to smbd-d */
110b819ceaGordon Rosstypedef int fksmb_kdoor_disp_func_t(smb_doorarg_t *);
111b819ceaGordon Ross
112b819ceaGordon Ross/* libfksmbsrv "opipe" callback to smbd-d */
113b819ceaGordon Rosstypedef int fksmb_opipe_disp_func_t(door_arg_t *);
1149fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
115148c5f4Alan Wright/*
116148c5f4Alan Wright * Legacy door interface
117148c5f4Alan Wright */
118148c5f4Alan Wright#define	SMB_SHARE_DNAME		"/var/run/smb_share_door"
119148c5f4Alan Wright#define	SMB_SHARE_DSIZE		(65 * 1024)
120148c5f4Alan Wright
121148c5f4Alan Wright/*
122148c5f4Alan Wright * door operations
123148c5f4Alan Wright */
124148c5f4Alan Wright#define	SMB_SHROP_NUM_SHARES		1
125148c5f4Alan Wright#define	SMB_SHROP_DELETE		2
126148c5f4Alan Wright#define	SMB_SHROP_RENAME		3
127148c5f4Alan Wright#define	SMB_SHROP_ADD			4
128148c5f4Alan Wright#define	SMB_SHROP_MODIFY		5
129148c5f4Alan Wright#define	SMB_SHROP_LIST			6
130148c5f4Alan Wright
131148c5f4Alan Wright/*
132148c5f4Alan Wright * Door server status
133148c5f4Alan Wright *
134148c5f4Alan Wright * SMB_SHARE_DERROR is returned by the door server if there is problem
135148c5f4Alan Wright * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is
136148c5f4Alan Wright * returned.
137148c5f4Alan Wright *
138148c5f4Alan Wright */
139148c5f4Alan Wright#define	SMB_SHARE_DSUCCESS		0
140148c5f4Alan Wright#define	SMB_SHARE_DERROR		-1
141148c5f4Alan Wright
1429fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statestypedef struct smb_dr_ctx {
1439fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	char *ptr;
1449fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	char *start_ptr;
1459fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	char *end_ptr;
1469fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States	int status;
1479fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States} smb_dr_ctx_t;
1489fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1499fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statessmb_dr_ctx_t *smb_dr_decode_start(char *, int);
1509fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint smb_dr_decode_finish(smb_dr_ctx_t *);
1519fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1529fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statessmb_dr_ctx_t *smb_dr_encode_start(char *, int);
1539fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint smb_dr_encode_finish(smb_dr_ctx_t *, unsigned int *);
1549fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1559fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint32_t smb_dr_get_int32(smb_dr_ctx_t *);
1569fb67eaafshin salek ardakani - Sun Microsystems - Irvine United StatesDWORD smb_dr_get_dword(smb_dr_ctx_t *);
1579fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesuint32_t smb_dr_get_uint32(smb_dr_ctx_t *);
1589fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint64_t smb_dr_get_int64(smb_dr_ctx_t *);
1599fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesuint64_t smb_dr_get_uint64(smb_dr_ctx_t *);
1609fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesunsigned short smb_dr_get_ushort(smb_dr_ctx_t *);
1619fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1629fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_int32(smb_dr_ctx_t *, int32_t);
1639fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_dword(smb_dr_ctx_t *, DWORD);
1649fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_uint32(smb_dr_ctx_t *, uint32_t);
1659fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_int64(smb_dr_ctx_t *, int64_t);
1669fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_uint64(smb_dr_ctx_t *, uint64_t);
1679fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_ushort(smb_dr_ctx_t *, unsigned short);
1689fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1699fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Stateschar *smb_dr_get_string(smb_dr_ctx_t *);
1709fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_string(smb_dr_ctx_t *, const char *);
1719fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_free_string(char *);
1729fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1739fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_word(smb_dr_ctx_t *, WORD);
1749fb67eaafshin salek ardakani - Sun Microsystems - Irvine United StatesWORD smb_dr_get_word(smb_dr_ctx_t *);
1759fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1769fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_BYTE(smb_dr_ctx_t *, BYTE);
1779fb67eaafshin salek ardakani - Sun Microsystems - Irvine United StatesBYTE smb_dr_get_BYTE(smb_dr_ctx_t *);
1789fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
1799fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesvoid smb_dr_put_buf(smb_dr_ctx_t *, unsigned char *, int);
1809fb67eaafshin salek ardakani - Sun Microsystems - Irvine United Statesint smb_dr_get_buf(smb_dr_ctx_t *, unsigned char *, int);
1819fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States
182148c5f4Alan Wrightvoid smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *);
183148c5f4Alan Wrightvoid smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *);
184148c5f4Alan Wright
185148c5f4Alan Wrightvoid smb_share_door_clnt_init(void);
186148c5f4Alan Wrightvoid smb_share_door_clnt_fini(void);
187148c5f4Alan Wright
1889fb67eaafshin salek ardakani - Sun Microsystems - Irvine United States#ifdef __cplusplus
189