2 * Routines for DCERPC NDR dissection
3 * Copyright 2001, Todd Sabin <tas@webspan.net>
5 * $Id: packet-dcerpc-ndr.c,v 1.4 2002/01/25 08:35:59 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)
53 /* no alignment needed */
54 return dissect_dcerpc_uint8 (tvb, offset, pinfo,
55 tree, drep, hfindex, pdata);
59 dissect_ndr_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
60 proto_tree *tree, char *drep,
61 int hfindex, guint16 *pdata)
66 return dissect_dcerpc_uint16 (tvb, offset, pinfo,
67 tree, drep, hfindex, pdata);
71 dissect_ndr_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
72 proto_tree *tree, char *drep,
73 int hfindex, guint32 *pdata)
76 offset += 4 - (offset % 4);
78 return dissect_dcerpc_uint32 (tvb, offset, pinfo,
79 tree, drep, hfindex, pdata);
83 dissect_ndr_uuid_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
84 proto_tree *tree, char *drep,
85 int hfindex, e_uuid_t *pdata)
89 /* uuid's are aligned to 4 bytes, due to initial uint32 in struct */
91 offset += 4 - (offset % 4);
93 dcerpc_tvb_get_uuid (tvb, offset, drep, &uuid);
95 proto_tree_add_string_format (tree, hfindex, tvb, offset, 16, "",
96 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
97 uuid.Data1, uuid.Data2, uuid.Data3,
98 uuid.Data4[0], uuid.Data4[1],
99 uuid.Data4[2], uuid.Data4[3],
100 uuid.Data4[4], uuid.Data4[5],
101 uuid.Data4[6], uuid.Data4[7]);
111 dissect_ndr_ctx_hnd (tvbuff_t *tvb, gint offset, packet_info *pinfo,
112 proto_tree *tree, char *drep,
113 int hfindex, e_ctx_hnd *pdata)
118 offset += 4 - (offset % 4);
120 ctx_hnd.Data1 = dcerpc_tvb_get_ntohl (tvb, offset, drep);
121 dcerpc_tvb_get_uuid (tvb, offset+4, drep, &ctx_hnd.uuid);
123 proto_tree_add_bytes (tree, hfindex, tvb, offset, 20,
124 tvb_get_ptr (tvb, offset, 20));