2 Unix SMB/Netbios implementation.
4 SMB parameters and setup
5 Copyright (C) Andrew Tridgell 1992-1995
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.
24 #ifndef MAX_CONNECTIONS
25 #define MAX_CONNECTIONS 127
28 #ifndef MAX_OPEN_FILES
29 #define MAX_OPEN_FILES 50
33 #define GUEST_ACCOUNT "nobody"
36 #define BUFFER_SIZE (0xFFFF)
37 #define SAFETY_MARGIN 1024
40 # define EXTERN extern
44 #define DGRAM_PORT 138
49 #define BOOLSTR(b) ((b) ? "Yes" : "No")
50 #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
51 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
52 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
57 Samba needs type definitions for int16, int32, uint16 and uint32.
59 Normally these are signed and unsigned 16 and 32 bit integers, but
60 they actually only need to be at least 16 and 32 bits
61 respectively. Thus if your word size is 8 bytes just defining them
62 as signed and unsigned int will work.
65 /* afs/stds.h defines int16 and int32 */
72 typedef unsigned short uint16;
76 typedef unsigned int uint32;
80 #define uchar unsigned char
86 #define uint16 unsigned short
89 #define uint32 unsigned int
94 #ifndef DEF_CREATE_MASK
95 #define DEF_CREATE_MASK (0755)
98 #ifndef DEFAULT_PIPE_TIMEOUT
99 #define DEFAULT_PIPE_TIMEOUT 10000000 /* Ten seconds */
102 /* how long to wait for secondary SMB packets (seconds) */
103 #define SMB_SECONDARY_WAIT 30
107 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
109 EXTERN int syslog_level;
111 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
114 /* this defines the error codes that receive_smb can put in smb_read_error */
115 #define READ_TIMEOUT 1
120 #define DIR_STRUCT_SIZE 43
122 /* these define all the command types recognised by the server - there
123 are lots of gaps so probably there are some rare commands that are not
126 #define pSETDIR '\377'
128 /* these define the attribute byte as seen by DOS */
129 #define aRONLY (1L<<0)
130 #define aHIDDEN (1L<<1)
131 #define aSYSTEM (1L<<2)
132 #define aVOLID (1L<<3)
134 #define aARCH (1L<<5)
145 #define STYPE_DISKTREE 0 /* Disk drive */
146 #define STYPE_PRINTQ 1 /* Spooler queue */
147 #define STYPE_DEVICE 2 /* Serial device */
148 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
150 /* SMB X/Open error codes for the ERRdos error class */
151 #define ERRbadfunc 1 /* Invalid function (or system call) */
152 #define ERRbadfile 2 /* File not found (pathname error) */
153 #define ERRbadpath 3 /* Directory not found */
154 #define ERRnofids 4 /* Too many open files */
155 #define ERRnoaccess 5 /* Access denied */
156 #define ERRbadfid 6 /* Invalid fid */
157 #define ERRnomem 8 /* Out of memory */
158 #define ERRbadmem 9 /* Invalid memory block address */
159 #define ERRbadenv 10 /* Invalid environment */
160 #define ERRbadaccess 12 /* Invalid open mode */
161 #define ERRbaddata 13 /* Invalid data (only from ioctl call) */
162 #define ERRres 14 /* reserved */
163 #define ERRbaddrive 15 /* Invalid drive */
164 #define ERRremcd 16 /* Attempt to delete current directory */
165 #define ERRdiffdevice 17 /* rename/move across different filesystems */
166 #define ERRnofiles 18 /* no more files found in file search */
167 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
168 #define ERRlock 33 /* Lock request conflicts with existing lock */
169 #define ERRfilexists 80 /* File in operation already exists */
170 #define ERRbadpipe 230 /* Named pipe invalid */
171 #define ERRpipebusy 231 /* All instances of pipe are busy */
172 #define ERRpipeclosing 232 /* named pipe close in progress */
173 #define ERRnotconnected 233 /* No process on other end of named pipe */
174 #define ERRmoredata 234 /* More data to be returned */
175 #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
176 #define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not suppored */
177 #define ERRunknownlevel 124
178 #define ERRunknownipc 2142
181 /* here's a special one from observing NT */
182 #define ERRnoipc 66 /* don't support ipc */
184 /* Error codes for the ERRSRV class */
186 #define ERRerror 1 /* Non specific error code */
187 #define ERRbadpw 2 /* Bad password */
188 #define ERRbadtype 3 /* reserved */
189 #define ERRaccess 4 /* No permissions to do the requested operation */
190 #define ERRinvnid 5 /* tid invalid */
191 #define ERRinvnetname 6 /* Invalid servername */
192 #define ERRinvdevice 7 /* Invalid device */
193 #define ERRqfull 49 /* Print queue full */
194 #define ERRqtoobig 50 /* Queued item too big */
195 #define ERRinvpfid 52 /* Invalid print file in smb_fid */
196 #define ERRsmbcmd 64 /* Unrecognised command */
197 #define ERRsrverror 65 /* smb server internal error */
198 #define ERRfilespecs 67 /* fid and pathname invalid combination */
199 #define ERRbadlink 68 /* reserved */
200 #define ERRbadpermits 69 /* Access specified for a file is not valid */
201 #define ERRbadpid 70 /* reserved */
202 #define ERRsetattrmode 71 /* attribute mode invalid */
203 #define ERRpaused 81 /* Message server paused */
204 #define ERRmsgoff 82 /* Not receiving messages */
205 #define ERRnoroom 83 /* No room for message */
206 #define ERRrmuns 87 /* too many remote usernames */
207 #define ERRtimeout 88 /* operation timed out */
208 #define ERRnoresource 89 /* No resources currently available for request. */
209 #define ERRtoomanyuids 90 /* too many userids */
210 #define ERRbaduid 91 /* bad userid */
211 #define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
212 #define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
213 #define ERRcontMPX 252 /* resume MPX mode */
214 #define ERRbadPW /* reserved */
215 #define ERRnosupport 0xFFFF
216 #define ERRunknownsmb 22 /* from NT 3.5 response */
219 /* Error codes for the ERRHRD class */
221 #define ERRnowrite 19 /* read only media */
222 #define ERRbadunit 20 /* Unknown device */
223 #define ERRnotready 21 /* Drive not ready */
224 #define ERRbadcmd 22 /* Unknown command */
225 #define ERRdata 23 /* Data (CRC) error */
226 #define ERRbadreq 24 /* Bad request structure length */
228 #define ERRbadmedia 26
229 #define ERRbadsector 27
230 #define ERRnopaper 28
231 #define ERRwrite 29 /* write fault */
232 #define ERRread 30 /* read fault */
233 #define ERRgeneral 31 /* General hardware failure */
234 #define ERRwrongdisk 34
235 #define ERRFCBunavail 35
236 #define ERRsharebufexc 36 /* share buffer exceeded */
237 #define ERRdiskfull 39
240 typedef char pstring[1024];
241 typedef char fstring[128];
242 typedef fstring string;
248 unsigned char *smb_passwd; /* Null if no password */
249 unsigned char *smb_nt_passwd; /* Null if no password */
250 /* Other fields / flags may be added later */
254 struct current_user {
268 /* these times are normally kept in GMT */
276 /* Structure used when SMBwritebmpx is active */
279 int wr_total_written; /* So we know when to discard this */
282 int32 wr_error; /* Cached errors */
283 BOOL wr_mode; /* write through mode) */
284 BOOL wr_discard; /* discard all further data */
296 write_bmpx_struct *wbmpx_ptr;
312 int list[UID_CACHE_SIZE];
319 int uid; /* uid of user who *opened* this connection */
320 int gid; /* gid of user who *opened* this connection */
321 struct uid_cache uid_cache;
331 char *user; /* name of user who *opened* this connection */
332 /* following groups stuff added by ih */
333 /* This groups info is valid for the user that *opened* the connection */
336 int *igroups; /* an integer version - some OSes are broken :-( */
345 int uid; /* uid of a validated user */
346 int gid; /* gid of a validated user */
347 fstring name; /* name of a validated user */
349 /* following groups stuff added by ih */
350 /* This groups info is needed for when we become_user() for this uid */
353 int *user_igroups; /* an integer version - some OSes are broken :-( */
357 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
368 } print_queue_struct;
370 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
376 } print_status_struct;
378 /* used for server information: client, nameserv and ipc */
379 struct server_info_struct
384 fstring domain; /* used ONLY in ipc.c NOT namework.c */
385 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
389 /* used for network interfaces */
392 struct interface *next;
394 struct in_addr bcast;
395 struct in_addr nmask;
398 /* this is used for smbstatus */
399 struct connect_record
413 #define LOCKING_VERSION 2
415 /* these are useful macros for checking validity of handles */
416 #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
417 #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
418 #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
419 #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
420 #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
421 #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
423 #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
424 return(ERROR(ERRDOS,ERRbadfid))
425 #define CHECK_READ(fnum) if (!Files[fnum].can_read) \
426 return(ERROR(ERRDOS,ERRbadaccess))
427 #define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
428 return(ERROR(ERRDOS,ERRbadaccess))
429 #define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
430 return(CACHED_ERROR(fnum))
432 /* translates a connection number into a service number */
433 #define SNUM(cnum) (Connections[cnum].service)
435 /* access various service details */
436 #define SERVICE(snum) (lp_servicename(snum))
437 #define PRINTCAP (lp_printcapname())
438 #define PRINTCOMMAND(snum) (lp_printcommand(snum))
439 #define PRINTERNAME(snum) (lp_printername(snum))
440 #define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
441 #define VALID_SNUM(snum) (lp_snum_ok(snum))
442 #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
443 #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
444 #define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
445 #define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
446 #define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
447 #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
448 #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
449 #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
450 #define CREATE_MODE(cnum) (lp_create_mode(SNUM(cnum)) | 0700)
452 #define SMBENCRYPT() (lp_encrypted_passwords())
454 #define SMBENCRYPT() (False)
457 /* the basic packet size, assuming no words or bytes */
460 /* offsets into message for common items */
495 #define SMBmkdir 0x00 /* create directory */
496 #define SMBrmdir 0x01 /* delete directory */
497 #define SMBopen 0x02 /* open file */
498 #define SMBcreate 0x03 /* create file */
499 #define SMBclose 0x04 /* close file */
500 #define SMBflush 0x05 /* flush file */
501 #define SMBunlink 0x06 /* delete file */
502 #define SMBmv 0x07 /* rename file */
503 #define SMBgetatr 0x08 /* get file attributes */
504 #define SMBsetatr 0x09 /* set file attributes */
505 #define SMBread 0x0A /* read from file */
506 #define SMBwrite 0x0B /* write to file */
507 #define SMBlock 0x0C /* lock byte range */
508 #define SMBunlock 0x0D /* unlock byte range */
509 #define SMBctemp 0x0E /* create temporary file */
510 #define SMBmknew 0x0F /* make new file */
511 #define SMBchkpth 0x10 /* check directory path */
512 #define SMBexit 0x11 /* process exit */
513 #define SMBlseek 0x12 /* seek */
514 #define SMBtcon 0x70 /* tree connect */
515 #define SMBtconX 0x75 /* tree connect and X*/
516 #define SMBtdis 0x71 /* tree disconnect */
517 #define SMBnegprot 0x72 /* negotiate protocol */
518 #define SMBdskattr 0x80 /* get disk attributes */
519 #define SMBsearch 0x81 /* search directory */
520 #define SMBsplopen 0xC0 /* open print spool file */
521 #define SMBsplwr 0xC1 /* write to print spool file */
522 #define SMBsplclose 0xC2 /* close print spool file */
523 #define SMBsplretq 0xC3 /* return print queue */
524 #define SMBsends 0xD0 /* send single block message */
525 #define SMBsendb 0xD1 /* send broadcast message */
526 #define SMBfwdname 0xD2 /* forward user name */
527 #define SMBcancelf 0xD3 /* cancel forward */
528 #define SMBgetmac 0xD4 /* get machine name */
529 #define SMBsendstrt 0xD5 /* send start of multi-block message */
530 #define SMBsendend 0xD6 /* send end of multi-block message */
531 #define SMBsendtxt 0xD7 /* send text of multi-block message */
534 #define SMBlockread 0x13 /* Lock a range and read */
535 #define SMBwriteunlock 0x14 /* Unlock a range then write */
536 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
537 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
538 #define SMBwritec 0x20 /* secondary write request */
539 #define SMBwriteclose 0x2c /* write a file then close it */
541 /* dos extended protocol */
542 #define SMBreadBraw 0x1A /* read block raw */
543 #define SMBreadBmpx 0x1B /* read block multiplexed */
544 #define SMBreadBs 0x1C /* read block (secondary response) */
545 #define SMBwriteBraw 0x1D /* write block raw */
546 #define SMBwriteBmpx 0x1E /* write block multiplexed */
547 #define SMBwriteBs 0x1F /* write block (secondary request) */
548 #define SMBwriteC 0x20 /* write complete response */
549 #define SMBsetattrE 0x22 /* set file attributes expanded */
550 #define SMBgetattrE 0x23 /* get file attributes expanded */
551 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
552 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
553 #define SMBtranss 0x26 /* transaction (secondary request/response) */
554 #define SMBioctl 0x27 /* IOCTL */
555 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
556 #define SMBcopy 0x29 /* copy */
557 #define SMBmove 0x2A /* move */
558 #define SMBecho 0x2B /* echo */
559 #define SMBopenX 0x2D /* open and X */
560 #define SMBreadX 0x2E /* read and X */
561 #define SMBwriteX 0x2F /* write and X */
562 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
563 #define SMBffirst 0x82 /* find first */
564 #define SMBfunique 0x83 /* find unique */
565 #define SMBfclose 0x84 /* find close */
566 #define SMBinvalid 0xFE /* invalid command */
568 /* Extended 2.0 protocol */
569 #define SMBtrans2 0x32 /* TRANS2 protocol set */
570 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
571 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
572 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
573 #define SMBulogoffX 0x74 /* user logoff */
576 /* these are the TRANS2 sub commands */
577 #define TRANSACT2_OPEN 0
578 #define TRANSACT2_FINDFIRST 1
579 #define TRANSACT2_FINDNEXT 2
580 #define TRANSACT2_QFSINFO 3
581 #define TRANSACT2_SETFSINFO 4
582 #define TRANSACT2_QPATHINFO 5
583 #define TRANSACT2_SETPATHINFO 6
584 #define TRANSACT2_QFILEINFO 7
585 #define TRANSACT2_SETFILEINFO 8
586 #define TRANSACT2_FSCTL 9
587 #define TRANSACT2_IOCTL 10
588 #define TRANSACT2_FINDNOTIFYFIRST 11
589 #define TRANSACT2_FINDNOTIFYNEXT 12
590 #define TRANSACT2_MKDIR 13
593 /* these are the trans2 sub fields for primary requests */
594 #define smb_tpscnt smb_vwv0
595 #define smb_tdscnt smb_vwv1
596 #define smb_mprcnt smb_vwv2
597 #define smb_mdrcnt smb_vwv3
598 #define smb_msrcnt smb_vwv4
599 #define smb_flags smb_vwv5
600 #define smb_timeout smb_vwv6
601 #define smb_pscnt smb_vwv9
602 #define smb_psoff smb_vwv10
603 #define smb_dscnt smb_vwv11
604 #define smb_dsoff smb_vwv12
605 #define smb_suwcnt smb_vwv13
606 #define smb_setup smb_vwv14
607 #define smb_setup0 smb_setup
608 #define smb_setup1 (smb_setup+2)
609 #define smb_setup2 (smb_setup+4)
611 /* these are for the secondary requests */
612 #define smb_spscnt smb_vwv2
613 #define smb_spsoff smb_vwv3
614 #define smb_spsdisp smb_vwv4
615 #define smb_sdscnt smb_vwv5
616 #define smb_sdsoff smb_vwv6
617 #define smb_sdsdisp smb_vwv7
618 #define smb_sfid smb_vwv8
620 /* and these for responses */
621 #define smb_tprcnt smb_vwv0
622 #define smb_tdrcnt smb_vwv1
623 #define smb_prcnt smb_vwv3
624 #define smb_proff smb_vwv4
625 #define smb_prdisp smb_vwv5
626 #define smb_drcnt smb_vwv6
627 #define smb_droff smb_vwv7
628 #define smb_drdisp smb_vwv8
630 /* where to find the base of the SMB packet proper */
631 #define smb_base(buf) (((char *)(buf))+4)
634 #define SUCCESS 0 /* The request was successful. */
635 #define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
636 #define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
637 #define ERRHRD 0x03 /* Error is an hardware error. */
638 #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
640 /* structure used to hold the incoming hosts info */
642 char *name; /* host name */
643 char *addr; /* host address */
644 struct sockaddr_in *sin; /* their side of the link */
648 int Debug1(char *, ...);
654 void dfs_unlogin(void);
655 extern int dcelogin_atmost_once;
659 void ajt_panic(void);
663 char *strdup(char *s);
666 #ifdef REPLACE_STRLEN
670 #ifdef REPLACE_STRSTR
671 char *Strstr(char *s, char *p);
675 #define MIN(a,b) ((a)<(b)?(a):(b))
678 #define MAX(a,b) ((a)>(b)?(a):(b))
682 #define ABS(a) ((a)>0?(a):(-(a)))
694 /* Some POSIX definitions for those without */
697 #define S_IFDIR 0x4000
700 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
703 #define S_IRWXU 00700 /* read, write, execute: owner */
706 #define S_IRUSR 00400 /* read permission: owner */
709 #define S_IWUSR 00200 /* write permission: owner */
712 #define S_IXUSR 00100 /* execute permission: owner */
715 #define S_IRWXG 00070 /* read, write, execute: group */
718 #define S_IRGRP 00040 /* read permission: group */
721 #define S_IWGRP 00020 /* write permission: group */
724 #define S_IXGRP 00010 /* execute permission: group */
727 #define S_IRWXO 00007 /* read, write, execute: other */
730 #define S_IROTH 00004 /* read permission: other */
733 #define S_IWOTH 00002 /* write permission: other */
736 #define S_IXOTH 00001 /* execute permission: other */
740 /* these are used in NetServerEnum to choose what to receive */
741 #define SV_TYPE_WORKSTATION 0x00000001
742 #define SV_TYPE_SERVER 0x00000002
743 #define SV_TYPE_SQLSERVER 0x00000004
744 #define SV_TYPE_DOMAIN_CTRL 0x00000008
745 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
746 #define SV_TYPE_TIME_SOURCE 0x00000020
747 #define SV_TYPE_AFP 0x00000040
748 #define SV_TYPE_NOVELL 0x00000080
749 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
750 #define SV_TYPE_PRINTQ_SERVER 0x00000200
751 #define SV_TYPE_DIALIN_SERVER 0x00000400
752 #define SV_TYPE_SERVER_UNIX 0x00000800
753 #define SV_TYPE_NT 0x00001000
754 #define SV_TYPE_WFW 0x00002000
755 #define SV_TYPE_SERVER_MFPN 0x00004000
756 #define SV_TYPE_SERVER_NT 0x00008000
757 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
758 #define SV_TYPE_BACKUP_BROWSER 0x00020000
759 #define SV_TYPE_MASTER_BROWSER 0x00040000
760 #define SV_TYPE_DOMAIN_MASTER 0x00080000
761 #define SV_TYPE_SERVER_OSF 0x00100000
762 #define SV_TYPE_SERVER_VMS 0x00200000
763 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
764 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
765 #define SV_TYPE_DOMAIN_ENUM 0x80000000
766 #define SV_TYPE_ALL 0xFFFFFFFF
770 /* protocol types. It assumes that higher protocols include lower protocols
772 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
774 /* security levels */
775 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
778 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
779 PRINT_QNX,PRINT_PLP};
783 enum case_handling {CASE_LOWER,CASE_UPPER};
786 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
787 structures. We cannot define these as actual structures
788 due to possible differences in structure packing
789 on different machines/compilers. */
791 #define SMB_LPID_OFFSET(indx) (10 * (indx))
792 #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
793 #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
795 /* Macro to cache an error in a write_bmpx_struct */
796 #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
797 w->wr_discard = True, -1)
798 /* Macro to test if an error has been cached for this fnum */
799 #define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
800 Files[(fnum)].wbmpx_ptr && \
801 Files[(fnum)].wbmpx_ptr->wr_discard)
802 /* Macro to turn the cached error into an error packet */
803 #define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
805 /* these are the datagram types */
806 #define DGRAM_DIRECT_UNIQUE 0x10
808 #define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
810 /* this is how errors are generated */
811 #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
813 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))