2 * Routines for smb2 packet dissection
5 * See http://wiki.wireshark.org/SMB2 for documentation of
7 * If you edit this file, keep the wiki updated as well.
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
35 #include <epan/conversation.h>
37 #include <epan/emem.h>
39 #include "packet-smb2.h"
40 #include "packet-dcerpc.h"
41 #include "packet-ntlmssp.h"
42 #include "packet-windows-common.h"
43 #include "packet-smb-common.h"
44 #include "packet-smb.h"
45 #include "packet-dcerpc-nt.h"
50 static int proto_smb2 = -1;
51 static int hf_smb2_cmd = -1;
52 static int hf_smb2_nt_status = -1;
53 static int hf_smb2_response_to = -1;
54 static int hf_smb2_response_in = -1;
55 static int hf_smb2_time = -1;
56 static int hf_smb2_header_len = -1;
57 static int hf_smb2_seqnum = -1;
58 static int hf_smb2_pid = -1;
59 static int hf_smb2_tid = -1;
60 static int hf_smb2_aid = -1;
61 static int hf_smb2_sesid = -1;
62 static int hf_smb2_previous_sesid = -1;
63 static int hf_smb2_flags_response = -1;
64 static int hf_smb2_flags_async_cmd = -1;
65 static int hf_smb2_flags_dfs_op = -1;
66 static int hf_smb2_flags_chained = -1;
67 static int hf_smb2_flags_signature = -1;
68 static int hf_smb2_chain_offset = -1;
69 static int hf_smb2_response_buffer_offset = -1;
70 static int hf_smb2_security_blob_offset = -1;
71 static int hf_smb2_security_blob_len = -1;
72 static int hf_smb2_security_blob = -1;
73 static int hf_smb2_ioctl_in_data = -1;
74 static int hf_smb2_ioctl_out_data = -1;
75 static int hf_smb2_unknown = -1;
76 static int hf_smb2_unknown_timestamp = -1;
77 static int hf_smb2_create_timestamp = -1;
78 static int hf_smb2_oplock = -1;
79 static int hf_smb2_close_flags = -1;
80 static int hf_smb2_notify_flags = -1;
81 static int hf_smb2_last_access_timestamp = -1;
82 static int hf_smb2_last_write_timestamp = -1;
83 static int hf_smb2_last_change_timestamp = -1;
84 static int hf_smb2_current_time = -1;
85 static int hf_smb2_boot_time = -1;
86 static int hf_smb2_filename = -1;
87 static int hf_smb2_filename_len = -1;
88 static int hf_smb2_nlinks = -1;
89 static int hf_smb2_delete_pending = -1;
90 static int hf_smb2_is_directory = -1;
91 static int hf_smb2_file_id = -1;
92 static int hf_smb2_allocation_size = -1;
93 static int hf_smb2_end_of_file = -1;
94 static int hf_smb2_tree = -1;
95 static int hf_smb2_find_pattern = -1;
96 static int hf_smb2_find_info_level = -1;
97 static int hf_smb2_find_info_blob = -1;
98 static int hf_smb2_client_guid = -1;
99 static int hf_smb2_server_guid = -1;
100 static int hf_smb2_object_id = -1;
101 static int hf_smb2_birth_volume_id = -1;
102 static int hf_smb2_birth_object_id = -1;
103 static int hf_smb2_domain_id = -1;
104 static int hf_smb2_class = -1;
105 static int hf_smb2_infolevel = -1;
106 static int hf_smb2_infolevel_file_info = -1;
107 static int hf_smb2_infolevel_fs_info = -1;
108 static int hf_smb2_infolevel_sec_info = -1;
109 static int hf_smb2_max_response_size = -1;
110 static int hf_smb2_max_ioctl_in_size = -1;
111 static int hf_smb2_max_ioctl_out_size = -1;
112 static int hf_smb2_required_buffer_size = -1;
113 static int hf_smb2_response_size = -1;
114 static int hf_smb2_setinfo_size = -1;
115 static int hf_smb2_setinfo_offset = -1;
116 static int hf_smb2_file_basic_info = -1;
117 static int hf_smb2_file_standard_info = -1;
118 static int hf_smb2_file_internal_info = -1;
119 static int hf_smb2_file_ea_info = -1;
120 static int hf_smb2_file_access_info = -1;
121 static int hf_smb2_file_rename_info = -1;
122 static int hf_smb2_file_disposition_info = -1;
123 static int hf_smb2_file_position_info = -1;
124 static int hf_smb2_file_info_0f = -1;
125 static int hf_smb2_file_mode_info = -1;
126 static int hf_smb2_file_alignment_info = -1;
127 static int hf_smb2_file_all_info = -1;
128 static int hf_smb2_file_allocation_info = -1;
129 static int hf_smb2_file_endoffile_info = -1;
130 static int hf_smb2_file_alternate_name_info = -1;
131 static int hf_smb2_file_stream_info = -1;
132 static int hf_smb2_file_pipe_info = -1;
133 static int hf_smb2_file_compression_info = -1;
134 static int hf_smb2_file_network_open_info = -1;
135 static int hf_smb2_file_attribute_tag_info = -1;
136 static int hf_smb2_fs_info_01 = -1;
137 static int hf_smb2_fs_info_03 = -1;
138 static int hf_smb2_fs_info_04 = -1;
139 static int hf_smb2_fs_info_05 = -1;
140 static int hf_smb2_fs_info_06 = -1;
141 static int hf_smb2_fs_info_07 = -1;
142 static int hf_smb2_fs_objectid_info = -1;
143 static int hf_smb2_sec_info_00 = -1;
144 static int hf_smb2_fid = -1;
145 static int hf_smb2_write_length = -1;
146 static int hf_smb2_write_data = -1;
147 static int hf_smb2_read_length = -1;
148 static int hf_smb2_read_remaining = -1;
149 static int hf_smb2_file_offset = -1;
150 static int hf_smb2_read_data = -1;
151 static int hf_smb2_disposition_delete_on_close = -1;
152 static int hf_smb2_create_disposition = -1;
153 static int hf_smb2_create_chain_offset = -1;
154 static int hf_smb2_create_chain_data = -1;
155 static int hf_smb2_data_offset = -1;
156 static int hf_smb2_data_length = -1;
157 static int hf_smb2_extrainfo = -1;
158 static int hf_smb2_create_action = -1;
159 static int hf_smb2_next_offset = -1;
160 static int hf_smb2_ea_size = -1;
161 static int hf_smb2_ea_flags = -1;
162 static int hf_smb2_ea_name_len = -1;
163 static int hf_smb2_ea_data_len = -1;
164 static int hf_smb2_ea_name = -1;
165 static int hf_smb2_ea_data = -1;
166 static int hf_smb2_buffer_code_len = -1;
167 static int hf_smb2_buffer_code_flags_dyn = -1;
168 static int hf_smb2_olb_offset = -1;
169 static int hf_smb2_olb_length = -1;
170 static int hf_smb2_tag = -1;
171 static int hf_smb2_impersonation_level = -1;
172 static int hf_smb2_ioctl_function = -1;
173 static int hf_smb2_ioctl_function_device = -1;
174 static int hf_smb2_ioctl_function_access = -1;
175 static int hf_smb2_ioctl_function_function = -1;
176 static int hf_smb2_ioctl_function_method = -1;
177 static int hf_smb2_ioctl_shadow_copy_num_volumes = -1;
178 static int hf_smb2_ioctl_shadow_copy_num_labels = -1;
179 static int hf_smb2_ioctl_shadow_copy_count = -1;
180 static int hf_smb2_ioctl_shadow_copy_label = -1;
181 static int hf_smb2_compression_format = -1;
182 static int hf_smb2_FILE_OBJECTID_BUFFER = -1;
183 static int hf_smb2_acct_name = -1;
184 static int hf_smb2_domain_name = -1;
185 static int hf_smb2_host_name = -1;
186 static int hf_smb2_auth_frame = -1;
187 static int hf_smb2_tcon_frame = -1;
188 static int hf_smb2_share_type = -1;
189 static int hf_smb2_signature = -1;
190 static int hf_smb2_epoch = -1;
191 static int hf_smb2_credits_requested = -1;
192 static int hf_smb2_credits_granted = -1;
193 static int hf_smb2_dialect_count = -1;
194 static int hf_smb2_security_mode = -1;
195 static int hf_smb2_secmode_flags_sign_required = -1;
196 static int hf_smb2_secmode_flags_sign_enabled = -1;
197 static int hf_smb2_capabilities = -1;
198 static int hf_smb2_cap_dfs = -1;
199 static int hf_smb2_dialect = -1;
200 static int hf_smb2_max_trans_size = -1;
201 static int hf_smb2_max_read_size = -1;
202 static int hf_smb2_max_write_size = -1;
203 static int hf_smb2_vcnum = -1;
204 static int hf_smb2_channel = -1;
205 static int hf_smb2_session_flags = -1;
206 static int hf_smb2_ses_flags_guest = -1;
207 static int hf_smb2_ses_flags_null = -1;
208 static int hf_smb2_share_flags = -1;
209 static int hf_smb2_share_flags_dfs = -1;
210 static int hf_smb2_share_flags_dfs_root = -1;
211 static int hf_smb2_share_flags_restrict_exclusive_opens = -1;
212 static int hf_smb2_share_flags_force_shared_delete = -1;
213 static int hf_smb2_share_flags_allow_namespace_caching = -1;
214 static int hf_smb2_share_flags_access_based_dir_enum = -1;
215 static int hf_smb2_share_caching = -1;
216 static int hf_smb2_share_caps = -1;
217 static int hf_smb2_share_caps_dfs = -1;
218 static int hf_smb2_create_flags = -1;
219 static int hf_smb2_lock_count = -1;
220 static int hf_smb2_min_count = -1;
221 static int hf_smb2_remaining_bytes = -1;
222 static int hf_smb2_channel_info_offset = -1;
223 static int hf_smb2_channel_info_length = -1;
224 static int hf_smb2_ioctl_flags = -1;
225 static int hf_smb2_ioctl_is_fsctl = -1;
226 static int hf_smb2_close_pq_attrib = -1;
227 static int hf_smb2_notify_watch_tree = -1;
228 static int hf_smb2_output_buffer_len = -1;
229 static int hf_smb2_notify_out_data = -1;
230 static int hf_smb2_find_flags = -1;
231 static int hf_smb2_find_flags_restart_scans = -1;
232 static int hf_smb2_find_flags_single_entry = -1;
233 static int hf_smb2_find_flags_index_specified = -1;
234 static int hf_smb2_find_flags_reopen = -1;
235 static int hf_smb2_file_index = -1;
236 static int hf_smb2_file_directory_info = -1;
237 static int hf_smb2_both_directory_info = -1;
238 static int hf_smb2_short_name_len = -1;
239 static int hf_smb2_short_name = -1;
240 static int hf_smb2_id_both_directory_info = -1;
241 static int hf_smb2_full_directory_info = -1;
242 static int hf_smb2_file_name_info = -1;
243 static int hf_smb2_lock_info = -1;
244 static int hf_smb2_lock_length = -1;
245 static int hf_smb2_lock_flags = -1;
246 static int hf_smb2_lock_flags_shared = -1;
247 static int hf_smb2_lock_flags_exclusive = -1;
248 static int hf_smb2_lock_flags_unlock = -1;
249 static int hf_smb2_lock_flags_fail_immediately = -1;
251 static gint ett_smb2 = -1;
252 static gint ett_smb2_olb = -1;
253 static gint ett_smb2_ea = -1;
254 static gint ett_smb2_header = -1;
255 static gint ett_smb2_command = -1;
256 static gint ett_smb2_secblob = -1;
257 static gint ett_smb2_file_basic_info = -1;
258 static gint ett_smb2_file_standard_info = -1;
259 static gint ett_smb2_file_internal_info = -1;
260 static gint ett_smb2_file_ea_info = -1;
261 static gint ett_smb2_file_access_info = -1;
262 static gint ett_smb2_file_position_info = -1;
263 static gint ett_smb2_file_mode_info = -1;
264 static gint ett_smb2_file_alignment_info = -1;
265 static gint ett_smb2_file_all_info = -1;
266 static gint ett_smb2_file_allocation_info = -1;
267 static gint ett_smb2_file_endoffile_info = -1;
268 static gint ett_smb2_file_alternate_name_info = -1;
269 static gint ett_smb2_file_stream_info = -1;
270 static gint ett_smb2_file_pipe_info = -1;
271 static gint ett_smb2_file_compression_info = -1;
272 static gint ett_smb2_file_network_open_info = -1;
273 static gint ett_smb2_file_attribute_tag_info = -1;
274 static gint ett_smb2_file_rename_info = -1;
275 static gint ett_smb2_file_disposition_info = -1;
276 static gint ett_smb2_file_info_0f = -1;
277 static gint ett_smb2_fs_info_01 = -1;
278 static gint ett_smb2_fs_info_03 = -1;
279 static gint ett_smb2_fs_info_04 = -1;
280 static gint ett_smb2_fs_info_05 = -1;
281 static gint ett_smb2_fs_info_06 = -1;
282 static gint ett_smb2_fs_info_07 = -1;
283 static gint ett_smb2_fs_objectid_info = -1;
284 static gint ett_smb2_sec_info_00 = -1;
285 static gint ett_smb2_tid_tree = -1;
286 static gint ett_smb2_sesid_tree = -1;
287 static gint ett_smb2_create_chain_element = -1;
288 static gint ett_smb2_MxAc_buffer = -1;
289 static gint ett_smb2_ioctl_function = -1;
290 static gint ett_smb2_FILE_OBJECTID_BUFFER = -1;
291 static gint ett_smb2_flags = -1;
292 static gint ett_smb2_sec_mode = -1;
293 static gint ett_smb2_capabilities = -1;
294 static gint ett_smb2_ses_flags = -1;
295 static gint ett_smb2_share_flags = -1;
296 static gint ett_smb2_share_caps = -1;
297 static gint ett_smb2_ioctl_flags = -1;
298 static gint ett_smb2_close_flags = -1;
299 static gint ett_smb2_notify_flags = -1;
300 static gint ett_smb2_find_flags = -1;
301 static gint ett_smb2_file_directory_info = -1;
302 static gint ett_smb2_both_directory_info = -1;
303 static gint ett_smb2_id_both_directory_info = -1;
304 static gint ett_smb2_full_directory_info = -1;
305 static gint ett_smb2_file_name_info = -1;
306 static gint ett_smb2_lock_info = -1;
307 static gint ett_smb2_lock_flags = -1;
309 static int smb2_tap = -1;
311 static dissector_handle_t gssapi_handle = NULL;
312 static dissector_handle_t ntlmssp_handle = NULL;
314 static heur_dissector_list_t smb2_heur_subdissector_list;
316 #define SMB2_CLASS_FILE_INFO 0x01
317 #define SMB2_CLASS_FS_INFO 0x02
318 #define SMB2_CLASS_SEC_INFO 0x03
319 static const value_string smb2_class_vals[] = {
320 { SMB2_CLASS_FILE_INFO, "FILE_INFO"},
321 { SMB2_CLASS_FS_INFO, "FS_INFO"},
322 { SMB2_CLASS_SEC_INFO, "SEC_INFO"},
326 #define SMB2_SHARE_TYPE_FILE 0x0001
327 #define SMB2_SHARE_TYPE_IPC 0x0002
328 #define SMB2_SHARE_TYPE_PRINT 0x0003
329 static const value_string smb2_share_type_vals[] = {
330 { SMB2_SHARE_TYPE_FILE, "File Share" },
331 { SMB2_SHARE_TYPE_IPC, "IPC share" },
332 { SMB2_SHARE_TYPE_PRINT, "Print Share" },
337 #define SMB2_FILE_BASIC_INFO 0x04
338 #define SMB2_FILE_STANDARD_INFO 0x05
339 #define SMB2_FILE_INTERNAL_INFO 0x06
340 #define SMB2_FILE_EA_INFO 0x07
341 #define SMB2_FILE_ACCESS_INFO 0x08
342 #define SMB2_FILE_RENAME_INFO 0x0a
343 #define SMB2_FILE_DISPOSITION_INFO 0x0d
344 #define SMB2_FILE_POSITION_INFO 0x0e
345 #define SMB2_FILE_INFO_0f 0x0f
346 #define SMB2_FILE_MODE_INFO 0x10
347 #define SMB2_FILE_ALIGNMENT_INFO 0x11
348 #define SMB2_FILE_ALL_INFO 0x12
349 #define SMB2_FILE_ALLOCATION_INFO 0x13
350 #define SMB2_FILE_ENDOFFILE_INFO 0x14
351 #define SMB2_FILE_ALTERNATE_NAME_INFO 0x15
352 #define SMB2_FILE_STREAM_INFO 0x16
353 #define SMB2_FILE_PIPE_INFO 0x17
354 #define SMB2_FILE_COMPRESSION_INFO 0x1c
355 #define SMB2_FILE_NETWORK_OPEN_INFO 0x22
356 #define SMB2_FILE_ATTRIBUTE_TAG_INFO 0x23
357 static const value_string smb2_file_info_levels[] = {
358 {SMB2_FILE_BASIC_INFO, "SMB2_FILE_BASIC_INFO" },
359 {SMB2_FILE_STANDARD_INFO, "SMB2_FILE_STANDARD_INFO" },
360 {SMB2_FILE_INTERNAL_INFO, "SMB2_FILE_INTERNAL_INFO" },
361 {SMB2_FILE_EA_INFO, "SMB2_FILE_EA_INFO" },
362 {SMB2_FILE_ACCESS_INFO, "SMB2_FILE_ACCESS_INFO" },
363 {SMB2_FILE_RENAME_INFO, "SMB2_FILE_RENAME_INFO" },
364 {SMB2_FILE_DISPOSITION_INFO, "SMB2_FILE_DISPOSITION_INFO" },
365 {SMB2_FILE_POSITION_INFO, "SMB2_FILE_POSITION_INFO" },
366 {SMB2_FILE_INFO_0f, "SMB2_FILE_INFO_0f" },
367 {SMB2_FILE_MODE_INFO, "SMB2_FILE_MODE_INFO" },
368 {SMB2_FILE_ALIGNMENT_INFO, "SMB2_FILE_ALIGNMENT_INFO" },
369 {SMB2_FILE_ALL_INFO, "SMB2_FILE_ALL_INFO" },
370 {SMB2_FILE_ALLOCATION_INFO, "SMB2_FILE_ALLOCATION_INFO" },
371 {SMB2_FILE_ENDOFFILE_INFO, "SMB2_FILE_ENDOFFILE_INFO" },
372 {SMB2_FILE_ALTERNATE_NAME_INFO, "SMB2_FILE_ALTERNATE_NAME_INFO" },
373 {SMB2_FILE_STREAM_INFO, "SMB2_FILE_STREAM_INFO" },
374 {SMB2_FILE_PIPE_INFO, "SMB2_FILE_PIPE_INFO" },
375 {SMB2_FILE_COMPRESSION_INFO, "SMB2_FILE_COMPRESSION_INFO" },
376 {SMB2_FILE_NETWORK_OPEN_INFO, "SMB2_FILE_NETWORK_OPEN_INFO" },
377 {SMB2_FILE_ATTRIBUTE_TAG_INFO, "SMB2_FILE_ATTRIBUTE_TAG_INFO" },
383 #define SMB2_FS_INFO_01 0x01
384 #define SMB2_FS_INFO_03 0x03
385 #define SMB2_FS_INFO_04 0x04
386 #define SMB2_FS_INFO_05 0x05
387 #define SMB2_FS_INFO_06 0x06
388 #define SMB2_FS_INFO_07 0x07
389 #define SMB2_FS_OBJECTID_INFO 0x08
390 static const value_string smb2_fs_info_levels[] = {
391 {SMB2_FS_INFO_01, "SMB2_FS_INFO_01" },
392 {SMB2_FS_INFO_03, "SMB2_FS_INFO_03" },
393 {SMB2_FS_INFO_04, "SMB2_FS_INFO_04" },
394 {SMB2_FS_INFO_05, "SMB2_FS_INFO_05" },
395 {SMB2_FS_INFO_06, "SMB2_FS_INFO_06" },
396 {SMB2_FS_INFO_07, "SMB2_FS_INFO_07" },
397 {SMB2_FS_OBJECTID_INFO, "SMB2_FS_OBJECTID_INFO" },
401 #define SMB2_SEC_INFO_00 0x00
402 static const value_string smb2_sec_info_levels[] = {
403 {SMB2_SEC_INFO_00, "SMB2_SEC_INFO_00" },
407 #define SMB2_FIND_DIRECTORY_INFO 0x01
408 #define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
409 #define SMB2_FIND_BOTH_DIRECTORY_INFO 0x03
410 #define SMB2_FIND_INDEX_SPECIFIED 0x04
411 #define SMB2_FIND_NAME_INFO 0x0C
412 #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
413 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
414 static const value_string smb2_find_info_levels[] = {
415 { SMB2_FIND_DIRECTORY_INFO, "SMB2_FIND_DIRECTORY_INFO" },
416 { SMB2_FIND_FULL_DIRECTORY_INFO, "SMB2_FIND_FULL_DIRECTORY_INFO" },
417 { SMB2_FIND_BOTH_DIRECTORY_INFO, "SMB2_FIND_BOTH_DIRECTORY_INFO" },
418 { SMB2_FIND_INDEX_SPECIFIED, "SMB2_FIND_INDEX_SPECIFIED" },
419 { SMB2_FIND_NAME_INFO, "SMB2_FIND_NAME_INFO" },
420 { SMB2_FIND_ID_BOTH_DIRECTORY_INFO, "SMB2_FIND_ID_BOTH_DIRECTORY_INFO" },
421 { SMB2_FIND_ID_FULL_DIRECTORY_INFO, "SMB2_FIND_ID_FULL_DIRECTORY_INFO" },
425 /* unmatched smb_saved_info structures.
426 For unmatched smb_saved_info structures we store the smb_saved_info
427 structure using the SEQNUM field.
430 smb2_saved_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
432 smb2_saved_info_t *key1 = (smb2_saved_info_t *)k1;
433 smb2_saved_info_t *key2 = (smb2_saved_info_t *)k2;
434 return key1->seqnum==key2->seqnum;
437 smb2_saved_info_hash_unmatched(gconstpointer k)
439 smb2_saved_info_t *key = (smb2_saved_info_t *)k;
442 hash=(guint32) (key->seqnum&0xffffffff);
446 /* matched smb_saved_info structures.
447 For matched smb_saved_info structures we store the smb_saved_info
448 structure using the SEQNUM field.
451 smb2_saved_info_equal_matched(gconstpointer k1, gconstpointer k2)
453 smb2_saved_info_t *key1 = (smb2_saved_info_t *)k1;
454 smb2_saved_info_t *key2 = (smb2_saved_info_t *)k2;
455 return key1->seqnum==key2->seqnum;
458 smb2_saved_info_hash_matched(gconstpointer k)
460 smb2_saved_info_t *key = (smb2_saved_info_t *)k;
463 hash=(guint32) (key->seqnum&0xffffffff);
467 /* For Tids of a specific conversation.
468 This keeps track of tid->sharename mappings and other information about the
471 We might need to refine this if it occurs that tids are reused on a single
472 conversation. we dont worry about that yet for simplicity
475 smb2_tid_info_equal(gconstpointer k1, gconstpointer k2)
477 smb2_tid_info_t *key1 = (smb2_tid_info_t *)k1;
478 smb2_tid_info_t *key2 = (smb2_tid_info_t *)k2;
479 return key1->tid==key2->tid;
482 smb2_tid_info_hash(gconstpointer k)
484 smb2_tid_info_t *key = (smb2_tid_info_t *)k;
491 /* For Uids of a specific conversation.
492 This keeps track of uid->acct_name mappings and other information about the
495 We might need to refine this if it occurs that uids are reused on a single
496 conversation. we dont worry about that yet for simplicity
499 smb2_sesid_info_equal(gconstpointer k1, gconstpointer k2)
501 smb2_sesid_info_t *key1 = (smb2_sesid_info_t *)k1;
502 smb2_sesid_info_t *key2 = (smb2_sesid_info_t *)k2;
503 return key1->sesid==key2->sesid;
506 smb2_sesid_info_hash(gconstpointer k)
508 smb2_sesid_info_t *key = (smb2_sesid_info_t *)k;
511 hash=(guint32)( ((key->sesid>>32)&0xffffffff)+((key->sesid)&0xffffffff) );
515 static int dissect_smb2_file_info_0f(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, smb2_info_t *si);
518 /* This is a helper to dissect the common string type
524 * This function is called twice, first to decode the offset/length and
525 * second time to dissect the actual string.
526 * It is done this way since there is no guarantee that we have the full packet and we dont
527 * want to abort dissection too early if the packet ends somewhere between the
528 * length/offset and the actual buffer.
531 enum offset_length_buffer_offset_size {
532 OLB_O_UINT16_S_UINT16,
533 OLB_O_UINT16_S_UINT32,
534 OLB_O_UINT32_S_UINT32,
535 OLB_S_UINT32_O_UINT32
537 typedef struct _offset_length_buffer_t {
542 enum offset_length_buffer_offset_size offset_size;
544 } offset_length_buffer_t;
546 dissect_smb2_olb_length_offset(tvbuff_t *tvb, int offset, offset_length_buffer_t *olb,
547 enum offset_length_buffer_offset_size offset_size, int hfindex)
549 olb->hfindex=hfindex;
550 olb->offset_size=offset_size;
552 case OLB_O_UINT16_S_UINT16:
553 olb->off=tvb_get_letohs(tvb, offset);
554 olb->off_offset=offset;
556 olb->len=tvb_get_letohs(tvb, offset);
557 olb->len_offset=offset;
560 case OLB_O_UINT16_S_UINT32:
561 olb->off=tvb_get_letohs(tvb, offset);
562 olb->off_offset=offset;
564 olb->len=tvb_get_letohl(tvb, offset);
565 olb->len_offset=offset;
568 case OLB_O_UINT32_S_UINT32:
569 olb->off=tvb_get_letohl(tvb, offset);
570 olb->off_offset=offset;
572 olb->len=tvb_get_letohl(tvb, offset);
573 olb->len_offset=offset;
576 case OLB_S_UINT32_O_UINT32:
577 olb->len=tvb_get_letohl(tvb, offset);
578 olb->len_offset=offset;
580 olb->off=tvb_get_letohl(tvb, offset);
581 olb->off_offset=offset;
589 #define OLB_TYPE_UNICODE_STRING 0x01
590 #define OLB_TYPE_ASCII_STRING 0x02
592 dissect_smb2_olb_string(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, offset_length_buffer_t *olb, int type)
595 proto_item *item=NULL;
596 proto_tree *tree=NULL;
597 const char *name=NULL;
604 bc=tvb_length_remaining(tvb, offset);
608 tvb_ensure_bytes_exist(tvb, off, len);
610 || ((off+len)>(off+tvb_reported_length_remaining(tvb, off)))){
611 proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset),
612 "Invalid offset/length. Malformed packet");
614 if (check_col(pinfo->cinfo, COL_INFO)){
615 col_append_str(pinfo->cinfo, COL_INFO, " [Malformed packet]");
623 case OLB_TYPE_UNICODE_STRING:
624 name = get_unicode_or_ascii_string(tvb, &off,
625 TRUE, &len, TRUE, TRUE, &bc);
630 item = proto_tree_add_string(parent_tree, olb->hfindex, tvb, offset, len, name);
631 tree = proto_item_add_subtree(item, ett_smb2_olb);
634 case OLB_TYPE_ASCII_STRING:
635 name = get_unicode_or_ascii_string(tvb, &off,
636 FALSE, &len, TRUE, TRUE, &bc);
641 item = proto_tree_add_string(parent_tree, olb->hfindex, tvb, offset, len, name);
642 tree = proto_item_add_subtree(item, ett_smb2_olb);
647 switch(olb->offset_size){
648 case OLB_O_UINT16_S_UINT16:
649 proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, TRUE);
650 proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 2, TRUE);
652 case OLB_O_UINT16_S_UINT32:
653 proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, TRUE);
654 proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, TRUE);
656 case OLB_O_UINT32_S_UINT32:
657 proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, TRUE);
658 proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, TRUE);
660 case OLB_S_UINT32_O_UINT32:
661 proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, TRUE);
662 proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, TRUE);
670 dissect_smb2_olb_buffer(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb,
671 offset_length_buffer_t *olb, smb2_info_t *si,
672 void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si))
675 proto_item *sub_item=NULL;
676 proto_tree *sub_tree=NULL;
677 tvbuff_t *sub_tvb=NULL;
684 bc=tvb_length_remaining(tvb, offset);
687 tvb_ensure_bytes_exist(tvb, off, len);
689 || ((off+len)>(off+tvb_reported_length_remaining(tvb, off)))){
690 proto_tree_add_text(parent_tree, tvb, offset, tvb_length_remaining(tvb, offset),
691 "Invalid offset/length. Malformed packet");
693 if (check_col(pinfo->cinfo, COL_INFO)){
694 col_append_str(pinfo->cinfo, COL_INFO, " [Malformed packet]");
700 /* if we dont want/need a subtree */
701 if(olb->hfindex==-1){
702 sub_item=parent_tree;
703 sub_tree=parent_tree;
706 sub_item = proto_tree_add_item(parent_tree, olb->hfindex, tvb, offset, len, TRUE);
707 sub_tree = proto_item_add_subtree(sub_item, ett_smb2_olb);
711 switch(olb->offset_size){
712 case OLB_O_UINT16_S_UINT16:
713 proto_tree_add_item(sub_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, TRUE);
714 proto_tree_add_item(sub_tree, hf_smb2_olb_length, tvb, olb->len_offset, 2, TRUE);
716 case OLB_O_UINT16_S_UINT32:
717 proto_tree_add_item(sub_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, TRUE);
718 proto_tree_add_item(sub_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, TRUE);
720 case OLB_O_UINT32_S_UINT32:
721 proto_tree_add_item(sub_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, TRUE);
722 proto_tree_add_item(sub_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, TRUE);
724 case OLB_S_UINT32_O_UINT32:
725 proto_tree_add_item(sub_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, TRUE);
726 proto_tree_add_item(sub_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, TRUE);
730 if (off == 0 || len == 0) {
731 proto_item_append_text(sub_item, ": NO DATA");
739 sub_tvb=tvb_new_subset(tvb, off, MIN((int)len, tvb_length_remaining(tvb, off)), len);
741 dissector(sub_tvb, pinfo, sub_tree, si);
747 dissect_smb2_olb_tvb_max_offset(int offset, offset_length_buffer_t *olb)
752 return MAX(offset, (int)(olb->off + olb->len));
755 typedef struct _smb2_function {
756 int (*request)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si);
757 int (*response)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si);
760 static const true_false_string tfs_flags_response = {
761 "This is a RESPONSE",
765 static const true_false_string tfs_flags_async_cmd = {
766 "This is an ASYNC command",
767 "This is a SYNC command"
770 static const true_false_string tfs_flags_dfs_op = {
771 "This is a DFS OPERATION",
772 "This is a normal operation"
775 static const true_false_string tfs_flags_chained = {
776 "This pdu a CHAINED command",
777 "This pdu is NOT a chained command"
780 static const true_false_string tfs_flags_signature = {
781 "This pdu is SIGNED",
782 "This pdu is NOT signed"
785 static const true_false_string tfs_cap_dfs = {
786 "This host supports DFS",
787 "This host does NOT support DFS"
790 static const value_string compression_format_vals[] = {
791 { 0, "COMPRESSION_FORMAT_NONE" },
792 { 1, "COMPRESSION_FORMAT_DEFAULT" },
793 { 2, "COMPRESSION_FORMAT_LZNT1" },
798 static const value_string smb2_ioctl_vals[] = {
799 /* dissector implemented */
800 {0x0011c017, "IOCTL_DO_DCERPC"},
801 {0x00144064, "FSCTL_GET_SHADOW_COPY_DATA"},
802 {0x000900C0, "FSCTL_CREATE_OR_GET_OBJECT_ID"},
803 {0x0009009C, "FSCTL_GET_OBJECT_ID"},
804 {0x000980A0, "FSCTL_DELETE_OBJECT_ID"}, /* no data in/out */
805 {0x00098098, "FSCTL_SET_OBJECT_ID"},
806 {0x000980BC, "FSCTL_SET_OBJECT_ID_EXTENDED"},
807 {0x0009003C, "FSCTL_GET_COMPRESSION"},
808 {0x0009C040, "FSCTL_SET_COMPRESSION"},
810 /* dissector not yet implemented */
811 {0x00090000, "FSCTL_REQUEST_OPLOCK_LEVEL_1"},
812 {0x00090004, "FSCTL_REQUEST_OPLOCK_LEVEL_2"},
813 {0x00090008, "FSCTL_REQUEST_BATCH_OPLOCK"},
814 {0x0009000C, "FSCTL_OPLOCK_BREAK_ACKNOWLEDGE"},
815 {0x00090010, "FSCTL_OPBATCH_ACK_CLOSE_PENDING"},
816 {0x00090014, "FSCTL_OPLOCK_BREAK_NOTIFY"},
817 {0x00090018, "FSCTL_LOCK_VOLUME"},
818 {0x0009001C, "FSCTL_UNLOCK_VOLUME"},
819 {0x00090020, "FSCTL_DISMOUNT_VOLUME"},
820 {0x00090028, "FSCTL_IS_VOLUME_MOUNTED"},
821 {0x0009002C, "FSCTL_IS_PATHNAME_VALID"},
822 {0x00090030, "FSCTL_MARK_VOLUME_DIRTY"},
823 {0x0009003B, "FSCTL_QUERY_RETRIEVAL_POINTERS"},
824 {0x0009004F, "FSCTL_MARK_AS_SYSTEM_HIVE"},
825 {0x00090050, "FSCTL_OPLOCK_BREAK_ACK_NO_2"},
826 {0x00090054, "FSCTL_INVALIDATE_VOLUMES"},
827 {0x00090058, "FSCTL_QUERY_FAT_BPB"},
828 {0x0009005C, "FSCTL_REQUEST_FILTER_OPLOCK"},
829 {0x00090060, "FSCTL_FILESYSTEM_GET_STATISTICS"},
830 {0x00090064, "FSCTL_GET_NTFS_VOLUME_DATA"},
831 {0x00090068, "FSCTL_GET_NTFS_FILE_RECORD"},
832 {0x0009006F, "FSCTL_GET_VOLUME_BITMAP"},
833 {0x00090073, "FSCTL_GET_RETRIEVAL_POINTERS"},
834 {0x00090074, "FSCTL_MOVE_FILE"},
835 {0x00090078, "FSCTL_IS_VOLUME_DIRTY"},
836 {0x0009007C, "FSCTL_GET_HFS_INFORMATION"},
837 {0x00090083, "FSCTL_ALLOW_EXTENDED_DASD_IO"},
838 {0x00090087, "FSCTL_READ_PROPERTY_DATA"},
839 {0x0009008B, "FSCTL_WRITE_PROPERTY_DATA"},
840 {0x0009008F, "FSCTL_FIND_FILES_BY_SID"},
841 {0x00090097, "FSCTL_DUMP_PROPERTY_DATA"},
842 {0x000980A4, "FSCTL_SET_REPARSE_POINT"},
843 {0x000900A8, "FSCTL_GET_REPARSE_POINT"},
844 {0x000980AC, "FSCTL_DELETE_REPARSE_POINT"},
845 {0x000940B3, "FSCTL_ENUM_USN_DATA"},
846 {0x000940B7, "FSCTL_SECURITY_ID_CHECK"},
847 {0x000940BB, "FSCTL_READ_USN_JOURNAL"},
848 {0x000980C4, "FSCTL_SET_SPARSE"},
849 {0x000980C8, "FSCTL_SET_ZERO_DATA"},
850 {0x000940CF, "FSCTL_QUERY_ALLOCATED_RANGES"},
851 {0x000980D0, "FSCTL_ENABLE_UPGRADE"},
852 {0x000900D4, "FSCTL_SET_ENCRYPTION"},
853 {0x000900DB, "FSCTL_ENCRYPTION_FSCTL_IO"},
854 {0x000900DF, "FSCTL_WRITE_RAW_ENCRYPTED"},
855 {0x000900E3, "FSCTL_READ_RAW_ENCRYPTED"},
856 {0x000940E7, "FSCTL_CREATE_USN_JOURNAL"},
857 {0x000940EB, "FSCTL_READ_FILE_USN_DATA"},
858 {0x000940EF, "FSCTL_WRITE_USN_CLOSE_RECORD"},
859 {0x000900F0, "FSCTL_EXTEND_VOLUME"},
864 static const value_string smb2_ioctl_device_vals[] = {
866 { 0x0002, "CD_ROM" },
867 { 0x0003, "CD_ROM_FILE_SYSTEM" },
868 { 0x0004, "CONTROLLER" },
869 { 0x0005, "DATALINK" },
872 { 0x0008, "DISK_FILE_SYSTEM" },
873 { 0x0009, "FILE_SYSTEM" },
874 { 0x000a, "INPORT_PORT" },
875 { 0x000b, "KEYBOARD" },
876 { 0x000c, "MAILSLOT" },
877 { 0x000d, "MIDI_IN" },
878 { 0x000e, "MIDI_OUT" },
880 { 0x0010, "MULTI_UNC_PROVIDER" },
881 { 0x0011, "NAMED_PIPE" },
882 { 0x0012, "NETWORK" },
883 { 0x0013, "NETWORK_BROWSER" },
884 { 0x0014, "NETWORK_FILE_SYSTEM" },
886 { 0x0016, "PARALLEL_PORT" },
887 { 0x0017, "PHYSICAL_NETCARD" },
888 { 0x0018, "PRINTER" },
889 { 0x0019, "SCANNER" },
890 { 0x001a, "SERIAL_MOUSE_PORT" },
891 { 0x001b, "SERIAL_PORT" },
892 { 0x001c, "SCREEN" },
894 { 0x001e, "STREAMS" },
896 { 0x0020, "TAPE_FILE_SYSTEM" },
897 { 0x0021, "TRANSPORT" },
898 { 0x0022, "UNKNOWN" },
900 { 0x0024, "VIRTUAL_DISK" },
901 { 0x0025, "WAVE_IN" },
902 { 0x0026, "WAVE_OUT" },
903 { 0x0027, "8042_PORT" },
904 { 0x0028, "NETWORK_REDIRECTOR" },
905 { 0x0029, "BATTERY" },
906 { 0x002a, "BUS_EXTENDER" },
909 { 0x002d, "MASS_STORAGE" },
912 { 0x0030, "CHANGER" },
913 { 0x0031, "SMARTCARD" },
916 { 0x0034, "FULLSCREEN_VIDEO" },
917 { 0x0035, "DFS_FILE_SYSTEM" },
918 { 0x0036, "DFS_VOLUME" },
919 { 0x0037, "SERENUM" },
920 { 0x0038, "TERMSRV" },
925 static const value_string smb2_ioctl_access_vals[] = {
926 { 0x00, "FILE_ANY_ACCESS" },
927 { 0x01, "FILE_READ_ACCESS" },
928 { 0x02, "FILE_WRITE_ACCESS" },
929 { 0x03, "FILE_READ_WRITE_ACCESS" },
933 static const value_string smb2_ioctl_method_vals[] = {
934 { 0x00, "METHOD_BUFFERED" },
935 { 0x01, "METHOD_IN_DIRECT" },
936 { 0x02, "METHOD_OUT_DIRECT" },
937 { 0x03, "METHOD_NEITHER" },
941 /* this is called from both smb and smb2. */
943 dissect_smb2_ioctl_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 *ioctlfunc)
945 proto_item *item=NULL;
946 proto_tree *tree=NULL;
947 guint32 ioctl_function;
950 item = proto_tree_add_item(parent_tree, hf_smb2_ioctl_function, tvb, offset, 4, TRUE);
951 tree = proto_item_add_subtree(item, ett_smb2_ioctl_function);
954 ioctl_function=tvb_get_letohl(tvb, offset);
955 *ioctlfunc=ioctl_function;
958 proto_tree_add_item(tree, hf_smb2_ioctl_function_device, tvb, offset, 4, TRUE);
959 if (check_col(pinfo->cinfo, COL_INFO)){
961 pinfo->cinfo, COL_INFO, " %s",
962 val_to_str((ioctl_function>>16)&0xffff, smb2_ioctl_device_vals,
963 "Unknown (0x%08X)"));
967 proto_tree_add_item(tree, hf_smb2_ioctl_function_access, tvb, offset, 4, TRUE);
970 proto_tree_add_item(tree, hf_smb2_ioctl_function_function, tvb, offset, 4, TRUE);
971 if (check_col(pinfo->cinfo, COL_INFO)){
973 pinfo->cinfo, COL_INFO, " Function:0x%04x",
974 (ioctl_function>>2)&0x0fff);
978 proto_tree_add_item(tree, hf_smb2_ioctl_function_method, tvb, offset, 4, TRUE);
986 /* fake the dce/rpc support structures so we can piggy back on
987 * dissect_nt_policy_hnd() since this will allow us
988 * a cheap way to track where FIDs are opened, closed
989 * and fid->filename mappings
990 * if we want to do those things in the future.
992 #define FID_MODE_OPEN 0
993 #define FID_MODE_CLOSE 1
994 #define FID_MODE_USE 2
995 #define FID_MODE_DHNQ 3
996 #define FID_MODE_DHNC 4
998 dissect_smb2_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si, int mode)
1000 guint8 drep[4] = { 0x10, 0x00, 0x00, 0x00}; /* fake DREP struct */
1001 dcerpc_info di; /* fake dcerpc_info struct */
1002 void *old_private_data;
1003 e_ctx_hnd policy_hnd;
1004 proto_item *hnd_item=NULL;
1006 guint32 open_frame = 0, close_frame = 0;
1008 di.conformant_run=0;
1010 old_private_data=pinfo->private_data;
1011 pinfo->private_data=&di;
1015 offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, drep, hf_smb2_fid, &policy_hnd, &hnd_item, TRUE, FALSE);
1016 if(!pinfo->fd->flags.visited){
1017 if(si->saved && si->saved->extra_info_type==SMB2_EI_FILENAME){
1018 fid_name = se_strdup_printf("File: %s", (char *)si->saved->extra_info);
1020 fid_name = se_strdup_printf("File: ");
1022 dcerpc_store_polhnd_name(&policy_hnd, pinfo,
1026 case FID_MODE_CLOSE:
1027 offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, drep, hf_smb2_fid, &policy_hnd, &hnd_item, FALSE, TRUE);
1032 offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, drep, hf_smb2_fid, &policy_hnd, &hnd_item, FALSE, FALSE);
1036 pinfo->private_data=old_private_data;
1039 /* put the filename in col_info */
1040 if (dcerpc_fetch_polhnd_data(&policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->fd->num)) {
1043 proto_item_append_text(hnd_item, " %s", fid_name);
1045 if (check_col(pinfo->cinfo, COL_INFO)){
1046 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", fid_name);
1055 /* this info level is unique to SMB2 and differst from the corresponding
1056 * SMB_FILE_ALL_INFO in SMB
1059 dissect_smb2_file_all_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1061 proto_item *item=NULL;
1062 proto_tree *tree=NULL;
1064 const char *name="";
1068 item = proto_tree_add_item(parent_tree, hf_smb2_file_all_info, tvb, offset, -1, TRUE);
1069 tree = proto_item_add_subtree(item, ett_smb2_file_all_info);
1073 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
1076 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
1079 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
1082 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
1084 /* File Attributes */
1085 offset = dissect_file_attributes(tvb, tree, offset, 4);
1087 /* some unknown bytes */
1088 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, FALSE);
1091 /* allocation size */
1092 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
1096 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
1099 /* number of links */
1100 proto_tree_add_item(tree, hf_smb2_nlinks, tvb, offset, 4, TRUE);
1103 /* delete pending */
1104 proto_tree_add_item(tree, hf_smb2_delete_pending, tvb, offset, 1, TRUE);
1108 proto_tree_add_item(tree, hf_smb2_is_directory, tvb, offset, 1, TRUE);
1115 proto_tree_add_item(tree, hf_smb2_file_id, tvb, offset, 8, TRUE);
1119 proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, TRUE);
1123 offset = dissect_smb_access_mask(tvb, tree, offset);
1125 /* some unknown bytes */
1126 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, FALSE);
1129 /* file name length */
1130 length=tvb_get_letohs(tvb, offset);
1131 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 2, TRUE);
1134 /* some unknown bytes */
1135 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, FALSE);
1140 bc=tvb_length_remaining(tvb, offset);
1141 name = get_unicode_or_ascii_string(tvb, &offset,
1142 TRUE, &length, TRUE, TRUE, &bc);
1144 proto_tree_add_string(tree, hf_smb2_filename, tvb,
1145 offset, length, name);
1157 dissect_smb2_file_allocation_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1159 proto_item *item=NULL;
1160 proto_tree *tree=NULL;
1165 item = proto_tree_add_item(parent_tree, hf_smb2_file_allocation_info, tvb, offset, -1, TRUE);
1166 tree = proto_item_add_subtree(item, ett_smb2_file_allocation_info);
1169 bc=tvb_length_remaining(tvb, offset);
1170 offset = dissect_qfi_SMB_FILE_ALLOCATION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1176 dissect_smb2_file_endoffile_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1178 proto_item *item=NULL;
1179 proto_tree *tree=NULL;
1184 item = proto_tree_add_item(parent_tree, hf_smb2_file_endoffile_info, tvb, offset, -1, TRUE);
1185 tree = proto_item_add_subtree(item, ett_smb2_file_endoffile_info);
1188 bc=tvb_length_remaining(tvb, offset);
1189 offset = dissect_qfi_SMB_FILE_ENDOFFILE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1195 dissect_smb2_file_alternate_name_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1197 proto_item *item=NULL;
1198 proto_tree *tree=NULL;
1203 item = proto_tree_add_item(parent_tree, hf_smb2_file_alternate_name_info, tvb, offset, -1, TRUE);
1204 tree = proto_item_add_subtree(item, ett_smb2_file_alternate_name_info);
1207 bc=tvb_length_remaining(tvb, offset);
1208 offset = dissect_qfi_SMB_FILE_ALTERNATE_NAME_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1215 dissect_smb2_file_basic_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1217 proto_item *item=NULL;
1218 proto_tree *tree=NULL;
1221 item = proto_tree_add_item(parent_tree, hf_smb2_file_basic_info, tvb, offset, -1, TRUE);
1222 tree = proto_item_add_subtree(item, ett_smb2_file_basic_info);
1226 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
1229 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
1232 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
1235 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
1237 /* File Attributes */
1238 offset = dissect_file_attributes(tvb, tree, offset, 4);
1240 /* some unknown bytes */
1241 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, FALSE);
1248 dissect_smb2_file_standard_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1250 proto_item *item=NULL;
1251 proto_tree *tree=NULL;
1256 item = proto_tree_add_item(parent_tree, hf_smb2_file_standard_info, tvb, offset, -1, TRUE);
1257 tree = proto_item_add_subtree(item, ett_smb2_file_standard_info);
1260 bc=tvb_length_remaining(tvb, offset);
1261 offset = dissect_qfi_SMB_FILE_STANDARD_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1266 dissect_smb2_file_internal_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1268 proto_item *item=NULL;
1269 proto_tree *tree=NULL;
1274 item = proto_tree_add_item(parent_tree, hf_smb2_file_internal_info, tvb, offset, -1, TRUE);
1275 tree = proto_item_add_subtree(item, ett_smb2_file_internal_info);
1278 bc=tvb_length_remaining(tvb, offset);
1279 offset = dissect_qfi_SMB_FILE_INTERNAL_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1284 dissect_smb2_file_mode_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1286 proto_item *item=NULL;
1287 proto_tree *tree=NULL;
1292 item = proto_tree_add_item(parent_tree, hf_smb2_file_mode_info, tvb, offset, -1, TRUE);
1293 tree = proto_item_add_subtree(item, ett_smb2_file_mode_info);
1296 bc=tvb_length_remaining(tvb, offset);
1297 offset = dissect_qfi_SMB_FILE_MODE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1302 dissect_smb2_file_alignment_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1304 proto_item *item=NULL;
1305 proto_tree *tree=NULL;
1310 item = proto_tree_add_item(parent_tree, hf_smb2_file_alignment_info, tvb, offset, -1, TRUE);
1311 tree = proto_item_add_subtree(item, ett_smb2_file_alignment_info);
1314 bc=tvb_length_remaining(tvb, offset);
1315 offset = dissect_qfi_SMB_FILE_ALIGNMENT_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1320 dissect_smb2_file_position_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1322 proto_item *item=NULL;
1323 proto_tree *tree=NULL;
1328 item = proto_tree_add_item(parent_tree, hf_smb2_file_position_info, tvb, offset, -1, TRUE);
1329 tree = proto_item_add_subtree(item, ett_smb2_file_position_info);
1332 bc=tvb_length_remaining(tvb, offset);
1333 offset = dissect_qfi_SMB_FILE_POSITION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1339 dissect_smb2_file_access_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1341 proto_item *item=NULL;
1342 proto_tree *tree=NULL;
1345 item = proto_tree_add_item(parent_tree, hf_smb2_file_access_info, tvb, offset, -1, TRUE);
1346 tree = proto_item_add_subtree(item, ett_smb2_file_access_info);
1350 offset = dissect_smb_access_mask(tvb, tree, offset);
1356 dissect_smb2_file_ea_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1358 proto_item *item=NULL;
1359 proto_tree *tree=NULL;
1364 item = proto_tree_add_item(parent_tree, hf_smb2_file_ea_info, tvb, offset, -1, TRUE);
1365 tree = proto_item_add_subtree(item, ett_smb2_file_ea_info);
1368 bc=tvb_length_remaining(tvb, offset);
1369 offset = dissect_qfi_SMB_FILE_EA_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1375 dissect_smb2_file_stream_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1377 proto_item *item=NULL;
1378 proto_tree *tree=NULL;
1383 item = proto_tree_add_item(parent_tree, hf_smb2_file_stream_info, tvb, offset, -1, TRUE);
1384 tree = proto_item_add_subtree(item, ett_smb2_file_stream_info);
1387 bc=tvb_length_remaining(tvb, offset);
1388 offset = dissect_qfi_SMB_FILE_STREAM_INFO(tvb, pinfo, tree, offset, &bc, &trunc, TRUE);
1394 dissect_smb2_file_pipe_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1396 proto_item *item=NULL;
1397 proto_tree *tree=NULL;
1402 item = proto_tree_add_item(parent_tree, hf_smb2_file_pipe_info, tvb, offset, -1, TRUE);
1403 tree = proto_item_add_subtree(item, ett_smb2_file_pipe_info);
1406 bc=tvb_length_remaining(tvb, offset);
1407 offset = dissect_sfi_SMB_FILE_PIPE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1413 dissect_smb2_file_compression_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1415 proto_item *item=NULL;
1416 proto_tree *tree=NULL;
1421 item = proto_tree_add_item(parent_tree, hf_smb2_file_compression_info, tvb, offset, -1, TRUE);
1422 tree = proto_item_add_subtree(item, ett_smb2_file_compression_info);
1425 bc=tvb_length_remaining(tvb, offset);
1426 offset = dissect_qfi_SMB_FILE_COMPRESSION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1432 dissect_smb2_file_network_open_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1434 proto_item *item=NULL;
1435 proto_tree *tree=NULL;
1440 item = proto_tree_add_item(parent_tree, hf_smb2_file_network_open_info, tvb, offset, -1, TRUE);
1441 tree = proto_item_add_subtree(item, ett_smb2_file_network_open_info);
1445 bc=tvb_length_remaining(tvb, offset);
1446 offset = dissect_qfi_SMB_FILE_NETWORK_OPEN_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1452 dissect_smb2_file_attribute_tag_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1454 proto_item *item=NULL;
1455 proto_tree *tree=NULL;
1460 item = proto_tree_add_item(parent_tree, hf_smb2_file_attribute_tag_info, tvb, offset, -1, TRUE);
1461 tree = proto_item_add_subtree(item, ett_smb2_file_attribute_tag_info);
1465 bc=tvb_length_remaining(tvb, offset);
1466 offset = dissect_qfi_SMB_FILE_ATTRIBUTE_TAG_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
1471 static const true_false_string tfs_disposition_delete_on_close = {
1472 "DELETE this file when closed",
1473 "Normal access, do not delete on close"
1477 dissect_smb2_file_disposition_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1479 proto_item *item=NULL;
1480 proto_tree *tree=NULL;
1483 item = proto_tree_add_item(parent_tree, hf_smb2_file_disposition_info, tvb, offset, -1, TRUE);
1484 tree = proto_item_add_subtree(item, ett_smb2_file_disposition_info);
1487 /* file disposition */
1488 proto_tree_add_item(tree, hf_smb2_disposition_delete_on_close, tvb, offset, 1, TRUE);
1494 dissect_smb2_file_info_0f(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1496 proto_item *item=NULL;
1497 proto_tree *tree=NULL;
1498 guint32 next_offset;
1499 guint8 ea_name_len, ea_data_len;
1502 item = proto_tree_add_item(parent_tree, hf_smb2_file_info_0f, tvb, offset, -1, TRUE);
1503 tree = proto_item_add_subtree(item, ett_smb2_file_info_0f);
1508 const char *name="";
1509 const char *data="";
1511 int start_offset=offset;
1512 proto_item *ea_item=NULL;
1513 proto_tree *ea_tree=NULL;
1516 ea_item = proto_tree_add_text(tree, tvb, offset, -1, "EA:");
1517 ea_tree = proto_item_add_subtree(ea_item, ett_smb2_ea);
1521 next_offset=tvb_get_letohl(tvb, offset);
1522 proto_tree_add_item(ea_tree, hf_smb2_next_offset, tvb, offset, 4, TRUE);
1526 proto_tree_add_item(ea_tree, hf_smb2_ea_flags, tvb, offset, 1, TRUE);
1529 /* EA Name Length */
1530 ea_name_len=tvb_get_guint8(tvb, offset);
1531 proto_tree_add_item(ea_tree, hf_smb2_ea_name_len, tvb, offset, 1, TRUE);
1534 /* EA Data Length */
1535 ea_data_len=tvb_get_guint8(tvb, offset);
1536 proto_tree_add_item(ea_tree, hf_smb2_ea_data_len, tvb, offset, 1, TRUE);
1539 /* some unknown bytes */
1540 proto_tree_add_item(ea_tree, hf_smb2_unknown, tvb, offset, 1, TRUE);
1546 bc=tvb_length_remaining(tvb, offset);
1547 name = get_unicode_or_ascii_string(tvb, &offset,
1548 FALSE, &length, TRUE, TRUE, &bc);
1550 proto_tree_add_string(ea_tree, hf_smb2_ea_name, tvb,
1551 offset, length, name);
1554 offset += ea_name_len;
1556 /* separator byte */
1562 bc=tvb_length_remaining(tvb, offset);
1563 data = get_unicode_or_ascii_string(tvb, &offset,
1564 FALSE, &length, TRUE, TRUE, &bc);
1566 proto_tree_add_string(ea_tree, hf_smb2_ea_data, tvb,
1567 offset, length, data);
1570 offset += ea_data_len;
1574 proto_item_append_text(ea_item, " %s := %s", name, data);
1576 proto_item_set_len(ea_item, offset-start_offset);
1582 if(next_offset>256){
1586 offset = start_offset+next_offset;
1593 dissect_smb2_file_rename_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1595 proto_item *item=NULL;
1596 proto_tree *tree=NULL;
1598 const char *name="";
1603 item = proto_tree_add_item(parent_tree, hf_smb2_file_rename_info, tvb, offset, -1, TRUE);
1604 tree = proto_item_add_subtree(item, ett_smb2_file_rename_info);
1607 /* some unknown bytes */
1608 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, FALSE);
1611 /* file name length */
1612 length=tvb_get_letohs(tvb, offset);
1613 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 2, TRUE);
1616 /* some unknown bytes */
1617 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, FALSE);
1622 bc=tvb_length_remaining(tvb, offset);
1623 name = get_unicode_or_ascii_string(tvb, &offset,
1624 TRUE, &length, TRUE, TRUE, &bc);
1626 proto_tree_add_string(tree, hf_smb2_filename, tvb,
1627 offset, length, name);
1630 if (check_col(pinfo->cinfo, COL_INFO)){
1631 col_append_fstr(pinfo->cinfo, COL_INFO, " NewName:%s",
1637 /* some unknown bytes */
1638 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, FALSE);
1645 dissect_smb2_sec_info_00(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1647 proto_item *item=NULL;
1648 proto_tree *tree=NULL;
1651 item = proto_tree_add_item(parent_tree, hf_smb2_sec_info_00, tvb, offset, -1, TRUE);
1652 tree = proto_item_add_subtree(item, ett_smb2_sec_info_00);
1655 /* security descriptor */
1656 offset = dissect_nt_sec_desc(tvb, offset, pinfo, tree, NULL, TRUE, tvb_length_remaining(tvb, offset), NULL);
1662 dissect_smb2_fs_info_05(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1664 proto_item *item=NULL;
1665 proto_tree *tree=NULL;
1669 item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_05, tvb, offset, -1, TRUE);
1670 tree = proto_item_add_subtree(item, ett_smb2_fs_info_05);
1673 bc=tvb_length_remaining(tvb, offset);
1674 offset=dissect_qfsi_FS_ATTRIBUTE_INFO(tvb, pinfo, tree, offset, &bc, TRUE);
1680 dissect_smb2_fs_info_06(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1682 proto_item *item=NULL;
1683 proto_tree *tree=NULL;
1687 item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_06, tvb, offset, -1, TRUE);
1688 tree = proto_item_add_subtree(item, ett_smb2_fs_info_06);
1691 bc=tvb_length_remaining(tvb, offset);
1692 offset=dissect_nt_quota(tvb, tree, offset, &bc);
1698 dissect_smb2_FS_OBJECTID_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1700 proto_item *item=NULL;
1701 proto_tree *tree=NULL;
1704 item = proto_tree_add_item(parent_tree, hf_smb2_fs_objectid_info, tvb, offset, -1, TRUE);
1705 tree = proto_item_add_subtree(item, ett_smb2_fs_objectid_info);
1708 /* FILE_OBJECTID_BUFFER */
1709 offset=dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
1715 dissect_smb2_fs_info_07(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1717 proto_item *item=NULL;
1718 proto_tree *tree=NULL;
1722 item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_07, tvb, offset, -1, TRUE);
1723 tree = proto_item_add_subtree(item, ett_smb2_fs_info_07);
1726 bc=tvb_length_remaining(tvb, offset);
1727 offset=dissect_qfsi_FS_FULL_SIZE_INFO(tvb, pinfo, tree, offset, &bc);
1733 dissect_smb2_fs_info_01(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1735 proto_item *item=NULL;
1736 proto_tree *tree=NULL;
1740 item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_01, tvb, offset, -1, TRUE);
1741 tree = proto_item_add_subtree(item, ett_smb2_fs_info_01);
1745 bc=tvb_length_remaining(tvb, offset);
1746 offset=dissect_qfsi_FS_VOLUME_INFO(tvb, pinfo, tree, offset, &bc, TRUE);
1752 dissect_smb2_fs_info_03(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1754 proto_item *item=NULL;
1755 proto_tree *tree=NULL;
1759 item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_03, tvb, offset, -1, TRUE);
1760 tree = proto_item_add_subtree(item, ett_smb2_fs_info_03);
1764 bc=tvb_length_remaining(tvb, offset);
1765 offset=dissect_qfsi_FS_SIZE_INFO(tvb, pinfo, tree, offset, &bc);
1771 dissect_smb2_fs_info_04(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
1773 proto_item *item=NULL;
1774 proto_tree *tree=NULL;
1778 item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_04, tvb, offset, -1, TRUE);
1779 tree = proto_item_add_subtree(item, ett_smb2_fs_info_04);
1783 bc=tvb_length_remaining(tvb, offset);
1784 offset=dissect_qfsi_FS_DEVICE_INFO(tvb, pinfo, tree, offset, &bc);
1789 static const value_string oplock_vals[] = {
1790 { 0x00, "No oplock" },
1791 { 0x01, "Level2 oplock" },
1792 { 0x08, "Exclusive oplock" },
1793 { 0x09, "Batch oplock" },
1798 dissect_smb2_oplock(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
1800 proto_tree_add_item(parent_tree, hf_smb2_oplock, tvb, offset, 1, TRUE);
1807 dissect_smb2_buffercode(proto_tree *tree, tvbuff_t *tvb, int offset, guint16 *length)
1809 guint16 buffer_code;
1811 /* dissect the first 2 bytes of the command PDU */
1812 buffer_code = tvb_get_letohs(tvb, offset);
1813 proto_tree_add_uint(tree, hf_smb2_buffer_code_len, tvb, offset, 2, buffer_code&0xfffe);
1814 proto_tree_add_item(tree, hf_smb2_buffer_code_flags_dyn, tvb, offset, 2, TRUE);
1818 *length=buffer_code&0xfffe;
1824 #define NEGPROT_CAP_DFS 0x00000001
1826 dissect_smb2_capabilities(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
1829 proto_item *item=NULL;
1830 proto_tree *tree=NULL;
1832 cap = tvb_get_letohl(tvb, offset);
1834 item = proto_tree_add_item(parent_tree, hf_smb2_capabilities, tvb, offset, 4, TRUE);
1835 tree = proto_item_add_subtree(item, ett_smb2_capabilities);
1838 proto_tree_add_boolean(tree, hf_smb2_cap_dfs, tvb, offset, 4, cap);
1848 #define NEGPROT_SIGN_REQ 0x0002
1849 #define NEGPROT_SIGN_ENABLED 0x0001
1852 dissect_smb2_secmode(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
1855 proto_item *item=NULL;
1856 proto_tree *tree=NULL;
1858 sm = tvb_get_guint8(tvb, offset);
1860 item = proto_tree_add_item(parent_tree, hf_smb2_security_mode, tvb, offset, 1, TRUE);
1861 tree = proto_item_add_subtree(item, ett_smb2_sec_mode);
1864 proto_tree_add_boolean(tree, hf_smb2_secmode_flags_sign_required, tvb, offset, 1, sm);
1865 proto_tree_add_boolean(tree, hf_smb2_secmode_flags_sign_enabled, tvb, offset, 1, sm);
1873 #define SES_FLAGS_GUEST 0x0001
1874 #define SES_FLAGS_NULL 0x0002
1877 dissect_smb2_ses_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
1880 proto_item *item=NULL;
1881 proto_tree *tree=NULL;
1883 sf = tvb_get_letohs(tvb, offset);
1885 item = proto_tree_add_item(parent_tree, hf_smb2_session_flags, tvb, offset, 2, TRUE);
1886 tree = proto_item_add_subtree(item, ett_smb2_ses_flags);
1889 proto_tree_add_boolean(tree, hf_smb2_ses_flags_null, tvb, offset, 2, sf);
1890 proto_tree_add_boolean(tree, hf_smb2_ses_flags_guest, tvb, offset, 2, sf);
1898 #define SHARE_FLAGS_manual_caching 0x00000000
1899 #define SHARE_FLAGS_auto_caching 0x00000010
1900 #define SHARE_FLAGS_vdo_caching 0x00000020
1901 #define SHARE_FLAGS_no_caching 0x00000030
1903 static const value_string share_cache_vals[] = {
1904 { SHARE_FLAGS_manual_caching, "manual_caching" },
1905 { SHARE_FLAGS_auto_caching, "auto_caching" },
1906 { SHARE_FLAGS_vdo_caching, "vdo_caching" },
1907 { SHARE_FLAGS_no_caching, "no_caching" },
1911 #define SHARE_FLAGS_dfs 0x00000001
1912 #define SHARE_FLAGS_dfs_root 0x00000002
1913 #define SHARE_FLAGS_restrict_exclusive_opens 0x00000100
1914 #define SHARE_FLAGS_force_shared_delete 0x00000200
1915 #define SHARE_FLAGS_allow_namespace_caching 0x00000400
1916 #define SHARE_FLAGS_access_based_dir_enum 0x00000800
1919 dissect_smb2_share_flags(proto_tree *tree, tvbuff_t *tvb, int offset)
1921 static const int *sf_fields[] = {
1922 &hf_smb2_share_flags_dfs,
1923 &hf_smb2_share_flags_dfs_root,
1924 &hf_smb2_share_flags_restrict_exclusive_opens,
1925 &hf_smb2_share_flags_force_shared_delete,
1926 &hf_smb2_share_flags_allow_namespace_caching,
1927 &hf_smb2_share_flags_access_based_dir_enum,
1933 item = proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_share_flags, ett_smb2_share_flags, sf_fields, TRUE);
1935 cp = tvb_get_letohl(tvb, offset);
1937 proto_tree_add_uint_format(item, hf_smb2_share_caching, tvb, offset, 4, cp, "Caching policy: %s (%08x)", val_to_str(cp, share_cache_vals, "Unknown:%u"), cp);
1945 #define SHARE_CAPS_DFS 0x00000008
1948 dissect_smb2_share_caps(proto_tree *tree, tvbuff_t *tvb, int offset)
1950 static const int *sc_fields[] = {
1951 &hf_smb2_share_caps_dfs,
1956 item = proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_share_caps, ett_smb2_share_caps, sc_fields, TRUE);
1965 dissect_smb2_secblob(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
1967 if( (tvb_length(tvb)>=7)
1968 && (!tvb_memeql(tvb, 0, "NTLMSSP", 7))){
1969 call_dissector(ntlmssp_handle, tvb, pinfo, tree);
1971 call_dissector(gssapi_handle, tvb, pinfo, tree);
1977 dissect_smb2_session_setup_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
1979 offset_length_buffer_t s_olb;
1980 const ntlmssp_header_t *ntlmssph;
1981 static int ntlmssp_tap_id = 0;
1984 if(!ntlmssp_tap_id){
1985 GString *error_string;
1986 /* We dont specify any callbacks at all.
1987 * Instead we manually fetch the tapped data after the
1988 * security blob has been fully dissected and before
1989 * we exit from this dissector.
1991 error_string=register_tap_listener("ntlmssp", NULL, NULL, NULL, NULL, NULL);
1993 ntlmssp_tap_id=find_tap_id("ntlmssp");
1999 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2000 /* some unknown bytes */
2003 proto_tree_add_item(tree, hf_smb2_vcnum, tvb, offset, 1, TRUE);
2007 offset = dissect_smb2_secmode(tree, tvb, offset);
2010 offset = dissect_smb2_capabilities(tree, tvb, offset);
2013 proto_tree_add_item(tree, hf_smb2_channel, tvb, offset, 4, TRUE);
2016 /* security blob offset/length */
2017 offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_security_blob);
2019 /* previous session id */
2020 proto_tree_add_item(tree, hf_smb2_previous_sesid, tvb, offset, 8, TRUE);
2024 /* the security blob itself */
2025 dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
2027 offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
2029 /* If we have found a uid->acct_name mapping, store it */
2030 if(!pinfo->fd->flags.visited){
2032 while((ntlmssph=fetch_tapped_data(ntlmssp_tap_id, idx++)) != NULL){
2033 if(ntlmssph && ntlmssph->type==3){
2034 smb2_sesid_info_t *sesid;
2035 sesid=se_alloc(sizeof(smb2_sesid_info_t));
2036 sesid->sesid=si->sesid;
2037 sesid->acct_name=se_strdup(ntlmssph->acct_name);
2038 sesid->domain_name=se_strdup(ntlmssph->domain_name);
2039 sesid->host_name=se_strdup(ntlmssph->host_name);
2040 sesid->auth_frame=pinfo->fd->num;
2041 sesid->tids= g_hash_table_new(smb2_tid_info_hash, smb2_tid_info_equal);
2042 g_hash_table_insert(si->conv->sesids, sesid, sesid);
2051 dissect_smb2_error_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2054 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2057 /* some unknown bytes */
2058 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
2061 /* some unknown bytes */
2062 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, TRUE);
2066 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), TRUE);
2067 offset += tvb_length_remaining(tvb, offset);
2073 dissect_smb2_session_setup_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
2075 offset_length_buffer_t s_olb;
2077 /* session_setup is special and we don't use dissect_smb2_error_response() here! */
2080 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2083 offset = dissect_smb2_ses_flags(tree, tvb, offset);
2085 /* security blob offset/length */
2086 offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_security_blob);
2088 /* the security blob itself */
2089 dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
2091 offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
2097 dissect_smb2_tree_connect_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
2099 offset_length_buffer_t olb;
2103 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2108 /* tree offset/length */
2109 offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT16, hf_smb2_tree);
2112 buf = dissect_smb2_olb_string(pinfo, tree, tvb, &olb, OLB_TYPE_UNICODE_STRING);
2114 offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
2116 /* treelen +1 is overkill here if the string is unicode,
2117 * but who ever has more than a handful of TCON in a trace anyways
2119 if(!pinfo->fd->flags.visited && si->saved && buf && olb.len){
2120 si->saved->extra_info_type=SMB2_EI_TREENAME;
2121 si->saved->extra_info=se_alloc(olb.len+1);
2122 g_snprintf((char *)si->saved->extra_info,olb.len+1,"%s",buf);
2125 if (check_col(pinfo->cinfo, COL_INFO)){
2126 col_append_fstr(pinfo->cinfo, COL_INFO, " Tree: %s", buf);
2133 dissect_smb2_tree_connect_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
2137 switch (si->status) {
2138 case 0x00000000: break;
2139 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2143 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2146 share_type = tvb_get_letohs(tvb, offset);
2147 proto_tree_add_item(tree, hf_smb2_share_type, tvb, offset, 2, TRUE);
2150 if(!pinfo->fd->flags.visited && si->saved && si->saved->extra_info_type==SMB2_EI_TREENAME && si->session) {
2151 smb2_tid_info_t *tid, tid_key;
2153 tid_key.tid=si->tid;
2154 tid=g_hash_table_lookup(si->session->tids, &tid_key);
2156 g_hash_table_remove(si->session->tids, &tid_key);
2158 tid=se_alloc(sizeof(smb2_tid_info_t));
2160 tid->name=(char *)si->saved->extra_info;
2161 tid->connect_frame=pinfo->fd->num;
2162 tid->share_type=share_type;
2164 g_hash_table_insert(si->session->tids, tid, tid);
2166 si->saved->extra_info_type=SMB2_EI_NONE;
2167 si->saved->extra_info=NULL;
2171 offset = dissect_smb2_share_flags(tree, tvb, offset);
2173 /* share capabilities */
2174 offset = dissect_smb2_share_caps(tree, tvb, offset);
2176 /* this is some sort of access mask */
2177 offset = dissect_smb_access_mask(tvb, tree, offset);
2183 dissect_smb2_tree_disconnect_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2186 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2195 dissect_smb2_tree_disconnect_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2197 switch (si->status) {
2198 case 0x00000000: break;
2199 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2203 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2212 dissect_smb2_sessionlogoff_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2215 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2217 /* reserved bytes */
2224 dissect_smb2_sessionlogoff_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2226 switch (si->status) {
2227 case 0x00000000: break;
2228 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2232 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2234 /* reserved bytes */
2241 dissect_smb2_keepalive_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2244 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2246 /* some unknown bytes */
2247 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
2254 dissect_smb2_keepalive_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2256 switch (si->status) {
2257 case 0x00000000: break;
2258 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2262 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2264 /* some unknown bytes */
2265 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
2272 dissect_smb2_notify_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
2274 proto_tree *flags_tree = NULL;
2275 proto_item *flags_item = NULL;
2278 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2282 flags_item = proto_tree_add_item(tree, hf_smb2_notify_flags, tvb, offset, 2, TRUE);
2283 flags_tree = proto_item_add_subtree(flags_item, ett_smb2_notify_flags);
2285 proto_tree_add_item(flags_tree, hf_smb2_notify_watch_tree, tvb, offset, 2, TRUE);
2288 /* output buffer length */
2289 proto_tree_add_item(tree, hf_smb2_output_buffer_len, tvb, offset, 4, TRUE);
2293 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
2295 /* completion filter */
2296 offset = dissect_nt_notify_completion_filter(tvb, tree, offset);
2305 dissect_smb2_notify_data_out(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
2307 proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), TRUE);
2311 dissect_smb2_notify_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si)
2313 offset_length_buffer_t olb;
2315 switch (si->status) {
2316 case 0x00000000: break;
2317 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2321 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2323 /* out buffer offset/length */
2324 offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, hf_smb2_notify_out_data);
2327 dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_notify_data_out);
2328 offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
2333 #define SMB2_FIND_FLAG_RESTART_SCANS 0x01
2334 #define SMB2_FIND_FLAG_SINGLE_ENTRY 0x02
2335 #define SMB2_FIND_FLAG_INDEX_SPECIFIED 0x04
2336 #define SMB2_FIND_FLAG_REOPEN 0x10
2339 dissect_smb2_find_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
2341 offset_length_buffer_t olb;
2344 static const int *f_fields[] = {
2345 &hf_smb2_find_flags_restart_scans,
2346 &hf_smb2_find_flags_single_entry,
2347 &hf_smb2_find_flags_index_specified,
2348 &hf_smb2_find_flags_reopen,
2353 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2355 il=tvb_get_guint8(tvb, offset);
2357 si->saved->infolevel=il;
2361 proto_tree_add_uint(tree, hf_smb2_find_info_level, tvb, offset, 1, il);
2365 proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_find_flags, ett_smb2_find_flags, f_fields, TRUE);
2369 proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, TRUE);
2373 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
2375 /* search pattern offset/length */
2376 offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT16, hf_smb2_find_pattern);
2378 /* output buffer length */
2379 proto_tree_add_item(tree, hf_smb2_output_buffer_len, tvb, offset, 4, TRUE);
2382 /* search pattern */
2383 buf = dissect_smb2_olb_string(pinfo, tree, tvb, &olb, OLB_TYPE_UNICODE_STRING);
2385 offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
2387 if(!pinfo->fd->flags.visited && si->saved && olb.len){
2388 si->saved->extra_info_type=SMB2_EI_FINDPATTERN;
2389 si->saved->extra_info=g_malloc(olb.len+1);
2390 g_snprintf((char *)si->saved->extra_info,olb.len+1,"%s",buf);
2393 if (check_col(pinfo->cinfo, COL_INFO)){
2394 col_append_fstr(pinfo->cinfo, COL_INFO, " %s Pattern: %s",
2395 val_to_str(il, smb2_find_info_levels, "(Level:0x%02x)"),
2402 static void dissect_smb2_file_directory_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
2405 proto_item *item=NULL;
2406 proto_tree *tree=NULL;
2407 const char *name=NULL;
2410 while(tvb_length_remaining(tvb, offset) > 4){
2411 int old_offset = offset;
2416 item = proto_tree_add_item(parent_tree, hf_smb2_file_directory_info, tvb, offset, -1, TRUE);
2417 tree = proto_item_add_subtree(item, ett_smb2_file_directory_info);
2421 next_offset = tvb_get_letohl(tvb, offset);
2422 proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, TRUE);
2426 proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, TRUE);
2430 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
2433 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
2436 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
2439 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
2442 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
2445 /* allocation size */
2446 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
2449 /* File Attributes */
2450 offset = dissect_file_attributes(tvb, tree, offset, 4);
2452 /* file name length */
2453 file_name_len=tvb_get_letohl(tvb, offset);
2454 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, TRUE);
2460 name = get_unicode_or_ascii_string(tvb, &offset,
2461 TRUE, &file_name_len, TRUE, TRUE, &bc);
2463 proto_tree_add_string(tree, hf_smb2_filename, tvb,
2464 offset, file_name_len, name);
2465 proto_item_append_text(item, ": %s", name);
2470 proto_item_set_len(item, offset-old_offset);
2472 if (next_offset == 0){
2476 offset = old_offset+next_offset;
2477 if (offset < old_offset) {
2478 proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset),
2479 "Invalid offset/length. Malformed packet");
2486 static void dissect_smb2_full_directory_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
2489 proto_item *item=NULL;
2490 proto_tree *tree=NULL;
2491 const char *name=NULL;
2494 while(tvb_length_remaining(tvb, offset) > 4){
2495 int old_offset = offset;
2500 item = proto_tree_add_item(parent_tree, hf_smb2_full_directory_info, tvb, offset, -1, TRUE);
2501 tree = proto_item_add_subtree(item, ett_smb2_full_directory_info);
2505 next_offset = tvb_get_letohl(tvb, offset);
2506 proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, TRUE);
2510 proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, TRUE);
2514 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
2517 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
2520 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
2523 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
2526 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
2529 /* allocation size */
2530 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
2533 /* File Attributes */
2534 offset = dissect_file_attributes(tvb, tree, offset, 4);
2536 /* file name length */
2537 file_name_len=tvb_get_letohl(tvb, offset);
2538 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, TRUE);
2542 proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, TRUE);
2548 name = get_unicode_or_ascii_string(tvb, &offset,
2549 TRUE, &file_name_len, TRUE, TRUE, &bc);
2551 proto_tree_add_string(tree, hf_smb2_filename, tvb,
2552 offset, file_name_len, name);
2553 proto_item_append_text(item, ": %s", name);
2558 proto_item_set_len(item, offset-old_offset);
2560 if (next_offset == 0){
2564 offset = old_offset+next_offset;
2565 if (offset < old_offset) {
2566 proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset),
2567 "Invalid offset/length. Malformed packet");
2574 static void dissect_smb2_both_directory_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
2577 proto_item *item=NULL;
2578 proto_tree *tree=NULL;
2579 const char *name=NULL;
2582 while(tvb_length_remaining(tvb, offset) > 4){
2583 int old_offset = offset;
2590 item = proto_tree_add_item(parent_tree, hf_smb2_both_directory_info, tvb, offset, -1, TRUE);
2591 tree = proto_item_add_subtree(item, ett_smb2_both_directory_info);
2595 next_offset = tvb_get_letohl(tvb, offset);
2596 proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, TRUE);
2600 proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, TRUE);
2604 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
2607 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
2610 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
2613 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
2616 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
2619 /* allocation size */
2620 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
2623 /* File Attributes */
2624 offset = dissect_file_attributes(tvb, tree, offset, 4);
2626 /* file name length */
2627 file_name_len=tvb_get_letohl(tvb, offset);
2628 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, TRUE);
2632 ea_size=tvb_get_letohl(tvb, offset);
2633 proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, TRUE);
2636 /* short name length */
2637 short_name_len=tvb_get_guint8(tvb, offset);
2638 proto_tree_add_item(tree, hf_smb2_short_name_len, tvb, offset, 1, TRUE);
2647 name = get_unicode_or_ascii_string(tvb, &offset,
2648 TRUE, &short_name_len, TRUE, TRUE, &bc);
2650 proto_tree_add_string(tree, hf_smb2_short_name, tvb,
2651 offset, short_name_len, name);
2659 name = get_unicode_or_ascii_string(tvb, &offset,
2660 TRUE, &file_name_len, TRUE, TRUE, &bc);
2662 proto_tree_add_string(tree, hf_smb2_filename, tvb,
2663 offset, file_name_len, name);
2664 proto_item_append_text(item, ": %s", name);
2669 proto_item_set_len(item, offset-old_offset);
2671 if (next_offset == 0){
2675 offset = old_offset+next_offset;
2676 if (offset < old_offset) {
2677 proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset),
2678 "Invalid offset/length. Malformed packet");
2685 static void dissect_smb2_file_name_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
2688 proto_item *item=NULL;
2689 proto_tree *tree=NULL;
2690 const char *name=NULL;
2693 while(tvb_length_remaining(tvb, offset) > 4){
2694 int old_offset = offset;
2699 item = proto_tree_add_item(parent_tree, hf_smb2_both_directory_info, tvb, offset, -1, TRUE);
2700 tree = proto_item_add_subtree(item, ett_smb2_both_directory_info);
2704 next_offset = tvb_get_letohl(tvb, offset);
2705 proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, TRUE);
2709 proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, TRUE);
2712 /* file name length */
2713 file_name_len=tvb_get_letohl(tvb, offset);
2714 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, TRUE);
2720 name = get_unicode_or_ascii_string(tvb, &offset,
2721 TRUE, &file_name_len, TRUE, TRUE, &bc);
2723 proto_tree_add_string(tree, hf_smb2_filename, tvb,
2724 offset, file_name_len, name);
2725 proto_item_append_text(item, ": %s", name);
2730 proto_item_set_len(item, offset-old_offset);
2732 if (next_offset == 0){
2736 offset = old_offset+next_offset;
2737 if (offset < old_offset) {
2738 proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset),
2739 "Invalid offset/length. Malformed packet");
2746 static void dissect_smb2_id_both_directory_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
2749 proto_item *item=NULL;
2750 proto_tree *tree=NULL;
2751 const char *name=NULL;
2754 while(tvb_length_remaining(tvb, offset) > 4){
2755 int old_offset = offset;
2762 item = proto_tree_add_item(parent_tree, hf_smb2_id_both_directory_info, tvb, offset, -1, TRUE);
2763 tree = proto_item_add_subtree(item, ett_smb2_id_both_directory_info);
2767 next_offset = tvb_get_letohl(tvb, offset);
2768 proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, TRUE);
2772 proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, TRUE);
2776 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
2779 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
2782 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
2785 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
2788 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
2791 /* allocation size */
2792 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
2795 /* File Attributes */
2796 offset = dissect_file_attributes(tvb, tree, offset, 4);
2798 /* file name length */
2799 file_name_len=tvb_get_letohl(tvb, offset);
2800 proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, TRUE);
2804 ea_size=tvb_get_letohl(tvb, offset);
2805 proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, TRUE);
2808 /* short name length */
2809 short_name_len=tvb_get_guint8(tvb, offset);
2810 proto_tree_add_item(tree, hf_smb2_short_name_len, tvb, offset, 1, TRUE);
2819 name = get_unicode_or_ascii_string(tvb, &offset,
2820 TRUE, &short_name_len, TRUE, TRUE, &bc);
2822 proto_tree_add_string(tree, hf_smb2_short_name, tvb,
2823 offset, short_name_len, name);
2832 proto_tree_add_item(tree, hf_smb2_file_id, tvb, offset, 8, TRUE);
2838 name = get_unicode_or_ascii_string(tvb, &offset,
2839 TRUE, &file_name_len, TRUE, TRUE, &bc);
2841 proto_tree_add_string(tree, hf_smb2_filename, tvb,
2842 offset, file_name_len, name);
2843 proto_item_append_text(item, ": %s", name);
2848 proto_item_set_len(item, offset-old_offset);
2850 if (next_offset == 0){
2854 offset = old_offset+next_offset;
2855 if (offset < old_offset) {
2856 proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset),
2857 "Invalid offset/length. Malformed packet");
2865 typedef struct _smb2_find_dissector_t {
2867 void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si);
2868 } smb2_find_dissector_t;
2870 smb2_find_dissector_t smb2_find_dissectors[] = {
2871 {SMB2_FIND_DIRECTORY_INFO, dissect_smb2_file_directory_info},
2872 {SMB2_FIND_FULL_DIRECTORY_INFO, dissect_smb2_full_directory_info},
2873 {SMB2_FIND_BOTH_DIRECTORY_INFO, dissect_smb2_both_directory_info},
2874 {SMB2_FIND_NAME_INFO, dissect_smb2_file_name_info},
2875 {SMB2_FIND_ID_BOTH_DIRECTORY_INFO,dissect_smb2_id_both_directory_info},
2880 dissect_smb2_find_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
2882 smb2_find_dissector_t *dis = smb2_find_dissectors;
2884 while(dis->dissector){
2885 if(si && si->saved && si->saved){
2886 if(dis->level ==si->saved->infolevel){
2887 dis->dissector(tvb, pinfo, tree, si);
2894 proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), FALSE);
2899 dissect_smb2_find_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2901 offset_length_buffer_t olb;
2902 proto_item *item=NULL;
2906 item=proto_tree_add_uint(tree, hf_smb2_find_info_level, tvb, offset, 0, si->saved->infolevel);
2907 PROTO_ITEM_SET_GENERATED(item);
2910 if(!pinfo->fd->flags.visited && si->saved && si->saved->extra_info_type==SMB2_EI_FINDPATTERN) {
2911 if (check_col(pinfo->cinfo, COL_INFO)){
2912 col_append_fstr(pinfo->cinfo, COL_INFO, " %s Pattern: %s",
2913 val_to_str(si->saved->infolevel, smb2_find_info_levels, "(Level:0x%02x)"),
2914 (const char *)si->saved->extra_info);
2917 g_free(si->saved->extra_info);
2918 si->saved->extra_info_type=SMB2_EI_NONE;
2919 si->saved->extra_info=NULL;
2922 switch (si->status) {
2923 case 0x00000000: break;
2924 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2928 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2930 /* findinfo offset */
2931 offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, hf_smb2_find_info_blob);
2934 dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_find_data);
2936 offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
2942 dissect_smb2_negotiate_protocol_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
2947 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2950 dc = tvb_get_letohs(tvb, offset);
2951 proto_tree_add_item(tree, hf_smb2_dialect_count, tvb, offset, 2, TRUE);
2954 /* security mode, skip second byte */
2955 offset = dissect_smb2_secmode(tree, tvb, offset);
2963 offset = dissect_smb2_capabilities(tree, tvb, offset);
2966 proto_tree_add_item(tree, hf_smb2_client_guid, tvb, offset, 16, TRUE);
2969 /* client boot time */
2970 dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_boot_time);
2974 proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, TRUE);
2982 dissect_smb2_negotiate_protocol_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
2984 offset_length_buffer_t s_olb;
2986 switch (si->status) {
2987 case 0x00000000: break;
2988 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
2992 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
2994 /* security mode, skip second byte */
2995 offset = dissect_smb2_secmode(tree, tvb, offset);
2998 /* dialect picked */
2999 proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, TRUE);
3006 proto_tree_add_item(tree, hf_smb2_server_guid, tvb, offset, 16, TRUE);
3010 offset = dissect_smb2_capabilities(tree, tvb, offset);
3012 /* max trans size */
3013 proto_tree_add_item(tree, hf_smb2_max_trans_size, tvb, offset, 4, TRUE);
3017 proto_tree_add_item(tree, hf_smb2_max_read_size, tvb, offset, 4, TRUE);
3020 /* max write size */
3021 proto_tree_add_item(tree, hf_smb2_max_write_size, tvb, offset, 4, TRUE);
3025 dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_current_time);
3029 dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_boot_time);
3032 /* security blob offset/length */
3033 offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_security_blob);
3035 /* the security blob itself */
3036 dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
3041 offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
3047 dissect_smb2_getinfo_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si)
3049 switch(si->saved->class){
3050 case SMB2_CLASS_FILE_INFO:
3051 switch(si->saved->infolevel){
3053 /* we dont handle this infolevel yet */
3054 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, TRUE);
3055 offset += tvb_length_remaining(tvb, offset);
3058 case SMB2_CLASS_FS_INFO:
3059 switch(si->saved->infolevel){
3061 /* we dont handle this infolevel yet */
3062 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, TRUE);
3063 offset += tvb_length_remaining(tvb, offset);
3066 case SMB2_CLASS_SEC_INFO:
3067 switch(si->saved->infolevel){
3068 case SMB2_SEC_INFO_00:
3069 dissect_security_information_mask(tvb, tree, offset+8);
3072 /* we dont handle this infolevel yet */
3073 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, TRUE);
3074 offset += tvb_length_remaining(tvb, offset);
3078 /* we dont handle this class yet */
3079 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, TRUE);
3085 dissect_smb2_class_infolevel(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree, smb2_info_t *si)
3090 static const value_string dummy_value_string[] = {
3093 const value_string *vs;
3095 if(si->flags & SMB2_FLAGS_RESPONSE){
3099 cl=si->saved->class;
3100 il=si->saved->infolevel;
3102 cl=tvb_get_guint8(tvb, offset);
3103 il=tvb_get_guint8(tvb, offset+1);
3105 si->saved->class=cl;
3106 si->saved->infolevel=il;
3112 case SMB2_CLASS_FILE_INFO:
3113 hfindex=hf_smb2_infolevel_file_info;
3114 vs=smb2_file_info_levels;
3116 case SMB2_CLASS_FS_INFO:
3117 hfindex=hf_smb2_infolevel_fs_info;
3118 vs=smb2_fs_info_levels;
3120 case SMB2_CLASS_SEC_INFO:
3121 hfindex=hf_smb2_infolevel_sec_info;
3122 vs=smb2_sec_info_levels;
3125 hfindex=hf_smb2_infolevel;
3126 vs=dummy_value_string;
3131 item=proto_tree_add_uint(tree, hf_smb2_class, tvb, offset, 1, cl);
3132 if(si->flags & SMB2_FLAGS_RESPONSE){
3133 PROTO_ITEM_SET_GENERATED(item);
3136 item=proto_tree_add_uint(tree, hfindex, tvb, offset+1, 1, il);
3137 if(si->flags & SMB2_FLAGS_RESPONSE){
3138 PROTO_ITEM_SET_GENERATED(item);
3142 if(!(si->flags & SMB2_FLAGS_RESPONSE)){
3143 /* Only update COL_INFO for requests. It clutters the
3144 * display ab bit too much if we do it for replies
3147 if (check_col(pinfo->cinfo, COL_INFO)){
3148 col_append_fstr(pinfo->cinfo, COL_INFO, " %s/%s",
3149 val_to_str(cl, smb2_class_vals, "(Class:0x%02x)"),
3150 val_to_str(il, vs, "(Level:0x%02x)"));
3158 dissect_smb2_getinfo_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3161 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3163 /* class and info level */
3164 offset = dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
3166 /* max response size */
3167 proto_tree_add_item(tree, hf_smb2_max_response_size, tvb, offset, 4, TRUE);
3172 dissect_smb2_getinfo_parameters(tvb, pinfo, tree, offset, si);
3174 /* some unknown bytes */
3175 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, TRUE);
3180 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
3186 dissect_smb2_infolevel(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si, guint8 class, guint8 infolevel)
3188 int old_offset = offset;
3191 case SMB2_CLASS_FILE_INFO:
3193 case SMB2_FILE_BASIC_INFO:
3194 dissect_smb2_file_basic_info(tvb, pinfo, tree, offset, si);
3196 case SMB2_FILE_STANDARD_INFO:
3197 dissect_smb2_file_standard_info(tvb, pinfo, tree, offset, si);
3199 case SMB2_FILE_INTERNAL_INFO:
3200 dissect_smb2_file_internal_info(tvb, pinfo, tree, offset, si);
3202 case SMB2_FILE_EA_INFO:
3203 dissect_smb2_file_ea_info(tvb, pinfo, tree, offset, si);
3205 case SMB2_FILE_ACCESS_INFO:
3206 dissect_smb2_file_access_info(tvb, pinfo, tree, offset, si);
3208 case SMB2_FILE_RENAME_INFO:
3209 dissect_smb2_file_rename_info(tvb, pinfo, tree, offset, si);
3211 case SMB2_FILE_DISPOSITION_INFO:
3212 dissect_smb2_file_disposition_info(tvb, pinfo, tree, offset, si);
3214 case SMB2_FILE_POSITION_INFO:
3215 dissect_smb2_file_position_info(tvb, pinfo, tree, offset, si);
3217 case SMB2_FILE_INFO_0f:
3218 dissect_smb2_file_info_0f(tvb, pinfo, tree, offset, si);
3220 case SMB2_FILE_MODE_INFO:
3221 dissect_smb2_file_mode_info(tvb, pinfo, tree, offset, si);
3223 case SMB2_FILE_ALIGNMENT_INFO:
3224 dissect_smb2_file_alignment_info(tvb, pinfo, tree, offset, si);
3226 case SMB2_FILE_ALL_INFO:
3227 dissect_smb2_file_all_info(tvb, pinfo, tree, offset, si);
3229 case SMB2_FILE_ALLOCATION_INFO:
3230 dissect_smb2_file_allocation_info(tvb, pinfo, tree, offset, si);
3232 case SMB2_FILE_ENDOFFILE_INFO:
3233 dissect_smb2_file_endoffile_info(tvb, pinfo, tree, offset, si);
3235 case SMB2_FILE_ALTERNATE_NAME_INFO:
3236 dissect_smb2_file_alternate_name_info(tvb, pinfo, tree, offset, si);
3238 case SMB2_FILE_STREAM_INFO:
3239 dissect_smb2_file_stream_info(tvb, pinfo, tree, offset, si);
3241 case SMB2_FILE_PIPE_INFO:
3242 dissect_smb2_file_pipe_info(tvb, pinfo, tree, offset, si);
3244 case SMB2_FILE_COMPRESSION_INFO:
3245 dissect_smb2_file_compression_info(tvb, pinfo, tree, offset, si);
3247 case SMB2_FILE_NETWORK_OPEN_INFO:
3248 dissect_smb2_file_network_open_info(tvb, pinfo, tree, offset, si);
3250 case SMB2_FILE_ATTRIBUTE_TAG_INFO:
3251 dissect_smb2_file_attribute_tag_info(tvb, pinfo, tree, offset, si);
3254 /* we dont handle this infolevel yet */
3255 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), TRUE);
3256 offset += tvb_length_remaining(tvb, offset);
3259 case SMB2_CLASS_FS_INFO:
3261 case SMB2_FS_INFO_01:
3262 dissect_smb2_fs_info_01(tvb, pinfo, tree, offset, si);
3264 case SMB2_FS_INFO_03:
3265 dissect_smb2_fs_info_03(tvb, pinfo, tree, offset, si);
3267 case SMB2_FS_INFO_04:
3268 dissect_smb2_fs_info_04(tvb, pinfo, tree, offset, si);
3270 case SMB2_FS_INFO_05:
3271 dissect_smb2_fs_info_05(tvb, pinfo, tree, offset, si);
3273 case SMB2_FS_INFO_06:
3274 dissect_smb2_fs_info_06(tvb, pinfo, tree, offset, si);
3276 case SMB2_FS_INFO_07:
3277 dissect_smb2_fs_info_07(tvb, pinfo, tree, offset, si);
3279 case SMB2_FS_OBJECTID_INFO:
3280 dissect_smb2_FS_OBJECTID_INFO(tvb, pinfo, tree, offset, si);
3283 /* we dont handle this infolevel yet */
3284 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), TRUE);
3285 offset += tvb_length_remaining(tvb, offset);
3288 case SMB2_CLASS_SEC_INFO:
3290 case SMB2_SEC_INFO_00:
3291 dissect_smb2_sec_info_00(tvb, pinfo, tree, offset, si);
3294 /* we dont handle this infolevel yet */
3295 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), TRUE);
3296 offset += tvb_length_remaining(tvb, offset);
3300 /* we dont handle this class yet */
3301 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), TRUE);
3304 /* if we get BUFFER_OVERFLOW there will be truncated data */
3305 if (si->status == 0x80000005) {
3307 item=proto_tree_add_text(tree, tvb, old_offset, 0, "Truncated...");
3308 PROTO_ITEM_SET_GENERATED(item);
3313 dissect_smb2_getinfo_response_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
3317 dissect_smb2_infolevel(tvb, pinfo, tree, 0, si, si->saved->class, si->saved->infolevel);
3319 /* some unknown bytes */
3320 proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), FALSE);
3328 dissect_smb2_getinfo_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3330 offset_length_buffer_t olb;
3332 /* class/infolevel */
3333 dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
3335 switch (si->status) {
3336 case 0x00000000: break;
3337 /* if we get BUFFER_OVERFLOW there will be truncated data */
3338 case 0x80000005: break;
3339 /* if we get BUFFER_TOO_SMALL there will not be any data there, only
3340 * a guin32 specifying how big the buffer needs to be
3343 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3344 offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, -1);
3345 proto_tree_add_item(tree, hf_smb2_required_buffer_size, tvb, offset, 4, TRUE);
3349 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
3354 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3355 /* response buffer offset and size */
3356 offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, -1);
3359 dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_getinfo_response_data);
3365 dissect_smb2_close_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3367 proto_tree *flags_tree = NULL;
3368 proto_item *flags_item = NULL;
3371 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3375 flags_item = proto_tree_add_item(tree, hf_smb2_close_flags, tvb, offset, 2, TRUE);
3376 flags_tree = proto_item_add_subtree(flags_item, ett_smb2_close_flags);
3378 proto_tree_add_item(flags_tree, hf_smb2_close_pq_attrib, tvb, offset, 2, TRUE);
3385 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_CLOSE);
3391 dissect_smb2_close_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
3393 proto_tree *flags_tree = NULL;
3394 proto_item *flags_item = NULL;
3396 switch (si->status) {
3397 case 0x00000000: break;
3398 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
3402 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3406 flags_item = proto_tree_add_item(tree, hf_smb2_close_flags, tvb, offset, 2, TRUE);
3407 flags_tree = proto_item_add_subtree(flags_item, ett_smb2_close_flags);
3415 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
3418 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
3421 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
3424 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
3426 /* allocation size */
3427 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
3431 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
3434 /* File Attributes */
3435 offset = dissect_file_attributes(tvb, tree, offset, 4);
3441 dissect_smb2_flush_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3444 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3446 /* some unknown bytes */
3447 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 6, TRUE);
3451 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
3457 dissect_smb2_flush_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
3459 switch (si->status) {
3460 case 0x00000000: break;
3461 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
3465 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3467 /* some unknown bytes */
3468 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
3476 dissect_smb2_lock_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3481 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3484 lock_count = tvb_get_letohs(tvb, offset);
3485 proto_tree_add_item(tree, hf_smb2_lock_count, tvb, offset, 2, TRUE);
3492 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
3494 while (lock_count--) {
3495 proto_item *lock_item=NULL;
3496 proto_tree *lock_tree=NULL;
3497 static const int *lf_fields[] = {
3498 &hf_smb2_lock_flags_shared,
3499 &hf_smb2_lock_flags_exclusive,
3500 &hf_smb2_lock_flags_unlock,
3501 &hf_smb2_lock_flags_fail_immediately,
3506 lock_item = proto_tree_add_item(tree, hf_smb2_lock_info, tvb, offset, 24, TRUE);
3507 lock_tree = proto_item_add_subtree(lock_item, ett_smb2_lock_info);
3511 proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, TRUE);
3515 proto_tree_add_item(lock_tree, hf_smb2_lock_length, tvb, offset, 8, TRUE);
3519 proto_tree_add_bitmask(lock_tree, tvb, offset, hf_smb2_lock_flags, ett_smb2_lock_flags, lf_fields, TRUE);
3530 dissect_smb2_lock_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
3532 switch (si->status) {
3533 case 0x00000000: break;
3534 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
3538 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3540 /* some unknown bytes */
3541 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
3547 dissect_smb2_cancel_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
3550 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3552 /* some unknown bytes */
3553 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
3561 dissect_file_data_dcerpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, int offset, guint32 datalen, proto_tree *top_tree)
3566 tvbuff_t *dcerpc_tvb;
3567 tvblen = tvb_length_remaining(tvb, offset);
3568 dcerpc_tvb = tvb_new_subset(tvb, offset, MIN((int)datalen, tvb_length_remaining(tvb, offset)), datalen);
3570 /* dissect the full PDU */
3571 result = dissector_try_heuristic(smb2_heur_subdissector_list, dcerpc_tvb, pinfo, top_tree);
3581 dissect_smb2_write_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3587 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3590 proto_tree_add_item(tree, hf_smb2_data_offset, tvb, offset, 2, TRUE);
3594 length=tvb_get_letohl(tvb, offset);
3595 proto_tree_add_item(tree, hf_smb2_write_length, tvb, offset, 4, TRUE);
3599 off=tvb_get_letoh64(tvb, offset);
3600 proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, TRUE);
3603 if (check_col(pinfo->cinfo, COL_INFO)){
3604 col_append_fstr(pinfo->cinfo, COL_INFO, " Len:%d Off:%" G_GINT64_MODIFIER "u", length, off);
3608 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
3610 /* some unknown bytes */
3611 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, TRUE);
3615 /* data or dcerpc ?*/
3616 if(length && si->tree && si->tree->share_type == SMB2_SHARE_TYPE_IPC){
3617 offset = dissect_file_data_dcerpc(tvb, pinfo, tree, offset, length, si->top_tree);
3621 /* just ordinary data */
3622 proto_tree_add_item(tree, hf_smb2_write_data, tvb, offset, length, TRUE);
3623 offset += MIN(length,(guint32)tvb_length_remaining(tvb, offset));
3630 dissect_smb2_write_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
3632 switch (si->status) {
3633 case 0x00000000: break;
3634 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
3638 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3639 /* some unknown bytes */
3640 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
3644 proto_tree_add_item(tree, hf_smb2_write_length, tvb, offset, 4, TRUE);
3647 /* some unknown bytes */
3648 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 9, TRUE);
3655 dissect_smb2_IOCTL_DO_DCERPC(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *top_tree, gboolean data_in _U_)
3657 dissect_file_data_dcerpc(tvb, pinfo, tree, offset, tvb_length_remaining(tvb, offset), top_tree);
3663 dissect_smb2_FSCTL_GET_SHADOW_COPY_DATA(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
3665 guint32 num_volumes, num_labels;
3667 /* There is no in data */
3673 num_volumes=tvb_get_letohl(tvb, offset);
3674 proto_tree_add_item(tree, hf_smb2_ioctl_shadow_copy_num_volumes, tvb, offset, 4, TRUE);
3678 num_labels=tvb_get_letohl(tvb, offset);
3679 proto_tree_add_item(tree, hf_smb2_ioctl_shadow_copy_num_labels, tvb, offset, 4, TRUE);
3683 proto_tree_add_item(tree, hf_smb2_ioctl_shadow_copy_count, tvb, offset, 4, TRUE);
3686 while(num_volumes--){
3690 int old_offset=offset;
3692 bc=tvb_length_remaining(tvb, offset);
3693 name = get_unicode_or_ascii_string(tvb, &offset,
3694 TRUE, &len, TRUE, FALSE, &bc);
3695 proto_tree_add_string(tree, hf_smb2_ioctl_shadow_copy_label, tvb, old_offset, len, name);
3697 offset = old_offset+len;
3708 dissect_smb2_FILE_OBJECTID_BUFFER(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset)
3710 proto_item *item=NULL;
3711 proto_tree *tree=NULL;
3713 /* FILE_OBJECTID_BUFFER */
3715 item = proto_tree_add_item(parent_tree, hf_smb2_FILE_OBJECTID_BUFFER, tvb, offset, 64, TRUE);
3716 tree = proto_item_add_subtree(item, ett_smb2_FILE_OBJECTID_BUFFER);
3720 proto_tree_add_item(tree, hf_smb2_object_id, tvb, offset, 16, TRUE);
3723 /* Birth Volume ID */
3724 proto_tree_add_item(tree, hf_smb2_birth_volume_id, tvb, offset, 16, TRUE);
3727 /* Birth Object ID */
3728 proto_tree_add_item(tree, hf_smb2_birth_object_id, tvb, offset, 16, TRUE);
3732 proto_tree_add_item(tree, hf_smb2_domain_id, tvb, offset, 16, TRUE);
3739 dissect_smb2_FSCTL_CREATE_OR_GET_OBJECT_ID(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
3742 /* There is no in data */
3747 /* FILE_OBJECTID_BUFFER */
3748 offset=dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
3754 dissect_smb2_FSCTL_GET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
3757 /* There is no in data */
3762 /* compression format */
3763 proto_tree_add_item(tree, hf_smb2_compression_format, tvb, offset, 2, TRUE);
3769 dissect_smb2_FSCTL_SET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
3772 /* There is no out data */
3777 /* compression format */
3778 proto_tree_add_item(tree, hf_smb2_compression_format, tvb, offset, 2, TRUE);
3785 dissect_smb2_FSCTL_SET_OBJECT_ID(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
3788 /* There is no out data */
3793 /* FILE_OBJECTID_BUFFER */
3794 offset=dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
3800 dissect_smb2_FSCTL_SET_OBJECT_ID_EXTENDED(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
3803 /* There is no out data */
3808 /* FILE_OBJECTID_BUFFER->ExtendedInfo */
3810 /* Birth Volume ID */
3811 proto_tree_add_item(tree, hf_smb2_birth_volume_id, tvb, offset, 16, TRUE);
3814 /* Birth Object ID */
3815 proto_tree_add_item(tree, hf_smb2_birth_object_id, tvb, offset, 16, TRUE);
3819 proto_tree_add_item(tree, hf_smb2_domain_id, tvb, offset, 16, TRUE);
3826 dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, guint32 ioctl_function, gboolean data_in)
3828 switch(ioctl_function){
3830 dissect_smb2_IOCTL_DO_DCERPC(tvb, pinfo, tree, 0, top_tree, data_in);
3832 case 0x00144064: /* FSCTL_GET_SHADOW_COPY_DATA */
3833 dissect_smb2_FSCTL_GET_SHADOW_COPY_DATA(tvb, pinfo, tree, 0, data_in);
3835 case 0x0009009C: /* FSCTL_GET_OBJECT_ID */
3836 case 0x000900c0: /* FSCTL_CREATE_OR_GET_OBJECT_ID */
3837 dissect_smb2_FSCTL_CREATE_OR_GET_OBJECT_ID(tvb, pinfo, tree, 0, data_in);
3839 case 0x00098098: /* FSCTL_SET_OBJECT_ID */
3840 dissect_smb2_FSCTL_SET_OBJECT_ID(tvb, pinfo, tree, 0, data_in);
3842 case 0x000980BC: /* FSCTL_SET_OBJECT_ID_EXTENDED */
3843 dissect_smb2_FSCTL_SET_OBJECT_ID_EXTENDED(tvb, pinfo, tree, 0, data_in);
3845 case 0x0009003C: /* FSCTL_GET_COMPRESSION */
3846 dissect_smb2_FSCTL_GET_COMPRESSION(tvb, pinfo, tree, 0, data_in);
3848 case 0x0009C040: /* FSCTL_SET_COMPRESSION */
3849 dissect_smb2_FSCTL_SET_COMPRESSION(tvb, pinfo, tree, 0, data_in);
3852 proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), TRUE);
3859 dissect_smb2_ioctl_data_in(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
3861 dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, TRUE);
3865 dissect_smb2_ioctl_data_out(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
3867 dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, FALSE);
3871 dissect_smb2_ioctl_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3873 offset_length_buffer_t o_olb;
3874 offset_length_buffer_t i_olb;
3875 proto_tree *flags_tree = NULL;
3876 proto_item *flags_item = NULL;
3879 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3884 /* ioctl function */
3885 offset = dissect_smb2_ioctl_function(tvb, pinfo, tree, offset, &si->ioctl_function);
3888 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
3890 /* in buffer offset/length */
3891 offset = dissect_smb2_olb_length_offset(tvb, offset, &i_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_in_data);
3893 /* max ioctl in size */
3894 proto_tree_add_item(tree, hf_smb2_max_ioctl_in_size, tvb, offset, 4, TRUE);
3897 /* out buffer offset/length */
3898 offset = dissect_smb2_olb_length_offset(tvb, offset, &o_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_out_data);
3900 /* max ioctl out size */
3901 proto_tree_add_item(tree, hf_smb2_max_ioctl_out_size, tvb, offset, 4, TRUE);
3906 flags_item = proto_tree_add_item(tree, hf_smb2_ioctl_flags, tvb, offset, 4, TRUE);
3907 flags_tree = proto_item_add_subtree(flags_item, ett_smb2_ioctl_flags);
3909 proto_tree_add_item(flags_tree, hf_smb2_ioctl_is_fsctl, tvb, offset, 4, TRUE);
3915 /* try to decode these blobs in the order they were encoded
3916 * so that for "short" packets we will dissect as much as possible
3917 * before aborting with "short packet"
3919 if(i_olb.off>o_olb.off){
3921 dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
3923 dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
3926 dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
3928 dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
3931 offset = dissect_smb2_olb_tvb_max_offset(offset, &o_olb);
3932 offset = dissect_smb2_olb_tvb_max_offset(offset, &i_olb);
3938 dissect_smb2_ioctl_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
3940 offset_length_buffer_t o_olb;
3941 offset_length_buffer_t i_olb;
3942 proto_tree *flags_tree = NULL;
3943 proto_item *flags_item = NULL;
3945 switch (si->status) {
3946 case 0x00000000: break;
3947 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
3951 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
3953 /* some unknown bytes */
3954 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, TRUE);
3957 /* ioctl function */
3958 offset = dissect_smb2_ioctl_function(tvb, pinfo, tree, offset, &si->ioctl_function);
3961 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
3963 /* in buffer offset/length */
3964 offset = dissect_smb2_olb_length_offset(tvb, offset, &i_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_in_data);
3966 /* out buffer offset/length */
3967 offset = dissect_smb2_olb_length_offset(tvb, offset, &o_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_out_data);
3972 flags_item = proto_tree_add_item(tree, hf_smb2_ioctl_flags, tvb, offset, 4, TRUE);
3973 flags_tree = proto_item_add_subtree(flags_item, ett_smb2_ioctl_flags);
3980 /* try to decode these blobs in the order they were encoded
3981 * so that for "short" packets we will dissect as much as possible
3982 * before aborting with "short packet"
3984 if(i_olb.off>o_olb.off){
3986 dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
3988 dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
3991 dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
3993 dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
3996 offset = dissect_smb2_olb_tvb_max_offset(offset, &i_olb);
3997 offset = dissect_smb2_olb_tvb_max_offset(offset, &o_olb);
4004 dissect_smb2_read_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4010 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4012 /* padding and reserved */
4016 len=tvb_get_letohl(tvb, offset);
4017 proto_tree_add_item(tree, hf_smb2_read_length, tvb, offset, 4, TRUE);
4021 off=tvb_get_letoh64(tvb, offset);
4022 proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, TRUE);
4025 if (check_col(pinfo->cinfo, COL_INFO)){
4026 col_append_fstr(pinfo->cinfo, COL_INFO, " Len:%d Off:%" G_GINT64_MODIFIER "u", len, off);
4030 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
4033 proto_tree_add_item(tree, hf_smb2_min_count, tvb, offset, 4, TRUE);
4036 proto_tree_add_item(tree, hf_smb2_channel, tvb, offset, 4, TRUE);
4039 /* remaining bytes */
4040 proto_tree_add_item(tree, hf_smb2_remaining_bytes, tvb, offset, 4, TRUE);
4043 /* channel info offset */
4044 proto_tree_add_item(tree, hf_smb2_channel_info_offset, tvb, offset, 2, TRUE);
4047 /* channel info length */
4048 proto_tree_add_item(tree, hf_smb2_channel_info_length, tvb, offset, 2, TRUE);
4051 /* there is a buffer here but it is never used (yet) */
4058 dissect_smb2_read_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
4062 switch (si->status) {
4063 case 0x00000000: break;
4064 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
4068 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4071 proto_tree_add_item(tree, hf_smb2_data_offset, tvb, offset, 2, TRUE);
4074 /* length might even be 64bits if they are ambitious*/
4075 length=tvb_get_letohl(tvb, offset);
4076 proto_tree_add_item(tree, hf_smb2_read_length, tvb, offset, 4, TRUE);
4080 proto_tree_add_item(tree, hf_smb2_read_remaining, tvb, offset, 4, TRUE);
4087 * If the pidvalid flag is set we assume it is a deferred
4088 * STATUS_PENDING read and thus a named pipe (==dcerpc)
4090 if(length && ( (si->tree && si->tree->share_type == SMB2_SHARE_TYPE_IPC)||(si->flags & SMB2_FLAGS_ASYNC_CMD))){
4091 offset = dissect_file_data_dcerpc(tvb, pinfo, tree, offset, length, si->top_tree);
4096 proto_tree_add_item(tree, hf_smb2_read_data, tvb, offset, length, TRUE);
4097 offset += MIN(length,(guint32)tvb_length_remaining(tvb, offset));
4103 dissect_smb2_ExtA_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
4105 proto_item *item=NULL;
4107 item = proto_tree_get_parent(tree);
4108 proto_item_append_text(item, ": SMB2_FILE_INFO_0f");
4110 dissect_smb2_file_info_0f(tvb, pinfo, tree, 0, si);
4115 dissect_smb2_TWrp_buffer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
4117 proto_item *item=NULL;
4119 item = proto_tree_get_parent(tree);
4120 proto_item_append_text(item, ": Timestamp");
4122 dissect_nt_64bit_time(tvb, tree, 0, hf_smb2_unknown_timestamp);
4129 dissect_smb2_AlSi_buffer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
4131 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, 0, 8, TRUE);
4135 dissect_smb2_DHnQ_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
4137 dissect_smb2_fid(tvb, pinfo, tree, 0, si, FID_MODE_DHNQ);
4141 dissect_smb2_DHnC_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
4143 dissect_smb2_fid(tvb, pinfo, tree, 0, si, FID_MODE_DHNC);
4147 dissect_smb2_MxAc_buffer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
4150 proto_item *item=NULL;
4151 proto_item *sub_item=NULL;
4152 proto_tree *sub_tree=NULL;
4155 item = proto_tree_get_parent(tree);
4158 if (tvb_length(tvb) == 0) {
4160 proto_item_append_text(item, ": NO DATA");
4166 proto_item_append_text(item, ": MxAc INFO");
4167 sub_item = proto_tree_add_text(tree, tvb, offset, -1, "MxAc INFO");
4168 sub_tree = proto_item_add_subtree(sub_item, ett_smb2_MxAc_buffer);
4171 proto_tree_add_item(sub_tree, hf_smb2_unknown, tvb, offset, 4, FALSE);
4174 offset = dissect_smb_access_mask(tvb, sub_tree, offset);
4180 dissect_smb2_create_extra_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si)
4182 offset_length_buffer_t tag_olb;
4183 offset_length_buffer_t data_olb;
4185 guint16 chain_offset;
4188 void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si);
4189 proto_item *sub_item=NULL;
4190 proto_tree *sub_tree=NULL;
4191 proto_item *parent_item=NULL;
4193 chain_offset=tvb_get_letohl(tvb, offset);
4199 sub_item = proto_tree_add_text(parent_tree, tvb, offset, len, "Chain Element");
4200 sub_tree = proto_item_add_subtree(sub_item, ett_smb2_create_chain_element);
4201 parent_item = proto_tree_get_parent(parent_tree);
4205 proto_tree_add_item(sub_tree, hf_smb2_create_chain_offset, tvb, offset, 4, TRUE);
4208 /* tag offset/length */
4209 offset = dissect_smb2_olb_length_offset(tvb, offset, &tag_olb, OLB_O_UINT16_S_UINT32, hf_smb2_tag);
4211 /* data offset/length */
4212 offset = dissect_smb2_olb_length_offset(tvb, offset, &data_olb, OLB_O_UINT16_S_UINT32, hf_smb2_create_chain_data);
4215 tag = dissect_smb2_olb_string(pinfo, sub_tree, tvb, &tag_olb, OLB_TYPE_ASCII_STRING);
4217 proto_item_append_text(parent_item, " %s", tag);
4218 proto_item_append_text(sub_item, ": %s", tag);
4222 if(!strcmp(tag, "ExtA")){
4223 dissector = dissect_smb2_ExtA_buffer;
4224 } else if(!strcmp(tag, "AlSi")){
4225 dissector = dissect_smb2_AlSi_buffer;
4226 } else if(!strcmp(tag, "MxAc")){
4227 dissector = dissect_smb2_MxAc_buffer;
4228 } else if(!strcmp(tag, "DHnQ")){
4229 dissector = dissect_smb2_DHnQ_buffer;
4230 } else if(!strcmp(tag, "DHnC")){
4231 dissector = dissect_smb2_DHnC_buffer;
4232 } else if(!strcmp(tag, "TWrp")){
4233 dissector = dissect_smb2_TWrp_buffer;
4236 dissect_smb2_olb_buffer(pinfo, sub_tree, tvb, &data_olb, si, dissector);
4239 tvbuff_t *chain_tvb;
4240 chain_tvb=tvb_new_subset(tvb, chain_offset, tvb_length_remaining(tvb, chain_offset), tvb_reported_length_remaining(tvb, chain_offset));
4242 /* next extra info */
4243 dissect_smb2_create_extra_info(chain_tvb, pinfo, parent_tree, si);
4249 dissect_smb2_create_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4251 offset_length_buffer_t f_olb, e_olb;
4255 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4257 /* security flags */
4261 offset = dissect_smb2_oplock(tree, tvb, offset);
4263 /* impersonation level */
4264 proto_tree_add_item(tree, hf_smb2_impersonation_level, tvb, offset, 4, TRUE);
4268 proto_tree_add_item(tree, hf_smb2_create_flags, tvb, offset, 8, TRUE);
4275 offset = dissect_smb_access_mask(tvb, tree, offset);
4277 /* File Attributes */
4278 offset = dissect_file_attributes(tvb, tree, offset, 4);
4281 offset = dissect_nt_share_access(tvb, tree, offset);
4283 /* create disposition */
4284 proto_tree_add_item(tree, hf_smb2_create_disposition, tvb, offset, 4, TRUE);
4287 /* create options */
4288 offset = dissect_nt_create_options(tvb, tree, offset);
4290 /* filename offset/length */
4291 offset = dissect_smb2_olb_length_offset(tvb, offset, &f_olb, OLB_O_UINT16_S_UINT16, hf_smb2_filename);
4293 /* extrainfo offset */
4294 offset = dissect_smb2_olb_length_offset(tvb, offset, &e_olb, OLB_O_UINT32_S_UINT32, hf_smb2_extrainfo);
4296 /* filename string */
4297 fname = dissect_smb2_olb_string(pinfo, tree, tvb, &f_olb, OLB_TYPE_UNICODE_STRING);
4298 if (check_col(pinfo->cinfo, COL_INFO)){
4299 col_append_fstr(pinfo->cinfo, COL_INFO, " File: %s", fname);
4302 /* save the name if it looks sane */
4303 if(!pinfo->fd->flags.visited){
4304 if(si->saved && si->saved->extra_info_type==SMB2_EI_FILENAME){
4305 g_free(si->saved->extra_info);
4306 si->saved->extra_info=NULL;
4307 si->saved->extra_info_type=SMB2_EI_NONE;
4309 if(si->saved && f_olb.len && f_olb.len<256){
4310 si->saved->extra_info_type=SMB2_EI_FILENAME;
4311 si->saved->extra_info=g_malloc(f_olb.len+1);
4312 g_snprintf(si->saved->extra_info, f_olb.len+1, "%s", fname);
4316 /* If extrainfo_offset is non-null then this points to another
4317 * buffer. The offset is relative to the start of the smb packet
4319 dissect_smb2_olb_buffer(pinfo, tree, tvb, &e_olb, si, dissect_smb2_create_extra_info);
4321 offset = dissect_smb2_olb_tvb_max_offset(offset, &f_olb);
4322 offset = dissect_smb2_olb_tvb_max_offset(offset, &e_olb);
4328 dissect_smb2_create_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4330 offset_length_buffer_t e_olb;
4332 switch (si->status) {
4333 case 0x00000000: break;
4334 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
4338 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4341 offset = dissect_smb2_oplock(tree, tvb, offset);
4347 proto_tree_add_item(tree, hf_smb2_create_action, tvb, offset, 4, TRUE);
4351 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
4354 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
4357 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
4360 offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
4362 /* allocation size */
4363 proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, TRUE);
4367 proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, TRUE);
4370 /* File Attributes */
4371 offset = dissect_file_attributes(tvb, tree, offset, 4);
4377 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_OPEN);
4379 /* extrainfo offset */
4380 offset = dissect_smb2_olb_length_offset(tvb, offset, &e_olb, OLB_O_UINT32_S_UINT32, hf_smb2_extrainfo);
4382 /* If extrainfo_offset is non-null then this points to another
4383 * buffer. The offset is relative to the start of the smb packet
4385 dissect_smb2_olb_buffer(pinfo, tree, tvb, &e_olb, si, dissect_smb2_create_extra_info);
4387 offset = dissect_smb2_olb_tvb_max_offset(offset, &e_olb);
4389 /* free si->saved->extra_info we dont need it any more */
4390 if(si->saved && si->saved->extra_info_type==SMB2_EI_FILENAME){
4391 g_free(si->saved->extra_info);
4392 si->saved->extra_info=NULL;
4393 si->saved->extra_info_type=SMB2_EI_NONE;
4401 dissect_smb2_setinfo_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4403 guint32 setinfo_size;
4404 guint16 setinfo_offset;
4407 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4409 /* class and info level */
4410 offset = dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
4413 setinfo_size=tvb_get_letohl(tvb, offset);
4414 proto_tree_add_item(tree, hf_smb2_setinfo_size, tvb, offset, 4, TRUE);
4418 setinfo_offset=tvb_get_letohs(tvb, offset);
4419 proto_tree_add_item(tree, hf_smb2_setinfo_offset, tvb, offset, 2, TRUE);
4422 /* some unknown bytes */
4423 proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 6, TRUE);
4427 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
4431 dissect_smb2_infolevel(tvb, pinfo, tree, setinfo_offset, si, si->saved->class, si->saved->infolevel);
4432 offset = setinfo_offset + setinfo_size;
4438 dissect_smb2_setinfo_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4440 /* class/infolevel */
4441 dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
4443 switch (si->status) {
4444 case 0x00000000: break;
4445 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
4449 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4455 dissect_smb2_break_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4458 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4461 offset = dissect_smb2_oplock(tree, tvb, offset);
4470 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
4476 dissect_smb2_break_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
4478 switch (si->status) {
4479 case 0x00000000: break;
4480 default: return dissect_smb2_error_response(tvb, pinfo, tree, offset, si);
4484 offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
4487 offset = dissect_smb2_oplock(tree, tvb, offset);
4496 offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
4498 /* in break requests from server to client here're 24 byte zero bytes
4499 * which are likely a bug in windows (they may use 2* 24 bytes instead of just
4506 /* names here are just until we find better names for these functions */
4507 const value_string smb2_cmd_vals[] = {
4508 { 0x00, "NegotiateProtocol" },
4509 { 0x01, "SessionSetup" },
4510 { 0x02, "SessionLogoff" },
4511 { 0x03, "TreeConnect" },
4512 { 0x04, "TreeDisconnect" },
4521 { 0x0D, "KeepAlive" },
4524 { 0x10, "GetInfo" },
4525 { 0x11, "SetInfo" },
4527 { 0x13, "unknown-0x13" },
4528 { 0x14, "unknown-0x14" },
4529 { 0x15, "unknown-0x15" },
4530 { 0x16, "unknown-0x16" },
4531 { 0x17, "unknown-0x17" },
4532 { 0x18, "unknown-0x18" },
4533 { 0x19, "unknown-0x19" },
4534 { 0x1A, "unknown-0x1A" },
4535 { 0x1B, "unknown-0x1B" },
4536 { 0x1C, "unknown-0x1C" },
4537 { 0x1D, "unknown-0x1D" },
4538 { 0x1E, "unknown-0x1E" },
4539 { 0x1F, "unknown-0x1F" },
4540 { 0x20, "unknown-0x20" },
4541 { 0x21, "unknown-0x21" },
4542 { 0x22, "unknown-0x22" },
4543 { 0x23, "unknown-0x23" },
4544 { 0x24, "unknown-0x24" },
4545 { 0x25, "unknown-0x25" },
4546 { 0x26, "unknown-0x26" },
4547 { 0x27, "unknown-0x27" },
4548 { 0x28, "unknown-0x28" },
4549 { 0x29, "unknown-0x29" },
4550 { 0x2A, "unknown-0x2A" },
4551 { 0x2B, "unknown-0x2B" },
4552 { 0x2C, "unknown-0x2C" },
4553 { 0x2D, "unknown-0x2D" },
4554 { 0x2E, "unknown-0x2E" },
4555 { 0x2F, "unknown-0x2F" },
4556 { 0x30, "unknown-0x30" },
4557 { 0x31, "unknown-0x31" },
4558 { 0x32, "unknown-0x32" },
4559 { 0x33, "unknown-0x33" },
4560 { 0x34, "unknown-0x34" },
4561 { 0x35, "unknown-0x35" },
4562 { 0x36, "unknown-0x36" },
4563 { 0x37, "unknown-0x37" },
4564 { 0x38, "unknown-0x38" },
4565 { 0x39, "unknown-0x39" },
4566 { 0x3A, "unknown-0x3A" },
4567 { 0x3B, "unknown-0x3B" },
4568 { 0x3C, "unknown-0x3C" },
4569 { 0x3D, "unknown-0x3D" },
4570 { 0x3E, "unknown-0x3E" },
4571 { 0x3F, "unknown-0x3F" },
4572 { 0x40, "unknown-0x40" },
4573 { 0x41, "unknown-0x41" },
4574 { 0x42, "unknown-0x42" },
4575 { 0x43, "unknown-0x43" },
4576 { 0x44, "unknown-0x44" },
4577 { 0x45, "unknown-0x45" },
4578 { 0x46, "unknown-0x46" },
4579 { 0x47, "unknown-0x47" },
4580 { 0x48, "unknown-0x48" },
4581 { 0x49, "unknown-0x49" },
4582 { 0x4A, "unknown-0x4A" },
4583 { 0x4B, "unknown-0x4B" },
4584 { 0x4C, "unknown-0x4C" },
4585 { 0x4D, "unknown-0x4D" },
4586 { 0x4E, "unknown-0x4E" },
4587 { 0x4F, "unknown-0x4F" },
4588 { 0x50, "unknown-0x50" },
4589 { 0x51, "unknown-0x51" },
4590 { 0x52, "unknown-0x52" },
4591 { 0x53, "unknown-0x53" },
4592 { 0x54, "unknown-0x54" },
4593 { 0x55, "unknown-0x55" },
4594 { 0x56, "unknown-0x56" },
4595 { 0x57, "unknown-0x57" },
4596 { 0x58, "unknown-0x58" },
4597 { 0x59, "unknown-0x59" },
4598 { 0x5A, "unknown-0x5A" },
4599 { 0x5B, "unknown-0x5B" },
4600 { 0x5C, "unknown-0x5C" },
4601 { 0x5D, "unknown-0x5D" },
4602 { 0x5E, "unknown-0x5E" },
4603 { 0x5F, "unknown-0x5F" },
4604 { 0x60, "unknown-0x60" },
4605 { 0x61, "unknown-0x61" },
4606 { 0x62, "unknown-0x62" },
4607 { 0x63, "unknown-0x63" },
4608 { 0x64, "unknown-0x64" },
4609 { 0x65, "unknown-0x65" },
4610 { 0x66, "unknown-0x66" },
4611 { 0x67, "unknown-0x67" },
4612 { 0x68, "unknown-0x68" },
4613 { 0x69, "unknown-0x69" },
4614 { 0x6A, "unknown-0x6A" },
4615 { 0x6B, "unknown-0x6B" },
4616 { 0x6C, "unknown-0x6C" },
4617 { 0x6D, "unknown-0x6D" },
4618 { 0x6E, "unknown-0x6E" },
4619 { 0x6F, "unknown-0x6F" },
4620 { 0x70, "unknown-0x70" },
4621 { 0x71, "unknown-0x71" },
4622 { 0x72, "unknown-0x72" },
4623 { 0x73, "unknown-0x73" },
4624 { 0x74, "unknown-0x74" },
4625 { 0x75, "unknown-0x75" },
4626 { 0x76, "unknown-0x76" },
4627 { 0x77, "unknown-0x77" },
4628 { 0x78, "unknown-0x78" },
4629 { 0x79, "unknown-0x79" },
4630 { 0x7A, "unknown-0x7A" },
4631 { 0x7B, "unknown-0x7B" },
4632 { 0x7C, "unknown-0x7C" },
4633 { 0x7D, "unknown-0x7D" },
4634 { 0x7E, "unknown-0x7E" },
4635 { 0x7F, "unknown-0x7F" },
4636 { 0x80, "unknown-0x80" },
4637 { 0x81, "unknown-0x81" },
4638 { 0x82, "unknown-0x82" },
4639 { 0x83, "unknown-0x83" },
4640 { 0x84, "unknown-0x84" },
4641 { 0x85, "unknown-0x85" },
4642 { 0x86, "unknown-0x86" },
4643 { 0x87, "unknown-0x87" },
4644 { 0x88, "unknown-0x88" },
4645 { 0x89, "unknown-0x89" },
4646 { 0x8A, "unknown-0x8A" },
4647 { 0x8B, "unknown-0x8B" },
4648 { 0x8C, "unknown-0x8C" },
4649 { 0x8D, "unknown-0x8D" },
4650 { 0x8E, "unknown-0x8E" },
4651 { 0x8F, "unknown-0x8F" },
4652 { 0x90, "unknown-0x90" },
4653 { 0x91, "unknown-0x91" },
4654 { 0x92, "unknown-0x92" },
4655 { 0x93, "unknown-0x93" },
4656 { 0x94, "unknown-0x94" },
4657 { 0x95, "unknown-0x95" },
4658 { 0x96, "unknown-0x96" },
4659 { 0x97, "unknown-0x97" },
4660 { 0x98, "unknown-0x98" },
4661 { 0x99, "unknown-0x99" },
4662 { 0x9A, "unknown-0x9A" },
4663 { 0x9B, "unknown-0x9B" },
4664 { 0x9C, "unknown-0x9C" },
4665 { 0x9D, "unknown-0x9D" },
4666 { 0x9E, "unknown-0x9E" },
4667 { 0x9F, "unknown-0x9F" },
4668 { 0xA0, "unknown-0xA0" },
4669 { 0xA1, "unknown-0xA1" },
4670 { 0xA2, "unknown-0xA2" },
4671 { 0xA3, "unknown-0xA3" },
4672 { 0xA4, "unknown-0xA4" },
4673 { 0xA5, "unknown-0xA5" },
4674 { 0xA6, "unknown-0xA6" },
4675 { 0xA7, "unknown-0xA7" },
4676 { 0xA8, "unknown-0xA8" },
4677 { 0xA9, "unknown-0xA9" },
4678 { 0xAA, "unknown-0xAA" },
4679 { 0xAB, "unknown-0xAB" },
4680 { 0xAC, "unknown-0xAC" },
4681 { 0xAD, "unknown-0xAD" },
4682 { 0xAE, "unknown-0xAE" },
4683 { 0xAF, "unknown-0xAF" },
4684 { 0xB0, "unknown-0xB0" },
4685 { 0xB1, "unknown-0xB1" },
4686 { 0xB2, "unknown-0xB2" },
4687 { 0xB3, "unknown-0xB3" },
4688 { 0xB4, "unknown-0xB4" },
4689 { 0xB5, "unknown-0xB5" },
4690 { 0xB6, "unknown-0xB6" },
4691 { 0xB7, "unknown-0xB7" },
4692 { 0xB8, "unknown-0xB8" },
4693 { 0xB9, "unknown-0xB9" },
4694 { 0xBA, "unknown-0xBA" },
4695 { 0xBB, "unknown-0xBB" },
4696 { 0xBC, "unknown-0xBC" },
4697 { 0xBD, "unknown-0xBD" },
4698 { 0xBE, "unknown-0xBE" },
4699 { 0xBF, "unknown-0xBF" },
4700 { 0xC0, "unknown-0xC0" },
4701 { 0xC1, "unknown-0xC1" },
4702 { 0xC2, "unknown-0xC2" },
4703 { 0xC3, "unknown-0xC3" },
4704 { 0xC4, "unknown-0xC4" },
4705 { 0xC5, "unknown-0xC5" },
4706 { 0xC6, "unknown-0xC6" },
4707 { 0xC7, "unknown-0xC7" },
4708 { 0xC8, "unknown-0xC8" },
4709 { 0xC9, "unknown-0xC9" },
4710 { 0xCA, "unknown-0xCA" },
4711 { 0xCB, "unknown-0xCB" },
4712 { 0xCC, "unknown-0xCC" },
4713 { 0xCD, "unknown-0xCD" },
4714 { 0xCE, "unknown-0xCE" },
4715 { 0xCF, "unknown-0xCF" },
4716 { 0xD0, "unknown-0xD0" },
4717 { 0xD1, "unknown-0xD1" },
4718 { 0xD2, "unknown-0xD2" },
4719 { 0xD3, "unknown-0xD3" },
4720 { 0xD4, "unknown-0xD4" },
4721 { 0xD5, "unknown-0xD5" },
4722 { 0xD6, "unknown-0xD6" },
4723 { 0xD7, "unknown-0xD7" },
4724 { 0xD8, "unknown-0xD8" },
4725 { 0xD9, "unknown-0xD9" },
4726 { 0xDA, "unknown-0xDA" },
4727 { 0xDB, "unknown-0xDB" },
4728 { 0xDC, "unknown-0xDC" },
4729 { 0xDD, "unknown-0xDD" },
4730 { 0xDE, "unknown-0xDE" },
4731 { 0xDF, "unknown-0xDF" },
4732 { 0xE0, "unknown-0xE0" },
4733 { 0xE1, "unknown-0xE1" },
4734 { 0xE2, "unknown-0xE2" },
4735 { 0xE3, "unknown-0xE3" },
4736 { 0xE4, "unknown-0xE4" },
4737 { 0xE5, "unknown-0xE5" },
4738 { 0xE6, "unknown-0xE6" },
4739 { 0xE7, "unknown-0xE7" },
4740 { 0xE8, "unknown-0xE8" },
4741 { 0xE9, "unknown-0xE9" },
4742 { 0xEA, "unknown-0xEA" },
4743 { 0xEB, "unknown-0xEB" },
4744 { 0xEC, "unknown-0xEC" },
4745 { 0xED, "unknown-0xED" },
4746 { 0xEE, "unknown-0xEE" },
4747 { 0xEF, "unknown-0xEF" },
4748 { 0xF0, "unknown-0xF0" },
4749 { 0xF1, "unknown-0xF1" },
4750 { 0xF2, "unknown-0xF2" },
4751 { 0xF3, "unknown-0xF3" },
4752 { 0xF4, "unknown-0xF4" },
4753 { 0xF5, "unknown-0xF5" },
4754 { 0xF6, "unknown-0xF6" },
4755 { 0xF7, "unknown-0xF7" },
4756 { 0xF8, "unknown-0xF8" },
4757 { 0xF9, "unknown-0xF9" },
4758 { 0xFA, "unknown-0xFA" },
4759 { 0xFB, "unknown-0xFB" },
4760 { 0xFC, "unknown-0xFC" },
4761 { 0xFD, "unknown-0xFD" },
4762 { 0xFE, "unknown-0xFE" },
4763 { 0xFF, "unknown-0xFF" },
4766 static const char *decode_smb2_name(guint16 cmd)
4768 if (cmd > 0xFF) return "unknown";
4769 return(smb2_cmd_vals[cmd & 0xFF].strptr);
4772 static smb2_function smb2_dissector[256] = {
4773 /* 0x00 NegotiateProtocol*/
4774 {dissect_smb2_negotiate_protocol_request,
4775 dissect_smb2_negotiate_protocol_response},
4776 /* 0x01 SessionSetup*/
4777 {dissect_smb2_session_setup_request,
4778 dissect_smb2_session_setup_response},
4779 /* 0x02 SessionLogoff*/
4780 {dissect_smb2_sessionlogoff_request,
4781 dissect_smb2_sessionlogoff_response},
4782 /* 0x03 TreeConnect*/
4783 {dissect_smb2_tree_connect_request,
4784 dissect_smb2_tree_connect_response},
4785 /* 0x04 TreeDisconnect*/
4786 {dissect_smb2_tree_disconnect_request,
4787 dissect_smb2_tree_disconnect_response},
4789 {dissect_smb2_create_request,
4790 dissect_smb2_create_response},
4792 {dissect_smb2_close_request,
4793 dissect_smb2_close_response},
4795 {dissect_smb2_flush_request,
4796 dissect_smb2_flush_response},
4798 {dissect_smb2_read_request,
4799 dissect_smb2_read_response},
4801 {dissect_smb2_write_request,
4802 dissect_smb2_write_response},
4804 {dissect_smb2_lock_request,
4805 dissect_smb2_lock_response},
4807 {dissect_smb2_ioctl_request,
4808 dissect_smb2_ioctl_response},
4810 {dissect_smb2_cancel_request,
4813 {dissect_smb2_keepalive_request,
4814 dissect_smb2_keepalive_response},
4816 {dissect_smb2_find_request,
4817 dissect_smb2_find_response},
4819 {dissect_smb2_notify_request,
4820 dissect_smb2_notify_response},
4822 {dissect_smb2_getinfo_request,
4823 dissect_smb2_getinfo_response},
4825 {dissect_smb2_setinfo_request,
4826 dissect_smb2_setinfo_response},
4828 {dissect_smb2_break_request,
4829 dissect_smb2_break_response},
4830 /* 0x13 */ {NULL, NULL},
4831 /* 0x14 */ {NULL, NULL},
4832 /* 0x15 */ {NULL, NULL},
4833 /* 0x16 */ {NULL, NULL},
4834 /* 0x17 */ {NULL, NULL},
4835 /* 0x18 */ {NULL, NULL},
4836 /* 0x19 */ {NULL, NULL},
4837 /* 0x1a */ {NULL, NULL},
4838 /* 0x1b */ {NULL, NULL},
4839 /* 0x1c */ {NULL, NULL},
4840 /* 0x1d */ {NULL, NULL},
4841 /* 0x1e */ {NULL, NULL},
4842 /* 0x1f */ {NULL, NULL},
4843 /* 0x20 */ {NULL, NULL},
4844 /* 0x21 */ {NULL, NULL},
4845 /* 0x22 */ {NULL, NULL},
4846 /* 0x23 */ {NULL, NULL},
4847 /* 0x24 */ {NULL, NULL},
4848 /* 0x25 */ {NULL, NULL},
4849 /* 0x26 */ {NULL, NULL},
4850 /* 0x27 */ {NULL, NULL},
4851 /* 0x28 */ {NULL, NULL},
4852 /* 0x29 */ {NULL, NULL},
4853 /* 0x2a */ {NULL, NULL},
4854 /* 0x2b */ {NULL, NULL},
4855 /* 0x2c */ {NULL, NULL},
4856 /* 0x2d */ {NULL, NULL},
4857 /* 0x2e */ {NULL, NULL},
4858 /* 0x2f */ {NULL, NULL},
4859 /* 0x30 */ {NULL, NULL},
4860 /* 0x31 */ {NULL, NULL},
4861 /* 0x32 */ {NULL, NULL},
4862 /* 0x33 */ {NULL, NULL},
4863 /* 0x34 */ {NULL, NULL},
4864 /* 0x35 */ {NULL, NULL},
4865 /* 0x36 */ {NULL, NULL},
4866 /* 0x37 */ {NULL, NULL},
4867 /* 0x38 */ {NULL, NULL},
4868 /* 0x39 */ {NULL, NULL},
4869 /* 0x3a */ {NULL, NULL},
4870 /* 0x3b */ {NULL, NULL},
4871 /* 0x3c */ {NULL, NULL},
4872 /* 0x3d */ {NULL, NULL},
4873 /* 0x3e */ {NULL, NULL},
4874 /* 0x3f */ {NULL, NULL},
4875 /* 0x40 */ {NULL, NULL},
4876 /* 0x41 */ {NULL, NULL},
4877 /* 0x42 */ {NULL, NULL},
4878 /* 0x43 */ {NULL, NULL},
4879 /* 0x44 */ {NULL, NULL},
4880 /* 0x45 */ {NULL, NULL},
4881 /* 0x46 */ {NULL, NULL},
4882 /* 0x47 */ {NULL, NULL},
4883 /* 0x48 */ {NULL, NULL},
4884 /* 0x49 */ {NULL, NULL},
4885 /* 0x4a */ {NULL, NULL},
4886 /* 0x4b */ {NULL, NULL},
4887 /* 0x4c */ {NULL, NULL},
4888 /* 0x4d */ {NULL, NULL},
4889 /* 0x4e */ {NULL, NULL},
4890 /* 0x4f */ {NULL, NULL},
4891 /* 0x50 */ {NULL, NULL},
4892 /* 0x51 */ {NULL, NULL},
4893 /* 0x52 */ {NULL, NULL},
4894 /* 0x53 */ {NULL, NULL},
4895 /* 0x54 */ {NULL, NULL},
4896 /* 0x55 */ {NULL, NULL},
4897 /* 0x56 */ {NULL, NULL},
4898 /* 0x57 */ {NULL, NULL},
4899 /* 0x58 */ {NULL, NULL},
4900 /* 0x59 */ {NULL, NULL},
4901 /* 0x5a */ {NULL, NULL},
4902 /* 0x5b */ {NULL, NULL},
4903 /* 0x5c */ {NULL, NULL},
4904 /* 0x5d */ {NULL, NULL},
4905 /* 0x5e */ {NULL, NULL},
4906 /* 0x5f */ {NULL, NULL},
4907 /* 0x60 */ {NULL, NULL},
4908 /* 0x61 */ {NULL, NULL},
4909 /* 0x62 */ {NULL, NULL},
4910 /* 0x63 */ {NULL, NULL},
4911 /* 0x64 */ {NULL, NULL},
4912 /* 0x65 */ {NULL, NULL},
4913 /* 0x66 */ {NULL, NULL},
4914 /* 0x67 */ {NULL, NULL},
4915 /* 0x68 */ {NULL, NULL},
4916 /* 0x69 */ {NULL, NULL},
4917 /* 0x6a */ {NULL, NULL},
4918 /* 0x6b */ {NULL, NULL},
4919 /* 0x6c */ {NULL, NULL},
4920 /* 0x6d */ {NULL, NULL},
4921 /* 0x6e */ {NULL, NULL},
4922 /* 0x6f */ {NULL, NULL},
4923 /* 0x70 */ {NULL, NULL},
4924 /* 0x71 */ {NULL, NULL},
4925 /* 0x72 */ {NULL, NULL},
4926 /* 0x73 */ {NULL, NULL},
4927 /* 0x74 */ {NULL, NULL},
4928 /* 0x75 */ {NULL, NULL},
4929 /* 0x76 */ {NULL, NULL},
4930 /* 0x77 */ {NULL, NULL},
4931 /* 0x78 */ {NULL, NULL},
4932 /* 0x79 */ {NULL, NULL},
4933 /* 0x7a */ {NULL, NULL},
4934 /* 0x7b */ {NULL, NULL},
4935 /* 0x7c */ {NULL, NULL},
4936 /* 0x7d */ {NULL, NULL},
4937 /* 0x7e */ {NULL, NULL},
4938 /* 0x7f */ {NULL, NULL},
4939 /* 0x80 */ {NULL, NULL},
4940 /* 0x81 */ {NULL, NULL},
4941 /* 0x82 */ {NULL, NULL},
4942 /* 0x83 */ {NULL, NULL},
4943 /* 0x84 */ {NULL, NULL},
4944 /* 0x85 */ {NULL, NULL},
4945 /* 0x86 */ {NULL, NULL},
4946 /* 0x87 */ {NULL, NULL},
4947 /* 0x88 */ {NULL, NULL},
4948 /* 0x89 */ {NULL, NULL},
4949 /* 0x8a */ {NULL, NULL},
4950 /* 0x8b */ {NULL, NULL},
4951 /* 0x8c */ {NULL, NULL},
4952 /* 0x8d */ {NULL, NULL},
4953 /* 0x8e */ {NULL, NULL},
4954 /* 0x8f */ {NULL, NULL},
4955 /* 0x90 */ {NULL, NULL},
4956 /* 0x91 */ {NULL, NULL},
4957 /* 0x92 */ {NULL, NULL},
4958 /* 0x93 */ {NULL, NULL},
4959 /* 0x94 */ {NULL, NULL},
4960 /* 0x95 */ {NULL, NULL},
4961 /* 0x96 */ {NULL, NULL},
4962 /* 0x97 */ {NULL, NULL},
4963 /* 0x98 */ {NULL, NULL},
4964 /* 0x99 */ {NULL, NULL},
4965 /* 0x9a */ {NULL, NULL},
4966 /* 0x9b */ {NULL, NULL},
4967 /* 0x9c */ {NULL, NULL},
4968 /* 0x9d */ {NULL, NULL},
4969 /* 0x9e */ {NULL, NULL},
4970 /* 0x9f */ {NULL, NULL},
4971 /* 0xa0 */ {NULL, NULL},
4972 /* 0xa1 */ {NULL, NULL},
4973 /* 0xa2 */ {NULL, NULL},
4974 /* 0xa3 */ {NULL, NULL},
4975 /* 0xa4 */ {NULL, NULL},
4976 /* 0xa5 */ {NULL, NULL},
4977 /* 0xa6 */ {NULL, NULL},
4978 /* 0xa7 */ {NULL, NULL},
4979 /* 0xa8 */ {NULL, NULL},
4980 /* 0xa9 */ {NULL, NULL},
4981 /* 0xaa */ {NULL, NULL},
4982 /* 0xab */ {NULL, NULL},
4983 /* 0xac */ {NULL, NULL},
4984 /* 0xad */ {NULL, NULL},
4985 /* 0xae */ {NULL, NULL},
4986 /* 0xaf */ {NULL, NULL},
4987 /* 0xb0 */ {NULL, NULL},
4988 /* 0xb1 */ {NULL, NULL},
4989 /* 0xb2 */ {NULL, NULL},
4990 /* 0xb3 */ {NULL, NULL},
4991 /* 0xb4 */ {NULL, NULL},
4992 /* 0xb5 */ {NULL, NULL},
4993 /* 0xb6 */ {NULL, NULL},
4994 /* 0xb7 */ {NULL, NULL},
4995 /* 0xb8 */ {NULL, NULL},
4996 /* 0xb9 */ {NULL, NULL},
4997 /* 0xba */ {NULL, NULL},
4998 /* 0xbb */ {NULL, NULL},
4999 /* 0xbc */ {NULL, NULL},
5000 /* 0xbd */ {NULL, NULL},
5001 /* 0xbe */ {NULL, NULL},
5002 /* 0xbf */ {NULL, NULL},
5003 /* 0xc0 */ {NULL, NULL},
5004 /* 0xc1 */ {NULL, NULL},
5005 /* 0xc2 */ {NULL, NULL},
5006 /* 0xc3 */ {NULL, NULL},
5007 /* 0xc4 */ {NULL, NULL},
5008 /* 0xc5 */ {NULL, NULL},
5009 /* 0xc6 */ {NULL, NULL},
5010 /* 0xc7 */ {NULL, NULL},
5011 /* 0xc8 */ {NULL, NULL},
5012 /* 0xc9 */ {NULL, NULL},
5013 /* 0xca */ {NULL, NULL},
5014 /* 0xcb */ {NULL, NULL},
5015 /* 0xcc */ {NULL, NULL},
5016 /* 0xcd */ {NULL, NULL},
5017 /* 0xce */ {NULL, NULL},
5018 /* 0xcf */ {NULL, NULL},
5019 /* 0xd0 */ {NULL, NULL},
5020 /* 0xd1 */ {NULL, NULL},
5021 /* 0xd2 */ {NULL, NULL},
5022 /* 0xd3 */ {NULL, NULL},
5023 /* 0xd4 */ {NULL, NULL},
5024 /* 0xd5 */ {NULL, NULL},
5025 /* 0xd6 */ {NULL, NULL},
5026 /* 0xd7 */ {NULL, NULL},
5027 /* 0xd8 */ {NULL, NULL},
5028 /* 0xd9 */ {NULL, NULL},
5029 /* 0xda */ {NULL, NULL},
5030 /* 0xdb */ {NULL, NULL},
5031 /* 0xdc */ {NULL, NULL},
5032 /* 0xdd */ {NULL, NULL},
5033 /* 0xde */ {NULL, NULL},
5034 /* 0xdf */ {NULL, NULL},
5035 /* 0xe0 */ {NULL, NULL},
5036 /* 0xe1 */ {NULL, NULL},
5037 /* 0xe2 */ {NULL, NULL},
5038 /* 0xe3 */ {NULL, NULL},
5039 /* 0xe4 */ {NULL, NULL},
5040 /* 0xe5 */ {NULL, NULL},
5041 /* 0xe6 */ {NULL, NULL},
5042 /* 0xe7 */ {NULL, NULL},
5043 /* 0xe8 */ {NULL, NULL},
5044 /* 0xe9 */ {NULL, NULL},
5045 /* 0xea */ {NULL, NULL},
5046 /* 0xeb */ {NULL, NULL},
5047 /* 0xec */ {NULL, NULL},
5048 /* 0xed */ {NULL, NULL},
5049 /* 0xee */ {NULL, NULL},
5050 /* 0xef */ {NULL, NULL},
5051 /* 0xf0 */ {NULL, NULL},
5052 /* 0xf1 */ {NULL, NULL},
5053 /* 0xf2 */ {NULL, NULL},
5054 /* 0xf3 */ {NULL, NULL},
5055 /* 0xf4 */ {NULL, NULL},
5056 /* 0xf5 */ {NULL, NULL},
5057 /* 0xf6 */ {NULL, NULL},
5058 /* 0xf7 */ {NULL, NULL},
5059 /* 0xf8 */ {NULL, NULL},
5060 /* 0xf9 */ {NULL, NULL},
5061 /* 0xfa */ {NULL, NULL},
5062 /* 0xfb */ {NULL, NULL},
5063 /* 0xfc */ {NULL, NULL},
5064 /* 0xfd */ {NULL, NULL},
5065 /* 0xfe */ {NULL, NULL},
5066 /* 0xff */ {NULL, NULL},
5071 dissect_smb2_command(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, smb2_info_t *si)
5073 int (*cmd_dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si);
5074 proto_item *cmd_item;
5075 proto_tree *cmd_tree;
5076 int old_offset = offset;
5078 cmd_item = proto_tree_add_text(tree, tvb, offset, -1,
5080 decode_smb2_name(si->opcode),
5081 (si->flags & SMB2_FLAGS_RESPONSE)?"Response":"Request",
5083 cmd_tree = proto_item_add_subtree(cmd_item, ett_smb2_command);
5086 cmd_dissector=(si->flags & SMB2_FLAGS_RESPONSE)?
5087 smb2_dissector[si->opcode&0xff].response:
5088 smb2_dissector[si->opcode&0xff].request;
5090 offset=(*cmd_dissector)(tvb, pinfo, cmd_tree, offset, si);
5092 proto_tree_add_item(cmd_tree, hf_smb2_unknown, tvb, offset, -1, FALSE);
5093 offset=tvb_length(tvb);
5096 proto_item_set_len(cmd_item, offset-old_offset);
5102 dissect_smb2_tid_sesid(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, smb2_info_t *si)
5104 proto_item *tid_item=NULL;
5105 proto_tree *tid_tree=NULL;
5106 smb2_tid_info_t tid_key;
5108 proto_item *sesid_item=NULL;
5109 proto_tree *sesid_tree=NULL;
5110 smb2_sesid_info_t sesid_key;
5116 if (si->flags&SMB2_FLAGS_ASYNC_CMD) {
5117 proto_tree_add_item(tree, hf_smb2_aid, tvb, offset, 8, TRUE);
5121 pid=tvb_get_letohl(tvb, offset);
5122 proto_tree_add_uint_format(tree, hf_smb2_pid, tvb, offset, 4, pid, "Process Id: %08x",pid);
5126 tid_offset = offset;
5127 si->tid=tvb_get_letohl(tvb, offset);
5128 tid_item=proto_tree_add_item(tree, hf_smb2_tid, tvb, offset, 4, TRUE);
5130 tid_tree=proto_item_add_subtree(tid_item, ett_smb2_tid_tree);
5136 sesid_offset = offset;
5137 si->sesid=tvb_get_letoh64(tvb, offset);
5138 sesid_item=proto_tree_add_item(tree, hf_smb2_sesid, tvb, offset, 8, TRUE);
5140 sesid_tree=proto_item_add_subtree(sesid_item, ett_smb2_sesid_tree);
5144 /* now we need to first lookup the uid session */
5145 sesid_key.sesid=si->sesid;
5146 si->session=g_hash_table_lookup(si->conv->sesids, &sesid_key);
5148 if (si->opcode != 0x03) return offset;
5150 /* if we come to a session that is unknown, and the operation is
5151 * a tree connect, we create a dummy sessison, so we can hang the
5154 si->session=se_alloc(sizeof(smb2_sesid_info_t));
5155 si->session->sesid=si->sesid;
5156 si->session->acct_name=NULL;
5157 si->session->domain_name=NULL;
5158 si->session->host_name=NULL;
5159 si->session->auth_frame=(guint32)-1;
5160 si->session->tids= g_hash_table_new(smb2_tid_info_hash, smb2_tid_info_equal);
5161 g_hash_table_insert(si->conv->sesids, si->session, si->session);
5166 if (si->session->auth_frame != (guint32)-1) {
5167 item=proto_tree_add_string(sesid_tree, hf_smb2_acct_name, tvb, sesid_offset, 0, si->session->acct_name);
5168 PROTO_ITEM_SET_GENERATED(item);
5169 proto_item_append_text(sesid_item, " Acct:%s", si->session->acct_name);
5171 item=proto_tree_add_string(sesid_tree, hf_smb2_domain_name, tvb, sesid_offset, 0, si->session->domain_name);
5172 PROTO_ITEM_SET_GENERATED(item);
5173 proto_item_append_text(sesid_item, " Domain:%s", si->session->domain_name);
5175 item=proto_tree_add_string(sesid_tree, hf_smb2_host_name, tvb, sesid_offset, 0, si->session->host_name);
5176 PROTO_ITEM_SET_GENERATED(item);
5177 proto_item_append_text(sesid_item, " Host:%s", si->session->host_name);
5179 item=proto_tree_add_uint(sesid_tree, hf_smb2_auth_frame, tvb, sesid_offset, 0, si->session->auth_frame);
5180 PROTO_ITEM_SET_GENERATED(item);
5183 if (!(si->flags&SMB2_FLAGS_ASYNC_CMD)) {
5184 /* see if we can find the name for this tid */
5185 tid_key.tid=si->tid;
5186 si->tree=g_hash_table_lookup(si->session->tids, &tid_key);
5187 if(!si->tree) return offset;
5189 item=proto_tree_add_string(tid_tree, hf_smb2_tree, tvb, tid_offset, 4, si->tree->name);
5190 PROTO_ITEM_SET_GENERATED(item);
5191 proto_item_append_text(tid_item, " %s", si->tree->name);
5193 item=proto_tree_add_uint(tid_tree, hf_smb2_share_type, tvb, tid_offset, 0, si->tree->share_type);
5194 PROTO_ITEM_SET_GENERATED(item);
5196 item=proto_tree_add_uint(tid_tree, hf_smb2_tcon_frame, tvb, tid_offset, 0, si->tree->connect_frame);
5197 PROTO_ITEM_SET_GENERATED(item);
5204 dissect_smb2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, gboolean first_in_chain)
5206 proto_item *seqnum_item;
5207 proto_item *item=NULL;
5208 proto_tree *tree=NULL;
5209 proto_item *header_item=NULL;
5210 proto_tree *header_tree=NULL;
5211 proto_item *flags_item=NULL;
5212 proto_tree *flags_tree=NULL;
5214 int chain_offset = 0;
5216 conversation_t *conversation;
5217 smb2_saved_info_t *ssi=NULL, ssi_key;
5220 si=ep_alloc(sizeof(smb2_info_t));
5224 si->top_tree=parent_tree;
5226 /* find which conversation we are part of and get the data for that
5229 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
5231 /* OK this is a new conversation so lets create it */
5232 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
5233 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
5235 si->conv=conversation_get_proto_data(conversation, proto_smb2);
5237 /* no smb2_into_t structure for this conversation yet,
5240 si->conv=se_alloc(sizeof(smb2_conv_info_t));
5241 /* qqq this leaks memory for now since we never free
5243 si->conv->matched= g_hash_table_new(smb2_saved_info_hash_matched,
5244 smb2_saved_info_equal_matched);
5245 si->conv->unmatched= g_hash_table_new(smb2_saved_info_hash_unmatched,
5246 smb2_saved_info_equal_unmatched);
5247 si->conv->sesids= g_hash_table_new(smb2_sesid_info_hash,
5248 smb2_sesid_info_equal);
5250 conversation_add_proto_data(conversation, proto_smb2, si->conv);
5254 if (check_col(pinfo->cinfo, COL_PROTOCOL)){
5255 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB2");
5257 if (check_col(pinfo->cinfo, COL_INFO)){
5258 if (first_in_chain) {
5260 col_clear(pinfo->cinfo, COL_INFO);
5262 col_append_str(pinfo->cinfo, COL_INFO, ";");
5267 item = proto_tree_add_item(parent_tree, proto_smb2, tvb, offset,
5269 tree = proto_item_add_subtree(item, ett_smb2);
5274 header_item = proto_tree_add_text(tree, tvb, offset, -1, "SMB2 Header");
5275 header_tree = proto_item_add_subtree(header_item, ett_smb2_header);
5278 /* Decode the header */
5280 proto_tree_add_text(header_tree, tvb, offset, 4, "Server Component: SMB2");
5284 header_len=tvb_get_letohs(tvb, offset);
5285 proto_tree_add_item(header_tree, hf_smb2_header_len, tvb, offset, 2, TRUE);
5289 proto_tree_add_item(header_tree, hf_smb2_epoch, tvb, offset, 2, TRUE);
5293 si->status=tvb_get_letohl(tvb, offset);
5294 proto_tree_add_item(header_tree, hf_smb2_nt_status, tvb, offset, 4, TRUE);
5299 si->opcode=tvb_get_letohs(tvb, offset);
5300 proto_tree_add_item(header_tree, hf_smb2_cmd, tvb, offset, 2, TRUE);
5303 /* we need the flags before we know how to parse the credits field */
5304 si->flags=tvb_get_letohl(tvb, offset+2);
5307 if (si->flags & SMB2_FLAGS_RESPONSE) {
5308 proto_tree_add_item(header_tree, hf_smb2_credits_granted, tvb, offset, 2, TRUE);
5310 proto_tree_add_item(header_tree, hf_smb2_credits_requested, tvb, offset, 2, TRUE);
5316 flags_item = proto_tree_add_text(header_tree, tvb, offset, 4,
5317 "Flags: 0x%08x", si->flags);
5318 flags_tree = proto_item_add_subtree(flags_item, ett_smb2_flags);
5320 proto_tree_add_boolean(flags_tree, hf_smb2_flags_dfs_op, tvb, offset, 4, si->flags);
5321 proto_tree_add_boolean(flags_tree, hf_smb2_flags_signature, tvb, offset, 4, si->flags);
5322 proto_tree_add_boolean(flags_tree, hf_smb2_flags_chained, tvb, offset, 4, si->flags);
5323 proto_tree_add_boolean(flags_tree, hf_smb2_flags_async_cmd, tvb, offset, 4, si->flags);
5324 proto_tree_add_boolean(flags_tree, hf_smb2_flags_response, tvb, offset, 4, si->flags);
5328 /* some unknown bytes */
5329 chain_offset=tvb_get_letohl(tvb, offset);
5330 proto_tree_add_item(header_tree, hf_smb2_chain_offset, tvb, offset, 4, FALSE);
5333 /* command sequence number*/
5334 si->seqnum=tvb_get_letoh64(tvb, offset);
5335 ssi_key.seqnum=si->seqnum;
5336 seqnum_item=proto_tree_add_item(header_tree, hf_smb2_seqnum, tvb, offset, 8, TRUE);
5337 if(seqnum_item && (si->seqnum==-1)){
5338 proto_item_append_text(seqnum_item, " (unsolicited response)");
5342 /* Tree ID and Session ID */
5343 offset = dissect_smb2_tid_sesid(pinfo, header_tree, tvb, offset, si);
5346 proto_tree_add_item(header_tree, hf_smb2_signature, tvb, offset, 16, FALSE);
5349 proto_item_set_len(header_item, offset);
5352 if (check_col(pinfo->cinfo, COL_INFO)){
5353 col_append_fstr(pinfo->cinfo, COL_INFO, "%s %s",
5354 decode_smb2_name(si->opcode),
5355 (si->flags & SMB2_FLAGS_RESPONSE)?"Response":"Request");
5358 pinfo->cinfo, COL_INFO, ", Error: %s",
5359 val_to_str(si->status, NT_errors,
5360 "Unknown (0x%08X)"));
5365 if(!pinfo->fd->flags.visited){
5366 /* see if we can find this seqnum in the unmatched table */
5367 ssi=g_hash_table_lookup(si->conv->unmatched, &ssi_key);
5369 if(!(si->flags & SMB2_FLAGS_RESPONSE)){
5370 /* This is a request */
5372 /* this is a request and we already found
5373 * an older ssi so just delete the previous
5376 g_hash_table_remove(si->conv->unmatched, ssi);
5381 /* no we couldnt find it, so just add it then
5382 * if was a request we are decoding
5384 ssi=se_alloc(sizeof(smb2_saved_info_t));
5387 ssi->seqnum=ssi_key.seqnum;
5388 ssi->frame_req=pinfo->fd->num;
5390 ssi->req_time=pinfo->fd->abs_ts;
5391 ssi->extra_info=NULL;
5392 ssi->extra_info_type=SMB2_EI_NONE;
5393 g_hash_table_insert(si->conv->unmatched, ssi, ssi);
5396 /* This is a response */
5398 /* just set the response frame and move it to the matched table */
5399 ssi->frame_res=pinfo->fd->num;
5400 g_hash_table_remove(si->conv->unmatched, ssi);
5401 g_hash_table_insert(si->conv->matched, ssi, ssi);
5405 /* see if we can find this seqnum in the matched table */
5406 ssi=g_hash_table_lookup(si->conv->matched, &ssi_key);
5407 /* if we couldnt find it in the matched table, it might still
5408 * be in the unmatched table
5411 ssi=g_hash_table_lookup(si->conv->unmatched, &ssi_key);
5416 if(!(si->flags & SMB2_FLAGS_RESPONSE)){
5418 proto_item *tmp_item;
5419 tmp_item=proto_tree_add_uint(header_tree, hf_smb2_response_in, tvb, 0, 0, ssi->frame_res);
5420 PROTO_ITEM_SET_GENERATED(tmp_item);
5424 proto_item *tmp_item;
5427 tmp_item=proto_tree_add_uint(header_tree, hf_smb2_response_to, tvb, 0, 0, ssi->frame_req);
5428 PROTO_ITEM_SET_GENERATED(tmp_item);
5429 t = pinfo->fd->abs_ts;
5430 nstime_delta(&deltat, &t, &ssi->req_time);
5431 tmp_item=proto_tree_add_time(header_tree, hf_smb2_time, tvb,
5433 PROTO_ITEM_SET_GENERATED(tmp_item);
5437 /* if we dont have ssi yet we must fake it */
5441 tap_queue_packet(smb2_tap, pinfo, si);
5443 /* Decode the payload */
5444 offset = dissect_smb2_command(pinfo, tree, tvb, offset, si);
5446 if (chain_offset > 0) {
5449 if (chain_offset < offset) {
5450 THROW(ReportedBoundsError);
5452 proto_item_set_len(item, chain_offset);
5454 next_tvb = tvb_new_subset(tvb, chain_offset, -1, -1);
5455 offset = dissect_smb2(next_tvb, pinfo, parent_tree, FALSE);
5462 dissect_smb2_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
5466 /* must check that this really is a smb2 packet */
5467 if (tvb_length(tvb) < 4)
5470 if( (tvb_get_guint8(tvb, 0) != 0xfe)
5471 || (tvb_get_guint8(tvb, 1) != 'S')
5472 || (tvb_get_guint8(tvb, 2) != 'M')
5473 || (tvb_get_guint8(tvb, 3) != 'B') ){
5477 offset = dissect_smb2(tvb, pinfo, parent_tree, TRUE);
5483 proto_register_smb2(void)
5485 static hf_register_info hf[] = {
5487 { "Command", "smb2.cmd", FT_UINT16, BASE_DEC,
5488 VALS(smb2_cmd_vals), 0, "SMB2 Command Opcode", HFILL }},
5489 { &hf_smb2_response_to,
5490 { "Response to", "smb2.response_to", FT_FRAMENUM, BASE_NONE,
5491 NULL, 0, "This packet is a response to the packet in this frame", HFILL }},
5492 { &hf_smb2_response_in,
5493 { "Response in", "smb2.response_in", FT_FRAMENUM, BASE_NONE,
5494 NULL, 0, "The response to this packet is in this packet", HFILL }},
5496 { "Time from request", "smb2.time", FT_RELATIVE_TIME, BASE_NONE,
5497 NULL, 0, "Time between Request and Response for SMB2 cmds", HFILL }},
5498 { &hf_smb2_header_len,
5499 { "Header Length", "smb2.header_len", FT_UINT16, BASE_DEC,
5500 NULL, 0, "SMB2 Size of Header", HFILL }},
5501 { &hf_smb2_nt_status,
5502 { "NT Status", "smb2.nt_status", FT_UINT32, BASE_HEX,
5503 VALS(NT_errors), 0, "NT Status code", HFILL }},
5505 { "Command Sequence Number", "smb2.seq_num", FT_INT64, BASE_DEC,
5506 NULL, 0, "SMB2 Command Sequence Number", HFILL }},
5508 { "Tree Id", "smb2.tid", FT_UINT32, BASE_HEX,
5509 NULL, 0, "SMB2 Tree Id", HFILL }},
5511 { "Async Id", "smb2.aid", FT_UINT64, BASE_HEX,
5512 NULL, 0, "SMB2 Async Id", HFILL }},
5514 { "Session Id", "smb2.sesid", FT_UINT64, BASE_HEX,
5515 NULL, 0, "SMB2 Session Id", HFILL }},
5516 { &hf_smb2_previous_sesid,
5517 { "Previous Session Id", "smb2.previous_sesid", FT_UINT64, BASE_HEX,
5518 NULL, 0, "SMB2 Previous Session Id", HFILL }},
5519 { &hf_smb2_chain_offset,
5520 { "Chain Offset", "smb2.chain_offset", FT_UINT32, BASE_HEX,
5521 NULL, 0, "SMB2 Chain Offset", HFILL }},
5522 { &hf_smb2_end_of_file,
5523 { "End Of File", "smb2.eof", FT_UINT64, BASE_DEC,
5524 NULL, 0, "SMB2 End Of File/File size", HFILL }},
5526 { "Number of Links", "smb2.nlinks", FT_UINT32, BASE_DEC,
5527 NULL, 0, "Number of links to this object", HFILL }},
5529 { "File Id", "smb2.file_id", FT_UINT64, BASE_HEX,
5530 NULL, 0, "SMB2 File Id", HFILL }},
5531 { &hf_smb2_allocation_size,
5532 { "Allocation Size", "smb2.allocation_size", FT_UINT64, BASE_DEC,
5533 NULL, 0, "SMB2 Allocation Size for this object", HFILL }},
5534 { &hf_smb2_max_response_size,
5535 { "Max Response Size", "smb2.max_response_size", FT_UINT32, BASE_DEC,
5536 NULL, 0, "SMB2 Maximum response size", HFILL }},
5537 { &hf_smb2_setinfo_size,
5538 { "Setinfo Size", "smb2.setinfo_size", FT_UINT32, BASE_DEC,
5539 NULL, 0, "SMB2 setinfo size", HFILL }},
5540 { &hf_smb2_setinfo_offset,
5541 { "Setinfo Offset", "smb2.setinfo_offset", FT_UINT16, BASE_HEX,
5542 NULL, 0, "SMB2 setinfo offset", HFILL }},
5543 { &hf_smb2_max_ioctl_out_size,
5544 { "Max Ioctl Out Size", "smb2.max_ioctl_out_size", FT_UINT32, BASE_DEC,
5545 NULL, 0, "SMB2 Maximum ioctl out size", HFILL }},
5546 { &hf_smb2_max_ioctl_in_size,
5547 { "Max Ioctl In Size", "smb2.max_ioctl_in_size", FT_UINT32, BASE_DEC,
5548 NULL, 0, "SMB2 Maximum ioctl out size", HFILL }},
5549 { &hf_smb2_response_size,
5550 { "Response Size", "smb2.response_size", FT_UINT32, BASE_DEC,
5551 NULL, 0, "SMB2 response size", HFILL }},
5552 { &hf_smb2_required_buffer_size,
5553 { "Required Buffer Size", "smb2.required_size", FT_UINT32, BASE_DEC,
5554 NULL, 0, "SMB2 required buffer size", HFILL }},
5556 { "Process Id", "smb2.pid", FT_UINT32, BASE_HEX,
5557 NULL, 0, "SMB2 Process Id", HFILL }},
5558 { &hf_smb2_flags_response,
5559 { "Response", "smb2.flags.response", FT_BOOLEAN, 32,
5560 TFS(&tfs_flags_response), SMB2_FLAGS_RESPONSE, "Whether this is an SMB2 Request or Response", HFILL }},
5561 { &hf_smb2_flags_async_cmd,
5562 { "Async command", "smb2.flags.async", FT_BOOLEAN, 32,
5563 TFS(&tfs_flags_async_cmd), SMB2_FLAGS_ASYNC_CMD, "", HFILL }},
5564 { &hf_smb2_flags_dfs_op,
5565 { "DFS operation", "smb2.flags.dfs", FT_BOOLEAN, 32,
5566 TFS(&tfs_flags_dfs_op), SMB2_FLAGS_DFS_OP, "", HFILL }},
5567 { &hf_smb2_flags_chained,
5568 { "Chained", "smb2.flags.chained", FT_BOOLEAN, 32,
5569 TFS(&tfs_flags_chained), SMB2_FLAGS_CHAINED, "Whether the pdu continues a chain or not", HFILL }},
5570 { &hf_smb2_flags_signature,
5571 { "Signing", "smb2.flags.signature", FT_BOOLEAN, 32,
5572 TFS(&tfs_flags_signature), SMB2_FLAGS_SIGNATURE, "Whether the pdu is signed or not", HFILL }},
5574 { "Tree", "smb2.tree", FT_STRING, BASE_NONE,
5575 NULL, 0, "Name of the Tree/Share", HFILL }},
5576 { &hf_smb2_filename,
5577 { "Filename", "smb2.filename", FT_STRING, BASE_NONE,
5578 NULL, 0, "Name of the file", HFILL }},
5579 { &hf_smb2_filename_len,
5580 { "Filename Length", "smb2.filename.len", FT_UINT32, BASE_DEC,
5581 NULL, 0, "Length of the file name", HFILL }},
5583 { &hf_smb2_security_blob_len,
5584 { "Security Blob Length", "smb2.security_blob_len", FT_UINT16, BASE_DEC,
5585 NULL, 0, "Security blob length", HFILL }},
5587 { &hf_smb2_security_blob_offset,
5588 { "Security Blob Offset", "smb2.security_blob_offset", FT_UINT16, BASE_HEX,
5589 NULL, 0, "Offset into the SMB2 PDU of the blob", HFILL }},
5591 { &hf_smb2_response_buffer_offset,
5592 { "Response Buffer Offset", "smb2.response_buffer_offset", FT_UINT16, BASE_HEX,
5593 NULL, 0, "Offset of the response buffer", HFILL }},
5595 { &hf_smb2_data_offset,
5596 { "Data Offset", "smb2.data_offset", FT_UINT16, BASE_HEX,
5597 NULL, 0, "Offset to data", HFILL }},
5599 { &hf_smb2_find_info_level,
5600 { "Info Level", "smb2.find.infolevel", FT_UINT32, BASE_DEC,
5601 VALS(smb2_find_info_levels), 0, "Find_Info Infolevel", HFILL }},
5602 { &hf_smb2_find_flags,
5603 { "Find Flags", "smb2.find.flags", FT_UINT8, BASE_HEX,
5604 NULL, 0, "", HFILL }},
5606 { &hf_smb2_find_pattern,
5607 { "Search Pattern", "smb2.find.pattern", FT_STRING, BASE_NONE,
5608 NULL, 0, "Find pattern", HFILL }},
5610 { &hf_smb2_find_info_blob,
5611 { "Info", "smb2.security_blob", FT_BYTES, BASE_HEX,
5612 NULL, 0, "Find Info", HFILL }},
5615 { "EA Size", "smb2.ea_size", FT_UINT32, BASE_DEC,
5616 NULL, 0, "Size of EA data", HFILL }},
5619 { "Class", "smb2.class", FT_UINT8, BASE_HEX,
5620 VALS(smb2_class_vals), 0, "Info class", HFILL }},
5622 { &hf_smb2_infolevel,
5623 { "InfoLevel", "smb2.infolevel", FT_UINT8, BASE_HEX,
5624 NULL, 0, "Infolevel", HFILL }},
5626 { &hf_smb2_infolevel_file_info,
5627 { "InfoLevel", "smb2.file_info.infolevel", FT_UINT8, BASE_HEX,
5628 VALS(smb2_file_info_levels), 0, "File_Info Infolevel", HFILL }},
5630 { &hf_smb2_infolevel_fs_info,
5631 { "InfoLevel", "smb2.fs_info.infolevel", FT_UINT8, BASE_HEX,
5632 VALS(smb2_fs_info_levels), 0, "Fs_Info Infolevel", HFILL }},
5634 { &hf_smb2_infolevel_sec_info,
5635 { "InfoLevel", "smb2.sec_info.infolevel", FT_UINT8, BASE_HEX,
5636 VALS(smb2_sec_info_levels), 0, "Sec_Info Infolevel", HFILL }},
5638 { &hf_smb2_write_length,
5639 { "Write Length", "smb2.write_length", FT_UINT32, BASE_DEC,
5640 NULL, 0, "Amount of data to write", HFILL }},
5642 { &hf_smb2_read_length,
5643 { "Read Length", "smb2.read_length", FT_UINT32, BASE_DEC,
5644 NULL, 0, "Amount of data to read", HFILL }},
5646 { &hf_smb2_read_remaining,
5647 { "Read Remaining", "smb2.read_remaining", FT_UINT32, BASE_DEC,
5648 NULL, 0, "", HFILL }},
5650 { &hf_smb2_create_flags,
5651 { "Create Flags", "smb2.create_flags", FT_UINT64, BASE_HEX,
5652 NULL, 0, "", HFILL }},
5654 { &hf_smb2_file_offset,
5655 { "File Offset", "smb2.file_offset", FT_UINT64, BASE_DEC,
5656 NULL, 0, "", HFILL }},
5658 { &hf_smb2_security_blob,
5659 { "Security Blob", "smb2.security_blob", FT_BYTES, BASE_HEX,
5660 NULL, 0, "Security blob", HFILL }},
5662 { &hf_smb2_ioctl_out_data,
5663 { "Out Data", "smb2.ioctl.out", FT_NONE, BASE_NONE,
5664 NULL, 0, "Ioctl Out", HFILL }},
5666 { &hf_smb2_ioctl_in_data,
5667 { "In Data", "smb2.ioctl.in", FT_NONE, BASE_NONE,
5668 NULL, 0, "Ioctl In", HFILL }},
5670 { &hf_smb2_server_guid,
5671 { "Server Guid", "smb2.server_guid", FT_GUID, BASE_NONE,
5672 NULL, 0, "Server GUID", HFILL }},
5674 { &hf_smb2_client_guid,
5675 { "Client Guid", "smb2.client_guid", FT_GUID, BASE_NONE,
5676 NULL, 0, "Client GUID", HFILL }},
5678 { &hf_smb2_object_id,
5679 { "ObjectId", "smb2.object_id", FT_GUID, BASE_NONE,
5680 NULL, 0, "ObjectID for this FID", HFILL }},
5682 { &hf_smb2_birth_volume_id,
5683 { "BirthVolumeId", "smb2.birth_volume_id", FT_GUID, BASE_NONE,
5684 NULL, 0, "ObjectID for the volume where this FID was originally created", HFILL }},
5686 { &hf_smb2_birth_object_id,
5687 { "BirthObjectId", "smb2.birth_object_id", FT_GUID, BASE_NONE,
5688 NULL, 0, "ObjectID for this FID when it was originally created", HFILL }},
5690 { &hf_smb2_domain_id,
5691 { "DomainId", "smb2.domain_id", FT_GUID, BASE_NONE,
5692 NULL, 0, "", HFILL }},
5694 { &hf_smb2_create_timestamp,
5695 { "Create", "smb2.create.time", FT_ABSOLUTE_TIME, BASE_NONE,
5696 NULL, 0, "Time when this object was created", HFILL }},
5699 { "File Id", "smb2.fid", FT_GUID, BASE_NONE,
5700 NULL, 0, "SMB2 File Id", HFILL }},
5702 { &hf_smb2_write_data,
5703 { "Write Data", "smb2.write_data", FT_BYTES, BASE_HEX,
5704 NULL, 0, "SMB2 Data to be written", HFILL }},
5706 { &hf_smb2_read_data,
5707 { "Read Data", "smb2.read_data", FT_BYTES, BASE_HEX,
5708 NULL, 0, "SMB2 Data that is read", HFILL }},
5710 { &hf_smb2_last_access_timestamp,
5711 { "Last Access", "smb2.last_access.time", FT_ABSOLUTE_TIME, BASE_NONE,
5712 NULL, 0, "Time when this object was last accessed", HFILL }},
5714 { &hf_smb2_last_write_timestamp,
5715 { "Last Write", "smb2.last_write.time", FT_ABSOLUTE_TIME, BASE_NONE,
5716 NULL, 0, "Time when this object was last written to", HFILL }},
5718 { &hf_smb2_last_change_timestamp,
5719 { "Last Change", "smb2.last_change.time", FT_ABSOLUTE_TIME, BASE_NONE,
5720 NULL, 0, "Time when this object was last changed", HFILL }},
5722 { &hf_smb2_file_all_info,
5723 { "SMB2_FILE_ALL_INFO", "smb2.smb2_file_all_info", FT_NONE, BASE_NONE,
5724 NULL, 0, "SMB2_FILE_ALL_INFO structure", HFILL }},
5726 { &hf_smb2_file_allocation_info,
5727 { "SMB2_FILE_ALLOCATION_INFO", "smb2.smb2_file_allocation_info", FT_NONE, BASE_NONE,
5728 NULL, 0, "SMB2_FILE_ALLOCATION_INFO structure", HFILL }},
5730 { &hf_smb2_file_endoffile_info,
5731 { "SMB2_FILE_ENDOFFILE_INFO", "smb2.smb2_file_endoffile_info", FT_NONE, BASE_NONE,
5732 NULL, 0, "SMB2_FILE_ENDOFFILE_INFO structure", HFILL }},
5734 { &hf_smb2_file_alternate_name_info,
5735 { "SMB2_FILE_ALTERNATE_NAME_INFO", "smb2.smb2_file_alternate_name_info", FT_NONE, BASE_NONE,
5736 NULL, 0, "SMB2_FILE_ALTERNATE_NAME_INFO structure", HFILL }},
5738 { &hf_smb2_file_stream_info,
5739 { "SMB2_FILE_STREAM_INFO", "smb2.smb2_file_stream_info", FT_NONE, BASE_NONE,
5740 NULL, 0, "SMB2_FILE_STREAM_INFO structure", HFILL }},
5742 { &hf_smb2_file_pipe_info,
5743 { "SMB2_FILE_PIPE_INFO", "smb2.smb2_file_pipe_info", FT_NONE, BASE_NONE,
5744 NULL, 0, "SMB2_FILE_PIPE_INFO structure", HFILL }},
5746 { &hf_smb2_file_compression_info,
5747 { "SMB2_FILE_COMPRESSION_INFO", "smb2.smb2_file_compression_info", FT_NONE, BASE_NONE,
5748 NULL, 0, "SMB2_FILE_COMPRESSION_INFO structure", HFILL }},
5750 { &hf_smb2_file_basic_info,
5751 { "SMB2_FILE_BASIC_INFO", "smb2.smb2_file_basic_info", FT_NONE, BASE_NONE,
5752 NULL, 0, "SMB2_FILE_BASIC_INFO structure", HFILL }},
5754 { &hf_smb2_file_standard_info,
5755 { "SMB2_FILE_STANDARD_INFO", "smb2.smb2_file_standard_info", FT_NONE, BASE_NONE,
5756 NULL, 0, "SMB2_FILE_STANDARD_INFO structure", HFILL }},
5758 { &hf_smb2_file_internal_info,
5759 { "SMB2_FILE_INTERNAL_INFO", "smb2.smb2_file_internal_info", FT_NONE, BASE_NONE,
5760 NULL, 0, "SMB2_FILE_INTERNAL_INFO structure", HFILL }},
5762 { &hf_smb2_file_mode_info,
5763 { "SMB2_FILE_MODE_INFO", "smb2.smb2_file_mode_info", FT_NONE, BASE_NONE,
5764 NULL, 0, "SMB2_FILE_MODE_INFO structure", HFILL }},
5766 { &hf_smb2_file_alignment_info,
5767 { "SMB2_FILE_ALIGNMENT_INFO", "smb2.smb2_file_alignment_info", FT_NONE, BASE_NONE,
5768 NULL, 0, "SMB2_FILE_ALIGNMENT_INFO structure", HFILL }},
5770 { &hf_smb2_file_position_info,
5771 { "SMB2_FILE_POSITION_INFO", "smb2.smb2_file_position_info", FT_NONE, BASE_NONE,
5772 NULL, 0, "SMB2_FILE_POSITION_INFO structure", HFILL }},
5774 { &hf_smb2_file_access_info,
5775 { "SMB2_FILE_ACCESS_INFO", "smb2.smb2_file_access_info", FT_NONE, BASE_NONE,
5776 NULL, 0, "SMB2_FILE_ACCESS_INFO structure", HFILL }},
5778 { &hf_smb2_file_ea_info,
5779 { "SMB2_FILE_EA_INFO", "smb2.smb2_file_ea_info", FT_NONE, BASE_NONE,
5780 NULL, 0, "SMB2_FILE_EA_INFO structure", HFILL }},
5782 { &hf_smb2_file_network_open_info,
5783 { "SMB2_FILE_NETWORK_OPEN_INFO", "smb2.smb2_file_network_open_info", FT_NONE, BASE_NONE,
5784 NULL, 0, "SMB2_FILE_NETWORK_OPEN_INFO structure", HFILL }},
5786 { &hf_smb2_file_attribute_tag_info,
5787 { "SMB2_FILE_ATTRIBUTE_TAG_INFO", "smb2.smb2_file_attribute_tag_info", FT_NONE, BASE_NONE,
5788 NULL, 0, "SMB2_FILE_ATTRIBUTE_TAG_INFO structure", HFILL }},
5790 { &hf_smb2_file_disposition_info,
5791 { "SMB2_FILE_DISPOSITION_INFO", "smb2.smb2_file_disposition_info", FT_NONE, BASE_NONE,
5792 NULL, 0, "SMB2_FILE_DISPOSITION_INFO structure", HFILL }},
5794 { &hf_smb2_file_info_0f,
5795 { "SMB2_FILE_INFO_0f", "smb2.smb2_file_info_0f", FT_NONE, BASE_NONE,
5796 NULL, 0, "SMB2_FILE_INFO_0f structure", HFILL }},
5798 { &hf_smb2_file_rename_info,
5799 { "SMB2_FILE_RENAME_INFO", "smb2.smb2_file_rename_info", FT_NONE, BASE_NONE,
5800 NULL, 0, "SMB2_FILE_RENAME_INFO structure", HFILL }},
5802 { &hf_smb2_fs_info_01,
5803 { "SMB2_FS_INFO_01", "smb2.smb2_fs_info_01", FT_NONE, BASE_NONE,
5804 NULL, 0, "SMB2_FS_INFO_01 structure", HFILL }},
5806 { &hf_smb2_fs_info_03,
5807 { "SMB2_FS_INFO_03", "smb2.smb2_fs_info_03", FT_NONE, BASE_NONE,
5808 NULL, 0, "SMB2_FS_INFO_03 structure", HFILL }},
5810 { &hf_smb2_fs_info_04,
5811 { "SMB2_FS_INFO_04", "smb2.smb2_fs_info_04", FT_NONE, BASE_NONE,
5812 NULL, 0, "SMB2_FS_INFO_04 structure", HFILL }},
5814 { &hf_smb2_fs_info_05,
5815 { "SMB2_FS_INFO_05", "smb2.smb2_fs_info_05", FT_NONE, BASE_NONE,
5816 NULL, 0, "SMB2_FS_INFO_05 structure", HFILL }},
5818 { &hf_smb2_fs_info_06,
5819 { "SMB2_FS_INFO_06", "smb2.smb2_fs_info_06", FT_NONE, BASE_NONE,
5820 NULL, 0, "SMB2_FS_INFO_06 structure", HFILL }},
5822 { &hf_smb2_fs_info_07,
5823 { "SMB2_FS_INFO_07", "smb2.smb2_fs_info_07", FT_NONE, BASE_NONE,
5824 NULL, 0, "SMB2_FS_INFO_07 structure", HFILL }},
5826 { &hf_smb2_fs_objectid_info,
5827 { "SMB2_FS_OBJECTID_INFO", "smb2.smb2_fs_objectid_info", FT_NONE, BASE_NONE,
5828 NULL, 0, "SMB2_FS_OBJECTID_INFO structure", HFILL }},
5830 { &hf_smb2_sec_info_00,
5831 { "SMB2_SEC_INFO_00", "smb2.smb2_sec_info_00", FT_NONE, BASE_NONE,
5832 NULL, 0, "SMB2_SEC_INFO_00 structure", HFILL }},
5834 { &hf_smb2_disposition_delete_on_close,
5835 { "Delete on close", "smb2.disposition.delete_on_close", FT_BOOLEAN, 8,
5836 TFS(&tfs_disposition_delete_on_close), 0x01, "", HFILL }},
5839 { &hf_smb2_create_disposition,
5840 { "Disposition", "smb2.create.disposition", FT_UINT32, BASE_DEC,
5841 VALS(create_disposition_vals), 0, "Create disposition, what to do if the file does/does not exist", HFILL }},
5843 { &hf_smb2_create_action,
5844 { "Create Action", "smb2.create.action", FT_UINT32, BASE_DEC,
5845 VALS(oa_open_vals), 0, "Create Action", HFILL }},
5847 { &hf_smb2_extrainfo,
5848 { "ExtraInfo", "smb2.create.extrainfo", FT_NONE, BASE_NONE,
5849 NULL, 0, "Create ExtraInfo", HFILL }},
5851 { &hf_smb2_create_chain_offset,
5852 { "Chain Offset", "smb2.create.chain_offset", FT_UINT32, BASE_HEX,
5853 NULL, 0, "Offset to next entry in chain or 0", HFILL }},
5855 { &hf_smb2_create_chain_data,
5856 { "Data", "smb2.create.chain_data", FT_NONE, BASE_NONE,
5857 NULL, 0, "Chain Data", HFILL }},
5859 { &hf_smb2_FILE_OBJECTID_BUFFER,
5860 { "FILE_OBJECTID_BUFFER", "smb2.FILE_OBJECTID_BUFFER", FT_NONE, BASE_NONE,
5861 NULL, 0, "A FILE_OBJECTID_BUFFER structure", HFILL }},
5863 { &hf_smb2_data_length,
5864 { "Data Length", "smb2.create.data_length", FT_UINT32, BASE_DEC,
5865 NULL, 0, "Length Data or 0", HFILL }},
5867 { &hf_smb2_next_offset,
5868 { "Next Offset", "smb2.next_offset", FT_UINT32, BASE_DEC,
5869 NULL, 0, "Offset to next buffer or 0", HFILL }},
5871 { &hf_smb2_current_time,
5872 { "Current Time", "smb2.current_time", FT_ABSOLUTE_TIME, BASE_NONE,
5873 NULL, 0, "Current Time at server", HFILL }},
5875 { &hf_smb2_boot_time,
5876 { "Boot Time", "smb2.boot_time", FT_ABSOLUTE_TIME, BASE_NONE,
5877 NULL, 0, "Boot Time at server", HFILL }},
5879 { &hf_smb2_ea_flags,
5880 { "EA Flags", "smb2.ea.flags", FT_UINT8, BASE_HEX,
5881 NULL, 0, "EA Flags", HFILL }},
5883 { &hf_smb2_ea_name_len,
5884 { "EA Name Length", "smb2.ea.name_len", FT_UINT8, BASE_DEC,
5885 NULL, 0, "EA Name Length", HFILL }},
5887 { &hf_smb2_ea_data_len,
5888 { "EA Data Length", "smb2.ea.data_len", FT_UINT8, BASE_DEC,
5889 NULL, 0, "EA Data Length", HFILL }},
5891 { &hf_smb2_delete_pending,
5892 { "Delete Pending", "smb2.delete_pending", FT_UINT8, BASE_DEC,
5893 NULL, 0, "Delete Pending", HFILL }},
5895 { &hf_smb2_is_directory,
5896 { "Is Directory", "smb2.is_directory", FT_UINT8, BASE_DEC,
5897 NULL, 0, "Is this a directory?", HFILL }},
5900 { "Oplock", "smb2.create.oplock", FT_UINT8, BASE_HEX,
5901 VALS(oplock_vals), 0, "Oplock type", HFILL }},
5903 { &hf_smb2_close_flags,
5904 { "Close Flags", "smb2.close.flags", FT_UINT16, BASE_HEX,
5905 NULL, 0, "close flags", HFILL }},
5907 { &hf_smb2_notify_flags,
5908 { "Notify Flags", "smb2.notify.flags", FT_UINT16, BASE_HEX,
5909 NULL, 0, "", HFILL }},
5911 { &hf_smb2_buffer_code_len,
5912 { "Length", "smb2.buffer_code.length", FT_UINT16, BASE_DEC,
5913 NULL, 0, "Length of fixed portion of PDU", HFILL }},
5915 { &hf_smb2_olb_length,
5916 { "Length", "smb2.olb.length", FT_UINT32, BASE_DEC,
5917 NULL, 0, "Length of the buffer", HFILL }},
5919 { &hf_smb2_olb_offset,
5920 { "Offset", "smb2.olb.offset", FT_UINT32, BASE_HEX,
5921 NULL, 0, "Offset to the buffer", HFILL }},
5923 { &hf_smb2_buffer_code_flags_dyn,
5924 { "Dynamic Part", "smb2.buffer_code.dynamic", FT_BOOLEAN, 16,
5925 NULL, 0x0001, "Whether a dynamic length blob follows", HFILL }},
5928 { "EA Data", "smb2.ea.data", FT_STRING, BASE_NONE,
5929 NULL, 0, "EA Data", HFILL }},
5932 { "EA Name", "smb2.ea.name", FT_STRING, BASE_NONE,
5933 NULL, 0, "EA Name", HFILL }},
5935 { &hf_smb2_impersonation_level,
5936 { "Impersonation", "smb2.impersonation.level", FT_UINT32, BASE_DEC,
5937 VALS(impersonation_level_vals), 0, "Impersonation level", HFILL }},
5939 { &hf_smb2_ioctl_function,
5940 { "Function", "smb2.ioctl.function", FT_UINT32, BASE_HEX,
5941 VALS(smb2_ioctl_vals), 0, "Ioctl function", HFILL }},
5943 { &hf_smb2_ioctl_function_device,
5944 { "Device", "smb2.ioctl.function.device", FT_UINT32, BASE_HEX,
5945 VALS(smb2_ioctl_device_vals), 0xffff0000, "Device for Ioctl", HFILL }},
5947 { &hf_smb2_ioctl_function_access,
5948 { "Access", "smb2.ioctl.function.access", FT_UINT32, BASE_HEX,
5949 VALS(smb2_ioctl_access_vals), 0x0000c000, "Access for Ioctl", HFILL }},
5951 { &hf_smb2_ioctl_function_function,
5952 { "Function", "smb2.ioctl.function.function", FT_UINT32, BASE_HEX,
5953 NULL, 0x00003ffc, "Function for Ioctl", HFILL }},
5955 { &hf_smb2_ioctl_function_method,
5956 { "Method", "smb2.ioctl.function.method", FT_UINT32, BASE_HEX,
5957 VALS(smb2_ioctl_method_vals), 0x00000003, "Method for Ioctl", HFILL }},
5959 { &hf_smb2_ioctl_shadow_copy_num_volumes,
5960 { "Num Volumes", "smb2.ioctl.shadow_copy.num_volumes", FT_UINT32, BASE_DEC,
5961 NULL, 0, "Number of shadow copy volumes", HFILL }},
5963 { &hf_smb2_ioctl_shadow_copy_num_labels,
5964 { "Num Labels", "smb2.ioctl.shadow_copy.num_labels", FT_UINT32, BASE_DEC,
5965 NULL, 0, "Number of shadow copy labels", HFILL }},
5967 { &hf_smb2_ioctl_shadow_copy_label,
5968 { "Label", "smb2.ioctl.shadow_copy.label", FT_STRING, BASE_NONE,
5969 NULL, 0, "Shadow copy label", HFILL }},
5971 { &hf_smb2_compression_format,
5972 { "Compression Format", "smb2.compression_format", FT_UINT16, BASE_DEC,
5973 VALS(compression_format_vals), 0, "Compression to use", HFILL }},
5975 { &hf_smb2_share_type,
5976 { "Share Type", "smb2.share_type", FT_UINT16, BASE_DEC,
5977 VALS(smb2_share_type_vals), 0, "Type of share", HFILL }},
5980 { "Epoch", "smb2.epoch", FT_UINT16, BASE_DEC,
5981 NULL, 0, "", HFILL }},
5983 { &hf_smb2_credits_requested,
5984 { "Credits requested", "smb2.credits.requested", FT_UINT16, BASE_DEC,
5985 NULL, 0, "", HFILL }},
5987 { &hf_smb2_credits_granted,
5988 { "Credits granted", "smb2.credits.granted", FT_UINT16, BASE_DEC,
5989 NULL, 0, "", HFILL }},
5991 { &hf_smb2_dialect_count,
5992 { "Dialect count", "smb2.dialect_count", FT_UINT16, BASE_DEC,
5993 NULL, 0, "", HFILL }},
5996 { "Dialect", "smb2.dialect", FT_UINT16, BASE_HEX,
5997 NULL, 0, "", HFILL }},
5999 { &hf_smb2_security_mode,
6000 { "Security mode", "smb2.sec_mode", FT_UINT8, BASE_HEX,
6001 NULL, 0, "", HFILL }},
6003 { &hf_smb2_session_flags,
6004 { "Session Flags", "smb2.session_flags", FT_UINT16, BASE_HEX,
6005 NULL, 0, "", HFILL }},
6007 { &hf_smb2_lock_count,
6008 { "Lock Count", "smb2.lock_count", FT_UINT16, BASE_DEC,
6009 NULL, 0, "", HFILL }},
6011 { &hf_smb2_capabilities,
6012 { "Capabilities", "smb2.capabilities", FT_UINT32, BASE_HEX,
6013 NULL, 0, "", HFILL }},
6015 { &hf_smb2_ioctl_shadow_copy_count,
6016 { "Count", "smb2.ioctl.shadow_copy.count", FT_UINT32, BASE_DEC,
6017 NULL, 0, "Number of bytes for shadow copy label strings", HFILL }},
6019 { &hf_smb2_auth_frame,
6020 { "Authenticated in Frame", "smb2.auth_frame", FT_UINT32, BASE_DEC,
6021 NULL, 0, "Which frame this user was authenticated in", HFILL }},
6023 { &hf_smb2_tcon_frame,
6024 { "Connected in Frame", "smb2.tcon_frame", FT_UINT32, BASE_DEC,
6025 NULL, 0, "Which frame this share was connected in", HFILL }},
6028 { "Tag", "smb2.tag", FT_STRING, BASE_NONE,
6029 NULL, 0, "Tag of chain entry", HFILL }},
6031 { &hf_smb2_acct_name,
6032 { "Account", "smb2.acct", FT_STRING, BASE_NONE,
6033 NULL, 0, "Account Name", HFILL }},
6035 { &hf_smb2_domain_name,
6036 { "Domain", "smb2.domain", FT_STRING, BASE_NONE,
6037 NULL, 0, "Domain Name", HFILL }},
6039 { &hf_smb2_host_name,
6040 { "Host", "smb2.host", FT_STRING, BASE_NONE,
6041 NULL, 0, "Host Name", HFILL }},
6043 { &hf_smb2_signature,
6044 { "Signature", "smb2.signature", FT_BYTES, BASE_HEX,
6045 NULL, 0, "Signature", HFILL }},
6048 { "unknown", "smb2.unknown", FT_BYTES, BASE_HEX,
6049 NULL, 0, "Unknown bytes", HFILL }},
6051 { &hf_smb2_unknown_timestamp,
6052 { "Timestamp", "smb2.unknown.timestamp", FT_ABSOLUTE_TIME, BASE_NONE,
6053 NULL, 0, "Unknown timestamp", HFILL }},
6055 { &hf_smb2_ses_flags_guest,
6056 { "Guest", "smb2.ses_flags.guest", FT_BOOLEAN, 16,
6057 NULL, SES_FLAGS_GUEST, "", HFILL }},
6059 { &hf_smb2_ses_flags_null,
6060 { "Null", "smb2.ses_flags.null", FT_BOOLEAN, 16,
6061 NULL, SES_FLAGS_NULL, "", HFILL }},
6063 { &hf_smb2_secmode_flags_sign_required,
6064 { "Signing required", "smb2.sec_mode.sign_required", FT_BOOLEAN, 8,
6065 NULL, NEGPROT_SIGN_REQ, "Is signing required", HFILL }},
6067 { &hf_smb2_secmode_flags_sign_enabled,
6068 { "Signing enabled", "smb2.sec_mode.sign_enabled", FT_BOOLEAN, 8,
6069 NULL, NEGPROT_SIGN_ENABLED, "Is signing enabled", HFILL }},
6072 { "DFS", "smb2.capabilities.dfs", FT_BOOLEAN, 32,
6073 TFS(&tfs_cap_dfs), NEGPROT_CAP_DFS, "If the host supports dfs", HFILL }},
6075 { &hf_smb2_max_trans_size,
6076 { "Max Transaction Size", "smb2.max_trans_size", FT_UINT32, BASE_DEC,
6077 NULL, 0, "Maximum size of a transaction", HFILL }},
6079 { &hf_smb2_max_read_size,
6080 { "Max Read Size", "smb2.max_read_size", FT_UINT32, BASE_DEC,
6081 NULL, 0, "Maximum size of a read", HFILL }},
6083 { &hf_smb2_max_write_size,
6084 { "Max Write Size", "smb2.max_write_size", FT_UINT32, BASE_DEC,
6085 NULL, 0, "Maximum size of a write", HFILL }},
6088 { "VC Num", "smb2.num_vc", FT_UINT8, BASE_DEC,
6089 NULL, 0, "Number of VCs", HFILL }},
6092 { "Channel", "smb2.channel", FT_UINT32, BASE_DEC,
6093 NULL, 0, "Channel", HFILL }},
6095 { &hf_smb2_share_flags,
6096 { "Share flags", "smb2.share_flags", FT_UINT32, BASE_HEX,
6097 NULL, 0, "share flags", HFILL }},
6099 { &hf_smb2_share_flags_dfs,
6100 { "dfs", "smb2.share_flags.dfs", FT_BOOLEAN, 32,
6101 NULL, SHARE_FLAGS_dfs, "", HFILL }},
6103 { &hf_smb2_share_flags_dfs_root,
6104 { "dfs_root", "smb2.share_flags.dfs_root", FT_BOOLEAN, 32,
6105 NULL, SHARE_FLAGS_dfs_root, "", HFILL }},
6107 { &hf_smb2_share_flags_restrict_exclusive_opens,
6108 { "restrict_exclusive_opens", "smb2.share_flags.restrict_exclusive_opens", FT_BOOLEAN, 32,
6109 NULL, SHARE_FLAGS_restrict_exclusive_opens, "", HFILL }},
6111 { &hf_smb2_share_flags_force_shared_delete,
6112 { "force_shared_delete", "smb2.share_flags.force_shared_delete", FT_BOOLEAN, 32,
6113 NULL, SHARE_FLAGS_force_shared_delete, "", HFILL }},
6115 { &hf_smb2_share_flags_allow_namespace_caching,
6116 { "allow_namespace_caching", "smb2.share_flags.allow_namespace_caching", FT_BOOLEAN, 32,
6117 NULL, SHARE_FLAGS_allow_namespace_caching, "", HFILL }},
6119 { &hf_smb2_share_flags_access_based_dir_enum,
6120 { "access_based_dir_enum", "smb2.share_flags.access_based_dir_enum", FT_BOOLEAN, 32,
6121 NULL, SHARE_FLAGS_access_based_dir_enum, "", HFILL }},
6123 { &hf_smb2_share_caching,
6124 { "Caching policy", "smb2.share.caching", FT_UINT32, BASE_HEX,
6125 VALS(share_cache_vals), 0, "", HFILL }},
6127 { &hf_smb2_share_caps,
6128 { "Share Capabilities", "smb2.share_caps", FT_UINT32, BASE_HEX,
6129 NULL, 0, "", HFILL }},
6131 { &hf_smb2_ioctl_flags,
6132 { "Flags", "smb2.ioctl.flags", FT_UINT32, BASE_HEX,
6133 NULL, 0, "", HFILL }},
6135 { &hf_smb2_min_count,
6136 { "Min Count", "smb2.min_count", FT_UINT32, BASE_DEC,
6137 NULL, 0, "", HFILL }},
6139 { &hf_smb2_remaining_bytes,
6140 { "Remaining Bytes", "smb2.remaining_bytes", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
6142 { &hf_smb2_channel_info_offset,
6143 { "Channel Info Offset", "smb2.channel_info_offset", FT_UINT16, BASE_DEC,
6144 NULL, 0, "", HFILL }},
6146 { &hf_smb2_channel_info_length,
6147 { "Channel Info Length", "smb2.channel_info_length", FT_UINT16, BASE_DEC,
6148 NULL, 0, "", HFILL }},
6150 { &hf_smb2_share_caps_dfs,
6151 { "dfs", "smb2.share_caps.dfs", FT_BOOLEAN, 32,
6152 NULL, SHARE_CAPS_DFS, "", HFILL }},
6154 { &hf_smb2_ioctl_is_fsctl,
6155 { "Is FSCTL", "smb2.ioctl.is_fsctl", FT_BOOLEAN, 32,
6156 NULL, 0x00000001, "", HFILL }},
6158 { &hf_smb2_output_buffer_len,
6159 { "Output Buffer Length", "smb2.output_buffer_len", FT_UINT16, BASE_DEC,
6160 NULL, 0, "", HFILL }},
6162 { &hf_smb2_close_pq_attrib,
6163 { "PostQuery Attrib", "smb2.close.pq_attrib", FT_BOOLEAN, 16,
6164 NULL, 0x0001, "", HFILL }},
6166 { &hf_smb2_notify_watch_tree,
6167 { "Watch Tree", "smb2.notify.watch_tree", FT_BOOLEAN, 16,
6168 NULL, 0x0001, "", HFILL }},
6170 { &hf_smb2_notify_out_data,
6171 { "Out Data", "smb2.notify.out", FT_NONE, BASE_NONE,
6172 NULL, 0, "", HFILL }},
6174 { &hf_smb2_find_flags_restart_scans,
6175 { "Restart Scans", "smb2.find.restart_scans", FT_BOOLEAN, 8,
6176 NULL, SMB2_FIND_FLAG_RESTART_SCANS, "", HFILL }},
6178 { &hf_smb2_find_flags_single_entry,
6179 { "Single Entry", "smb2.find.single_entry", FT_BOOLEAN, 8,
6180 NULL, SMB2_FIND_FLAG_SINGLE_ENTRY, "", HFILL }},
6182 { &hf_smb2_find_flags_index_specified,
6183 { "Index Specified", "smb2.find.index_specified", FT_BOOLEAN, 8,
6184 NULL, SMB2_FIND_FLAG_INDEX_SPECIFIED, "", HFILL }},
6186 { &hf_smb2_find_flags_reopen,
6187 { "Reopen", "smb2.find.reopen", FT_BOOLEAN, 8,
6188 NULL, SMB2_FIND_FLAG_REOPEN, "", HFILL }},
6190 { &hf_smb2_file_index,
6191 { "File Index", "smb2.file_index", FT_UINT32, BASE_HEX,
6192 NULL, 0, "", HFILL }},
6194 { &hf_smb2_file_directory_info,
6195 { "FileDirectoryInfo", "smb2.find.file_directory_info", FT_NONE, BASE_NONE,
6196 NULL, 0, "", HFILL }},
6198 { &hf_smb2_full_directory_info,
6199 { "FullDirectoryInfo", "smb2.find.full_directory_info", FT_NONE, BASE_NONE,
6200 NULL, 0, "", HFILL }},
6202 { &hf_smb2_both_directory_info,
6203 { "FileBothDirectoryInfo", "smb2.find.both_directory_info", FT_NONE, BASE_NONE,
6204 NULL, 0, "", HFILL }},
6206 { &hf_smb2_id_both_directory_info,
6207 { "FileIdBothDirectoryInfo", "smb2.find.id_both_directory_info", FT_NONE, BASE_NONE,
6208 NULL, 0, "", HFILL }},
6210 { &hf_smb2_short_name_len,
6211 { "Short Name Length", "smb2.short_name_len", FT_UINT8, BASE_DEC,
6212 NULL, 0, "", HFILL }},
6214 { &hf_smb2_short_name,
6215 { "Short Name", "smb2.shortname", FT_STRING, BASE_NONE,
6216 NULL, 0, "", HFILL }},
6217 { &hf_smb2_file_name_info,
6218 { "FileNameInfo", "smb2.find.name_info", FT_NONE, BASE_NONE,
6219 NULL, 0, "", HFILL }},
6221 { &hf_smb2_lock_info,
6222 { "Lock Info", "smb2.lock_info", FT_NONE, BASE_NONE,
6223 NULL, 0, "", HFILL }},
6225 { &hf_smb2_lock_length,
6226 { "Length", "smb2.lock_length", FT_UINT64, BASE_DEC,
6227 NULL, 0, "", HFILL }},
6229 { &hf_smb2_lock_flags,
6230 { "Flags", "smb2.lock_flags", FT_UINT32, BASE_HEX,
6231 NULL, 0, "", HFILL }},
6233 { &hf_smb2_lock_flags_shared,
6234 { "Shared", "smb2.lock_flags.shared", FT_BOOLEAN, 32,
6235 NULL, 0x00000001, "", HFILL }},
6237 { &hf_smb2_lock_flags_exclusive,
6238 { "Exclusive", "smb2.lock_flags.exclusive", FT_BOOLEAN, 32,
6239 NULL, 0x00000002, "", HFILL }},
6241 { &hf_smb2_lock_flags_unlock,
6242 { "Unlock", "smb2.lock_flags.unlock", FT_BOOLEAN, 32,
6243 NULL, 0x00000004, "", HFILL }},
6245 { &hf_smb2_lock_flags_fail_immediately,
6246 { "Fail Immediately", "smb2.lock_flags.fail_immediately", FT_BOOLEAN, 32,
6247 NULL, 0x00000010, "", HFILL }},
6251 static gint *ett[] = {
6258 &ett_smb2_file_basic_info,
6259 &ett_smb2_file_standard_info,
6260 &ett_smb2_file_internal_info,
6261 &ett_smb2_file_ea_info,
6262 &ett_smb2_file_access_info,
6263 &ett_smb2_file_rename_info,
6264 &ett_smb2_file_disposition_info,
6265 &ett_smb2_file_position_info,
6266 &ett_smb2_file_info_0f,
6267 &ett_smb2_file_mode_info,
6268 &ett_smb2_file_alignment_info,
6269 &ett_smb2_file_all_info,
6270 &ett_smb2_file_allocation_info,
6271 &ett_smb2_file_endoffile_info,
6272 &ett_smb2_file_alternate_name_info,
6273 &ett_smb2_file_stream_info,
6274 &ett_smb2_file_pipe_info,
6275 &ett_smb2_file_compression_info,
6276 &ett_smb2_file_network_open_info,
6277 &ett_smb2_file_attribute_tag_info,
6278 &ett_smb2_fs_info_01,
6279 &ett_smb2_fs_info_03,
6280 &ett_smb2_fs_info_04,
6281 &ett_smb2_fs_info_05,
6282 &ett_smb2_fs_info_06,
6283 &ett_smb2_fs_info_07,
6284 &ett_smb2_fs_objectid_info,
6285 &ett_smb2_sec_info_00,
6287 &ett_smb2_sesid_tree,
6288 &ett_smb2_create_chain_element,
6289 &ett_smb2_MxAc_buffer,
6290 &ett_smb2_ioctl_function,
6291 &ett_smb2_FILE_OBJECTID_BUFFER,
6294 &ett_smb2_capabilities,
6295 &ett_smb2_ses_flags,
6296 &ett_smb2_share_flags,
6297 &ett_smb2_share_caps,
6298 &ett_smb2_ioctl_flags,
6299 &ett_smb2_close_flags,
6300 &ett_smb2_notify_flags,
6301 &ett_smb2_find_flags,
6302 &ett_smb2_file_directory_info,
6303 &ett_smb2_both_directory_info,
6304 &ett_smb2_id_both_directory_info,
6305 &ett_smb2_full_directory_info,
6306 &ett_smb2_file_name_info,
6307 &ett_smb2_lock_info,
6308 &ett_smb2_lock_flags,
6311 proto_smb2 = proto_register_protocol("SMB2 (Server Message Block Protocol version 2)",
6313 proto_register_subtree_array(ett, array_length(ett));
6314 proto_register_field_array(proto_smb2, hf, array_length(hf));
6316 register_heur_dissector_list("smb2_heur_subdissectors", &smb2_heur_subdissector_list);
6317 smb2_tap = register_tap("smb2");
6321 proto_reg_handoff_smb2(void)
6323 gssapi_handle = find_dissector("gssapi");
6324 ntlmssp_handle = find_dissector("ntlmssp");
6325 heur_dissector_add("netbios", dissect_smb2_heur, proto_smb2);