wsgcrypt.h checks internally if we HAVE_LIBGCRYPT
[metze/wireshark/wip.git] / epan / dissectors / packet-smb2.c
index b33e90880b532bfba550006a11697282d5be4cd1..610d560cadb9c17cb1f634111b9c3f0f52a97591 100644 (file)
@@ -4,8 +4,8 @@
  *
  * For documentation of this protocol, see:
  *
- * http://wiki.wireshark.org/SMB2
- * http://msdn.microsoft.com/en-us/library/cc246482(PROT.10).aspx
+ * https://wiki.wireshark.org/SMB2
+ * https://msdn.microsoft.com/en-us/library/cc246482.aspx
  *
  * If you edit this file, keep the wiki updated as well.
  *
@@ -35,6 +35,7 @@
 #include <epan/prefs.h>
 #include <epan/expert.h>
 #include <epan/tap.h>
+#include <epan/srt_table.h>
 #include <epan/aftypes.h>
 #include <epan/to_str.h>
 #include <epan/asn1.h>
 #include "packet-smb-common.h"
 #include "packet-dcerpc-nt.h"
 
-/* Use libgcrypt for cipher libraries. */
-#ifdef HAVE_LIBGCRYPT
 #include <wsutil/wsgcrypt.h>
-#endif /* HAVE_LIBGCRYPT */
+
+#define NT_STATUS_PENDING      0x00000103
 
 void proto_register_smb2(void);
 void proto_reg_handoff_smb2(void);
@@ -76,11 +76,13 @@ static int hf_smb2_flags_dfs_op = -1;
 static int hf_smb2_flags_chained = -1;
 static int hf_smb2_flags_signature = -1;
 static int hf_smb2_flags_replay_operation = -1;
+static int hf_smb2_flags_priority_mask = -1;
 static int hf_smb2_chain_offset = -1;
 static int hf_smb2_security_blob = -1;
 static int hf_smb2_ioctl_in_data = -1;
 static int hf_smb2_ioctl_out_data = -1;
 static int hf_smb2_unknown = -1;
+static int hf_smb2_root_directory_mbz = -1;
 static int hf_smb2_twrp_timestamp = -1;
 static int hf_smb2_mxac_timestamp = -1;
 static int hf_smb2_mxac_status = -1;
@@ -96,6 +98,7 @@ static int hf_smb2_current_time = -1;
 static int hf_smb2_boot_time = -1;
 static int hf_smb2_filename = -1;
 static int hf_smb2_filename_len = -1;
+static int hf_smb2_replace_if = -1;
 static int hf_smb2_nlinks = -1;
 static int hf_smb2_delete_pending = -1;
 static int hf_smb2_is_directory = -1;
@@ -117,6 +120,7 @@ static int hf_smb2_infolevel = -1;
 static int hf_smb2_infolevel_file_info = -1;
 static int hf_smb2_infolevel_fs_info = -1;
 static int hf_smb2_infolevel_sec_info = -1;
+static int hf_smb2_infolevel_posix_info = -1;
 static int hf_smb2_max_response_size = -1;
 static int hf_smb2_max_ioctl_in_size = -1;
 static int hf_smb2_max_ioctl_out_size = -1;
@@ -162,6 +166,11 @@ static int hf_smb2_write_remaining = -1;
 static int hf_smb2_read_length = -1;
 static int hf_smb2_read_remaining = -1;
 static int hf_smb2_file_offset = -1;
+static int hf_smb2_qfr_length = -1;
+static int hf_smb2_qfr_usage = -1;
+static int hf_smb2_qfr_flags = -1;
+static int hf_smb2_qfr_total_region_entry_count = -1;
+static int hf_smb2_qfr_region_entry_count = -1;
 static int hf_smb2_read_data = -1;
 static int hf_smb2_disposition_delete_on_close = -1;
 static int hf_smb2_create_disposition = -1;
@@ -173,6 +182,10 @@ static int hf_smb2_create_action = -1;
 static int hf_smb2_create_rep_flags = -1;
 static int hf_smb2_create_rep_flags_reparse_point = -1;
 static int hf_smb2_next_offset = -1;
+static int hf_smb2_negotiate_context_type = -1;
+static int hf_smb2_negotiate_context_data_length = -1;
+static int hf_smb2_negotiate_context_offset = -1;
+static int hf_smb2_negotiate_context_count = -1;
 static int hf_smb2_ea_size = -1;
 static int hf_smb2_ea_flags = -1;
 static int hf_smb2_ea_name_len = -1;
@@ -190,6 +203,16 @@ static int hf_smb2_ioctl_function = -1;
 static int hf_smb2_ioctl_function_device = -1;
 static int hf_smb2_ioctl_function_access = -1;
 static int hf_smb2_ioctl_function_function = -1;
+static int hf_smb2_fsctl_pipe_wait_timeout = -1;
+static int hf_smb2_fsctl_pipe_wait_name = -1;
+static int hf_smb2_fsctl_offload_read_size = -1;
+static int hf_smb2_fsctl_offload_read_flags = -1;
+static int hf_smb2_fsctl_offload_read_token_ttl = -1;
+static int hf_smb2_fsctl_offload_reserved = -1;
+static int hf_smb2_fsctl_offload_read_file_offset = -1;
+static int hf_smb2_fsctl_offload_read_copy_length = -1;
+static int hf_smb2_fsctl_offload_read_transfer_length = -1;
+static int hf_smb2_fsctl_offload_token = -1;
 static int hf_smb2_ioctl_function_method = -1;
 static int hf_smb2_ioctl_resiliency_timeout = -1;
 static int hf_smb2_ioctl_resiliency_reserved = -1;
@@ -211,6 +234,10 @@ static int hf_smb2_ioctl_shadow_copy_num_labels = -1;
 static int hf_smb2_ioctl_shadow_copy_count = -1;
 static int hf_smb2_ioctl_shadow_copy_label = -1;
 static int hf_smb2_compression_format = -1;
+static int hf_smb2_checksum_algorithm = -1;
+static int hf_smb2_integrity_reserved = -1;
+static int hf_smb2_integrity_flags = -1;
+static int hf_smb2_integrity_flags_enforcement_off = -1;
 static int hf_smb2_FILE_OBJECTID_BUFFER = -1;
 static int hf_smb2_lease_key = -1;
 static int hf_smb2_lease_state = -1;
@@ -294,6 +321,9 @@ static int hf_smb2_close_pq_attrib = -1;
 static int hf_smb2_notify_watch_tree = -1;
 static int hf_smb2_output_buffer_len = -1;
 static int hf_smb2_notify_out_data = -1;
+static int hf_smb2_notify_info = -1;
+static int hf_smb2_notify_next_offset = -1;
+static int hf_smb2_notify_action = -1;
 static int hf_smb2_find_flags = -1;
 static int hf_smb2_find_flags_restart_scans = -1;
 static int hf_smb2_find_flags_single_entry = -1;
@@ -331,10 +361,22 @@ static int hf_smb2_svhdx_open_device_context_originator_flags = -1;
 static int hf_smb2_svhdx_open_device_context_open_request_id = -1;
 static int hf_smb2_svhdx_open_device_context_initiator_host_name_len = -1;
 static int hf_smb2_svhdx_open_device_context_initiator_host_name = -1;
+static int hf_smb2_posix_v1_version = -1;
+static int hf_smb2_posix_v1_request = -1;
+static int hf_smb2_posix_v1_supported_features = -1;
+static int hf_smb2_posix_v1_posix_lock = -1;
+static int hf_smb2_posix_v1_posix_file_semantics = -1;
+static int hf_smb2_posix_v1_posix_utf8_paths = -1;
+static int hf_smb2_posix_v1_case_sensitive = -1;
+static int hf_smb2_posix_v1_posix_will_convert_nt_acls = -1;
+static int hf_smb2_posix_v1_posix_fileinfo = -1;
+static int hf_smb2_posix_v1_posix_acls = -1;
+static int hf_smb2_posix_v1_rich_acls = -1;
 static int hf_smb2_error_byte_count = -1;
 static int hf_smb2_error_data = -1;
 static int hf_smb2_error_reserved = -1;
 static int hf_smb2_reserved = -1;
+static int hf_smb2_reserved_random = -1;
 static int hf_smb2_transform_signature = -1;
 static int hf_smb2_transform_nonce = -1;
 static int hf_smb2_transform_msg_size = -1;
@@ -353,6 +395,7 @@ static gint ett_smb2_header = -1;
 static gint ett_smb2_encrypted = -1;
 static gint ett_smb2_command = -1;
 static gint ett_smb2_secblob = -1;
+static gint ett_smb2_negotiate_context_element = -1;
 static gint ett_smb2_file_basic_info = -1;
 static gint ett_smb2_file_standard_info = -1;
 static gint ett_smb2_file_internal_info = -1;
@@ -403,6 +446,7 @@ static gint ett_smb2_ioctl_flags = -1;
 static gint ett_smb2_ioctl_network_interface = -1;
 static gint ett_windows_sockaddr = -1;
 static gint ett_smb2_close_flags = -1;
+static gint ett_smb2_notify_info = -1;
 static gint ett_smb2_notify_flags = -1;
 static gint ett_smb2_write_flags = -1;
 static gint ett_smb2_rdma_v1 = -1;
@@ -411,6 +455,10 @@ static gint ett_smb2_DH2C_buffer = -1;
 static gint ett_smb2_dh2x_flags = -1;
 static gint ett_smb2_APP_INSTANCE_buffer = -1;
 static gint ett_smb2_svhdx_open_device_context = -1;
+static gint ett_smb2_posix_v1_request = -1;
+static gint ett_smb2_posix_v1_response = -1;
+static gint ett_smb2_posix_v1_supported_features = -1;
+static gint ett_smb2_integrity_flags = -1;
 static gint ett_smb2_find_flags = -1;
 static gint ett_smb2_file_directory_info = -1;
 static gint ett_smb2_both_directory_info = -1;
@@ -422,6 +470,7 @@ static gint ett_smb2_lock_flags = -1;
 static gint ett_smb2_transform_enc_alg = -1;
 static gint ett_smb2_buffercode = -1;
 static gint ett_smb2_ioctl_network_interface_capabilities = -1;
+static gint ett_qfr_entry = -1;
 
 static expert_field ei_smb2_invalid_length = EI_INIT;
 static expert_field ei_smb2_bad_response = EI_INIT;
@@ -431,16 +480,19 @@ static int smb2_eo_tap = -1;
 
 static dissector_handle_t gssapi_handle  = NULL;
 static dissector_handle_t ntlmssp_handle = NULL;
+static dissector_handle_t rsvd_handle = NULL;
 
 static heur_dissector_list_t smb2_heur_subdissector_list;
 
 #define SMB2_CLASS_FILE_INFO   0x01
 #define SMB2_CLASS_FS_INFO     0x02
 #define SMB2_CLASS_SEC_INFO    0x03
+#define SMB2_CLASS_POSIX_INFO  0x80
 static const value_string smb2_class_vals[] = {
        { SMB2_CLASS_FILE_INFO, "FILE_INFO"},
        { SMB2_CLASS_FS_INFO,   "FS_INFO"},
        { SMB2_CLASS_SEC_INFO,  "SEC_INFO"},
+       { SMB2_CLASS_POSIX_INFO, "POSIX_INFO"},
        { 0, NULL }
 };
 
@@ -503,22 +555,30 @@ static value_string_ext smb2_file_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_f
 
 
 
