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