xref: /titanic_50/usr/src/cmd/smbsrv/smbd/smbd.h (revision 359db861fd14071f8a25831efe3bf3790980d071)
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 2013 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #ifndef _SMBD_H
28 #define	_SMBD_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/types.h>
35 #include <thread.h>
36 #include <synch.h>
37 #include <smbsrv/smb_ioctl.h>
38 #include <smbsrv/smb_token.h>
39 #include <smbsrv/libsmb.h>
40 #include <smbsrv/libmlsvc.h>
41 
42 void smbd_report(const char *fmt, ...);
43 int smbd_pipesvc_start(void);
44 void smbd_pipesvc_stop(void);
45 int smbd_share_start(void);
46 void smbd_share_stop(void);
47 int smbd_nicmon_start(const char *);
48 void smbd_nicmon_stop(void);
49 int smbd_nicmon_refresh(void);
50 int smbd_dc_monitor_init(void);
51 void smbd_dc_monitor_refresh(void);
52 smb_token_t *smbd_user_auth_logon(smb_logon_t *);
53 void smbd_user_nonauth_logon(uint32_t);
54 void smbd_user_auth_logoff(uint32_t);
55 uint32_t smbd_join(smb_joininfo_t *);
56 void smbd_set_secmode(int);
57 boolean_t smbd_online(void);
58 void smbd_online_wait(const char *);
59 
60 void smbd_spool_start(void);
61 void smbd_spool_stop(void);
62 int smbd_cups_init(void);
63 void smbd_cups_fini(void);
64 void smbd_load_printers(void);
65 
66 int smbd_vss_get_count(const char *, uint32_t *);
67 void smbd_vss_get_snapshots(const char *, uint32_t, uint32_t *,
68     uint32_t *, char **);
69 int smbd_vss_map_gmttoken(const char *, char *, char *);
70 
71 typedef struct smbd {
72 	const char	*s_version;	/* smbd version string */
73 	const char	*s_pname;	/* basename to use for messages */
74 	pid_t		s_pid;		/* process-ID of current daemon */
75 	uid_t		s_uid;		/* UID of current daemon */
76 	gid_t		s_gid;		/* GID of current daemon */
77 	int		s_fg;		/* Run in foreground */
78 	int		s_debug;	/* Enable debug output */
79 	int		s_dbg_stop;	/* stop for debugger attach */
80 	boolean_t	s_initialized;
81 	boolean_t	s_shutting_down; /* shutdown control */
82 	volatile uint_t	s_refreshes;
83 	boolean_t	s_kbound;	/* B_TRUE if bound to kernel */
84 	int		s_door_lmshr;
85 	int		s_door_srv;
86 	int		s_door_opipe;
87 	int		s_secmode;	/* Current security mode */
88 	char		s_site[MAXHOSTNAMELEN];
89 	smb_inaddr_t	s_pdc;
90 	boolean_t	s_pdc_changed;
91 	pthread_t	s_refresh_tid;
92 	pthread_t	s_localtime_tid;
93 	pthread_t	s_spool_tid;
94 	pthread_t	s_dc_monitor_tid;
95 	boolean_t	s_nbt_listener_running;
96 	boolean_t	s_tcp_listener_running;
97 	pthread_t	s_nbt_listener_id;
98 	pthread_t	s_tcp_listener_id;
99 	boolean_t	s_fatal_error;
100 } smbd_t;
101 
102 extern smbd_t smbd;
103 
104 #define	SMBD_LOG_MSGSIZE	256
105 
106 #define	SMBD_DOOR_NAMESZ	16
107 
108 typedef struct smbd_door {
109 	mutex_t		sd_mutex;
110 	cond_t		sd_cv;
111 	uint32_t	sd_ncalls;
112 	char		sd_name[SMBD_DOOR_NAMESZ];
113 } smbd_door_t;
114 
115 #define	SMBD_ARG_MAGIC		0x53415247	/* 'SARG' */
116 
117 /*
118  * Parameter for door operations.
119  */
120 typedef struct smbd_arg {
121 	uint32_t	magic;
122 	list_node_t	lnd;
123 	smb_doorhdr_t	hdr;
124 	const char	*opname;
125 	char		*data;
126 	size_t		datalen;
127 	char		*rbuf;
128 	size_t		rsize;
129 	boolean_t	response_ready;
130 	boolean_t	response_abort;
131 	uint32_t	status;
132 } smbd_arg_t;
133 
134 int smbd_door_start(void);
135 void smbd_door_stop(void);
136 void smbd_door_init(smbd_door_t *, const char *);
137 void smbd_door_fini(smbd_door_t *);
138 void smbd_door_enter(smbd_door_t *);
139 void smbd_door_return(smbd_door_t *, char *, size_t, door_desc_t *, uint_t);
140 
141 void *smbd_door_dispatch_op(void *);
142 
143 /* For fksmbd */
144 void fksmbd_init(void);
145 int fksmbd_door_dispatch(smb_doorarg_t *);
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* _SMBD_H */
152