1*b636d99dSDavid van Moolenbroek /* 2*b636d99dSDavid van Moolenbroek * Copyright (C) Andrew Tridgell 1995-1999 3*b636d99dSDavid van Moolenbroek * 4*b636d99dSDavid van Moolenbroek * This software may be distributed either under the terms of the 5*b636d99dSDavid van Moolenbroek * BSD-style license that accompanies tcpdump or the GNU GPL version 2 6*b636d99dSDavid van Moolenbroek * or later 7*b636d99dSDavid van Moolenbroek */ 8*b636d99dSDavid van Moolenbroek 9*b636d99dSDavid van Moolenbroek /* for netdissect_options */ 10*b636d99dSDavid van Moolenbroek #include "netdissect.h" 11*b636d99dSDavid van Moolenbroek 12*b636d99dSDavid van Moolenbroek /* the complete */ 13*b636d99dSDavid van Moolenbroek #define SMBmkdir 0x00 /* create directory */ 14*b636d99dSDavid van Moolenbroek #define SMBrmdir 0x01 /* delete directory */ 15*b636d99dSDavid van Moolenbroek #define SMBopen 0x02 /* open file */ 16*b636d99dSDavid van Moolenbroek #define SMBcreate 0x03 /* create file */ 17*b636d99dSDavid van Moolenbroek #define SMBclose 0x04 /* close file */ 18*b636d99dSDavid van Moolenbroek #define SMBflush 0x05 /* flush file */ 19*b636d99dSDavid van Moolenbroek #define SMBunlink 0x06 /* delete file */ 20*b636d99dSDavid van Moolenbroek #define SMBmv 0x07 /* rename file */ 21*b636d99dSDavid van Moolenbroek #define SMBgetatr 0x08 /* get file attributes */ 22*b636d99dSDavid van Moolenbroek #define SMBsetatr 0x09 /* set file attributes */ 23*b636d99dSDavid van Moolenbroek #define SMBread 0x0A /* read from file */ 24*b636d99dSDavid van Moolenbroek #define SMBwrite 0x0B /* write to file */ 25*b636d99dSDavid van Moolenbroek #define SMBlock 0x0C /* lock byte range */ 26*b636d99dSDavid van Moolenbroek #define SMBunlock 0x0D /* unlock byte range */ 27*b636d99dSDavid van Moolenbroek #define SMBctemp 0x0E /* create temporary file */ 28*b636d99dSDavid van Moolenbroek #define SMBmknew 0x0F /* make new file */ 29*b636d99dSDavid van Moolenbroek #define SMBchkpth 0x10 /* check directory path */ 30*b636d99dSDavid van Moolenbroek #define SMBexit 0x11 /* process exit */ 31*b636d99dSDavid van Moolenbroek #define SMBlseek 0x12 /* seek */ 32*b636d99dSDavid van Moolenbroek #define SMBtcon 0x70 /* tree connect */ 33*b636d99dSDavid van Moolenbroek #define SMBtconX 0x75 /* tree connect and X*/ 34*b636d99dSDavid van Moolenbroek #define SMBtdis 0x71 /* tree disconnect */ 35*b636d99dSDavid van Moolenbroek #define SMBnegprot 0x72 /* negotiate protocol */ 36*b636d99dSDavid van Moolenbroek #define SMBdskattr 0x80 /* get disk attributes */ 37*b636d99dSDavid van Moolenbroek #define SMBsearch 0x81 /* search directory */ 38*b636d99dSDavid van Moolenbroek #define SMBsplopen 0xC0 /* open print spool file */ 39*b636d99dSDavid van Moolenbroek #define SMBsplwr 0xC1 /* write to print spool file */ 40*b636d99dSDavid van Moolenbroek #define SMBsplclose 0xC2 /* close print spool file */ 41*b636d99dSDavid van Moolenbroek #define SMBsplretq 0xC3 /* return print queue */ 42*b636d99dSDavid van Moolenbroek #define SMBsends 0xD0 /* send single block message */ 43*b636d99dSDavid van Moolenbroek #define SMBsendb 0xD1 /* send broadcast message */ 44*b636d99dSDavid van Moolenbroek #define SMBfwdname 0xD2 /* forward user name */ 45*b636d99dSDavid van Moolenbroek #define SMBcancelf 0xD3 /* cancel forward */ 46*b636d99dSDavid van Moolenbroek #define SMBgetmac 0xD4 /* get machine name */ 47*b636d99dSDavid van Moolenbroek #define SMBsendstrt 0xD5 /* send start of multi-block message */ 48*b636d99dSDavid van Moolenbroek #define SMBsendend 0xD6 /* send end of multi-block message */ 49*b636d99dSDavid van Moolenbroek #define SMBsendtxt 0xD7 /* send text of multi-block message */ 50*b636d99dSDavid van Moolenbroek 51*b636d99dSDavid van Moolenbroek /* Core+ protocol */ 52*b636d99dSDavid van Moolenbroek #define SMBlockread 0x13 /* Lock a range and read */ 53*b636d99dSDavid van Moolenbroek #define SMBwriteunlock 0x14 /* Unlock a range then write */ 54*b636d99dSDavid van Moolenbroek #define SMBreadbraw 0x1a /* read a block of data with no smb header */ 55*b636d99dSDavid van Moolenbroek #define SMBwritebraw 0x1d /* write a block of data with no smb header */ 56*b636d99dSDavid van Moolenbroek #define SMBwritec 0x20 /* secondary write request */ 57*b636d99dSDavid van Moolenbroek #define SMBwriteclose 0x2c /* write a file then close it */ 58*b636d99dSDavid van Moolenbroek 59*b636d99dSDavid van Moolenbroek /* dos extended protocol */ 60*b636d99dSDavid van Moolenbroek #define SMBreadBraw 0x1A /* read block raw */ 61*b636d99dSDavid van Moolenbroek #define SMBreadBmpx 0x1B /* read block multiplexed */ 62*b636d99dSDavid van Moolenbroek #define SMBreadBs 0x1C /* read block (secondary response) */ 63*b636d99dSDavid van Moolenbroek #define SMBwriteBraw 0x1D /* write block raw */ 64*b636d99dSDavid van Moolenbroek #define SMBwriteBmpx 0x1E /* write block multiplexed */ 65*b636d99dSDavid van Moolenbroek #define SMBwriteBs 0x1F /* write block (secondary request) */ 66*b636d99dSDavid van Moolenbroek #define SMBwriteC 0x20 /* write complete response */ 67*b636d99dSDavid van Moolenbroek #define SMBsetattrE 0x22 /* set file attributes expanded */ 68*b636d99dSDavid van Moolenbroek #define SMBgetattrE 0x23 /* get file attributes expanded */ 69*b636d99dSDavid van Moolenbroek #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */ 70*b636d99dSDavid van Moolenbroek #define SMBtrans 0x25 /* transaction - name, bytes in/out */ 71*b636d99dSDavid van Moolenbroek #define SMBtranss 0x26 /* transaction (secondary request/response) */ 72*b636d99dSDavid van Moolenbroek #define SMBioctl 0x27 /* IOCTL */ 73*b636d99dSDavid van Moolenbroek #define SMBioctls 0x28 /* IOCTL (secondary request/response) */ 74*b636d99dSDavid van Moolenbroek #define SMBcopy 0x29 /* copy */ 75*b636d99dSDavid van Moolenbroek #define SMBmove 0x2A /* move */ 76*b636d99dSDavid van Moolenbroek #define SMBecho 0x2B /* echo */ 77*b636d99dSDavid van Moolenbroek #define SMBopenX 0x2D /* open and X */ 78*b636d99dSDavid van Moolenbroek #define SMBreadX 0x2E /* read and X */ 79*b636d99dSDavid van Moolenbroek #define SMBwriteX 0x2F /* write and X */ 80*b636d99dSDavid van Moolenbroek #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */ 81*b636d99dSDavid van Moolenbroek #define SMBffirst 0x82 /* find first */ 82*b636d99dSDavid van Moolenbroek #define SMBfunique 0x83 /* find unique */ 83*b636d99dSDavid van Moolenbroek #define SMBfclose 0x84 /* find close */ 84*b636d99dSDavid van Moolenbroek #define SMBinvalid 0xFE /* invalid command */ 85*b636d99dSDavid van Moolenbroek 86*b636d99dSDavid van Moolenbroek /* Extended 2.0 protocol */ 87*b636d99dSDavid van Moolenbroek #define SMBtrans2 0x32 /* TRANS2 protocol set */ 88*b636d99dSDavid van Moolenbroek #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */ 89*b636d99dSDavid van Moolenbroek #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */ 90*b636d99dSDavid van Moolenbroek #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */ 91*b636d99dSDavid van Moolenbroek #define SMBulogoffX 0x74 /* user logoff */ 92*b636d99dSDavid van Moolenbroek 93*b636d99dSDavid van Moolenbroek /* NT SMB extensions. */ 94*b636d99dSDavid van Moolenbroek #define SMBnttrans 0xA0 /* NT transact */ 95*b636d99dSDavid van Moolenbroek #define SMBnttranss 0xA1 /* NT transact secondary */ 96*b636d99dSDavid van Moolenbroek #define SMBntcreateX 0xA2 /* NT create and X */ 97*b636d99dSDavid van Moolenbroek #define SMBntcancel 0xA4 /* NT cancel */ 98*b636d99dSDavid van Moolenbroek 99*b636d99dSDavid van Moolenbroek /* pathworks special */ 100*b636d99dSDavid van Moolenbroek #define pSETDIR '\377' 101*b636d99dSDavid van Moolenbroek 102*b636d99dSDavid van Moolenbroek 103*b636d99dSDavid van Moolenbroek /* these are the TRANS2 sub commands */ 104*b636d99dSDavid van Moolenbroek #define TRANSACT2_OPEN 0 105*b636d99dSDavid van Moolenbroek #define TRANSACT2_FINDFIRST 1 106*b636d99dSDavid van Moolenbroek #define TRANSACT2_FINDNEXT 2 107*b636d99dSDavid van Moolenbroek #define TRANSACT2_QFSINFO 3 108*b636d99dSDavid van Moolenbroek #define TRANSACT2_SETFSINFO 4 109*b636d99dSDavid van Moolenbroek #define TRANSACT2_QPATHINFO 5 110*b636d99dSDavid van Moolenbroek #define TRANSACT2_SETPATHINFO 6 111*b636d99dSDavid van Moolenbroek #define TRANSACT2_QFILEINFO 7 112*b636d99dSDavid van Moolenbroek #define TRANSACT2_SETFILEINFO 8 113*b636d99dSDavid van Moolenbroek #define TRANSACT2_FSCTL 9 114*b636d99dSDavid van Moolenbroek #define TRANSACT2_IOCTL 10 115*b636d99dSDavid van Moolenbroek #define TRANSACT2_FINDNOTIFYFIRST 11 116*b636d99dSDavid van Moolenbroek #define TRANSACT2_FINDNOTIFYNEXT 12 117*b636d99dSDavid van Moolenbroek #define TRANSACT2_MKDIR 13 118*b636d99dSDavid van Moolenbroek 119*b636d99dSDavid van Moolenbroek #define PTR_DIFF(p1, p2) ((size_t)(((char *)(p1)) - (char *)(p2))) 120*b636d99dSDavid van Moolenbroek 121*b636d99dSDavid van Moolenbroek /* some protos */ 122*b636d99dSDavid van Moolenbroek const u_char *smb_fdata(netdissect_options *, const u_char *, const char *, const u_char *, int); 123