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