-#define SMB2_FS_INFO_01                0x01
-#define SMB2_FS_INFO_03                0x03
-#define SMB2_FS_INFO_04                0x04
-#define SMB2_FS_INFO_05                0x05
-#define SMB2_FS_INFO_06                0x06
-#define SMB2_FS_INFO_07                0x07
-#define SMB2_FS_OBJECTID_INFO  0x08
+#define SMB2_FS_INFO_01                        0x01
+#define SMB2_FS_LABEL_INFO             0x02
+#define SMB2_FS_INFO_03                        0x03
+#define SMB2_FS_INFO_04                        0x04
+#define SMB2_FS_INFO_05                        0x05
+#define SMB2_FS_INFO_06                        0x06
+#define SMB2_FS_INFO_07                        0x07
+#define SMB2_FS_OBJECTID_INFO          0x08
+#define SMB2_FS_DRIVER_PATH_INFO       0x09
+#define SMB2_FS_VOLUME_FLAGS_INFO      0x0a
+#define SMB2_FS_SECTOR_SIZE_INFO       0x0b
 
 static const value_string smb2_fs_info_levels[] = {
-       {SMB2_FS_INFO_01,       "SMB2_FS_INFO_01" },
-       {SMB2_FS_INFO_03,       "SMB2_FS_INFO_03" },
-       {SMB2_FS_INFO_04,       "SMB2_FS_INFO_04" },
-       {SMB2_FS_INFO_05,       "SMB2_FS_INFO_05" },
-       {SMB2_FS_INFO_06,       "SMB2_FS_INFO_06" },
-       {SMB2_FS_INFO_07,       "SMB2_FS_INFO_07" },
-       {SMB2_FS_OBJECTID_INFO, "SMB2_FS_OBJECTID_INFO" },
+       {SMB2_FS_INFO_01,               "FileFsVolumeInformation" },
+       {SMB2_FS_LABEL_INFO,            "FileFsLabelInformation" },
+       {SMB2_FS_INFO_03,               "FileFsSizeInformation" },
+       {SMB2_FS_INFO_04,               "FileFsDeviceInformation" },
+       {SMB2_FS_INFO_05,               "FileFsAttributeInformation" },
+       {SMB2_FS_INFO_06,               "FileFsControlInformation" },
+       {SMB2_FS_INFO_07,               "FileFsFullSizeInformation" },
+       {SMB2_FS_OBJECTID_INFO,         "FileFsObjectIdInformation" },
+       {SMB2_FS_DRIVER_PATH_INFO,      "FileFsDriverPathInformation" },
+       {SMB2_FS_VOLUME_FLAGS_INFO,     "FileFsVolumeFlagsInformation" },
+       {SMB2_FS_SECTOR_SIZE_INFO,      "FileFsSectorSizeInformation" },
        { 0, NULL }
 };
 static value_string_ext smb2_fs_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_fs_info_levels);
@@ -530,6 +590,17 @@ static const value_string smb2_sec_info_levels[] = {
 };
 static value_string_ext smb2_sec_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_sec_info_levels);
 
+static const value_string smb2_posix_info_levels[] = {
+       { 0,    "QueryFileUnixBasic" },
+       { 1,    "QueryFileUnixLink" },
+       { 3,    "QueryFileUnixHLink" },
+       { 5,    "QueryFileUnixXAttr" },
+       { 0x0B, "QueryFileUnixInfo2" },
+       { 0, NULL }
+};
+
+static value_string_ext smb2_posix_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_posix_info_levels);
+
 #define SMB2_FIND_DIRECTORY_INFO         0x01
 #define SMB2_FIND_FULL_DIRECTORY_INFO    0x02
 #define SMB2_FIND_BOTH_DIRECTORY_INFO    0x03
@@ -548,6 +619,61 @@ static const value_string smb2_find_info_levels[] = {
        { 0, NULL }
 };
 
+#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES 0x0001
+#define SMB2_ENCRYPTION_CAPABILITIES        0x0002
+static const value_string smb2_negotiate_context_types[] = {
+       { SMB2_PREAUTH_INTEGRITY_CAPABILITIES,  "SMB2_PREAUTH_INTEGRITY_CAPABILITIES" },
+       { SMB2_ENCRYPTION_CAPABILITIES, "SMB2_ENCRYPTION_CAPABILITIES" },
+       { 0, NULL }
+};
+
+#define SMB2_NUM_PROCEDURES     256
+
+static void
+smb2stat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data)
+{
+       srt_stat_table *smb2_srt_table;
+       guint32 i;
+
+       smb2_srt_table = init_srt_table("SMB2", NULL, srt_array, SMB2_NUM_PROCEDURES, "Commands", "smb2.cmd", gui_callback, gui_data, NULL);
+       for (i = 0; i < SMB2_NUM_PROCEDURES; i++)
+       {
+               init_srt_table_row(smb2_srt_table, i, val_to_str_ext_const(i, &smb2_cmd_vals_ext, "<unknown>"));
+       }
+}
+
+static int
+smb2stat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
+{
+       guint i = 0;
+       srt_stat_table *smb2_srt_table;
+       srt_data_t *data = (srt_data_t *)pss;
+       const smb2_info_t *si=(const smb2_info_t *)prv;
+
+       /* we are only interested in response packets */
+       if(!(si->flags&SMB2_FLAGS_RESPONSE)){
+               return 0;
+       }
+       /* if we haven't seen the request, just ignore it */
+       if(!si->saved){
+               return 0;
+       }
+
+       /* SMB2 SRT can be very inaccurate in the presence of retransmissions. Retransmitted responses
+        * not only add additional (bogus) transactions but also the latency associated with them.
+        * This can greatly inflate the maximum and average SRT stats especially in the case of
+        * retransmissions triggered by the expiry of the rexmit timer (RTOs). Only calculating SRT
+        * for the last received response accomplishes this goal without requiring the TCP pref
+        * "Do not call subdissectors for error packets" to be set. */
+       if ((si->saved->frame_req == 0) || (si->saved->frame_res != pinfo->fd->num))
+               return 0;
+
+       smb2_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
+       add_srt_table_data(smb2_srt_table, si->opcode, &si->saved->req_time, pinfo);
+       return 1;
+}
+
+
 static const gint8 zeros[NTLMSSP_KEY_LEN] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
 /* ExportObject preferences variable */
@@ -643,6 +769,54 @@ smb2_sesid_info_hash(gconstpointer k)
        return hash;
 }
 
+/*
+ * For File IDs of a specific conversation.
+ * This keeps track of fid to name mapping and application level conversations
+ * over named pipes.
+ *
+ * This handles implementation bugs, where the fid_persitent is 0 or
+ * the fid_persitent/fid_volative is not unique per conversation.
+ */
+static gint
+smb2_fid_info_equal(gconstpointer k1, gconstpointer k2)
+{
+       const smb2_fid_info_t *key1 = (const smb2_fid_info_t *)k1;
+       const smb2_fid_info_t *key2 = (const smb2_fid_info_t *)k2;
+
+       if (key1->fid_persistent != key2->fid_persistent) {
+               return 0;
+       };
+
+       if (key1->fid_volatile != key2->fid_volatile) {
+               return 0;
+       };
+
+       if (key1->sesid != key2->sesid) {
+               return 0;
+       };
+
+       if (key1->tid != key2->tid) {
+               return 0;
+       };
+
+       return 1;
+}
+
+static guint
+smb2_fid_info_hash(gconstpointer k)
+{
+       const smb2_fid_info_t *key = (const smb2_fid_info_t *)k;
+       guint32 hash;
+
+       if (key->fid_persistent != 0) {
+               hash = (guint32)( ((key->fid_persistent>>32)&0xffffffff)+((key->fid_persistent)&0xffffffff) );
+       } else {
+               hash = (guint32)( ((key->fid_volatile>>32)&0xffffffff)+((key->fid_volatile)&0xffffffff) );
+       }
+
+       return hash;
+}
+
 /* Callback for destroying the glib hash tables associated with a conversation
  * struct. */
 static gboolean
@@ -653,6 +827,7 @@ smb2_conv_destroy(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_,
 
        g_hash_table_destroy(conv->matched);
        g_hash_table_destroy(conv->unmatched);
+       g_hash_table_destroy(conv->fids);
        g_hash_table_destroy(conv->sesids);
        g_hash_table_destroy(conv->files);
 
@@ -703,17 +878,17 @@ static gchar *policy_hnd_to_file_id(const e_ctx_hnd *hnd) {
 gchar *file_id;
        file_id = wmem_strdup_printf(wmem_packet_scope(),
                        "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                       hnd->uuid.Data1,
-                       hnd->uuid.Data2,
-                       hnd->uuid.Data3,
-                       hnd->uuid.Data4[0],
-                       hnd->uuid.Data4[1],
-                       hnd->uuid.Data4[2],
-                       hnd->uuid.Data4[3],
-                       hnd->uuid.Data4[4],
-                       hnd->uuid.Data4[5],
-                       hnd->uuid.Data4[6],
-                       hnd->uuid.Data4[7]);
+                       hnd->uuid.data1,
+                       hnd->uuid.data2,
+                       hnd->uuid.data3,
+                       hnd->uuid.data4[0],
+                       hnd->uuid.data4[1],
+                       hnd->uuid.data4[2],
+                       hnd->uuid.data4[3],
+                       hnd->uuid.data4[4],
+                       hnd->uuid.data4[5],
+                       hnd->uuid.data4[6],
+                       hnd->uuid.data4[7]);
        return file_id;
 }
 static guint smb2_eo_files_hash(gconstpointer k) {
@@ -724,17 +899,17 @@ int       are_equal;
        const e_ctx_hnd *key1 = (const e_ctx_hnd *)k1;
        const e_ctx_hnd *key2 = (const e_ctx_hnd *)k2;
 
-       are_equal = (key1->uuid.Data1==key2->uuid.Data1 &&
-               key1->uuid.Data2==key2->uuid.Data2 &&
-               key1->uuid.Data3==key2->uuid.Data3 &&
-               key1->uuid.Data4[0]==key2->uuid.Data4[0] &&
-               key1->uuid.Data4[1]==key2->uuid.Data4[1] &&
-               key1->uuid.Data4[2]==key2->uuid.Data4[2] &&
-               key1->uuid.Data4[3]==key2->uuid.Data4[3] &&
-               key1->uuid.Data4[4]==key2->uuid.Data4[4] &&
-               key1->uuid.Data4[5]==key2->uuid.Data4[5] &&
-               key1->uuid.Data4[6]==key2->uuid.Data4[6] &&
-               key1->uuid.Data4[7]==key2->uuid.Data4[7]);
+       are_equal = (key1->uuid.data1==key2->uuid.data1 &&
+               key1->uuid.data2==key2->uuid.data2 &&
+               key1->uuid.data3==key2->uuid.data3 &&
+               key1->uuid.data4[0]==key2->uuid.data4[0] &&
+               key1->uuid.data4[1]==key2->uuid.data4[1] &&
+               key1->uuid.data4[2]==key2->uuid.data4[2] &&
+               key1->uuid.data4[3]==key2->uuid.data4[3] &&
+               key1->uuid.data4[4]==key2->uuid.data4[4] &&
+               key1->uuid.data4[5]==key2->uuid.data4[5] &&
+               key1->uuid.data4[6]==key2->uuid.data4[6] &&
+               key1->uuid.data4[7]==key2->uuid.data4[7]);
 
        return are_equal;
 }
@@ -930,7 +1105,7 @@ dissect_smb2_olb_string(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *t
        offset = olb->off;
        len = olb->len;
        off = olb->off;
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
 
 
        /* sanity check */
@@ -1059,7 +1234,7 @@ dissect_smb2_olb_buffer(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *t
                return;
        }
 
-       sub_tvb = tvb_new_subset(tvb, off, MIN((int)len, tvb_length_remaining(tvb, off)), len);
+       sub_tvb = tvb_new_subset(tvb, off, MIN((int)len, tvb_captured_length_remaining(tvb, off)), len);
 
        dissector(sub_tvb, pinfo, sub_tree, si);
 }
@@ -1113,6 +1288,11 @@ static const true_false_string tfs_flags_replay_operation = {
        "This is NOT a replay operation"
 };
 
+static const true_false_string tfs_flags_priority_mask = {
+       "This pdu contains a PRIORITY",
+       "This pdu does NOT contain a PRIORITY1"
+};
+
 static const true_false_string tfs_cap_dfs = {
        "This host supports DFS",
        "This host does NOT support DFS"
@@ -1158,12 +1338,57 @@ static const true_false_string tfs_smb2_ioctl_network_interface_capability_rdma
        "This interface does not support RDMA"
 };
 
+static const value_string file_region_usage_vals[] = {
+       { 0x00000001, "FILE_REGION_USAGE_VALID_CACHED_DATA" },
+       { 0, NULL }
+};
+
 static const value_string originator_flags_vals[] = {
        { 1, "SVHDX_ORIGINATOR_PVHDPARSER" },
        { 4, "SVHDX_ORIGINATOR_VHDMP" },
        { 0, NULL }
 };
 
