2 Unix SMB/Netbios implementation.
4 SMB parameters and setup
5 Copyright (C) Andrew Tridgell 1992-1997
6 Copyright (C) John H Terpstra 1996-1997
7 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
8 Copyright (C) Paul Ashton 1997
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #ifndef MAX_CONNECTIONS
28 #define MAX_CONNECTIONS 127
31 #ifndef MAX_OPEN_FILES
32 #define MAX_OPEN_FILES 50
36 #define GUEST_ACCOUNT "nobody"
39 #define BUFFER_SIZE (0xFFFF)
40 #define SAFETY_MARGIN 1024
42 /* Default size of shared memory used for share mode locking */
44 #define SHMEM_SIZE 102400
47 /* Default number of hash buckets used in shared memory share mode */
48 #ifndef SHMEM_HASH_SIZE
49 #define SHMEM_HASH_SIZE 113
53 #define DGRAM_PORT 138
58 #define BOOLSTR(b) ((b) ? "Yes" : "No")
59 #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
60 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
61 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
65 /* offset in shared memory */
66 typedef int smb_shm_offset_t;
67 #define NULL_OFFSET (smb_shm_offset_t)(0)
71 Samba needs type definitions for int16, int32, uint16 and uint32.
73 Normally these are signed and unsigned 16 and 32 bit integers, but
74 they actually only need to be at least 16 and 32 bits
75 respectively. Thus if your word size is 8 bytes just defining them
76 as signed and unsigned int will work.
79 /* afs/stds.h defines int16 and int32 */
86 typedef unsigned char uint8;
90 typedef unsigned short uint16;
94 typedef unsigned int uint32;
98 #define uchar unsigned char
104 #define uint16 unsigned short
107 #define uint32 unsigned int
112 #ifndef DEF_CREATE_MASK
113 #define DEF_CREATE_MASK (0755)
116 /* how long to wait for secondary SMB packets (milli-seconds) */
117 #define SMB_SECONDARY_WAIT (60*1000)
121 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
123 extern int syslog_level;
125 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
128 /* this defines the error codes that receive_smb can put in smb_read_error */
129 #define READ_TIMEOUT 1
134 #define DIR_STRUCT_SIZE 43
136 /* these define all the command types recognised by the server - there
137 are lots of gaps so probably there are some rare commands that are not
140 #define pSETDIR '\377'
142 /* these define the attribute byte as seen by DOS */
143 #define aRONLY (1L<<0)
144 #define aHIDDEN (1L<<1)
145 #define aSYSTEM (1L<<2)
146 #define aVOLID (1L<<3)
148 #define aARCH (1L<<5)
159 #define STYPE_DISKTREE 0 /* Disk drive */
160 #define STYPE_PRINTQ 1 /* Spooler queue */
161 #define STYPE_DEVICE 2 /* Serial device */
162 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
164 /* SMB X/Open error codes for the ERRdos error class */
165 #define ERRbadfunc 1 /* Invalid function (or system call) */
166 #define ERRbadfile 2 /* File not found (pathname error) */
167 #define ERRbadpath 3 /* Directory not found */
168 #define ERRnofids 4 /* Too many open files */
169 #define ERRnoaccess 5 /* Access denied */
170 #define ERRbadfid 6 /* Invalid fid */
171 #define ERRnomem 8 /* Out of memory */
172 #define ERRbadmem 9 /* Invalid memory block address */
173 #define ERRbadenv 10 /* Invalid environment */
174 #define ERRbadaccess 12 /* Invalid open mode */
175 #define ERRbaddata 13 /* Invalid data (only from ioctl call) */
176 #define ERRres 14 /* reserved */
177 #define ERRbaddrive 15 /* Invalid drive */
178 #define ERRremcd 16 /* Attempt to delete current directory */
179 #define ERRdiffdevice 17 /* rename/move across different filesystems */
180 #define ERRnofiles 18 /* no more files found in file search */
181 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
182 #define ERRlock 33 /* Lock request conflicts with existing lock */
183 #define ERRfilexists 80 /* File in operation already exists */
184 #define ERRcannotopen 110 /* Cannot open the file specified */
185 #define ERRunknownlevel 124
186 #define ERRbadpipe 230 /* Named pipe invalid */
187 #define ERRpipebusy 231 /* All instances of pipe are busy */
188 #define ERRpipeclosing 232 /* named pipe close in progress */
189 #define ERRnotconnected 233 /* No process on other end of named pipe */
190 #define ERRmoredata 234 /* More data to be returned */
191 #define ERRbaddirectory 267 /* Invalid directory name in a path. */
192 #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
193 #define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not supported */
194 #define ERRunknownipc 2142
197 /* here's a special one from observing NT */
198 #define ERRnoipc 66 /* don't support ipc */
200 /* Error codes for the ERRSRV class */
202 #define ERRerror 1 /* Non specific error code */
203 #define ERRbadpw 2 /* Bad password */
204 #define ERRbadtype 3 /* reserved */
205 #define ERRaccess 4 /* No permissions to do the requested operation */
206 #define ERRinvnid 5 /* tid invalid */
207 #define ERRinvnetname 6 /* Invalid servername */
208 #define ERRinvdevice 7 /* Invalid device */
209 #define ERRqfull 49 /* Print queue full */
210 #define ERRqtoobig 50 /* Queued item too big */
211 #define ERRinvpfid 52 /* Invalid print file in smb_fid */
212 #define ERRsmbcmd 64 /* Unrecognised command */
213 #define ERRsrverror 65 /* smb server internal error */
214 #define ERRfilespecs 67 /* fid and pathname invalid combination */
215 #define ERRbadlink 68 /* reserved */
216 #define ERRbadpermits 69 /* Access specified for a file is not valid */
217 #define ERRbadpid 70 /* reserved */
218 #define ERRsetattrmode 71 /* attribute mode invalid */
219 #define ERRpaused 81 /* Message server paused */
220 #define ERRmsgoff 82 /* Not receiving messages */
221 #define ERRnoroom 83 /* No room for message */
222 #define ERRrmuns 87 /* too many remote usernames */
223 #define ERRtimeout 88 /* operation timed out */
224 #define ERRnoresource 89 /* No resources currently available for request. */
225 #define ERRtoomanyuids 90 /* too many userids */
226 #define ERRbaduid 91 /* bad userid */
227 #define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
228 #define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
229 #define ERRcontMPX 252 /* resume MPX mode */
230 #define ERRbadPW /* reserved */
231 #define ERRnosupport 0xFFFF
232 #define ERRunknownsmb 22 /* from NT 3.5 response */
235 /* Error codes for the ERRHRD class */
237 #define ERRnowrite 19 /* read only media */
238 #define ERRbadunit 20 /* Unknown device */
239 #define ERRnotready 21 /* Drive not ready */
240 #define ERRbadcmd 22 /* Unknown command */
241 #define ERRdata 23 /* Data (CRC) error */
242 #define ERRbadreq 24 /* Bad request structure length */
244 #define ERRbadmedia 26
245 #define ERRbadsector 27
246 #define ERRnopaper 28
247 #define ERRwrite 29 /* write fault */
248 #define ERRread 30 /* read fault */
249 #define ERRgeneral 31 /* General hardware failure */
250 #define ERRwrongdisk 34
251 #define ERRFCBunavail 35
252 #define ERRsharebufexc 36 /* share buffer exceeded */
253 #define ERRdiskfull 39
256 typedef char pstring[1024];
257 typedef char fstring[128];
258 typedef fstring string;
261 /* NETLOGON opcodes and data structures */
263 #define NET_QUERYFORPDC 7 /* Query for PDC */
264 #define NET_QUERYFORPDC_R 12 /* Response to Query for PDC */
265 #define NET_SAMLOGON 18
266 #define NET_SAMLOGON_R 19
268 /* Allowable account control bits */
269 #define ACB_DISABLED 1 /* 1 = User account disabled */
270 #define ACB_HOMDIRREQ 2 /* 1 = Home directory required */
271 #define ACB_PWNOTREQ 4 /* 1 = User password not required */
272 #define ACB_TEMPDUP /* 1 = Temporary duplicate account */
273 #define ACB_NORMAL /* 1 = Normal user account */
274 #define ACB_MNS /* 1 = MNS logon user account */
275 #define ACB_DOMTRUST /* 1 = Interdomain trust account */
276 #define ACB_WSTRUST /* 1 = Workstation trust account */
277 #define ACB_SVRTRUST /* 1 = Server trust account */
278 #define ACB_PWNOEXP /* 1 = User password does not expire */
279 #define ACB_AUTOLOCK /* 1 = Account auto locked */
281 #define LSA_OPENPOLICY 0x2c
282 #define LSA_QUERYINFOPOLICY 0x07
283 #define LSA_ENUMTRUSTDOM 0x0d
284 #define LSA_REQCHAL 0x04
285 #define LSA_SRVPWSET 0x06
286 #define LSA_SAMLOGON 0x02
287 #define LSA_AUTH2 0x0f
288 #define LSA_CLOSE 0x00
291 #define LSA_OPENSECRET 0xFF
292 #define LSA_LOOKUPSIDS 0xFE
293 #define LSA_LOOKUPNAMES 0xFD
294 #define LSA_SAMLOGOFF 0xFC
297 #define NETSERVERGETINFO 0x15
298 #define NETSHAREENUM 0x0f
300 /* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
301 typedef struct time_info
307 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
308 typedef struct nttime_info
316 #define MAXSUBAUTHS 10 /* max sub authorities in a SID */
318 /* DOM_SID - security id */
319 typedef struct sid_info
321 uint8 sid_no; /* SID revision number */
322 uint8 num_auths; /* number of sub-authorities */
323 uint8 id_auth[6]; /* Identifier Authority */
324 uint16 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
328 /* UNIHDR - unicode string header */
329 typedef struct unihdr_info
333 uint32 undoc; /* usually has a value of 4 */
337 /* UNIHDR2 - unicode string header and undocumented buffer */
338 typedef struct unihdr2_info
341 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
345 /* clueless as to what maximum length should be */
346 #define MAX_UNISTRLEN 1024
348 /* UNISTR - unicode string size and buffer */
349 typedef struct unistr_info
351 uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. ***MUST*** be null-terminated */
355 /* UNISTR2 - unicode string size and buffer */
356 typedef struct unistr2_info
361 uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. **NOT** necessarily null-terminated */
365 /* DOM_SID2 - domain SID structure - SIDs stored in unicode */
366 typedef struct domsid2_info
368 uint32 type; /* value is 5 */
369 uint32 undoc; /* value is 0 */
371 UNIHDR2 hdr; /* XXXX conflict between hdr and str for length */
372 UNISTR str; /* XXXX conflict between hdr and str for length */
376 /* DOM_RID2 - domain RID structure */
377 typedef struct domrid2_info
379 uint32 type; /* value is 5 */
380 uint32 undoc; /* value is 5 */
382 uint32 rid_idx; /* don't know what this is */
386 /* DOM_CLNT_SRV - client / server names */
387 typedef struct clnt_srv_info
389 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
390 UNISTR2 uni_logon_srv; /* logon server name */
391 uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */
392 UNISTR2 uni_comp_name; /* client machine name */
396 /* DOM_LOG_INFO - login info */
397 typedef struct log_info
399 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
400 UNISTR2 uni_logon_srv; /* logon server name */
401 UNISTR2 uni_acct_name; /* account name */
402 uint16 sec_chan; /* secure channel type */
403 UNISTR2 uni_comp_name; /* client machine name */
407 /* DOM_CHAL - challenge info */
408 typedef struct chal_info
410 uint32 data[2]; /* credentials */
414 /* DOM_CREDs - timestamped client or server credentials */
415 typedef struct cred_info
417 DOM_CHAL challenge; /* credentials */
418 UTIME timestamp; /* credential time-stamp */
422 /* DOM_CLNT_INFO - client info */
423 typedef struct clnt_info
430 /* DOM_CLNT_INFO2 - client info */
431 typedef struct clnt_info2
439 /* DOM_LOGON_ID - logon id */
440 typedef struct logon_info
448 typedef struct arc4_owf_info
456 typedef struct id_info_1
458 uint32 ptr_id_info1; /* pointer to id_info_1 */
459 UNIHDR hdr_domain_name; /* domain name unicode header */
460 uint32 param_ctrl; /* param control */
461 DOM_LOGON_ID logon_id; /* logon ID */
462 UNIHDR hdr_user_name; /* user name unicode header */
463 UNIHDR hdr_workgroup_name; /* workgroup name unicode header */
464 ARC4_OWF arc4_lm_owf; /* arc4 LM OWF Password */
465 ARC4_OWF arc4_nt_owf; /* arc4 NT OWF Password */
466 UNISTR2 uni_domain_name; /* domain name unicode string */
467 UNISTR2 uni_user_name; /* user name unicode string */
468 UNISTR2 uni_workgroup_name; /* workgroup name unicode string */
472 /* SAM_INFO - sam logon/off id structure */
473 typedef struct sam_info
475 DOM_CLNT_INFO2 client;
476 uint32 ptr_rtn_cred; /* pointer to return credentials */
477 DOM_CRED rtn_cred; /* return credentials */
483 DOM_ID_INFO_1 id1; /* auth-level 1 */
489 /* DOM_GID - group id + user attributes */
490 typedef struct gid_info
492 uint32 gid; /* group id */
497 /* RPC_HDR - ms rpc header */
498 typedef struct rpc_hdr_info
500 uint8 major; /* 5 - RPC major version */
501 uint8 minor; /* 0 - RPC minor version */
502 uint8 pkt_type; /* 2 - RPC response packet */
503 uint8 frag; /* 3 - first frag + last frag */
504 uint32 pack_type; /* 0x1000 0000 - packed data representation */
505 uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
506 uint16 auth_len; /* 0 - authentication length */
507 uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */
508 uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
509 uint16 context_id; /* 0 - presentation context identifier */
510 uint8 cancel_count; /* 0 - cancel count */
511 uint8 reserved; /* 0 - reserved */
515 /* DOM_QUERY - info class 3 and 5 LSA Query response */
516 typedef struct dom_query_info
518 uint16 uni_dom_max_len; /* domain name string length * 2 */
519 uint16 uni_dom_str_len; /* domain name string length * 2 */
520 uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */
521 uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */
522 UNISTR2 uni_domain_name; /* domain name (unicode string) */
523 DOM_SID dom_sid; /* domain SID */
527 /* level 5 is same as level 3. we hope. */
528 typedef DOM_QUERY DOM_QUERY_3;
529 typedef DOM_QUERY DOM_QUERY_5;
531 #define POL_HND_SIZE 20
534 typedef struct lsa_policy_info
536 uint8 data[POL_HND_SIZE]; /* policy handle */
541 /* LSA_R_OPEN_POL - response to LSA Open Policy */
542 typedef struct lsa_r_open_pol_info
544 LSA_POL_HND pol; /* policy handle */
546 uint32 status; /* return code */
550 /* LSA_Q_QUERY_INFO - LSA query info policy */
551 typedef struct lsa_query_info
553 LSA_POL_HND pol; /* policy handle */
554 uint16 info_class; /* info class */
558 /* LSA_R_QUERY_INFO - response to LSA query info policy */
559 typedef struct lsa_r_query_info
561 uint32 undoc_buffer; /* undocumented buffer pointer */
562 uint16 info_class; /* info class (same as info class in request) */
570 uint32 status; /* return code */
574 #define MAX_REF_DOMAINS 10
577 typedef struct dom_ref_info
579 uint32 undoc_buffer; /* undocumented buffer pointer. */
580 uint32 num_ref_doms_1; /* num referenced domains? */
581 uint32 buffer_dom_name; /* undocumented domain name buffer pointer. */
582 uint32 max_entries; /* 32 - max number of entries */
583 uint32 num_ref_doms_2; /* 4 - num referenced domains? */
585 UNIHDR2 hdr_dom_name; /* domain name unicode string header */
586 UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */
588 UNISTR uni_dom_name; /* domain name unicode string */
589 DOM_SID ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
593 #define MAX_LOOKUP_SIDS 10
595 /* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
596 typedef struct lsa_q_lookup_sids
598 LSA_POL_HND pol_hnd; /* policy handle */
600 uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
601 uint32 buffer_dom_name; /* undocumented domain name buffer pointer */
602 uint32 buffer_lookup_sids[MAX_LOOKUP_SIDS]; /* undocumented domain SID pointers to be looked up. */
603 DOM_SID dom_sids[MAX_LOOKUP_SIDS]; /* domain SIDs to be looked up. */
604 uint8 undoc[16]; /* completely undocumented 16 bytes */
608 /* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
609 typedef struct lsa_r_lookup_sids
611 DOM_R_REF dom_ref; /* domain reference info */
614 uint32 undoc_buffer; /* undocumented buffer pointer */
617 DOM_SID2 dom_sid[MAX_LOOKUP_SIDS]; /* domain SIDs being looked up */
621 uint32 status; /* return code */
625 /* DOM_NAME - XXXX not sure about this structure */
626 typedef struct dom_name_info
634 #define UNKNOWN_LEN 1
636 /* LSA_Q_LOOKUP_RIDS - LSA Lookup RIDs */
637 typedef struct lsa_q_lookup_rids
640 LSA_POL_HND pol_hnd; /* policy handle */
643 uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
644 uint32 buffer_dom_name; /* undocumented domain name buffer pointer */
645 DOM_NAME lookup_name[MAX_LOOKUP_SIDS]; /* names to be looked up */
646 uint8 undoc[UNKNOWN_LEN]; /* completely undocumented bytes of unknown length */
650 /* LSA_R_LOOKUP_RIDS - response to LSA Lookup Names */
651 typedef struct lsa_r_lookup_rids
653 DOM_R_REF dom_ref; /* domain reference info */
656 uint32 undoc_buffer; /* undocumented buffer pointer */
659 DOM_RID2 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
663 uint32 status; /* return code */
670 typedef struct lsa_neg_flags_info
672 uint32 neg_flags; /* negotiated flags */
678 typedef struct lsa_q_req_chal_info
680 uint32 undoc_buffer; /* undocumented buffer pointer */
681 UNISTR2 uni_logon_srv; /* logon server unicode string */
682 UNISTR2 uni_logon_clnt; /* logon client unicode string */
683 DOM_CHAL clnt_chal; /* client challenge */
689 typedef struct lsa_r_req_chal_info
691 DOM_CHAL srv_chal; /* server challenge */
693 uint32 status; /* return code */
700 typedef struct lsa_q_auth2_info
702 DOM_LOG_INFO clnt_id; /* client identification info */
703 DOM_CHAL clnt_chal; /* client-calculated credentials */
705 NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
711 typedef struct lsa_r_auth2_info
713 DOM_CHAL srv_chal; /* server-calculated credentials */
714 NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
716 uint32 status; /* return code */
721 /* LSA_Q_SRV_PWSET */
722 typedef struct lsa_q_srv_pwset_info
724 DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
725 char pwd[16]; /* new password - undocumented. */
729 /* LSA_R_SRV_PWSET */
730 typedef struct lsa_r_srv_pwset_info
732 DOM_CRED srv_cred; /* server-calculated credentials */
734 uint32 status; /* return code */
738 #define LSA_MAX_GROUPS 32
739 #define LSA_MAX_SIDS 32
742 typedef struct lsa_q_user_info
744 uint32 ptr_user_info;
746 NTTIME logon_time; /* logon time */
747 NTTIME logoff_time; /* logoff time */
748 NTTIME kickoff_time; /* kickoff time */
749 NTTIME pass_last_set_time; /* password last set time */
750 NTTIME pass_can_change_time; /* password can change time */
751 NTTIME pass_must_change_time; /* password must change time */
753 UNIHDR hdr_user_name; /* username unicode string header */
754 UNIHDR hdr_full_name; /* user's full name unicode string header */
755 UNIHDR hdr_logon_script; /* logon script unicode string header */
756 UNIHDR hdr_profile_path; /* profile path unicode string header */
757 UNIHDR hdr_home_dir; /* home directory unicode string header */
758 UNIHDR hdr_dir_drive; /* home directory drive unicode string header */
760 uint16 logon_count; /* logon count */
761 uint16 bad_pw_count; /* bad password count */
763 uint32 user_id; /* User ID */
764 uint32 group_id; /* Group ID */
765 uint32 num_groups; /* num groups */
766 uint32 buffer_groups; /* undocumented buffer pointer to groups. */
767 uint32 user_flgs; /* user flags */
769 char sess_key[16]; /* unused user session key */
771 UNIHDR hdr_logon_srv; /* logon server unicode string header */
772 UNIHDR hdr_logon_dom; /* logon domain unicode string header */
774 uint32 buffer_dom_id; /* undocumented logon domain id pointer */
775 char padding[40]; /* unused padding bytes. expansion room */
777 uint32 num_other_sids; /* 0 - num_sids */
778 uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */
780 UNISTR2 uni_user_name; /* username unicode string */
781 UNISTR2 uni_full_name; /* user's full name unicode string */
782 UNISTR2 uni_logon_script; /* logon script unicode string */
783 UNISTR2 uni_profile_path; /* profile path unicode string */
784 UNISTR2 uni_home_dir; /* home directory unicode string */
785 UNISTR2 uni_dir_drive; /* home directory drive unicode string */
787 uint32 num_groups2; /* num groups */
788 DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
790 UNISTR2 uni_logon_srv; /* logon server unicode string */
791 UNISTR2 uni_logon_dom; /* logon domain unicode string */
793 DOM_SID dom_sid; /* domain SID */
794 DOM_SID other_sids[LSA_MAX_SIDS]; /* undocumented - domain SIDs */
799 /* LSA_Q_SAM_LOGON */
800 typedef struct lsa_q_sam_logon_info
806 /* LSA_R_SAM_LOGON */
807 typedef struct lsa_r_sam_logon_info
809 uint32 buffer_creds; /* undocumented buffer pointer */
810 DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
812 uint16 switch_value; /* 3 - indicates type of USER INFO */
815 uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
817 uint32 status; /* return code */
822 /* LSA_Q_SAM_LOGOFF */
823 typedef struct lsa_q_sam_logoff_info
829 /* LSA_R_SAM_LOGOFF */
830 typedef struct lsa_r_sam_logoff_info
832 uint32 buffer_creds; /* undocumented buffer pointer */
833 DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
835 uint32 status; /* return code */
840 /* SH_INFO_1 (pointers to level 1 share info strings) */
841 typedef struct ptr_share_info1
843 uint32 ptr_shi1_netname; /* pointer to net name. */
844 uint32 shi1_type; /* type of share. 0 - undocumented. */
845 uint32 ptr_shi1_remark; /* pointer to comment. */
849 /* SH_INFO_1_STR (level 1 share info strings) */
850 typedef struct str_share_info1
852 UNISTR2 uni_shi1_netname; /* unicode string of net name */
853 UNISTR2 uni_shi1_remark; /* unicode string of comment. */
857 /* oops - this is going to take up a *massive* amount of stack. */
858 /* the UNISTR2s already have 1024 uint16 chars in them... */
859 #define MAX_SHARE_ENTRIES 32
861 /* SHARE_INFO_1_CONTAINER */
862 typedef struct share_info_ctr
864 uint32 num_entries_read; /* EntriesRead */
865 uint32 ptr_share_info; /* Buffer */
866 SH_INFO_1 info_1 [MAX_SHARE_ENTRIES]; /* share entry pointers */
867 SH_INFO_1_STR info_1_str[MAX_SHARE_ENTRIES]; /* share entry strings */
868 uint32 num_entries_read2; /* EntriesRead2 */
873 /* SRV_Q_NET_SHARE_ENUM */
874 typedef struct q_net_share_enum_info
876 uint32 ptr_srv_name; /* pointer (to server name?) */
877 UNISTR2 uni_srv_name; /* server name */
879 uint32 share_level; /* share level */
880 uint32 switch_value; /* switch value */
882 uint32* ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
883 SHARE_INFO_1_CTR share_info; /* share info with 0 entries */
885 uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
887 } SRV_Q_NET_SHARE_ENUM;
890 /* SRV_R_NET_SHARE_ENUM */
891 typedef struct r_net_share_enum_info
893 uint32 share_level; /* share level */
894 uint32 switch_value; /* switch value */
896 uint32* ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
897 SHARE_INFO_1_CTR share_info; /* share info with 0 entries */
899 uint32 status; /* return status */
901 } SRV_R_NET_SHARE_ENUM;
907 Yet to be turned into structures:
909 6) \\MAILSLOT\NET\NTLOGON
910 -------------------------
917 uint16 0x0007 - Query for PDC
919 STR response mailslot
920 uint8[] padding to 2-byte align with start of mailslot.
928 uint16 0x000A - Respose to Query for PDC
929 STR machine name (in uppercase)
930 uint8[] padding to 2-byte align with start of mailslot.
933 uint32 NTversion (same as received in request)
934 uint16 LMNTtoken (same as received in request)
935 uint16 LM20token (same as received in request)
943 uint16 0x0012 - SAM Logon
947 STR response mailslot
948 uint32 alloweable account
949 uint32 domain SID size
950 char[sid_size] domain SID, of sid_size bytes.
951 uint8[] ???? padding to 4? 2? -byte align with start of mailslot.
958 uint16 0x0013 - Response to SAM Logon
960 UNISTR user name - workstation trust account
973 unsigned char *smb_passwd; /* Null if no password */
974 unsigned char *smb_nt_passwd; /* Null if no password */
975 /* Other fields / flags may be added later */
995 /* these times are normally kept in GMT */
1004 /* Structure used when SMBwritebmpx is active */
1007 int wr_total_written; /* So we know when to discard this */
1010 int32 wr_error; /* Cached errors */
1011 BOOL wr_mode; /* write through mode) */
1012 BOOL wr_discard; /* discard all further data */
1013 } write_bmpx_struct;
1016 * Structure used to indirect fd's from the files_struct.
1017 * Needed as POSIX locking is based on file and process, not
1018 * file descriptor and process.
1029 int real_open_flags;
1035 file_fd_struct *fd_ptr;
1042 write_bmpx_struct *wbmpx_ptr;
1043 struct timeval open_time;
1051 BOOL granted_oplock;
1058 int list[UID_CACHE_SIZE];
1065 } name_compare_entry;
1071 struct uid_cache uid_cache;
1081 char *user; /* name of user who *opened* this connection */
1082 int uid; /* uid of user who *opened* this connection */
1083 int gid; /* gid of user who *opened* this connection */
1085 uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
1087 /* following groups stuff added by ih */
1089 /* This groups info is valid for the user that *opened* the connection */
1092 int *igroups; /* an integer version - some OSes are broken :-( */
1098 name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
1099 name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
1101 } connection_struct;
1103 /* Domain controller authentication protocol info */
1106 DOM_CHAL clnt_chal; /* Initial challenge received from client */
1107 DOM_CHAL srv_chal; /* Initial server challenge */
1108 DOM_CHAL clnt_cred; /* Last client credential */
1109 DOM_CHAL srv_cred; /* Last server credential */
1111 uint32 sess_key[2]; /* Session key */
1112 uchar md4pw[16]; /* md4(machine password) */
1117 int uid; /* uid of a validated user */
1118 int gid; /* gid of a validated user */
1120 fstring name; /* name of a validated user */
1121 fstring real_name; /* to store real name from password file - simeon */
1124 /* following groups stuff added by ih */
1125 /* This groups info is needed for when we become_user() for this uid */
1128 int *igroups; /* an integer version - some OSes are broken :-( */
1129 int *attrs; /* attributes associated with each gid */
1131 #if (defined(NETGROUP) && defined(AUTOMOUNT))
1132 char *home_share; /* to store NIS home of a user - simeon */
1138 /* per-user authentication information on NT RPCs */
1144 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
1155 } print_queue_struct;
1157 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
1163 } print_status_struct;
1165 /* used for server information: client, nameserv and ipc */
1166 struct server_info_struct
1171 fstring domain; /* used ONLY in ipc.c NOT namework.c */
1172 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
1176 /* used for network interfaces */
1179 struct interface *next;
1181 struct in_addr bcast;
1182 struct in_addr nmask;
1185 /* share mode record pointed to in shared memory hash bucket */
1188 smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
1189 int locking_version;
1192 int num_share_mode_entries;
1193 smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
1195 } share_mode_record;
1197 /* share mode entry pointed to by share_mode_record struct */
1200 smb_shm_offset_t next_share_mode_entry;
1205 struct timeval time;
1208 /* struct returned by get_share_modes */
1215 struct timeval time;
1216 } min_share_mode_entry;
1218 /* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */
1219 typedef int share_lock_token;
1221 /* Conversion to hash entry index from device and inode numbers. */
1222 #define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size())
1224 /* this is used for smbstatus */
1225 struct connect_record
1238 #ifndef LOCKING_VERSION
1239 #define LOCKING_VERSION 4
1240 #endif /* LOCKING_VERSION */
1242 #if !defined(FAST_SHARE_MODES)
1244 * Defines for slow share modes.
1248 * Locking file header lengths & offsets.
1250 #define SMF_VERSION_OFFSET 0
1251 #define SMF_NUM_ENTRIES_OFFSET 4
1252 #define SMF_FILENAME_LEN_OFFSET 8
1253 #define SMF_HEADER_LENGTH 10
1255 #define SMF_ENTRY_LENGTH 20
1258 * Share mode record offsets.
1261 #define SME_SEC_OFFSET 0
1262 #define SME_USEC_OFFSET 4
1263 #define SME_SHAREMODE_OFFSET 8
1264 #define SME_PID_OFFSET 12
1265 #define SME_PORT_OFFSET 16
1266 #define SME_OPLOCK_TYPE_OFFSET 18
1268 #endif /* FAST_SHARE_MODES */
1270 /* these are useful macros for checking validity of handles */
1271 #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
1272 #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
1273 #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
1274 #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
1275 #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
1276 #define IS_PRINT(cnum) (VALID_CNUM(cnum) && Connections[cnum].printer)
1277 #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
1279 #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
1280 return(ERROR(ERRDOS,ERRbadfid))
1281 #define CHECK_READ(fnum) if (!Files[fnum].can_read) \
1282 return(ERROR(ERRDOS,ERRbadaccess))
1283 #define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
1284 return(ERROR(ERRDOS,ERRbadaccess))
1285 #define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
1286 return(CACHED_ERROR(fnum))
1288 /* translates a connection number into a service number */
1289 #define SNUM(cnum) (Connections[cnum].service)
1291 /* access various service details */
1292 #define SERVICE(snum) (lp_servicename(snum))
1293 #define PRINTCAP (lp_printcapname())
1294 #define PRINTCOMMAND(snum) (lp_printcommand(snum))
1295 #define PRINTERNAME(snum) (lp_printername(snum))
1296 #define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
1297 #define VALID_SNUM(snum) (lp_snum_ok(snum))
1298 #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
1299 #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
1300 #define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
1301 #define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
1302 #define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
1303 #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
1304 #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
1305 #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
1306 #define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list))
1307 #define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list))
1309 #define SMBENCRYPT() (lp_encrypted_passwords())
1311 /* the basic packet size, assuming no words or bytes */
1314 /* offsets into message for common items */
1338 #define smb_vwv10 57
1339 #define smb_vwv11 59
1340 #define smb_vwv12 61
1341 #define smb_vwv13 63
1342 #define smb_vwv14 65
1343 #define smb_vwv15 67
1344 #define smb_vwv16 69
1345 #define smb_vwv17 71
1349 #define SMBmkdir 0x00 /* create directory */
1350 #define SMBrmdir 0x01 /* delete directory */
1351 #define SMBopen 0x02 /* open file */
1352 #define SMBcreate 0x03 /* create file */
1353 #define SMBclose 0x04 /* close file */
1354 #define SMBflush 0x05 /* flush file */
1355 #define SMBunlink 0x06 /* delete file */
1356 #define SMBmv 0x07 /* rename file */
1357 #define SMBgetatr 0x08 /* get file attributes */
1358 #define SMBsetatr 0x09 /* set file attributes */
1359 #define SMBread 0x0A /* read from file */
1360 #define SMBwrite 0x0B /* write to file */
1361 #define SMBlock 0x0C /* lock byte range */
1362 #define SMBunlock 0x0D /* unlock byte range */
1363 #define SMBctemp 0x0E /* create temporary file */
1364 #define SMBmknew 0x0F /* make new file */
1365 #define SMBchkpth 0x10 /* check directory path */
1366 #define SMBexit 0x11 /* process exit */
1367 #define SMBlseek 0x12 /* seek */
1368 #define SMBtcon 0x70 /* tree connect */
1369 #define SMBtconX 0x75 /* tree connect and X*/
1370 #define SMBtdis 0x71 /* tree disconnect */
1371 #define SMBnegprot 0x72 /* negotiate protocol */
1372 #define SMBdskattr 0x80 /* get disk attributes */
1373 #define SMBsearch 0x81 /* search directory */
1374 #define SMBsplopen 0xC0 /* open print spool file */
1375 #define SMBsplwr 0xC1 /* write to print spool file */
1376 #define SMBsplclose 0xC2 /* close print spool file */
1377 #define SMBsplretq 0xC3 /* return print queue */
1378 #define SMBsends 0xD0 /* send single block message */
1379 #define SMBsendb 0xD1 /* send broadcast message */
1380 #define SMBfwdname 0xD2 /* forward user name */
1381 #define SMBcancelf 0xD3 /* cancel forward */
1382 #define SMBgetmac 0xD4 /* get machine name */
1383 #define SMBsendstrt 0xD5 /* send start of multi-block message */
1384 #define SMBsendend 0xD6 /* send end of multi-block message */
1385 #define SMBsendtxt 0xD7 /* send text of multi-block message */
1387 /* Core+ protocol */
1388 #define SMBlockread 0x13 /* Lock a range and read */
1389 #define SMBwriteunlock 0x14 /* Unlock a range then write */
1390 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
1391 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
1392 #define SMBwritec 0x20 /* secondary write request */
1393 #define SMBwriteclose 0x2c /* write a file then close it */
1395 /* dos extended protocol */
1396 #define SMBreadBraw 0x1A /* read block raw */
1397 #define SMBreadBmpx 0x1B /* read block multiplexed */
1398 #define SMBreadBs 0x1C /* read block (secondary response) */
1399 #define SMBwriteBraw 0x1D /* write block raw */
1400 #define SMBwriteBmpx 0x1E /* write block multiplexed */
1401 #define SMBwriteBs 0x1F /* write block (secondary request) */
1402 #define SMBwriteC 0x20 /* write complete response */
1403 #define SMBsetattrE 0x22 /* set file attributes expanded */
1404 #define SMBgetattrE 0x23 /* get file attributes expanded */
1405 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
1406 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
1407 #define SMBtranss 0x26 /* transaction (secondary request/response) */
1408 #define SMBioctl 0x27 /* IOCTL */
1409 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
1410 #define SMBcopy 0x29 /* copy */
1411 #define SMBmove 0x2A /* move */
1412 #define SMBecho 0x2B /* echo */
1413 #define SMBopenX 0x2D /* open and X */
1414 #define SMBreadX 0x2E /* read and X */
1415 #define SMBwriteX 0x2F /* write and X */
1416 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
1417 #define SMBffirst 0x82 /* find first */
1418 #define SMBfunique 0x83 /* find unique */
1419 #define SMBfclose 0x84 /* find close */
1420 #define SMBinvalid 0xFE /* invalid command */
1422 /* Extended 2.0 protocol */
1423 #define SMBtrans2 0x32 /* TRANS2 protocol set */
1424 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
1425 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
1426 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
1427 #define SMBulogoffX 0x74 /* user logoff */
1429 /* NT SMB extensions. */
1430 #define SMBnttrans 0xA0 /* NT transact */
1431 #define SMBnttranss 0xA1 /* NT transact secondary */
1432 #define SMBntcreateX 0xA2 /* NT create and X */
1433 #define SMBntcancel 0xA4 /* NT cancel */
1435 /* These are the TRANS2 sub commands */
1436 #define TRANSACT2_OPEN 0
1437 #define TRANSACT2_FINDFIRST 1
1438 #define TRANSACT2_FINDNEXT 2
1439 #define TRANSACT2_QFSINFO 3
1440 #define TRANSACT2_SETFSINFO 4
1441 #define TRANSACT2_QPATHINFO 5
1442 #define TRANSACT2_SETPATHINFO 6
1443 #define TRANSACT2_QFILEINFO 7
1444 #define TRANSACT2_SETFILEINFO 8
1445 #define TRANSACT2_FSCTL 9
1446 #define TRANSACT2_IOCTL 0xA
1447 #define TRANSACT2_FINDNOTIFYFIRST 0xB
1448 #define TRANSACT2_FINDNOTIFYNEXT 0xC
1449 #define TRANSACT2_MKDIR 0xD
1450 #define TRANSACT2_SESSION_SETUP 0xE
1451 #define TRANSACT2_GET_DFS_REFERRAL 0x10
1452 #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
1454 /* These are the NT transact sub commands. */
1455 #define NT_TRANSACT_CREATE 1
1456 #define NT_TRANSACT_IOCTL 2
1457 #define NT_TRANSACT_SET_SECURITY_DESC 3
1458 #define NT_TRANSACT_NOTIFY_CHANGE 4
1459 #define NT_TRANSACT_RENAME 5
1460 #define NT_TRANSACT_QUERY_SECURITY_DESC 6
1462 /* these are the trans2 sub fields for primary requests */
1463 #define smb_tpscnt smb_vwv0
1464 #define smb_tdscnt smb_vwv1
1465 #define smb_mprcnt smb_vwv2
1466 #define smb_mdrcnt smb_vwv3
1467 #define smb_msrcnt smb_vwv4
1468 #define smb_flags smb_vwv5
1469 #define smb_timeout smb_vwv6
1470 #define smb_pscnt smb_vwv9
1471 #define smb_psoff smb_vwv10
1472 #define smb_dscnt smb_vwv11
1473 #define smb_dsoff smb_vwv12
1474 #define smb_suwcnt smb_vwv13
1475 #define smb_setup smb_vwv14
1476 #define smb_setup0 smb_setup
1477 #define smb_setup1 (smb_setup+2)
1478 #define smb_setup2 (smb_setup+4)
1480 /* these are for the secondary requests */
1481 #define smb_spscnt smb_vwv2
1482 #define smb_spsoff smb_vwv3
1483 #define smb_spsdisp smb_vwv4
1484 #define smb_sdscnt smb_vwv5
1485 #define smb_sdsoff smb_vwv6
1486 #define smb_sdsdisp smb_vwv7
1487 #define smb_sfid smb_vwv8
1489 /* and these for responses */
1490 #define smb_tprcnt smb_vwv0
1491 #define smb_tdrcnt smb_vwv1
1492 #define smb_prcnt smb_vwv3
1493 #define smb_proff smb_vwv4
1494 #define smb_prdisp smb_vwv5
1495 #define smb_drcnt smb_vwv6
1496 #define smb_droff smb_vwv7
1497 #define smb_drdisp smb_vwv8
1499 /* where to find the base of the SMB packet proper */
1500 #define smb_base(buf) (((char *)(buf))+4)
1503 #define SUCCESS 0 /* The request was successful. */
1504 #define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
1505 #define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
1506 #define ERRHRD 0x03 /* Error is an hardware error. */
1507 #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
1510 int Debug1(char *, ...);
1516 void dfs_unlogin(void);
1517 extern int dcelogin_atmost_once;
1521 void ajt_panic(void);
1525 char *strdup(char *s);
1528 #ifdef REPLACE_STRLEN
1532 #ifdef REPLACE_STRSTR
1533 char *Strstr(char *s, char *p);
1537 #define MIN(a,b) ((a)<(b)?(a):(b))
1540 #define MAX(a,b) ((a)>(b)?(a):(b))
1544 #define ABS(a) ((a)>0?(a):(-(a)))
1556 /* Some POSIX definitions for those without */
1559 #define S_IFDIR 0x4000
1562 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
1565 #define S_IRWXU 00700 /* read, write, execute: owner */
1568 #define S_IRUSR 00400 /* read permission: owner */
1571 #define S_IWUSR 00200 /* write permission: owner */
1574 #define S_IXUSR 00100 /* execute permission: owner */
1577 #define S_IRWXG 00070 /* read, write, execute: group */
1580 #define S_IRGRP 00040 /* read permission: group */
1583 #define S_IWGRP 00020 /* write permission: group */
1586 #define S_IXGRP 00010 /* execute permission: group */
1589 #define S_IRWXO 00007 /* read, write, execute: other */
1592 #define S_IROTH 00004 /* read permission: other */
1595 #define S_IWOTH 00002 /* write permission: other */
1598 #define S_IXOTH 00001 /* execute permission: other */
1602 /* these are used in NetServerEnum to choose what to receive */
1603 #define SV_TYPE_WORKSTATION 0x00000001
1604 #define SV_TYPE_SERVER 0x00000002
1605 #define SV_TYPE_SQLSERVER 0x00000004
1606 #define SV_TYPE_DOMAIN_CTRL 0x00000008
1607 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
1608 #define SV_TYPE_TIME_SOURCE 0x00000020
1609 #define SV_TYPE_AFP 0x00000040
1610 #define SV_TYPE_NOVELL 0x00000080
1611 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
1612 #define SV_TYPE_PRINTQ_SERVER 0x00000200
1613 #define SV_TYPE_DIALIN_SERVER 0x00000400
1614 #define SV_TYPE_SERVER_UNIX 0x00000800
1615 #define SV_TYPE_NT 0x00001000
1616 #define SV_TYPE_WFW 0x00002000
1617 #define SV_TYPE_SERVER_MFPN 0x00004000
1618 #define SV_TYPE_SERVER_NT 0x00008000
1619 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
1620 #define SV_TYPE_BACKUP_BROWSER 0x00020000
1621 #define SV_TYPE_MASTER_BROWSER 0x00040000
1622 #define SV_TYPE_DOMAIN_MASTER 0x00080000
1623 #define SV_TYPE_SERVER_OSF 0x00100000
1624 #define SV_TYPE_SERVER_VMS 0x00200000
1625 #define SV_TYPE_WIN95_PLUS 0x00400000
1626 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
1627 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
1628 #define SV_TYPE_DOMAIN_ENUM 0x80000000
1629 #define SV_TYPE_ALL 0xFFFFFFFF
1631 /* what server type are we currently - JHT Says we ARE 4.20 */
1632 /* this was set by JHT in liaison with Jeremy Allison early 1997 */
1633 /* setting to 4.20 at same time as announcing ourselves as NT Server */
1635 /* Version 4.0 - never made public */
1636 /* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */
1637 /* - Reappeared in 1.9.16p11 with fixed smbd services */
1638 /* Version 4.20 - To indicate that nmbd and browsing now works better */
1640 #define DEFAULT_MAJOR_VERSION 0x04
1641 #define DEFAULT_MINOR_VERSION 0x02
1643 /* Browser Election Values */
1644 #define BROWSER_ELECTION_VERSION 0x010f
1645 #define BROWSER_CONSTANT 0xaa55
1648 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
1650 #define CAP_RAW_MODE 0x0001
1651 #define CAP_MPX_MODE 0x0002
1652 #define CAP_UNICODE 0x0004
1653 #define CAP_LARGE_FILES 0x0008
1654 #define CAP_NT_SMBS 0x0010
1655 #define CAP_RPC_REMOTE_APIS 0x0020
1656 #define CAP_STATUS32 0x0040
1657 #define CAP_LEVEL_II_OPLOCKS 0x0080
1658 #define CAP_LOCK_AND_READ 0x0100
1659 #define CAP_NT_FIND 0x0200
1660 #define CAP_DFS 0x1000
1661 #define CAP_LARGE_READX 0x4000
1663 /* protocol types. It assumes that higher protocols include lower protocols
1665 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
1667 /* security levels */
1668 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
1670 /* printing types */
1671 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
1672 PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
1674 /* Remote architectures we know about. */
1675 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
1678 enum case_handling {CASE_LOWER,CASE_UPPER};
1681 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
1682 structures. We cannot define these as actual structures
1683 due to possible differences in structure packing
1684 on different machines/compilers. */
1686 #define SMB_LPID_OFFSET(indx) (10 * (indx))
1687 #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
1688 #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
1690 /* Macro to cache an error in a write_bmpx_struct */
1691 #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
1692 w->wr_discard = True, -1)
1693 /* Macro to test if an error has been cached for this fnum */
1694 #define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
1695 Files[(fnum)].wbmpx_ptr && \
1696 Files[(fnum)].wbmpx_ptr->wr_discard)
1697 /* Macro to turn the cached error into an error packet */
1698 #define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
1700 /* these are the datagram types */
1701 #define DGRAM_DIRECT_UNIQUE 0x10
1703 #define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
1705 /* this is how errors are generated */
1706 #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
1708 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
1711 * Global value meaing that the smb_uid field should be
1712 * ingored (in share level security and protocol level == CORE)
1715 #define UID_FIELD_INVALID 0
1716 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
1720 /* Defines needed for multi-codepage support. */
1721 #define KANJI_CODEPAGE 932
1725 * Default client code page - Japanese
1727 #define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
1730 * Default client code page - 850 - Western European
1732 #define DEFAULT_CLIENT_CODE_PAGE 850
1736 * Size of buffer to use when moving files across filesystems.
1738 #define COPYBUF_SIZE (8*1024)
1741 * Integers used to override error codes.
1743 extern int unix_ERR_class;
1744 extern int unix_ERR_code;
1747 * Map the Core and Extended Oplock requesst bits down
1748 * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
1754 #define CORE_OPLOCK_REQUEST(inbuf) (((CVAL(inbuf,smb_flg)|(1<<5))>>5) | \
1755 ((CVAL(inbuf,smb_flg)|(1<<6))>>5))
1758 * Extended protocol.
1760 #define EXTENDED_OPLOCK_REQUEST(inbuf) (((SVAL(inbuf,smb_vwv2)|(1<<1))>>1) | \
1761 ((SVAL(inbuf,smb_vwv2)|(1<<2))>>1))
1764 #define LOCKING_ANDX_SHARED_LOCK 0x1
1765 #define LOCKING_ANDX_OPLOCK_RELEASE 0x2
1766 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
1767 #define LOCKING_ANDX_CANCEL_LOCK 0x8
1768 #define LOCKING_ANDX_LARGE_FILES 0x10
1771 #define OPLOCKLEVEL_NONE 0
1772 #define OPLOCKLEVEL_II 1
1775 * Bits we test with.
1777 #define EXCLUSIVE_OPLOCK 1
1778 #define BATCH_OPLOCK 2
1780 #define CORE_OPLOCK_GRANTED (1<<5)
1781 #define EXTENDED_OPLOCK_GRANTED (1<<15)
1784 * Loopback command offsets.
1787 #define UDP_CMD_LEN_OFFSET 0
1788 #define UDP_CMD_PORT_OFFSET 4
1789 #define UDP_CMD_HEADER_LEN 6
1791 #define UDP_MESSAGE_CMD_OFFSET 0
1794 * Oplock break command code to send over the udp socket.
1799 * +----+--------+--------+--------+-------+--------+
1800 * | cmd| pid | dev | inode | sec | usec |
1801 * +----+--------+--------+--------+-------+--------+
1804 #define OPLOCK_BREAK_CMD 0x1
1805 #define OPLOCK_BREAK_PID_OFFSET 2
1806 #define OPLOCK_BREAK_DEV_OFFSET 6
1807 #define OPLOCK_BREAK_INODE_OFFSET 10
1808 #define OPLOCK_BREAK_SEC_OFFSET 14
1809 #define OPLOCK_BREAK_USEC_OFFSET 18
1810 #define OPLOCK_BREAK_MSG_LEN 22
1813 #define CMD_REPLY 0x8000