2 * Defines for smb packet dissection
3 * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998, 1999 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ETH_VAR_IMPORT gboolean sid_name_snooping;
31 /* SMB command codes, from the SNIA CIFS spec. With MSVC and a
32 * libethereal.dll, we need a special declaration.
34 ETH_VAR_IMPORT const value_string smb_cmd_vals[];
35 ETH_VAR_IMPORT const value_string trans2_cmd_vals[];
36 ETH_VAR_IMPORT const value_string nt_cmd_vals[];
39 #define SMB_COM_CREATE_DIRECTORY 0x00
40 #define SMB_COM_DELETE_DIRECTORY 0x01
41 #define SMB_COM_OPEN 0x02
42 #define SMB_COM_CREATE 0x03
43 #define SMB_COM_CLOSE 0x04
44 #define SMB_COM_FLUSH 0x05
45 #define SMB_COM_DELETE 0x06
46 #define SMB_COM_RENAME 0x07
47 #define SMB_COM_QUERY_INFORMATION 0x08
48 #define SMB_COM_SET_INFORMATION 0x09
49 #define SMB_COM_READ 0x0A
50 #define SMB_COM_WRITE 0x0B
51 #define SMB_COM_LOCK_BYTE_RANGE 0x0C
52 #define SMB_COM_UNLOCK_BYTE_RANGE 0x0D
53 #define SMB_COM_CREATE_TEMPORARY 0x0E
54 #define SMB_COM_CREATE_NEW 0x0F
55 #define SMB_COM_CHECK_DIRECTORY 0x10
56 #define SMB_COM_PROCESS_EXIT 0x11
57 #define SMB_COM_SEEK 0x12
58 #define SMB_COM_LOCK_AND_READ 0x13
59 #define SMB_COM_WRITE_AND_UNLOCK 0x14
60 #define SMB_COM_READ_RAW 0x1A
61 #define SMB_COM_READ_MPX 0x1B
62 #define SMB_COM_READ_MPX_SECONDARY 0x1C
63 #define SMB_COM_WRITE_RAW 0x1D
64 #define SMB_COM_WRITE_MPX 0x1E
65 #define SMB_COM_WRITE_MPX_SECONDARY 0x1F
66 #define SMB_COM_WRITE_COMPLETE 0x20
67 #define SMB_COM_QUERY_SERVER 0x21
68 #define SMB_COM_SET_INFORMATION2 0x22
69 #define SMB_COM_QUERY_INFORMATION2 0x23
70 #define SMB_COM_LOCKING_ANDX 0x24
71 #define SMB_COM_TRANSACTION 0x25
72 #define SMB_COM_TRANSACTION_SECONDARY 0x26
73 #define SMB_COM_IOCTL 0x27
74 #define SMB_COM_IOCTL_SECONDARY 0x28
75 #define SMB_COM_COPY 0x29
76 #define SMB_COM_MOVE 0x2A
77 #define SMB_COM_ECHO 0x2B
78 #define SMB_COM_WRITE_AND_CLOSE 0x2C
79 #define SMB_COM_OPEN_ANDX 0x2D
80 #define SMB_COM_READ_ANDX 0x2E
81 #define SMB_COM_WRITE_ANDX 0x2F
82 #define SMB_COM_NEW_FILE_SIZE 0x30
83 #define SMB_COM_CLOSE_AND_TREE_DISC 0x31
84 #define SMB_COM_TRANSACTION2 0x32
85 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
86 #define SMB_COM_FIND_CLOSE2 0x34
87 #define SMB_COM_FIND_NOTIFY_CLOSE 0x35
88 /* Used by Xenix/Unix 0x60-0x6E */
89 #define SMB_COM_TREE_CONNECT 0x70
90 #define SMB_COM_TREE_DISCONNECT 0x71
91 #define SMB_COM_NEGOTIATE 0x72
92 #define SMB_COM_SESSION_SETUP_ANDX 0x73
93 #define SMB_COM_LOGOFF_ANDX 0x74
94 #define SMB_COM_TREE_CONNECT_ANDX 0x75
95 #define SMB_COM_QUERY_INFORMATION_DISK 0x80
96 #define SMB_COM_SEARCH 0x81
97 #define SMB_COM_FIND 0x82
98 #define SMB_COM_FIND_UNIQUE 0x83
99 #define SMB_COM_FIND_CLOSE 0x84
100 #define SMB_COM_NT_TRANSACT 0xA0
101 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
102 #define SMB_COM_NT_CREATE_ANDX 0xA2
103 #define SMB_COM_NT_CANCEL 0xA4
104 #define SMB_COM_NT_RENAME 0xA5
105 #define SMB_COM_OPEN_PRINT_FILE 0xC0
106 #define SMB_COM_WRITE_PRINT_FILE 0xC1
107 #define SMB_COM_CLOSE_PRINT_FILE 0xC2
108 #define SMB_COM_GET_PRINT_QUEUE 0xC3
109 #define SMB_COM_READ_BULK 0xD8
110 #define SMB_COM_WRITE_BULK 0xD9
111 #define SMB_COM_WRITE_BULK_DATA 0xDA
115 #define SMB_SUCCESS 0x00 /* All OK */
116 #define SMB_ERRDOS 0x01 /* DOS based error */
117 #define SMB_ERRSRV 0x02 /* server error, network file manager */
118 #define SMB_ERRHRD 0x03 /* Hardware style error */
119 #define SMB_ERRCMD 0x04 /* Not an SMB format command */
121 /* Error codes for the ERRSRV class */
123 #define SMBE_error 1 /* Non specific error code */
124 #define SMBE_badpw 2 /* Bad password */
125 #define SMBE_badtype 3 /* reserved */
126 #define SMBE_access 4 /* No permissions to do the requested operation */
127 #define SMBE_invnid 5 /* tid invalid */
128 #define SMBE_invnetname 6 /* Invalid servername */
129 #define SMBE_invdevice 7 /* Invalid device */
130 #define SMBE_qfull 49 /* Print queue full */
131 #define SMBE_qtoobig 50 /* Queued item too big */
132 #define SMBE_qeof 51 /* EOF in print queue dump */
133 #define SMBE_invpfid 52 /* Invalid print file in smb_fid */
134 #define SMBE_smbcmd 64 /* Unrecognised command */
135 #define SMBE_srverror 65 /* smb server internal error */
136 #define SMBE_filespecs 67 /* fid and pathname invalid combination */
137 #define SMBE_badlink 68
138 #define SMBE_badpermits 69 /* Access specified for a file is not valid */
139 #define SMBE_badpid 70
140 #define SMBE_setattrmode 71 /* attribute mode invalid */
141 #define SMBE_paused 81 /* Message server paused */
142 #define SMBE_msgoff 82 /* Not receiving messages */
143 #define SMBE_noroom 83 /* No room for message */
144 #define SMBE_rmuns 87 /* too many remote usernames */
145 #define SMBE_timeout 88 /* operation timed out */
146 #define SMBE_noresource 89 /* No resources currently available for request. */
147 #define SMBE_toomanyuids 90 /* too many userids */
148 #define SMBE_baduid 91 /* bad userid */
149 #define SMBE_useMPX 250 /* temporarily unable to use raw mode, use MPX mode */
150 #define SMBE_useSTD 251 /* temporarily unable to use raw mode, use standard mode */
151 #define SMBE_contMPX 252 /* resume MPX mode */
152 #define SMBE_badPW 253 /* Check this out ... */
153 #define SMBE_nosupport 0xFFFF
154 #define SMBE_unknownsmb 22 /* from NT 3.5 response */
156 /* Error codes for the ERRHRD class */
158 #define SMBE_nowrite 19 /* read only media */
159 #define SMBE_badunit 20 /* Unknown device */
160 #define SMBE_notready 21 /* Drive not ready */
161 #define SMBE_badcmd 22 /* Unknown command */
162 #define SMBE_data 23 /* Data (CRC) error */
163 #define SMBE_badreq 24 /* Bad request structure length */
164 #define SMBE_seek 25 /* Seek error */
165 #define SMBE_badmedia 26 /* Unknown media type */
166 #define SMBE_badsector 27 /* Sector not found */
167 #define SMBE_nopaper 28 /* Printer out of paper */
168 #define SMBE_write 29 /* Write fault */
169 #define SMBE_read 30 /* Read fault */
170 #define SMBE_general 31 /* General failure */
171 #define SMBE_badshare 32 /* An open conflicts with an existing open */
172 #define SMBE_lock 33 /* Lock conflict or invalid mode, or unlock of
173 lock held by another process */
174 #define SMBE_wrongdisk 34 /* The wrong disk was found in a drive */
175 #define SMBE_FCBunavail 35 /* No FCBs are available to process request */
176 #define SMBE_sharebufexc 36 /* A sharing buffer has been exceeded */
177 #define SMBE_diskfull 39
179 /* the information we need to keep around for NT transatcion commands */
182 } smb_nt_transact_info_t;
184 /* the information we need to keep around for transaction2 commands */
188 gboolean resume_keys; /* if "return resume" keys set in T2 FIND_FIRST request */
189 } smb_transact2_info_t;
192 * The information we need to save about a request in order to show the
193 * frame number of the request in the dissection of the reply.
195 #define SMB_SIF_TID_IS_IPC 0x0001
196 #define SMB_SIF_IS_CONTINUED 0x0002
198 guint32 frame_req, frame_res;
206 * The information we need to save about a Transaction request in order
207 * to dissect the reply; this includes information for use by the
208 * Remote API and Mailslot dissectors.
209 * XXX - have an additional data structure hung off of this by the
218 guchar *param_descrip; /* Keep these descriptors around */
219 guchar *data_descrip;
220 guchar *aux_data_descrip;
222 } smb_transact_info_t;
227 #define TRANSACTION_PIPE 0
228 #define TRANSACTION_MAILSLOT 1
230 /* these are defines used to represent different types of TIDs.
231 dont use the value 0 for any of these */
235 /* this is the structure which is associated with each conversation */
236 typedef struct conv_tables {
237 /* these two tables are used to match requests with responses */
238 GHashTable *unmatched;
241 /* This table is used to track TID->services for a conversation */
242 GHashTable *tid_service;
243 gboolean raw_ntlmssp; /* Do extended security exc use raw ntlmssp */
246 typedef struct smb_info {
248 int tid, pid, uid, mid;
249 gboolean unicode; /* Are strings in this SMB Unicode? */
250 gboolean request; /* Is this a request? */
254 smb_saved_info_t *sip; /* smb_saved_info_t, if any, for this */
259 * Show file data for a read or write.
261 extern int dissect_file_data(tvbuff_t *tvb, proto_tree *tree, int offset,
262 guint16 bc, guint16 datalen);
265 * Add a FID to the protocol tree and the Info column.
267 extern void add_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
268 int offset, int len, guint16 fid);
271 * Dissect named pipe state information.
273 extern int dissect_ipc_state(tvbuff_t *tvb, proto_tree *parent_tree,
274 int offset, gboolean setstate);
276 extern gboolean smb_dcerpc_reassembly;