luke's first attempt at using cvs
[Samba.git] / source / include / smb.h
blob0e9c9983d25344408b81b49cdc64ac4c6969041c
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
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.
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 #ifndef EXTERN
40 # define EXTERN extern
41 #endif
43 #define NMB_PORT 137
44 #define DGRAM_PORT 138
45 #define SMB_PORT 139
47 #define False (0)
48 #define True (1)
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)))
54 typedef int BOOL;
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 */
66 #ifndef AFS_AUTH
67 typedef short int16;
68 typedef int int32;
69 #endif
71 #ifndef uint16
72 typedef unsigned short uint16;
73 #endif
75 #ifndef uint32
76 typedef unsigned int uint32;
77 #endif
79 #ifndef uchar
80 #define uchar unsigned char
81 #endif
82 #ifndef int16
83 #define int16 short
84 #endif
85 #ifndef uint16
86 #define uint16 unsigned short
87 #endif
88 #ifndef uint32
89 #define uint32 unsigned int
90 #endif
92 #define SIZEOFWORD 2
94 #ifndef DEF_CREATE_MASK
95 #define DEF_CREATE_MASK (0755)
96 #endif
98 #ifndef DEFAULT_PIPE_TIMEOUT
99 #define DEFAULT_PIPE_TIMEOUT 10000000 /* Ten seconds */
100 #endif
102 /* how long to wait for secondary SMB packets (seconds) */
103 #define SMB_SECONDARY_WAIT 30
105 /* debugging code */
106 #ifndef SYSLOG
107 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
108 #else
109 EXTERN int syslog_level;
111 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? \
112 (syslog_level = (level), Debug1 body):0)
113 #endif
115 #define DIR_STRUCT_SIZE 43
117 /* these define all the command types recognised by the server - there
118 are lots of gaps so probably there are some rare commands that are not
119 implemented */
121 #define pSETDIR '\377'
123 /* these define the attribute byte as seen by DOS */
124 #define aRONLY (1L<<0)
125 #define aHIDDEN (1L<<1)
126 #define aSYSTEM (1L<<2)
127 #define aVOLID (1L<<3)
128 #define aDIR (1L<<4)
129 #define aARCH (1L<<5)
131 /* deny modes */
132 #define DENY_DOS 0
133 #define DENY_ALL 1
134 #define DENY_WRITE 2
135 #define DENY_READ 3
136 #define DENY_NONE 4
137 #define DENY_FCB 7
139 /* share types */
140 #define STYPE_DISKTREE 0 /* Disk drive */
141 #define STYPE_PRINTQ 1 /* Spooler queue */
142 #define STYPE_DEVICE 2 /* Serial device */
143 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
145 /* SMB X/Open error codes for the ERRdos error class */
146 #define ERRbadfunc 1 /* Invalid function (or system call) */
147 #define ERRbadfile 2 /* File not found (pathname error) */
148 #define ERRbadpath 3 /* Directory not found */
149 #define ERRnofids 4 /* Too many open files */
150 #define ERRnoaccess 5 /* Access denied */
151 #define ERRbadfid 6 /* Invalid fid */
152 #define ERRnomem 8 /* Out of memory */
153 #define ERRbadmem 9 /* Invalid memory block address */
154 #define ERRbadenv 10 /* Invalid environment */
155 #define ERRbadaccess 12 /* Invalid open mode */
156 #define ERRbaddata 13 /* Invalid data (only from ioctl call) */
157 #define ERRres 14 /* reserved */
158 #define ERRbaddrive 15 /* Invalid drive */
159 #define ERRremcd 16 /* Attempt to delete current directory */
160 #define ERRdiffdevice 17 /* rename/move across different filesystems */
161 #define ERRnofiles 18 /* no more files found in file search */
162 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
163 #define ERRlock 33 /* Lock request conflicts with existing lock */
164 #define ERRfilexists 80 /* File in operation already exists */
165 #define ERRbadpipe 230 /* Named pipe invalid */
166 #define ERRpipebusy 231 /* All instances of pipe are busy */
167 #define ERRpipeclosing 232 /* named pipe close in progress */
168 #define ERRnotconnected 233 /* No process on other end of named pipe */
169 #define ERRmoredata 234 /* More data to be returned */
170 #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
171 #define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not suppored */
172 #define ERRunknownlevel 124
173 #define ERRunknownipc 2142
176 /* here's a special one from observing NT */
177 #define ERRnoipc 66 /* don't support ipc */
179 /* Error codes for the ERRSRV class */
181 #define ERRerror 1 /* Non specific error code */
182 #define ERRbadpw 2 /* Bad password */
183 #define ERRbadtype 3 /* reserved */
184 #define ERRaccess 4 /* No permissions to do the requested operation */
185 #define ERRinvnid 5 /* tid invalid */
186 #define ERRinvnetname 6 /* Invalid servername */
187 #define ERRinvdevice 7 /* Invalid device */
188 #define ERRqfull 49 /* Print queue full */
189 #define ERRqtoobig 50 /* Queued item too big */
190 #define ERRinvpfid 52 /* Invalid print file in smb_fid */
191 #define ERRsmbcmd 64 /* Unrecognised command */
192 #define ERRsrverror 65 /* smb server internal error */
193 #define ERRfilespecs 67 /* fid and pathname invalid combination */
194 #define ERRbadlink 68 /* reserved */
195 #define ERRbadpermits 69 /* Access specified for a file is not valid */
196 #define ERRbadpid 70 /* reserved */
197 #define ERRsetattrmode 71 /* attribute mode invalid */
198 #define ERRpaused 81 /* Message server paused */
199 #define ERRmsgoff 82 /* Not receiving messages */
200 #define ERRnoroom 83 /* No room for message */
201 #define ERRrmuns 87 /* too many remote usernames */
202 #define ERRtimeout 88 /* operation timed out */
203 #define ERRnoresource 89 /* No resources currently available for request. */
204 #define ERRtoomanyuids 90 /* too many userids */
205 #define ERRbaduid 91 /* bad userid */
206 #define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
207 #define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
208 #define ERRcontMPX 252 /* resume MPX mode */
209 #define ERRbadPW /* reserved */
210 #define ERRnosupport 0xFFFF
211 #define ERRunknownsmb 22 /* from NT 3.5 response */
214 /* Error codes for the ERRHRD class */
216 #define ERRnowrite 19 /* read only media */
217 #define ERRbadunit 20 /* Unknown device */
218 #define ERRnotready 21 /* Drive not ready */
219 #define ERRbadcmd 22 /* Unknown command */
220 #define ERRdata 23 /* Data (CRC) error */
221 #define ERRbadreq 24 /* Bad request structure length */
222 #define ERRseek 25
223 #define ERRbadmedia 26
224 #define ERRbadsector 27
225 #define ERRnopaper 28
226 #define ERRwrite 29 /* write fault */
227 #define ERRread 30 /* read fault */
228 #define ERRgeneral 31 /* General hardware failure */
229 #define ERRwrongdisk 34
230 #define ERRFCBunavail 35
231 #define ERRsharebufexc 36 /* share buffer exceeded */
232 #define ERRdiskfull 39
235 typedef char pstring[1024];
236 typedef char fstring[128];
237 typedef fstring string;
240 struct smb_passwd {
241 int smb_userid;
242 char *smb_name;
243 unsigned char *smb_passwd; /* Null if no password */
244 unsigned char *smb_nt_passwd; /* Null if no password */
245 /* Other fields / flags may be added later */
249 struct current_user {
250 int cnum, id;
251 int uid, gid;
252 int ngroups;
253 gid_t *groups;
254 int *igroups;
257 typedef struct
259 int size;
260 int mode;
261 int uid;
262 int gid;
263 /* these times are normally kept in GMT */
264 time_t mtime;
265 time_t atime;
266 time_t ctime;
267 pstring name;
268 } file_info;
271 /* Structure used when SMBwritebmpx is active */
272 typedef struct
274 int wr_total_written; /* So we know when to discard this */
275 int32 wr_timeout;
276 int32 wr_errclass;
277 int32 wr_error; /* Cached errors */
278 BOOL wr_mode; /* write through mode) */
279 BOOL wr_discard; /* discard all further data */
280 } write_bmpx_struct;
282 typedef struct
284 int cnum;
285 int fd;
286 int pos;
287 int size;
288 int mode;
289 char *mmap_ptr;
290 int mmap_size;
291 write_bmpx_struct *wbmpx_ptr;
292 time_t open_time;
293 BOOL open;
294 BOOL can_lock;
295 BOOL can_read;
296 BOOL can_write;
297 BOOL share_mode;
298 BOOL share_pending;
299 BOOL print_file;
300 BOOL modified;
301 char *name;
302 } files_struct;
305 struct uid_cache {
306 int entries;
307 int list[UID_CACHE_SIZE];
310 typedef struct
312 int service;
313 BOOL force_user;
314 int uid; /* uid of user who *opened* this connection */
315 int gid; /* gid of user who *opened* this connection */
316 struct uid_cache uid_cache;
317 void *dirptr;
318 BOOL open;
319 BOOL printer;
320 BOOL ipc;
321 BOOL read_only;
322 BOOL admin_user;
323 char *dirpath;
324 char *connectpath;
325 char *origpath;
326 char *user; /* name of user who *opened* this connection */
327 /* following groups stuff added by ih */
328 /* This groups info is valid for the user that *opened* the connection */
329 int ngroups;
330 gid_t *groups;
331 int *igroups; /* an integer version - some OSes are broken :-( */
332 time_t lastused;
333 BOOL used;
334 int num_files_open;
335 } connection_struct;
338 typedef struct
340 int uid; /* uid of a validated user */
341 int gid; /* gid of a validated user */
342 fstring name; /* name of a validated user */
343 BOOL guest;
344 /* following groups stuff added by ih */
345 /* This groups info is needed for when we become_user() for this uid */
346 int user_ngroups;
347 gid_t *user_groups;
348 int *user_igroups; /* an integer version - some OSes are broken :-( */
349 } user_struct;
352 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
354 typedef struct
356 int job;
357 int size;
358 int status;
359 int priority;
360 time_t time;
361 char user[30];
362 char file[100];
363 } print_queue_struct;
365 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
367 typedef struct
369 fstring message;
370 int status;
371 } print_status_struct;
373 /* used for server information: client, nameserv and ipc */
374 struct server_info_struct
376 fstring name;
377 uint32 type;
378 fstring comment;
379 fstring domain; /* used ONLY in ipc.c NOT namework.c */
380 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
384 /* used for network interfaces */
385 struct interface
387 struct interface *next;
388 struct in_addr ip;
389 struct in_addr bcast;
390 struct in_addr nmask;
393 /* this is used for smbstatus */
394 struct connect_record
396 int magic;
397 int pid;
398 int cnum;
399 int uid;
400 int gid;
401 char name[24];
402 char addr[24];
403 char machine[128];
404 time_t start;
408 #define LOCKING_VERSION 2
410 /* these are useful macros for checking validity of handles */
411 #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
412 #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
413 #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
414 #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
415 #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
416 #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
418 #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
419 return(ERROR(ERRDOS,ERRbadfid))
420 #define CHECK_READ(fnum) if (!Files[fnum].can_read) \
421 return(ERROR(ERRDOS,ERRbadaccess))
422 #define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
423 return(ERROR(ERRDOS,ERRbadaccess))
424 #define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
425 return(CACHED_ERROR(fnum))
427 /* translates a connection number into a service number */
428 #define SNUM(cnum) (Connections[cnum].service)
430 /* access various service details */
431 #define SERVICE(snum) (lp_servicename(snum))
432 #define PRINTCAP (lp_printcapname())
433 #define PRINTCOMMAND(snum) (lp_printcommand(snum))
434 #define PRINTERNAME(snum) (lp_printername(snum))
435 #define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
436 #define VALID_SNUM(snum) (lp_snum_ok(snum))
437 #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
438 #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
439 #define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
440 #define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
441 #define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
442 #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
443 #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
444 #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
445 #define CREATE_MODE(cnum) (lp_create_mode(SNUM(cnum)) | 0700)
446 #ifdef SMB_PASSWD
447 #define SMBENCRYPT() (lp_encrypted_passwords())
448 #else
449 #define SMBENCRYPT() (False)
450 #endif
452 /* the basic packet size, assuming no words or bytes */
453 #define smb_size 39
455 /* offsets into message for common items */
456 #define smb_com 8
457 #define smb_rcls 9
458 #define smb_reh 10
459 #define smb_err 11
460 #define smb_flg 13
461 #define smb_flg2 14
462 #define smb_reb 13
463 #define smb_tid 28
464 #define smb_pid 30
465 #define smb_uid 32
466 #define smb_mid 34
467 #define smb_wct 36
468 #define smb_vwv 37
469 #define smb_vwv0 37
470 #define smb_vwv1 39
471 #define smb_vwv2 41
472 #define smb_vwv3 43
473 #define smb_vwv4 45
474 #define smb_vwv5 47
475 #define smb_vwv6 49
476 #define smb_vwv7 51
477 #define smb_vwv8 53
478 #define smb_vwv9 55
479 #define smb_vwv10 57
480 #define smb_vwv11 59
481 #define smb_vwv12 61
482 #define smb_vwv13 63
483 #define smb_vwv14 65
484 #define smb_vwv15 67
485 #define smb_vwv16 69
486 #define smb_vwv17 71
489 /* the complete */
490 #define SMBmkdir 0x00 /* create directory */
491 #define SMBrmdir 0x01 /* delete directory */
492 #define SMBopen 0x02 /* open file */
493 #define SMBcreate 0x03 /* create file */
494 #define SMBclose 0x04 /* close file */
495 #define SMBflush 0x05 /* flush file */
496 #define SMBunlink 0x06 /* delete file */
497 #define SMBmv 0x07 /* rename file */
498 #define SMBgetatr 0x08 /* get file attributes */
499 #define SMBsetatr 0x09 /* set file attributes */
500 #define SMBread 0x0A /* read from file */
501 #define SMBwrite 0x0B /* write to file */
502 #define SMBlock 0x0C /* lock byte range */
503 #define SMBunlock 0x0D /* unlock byte range */
504 #define SMBctemp 0x0E /* create temporary file */
505 #define SMBmknew 0x0F /* make new file */
506 #define SMBchkpth 0x10 /* check directory path */
507 #define SMBexit 0x11 /* process exit */
508 #define SMBlseek 0x12 /* seek */
509 #define SMBtcon 0x70 /* tree connect */
510 #define SMBtconX 0x75 /* tree connect and X*/
511 #define SMBtdis 0x71 /* tree disconnect */
512 #define SMBnegprot 0x72 /* negotiate protocol */
513 #define SMBdskattr 0x80 /* get disk attributes */
514 #define SMBsearch 0x81 /* search directory */
515 #define SMBsplopen 0xC0 /* open print spool file */
516 #define SMBsplwr 0xC1 /* write to print spool file */
517 #define SMBsplclose 0xC2 /* close print spool file */
518 #define SMBsplretq 0xC3 /* return print queue */
519 #define SMBsends 0xD0 /* send single block message */
520 #define SMBsendb 0xD1 /* send broadcast message */
521 #define SMBfwdname 0xD2 /* forward user name */
522 #define SMBcancelf 0xD3 /* cancel forward */
523 #define SMBgetmac 0xD4 /* get machine name */
524 #define SMBsendstrt 0xD5 /* send start of multi-block message */
525 #define SMBsendend 0xD6 /* send end of multi-block message */
526 #define SMBsendtxt 0xD7 /* send text of multi-block message */
528 /* Core+ protocol */
529 #define SMBlockread 0x13 /* Lock a range and read */
530 #define SMBwriteunlock 0x14 /* Unlock a range then write */
531 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
532 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
533 #define SMBwritec 0x20 /* secondary write request */
534 #define SMBwriteclose 0x2c /* write a file then close it */
536 /* dos extended protocol */
537 #define SMBreadBraw 0x1A /* read block raw */
538 #define SMBreadBmpx 0x1B /* read block multiplexed */
539 #define SMBreadBs 0x1C /* read block (secondary response) */
540 #define SMBwriteBraw 0x1D /* write block raw */
541 #define SMBwriteBmpx 0x1E /* write block multiplexed */
542 #define SMBwriteBs 0x1F /* write block (secondary request) */
543 #define SMBwriteC 0x20 /* write complete response */
544 #define SMBsetattrE 0x22 /* set file attributes expanded */
545 #define SMBgetattrE 0x23 /* get file attributes expanded */
546 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
547 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
548 #define SMBtranss 0x26 /* transaction (secondary request/response) */
549 #define SMBioctl 0x27 /* IOCTL */
550 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
551 #define SMBcopy 0x29 /* copy */
552 #define SMBmove 0x2A /* move */
553 #define SMBecho 0x2B /* echo */
554 #define SMBopenX 0x2D /* open and X */
555 #define SMBreadX 0x2E /* read and X */
556 #define SMBwriteX 0x2F /* write and X */
557 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
558 #define SMBffirst 0x82 /* find first */
559 #define SMBfunique 0x83 /* find unique */
560 #define SMBfclose 0x84 /* find close */
561 #define SMBinvalid 0xFE /* invalid command */
563 /* Extended 2.0 protocol */
564 #define SMBtrans2 0x32 /* TRANS2 protocol set */
565 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
566 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
567 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
568 #define SMBulogoffX 0x74 /* user logoff */
571 /* these are the TRANS2 sub commands */
572 #define TRANSACT2_OPEN 0
573 #define TRANSACT2_FINDFIRST 1
574 #define TRANSACT2_FINDNEXT 2
575 #define TRANSACT2_QFSINFO 3
576 #define TRANSACT2_SETFSINFO 4
577 #define TRANSACT2_QPATHINFO 5
578 #define TRANSACT2_SETPATHINFO 6
579 #define TRANSACT2_QFILEINFO 7
580 #define TRANSACT2_SETFILEINFO 8
581 #define TRANSACT2_FSCTL 9
582 #define TRANSACT2_IOCTL 10
583 #define TRANSACT2_FINDNOTIFYFIRST 11
584 #define TRANSACT2_FINDNOTIFYNEXT 12
585 #define TRANSACT2_MKDIR 13
588 /* these are the trans2 sub fields for primary requests */
589 #define smb_tpscnt smb_vwv0
590 #define smb_tdscnt smb_vwv1
591 #define smb_mprcnt smb_vwv2
592 #define smb_mdrcnt smb_vwv3
593 #define smb_msrcnt smb_vwv4
594 #define smb_flags smb_vwv5
595 #define smb_timeout smb_vwv6
596 #define smb_pscnt smb_vwv9
597 #define smb_psoff smb_vwv10
598 #define smb_dscnt smb_vwv11
599 #define smb_dsoff smb_vwv12
600 #define smb_suwcnt smb_vwv13
601 #define smb_setup smb_vwv14
602 #define smb_setup0 smb_setup
603 #define smb_setup1 (smb_setup+2)
604 #define smb_setup2 (smb_setup+4)
606 /* these are for the secondary requests */
607 #define smb_spscnt smb_vwv2
608 #define smb_spsoff smb_vwv3
609 #define smb_spsdisp smb_vwv4
610 #define smb_sdscnt smb_vwv5
611 #define smb_sdsoff smb_vwv6
612 #define smb_sdsdisp smb_vwv7
613 #define smb_sfid smb_vwv8
615 /* and these for responses */
616 #define smb_tprcnt smb_vwv0
617 #define smb_tdrcnt smb_vwv1
618 #define smb_prcnt smb_vwv3
619 #define smb_proff smb_vwv4
620 #define smb_prdisp smb_vwv5
621 #define smb_drcnt smb_vwv6
622 #define smb_droff smb_vwv7
623 #define smb_drdisp smb_vwv8
625 /* where to find the base of the SMB packet proper */
626 #define smb_base(buf) (((char *)(buf))+4)
629 #define SUCCESS 0 /* The request was successful. */
630 #define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
631 #define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
632 #define ERRHRD 0x03 /* Error is an hardware error. */
633 #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
635 /* structure used to hold the incoming hosts info */
636 struct from_host {
637 char *name; /* host name */
638 char *addr; /* host address */
639 struct sockaddr_in *sin; /* their side of the link */
642 #ifdef __STDC__
643 int Debug1(char *, ...);
644 #else
645 int Debug1();
646 #endif
648 #ifdef DFS_AUTH
649 void dfs_unlogin(void);
650 extern int dcelogin_atmost_once;
651 #endif
653 #if AJT
654 void ajt_panic(void);
655 #endif
657 #ifdef NOSTRDUP
658 char *strdup(char *s);
659 #endif
661 #ifdef REPLACE_STRLEN
662 int Strlen(char *);
663 #endif
665 #ifdef REPLACE_STRSTR
666 char *Strstr(char *s, char *p);
667 #endif
669 #ifndef MIN
670 #define MIN(a,b) ((a)<(b)?(a):(b))
671 #endif
672 #ifndef MAX
673 #define MAX(a,b) ((a)>(b)?(a):(b))
674 #endif
676 #ifndef ABS
677 #define ABS(a) ((a)>0?(a):(-(a)))
678 #endif
680 #ifndef SIGNAL_CAST
681 #define SIGNAL_CAST
682 #endif
684 #ifndef SELECT_CAST
685 #define SELECT_CAST
686 #endif
689 /* Some POSIX definitions for those without */
691 #ifndef S_IFDIR
692 #define S_IFDIR 0x4000
693 #endif
694 #ifndef S_ISDIR
695 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
696 #endif
697 #ifndef S_IRWXU
698 #define S_IRWXU 00700 /* read, write, execute: owner */
699 #endif
700 #ifndef S_IRUSR
701 #define S_IRUSR 00400 /* read permission: owner */
702 #endif
703 #ifndef S_IWUSR
704 #define S_IWUSR 00200 /* write permission: owner */
705 #endif
706 #ifndef S_IXUSR
707 #define S_IXUSR 00100 /* execute permission: owner */
708 #endif
709 #ifndef S_IRWXG
710 #define S_IRWXG 00070 /* read, write, execute: group */
711 #endif
712 #ifndef S_IRGRP
713 #define S_IRGRP 00040 /* read permission: group */
714 #endif
715 #ifndef S_IWGRP
716 #define S_IWGRP 00020 /* write permission: group */
717 #endif
718 #ifndef S_IXGRP
719 #define S_IXGRP 00010 /* execute permission: group */
720 #endif
721 #ifndef S_IRWXO
722 #define S_IRWXO 00007 /* read, write, execute: other */
723 #endif
724 #ifndef S_IROTH
725 #define S_IROTH 00004 /* read permission: other */
726 #endif
727 #ifndef S_IWOTH
728 #define S_IWOTH 00002 /* write permission: other */
729 #endif
730 #ifndef S_IXOTH
731 #define S_IXOTH 00001 /* execute permission: other */
732 #endif
735 /* these are used in NetServerEnum to choose what to receive */
736 #define SV_TYPE_WORKSTATION 0x00000001
737 #define SV_TYPE_SERVER 0x00000002
738 #define SV_TYPE_SQLSERVER 0x00000004
739 #define SV_TYPE_DOMAIN_CTRL 0x00000008
740 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
741 #define SV_TYPE_TIME_SOURCE 0x00000020
742 #define SV_TYPE_AFP 0x00000040
743 #define SV_TYPE_NOVELL 0x00000080
744 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
745 #define SV_TYPE_PRINTQ_SERVER 0x00000200
746 #define SV_TYPE_DIALIN_SERVER 0x00000400
747 #define SV_TYPE_SERVER_UNIX 0x00000800
748 #define SV_TYPE_NT 0x00001000
749 #define SV_TYPE_WFW 0x00002000
750 #define SV_TYPE_SERVER_MFPN 0x00004000
751 #define SV_TYPE_SERVER_NT 0x00008000
752 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
753 #define SV_TYPE_BACKUP_BROWSER 0x00020000
754 #define SV_TYPE_MASTER_BROWSER 0x00040000
755 #define SV_TYPE_DOMAIN_MASTER 0x00080000
756 #define SV_TYPE_SERVER_OSF 0x00100000
757 #define SV_TYPE_SERVER_VMS 0x00200000
758 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
759 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
760 #define SV_TYPE_DOMAIN_ENUM 0x80000000
761 #define SV_TYPE_ALL 0xFFFFFFFF
765 /* protocol types. It assumes that higher protocols include lower protocols
766 as subsets */
767 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
769 /* security levels */
770 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
772 /* printing types */
773 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
774 PRINT_QNX,PRINT_PLP};
777 /* case handling */
778 enum case_handling {CASE_LOWER,CASE_UPPER};
781 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
782 structures. We cannot define these as actual structures
783 due to possible differences in structure packing
784 on different machines/compilers. */
786 #define SMB_LPID_OFFSET(indx) (10 * (indx))
787 #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
788 #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
790 /* Macro to cache an error in a write_bmpx_struct */
791 #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
792 w->wr_discard = True, -1)
793 /* Macro to test if an error has been cached for this fnum */
794 #define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
795 Files[(fnum)].wbmpx_ptr && \
796 Files[(fnum)].wbmpx_ptr->wr_discard)
797 /* Macro to turn the cached error into an error packet */
798 #define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
800 /* these are the datagram types */
801 #define DGRAM_DIRECT_UNIQUE 0x10
803 #define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
805 /* this is how errors are generated */
806 #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
808 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
810 #endif
811 /* _SMB_H */