home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / tcpdumpb.zip / smb.h < prev    next >
C/C++ Source or Header  |  1996-10-07  |  7KB  |  159 lines

  1. /* 
  2.    Copyright (C) Andrew Tridgell 1995
  3.    
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.    
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.    
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. #define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
  20. #define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
  21. #define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
  22.  
  23. #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
  24. #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
  25. #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
  26. #define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
  27. #define SVALS(buf,pos) ((int16)SVAL(buf,pos))
  28. #define IVALS(buf,pos) ((int32)IVAL(buf,pos))
  29. #define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
  30. #define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
  31. #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
  32. #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
  33.  
  34. /* now the reverse routines - these are used in nmb packets (mostly) */
  35. #define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
  36. #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
  37.  
  38. #define RSVAL(buf,pos) SREV(SVAL(buf,pos))
  39. #define RIVAL(buf,pos) IREV(IVAL(buf,pos))
  40. #define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
  41. #define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
  42.  
  43. #define uint16 unsigned short
  44. #define uint32 unsigned int
  45. #ifndef uchar
  46. #define uchar unsigned char
  47. #endif
  48.  
  49. #ifndef MIN
  50. #define MIN(a,b) ((a)<(b)?(a):(b))
  51. #endif
  52.  
  53. /* the complete */
  54. #define SMBmkdir      0x00   /* create directory */
  55. #define SMBrmdir      0x01   /* delete directory */
  56. #define SMBopen       0x02   /* open file */
  57. #define SMBcreate     0x03   /* create file */
  58. #define SMBclose      0x04   /* close file */
  59. #define SMBflush      0x05   /* flush file */
  60. #define SMBunlink     0x06   /* delete file */
  61. #define SMBmv         0x07   /* rename file */
  62. #define SMBgetatr     0x08   /* get file attributes */
  63. #define SMBsetatr     0x09   /* set file attributes */
  64. #define SMBread       0x0A   /* read from file */
  65. #define SMBwrite      0x0B   /* write to file */
  66. #define SMBlock       0x0C   /* lock byte range */
  67. #define SMBunlock     0x0D   /* unlock byte range */
  68. #define SMBctemp      0x0E   /* create temporary file */
  69. #define SMBmknew      0x0F   /* make new file */
  70. #define SMBchkpth     0x10   /* check directory path */
  71. #define SMBexit       0x11   /* process exit */
  72. #define SMBlseek      0x12   /* seek */
  73. #define SMBtcon       0x70   /* tree connect */
  74. #define SMBtconX      0x75   /* tree connect and X*/
  75. #define SMBtdis       0x71   /* tree disconnect */
  76. #define SMBnegprot    0x72   /* negotiate protocol */
  77. #define SMBdskattr    0x80   /* get disk attributes */
  78. #define SMBsearch     0x81   /* search directory */
  79. #define SMBsplopen    0xC0   /* open print spool file */
  80. #define SMBsplwr      0xC1   /* write to print spool file */
  81. #define SMBsplclose   0xC2   /* close print spool file */
  82. #define SMBsplretq    0xC3   /* return print queue */
  83. #define SMBsends      0xD0   /* send single block message */
  84. #define SMBsendb      0xD1   /* send broadcast message */
  85. #define SMBfwdname    0xD2   /* forward user name */
  86. #define SMBcancelf    0xD3   /* cancel forward */
  87. #define SMBgetmac     0xD4   /* get machine name */
  88. #define SMBsendstrt   0xD5   /* send start of multi-block message */
  89. #define SMBsendend    0xD6   /* send end of multi-block message */
  90. #define SMBsendtxt    0xD7   /* send text of multi-block message */
  91.  
  92. /* Core+ protocol */
  93. #define SMBlockread      0x13   /* Lock a range and read */
  94. #define SMBwriteunlock 0x14 /* Unlock a range then write */
  95. #define SMBreadbraw   0x1a  /* read a block of data with no smb header */
  96. #define SMBwritebraw  0x1d  /* write a block of data with no smb header */
  97. #define SMBwritec     0x20  /* secondary write request */
  98. #define SMBwriteclose 0x2c  /* write a file then close it */
  99.  
  100. /* dos extended protocol */
  101. #define SMBreadBraw      0x1A   /* read block raw */
  102. #define SMBreadBmpx      0x1B   /* read block multiplexed */
  103. #define SMBreadBs        0x1C   /* read block (secondary response) */
  104. #define SMBwriteBraw     0x1D   /* write block raw */
  105. #define SMBwriteBmpx     0x1E   /* write block multiplexed */
  106. #define SMBwriteBs       0x1F   /* write block (secondary request) */
  107. #define SMBwriteC        0x20   /* write complete response */
  108. #define SMBsetattrE      0x22   /* set file attributes expanded */
  109. #define SMBgetattrE      0x23   /* get file attributes expanded */
  110. #define SMBlockingX      0x24   /* lock/unlock byte ranges and X */
  111. #define SMBtrans         0x25   /* transaction - name, bytes in/out */
  112. #define SMBtranss        0x26   /* transaction (secondary request/response) */
  113. #define SMBioctl         0x27   /* IOCTL */
  114. #define SMBioctls        0x28   /* IOCTL  (secondary request/response) */
  115. #define SMBcopy          0x29   /* copy */
  116. #define SMBmove          0x2A   /* move */
  117. #define SMBecho          0x2B   /* echo */
  118. #define SMBopenX         0x2D   /* open and X */
  119. #define SMBreadX         0x2E   /* read and X */
  120. #define SMBwriteX        0x2F   /* write and X */
  121. #define SMBsesssetupX    0x73   /* Session Set Up & X (including User Logon) */
  122. #define SMBtconX         0x75   /* tree connect and X */
  123. #define SMBffirst        0x82   /* find first */
  124. #define SMBfunique       0x83   /* find unique */
  125. #define SMBfclose        0x84   /* find close */
  126. #define SMBinvalid       0xFE   /* invalid command */
  127.  
  128. /* Extended 2.0 protocol */
  129. #define SMBtrans2        0x32   /* TRANS2 protocol set */
  130. #define SMBtranss2       0x33   /* TRANS2 protocol set, secondary command */
  131. #define SMBfindclose     0x34   /* Terminate a TRANSACT2_FINDFIRST */
  132. #define SMBfindnclose    0x35   /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
  133. #define SMBulogoffX      0x74   /* user logoff */
  134.  
  135. /* pathworks special */
  136. #define pSETDIR '\377'
  137.  
  138.  
  139. /* these are the TRANS2 sub commands */
  140. #define TRANSACT2_OPEN          0
  141. #define TRANSACT2_FINDFIRST     1
  142. #define TRANSACT2_FINDNEXT      2
  143. #define TRANSACT2_QFSINFO       3
  144. #define TRANSACT2_SETFSINFO     4
  145. #define TRANSACT2_QPATHINFO     5
  146. #define TRANSACT2_SETPATHINFO   6
  147. #define TRANSACT2_QFILEINFO     7
  148. #define TRANSACT2_SETFILEINFO   8
  149. #define TRANSACT2_FSCTL         9
  150. #define TRANSACT2_IOCTL           10
  151. #define TRANSACT2_FINDNOTIFYFIRST 11
  152. #define TRANSACT2_FINDNOTIFYNEXT  12
  153. #define TRANSACT2_MKDIR           13
  154.  
  155. #define PTR_DIFF(p1,p2) ((unsigned long)(((char *)(p1)) - (char *)(p2)))
  156.  
  157. /* some protos */
  158. uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf);
  159.