loadparm.c: Added "force create mode" and "force directory mode" params.
[Samba/gbeck.git] / source / include / smb.h
blob2dc2624566fbfcab72192148a59d41069ac029a9
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 SMB parameters and setup
5 Copyright (C) Andrew Tridgell 1992-1997
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _SMB_H
22 #define _SMB_H
24 #ifndef MAX_CONNECTIONS
25 #define MAX_CONNECTIONS 127
26 #endif
28 #ifndef MAX_OPEN_FILES
29 #define MAX_OPEN_FILES 50
30 #endif
32 #ifndef GUEST_ACCOUNT
33 #define GUEST_ACCOUNT "nobody"
34 #endif
36 #define BUFFER_SIZE (0xFFFF)
37 #define SAFETY_MARGIN 1024
39 /* Default size of shared memory used for share mode locking */
40 #ifndef SHMEM_SIZE
41 #define SHMEM_SIZE 102400
42 #endif
44 /* Default number of hash buckets used in shared memory share mode */
45 #ifndef SHMEM_HASH_SIZE
46 #define SHMEM_HASH_SIZE 113
47 #endif
49 #define NMB_PORT 137
50 #define DGRAM_PORT 138
51 #define SMB_PORT 139
53 #define False (0)
54 #define True (1)
55 #define BOOLSTR(b) ((b) ? "Yes" : "No")
56 #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
57 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
58 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
60 typedef int BOOL;
62 /* offset in shared memory */
63 typedef int smb_shm_offset_t;
64 #define NULL_OFFSET (smb_shm_offset_t)(0)
68 Samba needs type definitions for int16, int32, uint16 and uint32.
70 Normally these are signed and unsigned 16 and 32 bit integers, but
71 they actually only need to be at least 16 and 32 bits
72 respectively. Thus if your word size is 8 bytes just defining them
73 as signed and unsigned int will work.
76 /* afs/stds.h defines int16 and int32 */
77 #ifndef AFS_AUTH
78 typedef short int16;
79 typedef int int32;
80 #endif
82 #ifndef uint16
83 typedef unsigned short uint16;
84 #endif
86 #ifndef uint32
87 typedef unsigned int uint32;
88 #endif
90 #ifndef uchar
91 #define uchar unsigned char
92 #endif
93 #ifndef int16
94 #define int16 short
95 #endif
96 #ifndef uint16
97 #define uint16 unsigned short
98 #endif
99 #ifndef uint32
100 #define uint32 unsigned int
101 #endif
103 #define SIZEOFWORD 2
105 #ifndef DEF_CREATE_MASK
106 #define DEF_CREATE_MASK (0755)
107 #endif
109 /* how long to wait for secondary SMB packets (milli-seconds) */
110 #define SMB_SECONDARY_WAIT (60*1000)
112 /* debugging code */
113 #ifndef SYSLOG
114 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
115 #else
116 extern int syslog_level;
118 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
119 #endif
121 /* this defines the error codes that receive_smb can put in smb_read_error */
122 #define READ_TIMEOUT 1
123 #define READ_EOF 2
124 #define READ_ERROR 3
127 #define DIR_STRUCT_SIZE 43
129 /* these define all the command types recognised by the server - there
130 are lots of gaps so probably there are some rare commands that are not
131 implemented */
133 #define pSETDIR '\377'
135 /* these define the attribute byte as seen by DOS */
136 #define aRONLY (1L<<0)
137 #define aHIDDEN (1L<<1)
138 #define aSYSTEM (1L<<2)
139 #define aVOLID (1L<<3)
140 #define aDIR (1L<<4)
141 #define aARCH (1L<<5)
143 /* deny modes */
144 #define DENY_DOS 0
145 #define DENY_ALL 1
146 #define DENY_WRITE 2
147 #define DENY_READ 3
148 #define DENY_NONE 4
149 #define DENY_FCB 7
151 /* share types */
152 #define STYPE_DISKTREE 0 /* Disk drive */
153 #define STYPE_PRINTQ 1 /* Spooler queue */
154 #define STYPE_DEVICE 2 /* Serial device */
155 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
157 /* SMB X/Open error codes for the ERRdos error class */
158 #define ERRbadfunc 1 /* Invalid function (or system call) */
159 #define ERRbadfile 2 /* File not found (pathname error) */
160 #define ERRbadpath 3 /* Directory not found */
161 #define ERRnofids 4 /* Too many open files */
162 #define ERRnoaccess 5 /* Access denied */
163 #define ERRbadfid 6 /* Invalid fid */
164 #define ERRnomem 8 /* Out of memory */
165 #define ERRbadmem 9 /* Invalid memory block address */
166 #define ERRbadenv 10 /* Invalid environment */
167 #define ERRbadaccess 12 /* Invalid open mode */
168 #define ERRbaddata 13 /* Invalid data (only from ioctl call) */
169 #define ERRres 14 /* reserved */
170 #define ERRbaddrive 15 /* Invalid drive */
171 #define ERRremcd 16 /* Attempt to delete current directory */
172 #define ERRdiffdevice 17 /* rename/move across different filesystems */
173 #define ERRnofiles 18 /* no more files found in file search */
174 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
175 #define ERRlock 33 /* Lock request conflicts with existing lock */
176 #define ERRfilexists 80 /* File in operation already exists */
177 #define ERRbadpipe 230 /* Named pipe invalid */
178 #define ERRpipebusy 231 /* All instances of pipe are busy */
179 #define ERRpipeclosing 232 /* named pipe close in progress */
180 #define ERRnotconnected 233 /* No process on other end of named pipe */
181 #define ERRmoredata 234 /* More data to be returned */
182 #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
183 #define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not suppored */
184 #define ERRunknownlevel 124
185 #define ERRunknownipc 2142
188 /* here's a special one from observing NT */
189 #define ERRnoipc 66 /* don't support ipc */
191 /* Error codes for the ERRSRV class */
193 #define ERRerror 1 /* Non specific error code */
194 #define ERRbadpw 2 /* Bad password */
195 #define ERRbadtype 3 /* reserved */
196 #define ERRaccess 4 /* No permissions to do the requested operation */
197 #define ERRinvnid 5 /* tid invalid */
198 #define ERRinvnetname 6 /* Invalid servername */
199 #define ERRinvdevice 7 /* Invalid device */
200 #define ERRqfull 49 /* Print queue full */
201 #define ERRqtoobig 50 /* Queued item too big */
202 #define ERRinvpfid 52 /* Invalid print file in smb_fid */
203 #define ERRsmbcmd 64 /* Unrecognised command */
204 #define ERRsrverror 65 /* smb server internal error */
205 #define ERRfilespecs 67 /* fid and pathname invalid combination */
206 #define ERRbadlink 68 /* reserved */
207 #define ERRbadpermits 69 /* Access specified for a file is not valid */
208 #define ERRbadpid 70 /* reserved */
209 #define ERRsetattrmode 71 /* attribute mode invalid */
210 #define ERRpaused 81 /* Message server paused */
211 #define ERRmsgoff 82 /* Not receiving messages */
212 #define ERRnoroom 83 /* No room for message */
213 #define ERRrmuns 87 /* too many remote usernames */
214 #define ERRtimeout 88 /* operation timed out */
215 #define ERRnoresource 89 /* No resources currently available for request. */
216 #define ERRtoomanyuids 90 /* too many userids */
217 #define ERRbaduid 91 /* bad userid */
218 #define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
219 #define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
220 #define ERRcontMPX 252 /* resume MPX mode */
221 #define ERRbadPW /* reserved */
222 #define ERRnosupport 0xFFFF
223 #define ERRunknownsmb 22 /* from NT 3.5 response */
226 /* Error codes for the ERRHRD class */
228 #define ERRnowrite 19 /* read only media */
229 #define ERRbadunit 20 /* Unknown device */
230 #define ERRnotready 21 /* Drive not ready */
231 #define ERRbadcmd 22 /* Unknown command */
232 #define ERRdata 23 /* Data (CRC) error */
233 #define ERRbadreq 24 /* Bad request structure length */
234 #define ERRseek 25
235 #define ERRbadmedia 26
236 #define ERRbadsector 27
237 #define ERRnopaper 28
238 #define ERRwrite 29 /* write fault */
239 #define ERRread 30 /* read fault */
240 #define ERRgeneral 31 /* General hardware failure */
241 #define ERRwrongdisk 34
242 #define ERRFCBunavail 35
243 #define ERRsharebufexc 36 /* share buffer exceeded */
244 #define ERRdiskfull 39
247 typedef char pstring[1024];
248 typedef char fstring[128];
249 typedef fstring string;
252 struct smb_passwd {
253 int smb_userid;
254 char *smb_name;
255 unsigned char *smb_passwd; /* Null if no password */
256 unsigned char *smb_nt_passwd; /* Null if no password */
257 /* Other fields / flags may be added later */
261 struct current_user {
262 int cnum, id;
263 int uid, gid;
264 int ngroups;
265 gid_t *groups;
266 int *igroups;
269 typedef struct
271 int size;
272 int mode;
273 int uid;
274 int gid;
275 /* these times are normally kept in GMT */
276 time_t mtime;
277 time_t atime;
278 time_t ctime;
279 pstring name;
280 } file_info;
283 /* Structure used when SMBwritebmpx is active */
284 typedef struct
286 int wr_total_written; /* So we know when to discard this */
287 int32 wr_timeout;
288 int32 wr_errclass;
289 int32 wr_error; /* Cached errors */
290 BOOL wr_mode; /* write through mode) */
291 BOOL wr_discard; /* discard all further data */
292 } write_bmpx_struct;
295 * Structure used to indirect fd's from the files_struct.
296 * Needed as POSIX locking is based on file and process, not
297 * file descriptor and process.
300 typedef struct
302 uint16 ref_count;
303 uint32 dev;
304 uint32 inode;
305 int fd;
306 int fd_readonly;
307 int fd_writeonly;
308 int real_open_flags;
309 } file_fd_struct;
311 typedef struct
313 int cnum;
314 file_fd_struct *fd_ptr;
315 int pos;
316 int size;
317 int mode;
318 int uid;
319 char *mmap_ptr;
320 int mmap_size;
321 write_bmpx_struct *wbmpx_ptr;
322 struct timeval open_time;
323 BOOL open;
324 BOOL can_lock;
325 BOOL can_read;
326 BOOL can_write;
327 BOOL share_mode;
328 BOOL print_file;
329 BOOL modified;
330 char *name;
331 } files_struct;
334 struct uid_cache {
335 int entries;
336 int list[UID_CACHE_SIZE];
339 typedef struct
341 int service;
342 BOOL force_user;
343 struct uid_cache uid_cache;
344 void *dirptr;
345 BOOL open;
346 BOOL printer;
347 BOOL ipc;
348 BOOL read_only;
349 BOOL admin_user;
350 char *dirpath;
351 char *connectpath;
352 char *origpath;
353 char *user; /* name of user who *opened* this connection */
354 int uid; /* uid of user who *opened* this connection */
355 int gid; /* gid of user who *opened* this connection */
356 uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
357 /* following groups stuff added by ih */
358 /* This groups info is valid for the user that *opened* the connection */
359 int ngroups;
360 gid_t *groups;
361 int *igroups; /* an integer version - some OSes are broken :-( */
362 time_t lastused;
363 BOOL used;
364 int num_files_open;
365 } connection_struct;
368 typedef struct
370 int uid; /* uid of a validated user */
371 int gid; /* gid of a validated user */
372 fstring name; /* name of a validated user */
373 BOOL guest;
374 /* following groups stuff added by ih */
375 /* This groups info is needed for when we become_user() for this uid */
376 int user_ngroups;
377 gid_t *user_groups;
378 int *user_igroups; /* an integer version - some OSes are broken :-( */
379 #if (defined(NETGROUP) && defined(AUTOMOUNT))
380 char *home_share; /* to store NIS home of a user - simeon */
381 #endif
382 char *real_name; /* to store real name from password file - simeon */
383 } user_struct;
386 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
388 typedef struct
390 int job;
391 int size;
392 int status;
393 int priority;
394 time_t time;
395 char user[30];
396 char file[100];
397 } print_queue_struct;
399 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
401 typedef struct
403 fstring message;
404 int status;
405 } print_status_struct;
407 /* used for server information: client, nameserv and ipc */
408 struct server_info_struct
410 fstring name;
411 uint32 type;
412 fstring comment;
413 fstring domain; /* used ONLY in ipc.c NOT namework.c */
414 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
418 /* used for network interfaces */
419 struct interface
421 struct interface *next;
422 struct in_addr ip;
423 struct in_addr bcast;
424 struct in_addr nmask;
427 /* share mode record pointed to in shared memory hash bucket */
428 typedef struct
430 smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
431 int locking_version;
432 int32 st_dev;
433 int32 st_ino;
434 int num_share_mode_entries;
435 smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
436 char file_name[1];
437 } share_mode_record;
439 /* share mode entry pointed to by share_mode_record struct */
440 typedef struct
442 smb_shm_offset_t next_share_mode_entry;
443 int pid;
444 int share_mode;
445 struct timeval time;
446 } share_mode_entry;
448 /* struct returned by get_share_modes */
449 typedef struct
451 int pid;
452 int share_mode;
453 struct timeval time;
454 } min_share_mode_entry;
456 /* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */
457 typedef int share_lock_token;
459 /* Conversion to hash entry index from device and inode numbers. */
460 #define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size())
462 /* this is used for smbstatus */
463 struct connect_record
465 int magic;
466 int pid;
467 int cnum;
468 int uid;
469 int gid;
470 char name[24];
471 char addr[24];
472 char machine[128];
473 time_t start;
477 #define LOCKING_VERSION 3
479 /* these are useful macros for checking validity of handles */
480 #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
481 #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
482 #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
483 #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
484 #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
485 #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
487 #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
488 return(ERROR(ERRDOS,ERRbadfid))
489 #define CHECK_READ(fnum) if (!Files[fnum].can_read) \
490 return(ERROR(ERRDOS,ERRbadaccess))
491 #define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
492 return(ERROR(ERRDOS,ERRbadaccess))
493 #define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
494 return(CACHED_ERROR(fnum))
496 /* translates a connection number into a service number */
497 #define SNUM(cnum) (Connections[cnum].service)
499 /* access various service details */
500 #define SERVICE(snum) (lp_servicename(snum))
501 #define PRINTCAP (lp_printcapname())
502 #define PRINTCOMMAND(snum) (lp_printcommand(snum))
503 #define PRINTERNAME(snum) (lp_printername(snum))
504 #define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
505 #define VALID_SNUM(snum) (lp_snum_ok(snum))
506 #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
507 #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
508 #define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
509 #define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
510 #define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
511 #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
512 #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
513 #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
514 #ifdef SMB_PASSWD
515 #define SMBENCRYPT() (lp_encrypted_passwords())
516 #else
517 #define SMBENCRYPT() (False)
518 #endif
520 /* the basic packet size, assuming no words or bytes */
521 #define smb_size 39
523 /* offsets into message for common items */
524 #define smb_com 8
525 #define smb_rcls 9
526 #define smb_reh 10
527 #define smb_err 11
528 #define smb_flg 13
529 #define smb_flg2 14
530 #define smb_reb 13
531 #define smb_tid 28
532 #define smb_pid 30
533 #define smb_uid 32
534 #define smb_mid 34
535 #define smb_wct 36
536 #define smb_vwv 37
537 #define smb_vwv0 37
538 #define smb_vwv1 39
539 #define smb_vwv2 41
540 #define smb_vwv3 43
541 #define smb_vwv4 45
542 #define smb_vwv5 47
543 #define smb_vwv6 49
544 #define smb_vwv7 51
545 #define smb_vwv8 53
546 #define smb_vwv9 55
547 #define smb_vwv10 57
548 #define smb_vwv11 59
549 #define smb_vwv12 61
550 #define smb_vwv13 63
551 #define smb_vwv14 65
552 #define smb_vwv15 67
553 #define smb_vwv16 69
554 #define smb_vwv17 71
557 /* the complete */
558 #define SMBmkdir 0x00 /* create directory */
559 #define SMBrmdir 0x01 /* delete directory */
560 #define SMBopen 0x02 /* open file */
561 #define SMBcreate 0x03 /* create file */
562 #define SMBclose 0x04 /* close file */
563 #define SMBflush 0x05 /* flush file */
564 #define SMBunlink 0x06 /* delete file */
565 #define SMBmv 0x07 /* rename file */
566 #define SMBgetatr 0x08 /* get file attributes */
567 #define SMBsetatr 0x09 /* set file attributes */
568 #define SMBread 0x0A /* read from file */
569 #define SMBwrite 0x0B /* write to file */
570 #define SMBlock 0x0C /* lock byte range */
571 #define SMBunlock 0x0D /* unlock byte range */
572 #define SMBctemp 0x0E /* create temporary file */
573 #define SMBmknew 0x0F /* make new file */
574 #define SMBchkpth 0x10 /* check directory path */
575 #define SMBexit 0x11 /* process exit */
576 #define SMBlseek 0x12 /* seek */
577 #define SMBtcon 0x70 /* tree connect */
578 #define SMBtconX 0x75 /* tree connect and X*/
579 #define SMBtdis 0x71 /* tree disconnect */
580 #define SMBnegprot 0x72 /* negotiate protocol */
581 #define SMBdskattr 0x80 /* get disk attributes */
582 #define SMBsearch 0x81 /* search directory */
583 #define SMBsplopen 0xC0 /* open print spool file */
584 #define SMBsplwr 0xC1 /* write to print spool file */
585 #define SMBsplclose 0xC2 /* close print spool file */
586 #define SMBsplretq 0xC3 /* return print queue */
587 #define SMBsends 0xD0 /* send single block message */
588 #define SMBsendb 0xD1 /* send broadcast message */
589 #define SMBfwdname 0xD2 /* forward user name */
590 #define SMBcancelf 0xD3 /* cancel forward */
591 #define SMBgetmac 0xD4 /* get machine name */
592 #define SMBsendstrt 0xD5 /* send start of multi-block message */
593 #define SMBsendend 0xD6 /* send end of multi-block message */
594 #define SMBsendtxt 0xD7 /* send text of multi-block message */
596 /* Core+ protocol */
597 #define SMBlockread 0x13 /* Lock a range and read */
598 #define SMBwriteunlock 0x14 /* Unlock a range then write */
599 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
600 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
601 #define SMBwritec 0x20 /* secondary write request */
602 #define SMBwriteclose 0x2c /* write a file then close it */
604 /* dos extended protocol */
605 #define SMBreadBraw 0x1A /* read block raw */
606 #define SMBreadBmpx 0x1B /* read block multiplexed */
607 #define SMBreadBs 0x1C /* read block (secondary response) */
608 #define SMBwriteBraw 0x1D /* write block raw */
609 #define SMBwriteBmpx 0x1E /* write block multiplexed */
610 #define SMBwriteBs 0x1F /* write block (secondary request) */
611 #define SMBwriteC 0x20 /* write complete response */
612 #define SMBsetattrE 0x22 /* set file attributes expanded */
613 #define SMBgetattrE 0x23 /* get file attributes expanded */
614 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
615 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
616 #define SMBtranss 0x26 /* transaction (secondary request/response) */
617 #define SMBioctl 0x27 /* IOCTL */
618 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
619 #define SMBcopy 0x29 /* copy */
620 #define SMBmove 0x2A /* move */
621 #define SMBecho 0x2B /* echo */
622 #define SMBopenX 0x2D /* open and X */
623 #define SMBreadX 0x2E /* read and X */
624 #define SMBwriteX 0x2F /* write and X */
625 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
626 #define SMBffirst 0x82 /* find first */
627 #define SMBfunique 0x83 /* find unique */
628 #define SMBfclose 0x84 /* find close */
629 #define SMBinvalid 0xFE /* invalid command */
631 /* Extended 2.0 protocol */
632 #define SMBtrans2 0x32 /* TRANS2 protocol set */
633 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
634 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
635 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
636 #define SMBulogoffX 0x74 /* user logoff */
639 /* these are the TRANS2 sub commands */
640 #define TRANSACT2_OPEN 0
641 #define TRANSACT2_FINDFIRST 1
642 #define TRANSACT2_FINDNEXT 2
643 #define TRANSACT2_QFSINFO 3
644 #define TRANSACT2_SETFSINFO 4
645 #define TRANSACT2_QPATHINFO 5
646 #define TRANSACT2_SETPATHINFO 6
647 #define TRANSACT2_QFILEINFO 7
648 #define TRANSACT2_SETFILEINFO 8
649 #define TRANSACT2_FSCTL 9
650 #define TRANSACT2_IOCTL 10
651 #define TRANSACT2_FINDNOTIFYFIRST 11
652 #define TRANSACT2_FINDNOTIFYNEXT 12
653 #define TRANSACT2_MKDIR 13
656 /* these are the trans2 sub fields for primary requests */
657 #define smb_tpscnt smb_vwv0
658 #define smb_tdscnt smb_vwv1
659 #define smb_mprcnt smb_vwv2
660 #define smb_mdrcnt smb_vwv3
661 #define smb_msrcnt smb_vwv4
662 #define smb_flags smb_vwv5
663 #define smb_timeout smb_vwv6
664 #define smb_pscnt smb_vwv9
665 #define smb_psoff smb_vwv10
666 #define smb_dscnt smb_vwv11
667 #define smb_dsoff smb_vwv12
668 #define smb_suwcnt smb_vwv13
669 #define smb_setup smb_vwv14
670 #define smb_setup0 smb_setup
671 #define smb_setup1 (smb_setup+2)
672 #define smb_setup2 (smb_setup+4)
674 /* these are for the secondary requests */
675 #define smb_spscnt smb_vwv2
676 #define smb_spsoff smb_vwv3
677 #define smb_spsdisp smb_vwv4
678 #define smb_sdscnt smb_vwv5
679 #define smb_sdsoff smb_vwv6
680 #define smb_sdsdisp smb_vwv7
681 #define smb_sfid smb_vwv8
683 /* and these for responses */
684 #define smb_tprcnt smb_vwv0
685 #define smb_tdrcnt smb_vwv1
686 #define smb_prcnt smb_vwv3
687 #define smb_proff smb_vwv4
688 #define smb_prdisp smb_vwv5
689 #define smb_drcnt smb_vwv6
690 #define smb_droff smb_vwv7
691 #define smb_drdisp smb_vwv8
693 /* where to find the base of the SMB packet proper */
694 #define smb_base(buf) (((char *)(buf))+4)
697 #define SUCCESS 0 /* The request was successful. */
698 #define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
699 #define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
700 #define ERRHRD 0x03 /* Error is an hardware error. */
701 #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
703 #ifdef __STDC__
704 int Debug1(char *, ...);
705 #else
706 int Debug1();
707 #endif
709 #ifdef DFS_AUTH
710 void dfs_unlogin(void);
711 extern int dcelogin_atmost_once;
712 #endif
714 #if AJT
715 void ajt_panic(void);
716 #endif
718 #ifdef NOSTRDUP
719 char *strdup(char *s);
720 #endif
722 #ifdef REPLACE_STRLEN
723 int Strlen(char *);
724 #endif
726 #ifdef REPLACE_STRSTR
727 char *Strstr(char *s, char *p);
728 #endif
730 #ifndef MIN
731 #define MIN(a,b) ((a)<(b)?(a):(b))
732 #endif
733 #ifndef MAX
734 #define MAX(a,b) ((a)>(b)?(a):(b))
735 #endif
737 #ifndef ABS
738 #define ABS(a) ((a)>0?(a):(-(a)))
739 #endif
741 #ifndef SIGNAL_CAST
742 #define SIGNAL_CAST
743 #endif
745 #ifndef SELECT_CAST
746 #define SELECT_CAST
747 #endif
750 /* Some POSIX definitions for those without */
752 #ifndef S_IFDIR
753 #define S_IFDIR 0x4000
754 #endif
755 #ifndef S_ISDIR
756 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
757 #endif
758 #ifndef S_IRWXU
759 #define S_IRWXU 00700 /* read, write, execute: owner */
760 #endif
761 #ifndef S_IRUSR
762 #define S_IRUSR 00400 /* read permission: owner */
763 #endif
764 #ifndef S_IWUSR
765 #define S_IWUSR 00200 /* write permission: owner */
766 #endif
767 #ifndef S_IXUSR
768 #define S_IXUSR 00100 /* execute permission: owner */
769 #endif
770 #ifndef S_IRWXG
771 #define S_IRWXG 00070 /* read, write, execute: group */
772 #endif
773 #ifndef S_IRGRP
774 #define S_IRGRP 00040 /* read permission: group */
775 #endif
776 #ifndef S_IWGRP
777 #define S_IWGRP 00020 /* write permission: group */
778 #endif
779 #ifndef S_IXGRP
780 #define S_IXGRP 00010 /* execute permission: group */
781 #endif
782 #ifndef S_IRWXO
783 #define S_IRWXO 00007 /* read, write, execute: other */
784 #endif
785 #ifndef S_IROTH
786 #define S_IROTH 00004 /* read permission: other */
787 #endif
788 #ifndef S_IWOTH
789 #define S_IWOTH 00002 /* write permission: other */
790 #endif
791 #ifndef S_IXOTH
792 #define S_IXOTH 00001 /* execute permission: other */
793 #endif
796 /* these are used in NetServerEnum to choose what to receive */
797 #define SV_TYPE_WORKSTATION 0x00000001
798 #define SV_TYPE_SERVER 0x00000002
799 #define SV_TYPE_SQLSERVER 0x00000004
800 #define SV_TYPE_DOMAIN_CTRL 0x00000008
801 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
802 #define SV_TYPE_TIME_SOURCE 0x00000020
803 #define SV_TYPE_AFP 0x00000040
804 #define SV_TYPE_NOVELL 0x00000080
805 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
806 #define SV_TYPE_PRINTQ_SERVER 0x00000200
807 #define SV_TYPE_DIALIN_SERVER 0x00000400
808 #define SV_TYPE_SERVER_UNIX 0x00000800
809 #define SV_TYPE_NT 0x00001000
810 #define SV_TYPE_WFW 0x00002000
811 #define SV_TYPE_SERVER_MFPN 0x00004000
812 #define SV_TYPE_SERVER_NT 0x00008000
813 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
814 #define SV_TYPE_BACKUP_BROWSER 0x00020000
815 #define SV_TYPE_MASTER_BROWSER 0x00040000
816 #define SV_TYPE_DOMAIN_MASTER 0x00080000
817 #define SV_TYPE_SERVER_OSF 0x00100000
818 #define SV_TYPE_SERVER_VMS 0x00200000
819 #define SV_TYPE_WIN95_PLUS 0x00400000
820 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
821 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
822 #define SV_TYPE_DOMAIN_ENUM 0x80000000
823 #define SV_TYPE_ALL 0xFFFFFFFF
825 /* what server type are we currently - JHT Says we ARE 4.20 */
826 /* this was set by JHT in liaison with Jeremy Allison early 1997 */
827 /* setting to 4.20 at same time as announcing ourselves as NT Server */
828 /* History: */
829 /* Version 4.0 - never made public */
830 /* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */
831 /* - Reappeared in 1.9.16p11 with fixed smbd services */
832 /* Version 4.20 - To indicate that nmbd and browsing now works better */
834 #define MAJOR_VERSION 0x04
835 #define MINOR_VERSION 0x02
837 /* Browser Election Values */
838 #define BROWSER_ELECTION_VERSION 0x010f
839 #define BROWSER_CONSTANT 0xaa55
842 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
844 #define CAP_RAW_MODE 0x0001
845 #define CAP_MPX_MODE 0x0002
846 #define CAP_UNICODE 0x0004
847 #define CAP_LARGE_FILES 0x0008
848 #define CAP_NT_SMBS 0x0010
849 #define CAP_RPC_REMOTE_APIS 0x0020
850 #define CAP_STATUS32 0x0040
851 #define CAP_LEVEL_II_OPLOCKS 0x0080
852 #define CAP_LOCK_AND_READ 0x0100
853 #define CAP_NT_FIND 0x0200
854 #define CAP_DFS 0x1000
855 #define CAP_LARGE_READX 0x4000
857 /* protocol types. It assumes that higher protocols include lower protocols
858 as subsets */
859 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
861 /* security levels */
862 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
864 /* printing types */
865 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
866 PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
869 /* case handling */
870 enum case_handling {CASE_LOWER,CASE_UPPER};
873 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
874 structures. We cannot define these as actual structures
875 due to possible differences in structure packing
876 on different machines/compilers. */
878 #define SMB_LPID_OFFSET(indx) (10 * (indx))
879 #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
880 #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
882 /* Macro to cache an error in a write_bmpx_struct */
883 #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
884 w->wr_discard = True, -1)
885 /* Macro to test if an error has been cached for this fnum */
886 #define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
887 Files[(fnum)].wbmpx_ptr && \
888 Files[(fnum)].wbmpx_ptr->wr_discard)
889 /* Macro to turn the cached error into an error packet */
890 #define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
892 /* these are the datagram types */
893 #define DGRAM_DIRECT_UNIQUE 0x10
895 #define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
897 /* this is how errors are generated */
898 #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
900 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
903 * Global value meaing that the smb_uid field should be
904 * ingored (in share level security and protocol level == CORE)
907 #define UID_FIELD_INVALID 0
908 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
910 #endif
912 /* Default client code page - 850 - Western European */
913 #define DEFAULT_CLIENT_CODE_PAGE 850
915 /* _SMB_H */