Mercurial > illumos > illumos-gate
annotate usr/src/lib/smbsrv/libsmbrdr/common/smbrdr.h @ 10717:fe0545fc3cdd
6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
6877755 smbd should not route stderr, stdout to /dev/null
6882701 Wrong error message for attempt to map local user to Windows group, or vice versa
6885105 Potential for deadlock in smb_node_set_delete_on_close()
6881928 smbd core generated when running a script to join domain, set abe properties
6885538 Reduce dependencies on libsmbrdr
6820325 cifs service can't start on multi vlan+ipmp configuration
author | Alan Wright <amw@Sun.COM> |
---|---|
date | Mon, 05 Oct 2009 11:03:34 -0700 |
parents | ee04788f8605 |
children | 37e5dcdf36d3 |
rev | line source |
---|---|
5331 | 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 /* | |
8670
6da349c3f817
6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents:
8334
diff
changeset
|
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
5331 | 23 * Use is subject to license terms. |
24 */ | |
25 | |
26 #ifndef _SMBRDR_H_ | |
27 #define _SMBRDR_H_ | |
28 | |
29 #include <stdio.h> | |
30 #include <stdlib.h> | |
31 #include <syslog.h> | |
32 #include <synch.h> | |
33 #include <sys/types.h> | |
34 | |
10504
ee04788f8605
6861127 Want an RPC function to get the session key
Keyur Desai <Keyur.Desai@Sun.COM>
parents:
8670
diff
changeset
|
35 #include <smbsrv/libsmb.h> |
5331 | 36 #include <smbsrv/libsmbrdr.h> |
37 | |
38 #include <smbsrv/cifs.h> | |
39 #include <smbsrv/smbinfo.h> | |
40 #include <smbsrv/smb.h> | |
41 #include <smbsrv/wintypes.h> | |
42 | |
43 #define SMBRDR_REQ_BUFSZ 4096 | |
44 | |
45 #define MAX_ACCOUNT_NAME 32 | |
46 #define MAX_SHARE_NAME 32 | |
47 #define MAX_SCOPE_NAME 64 | |
48 #define MAX_FILE_PATH 128 | |
49 | |
50 /* | |
51 * The number of shares and pipes is limited to 48 based on the note | |
52 * below. This really shouldn't cause a problem because we always | |
53 * our shares and named pipes are always opened and closed round every | |
54 * RPC transaction. This also tends to limit the number of active | |
55 * logons because we (currently) need two named pipes per logon. | |
56 * | |
57 * Q141709 Limit of 49 named pipe connections from a single workstation. | |
58 * If a named pipe server creates more than 49 distincly named pipes, a | |
59 * single client cannot connect more than 49 pipes on the named pipe | |
60 * server. Chapter 4, p113. Network Programming for Microsoft Windows | |
61 * Anthony Jones and Jim Ohlund, Microsoft Press, ISBN: 0-7356-0560-2 | |
62 */ | |
7814
fba22078b05d
6758462 CIFS AD authentication fails spuriously, requires manual restart
afshin salek ardakani - Sun Microsystems - Irvine United States <Afshin.Ardakani@Sun.COM>
parents:
7052
diff
changeset
|
63 #define N_NETUSE_TABLE 256 |
fba22078b05d
6758462 CIFS AD authentication fails spuriously, requires manual restart
afshin salek ardakani - Sun Microsystems - Irvine United States <Afshin.Ardakani@Sun.COM>
parents:
7052
diff
changeset
|
64 #define N_OFILE_TABLE 256 |
5331 | 65 |
66 /* | |
67 * Logon's states | |
68 */ | |
69 #define SDB_LSTATE_START 0 | |
70 #define SDB_LSTATE_INIT 1 | |
71 #define SDB_LSTATE_LOGGING_OFF 2 | |
72 #define SDB_LSTATE_SETUP 3 | |
73 | |
74 #define SDB_LOGON_NONE 0 | |
75 #define SDB_LOGON_GUEST 1 | |
76 #define SDB_LOGON_ANONYMOUS 2 | |
77 #define SDB_LOGON_USER 3 | |
78 | |
79 typedef struct sdb_logon { | |
80 struct sdb_session *session; | |
81 char username[MAX_ACCOUNT_NAME]; | |
82 unsigned short uid; | |
83 unsigned int type; | |
84 unsigned short state; | |
85 smb_auth_info_t auth; | |
10504
ee04788f8605
6861127 Want an RPC function to get the session key
Keyur Desai <Keyur.Desai@Sun.COM>
parents:
8670
diff
changeset
|
86 unsigned char ssn_key[SMBAUTH_SESSION_KEY_SZ]; |
5331 | 87 } sdb_logon_t; |
88 | |
89 /* | |
90 * Session's states | |
91 * | |
92 * SDB_SSTATE_START ready to be used | |
93 * SDB_SSTATE_INIT initialized | |
94 * SDB_SSTATE_STALE lost transport connection | |
95 * SDB_SSTATE_DISCONNECTING disconnecting: logoff the user | |
96 * disconnect trees, close files | |
97 * SDB_SSTATE_CLEANING was in STALE state now just | |
98 * cleaning up | |
99 * SDB_SSTATE_CONNECTED got transport connection | |
100 * SDB_SSTATE_NEGOTIATED did SMB negotiate | |
101 */ | |
102 #define SDB_SSTATE_START 0 | |
103 #define SDB_SSTATE_INIT 1 | |
104 #define SDB_SSTATE_STALE 2 | |
105 #define SDB_SSTATE_DISCONNECTING 3 | |
106 #define SDB_SSTATE_CLEANING 4 | |
107 #define SDB_SSTATE_CONNECTED 5 | |
108 #define SDB_SSTATE_NEGOTIATED 6 | |
109 | |
110 #define SDB_SLCK_READ 1 | |
111 #define SDB_SLCK_WRITE 2 | |
112 | |
113 struct sdb_session { | |
8334
5f1c6a3b0fad
6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents:
7814
diff
changeset
|
114 char srv_name[MAXHOSTNAMELEN]; |
8670
6da349c3f817
6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents:
8334
diff
changeset
|
115 smb_inaddr_t srv_ipaddr; |
8334
5f1c6a3b0fad
6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents:
7814
diff
changeset
|
116 char domain[MAXHOSTNAMELEN]; |
5331 | 117 char scope[SMB_PI_MAX_SCOPE]; |
118 char native_os[SMB_PI_MAX_NATIVE_OS]; | |
119 char native_lanman[SMB_PI_MAX_LANMAN]; | |
120 int sock; | |
121 short port; | |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
122 uint16_t secmode; |
5331 | 123 uint32_t sesskey; |
124 uint32_t challenge_len; | |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
125 uint8_t challenge_key[32]; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
126 uint8_t smb_flags; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
127 uint16_t smb_flags2; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
128 uint16_t vc; |
5331 | 129 uint32_t remote_caps; |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
130 uint8_t state; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
131 uint32_t sid; /* session id */ |
5331 | 132 int remote_os; |
133 int remote_lm; | |
134 int pdc_type; | |
135 smb_sign_ctx_t sign_ctx; | |
136 sdb_logon_t logon; | |
137 rwlock_t rwl; | |
138 }; | |
139 | |
140 /* | |
141 * Netuse's states | |
142 */ | |
143 #define SDB_NSTATE_START 0 | |
144 #define SDB_NSTATE_INIT 1 | |
145 #define SDB_NSTATE_DISCONNECTING 2 | |
146 #define SDB_NSTATE_CONNECTED 3 | |
147 | |
148 struct sdb_netuse { | |
149 struct sdb_session *session; | |
150 unsigned short state; | |
151 int letter; /* local identity */ | |
152 unsigned int sid; | |
153 unsigned short uid; | |
154 unsigned short tid; /* remote identity */ | |
155 char share[MAX_SHARE_NAME]; | |
156 mutex_t mtx; | |
157 }; | |
158 | |
159 /* | |
160 * Ofile's states | |
161 */ | |
162 #define SDB_FSTATE_START 0 | |
163 #define SDB_FSTATE_INIT 1 | |
164 #define SDB_FSTATE_CLOSING 2 | |
165 #define SDB_FSTATE_OPEN 3 | |
166 | |
167 struct sdb_ofile { | |
168 struct sdb_session *session; | |
169 struct sdb_netuse *netuse; | |
170 unsigned short state; | |
171 unsigned int sid; | |
172 unsigned short uid; | |
173 unsigned short tid; | |
174 unsigned short fid; /* remote identity */ | |
175 char path[MAX_FILE_PATH]; | |
176 mutex_t mtx; | |
177 }; | |
178 | |
179 typedef struct smbrdr_handle { | |
180 unsigned char *srh_buf; | |
181 smb_msgbuf_t srh_mbuf; | |
182 unsigned int srh_mbflags; | |
183 unsigned char srh_cmd; | |
184 struct sdb_session *srh_session; | |
185 struct sdb_logon *srh_user; | |
186 struct sdb_netuse *srh_tree; | |
187 } smbrdr_handle_t; | |
188 | |
189 /* | |
190 * smbrdr_netbios.c | |
191 */ | |
192 void nb_lock(void); | |
193 void nb_unlock(void); | |
194 void nb_close(int); | |
7052 | 195 int nb_keep_alive(int, short); |
5331 | 196 |
197 int nb_send(int, unsigned char *, unsigned); | |
198 int nb_rcv(int, unsigned char *, unsigned, long); | |
199 int nb_exchange(int, unsigned char *, unsigned, | |
200 unsigned char *, unsigned, long); | |
201 int nb_session_request(int, char *, char *, char *, char *); | |
202 | |
203 /* | |
204 * smbrdr_session.c | |
205 */ | |
8334
5f1c6a3b0fad
6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents:
7814
diff
changeset
|
206 int smbrdr_negotiate(char *, char *); |
10717
fe0545fc3cdd
6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents:
10504
diff
changeset
|
207 struct sdb_session *smbrdr_session_lock(const char *, const char *, int); |
5331 | 208 void smbrdr_session_unlock(struct sdb_session *); |
209 | |
210 /* | |
211 * smbrdr_logon.c | |
212 */ | |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
213 int smbrdr_logoffx(struct sdb_logon *); |
5331 | 214 |
215 /* smbrdr_netuse.c */ | |
216 void smbrdr_netuse_logoff(unsigned short); | |
217 struct sdb_netuse *smbrdr_netuse_get(int); | |
7052 | 218 DWORD smbrdr_tree_connect(char *, char *, char *, unsigned short *); |
5331 | 219 int smbrdr_tree_disconnect(unsigned short); |
220 void smbrdr_netuse_put(struct sdb_netuse *); | |
7814
fba22078b05d
6758462 CIFS AD authentication fails spuriously, requires manual restart
afshin salek ardakani - Sun Microsystems - Irvine United States <Afshin.Ardakani@Sun.COM>
parents:
7052
diff
changeset
|
221 int smbrdr_tdcon(struct sdb_netuse *); |
5331 | 222 |
223 /* | |
224 * smbrdr_rpcpipe.c | |
225 */ | |
226 void smbrdr_ofile_end_of_share(unsigned short); | |
227 struct sdb_ofile *smbrdr_ofile_get(int); | |
228 void smbrdr_ofile_put(struct sdb_ofile *); | |
229 | |
230 /* smbrdr_lib.c */ | |
231 DWORD smbrdr_request_init(smbrdr_handle_t *, unsigned char, | |
232 struct sdb_session *, struct sdb_logon *, struct sdb_netuse *); | |
233 DWORD smbrdr_send(smbrdr_handle_t *); | |
234 DWORD smbrdr_rcv(smbrdr_handle_t *, int); | |
235 DWORD smbrdr_exchange(smbrdr_handle_t *, smb_hdr_t *, long); | |
236 void smbrdr_handle_free(smbrdr_handle_t *); | |
237 int smbrdr_sign_init(struct sdb_session *, struct sdb_logon *); | |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
238 void smbrdr_sign_fini(struct sdb_session *); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5331
diff
changeset
|
239 void smbrdr_sign_unset_key(struct sdb_session *); |
5331 | 240 |
241 void smbrdr_lock_transport(void); | |
242 void smbrdr_unlock_transport(void); | |
243 | |
244 #endif /* _SMBRDR_H_ */ |