2 * Routines for DCERPC NDR dissection
3 * Copyright 2001, Todd Sabin <tas@webspan.net>
5 * $Id: packet-dcerpc-ndr.c,v 1.5 2002/01/29 09:13:28 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 #include <sys/types.h>
38 #include <epan/packet.h>
39 #include "packet-dcerpc.h"
43 * The NDR routines are for use by dcerpc subdissetors. They're
44 * primarily for making sure things are aligned properly according
45 * to the rules of NDR.
49 dissect_ndr_uint8 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
50 proto_tree *tree, char *drep,
51 int hfindex, guint8 *pdata)
55 di=pinfo->private_data;
56 if(di->conformant_run){
57 /* just a run to handle conformant arrays, no scalars to dissect */
61 /* no alignment needed */
62 return dissect_dcerpc_uint8 (tvb, offset, pinfo,
63 tree, drep, hfindex, pdata);
67 dissect_ndr_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
68 proto_tree *tree, char *drep,
69 int hfindex, guint16 *pdata)
73 di=pinfo->private_data;
74 if(di->conformant_run){
75 /* just a run to handle conformant arrays, no scalars to dissect */
83 return dissect_dcerpc_uint16 (tvb, offset, pinfo,
84 tree, drep, hfindex, pdata);
88 dissect_ndr_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
89 proto_tree *tree, char *drep,
90 int hfindex, guint32 *pdata)
94 di=pinfo->private_data;
95 if(di->conformant_run){
96 /* just a run to handle conformant arrays, no scalars to dissect */
102 offset += 4 - (offset % 4);
104 return dissect_dcerpc_uint32 (tvb, offset, pinfo,
105 tree, drep, hfindex, pdata);
109 dissect_ndr_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
110 proto_tree *tree, char *drep,
111 int hfindex, unsigned char *pdata)
115 di=pinfo->private_data;
116 if(di->conformant_run){
117 /* just a run to handle conformant arrays, no scalars to dissect */
122 offset += 4 - (offset % 4);
124 return dissect_dcerpc_uint64 (tvb, offset, pinfo,
125 tree, drep, hfindex, pdata);
129 dissect_ndr_uuid_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
130 proto_tree *tree, char *drep,
131 int hfindex, e_uuid_t *pdata)
136 di=pinfo->private_data;
137 if(di->conformant_run){
138 /* just a run to handle conformant arrays, no scalars to dissect */
142 /* uuid's are aligned to 4 bytes, due to initial uint32 in struct */
144 offset += 4 - (offset % 4);
146 dcerpc_tvb_get_uuid (tvb, offset, drep, &uuid);
148 proto_tree_add_string_format (tree, hfindex, tvb, offset, 16, "",
149 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
150 uuid.Data1, uuid.Data2, uuid.Data3,
151 uuid.Data4[0], uuid.Data4[1],
152 uuid.Data4[2], uuid.Data4[3],
153 uuid.Data4[4], uuid.Data4[5],
154 uuid.Data4[6], uuid.Data4[7]);
164 dissect_ndr_ctx_hnd (tvbuff_t *tvb, gint offset, packet_info *pinfo,
165 proto_tree *tree, char *drep,
166 int hfindex, e_ctx_hnd *pdata)
171 di=pinfo->private_data;
172 if(di->conformant_run){
173 /* just a run to handle conformant arrays, no scalars to dissect */
178 offset += 4 - (offset % 4);
180 ctx_hnd.Data1 = dcerpc_tvb_get_ntohl (tvb, offset, drep);
181 dcerpc_tvb_get_uuid (tvb, offset+4, drep, &ctx_hnd.uuid);
183 proto_tree_add_bytes (tree, hfindex, tvb, offset, 20,
184 tvb_get_ptr (tvb, offset, 20));