1da6c28aaSamw /*
2da6c28aaSamw  * CDDL HEADER START
3da6c28aaSamw  *
4da6c28aaSamw  * The contents of this file are subject to the terms of the
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * You may not use this file except in compliance with the License.
7da6c28aaSamw  *
8da6c28aaSamw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw  * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw  * See the License for the specific language governing permissions
11da6c28aaSamw  * and limitations under the License.
12da6c28aaSamw  *
13da6c28aaSamw  * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw  * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw  * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw  * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw  *
19da6c28aaSamw  * CDDL HEADER END
20da6c28aaSamw  */
21148c5f43SAlan Wright 
22da6c28aaSamw /*
23c5866007SKeyur Desai  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24*ce8560eeSMatt Barden  * Copyright 2020 Tintri by DDN, Inc. All rights reserved.
254e065a9fSAlexander Stetsenko  * Copyright 2020 RackTop Systems, Inc.
26da6c28aaSamw  */
27da6c28aaSamw 
28da6c28aaSamw #ifndef	_LIBSMB_H
29da6c28aaSamw #define	_LIBSMB_H
30da6c28aaSamw 
31da6c28aaSamw #ifdef	__cplusplus
32da6c28aaSamw extern "C" {
33da6c28aaSamw #endif
34da6c28aaSamw 
35da6c28aaSamw #include <sys/types.h>
36a44e7c2cSGordon Ross #include <sys/inttypes.h>
377b59d02dSjb #include <sys/list.h>
389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <sys/avl.h>
39da6c28aaSamw #include <arpa/inet.h>
40b819cea2SGordon Ross #include <net/if.h>	/* LIFNAMSIZ */
41dc20a302Sas #include <netdb.h>
42da6c28aaSamw #include <stdlib.h>
43da6c28aaSamw #include <libscf.h>
44da6c28aaSamw #include <libshare.h>
451fcced4cSJordan Brown #include <uuid/uuid.h>
469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <synch.h>
47b819cea2SGordon Ross #include <stdarg.h>
48da6c28aaSamw 
493299f39fSGordon Ross #include <smb/nterror.h>
503299f39fSGordon Ross #include <smb/ntstatus.h>
513299f39fSGordon Ross #include <smb/wintypes.h>
523299f39fSGordon Ross 
53dc20a302Sas #include <smbsrv/string.h>
54da6c28aaSamw #include <smbsrv/smb_idmap.h>
557b59d02dSjb #include <smbsrv/netbios.h>
563db3f65cSamw #include <smbsrv/smb_share.h>
579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/smb_door.h>
58da6c28aaSamw #include <smbsrv/alloc.h>
59da6c28aaSamw #include <smbsrv/hash_table.h>
60da6c28aaSamw #include <smbsrv/msgbuf.h>
61da6c28aaSamw #include <smbsrv/smb_xdr.h>
62da6c28aaSamw #include <smbsrv/smbinfo.h>
6329bd2886SAlan Wright #include <smbsrv/ntifs.h>
64da6c28aaSamw 
65148c5f43SAlan Wright #define	SMB_VARSMB_DIR "/var/smb"
66faa1795aSjb #define	SMB_VARRUN_DIR "/var/run/smb"
67faa1795aSjb #define	SMB_CCACHE_FILE "ccache"
68faa1795aSjb #define	SMB_CCACHE_PATH SMB_VARRUN_DIR "/" SMB_CCACHE_FILE
69faa1795aSjb 
708d7e4166Sjose borrego 
71da6c28aaSamw /* Max value length of all SMB properties */
72da6c28aaSamw #define	MAX_VALUE_BUFLEN	512
73da6c28aaSamw 
74da6c28aaSamw #define	SMBD_FMRI_PREFIX		"network/smb/server"
75da6c28aaSamw #define	SMBD_DEFAULT_INSTANCE_FMRI	"svc:/network/smb/server:default"
76da6c28aaSamw #define	SMBD_PG_NAME			"smbd"
77da6c28aaSamw #define	SMBD_PROTECTED_PG_NAME		"read"
7829bd2886SAlan Wright #define	SMBD_EXEC_PG_NAME		"exec"
79da6c28aaSamw 
80da6c28aaSamw #define	SMBD_SMF_OK		0
81da6c28aaSamw #define	SMBD_SMF_NO_MEMORY	1	/* no memory for data structures */
82da6c28aaSamw #define	SMBD_SMF_SYSTEM_ERR	2	/* system error, use errno */
83da6c28aaSamw #define	SMBD_SMF_NO_PERMISSION	3	/* no permission for operation */
84dc20a302Sas #define	SMBD_SMF_INVALID_ARG	4
85da6c28aaSamw 
86da6c28aaSamw #define	SCH_STATE_UNINIT	0
87da6c28aaSamw #define	SCH_STATE_INITIALIZING	1
88da6c28aaSamw #define	SCH_STATE_INIT		2
89da6c28aaSamw 
90da6c28aaSamw typedef struct smb_scfhandle {
91da6c28aaSamw 	scf_handle_t		*scf_handle;
92da6c28aaSamw 	int			scf_state;
93da6c28aaSamw 	scf_service_t		*scf_service;
94da6c28aaSamw 	scf_scope_t		*scf_scope;
95da6c28aaSamw 	scf_transaction_t	*scf_trans;
96da6c28aaSamw 	scf_transaction_entry_t	*scf_entry;
97da6c28aaSamw 	scf_propertygroup_t	*scf_pg;
98da6c28aaSamw 	scf_instance_t		*scf_instance;
99da6c28aaSamw 	scf_iter_t		*scf_inst_iter;
100da6c28aaSamw 	scf_iter_t		*scf_pg_iter;
101da6c28aaSamw } smb_scfhandle_t;
102da6c28aaSamw 
103da6c28aaSamw /*
104da6c28aaSamw  * CIFS Configuration Management
105da6c28aaSamw  */
106da6c28aaSamw typedef enum {
1079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_CI_VERSION = 0,
1089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_CI_OPLOCK_ENABLE,
109da6c28aaSamw 
110da6c28aaSamw 	SMB_CI_AUTOHOME_MAP,
111da6c28aaSamw 
112da6c28aaSamw 	SMB_CI_DOMAIN_SID,
113da6c28aaSamw 	SMB_CI_DOMAIN_MEMB,
114da6c28aaSamw 	SMB_CI_DOMAIN_NAME,
1158d7e4166Sjose borrego 	SMB_CI_DOMAIN_FQDN,
1168d7e4166Sjose borrego 	SMB_CI_DOMAIN_FOREST,
1178d7e4166Sjose borrego 	SMB_CI_DOMAIN_GUID,
118da6c28aaSamw 	SMB_CI_DOMAIN_SRV,
119da6c28aaSamw 
120da6c28aaSamw 	SMB_CI_WINS_SRV1,
121da6c28aaSamw 	SMB_CI_WINS_SRV2,
122da6c28aaSamw 	SMB_CI_WINS_EXCL,
123da6c28aaSamw 
124da6c28aaSamw 	SMB_CI_MAX_WORKERS,
125da6c28aaSamw 	SMB_CI_MAX_CONNECTIONS,
126da6c28aaSamw 	SMB_CI_KEEPALIVE,
127da6c28aaSamw 	SMB_CI_RESTRICT_ANON,
128da6c28aaSamw 
129da6c28aaSamw 	SMB_CI_SIGNING_ENABLE,
130da6c28aaSamw 	SMB_CI_SIGNING_REQD,
131da6c28aaSamw 
132da6c28aaSamw 	SMB_CI_SYNC_ENABLE,
133da6c28aaSamw 
134da6c28aaSamw 	SMB_CI_SECURITY,
13583d2dfe6SGordon Ross 	SMB_CI_NETBIOS_ENABLE,
136da6c28aaSamw 	SMB_CI_NBSCOPE,
137da6c28aaSamw 	SMB_CI_SYS_CMNT,
138da6c28aaSamw 	SMB_CI_LM_LEVEL,
139da6c28aaSamw 
140da6c28aaSamw 	SMB_CI_ADS_SITE,
141da6c28aaSamw 
142da6c28aaSamw 	SMB_CI_DYNDNS_ENABLE,
143da6c28aaSamw 
144da6c28aaSamw 	SMB_CI_MACHINE_PASSWD,
14512b65585SGordon Ross 	SMB_CI_MACHINE_UUID,
146faa1795aSjb 	SMB_CI_KPASSWD_SRV,
147faa1795aSjb 	SMB_CI_KPASSWD_DOMAIN,
148faa1795aSjb 	SMB_CI_KPASSWD_SEQNUM,
149faa1795aSjb 	SMB_CI_NETLOGON_SEQNUM,
1507f667e74Sjose borrego 	SMB_CI_IPV6_ENABLE,
151cb174861Sjoyce mcintosh 	SMB_CI_PRINT_ENABLE,
15229bd2886SAlan Wright 	SMB_CI_MAP,
15329bd2886SAlan Wright 	SMB_CI_UNMAP,
15429bd2886SAlan Wright 	SMB_CI_DISPOSITION,
155148c5f43SAlan Wright 	SMB_CI_DFS_STDROOT_NUM,
1565f1ef25cSAram Hăvărneanu 	SMB_CI_TRAVERSE_MOUNTS,
157a90cf9f2SGordon Ross 	SMB_CI_SMB2_ENABLE_OLD, /* obsolete */
158a90cf9f2SGordon Ross 	SMB_CI_INITIAL_CREDITS,
159a90cf9f2SGordon Ross 	SMB_CI_MAXIMUM_CREDITS,
160a90cf9f2SGordon Ross 	SMB_CI_MAX_PROTOCOL,
1611160dcf7SMatt Barden 	SMB_CI_ENCRYPT,
1623e2c0c09SMatt Barden 	SMB_CI_MIN_PROTOCOL,
163cc3780e6SGordon Ross 	SMB_CI_BYPASS_TRAVERSE_CHECKING,
1644e065a9fSAlexander Stetsenko 	SMB_CI_ENCRYPT_CIPHER,
165*ce8560eeSMatt Barden 	SMB_CI_NETLOGON_FLAGS,
16683d2dfe6SGordon Ross 
167da6c28aaSamw 	SMB_CI_MAX
168da6c28aaSamw } smb_cfg_id_t;
169da6c28aaSamw 
170da6c28aaSamw /* SMF helper functions */
171da6c28aaSamw extern smb_scfhandle_t *smb_smf_scf_init(char *);
172da6c28aaSamw extern void smb_smf_scf_fini(smb_scfhandle_t *);
173da6c28aaSamw extern int smb_smf_start_transaction(smb_scfhandle_t *);
174da6c28aaSamw extern int smb_smf_end_transaction(smb_scfhandle_t *);
175da6c28aaSamw extern int smb_smf_set_string_property(smb_scfhandle_t *, char *, char *);
176da6c28aaSamw extern int smb_smf_get_string_property(smb_scfhandle_t *, char *,
177da6c28aaSamw     char *, size_t);
178da6c28aaSamw extern int smb_smf_set_integer_property(smb_scfhandle_t *, char *, int64_t);
179da6c28aaSamw extern int smb_smf_get_integer_property(smb_scfhandle_t *, char *, int64_t *);
180da6c28aaSamw extern int smb_smf_set_boolean_property(smb_scfhandle_t *, char *, uint8_t);
181da6c28aaSamw extern int smb_smf_get_boolean_property(smb_scfhandle_t *, char *, uint8_t *);
182