2 * Copyright 2001, Todd Sabin <tas@webspan.net>
4 * $Id: packet-dcerpc.h,v 1.24 2002/10/25 01:08:42 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
25 #ifndef __PACKET_DCERPC_H__
26 #define __PACKET_DCERPC_H__
28 #include <epan/conversation.h>
30 typedef struct _e_uuid_t {
37 typedef struct _e_ctx_hnd {
42 typedef struct _e_dce_cn_common_hdr_t {
51 } e_dce_cn_common_hdr_t;
53 typedef struct _e_dce_dg_common_hdr_t {
73 } e_dce_dg_common_hdr_t;
85 #define PDU_CL_CANCEL 8
87 #define PDU_CANCEL_ACK 10
89 #define PDU_BIND_ACK 12
90 #define PDU_BIND_NAK 13
92 #define PDU_ALTER_ACK 15
94 #define PDU_SHUTDOWN 17
95 #define PDU_CO_CANCEL 18
96 #define PDU_ORPHANED 19
100 * helpers for packet-dcerpc.c and packet-dcerpc-ndr.c
101 * If you're writing a subdissector, you almost certainly want the
102 * NDR functions below.
104 guint16 dcerpc_tvb_get_ntohs (tvbuff_t *tvb, gint offset, char *drep);
105 guint32 dcerpc_tvb_get_ntohl (tvbuff_t *tvb, gint offset, char *drep);
106 void dcerpc_tvb_get_uuid (tvbuff_t *tvb, gint offset, char *drep, e_uuid_t *uuid);
107 int dissect_dcerpc_uint8 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
108 proto_tree *tree, char *drep,
109 int hfindex, guint8 *pdata);
110 int dissect_dcerpc_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
111 proto_tree *tree, char *drep,
112 int hfindex, guint16 *pdata);
113 int dissect_dcerpc_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
114 proto_tree *tree, char *drep,
115 int hfindex, guint32 *pdata);
116 int dissect_dcerpc_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
117 proto_tree *tree, char *drep,
118 int hfindex, unsigned char *pdata);
119 int dissect_dcerpc_float (tvbuff_t *tvb, gint offset, packet_info *pinfo,
120 proto_tree *tree, char *drep,
121 int hfindex, gfloat *pdata);
122 int dissect_dcerpc_double (tvbuff_t *tvb, gint offset, packet_info *pinfo,
123 proto_tree *tree, char *drep,
124 int hfindex, gdouble *pdata);
125 int dissect_dcerpc_time_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
126 proto_tree *tree, char *drep,
127 int hfindex, guint32 *pdata);
129 * NDR routines for subdissectors.
131 int dissect_ndr_uint8 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
132 proto_tree *tree, char *drep,
133 int hfindex, guint8 *pdata);
134 int dissect_ndr_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
135 proto_tree *tree, char *drep,
136 int hfindex, guint16 *pdata);
137 int dissect_ndr_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
138 proto_tree *tree, char *drep,
139 int hfindex, guint32 *pdata);
140 int dissect_ndr_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
141 proto_tree *tree, char *drep,
142 int hfindex, unsigned char *pdata);
143 int dissect_ndr_float (tvbuff_t *tvb, gint offset, packet_info *pinfo,
144 proto_tree *tree, char *drep,
145 int hfindex, gfloat *pdata);
146 int dissect_ndr_double (tvbuff_t *tvb, gint offset, packet_info *pinfo,
147 proto_tree *tree, char *drep,
148 int hfindex, gdouble *pdata);
149 int dissect_ndr_time_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
150 proto_tree *tree, char *drep,
151 int hfindex, guint32 *pdata);
152 int dissect_ndr_uuid_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
153 proto_tree *tree, char *drep,
154 int hfindex, e_uuid_t *pdata);
155 int dissect_ndr_ctx_hnd (tvbuff_t *tvb, gint offset, packet_info *pinfo,
156 proto_tree *tree, char *drep,
157 int hfindex, e_ctx_hnd *pdata);
160 typedef int (dcerpc_dissect_fnct_t)(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep);
162 #define NDR_POINTER_REF 1
163 #define NDR_POINTER_UNIQUE 2
164 #define NDR_POINTER_PTR 3
166 int dissect_ndr_pointer (tvbuff_t *tvb, gint offset, packet_info *pinfo,
167 proto_tree *tree, char *drep,
168 dcerpc_dissect_fnct_t *fnct, int type, char *text, int hf_index, int levels);
170 /* dissect a NDR unidimensional conformant array */
171 int dissect_ndr_ucarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
172 proto_tree *tree, char *drep,
173 dcerpc_dissect_fnct_t *fnct);
175 /* dissect a NDR unidimensional conformant and varying array */
176 int dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
177 proto_tree *tree, char *drep,
178 dcerpc_dissect_fnct_t *fnct);
182 typedef struct _dcerpc_sub_dissector {
185 dcerpc_dissect_fnct_t *dissect_rqst;
186 dcerpc_dissect_fnct_t *dissect_resp;
187 } dcerpc_sub_dissector;
189 /* registration function for subdissectors */
190 void dcerpc_init_uuid (int proto, int ett, e_uuid_t *uuid, guint16 ver, dcerpc_sub_dissector *procs, int opnum_hf);
191 char *dcerpc_get_proto_name(e_uuid_t *uuid, guint16 ver);
192 dcerpc_sub_dissector *dcerpc_get_proto_sub_dissector(e_uuid_t *uuid, guint16 ver);
195 /* Private data structure to pass to DCERPC dissector. This is used to
196 pass transport specific information down to the dissector from the
197 dissector that parsed this encapsulated calls. */
199 #define DCERPC_TRANSPORT_SMB 1
201 typedef struct _dcerpc_private_info {
202 int transport_type; /* Tag */
205 struct { /* DCERPC_TRANSPORT_SMB */
209 } dcerpc_private_info;
211 /* Private data passed to subdissectors from the main DCERPC dissector. */
212 typedef struct _dcerpc_call_value {
223 typedef struct _dcerpc_info {
224 conversation_t *conv; /* Which TCP stream we are in */
225 guint32 call_id; /* Context id for this call */
226 guint16 smb_fid; /* FID for DCERPC over SMB */
228 gboolean conformant_run;
229 gint32 conformant_eaten; /* how many bytes did the conformant run eat?*/
230 guint32 array_max_count; /* max_count for conformant arrays */
231 guint32 array_max_count_offset;
232 guint32 array_offset;
233 guint32 array_offset_offset;
234 guint32 array_actual_count;
235 guint32 array_actual_count_offset;
237 int levels; /* number of levels upwards in the tree to append text*/
238 dcerpc_call_value *call_data;
243 /* the registered subdissectors */
244 extern GHashTable *dcerpc_uuids;
246 typedef struct _dcerpc_uuid_key {
251 typedef struct _dcerpc_uuid_value {
255 dcerpc_sub_dissector *procs;
260 #endif /* packet-dcerpc.h */