MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-dcom-remact.c
blobb44c8e65cf7ce0a9c8ec28515c14a83293ee5651
1 /* packet-dcom-remact.c
2 * Routines for DCOM Remote Activation
3 * Copyright 2001, Todd Sabin <tas@webspan.net>
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /* see packet-dcom.c for details about DCOM */
28 #include "config.h"
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include "packet-dcerpc.h"
33 #include "packet-dcom.h"
36 void proto_register_dcom_remact(void);
37 void proto_reg_handoff_dcom_remact(void);
39 static int hf_remact_opnum = -1;
41 static int hf_remact_requested_protseqs = -1;
42 static int hf_remact_protseqs = -1;
43 static int hf_remact_interfaces = -1;
44 static int hf_remact_mode = -1;
45 static int hf_remact_client_impl_level = -1;
46 static int hf_remact_object_name = -1;
47 static int hf_remact_object_storage = -1;
48 static int hf_remact_interface_data = -1;
50 static int hf_remact_oxid_bindings = -1;
51 static int hf_remact_authn_hint = -1;
54 static int proto_remact = -1;
55 static gint ett_remact = -1;
56 static e_uuid_t uuid_remact = { 0x4d9f4ab8, 0x7d1c, 0x11cf, { 0x86, 0x1e, 0x00, 0x20, 0xaf, 0x6e, 0x7c, 0x57 } };
57 static guint16 ver_remact = 0;
60 static int
61 dissect_remact_remote_activation_rqst(tvbuff_t *tvb, int offset,
62 packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
64 guint32 u32ClientImpLevel;
65 guint32 u32Mode;
66 guint32 u32Interfaces;
67 guint32 u32Pointer;
68 guint32 u32ArraySize;
69 guint32 u32ItemIdx;
70 guint16 u16ProtSeqs;
71 e_uuid_t clsid;
72 e_uuid_t iid;
74 gchar szObjName[1000] = { 0 };
75 guint32 u32ObjNameLen = sizeof(szObjName);
77 offset = dissect_dcom_this(tvb, offset, pinfo, tree, di, drep);
79 offset = dissect_dcom_append_UUID(tvb, offset, pinfo, tree, di, drep,
80 hf_dcom_clsid, -1, &clsid);
82 offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, di, drep,
83 &u32Pointer);
84 if (u32Pointer) {
85 offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, di, drep,
86 hf_remact_object_name, szObjName, u32ObjNameLen);
89 offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, di, drep,
90 hf_remact_object_storage, NULL /* XXX */);
92 offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, di, drep,
93 hf_remact_client_impl_level, &u32ClientImpLevel);
94 offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, di, drep,
95 hf_remact_mode, &u32Mode);
97 /* Interfaces */
98 offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, di, drep,
99 hf_remact_interfaces, &u32Interfaces);
100 offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, di, drep,
101 &u32Pointer);
102 if (u32Pointer) {
103 offset = dissect_dcom_dcerpc_array_size(tvb, offset, pinfo, tree, di, drep,
104 &u32ArraySize);
105 u32ItemIdx = 1;
106 while (u32Interfaces--) {
107 offset = dissect_dcom_append_UUID(tvb, offset, pinfo, tree, di, drep,
108 hf_dcom_iid, u32ItemIdx, &iid);
110 u32ItemIdx++;
114 offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, di, drep,
115 hf_remact_requested_protseqs, &u16ProtSeqs);
117 offset = dissect_dcom_dcerpc_array_size(tvb, offset, pinfo, tree, di, drep,
118 &u32ArraySize);
119 u32ItemIdx = 1;
120 while (u32ArraySize--) {
121 offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, di, drep,
122 hf_remact_protseqs, &u16ProtSeqs);
123 u32ItemIdx++;
126 return offset;
130 static int
131 dissect_remact_remote_activation_resp(tvbuff_t *tvb, int offset,
132 packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
134 guint32 u32Pointer;
135 e_uuid_t ipid;
136 guint32 u32AuthnHint;
137 guint16 u16VersionMajor;
138 guint16 u16VersionMinor;
139 guint32 u32HResult;
140 guint32 u32ArraySize;
141 guint32 u32Idx;
142 guint32 u32VariableOffset;
145 offset = dissect_dcom_that(tvb, offset, pinfo, tree, di, drep);
147 offset = dissect_dcom_ID(tvb, offset, pinfo, tree, di, drep,
148 hf_dcom_oxid, NULL);
149 offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, di, drep,
150 &u32Pointer);
151 if (u32Pointer) {
152 offset = dissect_dcom_dcerpc_array_size(tvb, offset, pinfo, tree, di, drep,
153 &u32ArraySize);
154 offset = dissect_dcom_DUALSTRINGARRAY(tvb, offset, pinfo, tree, di, drep,
155 hf_remact_oxid_bindings, NULL);
158 offset = dissect_dcom_UUID(tvb, offset, pinfo, tree, di, drep,
159 hf_dcom_ipid, &ipid);
160 offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, di, drep,
161 hf_remact_authn_hint, &u32AuthnHint);
162 offset = dissect_dcom_COMVERSION(tvb, offset, pinfo, tree, di, drep,
163 &u16VersionMajor, &u16VersionMinor);
165 offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, di, drep,
166 &u32HResult);
168 offset = dissect_dcom_dcerpc_array_size(tvb, offset, pinfo, tree, di, drep,
169 &u32ArraySize);
170 u32VariableOffset = offset + u32ArraySize * 4;
171 while (u32ArraySize--) {
172 offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, di, drep,
173 &u32Pointer);
174 if (u32Pointer) {
175 u32VariableOffset = dissect_dcom_MInterfacePointer(tvb, u32VariableOffset, pinfo, tree, di, drep,
176 hf_remact_interface_data, NULL /* XXX */);
179 offset = u32VariableOffset;
181 offset = dissect_dcom_dcerpc_array_size(tvb, offset, pinfo, tree, di, drep,
182 &u32ArraySize);
183 u32Idx = 1;
184 while (u32ArraySize--) {
185 offset = dissect_dcom_indexed_HRESULT(tvb, offset, pinfo, tree, di, drep,
186 &u32HResult, u32Idx);
187 /* update column info now */
188 col_append_fstr(pinfo->cinfo, COL_INFO, " %s[%u]",
189 val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)"),
190 u32Idx);
191 u32Idx++;
194 offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, di, drep,
195 &u32HResult);
197 /* update column info now */
198 col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s",
199 val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)"));
201 return offset;
205 static dcerpc_sub_dissector remact_dissectors[] = {
206 { 0, "RemoteActivation", dissect_remact_remote_activation_rqst, dissect_remact_remote_activation_resp },
207 { 0, NULL, NULL, NULL },
211 void
212 proto_register_remact (void)
214 static hf_register_info hf_remact[] = {
215 { &hf_remact_opnum,
216 { "Operation", "remact.opnum", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
218 { &hf_remact_requested_protseqs,
219 { "RequestedProtSeqs", "remact.req_prot_seqs", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
220 { &hf_remact_protseqs,
221 { "ProtSeqs", "remact.prot_seqs", FT_UINT16, BASE_DEC, VALS(dcom_protseq_vals), 0x0, NULL, HFILL }},
222 { &hf_remact_interfaces,
223 { "Interfaces", "remact.interfaces", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
224 { &hf_remact_mode,
225 { "Mode", "remact.mode", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
226 { &hf_remact_client_impl_level,
227 { "ClientImplLevel", "remact.client_impl_level", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
228 { &hf_remact_object_name,
229 { "ObjectName", "remact.object_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
230 { &hf_remact_object_storage,
231 { "ObjectStorage", "remact.object_storage", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
232 { &hf_remact_interface_data,
233 { "InterfaceData", "remact.interface_data", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
235 { &hf_remact_oxid_bindings,
236 { "OxidBindings", "remact.oxid_bindings", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
237 { &hf_remact_authn_hint,
238 { "AuthnHint", "remact.authn_hint", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
241 static gint *ett[] = {
242 &ett_remact
245 proto_remact = proto_register_protocol ("DCOM IRemoteActivation", "REMACT", "remact");
246 proto_register_field_array (proto_remact, hf_remact, array_length (hf_remact));
247 proto_register_subtree_array (ett, array_length (ett));
250 void
251 proto_reg_handoff_remact (void)
253 /* Register the protocol as dcerpc */
254 dcerpc_init_uuid (proto_remact, ett_remact, &uuid_remact, ver_remact, remact_dissectors, hf_remact_opnum);