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 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright 2020 Tintri by DDN, Inc.  All rights reserved.
25  * Copyright 2022 RackTop Systems, Inc.
26  */
27 
28 /*
29  * Function prototypes needed by the "testoplock" program
30  * (a small subset of what the SMB server uses)
31  */
32 
33 #ifndef _SMB_KPROTO_H_
34 #define	_SMB_KPROTO_H_
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <sys/varargs.h>
43 #include <sys/cmn_err.h>
44 #include <smbsrv/smb.h>
45 #include <smbsrv/smb_ktypes.h>
46 
47 boolean_t smb_ofile_is_open(smb_ofile_t *);
48 boolean_t smb_node_is_file(smb_node_t *);
49 
50 /*
51  * SMB locked list function prototypes
52  */
53 void	smb_llist_init(void);
54 void	smb_llist_fini(void);
55 void	smb_llist_constructor(smb_llist_t *, size_t, size_t);
56 void	smb_llist_destructor(smb_llist_t *);
57 void	smb_llist_enter(smb_llist_t *ll, krw_t);
58 void	smb_llist_exit(smb_llist_t *);
59 void	smb_llist_post(smb_llist_t *, void *, smb_dtorproc_t);
60 void	smb_llist_flush(smb_llist_t *);
61 void	smb_llist_insert_head(smb_llist_t *ll, void *obj);
62 void	smb_llist_insert_tail(smb_llist_t *ll, void *obj);
63 void	smb_llist_remove(smb_llist_t *ll, void *obj);
64 int	smb_llist_upgrade(smb_llist_t *ll);
65 uint32_t smb_llist_get_count(smb_llist_t *ll);
66 #define	smb_llist_head(ll)		list_head(&(ll)->ll_list)
67 #define	smb_llist_next(ll, obj)		list_next(&(ll)->ll_list, obj)
68 int	smb_account_connected(smb_user_t *user);
69 
70 /*
71  * Common oplock functions
72  */
73 uint32_t smb_oplock_request(smb_request_t *, smb_ofile_t *, uint32_t *);
74 uint32_t smb_oplock_request_LH(smb_request_t *, smb_ofile_t *, uint32_t *);
75 uint32_t smb_oplock_ack_break(smb_request_t *, smb_ofile_t *, uint32_t *);
76 uint32_t smb_oplock_break_PARENT(smb_node_t *, smb_ofile_t *);
77 uint32_t smb_oplock_break_OPEN(smb_node_t *, smb_ofile_t *,
78     uint32_t DesiredAccess, uint32_t CreateDisposition);
79 uint32_t smb_oplock_break_BATCH(smb_node_t *, smb_ofile_t *,
80     uint32_t DesiredAccess, uint32_t CreateDisposition);
81 uint32_t smb_oplock_break_HANDLE(smb_node_t *, smb_ofile_t *);
82 void smb_oplock_break_CLOSE(smb_node_t *, smb_ofile_t *);
83 uint32_t smb_oplock_break_READ(smb_node_t *, smb_ofile_t *);
84 uint32_t smb_oplock_break_WRITE(smb_node_t *, smb_ofile_t *);
85 uint32_t smb_oplock_break_SETINFO(smb_node_t *,
86     smb_ofile_t *ofile, uint32_t InfoClass);
87 uint32_t smb_oplock_break_DELETE(smb_node_t *, smb_ofile_t *);
88 void smb_oplock_close(smb_ofile_t *);
89 
90 void smb_oplock_ind_break(smb_ofile_t *, uint32_t, boolean_t, uint32_t);
91 void smb_oplock_ind_break_in_ack(smb_request_t *, smb_ofile_t *,
92     uint32_t, boolean_t);
93 void smb_oplock_send_break(smb_request_t *);
94 
95 uint32_t smb_oplock_wait_ack(smb_request_t *, uint32_t);
96 uint32_t smb_oplock_wait_break(smb_request_t *, smb_node_t *, int);
97 uint32_t smb_oplock_wait_break_fem(smb_node_t *, int);
98 
99 void smb_oplock_move(smb_node_t *, smb_ofile_t *, smb_ofile_t *);
100 
101 /*
102  * Protocol-specific oplock functions
103  * (not needed here)
104  */
105 
106 int smb_lock_range_access(smb_request_t *, smb_node_t *,
107     uint64_t, uint64_t, boolean_t);
108 
109 int smb_fem_oplock_install(smb_node_t *);
110 void smb_fem_oplock_uninstall(smb_node_t *);
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif /* _SMB_KPROTO_H_ */
117