+static const value_string posix_locks_vals[] = {
+       { 1, "POSIX_V1_POSIX_LOCK" },
+       { 0, NULL }
+};
+
+static const value_string posix_utf8_paths_vals[] = {
+       { 1, "POSIX_V1_UTF8_PATHS" },
+       { 0, NULL }
+};
+
+static const value_string posix_file_semantics_vals[] = {
+       { 1, "POSIX_V1_POSIX_FILE_SEMANTICS" },
+       { 0, NULL }
+};
+
+static const value_string posix_case_sensitive_vals[] = {
+       { 1, "POSIX_V1_CASE_SENSITIVE" },
+       { 0, NULL }
+};
+
+static const value_string posix_will_convert_ntacls_vals[] = {
+       { 1, "POSIX_V1_WILL_CONVERT_NT_ACLS" },
+       { 0, NULL }
+};
+
+static const value_string posix_fileinfo_vals[] = {
+       { 1, "POSIX_V1_POSIX_FILEINFO" },
+       { 0, NULL }
+};
+
+static const value_string posix_acls_vals[] = {
+       { 1, "POSIX_V1_POSIX_ACLS" },
+       { 0, NULL }
+};
+
+static const value_string posix_rich_acls_vals[] = {
+       { 1, "POSIX_V1_RICH_ACLS" },
+       { 0, NULL }
+};
+
 static const value_string compression_format_vals[] = {
        { 0, "COMPRESSION_FORMAT_NONE" },
        { 1, "COMPRESSION_FORMAT_DEFAULT" },
@@ -1171,6 +1396,12 @@ static const value_string compression_format_vals[] = {
        { 0, NULL }
 };
 
+static const value_string checksum_algorithm_vals[] = {
+       { 0x0000, "CHECKSUM_TYPE_NONE" },
+       { 0x0002, "CHECKSUM_TYPE_CRC64" },
+       { 0xFFFF, "CHECKSUM_TYPE_UNCHANGED" },
+       { 0, NULL }
+};
 
 /* Note: All uncommented are "dissector not implemented" */
 static const value_string smb2_ioctl_vals[] = {
@@ -1215,6 +1446,16 @@ static const value_string smb2_ioctl_vals[] = {
        {0x000900DF, "FSCTL_WRITE_RAW_ENCRYPTED"},
        {0x000900E3, "FSCTL_READ_RAW_ENCRYPTED"},
        {0x000900F0, "FSCTL_EXTEND_VOLUME"},
+       {0x0009027C, "FSCTL_GET_INTEGRITY_INFORMATION"},
+       {0x00090284, "FSCTL_QUERY_FILE_REGIONS"},
+       {0x00090300, "FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT"},      /* dissector implemented */
+       {0x00090304, "FSCTL_SVHDX_SYNC_TUNNEL_REQUEST"},              /* dissector implemented */
+       {0x00090308, "FSCTL_SVHDX_SET_INITIATOR_INFORMATION"},
+       {0x0009030C, "FSCTL_SET_EXTERNAL_BACKING"},
+       {0x00090310, "FSCTL_GET_EXTERNAL_BACKING"},
+       {0x00090314, "FSCTL_DELETE_EXTERNAL_BACKING"},
+       {0x00090318, "FSCTL_ENUM_EXTERNAL_BACKING"},
+       {0x0009031F, "FSCTL_ENUM_OVERLAY"},
        {0x000940B3, "FSCTL_ENUM_USN_DATA"},
        {0x000940B7, "FSCTL_SECURITY_ID_CHECK"},
        {0x000940BB, "FSCTL_READ_USN_JOURNAL"},
@@ -1222,8 +1463,9 @@ static const value_string smb2_ioctl_vals[] = {
        {0x000940E7, "FSCTL_CREATE_USN_JOURNAL"},
        {0x000940EB, "FSCTL_READ_FILE_USN_DATA"},
        {0x000940EF, "FSCTL_WRITE_USN_CLOSE_RECORD"},
+       {0x00094264, "FSCTL_OFFLOAD_READ"},
        {0x00098098, "FSCTL_SET_OBJECT_ID"},                          /* dissector implemented */
-       {0x000980A0, "FSCTL_DELETE_OBJECT_ID"}, /* no data in/out */  /* dissector implemented */
+       {0x000980A0, "FSCTL_DELETE_OBJECT_ID"}, /* no data in/out */
        {0x000980A4, "FSCTL_SET_REPARSE_POINT"},
        {0x000980AC, "FSCTL_DELETE_REPARSE_POINT"},
        {0x000980BC, "FSCTL_SET_OBJECT_ID_EXTENDED"},                 /* dissector implemented */
@@ -1231,6 +1473,8 @@ static const value_string smb2_ioctl_vals[] = {
        {0x000980C8, "FSCTL_SET_ZERO_DATA"},
        {0x000980D0, "FSCTL_ENABLE_UPGRADE"},
        {0x0009C040, "FSCTL_SET_COMPRESSION"},                        /* dissector implemented */
+       {0x0009C280, "FSCTL_SET_INTEGRITY_INFORMATION"},              /* dissector implemented */
+       {0x00110018, "FSCTL_PIPE_WAIT"},                              /* dissector implemented */
        {0x0011C017, "FSCTL_PIPE_TRANSCEIVE"},                        /* dissector implemented */
        {0x00140078, "FSCTL_SRV_REQUEST_RESUME_KEY"},
        {0x001401D4, "FSCTL_LMR_REQUEST_RESILIENCY"},                 /* dissector implemented */
@@ -1409,16 +1653,32 @@ dissect_smb2_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset
        char       *fid_name;
        guint32     open_frame = 0, close_frame = 0;
        smb2_eo_file_info_t     *eo_file_info;
+       smb2_fid_info_t sfi_key;
+       smb2_fid_info_t *sfi = NULL;
+
+       sfi_key.fid_persistent = tvb_get_letoh64(tvb, offset);
+       sfi_key.fid_volatile = tvb_get_letoh64(tvb, offset+8);
+       sfi_key.sesid = si->sesid;
+       sfi_key.tid = si->tid;
+       sfi_key.name = NULL;
 
        di.conformant_run = 0;
        /* we need di->call_data->flags.NDR64 == 0 */
        di.call_data = &call_data;
-       di.dcerpc_procedure_name = "";
 
        switch (mode) {
        case FID_MODE_OPEN:
                offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, &di, drep, hf_smb2_fid, &policy_hnd, &hnd_item, TRUE, FALSE);
                if (!pinfo->fd->flags.visited) {
+                       sfi = wmem_new(wmem_file_scope(), smb2_fid_info_t);
+                       *sfi = sfi_key;
+                       if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
+                               sfi->name = wmem_strdup(wmem_file_scope(), (char *)si->saved->extra_info);
+                       } else {
+                               sfi->name = wmem_strdup_printf(wmem_file_scope(), "[unknown]");
+                       }
+                       sfi->open_frame = pinfo->fd->num;
+
                        if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
                                fid_name = wmem_strdup_printf(wmem_file_scope(), "File: %s", (char *)si->saved->extra_info);
                        } else {
@@ -1427,8 +1687,14 @@ dissect_smb2_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset
                        dcerpc_store_polhnd_name(&policy_hnd, pinfo,
                                                  fid_name);
 
+                       g_hash_table_insert(si->conv->fids, sfi, sfi);
+                       si->file = sfi;
+
                        /* If needed, create the file entry and save the policy hnd */
-                       if (si->saved) { si->saved->policy_hnd = policy_hnd; }
+                       if (si->saved) {
+                               si->saved->file = sfi;
+                               si->saved->policy_hnd = policy_hnd;
+                       }
 
                        if (si->conv) {
                                eo_file_info = (smb2_eo_file_info_t *)g_hash_table_lookup(si->conv->files,&policy_hnd);
@@ -1453,15 +1719,20 @@ dissect_smb2_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset
                break;
        }
 
-       if (dcerpc_fetch_polhnd_data(&policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->fd->num)) {
-               /* put the filename in col_info */
-               if (fid_name) {
+       si->file = (smb2_fid_info_t *)g_hash_table_lookup(si->conv->fids, &sfi_key);
+       if (si->file) {
+               if (si->saved) {
+                       si->saved->file = si->file;
+               }
+               if (si->file->name) {
                        if (hnd_item) {
-                               proto_item_append_text(hnd_item, " %s", fid_name);
+                               proto_item_append_text(hnd_item, " File: %s", si->file->name);
                        }
-                       col_append_fstr(pinfo->cinfo, COL_INFO, " %s", fid_name);
+                       col_append_fstr(pinfo->cinfo, COL_INFO, " File: %s", si->file->name);
                }
+       }
 
+       if (dcerpc_fetch_polhnd_data(&policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->fd->num)) {
                /* look for the eo_file_info */
                if (!si->eo_file_info) {
                        if (si->saved) { si->saved->policy_hnd = policy_hnd; }
@@ -1561,16 +1832,12 @@ dissect_smb2_file_all_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pa
 
        /* file name length */
        length = tvb_get_letohs(tvb, offset);
-       proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
-       offset += 2;
-
-       /* some unknown bytes */
-       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
-       offset += 2;
+       proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
 
        /* file name */
        if (length) {
-               bc = tvb_length_remaining(tvb, offset);
+               bc = tvb_captured_length_remaining(tvb, offset);
                name = get_unicode_or_ascii_string(tvb, &offset,
                        TRUE, &length, TRUE, TRUE, &bc);
                if (name) {
@@ -1581,7 +1848,6 @@ dissect_smb2_file_all_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pa
        }
        offset += length;
 
-
        return offset;
 }
 
@@ -1599,7 +1865,7 @@ dissect_smb2_file_allocation_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
                tree = proto_item_add_subtree(item, ett_smb2_file_allocation_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qsfi_SMB_FILE_ALLOCATION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1618,7 +1884,7 @@ dissect_smb2_file_endoffile_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
                tree = proto_item_add_subtree(item, ett_smb2_file_endoffile_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qsfi_SMB_FILE_ENDOFFILE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1637,7 +1903,7 @@ dissect_smb2_file_alternate_name_info(tvbuff_t *tvb, packet_info *pinfo _U_, pro
                tree = proto_item_add_subtree(item, ett_smb2_file_alternate_name_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_NAME_INFO(tvb, pinfo, tree, offset, &bc, &trunc, /* XXX assumption hack */ TRUE);
 
        return offset;
@@ -1690,7 +1956,7 @@ dissect_smb2_file_standard_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                tree = proto_item_add_subtree(item, ett_smb2_file_standard_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_STANDARD_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1708,7 +1974,7 @@ dissect_smb2_file_internal_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                tree = proto_item_add_subtree(item, ett_smb2_file_internal_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_INTERNAL_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1726,7 +1992,7 @@ dissect_smb2_file_mode_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *p
                tree = proto_item_add_subtree(item, ett_smb2_file_mode_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qsfi_SMB_FILE_MODE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1744,7 +2010,7 @@ dissect_smb2_file_alignment_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
                tree = proto_item_add_subtree(item, ett_smb2_file_alignment_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_ALIGNMENT_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1762,7 +2028,7 @@ dissect_smb2_file_position_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                tree = proto_item_add_subtree(item, ett_smb2_file_position_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qsfi_SMB_FILE_POSITION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1798,7 +2064,7 @@ dissect_smb2_file_ea_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *par
                tree = proto_item_add_subtree(item, ett_smb2_file_ea_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_EA_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1817,7 +2083,7 @@ dissect_smb2_file_stream_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
                tree = proto_item_add_subtree(item, ett_smb2_file_stream_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_STREAM_INFO(tvb, pinfo, tree, offset, &bc, &trunc, TRUE);
 
        return offset;
@@ -1836,7 +2102,7 @@ dissect_smb2_file_pipe_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *p
                tree = proto_item_add_subtree(item, ett_smb2_file_pipe_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_sfi_SMB_FILE_PIPE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1855,7 +2121,7 @@ dissect_smb2_file_compression_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_
                tree = proto_item_add_subtree(item, ett_smb2_file_compression_info);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_COMPRESSION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1875,7 +2141,7 @@ dissect_smb2_file_network_open_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto
        }
 
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_NETWORK_OPEN_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1895,7 +2161,7 @@ dissect_smb2_file_attribute_tag_info(tvbuff_t *tvb, packet_info *pinfo _U_, prot
        }
 
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfi_SMB_FILE_ATTRIBUTE_TAG_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
 
        return offset;
@@ -1970,7 +2236,7 @@ dissect_smb2_file_full_ea_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
                /* ea name */
                length = ea_name_len;
                if (length) {
-                       bc = tvb_length_remaining(tvb, offset);
+                       bc = tvb_captured_length_remaining(tvb, offset);
                        name = get_unicode_or_ascii_string(tvb, &offset,
                                FALSE, &length, TRUE, TRUE, &bc);
                        if (name) {
@@ -1985,7 +2251,7 @@ dissect_smb2_file_full_ea_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
                /* ea data */
                length = ea_data_len;
                if (length) {
-                       bc = tvb_length_remaining(tvb, offset);
+                       bc = tvb_captured_length_remaining(tvb, offset);
                        data = get_unicode_or_ascii_string(tvb, &offset,
                                FALSE, &length, TRUE, TRUE, &bc);
                        /*
@@ -2013,6 +2279,11 @@ dissect_smb2_file_full_ea_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
        return offset;
 }
 
+static const true_false_string tfs_replace_if_exists = {
+       "Replace the target if it exists",
+       "Fail if the target exists"
+};
+
 static int
 dissect_smb2_file_rename_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
 {
@@ -2028,22 +2299,26 @@ dissect_smb2_file_rename_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
                tree = proto_item_add_subtree(item, ett_smb2_file_rename_info);
        }
 
-       /* some unknown bytes */
-       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, ENC_NA);
-       offset += 16;
+       /* ReplaceIfExists */
+       proto_tree_add_item(tree, hf_smb2_replace_if, tvb, offset, 1, ENC_NA);
+       offset += 1;
+
+       /* reserved */
+       proto_tree_add_item(tree, hf_smb2_reserved_random, tvb, offset, 7, ENC_NA);
+       offset += 7;
+
+       /* Root Directory Handle, MBZ */
+       proto_tree_add_item(tree, hf_smb2_root_directory_mbz, tvb, offset, 8, ENC_NA);
+       offset += 8;
 
        /* file name length */
        length = tvb_get_letohs(tvb, offset);
-       proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
-       offset += 2;
-
-       /* some unknown bytes */
-       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
-       offset += 2;
+       proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
 
        /* file name */
        if (length) {
-               bc = tvb_length_remaining(tvb, offset);
+               bc = tvb_captured_length_remaining(tvb, offset);
                name = get_unicode_or_ascii_string(tvb, &offset,
                        TRUE, &length, TRUE, TRUE, &bc);
                if (name) {
@@ -2055,10 +2330,6 @@ dissect_smb2_file_rename_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
        }
        offset += length;
 
-       /* some unknown bytes */
-       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, ENC_NA);
-       offset += 4;
-
        return offset;
 }
 
@@ -2074,7 +2345,7 @@ dissect_smb2_sec_info_00(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pare
        }
 
        /* security descriptor */
-       offset = dissect_nt_sec_desc(tvb, offset, pinfo, tree, NULL, TRUE, tvb_length_remaining(tvb, offset), NULL);
+       offset = dissect_nt_sec_desc(tvb, offset, pinfo, tree, NULL, TRUE, tvb_captured_length_remaining(tvb, offset), NULL);
 
        return offset;
 }
@@ -2091,7 +2362,7 @@ dissect_smb2_fs_info_05(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *paren
                tree = proto_item_add_subtree(item, ett_smb2_fs_info_05);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfsi_FS_ATTRIBUTE_INFO(tvb, pinfo, tree, offset, &bc, TRUE);
 
        return offset;
@@ -2109,7 +2380,7 @@ dissect_smb2_fs_info_06(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *paren
                tree = proto_item_add_subtree(item, ett_smb2_fs_info_06);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_nt_quota(tvb, tree, offset, &bc);
 
        return offset;
@@ -2144,7 +2415,7 @@ dissect_smb2_fs_info_07(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *paren
                tree = proto_item_add_subtree(item, ett_smb2_fs_info_07);
        }
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfsi_FS_FULL_SIZE_INFO(tvb, pinfo, tree, offset, &bc);
 
        return offset;
@@ -2163,7 +2434,7 @@ dissect_smb2_fs_info_01(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *paren
        }
 
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfsi_FS_VOLUME_INFO(tvb, pinfo, tree, offset, &bc, TRUE);
 
        return offset;
@@ -2182,7 +2453,7 @@ dissect_smb2_fs_info_03(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *paren
        }
 
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfsi_FS_SIZE_INFO(tvb, pinfo, tree, offset, &bc);
 
        return offset;
@@ -2201,7 +2472,7 @@ dissect_smb2_fs_info_04(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *paren
        }
 
 
-       bc = tvb_length_remaining(tvb, offset);
+       bc = tvb_captured_length_remaining(tvb, offset);
        offset = dissect_qfsi_FS_DEVICE_INFO(tvb, pinfo, tree, offset, &bc);
 
        return offset;
@@ -2236,10 +2507,7 @@ dissect_smb2_buffercode(proto_tree *parent_tree, tvbuff_t *tvb, int offset, guin
        buffer_code = tvb_get_letohs(tvb, offset);
        item = proto_tree_add_uint(parent_tree, hf_smb2_buffer_code, tvb, offset, 2, buffer_code);
        tree = proto_item_add_subtree(item, ett_smb2_buffercode);
-       proto_tree_add_uint_format(tree, hf_smb2_buffer_code_len, tvb, offset, 2,
-                                  buffer_code&0xfffe, "%s: %u",
-                                  decode_numeric_bitfield(buffer_code, 0xfffe, 16, "Fixed Part Length"),
-                                  buffer_code&0xfffe);
+       proto_tree_add_item(tree, hf_smb2_buffer_code_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(tree, hf_smb2_buffer_code_flags_dyn, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset += 2;
 
@@ -2412,7 +2680,7 @@ dissect_smb2_share_caps(proto_tree *tree, tvbuff_t *tvb, int offset)
 static void
 dissect_smb2_secblob(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
 {
-       if ((tvb_length(tvb)>=7)
+       if ((tvb_captured_length(tvb)>=7)
        &&  (!tvb_memeql(tvb, 0, "NTLMSSP", 7))) {
                call_dissector(ntlmssp_handle, tvb, pinfo, tree);
        } else {
@@ -2817,10 +3085,70 @@ dissect_smb2_notify_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        return offset;
 }
 
+static const value_string notify_action_vals[] = {
+       {0x01, "FILE_ACTION_ADDED"},
+       {0x02, "FILE_ACTION_REMOVED"},
+       {0x03, "FILE_ACTION_MODIFIED"},
+       {0x04, "FILE_ACTION_RENAMED_OLD_NAME"},
+       {0x05, "FILE_ACTION_RENAMED_NEW_NAME"},
+       {0x06, "FILE_ACTION_ADDED_STREAM"},
+       {0x07, "FILE_ACTION_REMOVED_STREAM"},
+       {0x08, "FILE_ACTION_MODIFIED_STREAM"},
+       {0x09, "FILE_ACTION_REMOVED_BY_DELETE"},
+       {0, NULL}
+};
+
 static void
-dissect_smb2_notify_data_out(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
+dissect_smb2_notify_data_out(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
 {
-       proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), ENC_NA);
+       proto_tree *tree = NULL;
+       proto_item *item = NULL;
+       int offset = 0;
+
+       while (tvb_reported_length_remaining(tvb, offset) > 4) {
+               guint32 start_offset = offset;
+               guint32 next_offset;
+               guint32 length;
+
+               if (parent_tree) {
+                       item = proto_tree_add_item(parent_tree, hf_smb2_notify_info, tvb, offset, -1, ENC_NA);
+                       tree = proto_item_add_subtree(item, ett_smb2_notify_info);
+               }
+
+               /* next offset */
+               proto_tree_add_item_ret_uint(tree, hf_smb2_notify_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN, &next_offset);
+               offset += 4;
+
+               proto_tree_add_item(tree, hf_smb2_notify_action, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+               offset += 4;
+
+               /* file name length */
+               proto_tree_add_item_ret_uint(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &length);
+               offset += 4;
+
+               /* file name */
+               if (length) {
+                       const guchar *name = "";
+                       guint16     bc;
+
+                       bc = tvb_reported_length_remaining(tvb, offset);
+                       name = get_unicode_or_ascii_string(tvb, &offset,
+                                       TRUE, &length, TRUE, TRUE, &bc);
+                       if (name) {
+                               proto_tree_add_string(tree, hf_smb2_filename,
+                                                     tvb, offset, length,
+                                                     name);
+                       }
+
+                       offset += length;
+               }
+
+               if (!next_offset) {
+                       break;
+               }
+
+               offset = start_offset+next_offset;
+       }
 }
 
 static int
@@ -2921,7 +3249,7 @@ static void dissect_smb2_file_directory_info(tvbuff_t *tvb, packet_info *pinfo _
        const char *name   = NULL;
        guint16     bc;
 
-       while (tvb_length_remaining(tvb, offset) > 4) {
+       while (tvb_reported_length_remaining(tvb, offset) > 4) {
                int old_offset = offset;
                int next_offset;
                int file_name_len;
@@ -3004,7 +3332,7 @@ static void dissect_smb2_full_directory_info(tvbuff_t *tvb, packet_info *pinfo _
        const char *name   = NULL;
        guint16     bc;
 
-       while (tvb_length_remaining(tvb, offset) > 4) {
+       while (tvb_reported_length_remaining(tvb, offset) > 4) {
                int old_offset = offset;
                int next_offset;
                int file_name_len;
@@ -3091,7 +3419,7 @@ static void dissect_smb2_both_directory_info(tvbuff_t *tvb, packet_info *pinfo _
        const char *name   = NULL;
        guint16     bc;
 
-       while (tvb_length_remaining(tvb, offset) > 4) {
+       while (tvb_reported_length_remaining(tvb, offset) > 4) {
                int old_offset = offset;
                int next_offset;
                int file_name_len;
@@ -3199,7 +3527,7 @@ static void dissect_smb2_file_name_info(tvbuff_t *tvb, packet_info *pinfo _U_, p
        const char *name   = NULL;
        guint16     bc;
 
-       while (tvb_length_remaining(tvb, offset) > 4) {
+       while (tvb_reported_length_remaining(tvb, offset) > 4) {
                int old_offset = offset;
                int next_offset;
                int file_name_len;
@@ -3259,7 +3587,7 @@ static void dissect_smb2_id_both_directory_info(tvbuff_t *tvb, packet_info *pinf
        const char *name   = NULL;
        guint16     bc;
 
-       while (tvb_length_remaining(tvb, offset) > 4) {
+       while (tvb_reported_length_remaining(tvb, offset) > 4) {
                int old_offset = offset;
                int next_offset;
                int file_name_len;
@@ -3387,8 +3715,8 @@ dissect_smb2_find_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2
        smb2_find_dissector_t *dis = smb2_find_dissectors;
 
        while (dis->dissector) {
-               if (si && si->saved && si->saved) {
-                       if (dis->level ==si->saved->infolevel) {
+               if (si && si->saved) {
+                       if (dis->level == si->saved->infolevel) {
                                dis->dissector(tvb, pinfo, tree, si);
                                return;
                        }
@@ -3396,7 +3724,7 @@ dissect_smb2_find_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2
                dis++;
        }
 
-       proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), ENC_NA);
+       proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_captured_length(tvb), ENC_NA);
 }
 
 static int
@@ -3440,10 +3768,57 @@ dissect_smb2_find_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr
        return offset;
 }
 
+static int
+dissect_smb2_negotiate_context(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
+{
+       int start_offset = offset;
+       guint16 type;
+       const gchar *type_str;
+       guint16 data_length;
+       proto_item *sub_item;
+       proto_tree *sub_tree;
+       tvbuff_t *sub_tvb;
+
+       sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_smb2_negotiate_context_element, &sub_item, "Negotiate Context");
+
+       /* type */
+       type = tvb_get_letohl(tvb, offset);
+       type_str = val_to_str(type, smb2_negotiate_context_types, "Unknown Type: (0x%0x)");
+       proto_item_append_text(sub_item, ": %s ", type_str);
+       proto_tree_add_item(sub_tree, hf_smb2_negotiate_context_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+       offset += 2;
+
+       /* data length */
+       data_length = tvb_get_letohl(tvb, offset);
+       proto_tree_add_item(sub_tree, hf_smb2_negotiate_context_data_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+       offset += 2;
+
+       /* reserved */
+       proto_tree_add_item(sub_tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
+       offset += 4;
+
+       /* data */
+       sub_tvb = tvb_new_subset_length(tvb, offset, data_length);
+       offset += data_length;
+
+       proto_item_set_len(sub_item, offset - start_offset);
+
+       /*
+        * TODO: disssect the context data
+        */
+       proto_tree_add_item(sub_tree, hf_smb2_unknown, sub_tvb, 0, data_length, ENC_NA);
+
+       return offset;
+}
+
 static int
 dissect_smb2_negotiate_protocol_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
 {
        guint16 dc;
+       guint16 i;
+       gboolean supports_smb_3_10 = FALSE;
+       guint32 nco;
+       guint16 ncc;
 
        /* buffer code */
        offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
@@ -3459,6 +3834,7 @@ dissect_smb2_negotiate_protocol_request(tvbuff_t *tvb, packet_info *pinfo _U_, p
 
 
        /* reserved */
+       proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
        offset += 2;
 
        /* capabilities */
@@ -3468,13 +3844,47 @@ dissect_smb2_negotiate_protocol_request(tvbuff_t *tvb, packet_info *pinfo _U_, p
        proto_tree_add_item(tree, hf_smb2_client_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
        offset += 16;
 
-       /* client boot time */
-       dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_boot_time);
-       offset += 8;
+       /* negotiate context offset */
+       nco = tvb_get_letohl(tvb, offset);
+       proto_tree_add_item(tree, hf_smb2_negotiate_context_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
+
+       /* negotiate context count */
+       ncc = tvb_get_letohs(tvb, offset);
+       proto_tree_add_item(tree, hf_smb2_negotiate_context_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+       offset += 2;
 
-       for ( ; dc>0; dc--) {
+       /* reserved */
+       proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
+       offset += 2;
+
+       for (i = 0 ; i < dc; i++) {
+               guint16 d = tvb_get_letohs(tvb, offset);
                proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
                offset += 2;
+
+               if (d >= 0x310) {
+                       supports_smb_3_10 = TRUE;
+               }
+       }
+
+       if (!supports_smb_3_10) {
+               ncc = 0;
+       }
+
+       if (nco != 0) {
+               guint32 tmp = 0x40 + 36 + dc * 2;
+
+               if (nco >= tmp) {
+                       offset += nco - tmp;
+               } else {
+                       ncc = 0;
+               }
+       }
+
+       for (i = 0; i < ncc; i++) {
+               offset = (offset + 7) & ~7;
+               offset = dissect_smb2_negotiate_context(tvb, pinfo, tree, offset, si);
        }
 
        return offset;
@@ -3484,6 +3894,10 @@ static int
 dissect_smb2_negotiate_protocol_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
 {
        offset_length_buffer_t s_olb;
+       guint16 d;
+       guint16 i;
+       guint32 nco;
+       guint16 ncc;
 
        switch (si->status) {
        case 0x00000000: break;
@@ -3498,10 +3912,13 @@ dissect_smb2_negotiate_protocol_response(tvbuff_t *tvb, packet_info *pinfo, prot
        offset++;
 
        /* dialect picked */
+       d = tvb_get_letohs(tvb, offset);
        proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset += 2;
 
-       /* reserved */
+       /* negotiate context count */
+       ncc = tvb_get_letohs(tvb, offset);
+       proto_tree_add_item(tree, hf_smb2_negotiate_context_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset += 2;
 
        /* server GUID */
@@ -3537,11 +3954,32 @@ dissect_smb2_negotiate_protocol_response(tvbuff_t *tvb, packet_info *pinfo, prot
        /* the security blob itself */
        dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
 
-       /* reserved */
+       /* negotiate context offset */
+       nco = tvb_get_letohl(tvb, offset);
+       proto_tree_add_item(tree, hf_smb2_negotiate_context_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
        offset += 4;
 
        offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
 
+       if (d < 0x310) {
+               ncc = 0;
+       }
+
+       if (nco != 0) {
+               guint32 tmp = 0x40 + 64 + s_olb.len;
+
+               if (nco >= tmp) {
+                       offset += nco - tmp;
+               } else {
+                       ncc = 0;
+               }
+       }
+
+       for (i = 0; i < ncc; i++) {
+               offset = (offset + 7) & ~7;
+               offset = dissect_smb2_negotiate_context(tvb, pinfo, tree, offset, si);
+       }
+
        return offset;
 }
 
@@ -3554,7 +3992,7 @@ dissect_smb2_getinfo_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                default:
                        /* we don't handle this infolevel yet */
                        proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, ENC_NA);
-                       offset += tvb_length_remaining(tvb, offset);
+                       offset += tvb_captured_length_remaining(tvb, offset);
                }
                break;
        case SMB2_CLASS_FS_INFO:
@@ -3562,7 +4000,7 @@ dissect_smb2_getinfo_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                default:
                        /* we don't handle this infolevel yet */
                        proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, ENC_NA);
-                       offset += tvb_length_remaining(tvb, offset);
+                       offset += tvb_captured_length_remaining(tvb, offset);
                }
                break;
        case SMB2_CLASS_SEC_INFO:
@@ -3573,13 +4011,13 @@ dissect_smb2_getinfo_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                default:
                        /* we don't handle this infolevel yet */
                        proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, ENC_NA);
-                       offset += tvb_length_remaining(tvb, offset);
+                       offset += tvb_captured_length_remaining(tvb, offset);
                }
                break;
        default:
                /* we don't handle this class yet */
                proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 16, ENC_NA);
-               offset += tvb_length_remaining(tvb, offset);
+               offset += tvb_captured_length_remaining(tvb, offset);
        }
        return offset;
 }
@@ -3588,7 +4026,7 @@ dissect_smb2_getinfo_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
 static int
 dissect_smb2_class_infolevel(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree, smb2_info_t *si)
 {
-       char              cl, il;
+       guint8            cl, il;
        proto_item       *item;
        int               hfindex;
        value_string_ext *vsx;
@@ -3622,6 +4060,10 @@ dissect_smb2_class_infolevel(packet_info *pinfo, tvbuff_t *tvb, int offset, prot
                hfindex = hf_smb2_infolevel_sec_info;
                vsx = &smb2_sec_info_levels_ext;
                break;
+       case SMB2_CLASS_POSIX_INFO:
+               hfindex = hf_smb2_infolevel_posix_info;
+               vsx = &smb2_posix_info_levels_ext;
+               break;
        default:
                hfindex = hf_smb2_infolevel;
                vsx = NULL;  /* allowed arg to val_to_str_ext() */
@@ -3751,8 +4193,8 @@ dissect_smb2_infolevel(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                        break;
                default:
                        /* we don't handle this infolevel yet */
-                       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), ENC_NA);
-                       offset += tvb_length_remaining(tvb, offset);
+                       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
+                       offset += tvb_captured_length_remaining(tvb, offset);
                }
                break;
        case SMB2_CLASS_FS_INFO:
@@ -3780,8 +4222,8 @@ dissect_smb2_infolevel(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                        break;
                default:
                        /* we don't handle this infolevel yet */
-                       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), ENC_NA);
-                       offset += tvb_length_remaining(tvb, offset);
+                       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
+                       offset += tvb_captured_length_remaining(tvb, offset);
                }
                break;
        case SMB2_CLASS_SEC_INFO:
@@ -3791,14 +4233,14 @@ dissect_smb2_infolevel(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                        break;
                default:
                        /* we don't handle this infolevel yet */
-                       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), ENC_NA);
-                       offset += tvb_length_remaining(tvb, offset);
+                       proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
+                       offset += tvb_captured_length_remaining(tvb, offset);
                }
                break;
        default:
                /* we don't handle this class yet */
-               proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_length_remaining(tvb, offset), ENC_NA);
-               offset += tvb_length_remaining(tvb, offset);
+               proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
+               offset += tvb_captured_length_remaining(tvb, offset);
        }
 
        /* if we get BUFFER_OVERFLOW there will be truncated data */
@@ -3818,7 +4260,7 @@ dissect_smb2_getinfo_response_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree
                dissect_smb2_infolevel(tvb, pinfo, tree, 0, si, si->saved->smb2_class, si->saved->infolevel);
        } else {
                /* some unknown bytes */
-               proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), ENC_NA);
+               proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_captured_length(tvb), ENC_NA);
        }
 
 }
@@ -4057,21 +4499,37 @@ dissect_smb2_cancel_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
        return offset;
 }
 
+static void
+smb2_set_dcerpc_file_id(packet_info *pinfo, smb2_info_t *si)
+{
+       guint64 persistent;
+
+       if (si == NULL) {
+               return;
+       }
+       if (si->file == NULL) {
+               return;
+       }
+
+       persistent = GPOINTER_TO_UINT(si->file);
+
+       dcerpc_set_transport_salt(persistent, pinfo);
+}
 
 static int
-dissect_file_data_dcerpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, int offset, guint32 datalen, proto_tree *top_tree)
+dissect_file_data_dcerpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, int offset, guint32 datalen, proto_tree *top_tree, void *data)
 {
        tvbuff_t *dcerpc_tvb;
        heur_dtbl_entry_t *hdtbl_entry;
 
-       dcerpc_tvb = tvb_new_subset(tvb, offset, MIN((int)datalen, tvb_length_remaining(tvb, offset)), datalen);
+       dcerpc_tvb = tvb_new_subset(tvb, offset, MIN((int)datalen, tvb_captured_length_remaining(tvb, offset)), datalen);
 
        /* dissect the full PDU */
-       dissector_try_heuristic(smb2_heur_subdissector_list, dcerpc_tvb, pinfo, top_tree, &hdtbl_entry, NULL);
-
+       if (dissector_try_heuristic(smb2_heur_subdissector_list, dcerpc_tvb, pinfo, top_tree, &hdtbl_entry, data)) {
 
-       offset += datalen;
 
+               offset += datalen;
+       }
        return offset;
 }
 
@@ -4141,7 +4599,7 @@ dissect_smb2_write_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
 
        /* data offset */
-       dataoffset=tvb_get_letohl(tvb,offset);
+       dataoffset=tvb_get_letohs(tvb,offset);
        proto_tree_add_item(tree, hf_smb2_data_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset += 2;
 
@@ -4190,17 +4648,22 @@ dissect_smb2_write_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        }
 
        /* data or dcerpc ?*/
-       if (length && si->tree && si->tree->share_type == SMB2_SHARE_TYPE_PIPE) {
-               offset = dissect_file_data_dcerpc(tvb, pinfo, tree, offset, length, si->top_tree);
-               return offset;
+       if (length) {
+               int oldoffset = offset;
+               smb2_set_dcerpc_file_id(pinfo, si);
+               offset = dissect_file_data_dcerpc(tvb, pinfo, tree, offset, length, si->top_tree, si);
+               if (offset != oldoffset) {
+                       /* managed to dissect pipe data */
+                       return offset;
+               }
        }
 
        /* just ordinary data */
        proto_tree_add_item(tree, hf_smb2_write_data, tvb, offset, length, ENC_NA);
 
-       data_tvb_len=(guint32)tvb_length_remaining(tvb, offset);
+       data_tvb_len=(guint32)tvb_captured_length_remaining(tvb, offset);
 
-       offset += MIN(length,(guint32)tvb_length_remaining(tvb, offset));
+       offset += MIN(length,(guint32)tvb_captured_length_remaining(tvb, offset));
 
        offset = dissect_smb2_olb_tvb_max_offset(offset, &c_olb);
 
@@ -4249,9 +4712,126 @@ dissect_smb2_write_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
 }
 
 static void
-dissect_smb2_FSCTL_PIPE_TRANSCEIVE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *top_tree, gboolean data_in _U_)
+dissect_smb2_FSCTL_OFFLOAD_READ(tvbuff_t *tvb,
+                               packet_info *pinfo _U_,
+                               proto_tree *tree,
+                               int offset,
+                               proto_tree *top_tree _U_,
+                               gboolean in)
+{
+       proto_tree_add_item(tree, hf_smb2_fsctl_offload_read_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
+
+       proto_tree_add_item(tree, hf_smb2_fsctl_offload_read_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
+
+       if (in) {
+               proto_tree_add_item(tree, hf_smb2_fsctl_offload_read_token_ttl, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+               offset += 4;
+
+               proto_tree_add_item(tree, hf_smb2_fsctl_offload_reserved, tvb, offset, 4, ENC_NA);
+               offset += 4;
+
+               proto_tree_add_item(tree, hf_smb2_fsctl_offload_read_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+               offset += 8;
+
+               proto_tree_add_item(tree, hf_smb2_fsctl_offload_read_copy_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+               /* offset += 8; */
+       } else {
+               proto_tree_add_item(tree, hf_smb2_fsctl_offload_read_transfer_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+               offset += 8;
+
+               proto_tree_add_item(tree, hf_smb2_fsctl_offload_token, tvb, offset, 512, ENC_NA);
+               /* offset += 512; */
+       }
+}
+
+static void
+dissect_smb2_FSCTL_PIPE_TRANSCEIVE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *top_tree, gboolean data_in _U_, void *data)
+{
+       dissect_file_data_dcerpc(tvb, pinfo, tree, offset, tvb_captured_length_remaining(tvb, offset), top_tree, data);
+}
+
+static void
+dissect_smb2_FSCTL_PIPE_WAIT(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, int offset, proto_tree *top_tree, gboolean data_in _U_)
+{
+       guint8 timeout_specified = tvb_get_guint8(tvb, offset + 12);
+       guint32 name_len = tvb_get_letohs(tvb, offset + 8);
+       const gchar *name;
+       int off = offset + 14;
+       guint16 bc = tvb_captured_length_remaining(tvb, off);
+       int len = name_len;
+
+       /* sanity check */
+       tvb_ensure_bytes_exist(tvb, off, name_len);
+
+       name = get_unicode_or_ascii_string(tvb, &off, TRUE, &len, TRUE, TRUE, &bc);
+       if (name == NULL) {
+               name = "";
+       }
+
+       col_append_fstr(pinfo->cinfo, COL_INFO, " Pipe: %s", name);
+
+       if (top_tree) {
+               proto_tree_add_string(top_tree, hf_smb2_fsctl_pipe_wait_name, tvb, offset + 14, name_len, name);
+               if (timeout_specified) {
+                       proto_tree_add_item(top_tree, hf_smb2_fsctl_pipe_wait_timeout, tvb, 0, 8, ENC_LITTLE_ENDIAN);
+               }
+       }
+}
+
+static void
+dissect_smb2_FSCTL_QUERY_FILE_REGIONS(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int offset _U_, gboolean data_in)
 {
-       dissect_file_data_dcerpc(tvb, pinfo, tree, offset, tvb_length_remaining(tvb, offset), top_tree);
+
+       if (data_in) {
+               proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+               offset += 8;
+
+               proto_tree_add_item(tree, hf_smb2_qfr_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+               offset += 8;
+
+               proto_tree_add_item(tree, hf_smb2_qfr_usage, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+               offset += 4;
+
+               proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
+               offset += 4;
+       } else {
+               guint32 entry_count = 0;
+
+               proto_tree_add_item(tree, hf_smb2_qfr_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+               offset += 4;
+
+               proto_tree_add_item(tree, hf_smb2_qfr_total_region_entry_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+               offset += 4;
+
+               proto_tree_add_item_ret_uint(tree, hf_smb2_qfr_region_entry_count, tvb, offset, 4, ENC_LITTLE_ENDIAN, &entry_count);
+               offset += 4;
+
+               proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
+               offset += 4;
+
+               while (entry_count && tvb_reported_length_remaining(tvb, offset)) {
+                       proto_tree *sub_tree;
+                       proto_item *sub_item;
+
+                       sub_tree = proto_tree_add_subtree(tree, tvb, offset, 24, ett_qfr_entry, &sub_item, "Entry");
+
+                       proto_tree_add_item(sub_tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+                       offset += 8;
+
+                       proto_tree_add_item(sub_tree, hf_smb2_qfr_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+                       offset += 8;
+
+                       proto_tree_add_item(sub_tree, hf_smb2_qfr_usage, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+                       offset += 4;
+
+                       proto_tree_add_item(sub_tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
+                       offset += 4;
+
+                       entry_count--;
+               }
+       }
 }
 
 static void
@@ -4270,6 +4850,17 @@ dissect_smb2_FSCTL_LMR_REQUEST_RESILIENCY(tvbuff_t *tvb, packet_info *pinfo _U_,
        proto_tree_add_item(tree, hf_smb2_ioctl_resiliency_reserved, tvb, offset, 4, ENC_LITTLE_ENDIAN);
 }
 
+static void
+dissect_smb2_FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int offset _U_, gboolean data_in _U_)
+{
+       /* There is no out data */
+       if (!data_in) {
+               return;
+       }
+
+       /* There is nothing to do here ... */
+}
+
 static void
 dissect_windows_sockaddr_in(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, int len)
 {
@@ -4579,7 +5170,7 @@ dissect_smb2_FSCTL_GET_SHADOW_COPY_DATA(tvbuff_t *tvb, packet_info *pinfo _U_, p
                int len = 0;
                int old_offset = offset;
 
-               bc = tvb_length_remaining(tvb, offset);
+               bc = tvb_captured_length_remaining(tvb, offset);
                name = get_unicode_or_ascii_string(tvb, &offset,
                        TRUE, &len, TRUE, FALSE, &bc);
                proto_tree_add_string(tree, hf_smb2_ioctl_shadow_copy_label, tvb, old_offset, len, name);
@@ -4653,6 +5244,7 @@ dissect_smb2_FSCTL_GET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_
 
        return offset;
 }
+
 static int
 dissect_smb2_FSCTL_SET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
 {
@@ -4669,6 +5261,31 @@ dissect_smb2_FSCTL_SET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_
        return offset;
 }
 
+static int
+dissect_smb2_FSCTL_SET_INTEGRITY_INFORMATION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
+{
+       const int *integrity_flags[] = {
+               &hf_smb2_integrity_flags_enforcement_off,
+               NULL
+       };
+
+       /* There is no out data */
+       if (!data_in) {
+               return offset;
+       }
+
+       proto_tree_add_item(tree, hf_smb2_checksum_algorithm, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+       offset += 2;
+
+       proto_tree_add_item(tree, hf_smb2_integrity_reserved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+       offset += 2;
+
+       proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_integrity_flags, ett_smb2_integrity_flags, integrity_flags, ENC_LITTLE_ENDIAN);
+       offset += 4;
+
+       return offset;
+}
+
 static int
 dissect_smb2_FSCTL_SET_OBJECT_ID(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
 {
@@ -4711,7 +5328,7 @@ dissect_smb2_FSCTL_SET_OBJECT_ID_EXTENDED(tvbuff_t *tvb, packet_info *pinfo _U_,
 }
 
 void
-dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, guint32 ioctl_function, gboolean data_in)
+dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, guint32 ioctl_function, gboolean data_in, void *private_data _U_)
 {
        guint16 dc;
 
@@ -4725,8 +5342,14 @@ dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
                        dissect_get_dfs_referral_data(tvb, pinfo, tree, 0, &dc, TRUE);
                }
                break;
-       case 0x0011c017:
-               dissect_smb2_FSCTL_PIPE_TRANSCEIVE(tvb, pinfo, tree, 0, top_tree, data_in);
+       case 0x00094264: /* FSCTL_OFFLOAD_READ */
+               dissect_smb2_FSCTL_OFFLOAD_READ(tvb, pinfo, tree, 0, top_tree, data_in);
+               break;
+       case 0x0011c017: /* FSCTL_PIPE_TRANSCEIVE */
+               dissect_smb2_FSCTL_PIPE_TRANSCEIVE(tvb, pinfo, tree, 0, top_tree, data_in, private_data);
+               break;
+       case 0x00110018: /* FSCTL_PIPE_WAIT */
+               dissect_smb2_FSCTL_PIPE_WAIT(tvb, pinfo, tree, 0, top_tree, data_in);
                break;
        case 0x001401D4: /* FSCTL_LMR_REQUEST_RESILIENCY */
                dissect_smb2_FSCTL_LMR_REQUEST_RESILIENCY(tvb, pinfo, tree, 0, data_in);
@@ -4756,24 +5379,39 @@ dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
        case 0x0009003C: /* FSCTL_GET_COMPRESSION */
                dissect_smb2_FSCTL_GET_COMPRESSION(tvb, pinfo, tree, 0, data_in);
                break;
+       case 0x00090300: /* FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT */
+               if (!data_in)
+                       dissect_smb2_FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT(tvb, pinfo, tree, 0, dc);
+               break;
+       case 0x00090304: /* FSCTL_SVHDX_SYNC_TUNNEL or response */
+               call_dissector_with_data(rsvd_handle, tvb, pinfo, top_tree, &data_in);
+               break;
        case 0x0009C040: /* FSCTL_SET_COMPRESSION */
                dissect_smb2_FSCTL_SET_COMPRESSION(tvb, pinfo, tree, 0, data_in);
                break;
+       case 0x00090284: /* FSCTL_QUERY_FILE_REGIONS */
+               dissect_smb2_FSCTL_QUERY_FILE_REGIONS(tvb, pinfo, tree, 0, data_in);
+               break;
+       case 0x0009C280: /* FSCTL_SET_INTEGRITY_INFORMATION request or response */
+               dissect_smb2_FSCTL_SET_INTEGRITY_INFORMATION(tvb, pinfo, tree, 0, data_in);
+               break;
        default:
-               proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_length(tvb), ENC_NA);
+               proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_captured_length(tvb), ENC_NA);
        }
 }
 
 static void
 dissect_smb2_ioctl_data_in(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
 {
-       dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, TRUE);
+       smb2_set_dcerpc_file_id(pinfo, si);
+       dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, TRUE, si);
 }
 
 static void
 dissect_smb2_ioctl_data_out(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
 {
-       dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, FALSE);
+       smb2_set_dcerpc_file_id(pinfo, si);
+       dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, FALSE, si);
 }
 
 static int
@@ -5002,19 +5640,21 @@ dissect_smb2_read_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        /* reserved */
        offset += 4;
 
-       /* data or dcerpc ?
-        * If the pidvalid flag is set we assume it is a deferred
-        * STATUS_PENDING read and thus a named pipe (==dcerpc)
-        */
-       if (length && ( (si->tree && si->tree->share_type == SMB2_SHARE_TYPE_PIPE)||(si->flags & SMB2_FLAGS_ASYNC_CMD))) {
-               offset = dissect_file_data_dcerpc(tvb, pinfo, tree, offset, length, si->top_tree);
-               return offset;
+       /* data or dcerpc ?*/
+       if (length) {
+               int oldoffset = offset;
+               smb2_set_dcerpc_file_id(pinfo, si);
+               offset = dissect_file_data_dcerpc(tvb, pinfo, tree, offset, length, si->top_tree, si);
+               if (offset != oldoffset) {
+                       /* managed to dissect pipe data */
+                       return offset;
+               }
        }
 
        /* data */
        proto_tree_add_item(tree, hf_smb2_read_data, tvb, offset, length, ENC_NA);
 
-       data_tvb_len=(guint32)tvb_length_remaining(tvb, offset);
+       data_tvb_len=(guint32)tvb_captured_length_remaining(tvb, offset);
 
        offset += MIN(length,data_tvb_len);
 
@@ -5094,7 +5734,7 @@ dissect_smb2_QFid_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
        }
 
        if (item) {
-               if (tvb_length(tvb) == 0) {
+               if (tvb_reported_length(tvb) == 0) {
                        proto_item_append_text(item, ": NO DATA");
                } else {
                        proto_item_append_text(item, ": QFid request should have no data, malformed packet");
@@ -5267,7 +5907,7 @@ dissect_smb2_MxAc_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
                item = proto_tree_get_parent(tree);
        }
 
-       if (tvb_length(tvb) == 0) {
+       if (tvb_reported_length(tvb) == 0) {
                if (item) {
                        proto_item_append_text(item, ": NO DATA");
                }
@@ -5290,7 +5930,7 @@ dissect_smb2_MxAc_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
 
        item = proto_tree_get_parent(tree);
 
-       if (tvb_length(tvb) == 0) {
+       if (tvb_reported_length(tvb) == 0) {
                proto_item_append_text(item, ": NO DATA");
                return;
        }
@@ -5351,16 +5991,16 @@ dissect_SMB2_CREATE_LEASE_VX(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
 
        parent_item = proto_tree_get_parent(parent_tree);
 
-       len = tvb_length(tvb);
+       len = tvb_reported_length(tvb);
 
        switch (len) {
        case 32: /* SMB2_CREATE_REQUEST/RESPONSE_LEASE */
                proto_item_append_text(parent_item, ": LEASE_V1");
-               sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_smb2_RqLs_buffer, NULL, "LEASE_V1");
+               sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_smb2_RqLs_buffer, NULL, "LEASE_V1");
                break;
        case 52: /* SMB2_CREATE_REQUEST/RESPONSE_LEASE_V2 */
                proto_item_append_text(parent_item, ": LEASE_V2");
-               sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_smb2_RqLs_buffer, NULL, "LEASE_V2");
+               sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_smb2_RqLs_buffer, NULL, "LEASE_V2");
                break;
        default:
                report_create_context_malformed_buffer(tvb, pinfo, parent_tree, "RqLs");
@@ -5422,7 +6062,7 @@ dissect_smb2_APP_INSTANCE_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_,
 
        item = proto_tree_get_parent(tree);
 
-       proto_item_append_text(item, ": APP INSTANCE ID");
+       proto_item_append_text(item, ": CREATE APP INSTANCE ID");
        sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_APP_INSTANCE_buffer, NULL, "APP INSTANCE ID");
 
        /* struct size */
@@ -5511,6 +6151,65 @@ dissect_smb2_svhdx_open_device_context_response(tvbuff_t *tvb, packet_info *pinf
        report_create_context_malformed_buffer(tvb, pinfo, tree, "SHVXD OPEN DEVICE CONTEXT Response");
 }
 
+static const int *posix_flags_fields[] = {
+       &hf_smb2_posix_v1_case_sensitive,
+       &hf_smb2_posix_v1_posix_lock,
+       &hf_smb2_posix_v1_posix_file_semantics,
+       &hf_smb2_posix_v1_posix_utf8_paths,
+       &hf_smb2_posix_v1_posix_will_convert_nt_acls,
+       &hf_smb2_posix_v1_posix_fileinfo,
+       &hf_smb2_posix_v1_posix_acls,
+       &hf_smb2_posix_v1_rich_acls,
+       NULL
+};
+
+static void
+dissect_smb2_posix_v1_caps_request(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
+{
+       int         offset   = 0;
+       proto_item *item;
+       proto_item *sub_tree;
+
+       item = proto_tree_get_parent(tree);
+
+       proto_item_append_text(item, ": POSIX V1 CAPS request");
+       sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_posix_v1_request, NULL, "POSIX_V1_REQUEST");
+
+       /* Version */
+       proto_tree_add_item(sub_tree, hf_smb2_posix_v1_version,
+                           tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
+
+       /* Request */
+       proto_tree_add_item(sub_tree, hf_smb2_posix_v1_request,
+                           tvb, offset, 4, ENC_LITTLE_ENDIAN);
+}
+
+static void
+dissect_smb2_posix_v1_caps_response(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
+{
+       int         offset   = 0;
+       proto_item *item;
+       proto_item *sub_tree;
+
+       item = proto_tree_get_parent(tree);
+
+       proto_item_append_text(item, ": POSIX V1 CAPS response");
+       sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_posix_v1_response, NULL, "POSIX_V1_RESPONSE");
+
+       /* Version */
+       proto_tree_add_item(sub_tree, hf_smb2_posix_v1_version,
+                           tvb, offset, 4, ENC_LITTLE_ENDIAN);
+       offset += 4;
+
+       /* Supported Features */
+       proto_tree_add_bitmask(sub_tree, tvb, offset,
+                              hf_smb2_posix_v1_supported_features,
+                              ett_smb2_posix_v1_supported_features,
+                              posix_flags_fields, ENC_LITTLE_ENDIAN);
+
+}
+
 typedef void (*create_context_data_dissector_t)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si);
 
 typedef struct create_context_data_dissectors {
@@ -5550,9 +6249,15 @@ struct create_context_data_tag_dissectors create_context_dissectors_array[] = {
        { "744D142E-46FA-0890-4AF7-A7EF6AA6BC45", "SMB2_CREATE_APP_INSTANCE_ID",
                { dissect_smb2_APP_INSTANCE_buffer_request,
                  dissect_smb2_APP_INSTANCE_buffer_response } },
+       { "6aa6bc45-a7ef-4af7-9008-fa462e144d74", "SMB2_CREATE_APP_INSTANCE_ID",
+               { dissect_smb2_APP_INSTANCE_buffer_request,
+                 dissect_smb2_APP_INSTANCE_buffer_response } },
        { "9ecfcb9c-c104-43e6-980e-158da1f6ec83", "SVHDX_OPEN_DEVICE_CONTEXT",
                { dissect_smb2_svhdx_open_device_context_request,
-                 dissect_smb2_svhdx_open_device_context_response} }
+                 dissect_smb2_svhdx_open_device_context_response} },
+       { "34263501-2921-4912-2586-447794114531", "SMB2_POSIX_V1_CAPS",
+               { dissect_smb2_posix_v1_caps_request,
+                 dissect_smb2_posix_v1_caps_response } }
 };
 
 static struct create_context_data_tag_dissectors*
@@ -5618,7 +6323,7 @@ dissect_smb2_create_extra_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa
                proto_tree *tag_tree;
 
                tvb_get_letohguid(tvb, tag_olb.off, &tag_guid);
-               tag = guid_to_ep_str(&tag_guid);
+               tag = guid_to_str(wmem_packet_scope(), &tag_guid);
 
                tag_item = proto_tree_add_string(sub_tree, tag_olb.hfindex, tvb, tag_olb.off, tag_olb.len, tag);
                tag_tree = proto_item_add_subtree(tag_item, ett_smb2_olb);
@@ -5632,7 +6337,7 @@ dissect_smb2_create_extra_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa
 
        tag_dissectors = get_create_context_data_tag_dissectors(tag);
 
-       proto_item_append_text(parent_item, " %s", tag);
+       proto_item_append_text(parent_item, " %s", tag_dissectors->val);
        proto_item_append_text(sub_item, ": %s \"%s\"", tag_dissectors->val, tag);
 
        /* data */
@@ -6784,7 +7489,7 @@ dissect_smb2_command(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int of
                offset = (*cmd_dissector)(tvb, pinfo, cmd_tree, offset, si);
        } else {
                proto_tree_add_item(cmd_tree, hf_smb2_unknown, tvb, offset, -1, ENC_NA);
-               offset = tvb_length(tvb);
+               offset = tvb_captured_length(tvb);
        }
 
        proto_item_set_len(cmd_item, offset-old_offset);
@@ -6932,6 +7637,8 @@ dissect_smb2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, gboolea
                        smb2_saved_info_equal_unmatched);
                si->conv->sesids = g_hash_table_new(smb2_sesid_info_hash,
                        smb2_sesid_info_equal);
+               si->conv->fids = g_hash_table_new(smb2_fid_info_hash,
+                       smb2_fid_info_equal);
                si->conv->files = g_hash_table_new(smb2_eo_files_hash,smb2_eo_files_equal);
 
                /* Bit of a hack to avoid leaking the hash tables - register a
@@ -7009,6 +7716,7 @@ dissect_smb2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, gboolea
                                &hf_smb2_flags_async_cmd,
                                &hf_smb2_flags_chained,
                                &hf_smb2_flags_signature,
+                               &hf_smb2_flags_priority_mask,
                                &hf_smb2_flags_dfs_op,
                                &hf_smb2_flags_replay_operation,
                                NULL
@@ -7083,7 +7791,9 @@ dissect_smb2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, gboolea
                                }
                        } else {
                                /* This is a response */
-                               if (ssi) {
+                               if (!((si->flags & SMB2_FLAGS_ASYNC_CMD)
+                                       && si->status == NT_STATUS_PENDING)
+                                       && ssi) {
                                        /* just  set the response frame and move it to the matched table */
                                        ssi->frame_res = pinfo->fd->num;
                                        g_hash_table_remove(si->conv->unmatched, ssi);
@@ -7193,7 +7903,7 @@ dissect_smb2_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, vo
 {
 
        /* must check that this really is a smb2 packet */
-       if (tvb_length(tvb) < 4)
+       if (tvb_captured_length(tvb) < 4)
                return FALSE;
 
        if (((tvb_get_guint8(tvb, 0) != 0xfe) && (tvb_get_guint8(tvb, 0) != 0xfd))
@@ -7305,17 +8015,26 @@ proto_register_smb2(void)
                { &hf_smb2_flags_replay_operation,
                  { "Replay operation", "smb2.flags.replay", FT_BOOLEAN, 32,
                    TFS(&tfs_flags_replay_operation), SMB2_FLAGS_REPLAY_OPERATION, "Whether this is a replay operation", HFILL }},
+               { &hf_smb2_flags_priority_mask,
+                 { "Priority", "smb2.flags.priority_mask", FT_BOOLEAN, 32,
+                   TFS(&tfs_flags_priority_mask), SMB2_FLAGS_PRIORITY_MASK, "Priority Mask", HFILL }},
 
                { &hf_smb2_tree,
                  { "Tree", "smb2.tree", FT_STRING, BASE_NONE,
                    NULL, 0, "Name of the Tree/Share", HFILL }},
+
                { &hf_smb2_filename,
                  { "Filename", "smb2.filename", FT_STRING, BASE_NONE,
                    NULL, 0, "Name of the file", HFILL }},
+
                { &hf_smb2_filename_len,
                  { "Filename Length", "smb2.filename.len", FT_UINT32, BASE_DEC,
                    NULL, 0, "Length of the file name", HFILL }},
 
+               { &hf_smb2_replace_if,
+                 { "Replace If", "smb2.rename.replace_if", FT_BOOLEAN, 8,
+                   TFS(&tfs_replace_if_exists), 0xFF, "Whether to replace if the target exists", HFILL }},
+
                { &hf_smb2_data_offset,
                  { "Data Offset", "smb2.data_offset", FT_UINT16, BASE_HEX,
                    NULL, 0, "Offset to data", HFILL }},
@@ -7359,6 +8078,10 @@ proto_register_smb2(void)
                  { "InfoLevel", "smb2.sec_info.infolevel", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
                    &smb2_sec_info_levels_ext, 0, "Sec_Info Infolevel", HFILL }},
 
+               { &hf_smb2_infolevel_posix_info,
+                 { "InfoLevel", "smb2.posix_info.infolevel", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
+                   &smb2_posix_info_levels_ext, 0, "Posix_Info Infolevel", HFILL }},
+
                { &hf_smb2_write_length,
                  { "Write Length", "smb2.write_length", FT_UINT32, BASE_DEC,
                    NULL, 0, "Amount of data to write", HFILL }},
@@ -7379,6 +8102,26 @@ proto_register_smb2(void)
                  { "File Offset", "smb2.file_offset", FT_UINT64, BASE_DEC,
                    NULL, 0, NULL, HFILL }},
 
+               { &hf_smb2_qfr_length,
+                 { "Length", "smb2.qfr_length", FT_UINT64, BASE_DEC,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_qfr_usage,
+                 { "Desired Usage", "smb2.qfr_usage", FT_UINT32, BASE_HEX,
+                   VALS(file_region_usage_vals), 0, NULL, HFILL }},
+
+               { &hf_smb2_qfr_flags,
+                 { "Flags", "smb2.qfr_flags", FT_UINT32, BASE_HEX,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_qfr_total_region_entry_count,
+                 { "Total Region Entry Count", "smb2.qfr_tot_region_entry_count", FT_UINT32, BASE_HEX,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_qfr_region_entry_count,
+                 { "Region Entry Count", "smb2.qfr_region_entry_count", FT_UINT32, BASE_HEX,
+                   NULL, 0, NULL, HFILL }},
+
                { &hf_smb2_security_blob,
                  { "Security Blob", "smb2.security_blob", FT_BYTES, BASE_NONE,
                    NULL, 0, NULL, HFILL }},
@@ -7676,6 +8419,22 @@ proto_register_smb2(void)
                  { "Next Offset", "smb2.next_offset", FT_UINT32, BASE_DEC,
                    NULL, 0, "Offset to next buffer or 0", HFILL }},
 
+               { &hf_smb2_negotiate_context_type,
+                 { "Type", "smb2.negotiate_context.type", FT_UINT16, BASE_HEX,
+                   VALS(smb2_negotiate_context_types), 0, "NegotiateContext Type", HFILL }},
+
+               { &hf_smb2_negotiate_context_data_length,
+                 { "DataLength", "smb2.negotiate_context.data_length", FT_UINT16, BASE_DEC,
+                   NULL, 0, "NegotiateContext DataLength", HFILL }},
+
+               { &hf_smb2_negotiate_context_offset,
+                 { "NegotiateContextOffset", "smb2.negotiate_context.offset", FT_UINT16, BASE_HEX,
+                   NULL, 0, "NegotiateContext Offset", HFILL }},
+
+               { &hf_smb2_negotiate_context_count,
+                 { "NegotiateContextCount", "smb2.negotiate_context.count", FT_UINT16, BASE_DEC,
+                   NULL, 0, "NegotiateContext Count", HFILL }},
+
                { &hf_smb2_current_time,
                  { "Current Time", "smb2.current_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
                    NULL, 0, "Current Time at server", HFILL }},
@@ -7722,7 +8481,7 @@ proto_register_smb2(void)
 
                { &hf_smb2_buffer_code_len,
                  { "Fixed Part Length", "smb2.buffer_code.length", FT_UINT16, BASE_DEC,
-                   NULL, 0, "Length of fixed portion of PDU", HFILL }},
+                   NULL, 0xFFFE, "Length of fixed portion of PDU", HFILL }},
 
                { &hf_smb2_olb_length,
                  { "Length", "smb2.olb.length", FT_UINT32, BASE_DEC,
@@ -7768,6 +8527,52 @@ proto_register_smb2(void)
                  { "Method", "smb2.ioctl.function.method", FT_UINT32, BASE_HEX,
                    VALS(smb2_ioctl_method_vals), 0x00000003, "Method for Ioctl", HFILL }},
 
+               { &hf_smb2_fsctl_pipe_wait_timeout,
+                 { "Timeout", "smb2.fsctl.wait.timeout", FT_INT64, BASE_DEC,
+                   NULL, 0, "Wait timeout", HFILL }},
+
+               { &hf_smb2_fsctl_pipe_wait_name,
+                 { "Name", "smb2.fsctl.wait.name", FT_STRING, BASE_NONE,
+                   NULL, 0, "Pipe name", HFILL }},
+
+               { &hf_smb2_fsctl_offload_read_size,
+                 { "Size", "smb2.fsctl.offload.read", FT_UINT32, BASE_DEC,
+                   NULL, 0, "Size of data element", HFILL }},
+
+               { &hf_smb2_fsctl_offload_read_flags,
+                 { "Flags", "smb2.fsctl.offload.flags", FT_UINT32, BASE_HEX,
+                   NULL, 0, "Flags for this operation", HFILL }},
+
+               { &hf_smb2_fsctl_offload_read_token_ttl,
+                 { "TokenTimeToLive", "smb2.fsctl.offload.token_ttl",
+                   FT_UINT32, BASE_DEC, NULL, 0,
+                   "TTL for the generated token (in milliseconds)", HFILL }},
+
+               { &hf_smb2_fsctl_offload_reserved,
+                 { "Reserved", "smb2.fsctl.offload.reserved",
+                   FT_BYTES, BASE_NONE, NULL, 0,
+                   NULL, HFILL }},
+
+               { &hf_smb2_fsctl_offload_read_file_offset,
+                 { "FileOffset", "smb2.fsctl.offload.file_offset",
+                   FT_UINT64, BASE_DEC, NULL, 0,
+                   "File offset", HFILL }},
+
+               { &hf_smb2_fsctl_offload_read_copy_length,
+                 { "CopyLength", "smb2.fsctl.offload.copy_length",
+                   FT_UINT64, BASE_DEC, NULL, 0,
+                   "Copy length", HFILL }},
+
+               { &hf_smb2_fsctl_offload_read_transfer_length,
+                 { "TransferLength", "smb2.fsctl.offload.transfer_length",
+                   FT_UINT64, BASE_DEC, NULL, 0,
+                   "Transfer length", HFILL }},
+
+               { &hf_smb2_fsctl_offload_token,
+                 { "Token", "smb2.fsctl.offload.token",
+                   FT_BYTES, BASE_NONE, NULL, 0,
+                   NULL, HFILL }},
+
                { &hf_smb2_ioctl_resiliency_timeout,
                  { "Timeout", "smb2.ioctl.resiliency.timeout", FT_UINT32, BASE_DEC,
                    NULL, 0, "Resiliency timeout", HFILL }},
@@ -7846,6 +8651,22 @@ proto_register_smb2(void)
                  { "Compression Format", "smb2.compression_format", FT_UINT16, BASE_DEC,
                    VALS(compression_format_vals), 0, "Compression to use", HFILL }},
 
+               { &hf_smb2_checksum_algorithm,
+                 { "Checksum Algorithm", "smb2.checksum_algorithm", FT_UINT16, BASE_HEX,
+                   VALS(checksum_algorithm_vals), 0, "Checksum algorithm to use", HFILL}},
+
+               { &hf_smb2_integrity_reserved,
+                 { "Reserved", "smb2.integrity_reserved", FT_UINT16, BASE_DEC,
+                   NULL, 0, "Reserved Field", HFILL}},
+
+               { &hf_smb2_integrity_flags,
+                 { "Flags", "smb2.integrity_flags", FT_UINT32, BASE_HEX,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_integrity_flags_enforcement_off,
+                 { "FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF", "smb2.integrity_flags_enforcement", FT_BOOLEAN, 32,
+                   NULL, 0x1, "If checksum error enforcement is off", HFILL }},
+
                { &hf_smb2_share_type,
                  { "Share Type", "smb2.share_type", FT_UINT8, BASE_HEX,
                    VALS(smb2_share_type_vals), 0, "Type of share", HFILL }},
@@ -8143,6 +8964,19 @@ proto_register_smb2(void)
                  { "Out Data", "smb2.notify.out", FT_NONE, BASE_NONE,
                    NULL, 0, NULL, HFILL }},
 
+               { &hf_smb2_notify_info,
+                 { "Notify Info", "smb2.notify.info", FT_NONE, BASE_NONE,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_notify_next_offset,
+                 { "Next Offset", "smb2.notify.next_offset", FT_UINT32, BASE_HEX,
+                   NULL, 0, "Offset to next entry in chain or 0", HFILL }},
+
+               { &hf_smb2_notify_action,
+                 { "Action", "smb2.notify.action", FT_UINT32, BASE_HEX,
+                   VALS(notify_action_vals), 0, "Notify Action", HFILL }},
+
+
                { &hf_smb2_find_flags_restart_scans,
                  { "Restart Scans", "smb2.find.restart_scans", FT_BOOLEAN, 8,
                    NULL, SMB2_FIND_FLAG_RESTART_SCANS, NULL, HFILL }},
@@ -8231,6 +9065,14 @@ proto_register_smb2(void)
                  { "Reserved", "smb2.reserved", FT_BYTES, BASE_NONE,
                    NULL, 0, "Reserved bytes", HFILL }},
 
+               { &hf_smb2_reserved_random,
+                 { "Reserved (Random)", "smb2.reserved.random", FT_BYTES, BASE_NONE,
+                   NULL, 0, "Reserved bytes, random data", HFILL }},
+
+               { &hf_smb2_root_directory_mbz,
+                 { "Root Dir Handle (MBZ)", "smb2.root_directory", FT_BYTES, BASE_NONE,
+                   NULL, 0, "Root Directory Handle, mbz", HFILL }},
+
                { &hf_smb2_dhnq_buffer_reserved,
                  { "Reserved", "smb2.dhnq_buffer_reserved", FT_UINT64, BASE_HEX,
                    NULL, 0, NULL, HFILL}},
@@ -8303,6 +9145,50 @@ proto_register_smb2(void)
                  { "HostName", "smb2.svhdx_open_device_context.host_name", FT_STRING, BASE_NONE,
                     NULL, 0, NULL, HFILL }},
 
+               { &hf_smb2_posix_v1_version,
+                 { "Version", "smb2.posix_v1_version", FT_UINT32, BASE_DEC,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_request,
+                 { "Request", "smb2.posix_request", FT_UINT32, BASE_HEX,
+                   NULL, 0, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_case_sensitive,
+                 { "Posix Case Sensitive File Names", "smb2.posix_case_sensitive", FT_UINT32, BASE_HEX,
+                   VALS(posix_case_sensitive_vals), 0x01, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_posix_lock,
+                 { "Posix Byte-Range Locks", "smb2.posix_locks", FT_UINT32, BASE_HEX,
+                   VALS(posix_locks_vals), 0x02, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_posix_file_semantics,
+                 { "Posix File Semantics", "smb2.posix_file_semantics", FT_UINT32, BASE_HEX,
+                   VALS(posix_file_semantics_vals), 0x04, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_posix_utf8_paths,
+                 { "Posix UTF8 Paths", "smb2.posix_utf8_paths", FT_UINT32, BASE_HEX,
+                   VALS(posix_utf8_paths_vals), 0x08, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_posix_will_convert_nt_acls,
+                 { "Posix Will Convert NT ACLs", "smb2.will_convert_NTACLs", FT_UINT32, BASE_HEX,
+                   VALS(posix_will_convert_ntacls_vals), 0x10, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_posix_fileinfo,
+                 { "Posix Fileinfo", "smb2.posix_fileinfo", FT_UINT32, BASE_HEX,
+                   VALS(posix_fileinfo_vals), 0x20, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_posix_acls,
+                 { "Posix ACLs", "smb2.posix_acls", FT_UINT32, BASE_HEX,
+                   VALS(posix_acls_vals), 0x40, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_rich_acls,
+                 { "Rich ACLs", "smb2.rich_acls", FT_UINT32, BASE_HEX,
+                   VALS(posix_rich_acls_vals), 0x80, NULL, HFILL }},
+
+               { &hf_smb2_posix_v1_supported_features,
+                 { "Supported Features", "smb2.posix_supported_features", FT_UINT32, BASE_HEX,
+                   NULL, 0, NULL, HFILL }},
+
                { &hf_smb2_transform_signature,
                  { "Signature", "smb2.header.transform.signature", FT_BYTES, BASE_NONE,
                    NULL, 0, NULL, HFILL }},
@@ -8352,6 +9238,7 @@ proto_register_smb2(void)
                &ett_smb2_encrypted,
                &ett_smb2_command,
                &ett_smb2_secblob,
+               &ett_smb2_negotiate_context_element,
                &ett_smb2_file_basic_info,
                &ett_smb2_file_standard_info,
                &ett_smb2_file_internal_info,
@@ -8402,6 +9289,7 @@ proto_register_smb2(void)
                &ett_smb2_ioctl_network_interface,
                &ett_windows_sockaddr,
                &ett_smb2_close_flags,
+               &ett_smb2_notify_info,
                &ett_smb2_notify_flags,
                &ett_smb2_rdma_v1,
                &ett_smb2_write_flags,
@@ -8418,9 +9306,14 @@ proto_register_smb2(void)
                &ett_smb2_dh2x_flags,
                &ett_smb2_APP_INSTANCE_buffer,
                &ett_smb2_svhdx_open_device_context,
+               &ett_smb2_posix_v1_request,
+               &ett_smb2_posix_v1_response,
+               &ett_smb2_posix_v1_supported_features,
+               &ett_smb2_integrity_flags,
                &ett_smb2_transform_enc_alg,
                &ett_smb2_buffercode,
                &ett_smb2_ioctl_network_interface_capabilities,
+               &ett_qfr_entry,
        };
 
        static ei_register_info ei[] = {
@@ -8447,6 +9340,7 @@ proto_register_smb2(void)
        smb2_tap = register_tap("smb2");
        smb2_eo_tap = register_tap("smb_eo"); /* SMB Export Object tap */
 
+       register_srt_table(proto_smb2, NULL, 1, smb2stat_packet, smb2stat_init, NULL);
 }
 
 void
@@ -8454,8 +9348,9 @@ proto_reg_handoff_smb2(void)
 {
        gssapi_handle  = find_dissector("gssapi");
        ntlmssp_handle = find_dissector("ntlmssp");
-       heur_dissector_add("netbios", dissect_smb2_heur, proto_smb2);
-       heur_dissector_add("smb_direct", dissect_smb2_heur, proto_smb2);
+       rsvd_handle    = find_dissector("rsvd");
+       heur_dissector_add("netbios", dissect_smb2_heur, "SMB2 over Netbios", "smb2_netbios", proto_smb2, HEURISTIC_ENABLE);
+       heur_dissector_add("smb_direct", dissect_smb2_heur, "SMB2 over SMB Direct", "smb2_smb_direct", proto_smb2, HEURISTIC_ENABLE);
 }
 
 /*