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