From Didier Gautheron:
[obnox/wireshark/wip.git] / epan / dissectors / packet-smb2.h
1 /* packet-smb2.h
2  * Defines for SMB2 packet dissection
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998, 1999 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __PACKET_SMB2_H__
26 #define __PACKET_SMB2_H__
27
28 /* SMB2 command codes. With MSVC and a 
29  * libwireshark.dll, we need a special declaration.
30  */
31 WS_VAR_IMPORT const value_string smb2_cmd_vals[];
32
33 /* Structure to keep track of information specific to a single
34  * SMB2 transaction. Here we store things we need to remember between
35  * a specific request and a specific response.
36  * 
37  * There is no guarantee we will have this structure available for all
38  * SMB2 packets so a dissector must check this pointer for NULL
39  * before dereferencing it.
40  *
41  * private data is set to NULL when the structure is created.  It is used
42  * for communications between the Request and the Response packets.
43  */
44 typedef enum {
45         SMB2_EI_NONE,           /* Unassigned / NULL */
46         SMB2_EI_TREENAME,       /* tid tracking  char * */
47         SMB2_EI_FILENAME,       /* fid tracking  char * */
48         SMB2_EI_FINDPATTERN     /* find tracking  char * */
49 } smb2_extra_info_t;
50 typedef struct _smb2_saved_info_t {
51         guint8 class;
52         guint8 infolevel;
53         guint64 seqnum;
54         guint32 frame_req, frame_res;
55         nstime_t req_time;
56         void *extra_info;
57         smb2_extra_info_t extra_info_type;
58 } smb2_saved_info_t;
59
60 typedef struct _smb2_tid_info_t {
61         guint32 tid;
62         guint32 connect_frame;
63         guint16 share_type;
64         char *name;
65 } smb2_tid_info_t;
66
67 typedef struct _smb2_sesid_info_t {
68         guint64 sesid;
69         guint32 auth_frame;
70         char *acct_name;
71         char *domain_name;
72         char *host_name;
73         GHashTable *tids;
74 } smb2_sesid_info_t;
75
76 /* Structure to keep track of conversations and the hash tables.
77  * There is one such structure for each conversation.
78  */
79 typedef struct _smb2_conv_info_t {
80         /* these two tables are used to match requests with responses */
81         GHashTable *unmatched;
82         GHashTable *matched;
83         GHashTable *sesids;
84 } smb2_conv_info_t;
85
86 /* This structure contains information from the SMB2 header
87  * as well as pointers to the conversation and the transaction specific
88  * structures.
89  */
90 #define SMB2_FLAGS_RESPONSE     0x00000001
91 #define SMB2_FLAGS_ASYNC_CMD    0x00000002
92 #define SMB2_FLAGS_CHAINED      0x00000004
93 #define SMB2_FLAGS_SIGNATURE    0x00000008
94 #define SMB2_FLAGS_DFS_OP       0x10000000
95 typedef struct _smb2_info_t {
96         guint16 opcode;
97         guint32 ioctl_function;
98         guint32 status;
99         guint32 tid;
100         guint64 sesid;
101         gint64  seqnum;
102         guint32 flags;
103         smb2_conv_info_t        *conv;
104         smb2_saved_info_t       *saved;
105         smb2_tid_info_t         *tree;
106         smb2_sesid_info_t       *session;
107         proto_tree *top_tree;   
108 } smb2_info_t;
109
110
111 int dissect_smb2_FILE_OBJECTID_BUFFER(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset);
112 int dissect_smb2_ioctl_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 *ioctl_function);
113 void dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, guint32 ioctl_function, gboolean data_in);
114
115 #endif