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
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifndef MAX_CONNECTIONS
26 #define MAX_CONNECTIONS 127
29 #ifndef MAX_OPEN_FILES
30 #define MAX_OPEN_FILES 50
34 #define GUEST_ACCOUNT "nobody"
37 #define BUFFER_SIZE (0xFFFF)
38 #define SAFETY_MARGIN 1024
40 /* Default size of shared memory used for share mode locking */
42 #define SHMEM_SIZE 102400
45 /* Default number of hash buckets used in shared memory share mode */
46 #ifndef SHMEM_HASH_SIZE
47 #define SHMEM_HASH_SIZE 113
51 #define DGRAM_PORT 138
56 #define BOOLSTR(b) ((b) ? "Yes" : "No")
57 #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
58 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
59 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
63 /* offset in shared memory */
64 typedef int smb_shm_offset_t;
65 #define NULL_OFFSET (smb_shm_offset_t)(0)
69 Samba needs type definitions for int16, int32, uint16 and uint32.
71 Normally these are signed and unsigned 16 and 32 bit integers, but
72 they actually only need to be at least 16 and 32 bits
73 respectively. Thus if your word size is 8 bytes just defining them
74 as signed and unsigned int will work.
77 /* afs/stds.h defines int16 and int32 */
84 typedef unsigned short uint16;
88 typedef unsigned int uint32;
92 #define uchar unsigned char
98 #define uint16 unsigned short
101 #define uint32 unsigned int
106 #ifndef DEF_CREATE_MASK
107 #define DEF_CREATE_MASK (0755)
110 /* how long to wait for secondary SMB packets (milli-seconds) */
111 #define SMB_SECONDARY_WAIT (60*1000)
115 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
117 extern int syslog_level;
119 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
122 /* this defines the error codes that receive_smb can put in smb_read_error */
123 #define READ_TIMEOUT 1
128 #define DIR_STRUCT_SIZE 43
130 /* these define all the command types recognised by the server - there
131 are lots of gaps so probably there are some rare commands that are not
134 #define pSETDIR '\377'
136 /* these define the attribute byte as seen by DOS */
137 #define aRONLY (1L<<0)
138 #define aHIDDEN (1L<<1)
139 #define aSYSTEM (1L<<2)
140 #define aVOLID (1L<<3)
142 #define aARCH (1L<<5)
153 #define STYPE_DISKTREE 0 /* Disk drive */
154 #define STYPE_PRINTQ 1 /* Spooler queue */
155 #define STYPE_DEVICE 2 /* Serial device */
156 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
158 /* SMB X/Open error codes for the ERRdos error class */
159 #define ERRbadfunc 1 /* Invalid function (or system call) */
160 #define ERRbadfile 2 /* File not found (pathname error) */
161 #define ERRbadpath 3 /* Directory not found */
162 #define ERRnofids 4 /* Too many open files */
163 #define ERRnoaccess 5 /* Access denied */
164 #define ERRbadfid 6 /* Invalid fid */
165 #define ERRnomem 8 /* Out of memory */
166 #define ERRbadmem 9 /* Invalid memory block address */
167 #define ERRbadenv 10 /* Invalid environment */
168 #define ERRbadaccess 12 /* Invalid open mode */
169 #define ERRbaddata 13 /* Invalid data (only from ioctl call) */
170 #define ERRres 14 /* reserved */
171 #define ERRbaddrive 15 /* Invalid drive */
172 #define ERRremcd 16 /* Attempt to delete current directory */
173 #define ERRdiffdevice 17 /* rename/move across different filesystems */
174 #define ERRnofiles 18 /* no more files found in file search */
175 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
176 #define ERRlock 33 /* Lock request conflicts with existing lock */
177 #define ERRfilexists 80 /* File in operation already exists */
178 #define ERRcannotopen 110 /* Cannot open the file specified */
179 #define ERRunknownlevel 124
180 #define ERRbadpipe 230 /* Named pipe invalid */
181 #define ERRpipebusy 231 /* All instances of pipe are busy */
182 #define ERRpipeclosing 232 /* named pipe close in progress */
183 #define ERRnotconnected 233 /* No process on other end of named pipe */
184 #define ERRmoredata 234 /* More data to be returned */
185 #define ERRbaddirectory 267 /* Invalid directory name in a path. */
186 #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
187 #define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not supported */
188 #define ERRunknownipc 2142
191 /* here's a special one from observing NT */
192 #define ERRnoipc 66 /* don't support ipc */
194 /* Error codes for the ERRSRV class */
196 #define ERRerror 1 /* Non specific error code */
197 #define ERRbadpw 2 /* Bad password */
198 #define ERRbadtype 3 /* reserved */
199 #define ERRaccess 4 /* No permissions to do the requested operation */
200 #define ERRinvnid 5 /* tid invalid */
201 #define ERRinvnetname 6 /* Invalid servername */
202 #define ERRinvdevice 7 /* Invalid device */
203 #define ERRqfull 49 /* Print queue full */
204 #define ERRqtoobig 50 /* Queued item too big */
205 #define ERRinvpfid 52 /* Invalid print file in smb_fid */
206 #define ERRsmbcmd 64 /* Unrecognised command */
207 #define ERRsrverror 65 /* smb server internal error */
208 #define ERRfilespecs 67 /* fid and pathname invalid combination */
209 #define ERRbadlink 68 /* reserved */
210 #define ERRbadpermits 69 /* Access specified for a file is not valid */
211 #define ERRbadpid 70 /* reserved */
212 #define ERRsetattrmode 71 /* attribute mode invalid */
213 #define ERRpaused 81 /* Message server paused */
214 #define ERRmsgoff 82 /* Not receiving messages */
215 #define ERRnoroom 83 /* No room for message */
216 #define ERRrmuns 87 /* too many remote usernames */
217 #define ERRtimeout 88 /* operation timed out */
218 #define ERRnoresource 89 /* No resources currently available for request. */
219 #define ERRtoomanyuids 90 /* too many userids */
220 #define ERRbaduid 91 /* bad userid */
221 #define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
222 #define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
223 #define ERRcontMPX 252 /* resume MPX mode */
224 #define ERRbadPW /* reserved */
225 #define ERRnosupport 0xFFFF
226 #define ERRunknownsmb 22 /* from NT 3.5 response */
229 /* Error codes for the ERRHRD class */
231 #define ERRnowrite 19 /* read only media */
232 #define ERRbadunit 20 /* Unknown device */
233 #define ERRnotready 21 /* Drive not ready */
234 #define ERRbadcmd 22 /* Unknown command */
235 #define ERRdata 23 /* Data (CRC) error */
236 #define ERRbadreq 24 /* Bad request structure length */
238 #define ERRbadmedia 26
239 #define ERRbadsector 27
240 #define ERRnopaper 28
241 #define ERRwrite 29 /* write fault */
242 #define ERRread 30 /* read fault */
243 #define ERRgeneral 31 /* General hardware failure */
244 #define ERRwrongdisk 34
245 #define ERRFCBunavail 35
246 #define ERRsharebufexc 36 /* share buffer exceeded */
247 #define ERRdiskfull 39
250 typedef char pstring[1024];
251 typedef char fstring[128];
252 typedef fstring string;
258 unsigned char *smb_passwd; /* Null if no password */
259 unsigned char *smb_nt_passwd; /* Null if no password */
260 /* Other fields / flags may be added later */
264 struct current_user {
278 /* these times are normally kept in GMT */
286 /* Structure used when SMBwritebmpx is active */
289 int wr_total_written; /* So we know when to discard this */
292 int32 wr_error; /* Cached errors */
293 BOOL wr_mode; /* write through mode) */
294 BOOL wr_discard; /* discard all further data */
298 * Structure used to indirect fd's from the files_struct.
299 * Needed as POSIX locking is based on file and process, not
300 * file descriptor and process.
317 file_fd_struct *fd_ptr;
324 write_bmpx_struct *wbmpx_ptr;
325 struct timeval open_time;
339 int list[UID_CACHE_SIZE];
346 } name_compare_entry;
352 struct uid_cache uid_cache;
362 char *user; /* name of user who *opened* this connection */
363 int uid; /* uid of user who *opened* this connection */
364 int gid; /* gid of user who *opened* this connection */
365 uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
366 /* following groups stuff added by ih */
367 /* This groups info is valid for the user that *opened* the connection */
370 int *igroups; /* an integer version - some OSes are broken :-( */
374 name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
375 name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
381 int uid; /* uid of a validated user */
382 int gid; /* gid of a validated user */
383 fstring name; /* name of a validated user */
385 /* following groups stuff added by ih */
386 /* This groups info is needed for when we become_user() for this uid */
389 int *user_igroups; /* an integer version - some OSes are broken :-( */
390 #if (defined(NETGROUP) && defined(AUTOMOUNT))
391 char *home_share; /* to store NIS home of a user - simeon */
393 char *real_name; /* to store real name from password file - simeon */
397 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
408 } print_queue_struct;
410 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
416 } print_status_struct;
418 /* used for server information: client, nameserv and ipc */
419 struct server_info_struct
424 fstring domain; /* used ONLY in ipc.c NOT namework.c */
425 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
429 /* used for network interfaces */
432 struct interface *next;
434 struct in_addr bcast;
435 struct in_addr nmask;
438 /* share mode record pointed to in shared memory hash bucket */
441 smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
445 int num_share_mode_entries;
446 smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
450 /* share mode entry pointed to by share_mode_record struct */
453 smb_shm_offset_t next_share_mode_entry;
459 /* struct returned by get_share_modes */
465 } min_share_mode_entry;
467 /* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */
468 typedef int share_lock_token;
470 /* Conversion to hash entry index from device and inode numbers. */
471 #define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size())
473 /* this is used for smbstatus */
474 struct connect_record
488 #define LOCKING_VERSION 3
490 /* these are useful macros for checking validity of handles */
491 #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
492 #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
493 #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
494 #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
495 #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
496 #define IS_PRINT(cnum) (VALID_CNUM(cnum) && Connections[cnum].printer)
497 #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
499 #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
500 return(ERROR(ERRDOS,ERRbadfid))
501 #define CHECK_READ(fnum) if (!Files[fnum].can_read) \
502 return(ERROR(ERRDOS,ERRbadaccess))
503 #define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
504 return(ERROR(ERRDOS,ERRbadaccess))
505 #define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
506 return(CACHED_ERROR(fnum))
508 /* translates a connection number into a service number */
509 #define SNUM(cnum) (Connections[cnum].service)
511 /* access various service details */
512 #define SERVICE(snum) (lp_servicename(snum))
513 #define PRINTCAP (lp_printcapname())
514 #define PRINTCOMMAND(snum) (lp_printcommand(snum))
515 #define PRINTERNAME(snum) (lp_printername(snum))
516 #define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
517 #define VALID_SNUM(snum) (lp_snum_ok(snum))
518 #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
519 #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
520 #define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
521 #define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
522 #define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
523 #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
524 #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
525 #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
526 #define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list))
527 #define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list))
530 #define SMBENCRYPT() (lp_encrypted_passwords())
532 #define SMBENCRYPT() (False)
535 /* the basic packet size, assuming no words or bytes */
538 /* offsets into message for common items */
573 #define SMBmkdir 0x00 /* create directory */
574 #define SMBrmdir 0x01 /* delete directory */
575 #define SMBopen 0x02 /* open file */
576 #define SMBcreate 0x03 /* create file */
577 #define SMBclose 0x04 /* close file */
578 #define SMBflush 0x05 /* flush file */
579 #define SMBunlink 0x06 /* delete file */
580 #define SMBmv 0x07 /* rename file */
581 #define SMBgetatr 0x08 /* get file attributes */
582 #define SMBsetatr 0x09 /* set file attributes */
583 #define SMBread 0x0A /* read from file */
584 #define SMBwrite 0x0B /* write to file */
585 #define SMBlock 0x0C /* lock byte range */
586 #define SMBunlock 0x0D /* unlock byte range */
587 #define SMBctemp 0x0E /* create temporary file */
588 #define SMBmknew 0x0F /* make new file */
589 #define SMBchkpth 0x10 /* check directory path */
590 #define SMBexit 0x11 /* process exit */
591 #define SMBlseek 0x12 /* seek */
592 #define SMBtcon 0x70 /* tree connect */
593 #define SMBtconX 0x75 /* tree connect and X*/
594 #define SMBtdis 0x71 /* tree disconnect */
595 #define SMBnegprot 0x72 /* negotiate protocol */
596 #define SMBdskattr 0x80 /* get disk attributes */
597 #define SMBsearch 0x81 /* search directory */
598 #define SMBsplopen 0xC0 /* open print spool file */
599 #define SMBsplwr 0xC1 /* write to print spool file */
600 #define SMBsplclose 0xC2 /* close print spool file */
601 #define SMBsplretq 0xC3 /* return print queue */
602 #define SMBsends 0xD0 /* send single block message */
603 #define SMBsendb 0xD1 /* send broadcast message */
604 #define SMBfwdname 0xD2 /* forward user name */
605 #define SMBcancelf 0xD3 /* cancel forward */
606 #define SMBgetmac 0xD4 /* get machine name */
607 #define SMBsendstrt 0xD5 /* send start of multi-block message */
608 #define SMBsendend 0xD6 /* send end of multi-block message */
609 #define SMBsendtxt 0xD7 /* send text of multi-block message */
612 #define SMBlockread 0x13 /* Lock a range and read */
613 #define SMBwriteunlock 0x14 /* Unlock a range then write */
614 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
615 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
616 #define SMBwritec 0x20 /* secondary write request */
617 #define SMBwriteclose 0x2c /* write a file then close it */
619 /* dos extended protocol */
620 #define SMBreadBraw 0x1A /* read block raw */
621 #define SMBreadBmpx 0x1B /* read block multiplexed */
622 #define SMBreadBs 0x1C /* read block (secondary response) */
623 #define SMBwriteBraw 0x1D /* write block raw */
624 #define SMBwriteBmpx 0x1E /* write block multiplexed */
625 #define SMBwriteBs 0x1F /* write block (secondary request) */
626 #define SMBwriteC 0x20 /* write complete response */
627 #define SMBsetattrE 0x22 /* set file attributes expanded */
628 #define SMBgetattrE 0x23 /* get file attributes expanded */
629 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
630 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
631 #define SMBtranss 0x26 /* transaction (secondary request/response) */
632 #define SMBioctl 0x27 /* IOCTL */
633 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
634 #define SMBcopy 0x29 /* copy */
635 #define SMBmove 0x2A /* move */
636 #define SMBecho 0x2B /* echo */
637 #define SMBopenX 0x2D /* open and X */
638 #define SMBreadX 0x2E /* read and X */
639 #define SMBwriteX 0x2F /* write and X */
640 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
641 #define SMBffirst 0x82 /* find first */
642 #define SMBfunique 0x83 /* find unique */
643 #define SMBfclose 0x84 /* find close */
644 #define SMBinvalid 0xFE /* invalid command */
646 /* Extended 2.0 protocol */
647 #define SMBtrans2 0x32 /* TRANS2 protocol set */
648 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
649 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
650 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
651 #define SMBulogoffX 0x74 /* user logoff */
654 /* these are the TRANS2 sub commands */
655 #define TRANSACT2_OPEN 0
656 #define TRANSACT2_FINDFIRST 1
657 #define TRANSACT2_FINDNEXT 2
658 #define TRANSACT2_QFSINFO 3
659 #define TRANSACT2_SETFSINFO 4
660 #define TRANSACT2_QPATHINFO 5
661 #define TRANSACT2_SETPATHINFO 6
662 #define TRANSACT2_QFILEINFO 7
663 #define TRANSACT2_SETFILEINFO 8
664 #define TRANSACT2_FSCTL 9
665 #define TRANSACT2_IOCTL 10
666 #define TRANSACT2_FINDNOTIFYFIRST 11
667 #define TRANSACT2_FINDNOTIFYNEXT 12
668 #define TRANSACT2_MKDIR 13
671 /* these are the trans2 sub fields for primary requests */
672 #define smb_tpscnt smb_vwv0
673 #define smb_tdscnt smb_vwv1
674 #define smb_mprcnt smb_vwv2
675 #define smb_mdrcnt smb_vwv3
676 #define smb_msrcnt smb_vwv4
677 #define smb_flags smb_vwv5
678 #define smb_timeout smb_vwv6
679 #define smb_pscnt smb_vwv9
680 #define smb_psoff smb_vwv10
681 #define smb_dscnt smb_vwv11
682 #define smb_dsoff smb_vwv12
683 #define smb_suwcnt smb_vwv13
684 #define smb_setup smb_vwv14
685 #define smb_setup0 smb_setup
686 #define smb_setup1 (smb_setup+2)
687 #define smb_setup2 (smb_setup+4)
689 /* these are for the secondary requests */
690 #define smb_spscnt smb_vwv2
691 #define smb_spsoff smb_vwv3
692 #define smb_spsdisp smb_vwv4
693 #define smb_sdscnt smb_vwv5
694 #define smb_sdsoff smb_vwv6
695 #define smb_sdsdisp smb_vwv7
696 #define smb_sfid smb_vwv8
698 /* and these for responses */
699 #define smb_tprcnt smb_vwv0
700 #define smb_tdrcnt smb_vwv1
701 #define smb_prcnt smb_vwv3
702 #define smb_proff smb_vwv4
703 #define smb_prdisp smb_vwv5
704 #define smb_drcnt smb_vwv6
705 #define smb_droff smb_vwv7
706 #define smb_drdisp smb_vwv8
708 /* where to find the base of the SMB packet proper */
709 #define smb_base(buf) (((char *)(buf))+4)
712 #define SUCCESS 0 /* The request was successful. */
713 #define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
714 #define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
715 #define ERRHRD 0x03 /* Error is an hardware error. */
716 #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
719 int Debug1(char *, ...);
725 void dfs_unlogin(void);
726 extern int dcelogin_atmost_once;
730 void ajt_panic(void);
734 char *strdup(char *s);
737 #ifdef REPLACE_STRLEN
741 #ifdef REPLACE_STRSTR
742 char *Strstr(char *s, char *p);
746 #define MIN(a,b) ((a)<(b)?(a):(b))
749 #define MAX(a,b) ((a)>(b)?(a):(b))
753 #define ABS(a) ((a)>0?(a):(-(a)))
765 /* Some POSIX definitions for those without */
768 #define S_IFDIR 0x4000
771 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
774 #define S_IRWXU 00700 /* read, write, execute: owner */
777 #define S_IRUSR 00400 /* read permission: owner */
780 #define S_IWUSR 00200 /* write permission: owner */
783 #define S_IXUSR 00100 /* execute permission: owner */
786 #define S_IRWXG 00070 /* read, write, execute: group */
789 #define S_IRGRP 00040 /* read permission: group */
792 #define S_IWGRP 00020 /* write permission: group */
795 #define S_IXGRP 00010 /* execute permission: group */
798 #define S_IRWXO 00007 /* read, write, execute: other */
801 #define S_IROTH 00004 /* read permission: other */
804 #define S_IWOTH 00002 /* write permission: other */
807 #define S_IXOTH 00001 /* execute permission: other */
811 /* these are used in NetServerEnum to choose what to receive */
812 #define SV_TYPE_WORKSTATION 0x00000001
813 #define SV_TYPE_SERVER 0x00000002
814 #define SV_TYPE_SQLSERVER 0x00000004
815 #define SV_TYPE_DOMAIN_CTRL 0x00000008
816 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
817 #define SV_TYPE_TIME_SOURCE 0x00000020
818 #define SV_TYPE_AFP 0x00000040
819 #define SV_TYPE_NOVELL 0x00000080
820 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
821 #define SV_TYPE_PRINTQ_SERVER 0x00000200
822 #define SV_TYPE_DIALIN_SERVER 0x00000400
823 #define SV_TYPE_SERVER_UNIX 0x00000800
824 #define SV_TYPE_NT 0x00001000
825 #define SV_TYPE_WFW 0x00002000
826 #define SV_TYPE_SERVER_MFPN 0x00004000
827 #define SV_TYPE_SERVER_NT 0x00008000
828 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
829 #define SV_TYPE_BACKUP_BROWSER 0x00020000
830 #define SV_TYPE_MASTER_BROWSER 0x00040000
831 #define SV_TYPE_DOMAIN_MASTER 0x00080000
832 #define SV_TYPE_SERVER_OSF 0x00100000
833 #define SV_TYPE_SERVER_VMS 0x00200000
834 #define SV_TYPE_WIN95_PLUS 0x00400000
835 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
836 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
837 #define SV_TYPE_DOMAIN_ENUM 0x80000000
838 #define SV_TYPE_ALL 0xFFFFFFFF
840 /* what server type are we currently - JHT Says we ARE 4.20 */
841 /* this was set by JHT in liaison with Jeremy Allison early 1997 */
842 /* setting to 4.20 at same time as announcing ourselves as NT Server */
844 /* Version 4.0 - never made public */
845 /* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */
846 /* - Reappeared in 1.9.16p11 with fixed smbd services */
847 /* Version 4.20 - To indicate that nmbd and browsing now works better */
849 #define DEFAULT_MAJOR_VERSION 0x04
850 #define DEFAULT_MINOR_VERSION 0x02
852 /* Browser Election Values */
853 #define BROWSER_ELECTION_VERSION 0x010f
854 #define BROWSER_CONSTANT 0xaa55
857 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
859 #define CAP_RAW_MODE 0x0001
860 #define CAP_MPX_MODE 0x0002
861 #define CAP_UNICODE 0x0004
862 #define CAP_LARGE_FILES 0x0008
863 #define CAP_NT_SMBS 0x0010
864 #define CAP_RPC_REMOTE_APIS 0x0020
865 #define CAP_STATUS32 0x0040
866 #define CAP_LEVEL_II_OPLOCKS 0x0080
867 #define CAP_LOCK_AND_READ 0x0100
868 #define CAP_NT_FIND 0x0200
869 #define CAP_DFS 0x1000
870 #define CAP_LARGE_READX 0x4000
872 /* protocol types. It assumes that higher protocols include lower protocols
874 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
876 /* security levels */
877 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
880 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
881 PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
883 /* Remote architectures we know about. */
884 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
887 enum case_handling {CASE_LOWER,CASE_UPPER};
890 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
891 structures. We cannot define these as actual structures
892 due to possible differences in structure packing
893 on different machines/compilers. */
895 #define SMB_LPID_OFFSET(indx) (10 * (indx))
896 #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
897 #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
899 /* Macro to cache an error in a write_bmpx_struct */
900 #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
901 w->wr_discard = True, -1)
902 /* Macro to test if an error has been cached for this fnum */
903 #define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
904 Files[(fnum)].wbmpx_ptr && \
905 Files[(fnum)].wbmpx_ptr->wr_discard)
906 /* Macro to turn the cached error into an error packet */
907 #define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
909 /* these are the datagram types */
910 #define DGRAM_DIRECT_UNIQUE 0x10
912 #define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
914 /* this is how errors are generated */
915 #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
917 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
920 * Global value meaing that the smb_uid field should be
921 * ingored (in share level security and protocol level == CORE)
924 #define UID_FIELD_INVALID 0
925 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
929 /* Defines needed for multi-codepage support. */
930 #define KANJI_CODEPAGE 932
933 /* Default client code page - Japanese */
934 #define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
936 /* Default client code page - 850 - Western European */
937 #define DEFAULT_CLIENT_CODE_PAGE 850
939 /* Size of buffer to use when moving files across filesystems. */
940 #define COPYBUF_SIZE (8*1024)
942 /* Integers used to override error codes. */
943 extern int unix_ERR_class;
944 extern int unix_ERR_code;